[monorepo][m] - remove nx from simple-example

This commit is contained in:
Luccas Mateus de Medeiros Gomes 2023-04-24 08:06:45 -03:00
parent 6e90f1897b
commit 1a1a485927
13 changed files with 5330 additions and 215 deletions

View File

@ -1,25 +1,18 @@
This is a repo intended to serve as a simple example of a data catalog that get its data from a series of github repos, you can init an example just like this one by.
- Cloning the PortalJS repo on your machine
```
git clone https://github.com/datopian/portaljs.git
```
- Creating a new file inside the `examples` folder with `create-next-app` like so:
- Creating a new project with `create-next-app` like so:
```
npx create-next-app <app-name> --example https://github.com/datopian/portaljs/tree/main/ --example-path examples/simple-example
```
- Inside `<app-name>` go to the `project.json` file and replace all instances of `simple-example` with `<app-name>`
- Create a `.env` file with the following content
- Install dependencies
```
PROJECT_NAME=<app-name>
npm install
```
- This project uses the github api, which for anonymous users will cap at 50 requests per hour, so you might want to get a [Personal Access Token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token) and add it to your .env file like so
- This project uses the github api, which for anonymous users will cap at 50 requests per hour, so you might want to get a [Personal Access Token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token) and add it to a `.env` file inside the folder like so
```
GITHUB_PAT=<github token>
@ -29,10 +22,10 @@ GITHUB_PAT=<github token>
- Run the app using:
```
nx serve <app-name>
npm run dev
```
Congratulations, you now have something similar to this running on `http://localhost:4200`
Congratulations, you now have something similar to this running on `http://localhost:3000`
![](https://i.imgur.com/jAljJ9C.png)
If yo go to any one of those pages by clicking on `More info` you will see something similar to this
![](https://i.imgur.com/AoJd4O0.png)

View File

@ -1,11 +0,0 @@
/* eslint-disable */
export default {
displayName: 'simple-example',
preset: '../../jest.preset.js',
transform: {
'^(?!.*\\.(js|jsx|ts|tsx|css|json)$)': '@nrwl/react/plugins/jest',
'^.+\\.[tj]sx?$': ['babel-jest', { presets: ['@nrwl/next/babel'] }],
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
coverageDirectory: '../../coverage/examples/simple-example',
};

View File

@ -1,9 +1,3 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { withNx } = require('@nrwl/next/plugins/with-nx');
/**
* @type {import('@nrwl/next/plugins/with-nx').WithNxOptions}
**/
const nextConfig = {
async rewrites() {
return {
@ -17,13 +11,7 @@ const nextConfig = {
},
serverRuntimeConfig: {
github_pat: process.env.GITHUB_PAT ? process.env.GITHUB_PAT : null,
project_name: process.env.PROJECT_NAME ? process.env.PROJECT_NAME : 'simple-example'
},
nx: {
// Set this to true if you would like to use SVGR
// See: https://github.com/gregberge/svgr
svgr: true,
},
};
module.exports = withNx(nextConfig);
module.exports = nextConfig;

5273
examples/simple-example/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,31 @@
{
"name": "simple-example",
"version": "1.0.0",
"description": "",
"author": "",
"license": "ISC"
"name": "my-app",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"@types/node": "18.16.0",
"@types/react": "18.0.38",
"@types/react-dom": "18.0.11",
"eslint": "8.39.0",
"eslint-config-next": "13.3.1",
"next": "13.3.1",
"next-seo": "^6.0.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-markdown": "^8.0.7",
"remark-gfm": "^3.0.1",
"typescript": "5.0.4"
},
"devDependencies": {
"@tailwindcss/typography": "^0.5.9",
"autoprefixer": "^10.4.14",
"postcss": "^8.4.23",
"tailwindcss": "^3.3.1"
}
}

View File

@ -61,10 +61,9 @@ export default function ProjectPage({ project }) {
// Generates `/posts/1` and `/posts/2`
export async function getStaticPaths() {
const project_name = getConfig().serverRuntimeConfig.project_name;
const jsonDirectory = path.join(
process.cwd(),
`/examples/${project_name}/datasets.json`
'datasets.json'
);
const repos = await fs.readFile(jsonDirectory, 'utf8');
@ -89,10 +88,9 @@ export async function getStaticPaths() {
}
export async function getStaticProps({ params }) {
const project_name = getConfig().serverRuntimeConfig.project_name;
const jsonDirectory = path.join(
process.cwd(),
`/examples/${project_name}/datasets.json`
'datasets.json'
);
const reposFile = await fs.readFile(jsonDirectory, 'utf8');
const repos: GithubProject[] = JSON.parse(reposFile);

View File

@ -4,10 +4,9 @@ import { getProject } from '../lib/octokit';
import getConfig from 'next/config';
export async function getStaticProps() {
const project_name = getConfig().serverRuntimeConfig.project_name;
const jsonDirectory = path.join(
process.cwd(),
`/examples/${project_name}/datasets.json`
'/datasets.json'
);
const repos = await fs.readFile(jsonDirectory, 'utf8');
const github_pat = getConfig().serverRuntimeConfig.github_pat;

View File

@ -1,15 +1,6 @@
const { join } = require('path');
// Note: If you use library-specific PostCSS/Tailwind configuration then you should remove the `postcssConfig` build
// option from your application's configuration (i.e. project.json).
//
// See: https://nx.dev/guides/using-tailwind-css-in-react#step-4:-applying-configuration-to-libraries
module.exports = {
plugins: {
tailwindcss: {
config: join(__dirname, 'tailwind.config.js'),
},
tailwindcss: {},
autoprefixer: {},
},
};
}

View File

@ -1,69 +0,0 @@
{
"name": "simple-example",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "examples/simple-example",
"projectType": "application",
"targets": {
"build": {
"executor": "@nrwl/next:build",
"outputs": ["{options.outputPath}"],
"defaultConfiguration": "production",
"options": {
"root": "examples/simple-example",
"outputPath": "dist/examples/simple-example"
},
"configurations": {
"development": {
"outputPath": "examples/simple-example"
},
"production": {}
}
},
"serve": {
"executor": "@nrwl/next:server",
"defaultConfiguration": "development",
"options": {
"buildTarget": "simple-example:build",
"dev": true
},
"configurations": {
"development": {
"buildTarget": "simple-example:build:development",
"dev": true
},
"production": {
"buildTarget": "simple-example:build:production",
"dev": false
}
}
},
"export": {
"executor": "@nrwl/next:export",
"options": {
"buildTarget": "simple-example:build:production"
}
},
"test": {
"executor": "@nrwl/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "examples/simple-example/jest.config.ts",
"passWithNoTests": true
},
"configurations": {
"ci": {
"ci": true,
"codeCoverage": true
}
}
},
"lint": {
"executor": "@nrwl/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["examples/simple-example/**/*.{ts,tsx,js,jsx}"]
}
}
},
"tags": []
}

View File

@ -1,11 +0,0 @@
import React from 'react';
import { render } from '@testing-library/react';
import Index from '../pages/index';
describe('Index', () => {
it('should render successfully', () => {
const { baseElement } = render(<Index />);
expect(baseElement).toBeTruthy();
});
});

View File

@ -1,21 +1,15 @@
const { createGlobPatternsForDependencies } = require('@nrwl/react/tailwind');
const { join } = require('path');
/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
"node_modules/@flowershow/core/dist/*.js",
"node_modules/@flowershow/core/*.js",
join(
__dirname,
'{src,pages,components}/**/*!(*.stories|*.spec).{ts,tsx,html}'
),
...createGlobPatternsForDependencies(__dirname),
"./app/**/*.{js,ts,jsx,tsx,mdx}",
"./pages/**/*.{js,ts,jsx,tsx,mdx}",
"./components/**/*.{js,ts,jsx,tsx,mdx}",
],
theme: {
extend: {},
},
plugins: [
require('@tailwindcss/typography'),
require('@tailwindcss/typography')
],
};
}

View File

@ -1,50 +1,20 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"jsx": "preserve",
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"skipLibCheck": true,
"strict": false,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"incremental": true,
"types": [
"jest",
"node"
]
"jsx": "preserve",
"incremental": true
},
"target": "es2020",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"strict": false,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"incremental": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"include": [
"**/*.ts",
"**/*.tsx",
"**/*.js",
"**/*.jsx",
"next-env.d.ts"
],
"exclude": [
"node_modules",
"jest.config.ts",
"src/**/*.spec.ts",
"src/**/*.test.ts"
]
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
}

View File

@ -1,24 +0,0 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"types": ["jest", "node"],
"jsx": "react"
},
"paths": {
"@/*": ["./*"]
},
"include": [
"jest.config.ts",
"src/**/*.test.ts",
"src/**/*.spec.ts",
"src/**/*.test.tsx",
"src/**/*.spec.tsx",
"src/**/*.test.js",
"src/**/*.spec.js",
"src/**/*.test.jsx",
"src/**/*.spec.jsx",
"src/**/*.d.ts"
]
}