@nx/workspace 0.0.0-pr-22179-271588f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/README.md +66 -0
- package/executors.json +11 -0
- package/generators.d.ts +5 -0
- package/generators.js +13 -0
- package/generators.json +59 -0
- package/index.d.ts +12 -0
- package/index.js +33 -0
- package/migrations.json +90 -0
- package/package.json +76 -0
- package/presets/core.json +11 -0
- package/presets/npm.json +7 -0
- package/src/core/file-utils.d.ts +1 -0
- package/src/core/file-utils.js +4 -0
- package/src/core/project-graph.d.ts +1 -0
- package/src/core/project-graph.js +4 -0
- package/src/executors/counter/counter.impl.d.ts +12 -0
- package/src/executors/counter/counter.impl.js +40 -0
- package/src/executors/counter/schema.json +20 -0
- package/src/generators/ci-workflow/ci-workflow.d.ts +6 -0
- package/src/generators/ci-workflow/ci-workflow.js +60 -0
- package/src/generators/ci-workflow/files/azure/azure-pipelines.yml__tmpl__ +54 -0
- package/src/generators/ci-workflow/files/bitbucket-pipelines/bitbucket-pipelines.yml__tmpl__ +41 -0
- package/src/generators/ci-workflow/files/circleci/.circleci/config.yml__tmpl__ +33 -0
- package/src/generators/ci-workflow/files/github/.github/workflows/__workflowFileName__.yml__tmpl__ +38 -0
- package/src/generators/ci-workflow/files/gitlab/.gitlab-ci.yml__tmpl__ +24 -0
- package/src/generators/ci-workflow/schema.json +38 -0
- package/src/generators/convert-to-monorepo/convert-to-monorepo.d.ts +3 -0
- package/src/generators/convert-to-monorepo/convert-to-monorepo.js +41 -0
- package/src/generators/convert-to-monorepo/schema.json +16 -0
- package/src/generators/convert-to-nx-project/convert-to-nx-project.d.ts +5 -0
- package/src/generators/convert-to-nx-project/convert-to-nx-project.js +79 -0
- package/src/generators/convert-to-nx-project/schema.d.ts +7 -0
- package/src/generators/convert-to-nx-project/schema.json +38 -0
- package/src/generators/move/lib/check-destination.d.ts +11 -0
- package/src/generators/move/lib/check-destination.js +21 -0
- package/src/generators/move/lib/create-project-configuration-in-new-destination.d.ts +3 -0
- package/src/generators/move/lib/create-project-configuration-in-new-destination.js +54 -0
- package/src/generators/move/lib/extract-base-configs.d.ts +4 -0
- package/src/generators/move/lib/extract-base-configs.js +43 -0
- package/src/generators/move/lib/move-project-files.d.ts +8 -0
- package/src/generators/move/lib/move-project-files.js +60 -0
- package/src/generators/move/lib/normalize-schema.d.ts +3 -0
- package/src/generators/move/lib/normalize-schema.js +183 -0
- package/src/generators/move/lib/run-angular-plugin.d.ts +3 -0
- package/src/generators/move/lib/run-angular-plugin.js +19 -0
- package/src/generators/move/lib/update-build-targets.d.ts +6 -0
- package/src/generators/move/lib/update-build-targets.js +53 -0
- package/src/generators/move/lib/update-cypress-config.d.ts +10 -0
- package/src/generators/move/lib/update-cypress-config.js +40 -0
- package/src/generators/move/lib/update-default-project.d.ts +10 -0
- package/src/generators/move/lib/update-default-project.js +20 -0
- package/src/generators/move/lib/update-eslint-config.d.ts +8 -0
- package/src/generators/move/lib/update-eslint-config.js +33 -0
- package/src/generators/move/lib/update-implicit-dependencies.d.ts +6 -0
- package/src/generators/move/lib/update-implicit-dependencies.js +19 -0
- package/src/generators/move/lib/update-imports.d.ts +8 -0
- package/src/generators/move/lib/update-imports.js +182 -0
- package/src/generators/move/lib/update-jest-config.d.ts +10 -0
- package/src/generators/move/lib/update-jest-config.js +49 -0
- package/src/generators/move/lib/update-package-json.d.ts +8 -0
- package/src/generators/move/lib/update-package-json.js +24 -0
- package/src/generators/move/lib/update-project-root-files.d.ts +12 -0
- package/src/generators/move/lib/update-project-root-files.js +87 -0
- package/src/generators/move/lib/update-readme.d.ts +8 -0
- package/src/generators/move/lib/update-readme.js +21 -0
- package/src/generators/move/lib/update-storybook-config.d.ts +10 -0
- package/src/generators/move/lib/update-storybook-config.js +43 -0
- package/src/generators/move/lib/utils.d.ts +22 -0
- package/src/generators/move/lib/utils.js +49 -0
- package/src/generators/move/move.d.ts +5 -0
- package/src/generators/move/move.js +63 -0
- package/src/generators/move/schema.d.ts +15 -0
- package/src/generators/move/schema.json +59 -0
- package/src/generators/new/files-integrated-repo/__dot__editorconfig +13 -0
- package/src/generators/new/files-integrated-repo/__dot__gitignore +41 -0
- package/src/generators/new/files-integrated-repo/__dot__vscode/extensions.json__tmpl__ +9 -0
- package/src/generators/new/files-integrated-repo/package.json__tmpl__ +14 -0
- package/src/generators/new/files-package-based-repo/__dot__gitignore +41 -0
- package/src/generators/new/files-package-based-repo/__dot__vscode/extensions.json__tmpl__ +8 -0
- package/src/generators/new/files-package-based-repo/package.json__tmpl__ +13 -0
- package/src/generators/new/files-readme/README.md.template +89 -0
- package/src/generators/new/files-root-app/__dot__gitignore +41 -0
- package/src/generators/new/files-root-app/__dot__vscode/extensions.json__tmpl__ +6 -0
- package/src/generators/new/files-root-app/package.json__tmpl__ +17 -0
- package/src/generators/new/generate-preset.d.ts +4 -0
- package/src/generators/new/generate-preset.js +162 -0
- package/src/generators/new/generate-workspace-files.d.ts +3 -0
- package/src/generators/new/generate-workspace-files.js +190 -0
- package/src/generators/new/new.d.ts +30 -0
- package/src/generators/new/new.js +84 -0
- package/src/generators/new/schema.json +92 -0
- package/src/generators/npm-package/files/index.js.template +1 -0
- package/src/generators/npm-package/npm-package.d.ts +9 -0
- package/src/generators/npm-package/npm-package.js +53 -0
- package/src/generators/npm-package/schema.json +31 -0
- package/src/generators/preset/preset.d.ts +4 -0
- package/src/generators/preset/preset.js +301 -0
- package/src/generators/preset/schema.d.ts +22 -0
- package/src/generators/preset/schema.json +109 -0
- package/src/generators/remove/lib/__fixtures__/jest-project.config.d.ts +14 -0
- package/src/generators/remove/lib/__fixtures__/jest-project.config.js +17 -0
- package/src/generators/remove/lib/__fixtures__/jest.config.d.ts +0 -0
- package/src/generators/remove/lib/__fixtures__/jest.config.js +8 -0
- package/src/generators/remove/lib/check-dependencies.d.ts +7 -0
- package/src/generators/remove/lib/check-dependencies.js +23 -0
- package/src/generators/remove/lib/check-project-is-safe-to-remove.d.ts +3 -0
- package/src/generators/remove/lib/check-project-is-safe-to-remove.js +25 -0
- package/src/generators/remove/lib/check-targets.d.ts +10 -0
- package/src/generators/remove/lib/check-targets.js +68 -0
- package/src/generators/remove/lib/remove-project-references-in-config.d.ts +3 -0
- package/src/generators/remove/lib/remove-project-references-in-config.js +21 -0
- package/src/generators/remove/lib/remove-project.d.ts +5 -0
- package/src/generators/remove/lib/remove-project.js +14 -0
- package/src/generators/remove/lib/update-jest-config.d.ts +6 -0
- package/src/generators/remove/lib/update-jest-config.js +75 -0
- package/src/generators/remove/lib/update-tsconfig.d.ts +8 -0
- package/src/generators/remove/lib/update-tsconfig.js +31 -0
- package/src/generators/remove/remove.d.ts +4 -0
- package/src/generators/remove/remove.js +26 -0
- package/src/generators/remove/schema.d.ts +10 -0
- package/src/generators/remove/schema.json +47 -0
- package/src/generators/run-commands/run-commands.d.ts +4 -0
- package/src/generators/run-commands/run-commands.js +25 -0
- package/src/generators/run-commands/schema.d.ts +8 -0
- package/src/generators/run-commands/schema.json +49 -0
- package/src/generators/utils/get-npm-package-version.d.ts +1 -0
- package/src/generators/utils/get-npm-package-version.js +21 -0
- package/src/generators/utils/insert-import.d.ts +2 -0
- package/src/generators/utils/insert-import.js +47 -0
- package/src/generators/utils/insert-statement.d.ts +5 -0
- package/src/generators/utils/insert-statement.js +33 -0
- package/src/generators/utils/jest-config.d.ts +2 -0
- package/src/generators/utils/jest-config.js +13 -0
- package/src/generators/utils/presets.d.ts +29 -0
- package/src/generators/utils/presets.js +34 -0
- package/src/migrations/update-15-7-0/split-configuration-into-project-json-files.d.ts +3 -0
- package/src/migrations/update-15-7-0/split-configuration-into-project-json-files.js +11 -0
- package/src/migrations/update-16-0-0/fix-invalid-babelrc.d.ts +2 -0
- package/src/migrations/update-16-0-0/fix-invalid-babelrc.js +41 -0
- package/src/migrations/update-16-0-0/move-workspace-generators-to-local-plugin.d.ts +2 -0
- package/src/migrations/update-16-0-0/move-workspace-generators-to-local-plugin.js +187 -0
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +2 -0
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +9 -0
- package/src/tasks-runner/cache.d.ts +1 -0
- package/src/tasks-runner/cache.js +5 -0
- package/src/tasks-runner/default-tasks-runner.d.ts +1 -0
- package/src/tasks-runner/default-tasks-runner.js +4 -0
- package/src/tasks-runner/life-cycle.d.ts +1 -0
- package/src/tasks-runner/life-cycle.js +5 -0
- package/src/tasks-runner/life-cycles/dynamic-run-many-terminal-output-life-cycle.d.ts +1 -0
- package/src/tasks-runner/life-cycles/dynamic-run-many-terminal-output-life-cycle.js +4 -0
- package/src/tasks-runner/tasks-runner.d.ts +2 -0
- package/src/tasks-runner/tasks-runner.js +4 -0
- package/src/tasks-runner/utils.d.ts +1 -0
- package/src/tasks-runner/utils.js +4 -0
- package/src/utilities/app-root.d.ts +1 -0
- package/src/utilities/app-root.js +4 -0
- package/src/utilities/default-base.d.ts +1 -0
- package/src/utilities/default-base.js +15 -0
- package/src/utilities/fileutils.d.ts +13 -0
- package/src/utilities/fileutils.js +51 -0
- package/src/utilities/get-import-path.d.ts +3 -0
- package/src/utilities/get-import-path.js +20 -0
- package/src/utilities/output.d.ts +1 -0
- package/src/utilities/output.js +4 -0
- package/src/utilities/ts-config.d.ts +7 -0
- package/src/utilities/ts-config.js +67 -0
- package/src/utilities/typescript/compilation.d.ts +22 -0
- package/src/utilities/typescript/compilation.js +120 -0
- package/src/utilities/typescript/get-source-nodes.d.ts +5 -0
- package/src/utilities/typescript/get-source-nodes.js +21 -0
- package/src/utilities/typescript.d.ts +13 -0
- package/src/utilities/typescript.js +55 -0
- package/src/utils/ast-utils.d.ts +1 -0
- package/src/utils/ast-utils.js +5 -0
- package/src/utils/cli-config-utils.d.ts +16 -0
- package/src/utils/cli-config-utils.js +29 -0
- package/src/utils/lint.d.ts +4 -0
- package/src/utils/lint.js +2 -0
- package/src/utils/output.d.ts +52 -0
- package/src/utils/output.js +133 -0
- package/src/utils/perf-logging.d.ts +1 -0
- package/src/utils/perf-logging.js +10 -0
- package/src/utils/project-type.d.ts +5 -0
- package/src/utils/project-type.js +17 -0
- package/src/utils/versions.d.ts +3 -0
- package/src/utils/versions.js +8 -0
- package/tasks-runners/default.d.ts +1 -0
- package/tasks-runners/default.js +5 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateJestConfig = void 0;
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const jest_config_1 = require("../../utils/jest-config");
|
|
6
|
+
/**
|
|
7
|
+
* Updates the project name and coverage folder in the jest.config.js if it exists
|
|
8
|
+
*
|
|
9
|
+
* (assume relative paths have been updated previously)
|
|
10
|
+
*
|
|
11
|
+
* @param schema The options provided to the schematic
|
|
12
|
+
*/
|
|
13
|
+
function updateJestConfig(tree, schema, project) {
|
|
14
|
+
const jestConfigPath = path.join(schema.relativeToRootDestination, 'jest.config.ts');
|
|
15
|
+
if (tree.exists(jestConfigPath)) {
|
|
16
|
+
const oldContent = tree.read(jestConfigPath, 'utf-8');
|
|
17
|
+
let newContent = oldContent;
|
|
18
|
+
if (schema.projectName !== schema.newProjectName) {
|
|
19
|
+
// ensure both single and double quotes are replaced
|
|
20
|
+
const findName = new RegExp(`'${schema.projectName}'|"${schema.projectName}"|\`${schema.projectName}\``, 'g');
|
|
21
|
+
newContent = oldContent.replace(findName, `'${schema.newProjectName}'`);
|
|
22
|
+
}
|
|
23
|
+
let dirRegex = new RegExp(`\\/${project.root}\\/`, 'g');
|
|
24
|
+
if (dirRegex.test(newContent)) {
|
|
25
|
+
newContent = newContent.replace(dirRegex, `/${schema.relativeToRootDestination}/`);
|
|
26
|
+
}
|
|
27
|
+
dirRegex = new RegExp(`\\/${project.root}['"\`]`, 'g');
|
|
28
|
+
if (dirRegex.test(newContent)) {
|
|
29
|
+
newContent = newContent.replace(dirRegex, `/${schema.relativeToRootDestination}'`);
|
|
30
|
+
}
|
|
31
|
+
dirRegex = new RegExp(`['"\`]${project.root}\\/`, 'g');
|
|
32
|
+
if (dirRegex.test(newContent)) {
|
|
33
|
+
newContent = newContent.replace(dirRegex, `'${schema.relativeToRootDestination}/`);
|
|
34
|
+
}
|
|
35
|
+
tree.write(jestConfigPath, newContent);
|
|
36
|
+
}
|
|
37
|
+
// update root jest.config.ts
|
|
38
|
+
const rootJestConfigPath = (0, jest_config_1.findRootJestConfig)(tree);
|
|
39
|
+
if (!rootJestConfigPath || !tree.exists(rootJestConfigPath)) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const findProject = `'<rootDir>/${project.root}'`;
|
|
43
|
+
const oldRootJestConfigContent = tree.read(rootJestConfigPath, 'utf-8');
|
|
44
|
+
const usingJestProjects = oldRootJestConfigContent.includes('getJestProjects()') ||
|
|
45
|
+
oldRootJestConfigContent.includes('getJestProjectsAsync()');
|
|
46
|
+
const newRootJestConfigContent = oldRootJestConfigContent.replace(findProject, usingJestProjects ? `` : `'<rootDir>/${schema.relativeToRootDestination}'`);
|
|
47
|
+
tree.write(rootJestConfigPath, newRootJestConfigContent);
|
|
48
|
+
}
|
|
49
|
+
exports.updateJestConfig = updateJestConfig;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Tree } from '@nx/devkit';
|
|
2
|
+
import { NormalizedSchema } from '../schema';
|
|
3
|
+
/**
|
|
4
|
+
* Updates the name in the package.json if it exists.
|
|
5
|
+
*
|
|
6
|
+
* @param schema The options provided to the schematic
|
|
7
|
+
*/
|
|
8
|
+
export declare function updatePackageJson(tree: Tree, schema: NormalizedSchema): void;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updatePackageJson = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
/**
|
|
7
|
+
* Updates the name in the package.json if it exists.
|
|
8
|
+
*
|
|
9
|
+
* @param schema The options provided to the schematic
|
|
10
|
+
*/
|
|
11
|
+
function updatePackageJson(tree, schema) {
|
|
12
|
+
if (!schema.importPath) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const packageJsonPath = path.join(schema.relativeToRootDestination, 'package.json');
|
|
16
|
+
if (!tree.exists(packageJsonPath)) {
|
|
17
|
+
// nothing to do
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const packageJson = (0, devkit_1.readJson)(tree, packageJsonPath);
|
|
21
|
+
packageJson.name = schema.importPath;
|
|
22
|
+
tree.write(packageJsonPath, JSON.stringify(packageJson));
|
|
23
|
+
}
|
|
24
|
+
exports.updatePackageJson = updatePackageJson;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ProjectConfiguration, Tree } from '@nx/devkit';
|
|
2
|
+
import { NormalizedSchema } from '../schema';
|
|
3
|
+
/**
|
|
4
|
+
* Updates the files in the root of the project
|
|
5
|
+
*
|
|
6
|
+
* Typically these are config files which point outside of the project folder
|
|
7
|
+
*
|
|
8
|
+
* @param schema The options provided to the schematic
|
|
9
|
+
*/
|
|
10
|
+
export declare function updateProjectRootFiles(tree: Tree, schema: NormalizedSchema, project: ProjectConfiguration): void;
|
|
11
|
+
export declare function updateFilesForRootProjects(tree: Tree, schema: NormalizedSchema, project: ProjectConfiguration): void;
|
|
12
|
+
export declare function updateFilesForNonRootProjects(tree: Tree, schema: NormalizedSchema, project: ProjectConfiguration): void;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateFilesForNonRootProjects = exports.updateFilesForRootProjects = exports.updateProjectRootFiles = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
const path_1 = require("path");
|
|
7
|
+
const allowedExt = ['.ts', '.js', '.json'];
|
|
8
|
+
/**
|
|
9
|
+
* Updates the files in the root of the project
|
|
10
|
+
*
|
|
11
|
+
* Typically these are config files which point outside of the project folder
|
|
12
|
+
*
|
|
13
|
+
* @param schema The options provided to the schematic
|
|
14
|
+
*/
|
|
15
|
+
function updateProjectRootFiles(tree, schema, project) {
|
|
16
|
+
if (project.root === '.') {
|
|
17
|
+
// Need to handle root project differently since replacing '.' with 'dir',
|
|
18
|
+
// for example, // will change '../../' to 'dirdir/dirdir/'.
|
|
19
|
+
updateFilesForRootProjects(tree, schema, project);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
updateFilesForNonRootProjects(tree, schema, project);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.updateProjectRootFiles = updateProjectRootFiles;
|
|
26
|
+
function updateFilesForRootProjects(tree, schema, project) {
|
|
27
|
+
// Skip updating "path" and "extends" for tsconfig files since they are mostly
|
|
28
|
+
// relative to the project root. The only exception is tsconfig.json that
|
|
29
|
+
// should extend from ../../tsconfig.base.json. We'll handle this separately.
|
|
30
|
+
const regex = /(?<!"path".+)(?<!"extends".+)(?<=['"])\.\/(?=[a-zA-Z0-9])/g;
|
|
31
|
+
const newRelativeRoot =
|
|
32
|
+
// Normalize separators
|
|
33
|
+
path
|
|
34
|
+
.relative(path.join(devkit_1.workspaceRoot, schema.relativeToRootDestination), devkit_1.workspaceRoot)
|
|
35
|
+
.split(path.sep)
|
|
36
|
+
// Include trailing slash because the regex matches the trailing slash in "./"
|
|
37
|
+
.join('/') + '/';
|
|
38
|
+
for (const file of tree.children(schema.relativeToRootDestination)) {
|
|
39
|
+
const ext = (0, path_1.extname)(file);
|
|
40
|
+
if (!allowedExt.includes(ext)) {
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
if (file === '.eslintrc.json' || file === 'eslint.config.js') {
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
const oldContent = tree.read((0, path_1.join)(schema.relativeToRootDestination, file), 'utf-8');
|
|
47
|
+
let newContent = oldContent.replace(regex, newRelativeRoot);
|
|
48
|
+
if (file === 'tsconfig.json') {
|
|
49
|
+
// Since we skipped updating "extends" earlier, need to point to the base config.
|
|
50
|
+
newContent = newContent.replace(`./tsconfig.base.json`, newRelativeRoot + `tsconfig.base.json`);
|
|
51
|
+
}
|
|
52
|
+
tree.write((0, path_1.join)(schema.relativeToRootDestination, file), newContent);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.updateFilesForRootProjects = updateFilesForRootProjects;
|
|
56
|
+
function updateFilesForNonRootProjects(tree, schema, project) {
|
|
57
|
+
const newRelativeRoot = path
|
|
58
|
+
.relative(path.join(devkit_1.workspaceRoot, schema.relativeToRootDestination), devkit_1.workspaceRoot)
|
|
59
|
+
.split(path.sep)
|
|
60
|
+
.join('/') + '/';
|
|
61
|
+
const oldRelativeRoot = path
|
|
62
|
+
.relative(path.join(devkit_1.workspaceRoot, project.root), devkit_1.workspaceRoot)
|
|
63
|
+
.split(path.sep)
|
|
64
|
+
.join('/');
|
|
65
|
+
if (newRelativeRoot === oldRelativeRoot) {
|
|
66
|
+
// nothing to do
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
const dots = /\./g;
|
|
70
|
+
const regex = new RegExp(`(?<!\\.\\.\\/)${oldRelativeRoot.replace(dots, '\\.')}\/(?!\\.\\.\\/)`, 'g');
|
|
71
|
+
for (const file of tree.children(schema.relativeToRootDestination)) {
|
|
72
|
+
const ext = (0, path_1.extname)(file);
|
|
73
|
+
if (!allowedExt.includes(ext)) {
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
if (file === '.eslintrc.json' || file === 'eslint.config.js') {
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
const oldContent = tree.read((0, path_1.join)(schema.relativeToRootDestination, file), 'utf-8');
|
|
80
|
+
let newContent = oldContent.replace(regex, newRelativeRoot);
|
|
81
|
+
if (file == 'tsconfig.json') {
|
|
82
|
+
newContent = newContent.replace('tsconfig.json', 'tsconfig.base.json');
|
|
83
|
+
}
|
|
84
|
+
tree.write((0, path_1.join)(schema.relativeToRootDestination, file), newContent);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
exports.updateFilesForNonRootProjects = updateFilesForNonRootProjects;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Tree } from '@nx/devkit';
|
|
2
|
+
import { NormalizedSchema } from '../schema';
|
|
3
|
+
/**
|
|
4
|
+
* Update the README.md file of the project if it exists.
|
|
5
|
+
*
|
|
6
|
+
* @param schema The options provided to the schematic
|
|
7
|
+
*/
|
|
8
|
+
export declare function updateReadme(tree: Tree, schema: NormalizedSchema): void;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateReadme = void 0;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
/**
|
|
6
|
+
* Update the README.md file of the project if it exists.
|
|
7
|
+
*
|
|
8
|
+
* @param schema The options provided to the schematic
|
|
9
|
+
*/
|
|
10
|
+
function updateReadme(tree, schema) {
|
|
11
|
+
const readmePath = (0, path_1.join)(schema.relativeToRootDestination, 'README.md');
|
|
12
|
+
if (!tree.exists(readmePath)) {
|
|
13
|
+
// no README found. nothing to do
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const findName = new RegExp(`${schema.projectName}`, 'g');
|
|
17
|
+
const oldContent = tree.read(readmePath, 'utf-8');
|
|
18
|
+
const newContent = oldContent.replace(findName, schema.newProjectName);
|
|
19
|
+
tree.write(readmePath, newContent);
|
|
20
|
+
}
|
|
21
|
+
exports.updateReadme = updateReadme;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ProjectConfiguration, Tree } from '@nx/devkit';
|
|
2
|
+
import { NormalizedSchema } from '../schema';
|
|
3
|
+
/**
|
|
4
|
+
* Updates relative path to root storybook config for `main.js` & `webpack.config.js`
|
|
5
|
+
*
|
|
6
|
+
* @param {Tree} tree
|
|
7
|
+
* @param {NormalizedSchema} schema The options provided to the schematic
|
|
8
|
+
* @param {ProjectConfiguration} project
|
|
9
|
+
*/
|
|
10
|
+
export declare function updateStorybookConfig(tree: Tree, schema: NormalizedSchema, project: ProjectConfiguration): void;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateStorybookConfig = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
const path_1 = require("path");
|
|
7
|
+
/**
|
|
8
|
+
* Updates relative path to root storybook config for `main.js` & `webpack.config.js`
|
|
9
|
+
*
|
|
10
|
+
* @param {Tree} tree
|
|
11
|
+
* @param {NormalizedSchema} schema The options provided to the schematic
|
|
12
|
+
* @param {ProjectConfiguration} project
|
|
13
|
+
*/
|
|
14
|
+
function updateStorybookConfig(tree, schema, project) {
|
|
15
|
+
const oldRelativeRoot = path
|
|
16
|
+
.relative(path.join(devkit_1.workspaceRoot, `${project.root}/.storybook`), devkit_1.workspaceRoot)
|
|
17
|
+
.split(path.sep)
|
|
18
|
+
.join('/');
|
|
19
|
+
const newRelativeRoot = path
|
|
20
|
+
.relative(path.join(devkit_1.workspaceRoot, `${schema.relativeToRootDestination}/.storybook`), devkit_1.workspaceRoot)
|
|
21
|
+
.split(path.sep)
|
|
22
|
+
.join('/');
|
|
23
|
+
const storybookDir = path.join(schema.relativeToRootDestination, '.storybook');
|
|
24
|
+
if (!storybookDir) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
// Replace relative import path to root storybook folder for each file under project storybook
|
|
28
|
+
updateRecursively(tree, storybookDir, oldRelativeRoot, newRelativeRoot);
|
|
29
|
+
}
|
|
30
|
+
exports.updateStorybookConfig = updateStorybookConfig;
|
|
31
|
+
function updateRecursively(tree, dir, oldRoot, newRoot) {
|
|
32
|
+
for (const child of tree.children(dir)) {
|
|
33
|
+
const childPath = (0, path_1.join)(dir, child);
|
|
34
|
+
if (tree.isFile(childPath)) {
|
|
35
|
+
const oldContent = tree.read(childPath, 'utf-8');
|
|
36
|
+
const newContent = oldContent.replace(oldRoot, newRoot);
|
|
37
|
+
tree.write(childPath, newContent);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
updateRecursively(tree, childPath, oldRoot, newRoot);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ProjectConfiguration, Tree } from '@nx/devkit';
|
|
2
|
+
import { Schema } from '../schema';
|
|
3
|
+
/**
|
|
4
|
+
* This helper function ensures that we don't move libs or apps
|
|
5
|
+
* outside of the folders they should be in.
|
|
6
|
+
*
|
|
7
|
+
* This will break if someone isn't using the default libs/apps
|
|
8
|
+
* folders. In that case, they're on their own :/
|
|
9
|
+
*/
|
|
10
|
+
export declare function getDestination(host: Tree, schema: Schema, project: ProjectConfiguration): string;
|
|
11
|
+
/**
|
|
12
|
+
* Joins path segments replacing slashes with dashes
|
|
13
|
+
*
|
|
14
|
+
* @param path
|
|
15
|
+
*/
|
|
16
|
+
export declare function getNewProjectName(path: string): string;
|
|
17
|
+
/**
|
|
18
|
+
* Normalizes slashes (removes duplicates)
|
|
19
|
+
*
|
|
20
|
+
* @param input
|
|
21
|
+
*/
|
|
22
|
+
export declare function normalizePathSlashes(input: string): string;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizePathSlashes = exports.getNewProjectName = exports.getDestination = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
/**
|
|
6
|
+
* This helper function ensures that we don't move libs or apps
|
|
7
|
+
* outside of the folders they should be in.
|
|
8
|
+
*
|
|
9
|
+
* This will break if someone isn't using the default libs/apps
|
|
10
|
+
* folders. In that case, they're on their own :/
|
|
11
|
+
*/
|
|
12
|
+
function getDestination(host, schema, project) {
|
|
13
|
+
const projectType = project.projectType;
|
|
14
|
+
const workspaceLayout = (0, devkit_1.getWorkspaceLayout)(host);
|
|
15
|
+
let rootFolder = workspaceLayout.libsDir;
|
|
16
|
+
if (projectType === 'application') {
|
|
17
|
+
rootFolder = workspaceLayout.appsDir;
|
|
18
|
+
}
|
|
19
|
+
return (0, devkit_1.joinPathFragments)(rootFolder, schema.destination);
|
|
20
|
+
}
|
|
21
|
+
exports.getDestination = getDestination;
|
|
22
|
+
/**
|
|
23
|
+
* Joins path segments replacing slashes with dashes
|
|
24
|
+
*
|
|
25
|
+
* @param path
|
|
26
|
+
*/
|
|
27
|
+
function getNewProjectName(path) {
|
|
28
|
+
// strip leading '/' or './' or '../' and trailing '/' and replaces '/' with '-'
|
|
29
|
+
return (0, devkit_1.normalizePath)(path)
|
|
30
|
+
.replace(/(^\.{0,2}\/|\.{1,2}\/|\/$)/g, '')
|
|
31
|
+
.split('/')
|
|
32
|
+
.filter((x) => !!x)
|
|
33
|
+
.join('-');
|
|
34
|
+
}
|
|
35
|
+
exports.getNewProjectName = getNewProjectName;
|
|
36
|
+
/**
|
|
37
|
+
* Normalizes slashes (removes duplicates)
|
|
38
|
+
*
|
|
39
|
+
* @param input
|
|
40
|
+
*/
|
|
41
|
+
function normalizePathSlashes(input) {
|
|
42
|
+
return ((0, devkit_1.normalizePath)(input)
|
|
43
|
+
// strip leading ./ or /
|
|
44
|
+
.replace(/^\.?\//, '')
|
|
45
|
+
.split('/')
|
|
46
|
+
.filter((x) => !!x)
|
|
47
|
+
.join('/'));
|
|
48
|
+
}
|
|
49
|
+
exports.normalizePathSlashes = normalizePathSlashes;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Tree } from '@nx/devkit';
|
|
2
|
+
import { Schema } from './schema';
|
|
3
|
+
export declare function moveGenerator(tree: Tree, rawSchema: Schema): Promise<void>;
|
|
4
|
+
export declare function moveGeneratorInternal(tree: Tree, rawSchema: Schema): Promise<void>;
|
|
5
|
+
export default moveGenerator;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.moveGeneratorInternal = exports.moveGenerator = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const check_destination_1 = require("./lib/check-destination");
|
|
6
|
+
const create_project_configuration_in_new_destination_1 = require("./lib/create-project-configuration-in-new-destination");
|
|
7
|
+
const move_project_files_1 = require("./lib/move-project-files");
|
|
8
|
+
const normalize_schema_1 = require("./lib/normalize-schema");
|
|
9
|
+
const run_angular_plugin_1 = require("./lib/run-angular-plugin");
|
|
10
|
+
const update_build_targets_1 = require("./lib/update-build-targets");
|
|
11
|
+
const update_cypress_config_1 = require("./lib/update-cypress-config");
|
|
12
|
+
const update_default_project_1 = require("./lib/update-default-project");
|
|
13
|
+
const update_eslint_config_1 = require("./lib/update-eslint-config");
|
|
14
|
+
const update_implicit_dependencies_1 = require("./lib/update-implicit-dependencies");
|
|
15
|
+
const update_imports_1 = require("./lib/update-imports");
|
|
16
|
+
const update_jest_config_1 = require("./lib/update-jest-config");
|
|
17
|
+
const update_package_json_1 = require("./lib/update-package-json");
|
|
18
|
+
const update_project_root_files_1 = require("./lib/update-project-root-files");
|
|
19
|
+
const update_readme_1 = require("./lib/update-readme");
|
|
20
|
+
const update_storybook_config_1 = require("./lib/update-storybook-config");
|
|
21
|
+
const extract_base_configs_1 = require("./lib/extract-base-configs");
|
|
22
|
+
async function moveGenerator(tree, rawSchema) {
|
|
23
|
+
await moveGeneratorInternal(tree, {
|
|
24
|
+
projectNameAndRootFormat: 'derived',
|
|
25
|
+
...rawSchema,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
exports.moveGenerator = moveGenerator;
|
|
29
|
+
async function moveGeneratorInternal(tree, rawSchema) {
|
|
30
|
+
let projectConfig = (0, devkit_1.readProjectConfiguration)(tree, rawSchema.projectName);
|
|
31
|
+
const schema = await (0, normalize_schema_1.normalizeSchema)(tree, rawSchema, projectConfig);
|
|
32
|
+
(0, check_destination_1.checkDestination)(tree, schema, rawSchema.destination);
|
|
33
|
+
if (projectConfig.root === '.') {
|
|
34
|
+
(0, extract_base_configs_1.maybeExtractTsConfigBase)(tree);
|
|
35
|
+
await (0, extract_base_configs_1.maybeExtractJestConfigBase)(tree);
|
|
36
|
+
// Reload config since it has been updated after extracting base configs
|
|
37
|
+
projectConfig = (0, devkit_1.readProjectConfiguration)(tree, rawSchema.projectName);
|
|
38
|
+
}
|
|
39
|
+
(0, devkit_1.removeProjectConfiguration)(tree, schema.projectName);
|
|
40
|
+
(0, move_project_files_1.moveProjectFiles)(tree, schema, projectConfig);
|
|
41
|
+
(0, create_project_configuration_in_new_destination_1.createProjectConfigurationInNewDestination)(tree, schema, projectConfig);
|
|
42
|
+
(0, update_imports_1.updateImports)(tree, schema, projectConfig);
|
|
43
|
+
(0, update_project_root_files_1.updateProjectRootFiles)(tree, schema, projectConfig);
|
|
44
|
+
(0, update_cypress_config_1.updateCypressConfig)(tree, schema, projectConfig);
|
|
45
|
+
(0, update_jest_config_1.updateJestConfig)(tree, schema, projectConfig);
|
|
46
|
+
(0, update_storybook_config_1.updateStorybookConfig)(tree, schema, projectConfig);
|
|
47
|
+
(0, update_eslint_config_1.updateEslintConfig)(tree, schema, projectConfig);
|
|
48
|
+
(0, update_readme_1.updateReadme)(tree, schema);
|
|
49
|
+
(0, update_package_json_1.updatePackageJson)(tree, schema);
|
|
50
|
+
(0, update_build_targets_1.updateBuildTargets)(tree, schema);
|
|
51
|
+
(0, update_default_project_1.updateDefaultProject)(tree, schema);
|
|
52
|
+
(0, update_implicit_dependencies_1.updateImplicitDependencies)(tree, schema);
|
|
53
|
+
if (projectConfig.root === '.') {
|
|
54
|
+
// we want to migrate eslint config once the root project files are moved
|
|
55
|
+
(0, extract_base_configs_1.maybeMigrateEslintConfigIfRootProject)(tree, projectConfig);
|
|
56
|
+
}
|
|
57
|
+
await (0, run_angular_plugin_1.runAngularPlugin)(tree, schema);
|
|
58
|
+
if (!schema.skipFormat) {
|
|
59
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.moveGeneratorInternal = moveGeneratorInternal;
|
|
63
|
+
exports.default = moveGenerator;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ProjectNameAndRootFormat } from '@nx/devkit/src/generators/project-name-and-root-utils';
|
|
2
|
+
|
|
3
|
+
export interface Schema {
|
|
4
|
+
projectName: string;
|
|
5
|
+
destination: string;
|
|
6
|
+
importPath?: string;
|
|
7
|
+
updateImportPath: boolean;
|
|
8
|
+
skipFormat?: boolean;
|
|
9
|
+
newProjectName?: string;
|
|
10
|
+
projectNameAndRootFormat?: ProjectNameAndRootFormat;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface NormalizedSchema extends Schema {
|
|
14
|
+
relativeToRootDestination: string;
|
|
15
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
|
+
"$id": "NxWorkspaceMove",
|
|
4
|
+
"cli": "nx",
|
|
5
|
+
"title": "Nx Move",
|
|
6
|
+
"description": "Move a project to another folder in the workspace.",
|
|
7
|
+
"type": "object",
|
|
8
|
+
"examples": [
|
|
9
|
+
{
|
|
10
|
+
"command": "nx g @nx/workspace:move --project my-feature-lib --destination shared/my-feature-lib",
|
|
11
|
+
"description": "Move `libs/my-feature-lib` to `libs/shared/my-feature-lib`"
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
"properties": {
|
|
15
|
+
"projectName": {
|
|
16
|
+
"type": "string",
|
|
17
|
+
"alias": "project",
|
|
18
|
+
"description": "The name of the project to move.",
|
|
19
|
+
"x-dropdown": "projects"
|
|
20
|
+
},
|
|
21
|
+
"newProjectName": {
|
|
22
|
+
"type": "string",
|
|
23
|
+
"alias": "project",
|
|
24
|
+
"description": "The new name of the project after the move.",
|
|
25
|
+
"pattern": "(?:^@[a-zA-Z0-9-*~][a-zA-Z0-9-*._~]*\\/[a-zA-Z0-9-~][a-zA-Z0-9-._~]*|^[a-zA-Z][^:]*)$",
|
|
26
|
+
"x-priority": "important"
|
|
27
|
+
},
|
|
28
|
+
"destination": {
|
|
29
|
+
"type": "string",
|
|
30
|
+
"description": "The folder to move the project into.",
|
|
31
|
+
"$default": {
|
|
32
|
+
"$source": "argv",
|
|
33
|
+
"index": 0
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"projectNameAndRootFormat": {
|
|
37
|
+
"description": "Whether to generate the new project name and destination as provided (`as-provided`) or generate them composing their values and taking the configured layout into account (`derived`).",
|
|
38
|
+
"type": "string",
|
|
39
|
+
"enum": ["as-provided", "derived"]
|
|
40
|
+
},
|
|
41
|
+
"importPath": {
|
|
42
|
+
"type": "string",
|
|
43
|
+
"description": "The new import path to use in the `tsconfig.base.json`."
|
|
44
|
+
},
|
|
45
|
+
"updateImportPath": {
|
|
46
|
+
"type": "boolean",
|
|
47
|
+
"description": "Should the generator update the import path to reflect the new location?",
|
|
48
|
+
"default": true
|
|
49
|
+
},
|
|
50
|
+
"skipFormat": {
|
|
51
|
+
"type": "boolean",
|
|
52
|
+
"aliases": ["skip-format"],
|
|
53
|
+
"description": "Skip formatting files.",
|
|
54
|
+
"default": false,
|
|
55
|
+
"x-priority": "internal"
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
"required": ["projectName", "destination"]
|
|
59
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Editor configuration, see http://editorconfig.org
|
|
2
|
+
root = true
|
|
3
|
+
|
|
4
|
+
[*]
|
|
5
|
+
charset = utf-8
|
|
6
|
+
indent_style = space
|
|
7
|
+
indent_size = 2
|
|
8
|
+
insert_final_newline = true
|
|
9
|
+
trim_trailing_whitespace = true
|
|
10
|
+
|
|
11
|
+
[*.md]
|
|
12
|
+
max_line_length = off
|
|
13
|
+
trim_trailing_whitespace = false
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# See http://help.github.com/ignore-files/ for more about ignoring files.
|
|
2
|
+
|
|
3
|
+
# compiled output
|
|
4
|
+
dist
|
|
5
|
+
tmp
|
|
6
|
+
/out-tsc
|
|
7
|
+
|
|
8
|
+
# dependencies
|
|
9
|
+
node_modules
|
|
10
|
+
|
|
11
|
+
# IDEs and editors
|
|
12
|
+
/.idea
|
|
13
|
+
.project
|
|
14
|
+
.classpath
|
|
15
|
+
.c9/
|
|
16
|
+
*.launch
|
|
17
|
+
.settings/
|
|
18
|
+
*.sublime-workspace
|
|
19
|
+
|
|
20
|
+
# IDE - VSCode
|
|
21
|
+
.vscode/*
|
|
22
|
+
!.vscode/settings.json
|
|
23
|
+
!.vscode/tasks.json
|
|
24
|
+
!.vscode/launch.json
|
|
25
|
+
!.vscode/extensions.json
|
|
26
|
+
|
|
27
|
+
# misc
|
|
28
|
+
/.sass-cache
|
|
29
|
+
/connect.lock
|
|
30
|
+
/coverage
|
|
31
|
+
/libpeerconnection.log
|
|
32
|
+
npm-debug.log
|
|
33
|
+
yarn-error.log
|
|
34
|
+
testem.log
|
|
35
|
+
/typings
|
|
36
|
+
|
|
37
|
+
# System Files
|
|
38
|
+
.DS_Store
|
|
39
|
+
Thumbs.db
|
|
40
|
+
|
|
41
|
+
.nx/cache
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@<%= formattedNames.fileName %>/source",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"scripts": {
|
|
6
|
+
},
|
|
7
|
+
"private": true,
|
|
8
|
+
"dependencies": {
|
|
9
|
+
},
|
|
10
|
+
"devDependencies": {
|
|
11
|
+
"nx": "<%= nxVersion %>",
|
|
12
|
+
"@nx/workspace": "<%= nxVersion %>"
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# See http://help.github.com/ignore-files/ for more about ignoring files.
|
|
2
|
+
|
|
3
|
+
# compiled output
|
|
4
|
+
dist
|
|
5
|
+
tmp
|
|
6
|
+
/out-tsc
|
|
7
|
+
|
|
8
|
+
# dependencies
|
|
9
|
+
node_modules
|
|
10
|
+
|
|
11
|
+
# IDEs and editors
|
|
12
|
+
/.idea
|
|
13
|
+
.project
|
|
14
|
+
.classpath
|
|
15
|
+
.c9/
|
|
16
|
+
*.launch
|
|
17
|
+
.settings/
|
|
18
|
+
*.sublime-workspace
|
|
19
|
+
|
|
20
|
+
# IDE - VSCode
|
|
21
|
+
.vscode/*
|
|
22
|
+
!.vscode/settings.json
|
|
23
|
+
!.vscode/tasks.json
|
|
24
|
+
!.vscode/launch.json
|
|
25
|
+
!.vscode/extensions.json
|
|
26
|
+
|
|
27
|
+
# misc
|
|
28
|
+
/.sass-cache
|
|
29
|
+
/connect.lock
|
|
30
|
+
/coverage
|
|
31
|
+
/libpeerconnection.log
|
|
32
|
+
npm-debug.log
|
|
33
|
+
yarn-error.log
|
|
34
|
+
testem.log
|
|
35
|
+
/typings
|
|
36
|
+
|
|
37
|
+
# System Files
|
|
38
|
+
.DS_Store
|
|
39
|
+
Thumbs.db
|
|
40
|
+
|
|
41
|
+
.nx/cache
|