cleanup(react): remove cra-to-nx package (#15556)

This commit is contained in:
Leosvel Pérez Espinosa 2023-04-12 17:43:49 +01:00 committed by GitHub
parent d2f855502a
commit 856296431d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
36 changed files with 1 additions and 1073 deletions

View File

@ -104,7 +104,6 @@ jobs:
project:
- e2e-angular-core
- e2e-angular-extensions
- e2e-cra-to-nx
- e2e-cypress
- e2e-detox
- e2e-esbuild
@ -146,8 +145,6 @@ jobs:
codeowners: 'S04SS457V38'
- project: e2e-angular-extensions
codeowners: 'S04SS457V38'
- project: e2e-cra-to-nx
codeowners: 'S04TNCNJG5N'
- project: e2e-cypress
codeowners: 'S04T16BTJJY'
- project: e2e-detox
@ -211,8 +208,6 @@ jobs:
project: e2e-angular-core
- node_version: 16
project: e2e-angular-extensions
- node_version: 16
project: e2e-cra-to-nx
- node_version: 16
project: e2e-cypress
- node_version: 16
@ -261,8 +256,6 @@ jobs:
project: e2e-angular-core
- node_version: 19
project: e2e-angular-extensions
- node_version: 19
project: e2e-cra-to-nx
- node_version: 19
project: e2e-cypress
- node_version: 19

View File

@ -75,7 +75,6 @@ jobs:
project:
- e2e-angular-core
- e2e-angular-extensions
- e2e-cra-to-nx
- e2e-cypress
- e2e-esbuild
- e2e-jest
@ -104,8 +103,6 @@ jobs:
codeowners: 'S04SS457V38'
- project: e2e-angular-extensions
codeowners: 'S04SS457V38'
- project: e2e-cra-to-nx
codeowners: 'S04TNCNJG5N'
- project: e2e-cypress
codeowners: 'S04T16BTJJY'
- project: e2e-esbuild
@ -156,8 +153,6 @@ jobs:
project: e2e-angular-core
- node_version: 16
project: e2e-angular-extensions
- node_version: 16
project: e2e-cra-to-nx
- node_version: 16
project: e2e-cypress
- node_version: 16
@ -200,8 +195,6 @@ jobs:
project: e2e-angular-core
- node_version: 19
project: e2e-angular-extensions
- node_version: 19
project: e2e-cra-to-nx
- node_version: 19
project: e2e-cypress
- node_version: 19

View File

@ -38,8 +38,6 @@ yarn.lock @FrozenPandaz @vsavkin @AgentEnder @jaysoo @JamesHenry
/e2e/react/** @jaysoo @mandarini @xiongemi @ndcunningham
/packages/next/** @ndcunningham @jaysoo @xiongemi
/e2e/next/** @ndcunningham @jaysoo @xiongemi
/packages/cra-to-nx/** @jaysoo @xiongemi @mandarini
/e2e/cra-to-nx/** @jaysoo @xiongemi @mandarini @ndcunningham
/packages/react/plugins/component-testing/** @jaysoo @ndcunningham @barbados-clemens
/packages/react/src/generators/cypress-component-configuration/** @jaysoo @ndcunningham @barbados-clemens
/packages/react/src/generators/component-test/** @jaysoo @ndcunningham @barbados-clemens

View File

@ -4102,14 +4102,6 @@
"isExternal": false,
"disableCollapsible": false
},
{
"id": "cra-to-nx",
"path": "/packages/cra-to-nx",
"name": "cra-to-nx",
"children": [],
"isExternal": false,
"disableCollapsible": false
},
{
"id": "create-nx-plugin",
"path": "/packages/create-nx-plugin",

View File

@ -369,18 +369,6 @@
},
"path": "/packages/angular"
},
"cra-to-nx": {
"githubRoot": "https://github.com/nrwl/nx/blob/master",
"name": "cra-to-nx",
"packageName": "cra-to-nx",
"description": "This package will turn your React app into an Nx workspace. To use this package, your React app must have been generated and kept the structure of Create-React-App, with files generated either in js/jsx or ts/tsx.",
"documents": {},
"root": "/packages/cra-to-nx",
"source": "/packages/cra-to-nx/src",
"executors": {},
"generators": {},
"path": "/packages/cra-to-nx"
},
"create-nx-plugin": {
"githubRoot": "https://github.com/nrwl/nx/blob/master",
"name": "create-nx-plugin",

View File

@ -368,17 +368,6 @@
"root": "/packages/angular",
"source": "/packages/angular/src"
},
{
"description": "This package will turn your React app into an Nx workspace. To use this package, your React app must have been generated and kept the structure of Create-React-App, with files generated either in js/jsx or ts/tsx.",
"documents": [],
"executors": [],
"generators": [],
"githubRoot": "https://github.com/nrwl/nx/blob/master",
"name": "cra-to-nx",
"packageName": "cra-to-nx",
"root": "/packages/cra-to-nx",
"source": "/packages/cra-to-nx/src"
},
{
"description": "This package is used to scaffold a brand-new workspace used to develop an Nx plugin, and sets up a pre-configured plugin with the specified name. The new plugin is created with a default generator, executor, and e2e app.",
"documents": [],

View File

@ -51,13 +51,6 @@
]
}
},
{
"name": "cra-to-nx",
"packageName": "cra-to-nx",
"description": "This package will turn your React app into an Nx workspace. To use this package, your React app must have been generated and kept the structure of Create-React-App, with files generated either in js/jsx or ts/tsx.",
"path": "generated/packages/cra-to-nx.json",
"schemas": { "executors": [], "generators": [] }
},
{
"name": "create-nx-plugin",
"packageName": "create-nx-plugin",

View File

@ -3789,188 +3789,6 @@
}
}
},
{
"name": "cra-to-nx",
"type": "lib",
"data": {
"tags": [],
"root": "packages/cra-to-nx",
"files": [
{
"file": "packages/cra-to-nx/.eslintrc.json",
"hash": "fea46111a20ae8689af46385367f70421bb9b054"
},
{
"file": "packages/cra-to-nx/jest.config.ts",
"hash": "37b4e4bf05b17827dad05d4ca65d0b5560b2b26d"
},
{
"file": "packages/cra-to-nx/package.json",
"hash": "1b3f3cf90b1c769a36dce8d60482151425ee1dbb",
"deps": ["npm:fs-extra", "npm:glob", "nx", "npm:tslib", "npm:yargs"]
},
{
"file": "packages/cra-to-nx/project.json",
"hash": "dc3f4918627106fb30fa6ca4b5b65254006340b6"
},
{
"file": "packages/cra-to-nx/README.md",
"hash": "f42a26370ce356697f654a1a7884e9f0dee483d8"
},
{
"file": "packages/cra-to-nx/src/index.ts",
"hash": "57945b8372ce0231db6dcbef27582ac6b8d36155",
"deps": ["npm:yargs"]
},
{
"file": "packages/cra-to-nx/src/lib/add-craco-commands-to-package-scripts.ts",
"hash": "40af912523cba3658d766d338177dcfcfdd6ae52",
"deps": ["nx"]
},
{
"file": "packages/cra-to-nx/src/lib/add-vite-commands-to-package-scripts.ts",
"hash": "3e6c36e16c8d230f4d3ee9d54f995e0f02181f66",
"deps": ["nx"]
},
{
"file": "packages/cra-to-nx/src/lib/check-for-custom-webpack-setup.ts",
"hash": "b2a19cdb2afc817c8c65cc7d6ac68077034f6964",
"deps": ["nx"]
},
{
"file": "packages/cra-to-nx/src/lib/check-for-uncommitted-changes.ts",
"hash": "192f13715282504b3d1f9e3625ea6494585c9d98"
},
{
"file": "packages/cra-to-nx/src/lib/clean-up-files.ts",
"hash": "6162b76ca472be96100e9b23c4c961696f56564c",
"deps": ["npm:fs-extra", "nx"]
},
{
"file": "packages/cra-to-nx/src/lib/cra-to-nx.ts",
"hash": "a4014fefc9ef13a24425f0434afb5e5d85393368",
"deps": ["npm:fs-extra", "nx"]
},
{
"file": "packages/cra-to-nx/src/lib/read-name-from-package-json.ts",
"hash": "c52be1039a6a4b9a7e4b6764cc5b450a4062535a",
"deps": ["nx"]
},
{
"file": "packages/cra-to-nx/src/lib/rename-js-to-jsx.ts",
"hash": "d3ee6cbcca6ca5e27c2bf4def4ee05e18b5646d2",
"deps": ["npm:glob", "npm:fs-extra"]
},
{
"file": "packages/cra-to-nx/src/lib/setup-e2e-project.ts",
"hash": "f4b8b7cfb1ee4069bf8168a00cc0cfd1f6a990b8",
"deps": ["nx"]
},
{
"file": "packages/cra-to-nx/src/lib/tsconfig-setup.ts",
"hash": "861d12b4cd1f8e604a8b82b945b587549faac81b",
"deps": ["nx"]
},
{
"file": "packages/cra-to-nx/src/lib/write-craco-config.ts",
"hash": "b9c629360abb946e885528beea32362e1abb5be2"
},
{
"file": "packages/cra-to-nx/src/lib/write-vite-config.ts",
"hash": "e096d30e80f38cdba3ba3aef153709aa0a5f4177",
"deps": ["npm:vite"]
},
{
"file": "packages/cra-to-nx/src/lib/write-vite-index-html.ts",
"hash": "28f9d38acac0846339948cbd029a656f632e31a6"
},
{
"file": "packages/cra-to-nx/tsconfig.json",
"hash": "62ebbd946474cea997e774d20fffc4d585c184f3"
},
{
"file": "packages/cra-to-nx/tsconfig.lib.json",
"hash": "89d635c5671f170bd2e0973400ebe8e724f8b5d2"
},
{
"file": "packages/cra-to-nx/tsconfig.spec.json",
"hash": "831ab6481bfec07dac66b6f62828f76f898f0edf"
}
],
"targets": {
"lint": {
"executor": "@nrwl/linter:eslint",
"options": {
"lintFilePatterns": ["packages/cra-to-nx/**/*.ts"]
},
"inputs": [
"default",
"{workspaceRoot}/.eslintrc.json",
"{workspaceRoot}/tools/eslint-rules/**/*"
]
},
"test": {
"executor": "@nrwl/jest:jest",
"outputs": ["{workspaceRoot}/coverage/packages/cra-to-nx"],
"options": {
"jestConfig": "packages/cra-to-nx/jest.config.ts",
"passWithNoTests": true
},
"dependsOn": ["build"],
"inputs": [
"default",
"^production",
"{workspaceRoot}/jest.preset.js"
]
},
"build-base": {
"executor": "@nrwl/js:tsc",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "build/packages/cra-to-nx",
"tsConfig": "packages/cra-to-nx/tsconfig.lib.json",
"packageJson": "packages/cra-to-nx/package.json",
"main": "packages/cra-to-nx/src/index.ts",
"updateBuildableProjectDepsInPackageJson": false,
"assets": [
"packages/cra-to-nx/*.md",
"packages/cra-to-nx/package.json",
{
"input": "",
"glob": "LICENSE",
"output": "/"
}
]
},
"dependsOn": ["^build-base"],
"inputs": ["production", "^production"]
},
"build": {
"executor": "nx:run-commands",
"outputs": ["{workspaceRoot}/build/packages/cra-to-nx"],
"options": {
"commands": [
{
"command": "node ./scripts/chmod build/packages/cra-to-nx/src/index.js"
},
{
"command": "node ./scripts/copy-readme.js cra-to-nx"
}
],
"parallel": false
},
"dependsOn": ["build-base"],
"inputs": ["production", "^production"]
},
"publish": {
"executor": "nx:run-commands",
"options": {
"command": "node tools/scripts/publish.js cra-to-nx {args.ver} {args.tag} {args.local}"
}
}
}
}
},
{
"name": "nx-plugin",
"type": "lib",
@ -15985,117 +15803,6 @@
}
}
},
{
"name": "e2e-cra-to-nx",
"type": "app",
"data": {
"tags": [],
"root": "e2e/cra-to-nx",
"files": [
{
"file": "e2e/cra-to-nx/jest.config.ts",
"hash": "73592b0fba57e66aa78e0ebf69b1840c06fdc972"
},
{
"file": "e2e/cra-to-nx/project.json",
"hash": "64215e11e61b0fbb907abd5872d6407bc9989e32"
},
{
"file": "e2e/cra-to-nx/src/cra-to-nx.test.ts",
"hash": "5487d3a31e3fbead0797de44f41d7a179458e76e",
"deps": ["e2e-utils"]
},
{
"file": "e2e/cra-to-nx/src/files/cra/package.json.txt",
"hash": "8d59d54fb454d4f4c85e655c3753667605faae34"
},
{
"file": "e2e/cra-to-nx/src/files/cra/public/index.html.txt",
"hash": "167a1546d09ba5d784e650dff04a440e11f780ce"
},
{
"file": "e2e/cra-to-nx/src/files/cra/src/App.css.txt",
"hash": "2bea5c1feb26c74edc9bfc20d9c81ee358d37299"
},
{
"file": "e2e/cra-to-nx/src/files/cra/src/App.js.txt",
"hash": "9473b5591975183023403a5c705d41e229ca3025"
},
{
"file": "e2e/cra-to-nx/src/files/cra/src/App.test.js.txt",
"hash": "bc17e7f6c6a3413118bb950cbe9bef5307d2726c"
},
{
"file": "e2e/cra-to-nx/src/files/cra/src/index.css.txt",
"hash": "4f2e20925e1fcecb84161d5c771bb1c8d2df853e"
},
{
"file": "e2e/cra-to-nx/src/files/cra/src/index.js.txt",
"hash": "d9d4b4e819daa0595d40f3797dd5b7e70b77c3e0"
},
{
"file": "e2e/cra-to-nx/src/files/cra/src/setupTests.js.txt",
"hash": "7b0828bfa80fb3c4504510349e22dc4cf5bc0a7b"
},
{
"file": "e2e/cra-to-nx/src/utils.ts",
"hash": "3f6e75b468fc4233897bc7e12692e7487a83289e",
"deps": ["e2e-utils", "npm:fs-extra", "npm:glob"]
},
{
"file": "e2e/cra-to-nx/tsconfig.json",
"hash": "6d5abf84832009a8c70e7a910c49f332bf1f0612"
},
{
"file": "e2e/cra-to-nx/tsconfig.spec.json",
"hash": "1a24bfb0a13536cd17717808ca5609e15def438f"
}
],
"targets": {
"e2e": {
"executor": "nx:run-commands",
"options": {
"commands": [
{
"command": "yarn e2e-start-local-registry"
},
{
"command": "yarn e2e-build-package-publish"
},
{
"command": "nx run-e2e-tests e2e-cra-to-nx"
}
],
"parallel": false
},
"inputs": [
"default",
"^production",
{
"env": "SELECTED_CLI"
},
{
"env": "NX_E2E_CI_CACHE_KEY"
}
]
},
"run-e2e-tests": {
"executor": "@nrwl/jest:jest",
"options": {
"jestConfig": "e2e/cra-to-nx/jest.config.ts",
"passWithNoTests": true,
"runInBand": true
},
"outputs": ["{workspaceRoot}/coverage/e2e/cra-to-nx"],
"inputs": [
"default",
"^production",
"{workspaceRoot}/jest.preset.js"
]
}
}
}
},
{
"name": "e2e-nx-plugin",
"type": "app",
@ -25631,10 +25338,6 @@
"file": "docs/generated/packages/angular.json",
"hash": "9dfbc789bcc954b861b2df7383ad440889bb1719"
},
{
"file": "docs/generated/packages/cra-to-nx.json",
"hash": "2ba8eb96f570f456955153850e842d41613f0dc1"
},
{
"file": "docs/generated/packages/create-nx-plugin.json",
"hash": "4f884c5039f39772dbd59b62c16a00deffde3a5c"
@ -30712,147 +30415,6 @@
},
"dependencies": { "nx-dev-ui-commands:test": [] }
},
"cra-to-nx:lint": {
"roots": ["cra-to-nx:lint"],
"tasks": {
"cra-to-nx:lint": {
"id": "cra-to-nx:lint",
"target": { "project": "cra-to-nx", "target": "lint" },
"projectRoot": "packages/cra-to-nx",
"overrides": {}
}
},
"dependencies": { "cra-to-nx:lint": [] }
},
"cra-to-nx:test": {
"roots": ["graph-client:build-base:release"],
"tasks": {
"cra-to-nx:test": {
"id": "cra-to-nx:test",
"target": { "project": "cra-to-nx", "target": "test" },
"projectRoot": "packages/cra-to-nx",
"overrides": {}
},
"cra-to-nx:build": {
"id": "cra-to-nx:build",
"target": { "project": "cra-to-nx", "target": "build" },
"projectRoot": "packages/cra-to-nx",
"overrides": { "__overrides_unparsed__": [] }
},
"cra-to-nx:build-base": {
"id": "cra-to-nx:build-base",
"target": { "project": "cra-to-nx", "target": "build-base" },
"projectRoot": "packages/cra-to-nx",
"overrides": { "__overrides_unparsed__": [] }
},
"nx:build-base": {
"id": "nx:build-base",
"target": { "project": "nx", "target": "build-base" },
"projectRoot": "packages/nx",
"overrides": { "__overrides_unparsed__": [] }
},
"graph-client:build-base:release": {
"id": "graph-client:build-base:release",
"target": {
"project": "graph-client",
"target": "build-base",
"configuration": "release"
},
"projectRoot": "graph/client",
"overrides": { "__overrides_unparsed__": [] }
}
},
"dependencies": {
"cra-to-nx:test": ["cra-to-nx:build"],
"cra-to-nx:build": ["cra-to-nx:build-base"],
"cra-to-nx:build-base": ["nx:build-base"],
"nx:build-base": ["graph-client:build-base:release"],
"graph-client:build-base:release": []
}
},
"cra-to-nx:build-base": {
"roots": ["graph-client:build-base:release"],
"tasks": {
"cra-to-nx:build-base": {
"id": "cra-to-nx:build-base",
"target": { "project": "cra-to-nx", "target": "build-base" },
"projectRoot": "packages/cra-to-nx",
"overrides": {}
},
"nx:build-base": {
"id": "nx:build-base",
"target": { "project": "nx", "target": "build-base" },
"projectRoot": "packages/nx",
"overrides": { "__overrides_unparsed__": [] }
},
"graph-client:build-base:release": {
"id": "graph-client:build-base:release",
"target": {
"project": "graph-client",
"target": "build-base",
"configuration": "release"
},
"projectRoot": "graph/client",
"overrides": { "__overrides_unparsed__": [] }
}
},
"dependencies": {
"cra-to-nx:build-base": ["nx:build-base"],
"nx:build-base": ["graph-client:build-base:release"],
"graph-client:build-base:release": []
}
},
"cra-to-nx:build": {
"roots": ["graph-client:build-base:release"],
"tasks": {
"cra-to-nx:build": {
"id": "cra-to-nx:build",
"target": { "project": "cra-to-nx", "target": "build" },
"projectRoot": "packages/cra-to-nx",
"overrides": {}
},
"cra-to-nx:build-base": {
"id": "cra-to-nx:build-base",
"target": { "project": "cra-to-nx", "target": "build-base" },
"projectRoot": "packages/cra-to-nx",
"overrides": { "__overrides_unparsed__": [] }
},
"nx:build-base": {
"id": "nx:build-base",
"target": { "project": "nx", "target": "build-base" },
"projectRoot": "packages/nx",
"overrides": { "__overrides_unparsed__": [] }
},
"graph-client:build-base:release": {
"id": "graph-client:build-base:release",
"target": {
"project": "graph-client",
"target": "build-base",
"configuration": "release"
},
"projectRoot": "graph/client",
"overrides": { "__overrides_unparsed__": [] }
}
},
"dependencies": {
"cra-to-nx:build": ["cra-to-nx:build-base"],
"cra-to-nx:build-base": ["nx:build-base"],
"nx:build-base": ["graph-client:build-base:release"],
"graph-client:build-base:release": []
}
},
"cra-to-nx:publish": {
"roots": ["cra-to-nx:publish"],
"tasks": {
"cra-to-nx:publish": {
"id": "cra-to-nx:publish",
"target": { "project": "cra-to-nx", "target": "publish" },
"projectRoot": "packages/cra-to-nx",
"overrides": {}
}
},
"dependencies": { "cra-to-nx:publish": [] }
},
"nx-plugin:test": {
"roots": ["graph-client:build-base:release"],
"tasks": {
@ -35811,30 +35373,6 @@
"typedoc-theme:build-base": []
}
},
"e2e-cra-to-nx:e2e": {
"roots": ["e2e-cra-to-nx:e2e"],
"tasks": {
"e2e-cra-to-nx:e2e": {
"id": "e2e-cra-to-nx:e2e",
"target": { "project": "e2e-cra-to-nx", "target": "e2e" },
"projectRoot": "e2e/cra-to-nx",
"overrides": {}
}
},
"dependencies": { "e2e-cra-to-nx:e2e": [] }
},
"e2e-cra-to-nx:run-e2e-tests": {
"roots": ["e2e-cra-to-nx:run-e2e-tests"],
"tasks": {
"e2e-cra-to-nx:run-e2e-tests": {
"id": "e2e-cra-to-nx:run-e2e-tests",
"target": { "project": "e2e-cra-to-nx", "target": "run-e2e-tests" },
"projectRoot": "e2e/cra-to-nx",
"overrides": {}
}
},
"dependencies": { "e2e-cra-to-nx:run-e2e-tests": [] }
},
"e2e-nx-plugin:e2e": {
"roots": ["e2e-nx-plugin:e2e"],
"tasks": {

View File

@ -1,11 +0,0 @@
/* eslint-disable */
export default {
transform: {
'^.+\\.[tj]sx?$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
maxWorkers: 1,
globals: {},
displayName: 'e2e-cra-to-nx',
preset: '../../jest.preset.js',
};

View File

@ -1,11 +0,0 @@
{
"name": "e2e-cra-to-nx",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "e2e/cra-to-nx",
"projectType": "application",
"targets": {
"e2e": {},
"run-e2e-tests": {}
},
"implicitDependencies": ["cra-to-nx"]
}

View File

@ -1,155 +0,0 @@
import {
checkFilesDoNotExist,
checkFilesExist,
getPackageManagerCommand,
getPublishedVersion,
getSelectedPackageManager,
readFile,
readJson,
runCLI,
runCommand,
updateFile,
} from '@nrwl/e2e/utils';
import { createReactApp } from './utils';
const pmc = getPackageManagerCommand({
packageManager: getSelectedPackageManager(),
});
describe('nx init (for CRA)', () => {
it('should convert to an integrated workspace with craco (webpack)', () => {
const appName = 'my-app';
createReactApp(appName);
const craToNxOutput = runCommand(
`${
pmc.runUninstalledPackage
} nx@${getPublishedVersion()} init --nxCloud=false --integrated --vite=false`
);
expect(craToNxOutput).toContain('🎉 Done!');
const packageJson = readJson('package.json');
expect(packageJson.devDependencies['@nrwl/jest']).toBeDefined();
expect(packageJson.devDependencies['@nrwl/vite']).toBeUndefined();
expect(packageJson.devDependencies['@nrwl/webpack']).toBeDefined();
runCLI(`build ${appName}`, {
env: {
// since craco 7.1.0 the NODE_ENV is used, since the tests set it
// to "test" is causes an issue with React Refresh Babel
NODE_ENV: undefined,
},
});
checkFilesExist(`dist/apps/${appName}/index.html`);
});
it('should convert to an integrated workspace with Vite', () => {
// TODO investigate why this is broken
const originalPM = process.env.SELECTED_PM;
process.env.SELECTED_PM = originalPM === 'pnpm' ? 'yarn' : originalPM;
const appName = 'my-app';
createReactApp(appName);
const craToNxOutput = runCommand(
`${
pmc.runUninstalledPackage
} nx@${getPublishedVersion()} init --nxCloud=false --integrated`
);
expect(craToNxOutput).toContain('🎉 Done!');
const packageJson = readJson('package.json');
expect(packageJson.devDependencies['@nrwl/jest']).toBeUndefined();
expect(packageJson.devDependencies['@nrwl/vite']).toBeDefined();
expect(packageJson.devDependencies['@nrwl/webpack']).toBeUndefined();
const viteConfig = readFile(`apps/${appName}/vite.config.js`);
expect(viteConfig).toContain('port: 4200'); // default port
runCLI(`build ${appName}`);
checkFilesExist(`dist/apps/${appName}/index.html`);
const unitTestsOutput = runCLI(`test ${appName}`);
expect(unitTestsOutput).toContain('Successfully ran target test');
process.env.SELECTED_PM = originalPM;
});
it('should convert to an integrated workspace with Vite with custom port', () => {
// TODO investigate why this is broken
const originalPM = process.env.SELECTED_PM;
process.env.SELECTED_PM = originalPM === 'pnpm' ? 'yarn' : originalPM;
const appName = 'my-app';
createReactApp(appName);
updateFile(`.env`, `NOT_THE_PORT=8000\nPORT=3000\nSOMETHING_ELSE=whatever`);
runCommand(
`${
pmc.runUninstalledPackage
} nx@${getPublishedVersion()} init --nxCloud=false --force --integrated`
);
const viteConfig = readFile(`apps/${appName}/vite.config.js`);
expect(viteConfig).toContain('port: 3000');
const unitTestsOutput = runCLI(`test ${appName}`);
expect(unitTestsOutput).toContain('Successfully ran target test');
process.env.SELECTED_PM = originalPM;
});
it('should convert to a standalone workspace with craco (webpack)', () => {
const appName = 'my-app';
createReactApp(appName);
const craToNxOutput = runCommand(
`${
pmc.runUninstalledPackage
} nx@${getPublishedVersion()} init --nxCloud=false --vite=false`
);
expect(craToNxOutput).toContain('🎉 Done!');
runCLI(`build ${appName}`, {
env: {
// since craco 7.1.0 the NODE_ENV is used, since the tests set it
// to "test" is causes an issue with React Refresh Babel
NODE_ENV: undefined,
},
});
checkFilesExist(`dist/${appName}/index.html`);
});
it('should convert to an standalone workspace with Vite', () => {
const appName = 'my-app';
createReactApp(appName);
const craToNxOutput = runCommand(
`${
pmc.runUninstalledPackage
} nx@${getPublishedVersion()} init --nxCloud=false --vite`
);
expect(craToNxOutput).toContain('🎉 Done!');
checkFilesDoNotExist(
'libs/.gitkeep',
'tools/tsconfig.tools.json',
'babel.config.json',
'jest.preset.js',
'jest.config.ts'
);
const packageJson = readJson('package.json');
expect(packageJson.devDependencies['@nrwl/jest']).toBeUndefined();
const viteConfig = readFile(`vite.config.js`);
expect(viteConfig).toContain('port: 4200'); // default port
runCLI(`build ${appName}`);
checkFilesExist(`dist/${appName}/index.html`);
const unitTestsOutput = runCLI(`test ${appName}`);
expect(unitTestsOutput).toContain('Successfully ran target test');
});
});

View File

@ -1,38 +0,0 @@
{
"name": "<%= appName %>",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "5.16.5",
"@testing-library/react": "13.4.0",
"@testing-library/user-event": "13.5.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
"web-vitals": "2.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}

View File

@ -1,8 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<body>
<div id="root"></div>
</body>
</html>

View File

@ -1,4 +0,0 @@
.App {
text-align: center;
}

View File

@ -1,11 +0,0 @@
import './App.css';
function App() {
return (
<div className="App">
Hello World!
</div>
);
}
export default App;

View File

@ -1,8 +0,0 @@
import { render, screen } from '@testing-library/react';
import App from './App';
test('renders learn react link', () => {
render(<App />);
const linkElement = screen.getByText(/Hello/);
expect(linkElement).toBeInTheDocument();
});

View File

@ -1,5 +0,0 @@
body {
margin: 0;
font-family: sans-serif;
}

View File

@ -1,13 +0,0 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import App from './App';
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
<React.StrictMode>
<App />
</React.StrictMode>
);

View File

@ -1 +0,0 @@
import '@testing-library/jest-dom';

View File

@ -1,62 +0,0 @@
import {
createNonNxProjectDirectory,
getPackageManagerCommand,
getSelectedPackageManager,
runCommand,
tmpProjPath,
updateFile,
updateJson,
} from '../../utils';
import { copySync, renameSync } from 'fs-extra';
import { join } from 'path';
import { sync as globSync } from 'glob';
export function createReactApp(appName: string) {
const pmc = getPackageManagerCommand({
packageManager: getSelectedPackageManager(),
});
createNonNxProjectDirectory();
const projPath = tmpProjPath();
copySync(join(__dirname, 'files/cra'), projPath);
const filesToRename = globSync(join(projPath, '**/*.txt'));
filesToRename.forEach((f) => {
renameSync(f, f.split('.txt')[0]);
});
updateFile('.gitignore', 'node_modules');
updateJson('package.json', (_) => ({
name: appName,
version: '0.1.0',
private: true,
dependencies: {
'@testing-library/jest-dom': '5.16.5',
'@testing-library/react': '13.4.0',
'@testing-library/user-event': '13.5.0',
react: '^18.2.0',
'react-dom': '^18.2.0',
'react-scripts': '5.0.1',
'web-vitals': '2.1.4',
},
scripts: {
start: 'react-scripts start',
build: 'react-scripts build',
test: 'react-scripts test',
eject: 'react-scripts eject',
},
eslintConfig: {
extends: ['react-app', 'react-app/jest'],
},
browserslist: {
production: ['>0.2%', 'not dead', 'not op_mini all'],
development: [
'last 1 chrome version',
'last 1 firefox version',
'last 1 safari version',
],
},
}));
runCommand(pmc.install);
runCommand('git init');
runCommand('git add .');
runCommand('git commit -m "Init"');
}

View File

@ -1,13 +0,0 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"types": ["node", "jest"]
},
"include": [],
"files": [],
"references": [
{
"path": "./tsconfig.spec.json"
}
]
}

View File

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

View File

@ -45,7 +45,6 @@ export function getPackagesSections(items: MenuItem[]): MenuSection[] {
return items
.filter(
(m) =>
m.id !== 'cra-to-nx' &&
m.id !== 'create-nx-plugin' &&
m.id !== 'create-nx-workspace' &&
m.id !== 'make-angular-cli-faster' &&

View File

@ -30,7 +30,6 @@ export function filterMigrationPackages<ItemType extends { name: string }>(
const nxPackageNames = [
'create-nx-workspace',
'create-nx-plugin',
'cra-to-nx',
'make-angular-cli-faster',
'tao',
];

View File

@ -96,7 +96,6 @@ describe('nx-dev: Packages Section', () => {
title: '@nrwl/angular:package',
path: '/packages/angular/executors/package',
},
{ title: 'cra-to-nx', path: '/packages/cra-to-nx' },
{ title: 'create-nx-plugin', path: '/packages/create-nx-plugin' },
{
title: 'create-nx-workspace',

View File

@ -33,7 +33,6 @@ export async function getStaticProps(): Promise<{ props: CommunityProps }> {
const officialPluginList = (nxPackagesApi.getRootPackageIndex() ?? []).filter(
(m) =>
m.name !== 'cra-to-nx' &&
m.name !== 'create-nx-plugin' &&
m.name !== 'create-nx-workspace' &&
m.name !== 'make-angular-cli-faster' &&

View File

@ -507,6 +507,7 @@ const packagesDocuments = {
'/packages/storybook/generators/migrate-7',
'/linter/eslint-plugin-nx': '/packages/linter/documents/eslint-plugin-nx',
'/packages/add-nx-to-monorepo': '/packages/nx/documents/init',
'/packages/cra-to-nx': '/packages/nx/documents/init',
};
/**

View File

@ -1,5 +0,0 @@
{
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"rules": {}
}

View File

@ -1,48 +0,0 @@
# Migrating CRA to Nx
This package will turn your React app into an [Nx workspace](https://nx.dev/) with [Vite](https://vitejs.dev/). To use this package, your React app must have been generated and kept the structure of [Create-React-App](https://reactjs.org/docs/create-a-new-react-app.html), with files generated either in js/jsx or ts/tsx.
## How to use
Go to your CRA React app directory and run the following command:
```
npx nx init
```
Nx will automatically detect that you are in a CRA project and add Nx, Vite, and Vitest for you.
## Ok, it's done, what do I do now?
### Run, build, lint, test
Your previous scripts still work:
```
# Serve and build app with Vite
npm start
npm run build
# Run unit tests with Vitest
npm test
```
### Generate code
Nx comes with code generators to automate repeatable tasks performed on your code.
Take a look at [this guide](https://nx.dev/plugin-features/use-code-generators).
And try generating a library:
```
nx generate lib ui-button
```
### Courses, guides, docs
- [Follow the Nx React tutorial](https://nx.dev/tutorials/react-standalone-tutorial)
- [Free Nx course on Egghead.io](https://egghead.io/playlists/scale-react-development-with-nx-4038)
- Or just use the VS Code Nx Extension, [Nx Console](/core-features/integrate-with-editors) to do all these using a UI.

View File

@ -1,8 +0,0 @@
#!/usr/bin/env node
import { execSync } from 'child_process';
const args = process.argv.slice(2).join(' ');
execSync(`npx --yes nx@latest init ${args}`, {
stdio: [0, 1, 2],
});

View File

@ -1,17 +0,0 @@
/* eslint-disable */
export default {
displayName: 'cra-to-nx',
globals: {},
transform: {
'^.+\\.[tj]sx?$': [
'ts-jest',
{
tsConfig: '<rootDir>/tsconfig.spec.json',
},
],
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
coverageDirectory: '../../coverage/projects/cra-to-nx',
preset: '../../jest.preset.js',
};

View File

@ -1,28 +0,0 @@
{
"name": "cra-to-nx",
"version": "0.0.1",
"private": false,
"description": "This package will turn your React app into an Nx workspace. To use this package, your React app must have been generated and kept the structure of Create-React-App, with files generated either in js/jsx or ts/tsx.",
"repository": {
"type": "git",
"url": "https://github.com/nrwl/nx.git",
"directory": "packages/cra-to-nx"
},
"keywords": [
"Monorepo",
"React",
"Web",
"CLI"
],
"bin": {
"cra-to-nx": "./index.js"
},
"license": "MIT",
"bugs": {
"url": "https://github.com/nrwl/nx/issues"
},
"homepage": "https://nx.dev",
"publishConfig": {
"access": "public"
}
}

View File

@ -1,46 +0,0 @@
{
"name": "cra-to-nx",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "packages/cra-to-nx",
"projectType": "library",
"targets": {
"lint": {},
"test": {},
"build-base": {
"executor": "@nrwl/js:tsc",
"options": {
"main": "packages/cra-to-nx/index.ts",
"assets": [
"packages/cra-to-nx/*.md",
"packages/cra-to-nx/package.json",
{
"input": "",
"glob": "LICENSE",
"output": "/"
}
]
}
},
"build": {
"executor": "nx:run-commands",
"outputs": ["{workspaceRoot}/build/packages/cra-to-nx"],
"options": {
"commands": [
{
"command": "node ./scripts/chmod build/packages/cra-to-nx/index.js"
},
{
"command": "node ./scripts/copy-readme.js cra-to-nx"
}
],
"parallel": false
}
},
"publish": {
"executor": "nx:run-commands",
"options": {
"command": "node tools/scripts/publish.js cra-to-nx {args.ver} {args.tag} {args.local}"
}
}
}
}

View File

@ -1,13 +0,0 @@
{
"extends": "../../tsconfig.base.json",
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
},
{
"path": "./tsconfig.spec.json"
}
]
}

View File

@ -1,12 +0,0 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "commonjs",
"outDir": "../../dist/out-tsc",
"declaration": false,
"types": ["node"],
"sourceMap": false
},
"exclude": ["**/*.spec.ts", "jest.config.ts"],
"include": ["**/*.ts"]
}

View File

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