@nx/plugin 20.0.0-beta.4 → 20.0.0-beta.6
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/migrations.json +1 -20
- package/package.json +5 -6
- package/src/generators/create-package/create-package.js +4 -2
- package/src/generators/create-package/schema.d.ts +1 -3
- package/src/generators/create-package/schema.json +9 -14
- package/src/generators/create-package/utils/normalize-schema.js +4 -3
- package/src/generators/e2e-project/e2e.js +9 -20
- package/src/generators/e2e-project/schema.d.ts +0 -2
- package/src/generators/e2e-project/schema.json +0 -5
- package/src/generators/executor/executor.js +8 -9
- package/src/generators/executor/schema.d.ts +2 -5
- package/src/generators/executor/schema.json +7 -12
- package/src/generators/generator/generator.js +7 -8
- package/src/generators/generator/schema.d.ts +2 -3
- package/src/generators/generator/schema.json +8 -13
- package/src/generators/migration/migration.js +7 -5
- package/src/generators/migration/schema.d.ts +1 -2
- package/src/generators/migration/schema.json +9 -13
- package/src/generators/plugin/plugin.js +2 -2
- package/src/generators/plugin/schema.d.ts +2 -4
- package/src/generators/plugin/schema.json +7 -13
- package/src/generators/plugin/utils/normalize-schema.js +2 -3
- package/src/generators/preset/generator.js +3 -2
- package/src/migrations/update-16-0-0/cli-in-schema-json.d.ts +0 -3
- package/src/migrations/update-16-0-0/cli-in-schema-json.js +0 -134
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +0 -2
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +0 -9
- package/src/migrations/update-16-2-0/replace-e2e-executor.d.ts +0 -7
- package/src/migrations/update-16-2-0/replace-e2e-executor.js +0 -32
package/migrations.json
CHANGED
|
@@ -1,22 +1,3 @@
|
|
|
1
1
|
{
|
|
2
|
-
"generators": {
|
|
3
|
-
"update-remove-cli-prop": {
|
|
4
|
-
"version": "16.0.0-beta.1",
|
|
5
|
-
"cli": "nx",
|
|
6
|
-
"description": "Removes CLI property within schema.json files and moves generators and schematics to the proper root node in migrations.json",
|
|
7
|
-
"factory": "./src/migrations/update-16-0-0/cli-in-schema-json"
|
|
8
|
-
},
|
|
9
|
-
"update-16-0-0-add-nx-packages": {
|
|
10
|
-
"cli": "nx",
|
|
11
|
-
"version": "16.0.0-beta.1",
|
|
12
|
-
"description": "Replace @nrwl/nx-plugin with @nx/plugin",
|
|
13
|
-
"implementation": "./src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages"
|
|
14
|
-
},
|
|
15
|
-
"update-16-2-0-replace-e2e-executor": {
|
|
16
|
-
"cli": "nx",
|
|
17
|
-
"version": "16.2.0-beta.0",
|
|
18
|
-
"description": "Replace @nx/plugin:e2e with @nx/jest",
|
|
19
|
-
"implementation": "./src/migrations/update-16-2-0/replace-e2e-executor"
|
|
20
|
-
}
|
|
21
|
-
}
|
|
2
|
+
"generators": {}
|
|
22
3
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/plugin",
|
|
3
|
-
"version": "20.0.0-beta.
|
|
3
|
+
"version": "20.0.0-beta.6",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "This plugin is used to create Nx plugins! It contains generators for generating common plugin features like generators, executors, migrations and more.",
|
|
6
6
|
"repository": {
|
|
@@ -28,11 +28,10 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"tslib": "^2.3.0",
|
|
31
|
-
"@nx/devkit": "20.0.0-beta.
|
|
32
|
-
"@nx/jest": "20.0.0-beta.
|
|
33
|
-
"@nx/js": "20.0.0-beta.
|
|
34
|
-
"@nx/eslint": "20.0.0-beta.
|
|
35
|
-
"@nrwl/nx-plugin": "20.0.0-beta.4"
|
|
31
|
+
"@nx/devkit": "20.0.0-beta.6",
|
|
32
|
+
"@nx/jest": "20.0.0-beta.6",
|
|
33
|
+
"@nx/js": "20.0.0-beta.6",
|
|
34
|
+
"@nx/eslint": "20.0.0-beta.6"
|
|
36
35
|
},
|
|
37
36
|
"publishConfig": {
|
|
38
37
|
"access": "public"
|
|
@@ -4,6 +4,7 @@ exports.createPackageGenerator = createPackageGenerator;
|
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const js_1 = require("@nx/js");
|
|
6
6
|
const add_tslib_dependencies_1 = require("@nx/js/src/utils/typescript/add-tslib-dependencies");
|
|
7
|
+
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
7
8
|
const versions_1 = require("nx/src/utils/versions");
|
|
8
9
|
const generator_1 = require("../generator/generator");
|
|
9
10
|
const normalize_schema_1 = require("./utils/normalize-schema");
|
|
@@ -11,6 +12,7 @@ const has_generator_1 = require("../../utils/has-generator");
|
|
|
11
12
|
const path_1 = require("path");
|
|
12
13
|
const versions_2 = require("@nx/js/src/utils/versions");
|
|
13
14
|
async function createPackageGenerator(host, schema) {
|
|
15
|
+
(0, ts_solution_setup_1.assertNotUsingTsSolutionSetup)(host, 'plugin', 'create-package');
|
|
14
16
|
const tasks = [];
|
|
15
17
|
const options = await (0, normalize_schema_1.normalizeSchema)(host, schema);
|
|
16
18
|
const pluginPackageName = await addPresetGenerator(host, options);
|
|
@@ -41,10 +43,9 @@ async function addPresetGenerator(host, schema) {
|
|
|
41
43
|
if (!(0, has_generator_1.hasGenerator)(host, schema.project, 'preset')) {
|
|
42
44
|
await (0, generator_1.default)(host, {
|
|
43
45
|
name: 'preset',
|
|
44
|
-
|
|
46
|
+
path: (0, path_1.join)(projectRoot, 'src/generators/preset'),
|
|
45
47
|
unitTestRunner: schema.unitTestRunner,
|
|
46
48
|
skipFormat: true,
|
|
47
|
-
nameAndDirectoryFormat: 'as-provided',
|
|
48
49
|
});
|
|
49
50
|
}
|
|
50
51
|
return (0, devkit_1.readJson)(host, (0, devkit_1.joinPathFragments)(projectRoot, 'package.json'))?.name;
|
|
@@ -52,6 +53,7 @@ async function addPresetGenerator(host, schema) {
|
|
|
52
53
|
async function createCliPackage(host, options, pluginPackageName) {
|
|
53
54
|
await (0, js_1.libraryGenerator)(host, {
|
|
54
55
|
...options,
|
|
56
|
+
directory: options.directory,
|
|
55
57
|
rootProject: false,
|
|
56
58
|
config: 'project',
|
|
57
59
|
publishable: true,
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import type { ProjectNameAndRootFormat } from '@nx/devkit/src/generators/project-name-and-root-utils';
|
|
2
1
|
import type { Linter, LinterType } from '@nx/eslint';
|
|
3
2
|
|
|
4
3
|
export interface CreatePackageSchema {
|
|
5
4
|
name: string;
|
|
6
5
|
project: string;
|
|
6
|
+
directory: string;
|
|
7
7
|
|
|
8
8
|
// options to create cli package, passed to js library generator
|
|
9
|
-
directory?: string;
|
|
10
|
-
projectNameAndRootFormat?: ProjectNameAndRootFormat;
|
|
11
9
|
skipFormat: boolean;
|
|
12
10
|
tags?: string;
|
|
13
11
|
unitTestRunner: 'jest' | 'none';
|
|
@@ -7,14 +7,18 @@
|
|
|
7
7
|
"examplesFile": "../../../docs/generators/create-package-examples.md",
|
|
8
8
|
"type": "object",
|
|
9
9
|
"properties": {
|
|
10
|
-
"
|
|
10
|
+
"directory": {
|
|
11
11
|
"type": "string",
|
|
12
|
-
"description": "
|
|
13
|
-
"pattern": "create-.+|^@.+/create(?:-.+)?",
|
|
12
|
+
"description": "A directory where the app is placed.",
|
|
14
13
|
"$default": {
|
|
15
14
|
"$source": "argv",
|
|
16
15
|
"index": 0
|
|
17
|
-
}
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"name": {
|
|
19
|
+
"type": "string",
|
|
20
|
+
"description": "The package name of cli, e.g. `create-framework-package`. Note this must be a valid NPM name to be published.",
|
|
21
|
+
"pattern": "create-.+|^@.+/create(?:-.+)?",
|
|
18
22
|
"x-priority": "important"
|
|
19
23
|
},
|
|
20
24
|
"project": {
|
|
@@ -33,15 +37,6 @@
|
|
|
33
37
|
"description": "Test runner to use for unit tests.",
|
|
34
38
|
"default": "jest"
|
|
35
39
|
},
|
|
36
|
-
"directory": {
|
|
37
|
-
"type": "string",
|
|
38
|
-
"description": "A directory where the app is placed."
|
|
39
|
-
},
|
|
40
|
-
"projectNameAndRootFormat": {
|
|
41
|
-
"description": "Whether to generate the project name and root directory as provided (`as-provided`) or generate them composing their values and taking the configured layout into account (`derived`).",
|
|
42
|
-
"type": "string",
|
|
43
|
-
"enum": ["as-provided", "derived"]
|
|
44
|
-
},
|
|
45
40
|
"linter": {
|
|
46
41
|
"description": "The tool to use for running lint checks.",
|
|
47
42
|
"type": "string",
|
|
@@ -71,5 +66,5 @@
|
|
|
71
66
|
"x-prompt": "What is the name of the e2e project? Leave blank to skip e2e tests"
|
|
72
67
|
}
|
|
73
68
|
},
|
|
74
|
-
"required": ["name", "project"]
|
|
69
|
+
"required": ["directory", "name", "project"]
|
|
75
70
|
}
|
|
@@ -3,13 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.normalizeSchema = normalizeSchema;
|
|
4
4
|
const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
|
|
5
5
|
async function normalizeSchema(host, schema) {
|
|
6
|
-
|
|
6
|
+
if (!schema.directory) {
|
|
7
|
+
throw new Error(`Please provide the --directory option. It should be the directory containing the project '${schema.project}'.`);
|
|
8
|
+
}
|
|
9
|
+
const { projectName, names: projectNames, projectRoot, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
|
|
7
10
|
name: schema.name,
|
|
8
11
|
projectType: 'library',
|
|
9
12
|
directory: schema.directory,
|
|
10
|
-
projectNameAndRootFormat: schema.projectNameAndRootFormat,
|
|
11
13
|
});
|
|
12
|
-
schema.projectNameAndRootFormat = projectNameAndRootFormat;
|
|
13
14
|
return {
|
|
14
15
|
...schema,
|
|
15
16
|
bundler: schema.compiler ?? 'tsc',
|
|
@@ -8,6 +8,7 @@ const jest_1 = require("@nx/jest");
|
|
|
8
8
|
const js_1 = require("@nx/js");
|
|
9
9
|
const generator_1 = require("@nx/js/src/generators/setup-verdaccio/generator");
|
|
10
10
|
const add_local_registry_scripts_1 = require("@nx/js/src/utils/add-local-registry-scripts");
|
|
11
|
+
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
11
12
|
const eslint_1 = require("@nx/eslint");
|
|
12
13
|
const path_1 = require("path");
|
|
13
14
|
async function normalizeOptions(host, options) {
|
|
@@ -17,27 +18,14 @@ async function normalizeOptions(host, options) {
|
|
|
17
18
|
nxJson.useInferencePlugins !== false;
|
|
18
19
|
options.addPlugin ??= addPlugin;
|
|
19
20
|
let projectRoot;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
directory: options.rootProject || !options.projectDirectory
|
|
25
|
-
? projectName
|
|
26
|
-
: `${options.projectDirectory}-e2e`,
|
|
27
|
-
projectNameAndRootFormat: `as-provided`,
|
|
28
|
-
});
|
|
29
|
-
projectRoot = projectNameAndRootOptions.projectRoot;
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
const { layoutDirectory, projectDirectory } = (0, devkit_1.extractLayoutDirectory)(options.projectDirectory);
|
|
33
|
-
const { appsDir: defaultAppsDir } = (0, devkit_1.getWorkspaceLayout)(host);
|
|
34
|
-
const appsDir = layoutDirectory ?? defaultAppsDir;
|
|
35
|
-
projectRoot = options.rootProject
|
|
21
|
+
const projectNameAndRootOptions = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
|
|
22
|
+
name: projectName,
|
|
23
|
+
projectType: 'application',
|
|
24
|
+
directory: options.rootProject || !options.projectDirectory
|
|
36
25
|
? projectName
|
|
37
|
-
: projectDirectory
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
26
|
+
: `${options.projectDirectory}-e2e`,
|
|
27
|
+
});
|
|
28
|
+
projectRoot = projectNameAndRootOptions.projectRoot;
|
|
41
29
|
const pluginPropertyName = (0, devkit_1.names)(options.pluginName).propertyName;
|
|
42
30
|
return {
|
|
43
31
|
...options,
|
|
@@ -120,6 +108,7 @@ async function e2eProjectGenerator(host, schema) {
|
|
|
120
108
|
});
|
|
121
109
|
}
|
|
122
110
|
async function e2eProjectGeneratorInternal(host, schema) {
|
|
111
|
+
(0, ts_solution_setup_1.assertNotUsingTsSolutionSetup)(host, 'plugin', 'e2e-project');
|
|
123
112
|
const tasks = [];
|
|
124
113
|
validatePlugin(host, schema.pluginName);
|
|
125
114
|
const options = await normalizeOptions(host, schema);
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import type { ProjectNameAndRootFormat } from '@nx/devkit/src/generators/project-name-and-root-utils';
|
|
2
1
|
import type { Linter, LinterType } from '@nx/eslint';
|
|
3
2
|
|
|
4
3
|
export interface Schema {
|
|
5
4
|
pluginName: string;
|
|
6
5
|
npmPackageName: string;
|
|
7
6
|
projectDirectory?: string;
|
|
8
|
-
projectNameAndRootFormat?: ProjectNameAndRootFormat;
|
|
9
7
|
pluginOutputPath?: string;
|
|
10
8
|
jestConfig?: string;
|
|
11
9
|
linter?: Linter | LinterType;
|
|
@@ -21,11 +21,6 @@
|
|
|
21
21
|
"type": "string",
|
|
22
22
|
"description": "the directory where the plugin is placed."
|
|
23
23
|
},
|
|
24
|
-
"projectNameAndRootFormat": {
|
|
25
|
-
"description": "Whether to generate the project name and root directory as provided (`as-provided`) or generate them composing their values and taking the configured layout into account (`derived`).",
|
|
26
|
-
"type": "string",
|
|
27
|
-
"enum": ["as-provided", "derived"]
|
|
28
|
-
},
|
|
29
24
|
"pluginOutputPath": {
|
|
30
25
|
"type": "string",
|
|
31
26
|
"description": "the output path of the plugin after it builds.",
|
|
@@ -9,19 +9,19 @@ const versions_1 = require("../../utils/versions");
|
|
|
9
9
|
const artifact_name_and_directory_utils_1 = require("@nx/devkit/src/generators/artifact-name-and-directory-utils");
|
|
10
10
|
const path_1 = require("path");
|
|
11
11
|
function addFiles(host, options) {
|
|
12
|
-
(0, devkit_1.generateFiles)(host, path.join(__dirname, './files/executor'), options.
|
|
12
|
+
(0, devkit_1.generateFiles)(host, path.join(__dirname, './files/executor'), options.path, {
|
|
13
13
|
...options,
|
|
14
14
|
});
|
|
15
15
|
if (options.unitTestRunner === 'none') {
|
|
16
|
-
host.delete((0, devkit_1.joinPathFragments)(options.
|
|
16
|
+
host.delete((0, devkit_1.joinPathFragments)(options.path, `executor.spec.ts`));
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
function addHasherFiles(host, options) {
|
|
20
|
-
(0, devkit_1.generateFiles)(host, path.join(__dirname, './files/hasher'), options.
|
|
20
|
+
(0, devkit_1.generateFiles)(host, path.join(__dirname, './files/hasher'), options.path, {
|
|
21
21
|
...options,
|
|
22
22
|
});
|
|
23
23
|
if (options.unitTestRunner === 'none') {
|
|
24
|
-
host.delete((0, devkit_1.joinPathFragments)(options.
|
|
24
|
+
host.delete((0, devkit_1.joinPathFragments)(options.path, 'hasher.spec.ts'));
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
async function createExecutorsJson(host, projectRoot, projectName, skipLintChecks) {
|
|
@@ -62,12 +62,12 @@ async function updateExecutorJson(host, options) {
|
|
|
62
62
|
let executors = json.executors ?? json.builders;
|
|
63
63
|
executors ||= {};
|
|
64
64
|
executors[options.name] = {
|
|
65
|
-
implementation: `./${(0, devkit_1.joinPathFragments)((0, path_1.relative)(options.projectRoot, options.
|
|
66
|
-
schema: `./${(0, devkit_1.joinPathFragments)((0, path_1.relative)(options.projectRoot, options.
|
|
65
|
+
implementation: `./${(0, devkit_1.joinPathFragments)((0, path_1.relative)(options.projectRoot, options.path), 'executor')}`,
|
|
66
|
+
schema: `./${(0, devkit_1.joinPathFragments)((0, path_1.relative)(options.projectRoot, options.path), 'schema.json')}`,
|
|
67
67
|
description: options.description,
|
|
68
68
|
};
|
|
69
69
|
if (options.includeHasher) {
|
|
70
|
-
executors[options.name].hasher = `./${(0, devkit_1.joinPathFragments)((0, path_1.relative)(options.projectRoot, options.
|
|
70
|
+
executors[options.name].hasher = `./${(0, devkit_1.joinPathFragments)((0, path_1.relative)(options.projectRoot, options.path), 'hasher')}`;
|
|
71
71
|
}
|
|
72
72
|
json.executors = executors;
|
|
73
73
|
return json;
|
|
@@ -76,8 +76,7 @@ async function updateExecutorJson(host, options) {
|
|
|
76
76
|
async function normalizeOptions(tree, options) {
|
|
77
77
|
const { project, artifactName, filePath, directory } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(tree, {
|
|
78
78
|
name: options.name,
|
|
79
|
-
|
|
80
|
-
directory: options.directory,
|
|
79
|
+
path: options.path,
|
|
81
80
|
fileName: 'executor',
|
|
82
81
|
});
|
|
83
82
|
const { className, propertyName } = (0, devkit_1.names)(artifactName);
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import type { NameAndDirectoryFormat } from '@nx/devkit/src/generators/artifact-name-and-directory-utils';
|
|
2
|
-
|
|
3
1
|
export interface Schema {
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
path: string;
|
|
3
|
+
name?: string;
|
|
6
4
|
description?: string;
|
|
7
5
|
unitTestRunner: 'jest' | 'none';
|
|
8
6
|
includeHasher: boolean;
|
|
9
|
-
nameAndDirectoryFormat?: NameAndDirectoryFormat;
|
|
10
7
|
skipLintChecks?: boolean;
|
|
11
8
|
skipFormat?: boolean;
|
|
12
9
|
}
|
|
@@ -13,20 +13,20 @@
|
|
|
13
13
|
}
|
|
14
14
|
],
|
|
15
15
|
"properties": {
|
|
16
|
-
"
|
|
16
|
+
"path": {
|
|
17
17
|
"type": "string",
|
|
18
|
-
"description": "
|
|
18
|
+
"description": "Path at which to generate the executor file.",
|
|
19
|
+
"x-prompt": "What path would you like to use for the executor?",
|
|
19
20
|
"$default": {
|
|
20
21
|
"$source": "argv",
|
|
21
22
|
"index": 0
|
|
22
23
|
},
|
|
23
|
-
"x-prompt": "What name would you like to use for the executor?",
|
|
24
24
|
"x-priority": "important"
|
|
25
25
|
},
|
|
26
|
-
"
|
|
26
|
+
"name": {
|
|
27
27
|
"type": "string",
|
|
28
|
-
"description": "
|
|
29
|
-
"
|
|
28
|
+
"description": "Executor name.",
|
|
29
|
+
"x-prompt": "What name would you like to use for the executor?",
|
|
30
30
|
"x-priority": "important"
|
|
31
31
|
},
|
|
32
32
|
"description": {
|
|
@@ -50,11 +50,6 @@
|
|
|
50
50
|
"default": false,
|
|
51
51
|
"description": "Do not add an eslint configuration for plugin json files."
|
|
52
52
|
},
|
|
53
|
-
"nameAndDirectoryFormat": {
|
|
54
|
-
"description": "Whether to generate the executor in the directory as provided, relative to the current working directory and ignoring the project (`as-provided`) or generate it using the project and directory relative to the workspace root (`derived`).",
|
|
55
|
-
"type": "string",
|
|
56
|
-
"enum": ["as-provided", "derived"]
|
|
57
|
-
},
|
|
58
53
|
"skipFormat": {
|
|
59
54
|
"type": "boolean",
|
|
60
55
|
"description": "Skip formatting files.",
|
|
@@ -62,6 +57,6 @@
|
|
|
62
57
|
"x-priority": "internal"
|
|
63
58
|
}
|
|
64
59
|
},
|
|
65
|
-
"required": ["
|
|
60
|
+
"required": ["path"],
|
|
66
61
|
"additionalProperties": false
|
|
67
62
|
}
|
|
@@ -11,8 +11,7 @@ const path_1 = require("path");
|
|
|
11
11
|
async function normalizeOptions(tree, options) {
|
|
12
12
|
const { project, fileName, artifactName, filePath, directory } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(tree, {
|
|
13
13
|
name: options.name,
|
|
14
|
-
|
|
15
|
-
directory: options.directory,
|
|
14
|
+
path: options.path,
|
|
16
15
|
fileName: 'generator',
|
|
17
16
|
});
|
|
18
17
|
const { className, propertyName } = (0, devkit_1.names)(artifactName);
|
|
@@ -26,8 +25,8 @@ async function normalizeOptions(tree, options) {
|
|
|
26
25
|
}
|
|
27
26
|
return {
|
|
28
27
|
...options,
|
|
29
|
-
project,
|
|
30
28
|
directory,
|
|
29
|
+
project,
|
|
31
30
|
fileName,
|
|
32
31
|
className,
|
|
33
32
|
propertyName,
|
|
@@ -37,17 +36,17 @@ async function normalizeOptions(tree, options) {
|
|
|
37
36
|
};
|
|
38
37
|
}
|
|
39
38
|
function addFiles(host, options) {
|
|
40
|
-
const indexPath = (0, path_1.join)(options.
|
|
39
|
+
const indexPath = (0, path_1.join)(options.path, 'files/src/index.ts.template');
|
|
41
40
|
if (!host.exists(indexPath)) {
|
|
42
41
|
host.write(indexPath, 'const variable = "<%= name %>";');
|
|
43
42
|
}
|
|
44
|
-
(0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, './files/generator'), options.
|
|
43
|
+
(0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, './files/generator'), options.path, {
|
|
45
44
|
...options,
|
|
46
45
|
generatorFnName: `${options.propertyName}Generator`,
|
|
47
46
|
schemaInterfaceName: `${options.className}GeneratorSchema`,
|
|
48
47
|
});
|
|
49
48
|
if (options.unitTestRunner === 'none') {
|
|
50
|
-
host.delete((0, path_1.join)(options.
|
|
49
|
+
host.delete((0, path_1.join)(options.path, `generator.spec.ts`));
|
|
51
50
|
}
|
|
52
51
|
}
|
|
53
52
|
async function createGeneratorsJson(host, projectRoot, projectName, skipLintChecks, skipFormat) {
|
|
@@ -89,8 +88,8 @@ async function updateGeneratorJson(host, options) {
|
|
|
89
88
|
let generators = json.generators ?? json.schematics;
|
|
90
89
|
generators = generators || {};
|
|
91
90
|
generators[options.name] = {
|
|
92
|
-
factory: `./${(0, devkit_1.joinPathFragments)((0, path_1.relative)(options.projectRoot, options.
|
|
93
|
-
schema: `./${(0, devkit_1.joinPathFragments)((0, path_1.relative)(options.projectRoot, options.
|
|
91
|
+
factory: `./${(0, devkit_1.joinPathFragments)((0, path_1.relative)(options.projectRoot, options.path), 'generator')}`,
|
|
92
|
+
schema: `./${(0, devkit_1.joinPathFragments)((0, path_1.relative)(options.projectRoot, options.path), 'schema.json')}`,
|
|
94
93
|
description: options.description,
|
|
95
94
|
};
|
|
96
95
|
// @todo(v17): Remove this, prop is defunct.
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { NameAndDirectoryFormat } from '@nx/devkit/src/generators/artifact-name-and-directory-utils';
|
|
2
2
|
|
|
3
3
|
export interface Schema {
|
|
4
|
-
|
|
5
|
-
name
|
|
4
|
+
path: string;
|
|
5
|
+
name?: string;
|
|
6
6
|
description?: string;
|
|
7
7
|
unitTestRunner: 'jest' | 'none';
|
|
8
8
|
skipLintChecks?: boolean;
|
|
9
9
|
skipFormat?: boolean;
|
|
10
|
-
nameAndDirectoryFormat?: NameAndDirectoryFormat;
|
|
11
10
|
}
|
|
@@ -7,25 +7,25 @@
|
|
|
7
7
|
"type": "object",
|
|
8
8
|
"examples": [
|
|
9
9
|
{
|
|
10
|
-
"command": "nx g generator my-
|
|
10
|
+
"command": "nx g generator libs/my-plugin/src/generators//my-generator",
|
|
11
11
|
"description": "Generate `libs/my-plugin/src/generators/my-generator`"
|
|
12
12
|
}
|
|
13
13
|
],
|
|
14
14
|
"properties": {
|
|
15
|
-
"
|
|
15
|
+
"path": {
|
|
16
16
|
"type": "string",
|
|
17
|
-
"description": "
|
|
17
|
+
"description": "Path where the generator will be generated.",
|
|
18
18
|
"$default": {
|
|
19
19
|
"$source": "argv",
|
|
20
20
|
"index": 0
|
|
21
21
|
},
|
|
22
|
-
"x-prompt": "
|
|
22
|
+
"x-prompt": "Where should the generator be generated?",
|
|
23
23
|
"x-priority": "important"
|
|
24
24
|
},
|
|
25
|
-
"
|
|
25
|
+
"name": {
|
|
26
26
|
"type": "string",
|
|
27
|
-
"description": "
|
|
28
|
-
"
|
|
27
|
+
"description": "Generator name.",
|
|
28
|
+
"x-prompt": "What name would you like to use for the generator?",
|
|
29
29
|
"x-priority": "important"
|
|
30
30
|
},
|
|
31
31
|
"description": {
|
|
@@ -49,13 +49,8 @@
|
|
|
49
49
|
"default": false,
|
|
50
50
|
"description": "Do not format files with prettier.",
|
|
51
51
|
"x-priority": "internal"
|
|
52
|
-
},
|
|
53
|
-
"nameAndDirectoryFormat": {
|
|
54
|
-
"description": "Whether to generate the generator in the directory as provided, relative to the current working directory and ignoring the project (`as-provided`) or generate it using the project and directory relative to the workspace root (`derived`).",
|
|
55
|
-
"type": "string",
|
|
56
|
-
"enum": ["as-provided", "derived"]
|
|
57
52
|
}
|
|
58
53
|
},
|
|
59
|
-
"required": ["
|
|
54
|
+
"required": ["path"],
|
|
60
55
|
"additionalProperties": false
|
|
61
56
|
}
|
|
@@ -18,8 +18,7 @@ async function normalizeOptions(tree, options) {
|
|
|
18
18
|
}
|
|
19
19
|
const { project, fileName, artifactName, filePath, directory } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(tree, {
|
|
20
20
|
name: name,
|
|
21
|
-
|
|
22
|
-
directory: options.directory,
|
|
21
|
+
path: options.path,
|
|
23
22
|
fileName: name,
|
|
24
23
|
});
|
|
25
24
|
const { root: projectRoot, sourceRoot: projectSourceRoot } = (0, devkit_1.readProjectConfiguration)(tree, project);
|
|
@@ -28,9 +27,9 @@ async function normalizeOptions(tree, options) {
|
|
|
28
27
|
// readProjectConfiguration(host, options.project);
|
|
29
28
|
const normalized = {
|
|
30
29
|
...options,
|
|
30
|
+
directory,
|
|
31
31
|
project,
|
|
32
32
|
name: artifactName,
|
|
33
|
-
directory,
|
|
34
33
|
description,
|
|
35
34
|
projectRoot,
|
|
36
35
|
projectSourceRoot,
|
|
@@ -38,7 +37,10 @@ async function normalizeOptions(tree, options) {
|
|
|
38
37
|
return normalized;
|
|
39
38
|
}
|
|
40
39
|
function addFiles(host, options) {
|
|
41
|
-
(0, devkit_1.generateFiles)(host, path.join(__dirname, 'files/migration'), options.
|
|
40
|
+
(0, devkit_1.generateFiles)(host, path.join(__dirname, 'files/migration'), options.path, {
|
|
41
|
+
...options,
|
|
42
|
+
tmpl: '',
|
|
43
|
+
});
|
|
42
44
|
}
|
|
43
45
|
function updateMigrationsJson(host, options) {
|
|
44
46
|
const configuredMigrationPath = (0, package_json_1.readNxMigrateConfig)((0, devkit_1.readJson)(host, (0, devkit_1.joinPathFragments)(options.projectRoot, 'package.json'))).migrations;
|
|
@@ -50,7 +52,7 @@ function updateMigrationsJson(host, options) {
|
|
|
50
52
|
generators[options.name] = {
|
|
51
53
|
version: options.packageVersion,
|
|
52
54
|
description: options.description,
|
|
53
|
-
implementation: `./${(0, devkit_1.joinPathFragments)((0, path_1.relative)(options.projectRoot, options.
|
|
55
|
+
implementation: `./${(0, devkit_1.joinPathFragments)((0, path_1.relative)(options.projectRoot, options.path), options.name)}`,
|
|
54
56
|
};
|
|
55
57
|
migrations.generators = generators;
|
|
56
58
|
if (options.packageJsonUpdates) {
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { NameAndDirectoryFormat } from '@nx/devkit/src/generators/artifact-name-and-directory-utils';
|
|
2
2
|
|
|
3
3
|
export interface Schema {
|
|
4
|
+
path: string;
|
|
4
5
|
name?: string;
|
|
5
|
-
directory?: string;
|
|
6
6
|
description?: string;
|
|
7
7
|
packageVersion: string;
|
|
8
8
|
packageJsonUpdates?: boolean;
|
|
9
9
|
skipFormat?: boolean;
|
|
10
|
-
nameAndDirectoryFormat?: NameAndDirectoryFormat;
|
|
11
10
|
}
|
|
@@ -7,24 +7,25 @@
|
|
|
7
7
|
"type": "object",
|
|
8
8
|
"examples": [
|
|
9
9
|
{
|
|
10
|
-
"command": "nx g migration my-
|
|
11
|
-
"description": "Adds a new migration
|
|
10
|
+
"command": "nx g migration my-plugin/my-migration --version=1.0.0",
|
|
11
|
+
"description": "Adds a new migration inside `my-plugin`, which will be triggered when migrating to version 1.0.0 or above from a previous version."
|
|
12
12
|
}
|
|
13
13
|
],
|
|
14
14
|
"properties": {
|
|
15
|
-
"
|
|
15
|
+
"path": {
|
|
16
16
|
"type": "string",
|
|
17
|
-
"description": "
|
|
17
|
+
"description": "Path where the migration will be generated.",
|
|
18
18
|
"$default": {
|
|
19
19
|
"$source": "argv",
|
|
20
20
|
"index": 0
|
|
21
21
|
},
|
|
22
|
+
"x-prompt": "Where should the migration be generated?",
|
|
22
23
|
"x-priority": "important"
|
|
23
24
|
},
|
|
24
|
-
"
|
|
25
|
+
"name": {
|
|
25
26
|
"type": "string",
|
|
26
|
-
"description": "
|
|
27
|
-
"
|
|
27
|
+
"description": "Migration name.",
|
|
28
|
+
"x-priority": "important"
|
|
28
29
|
},
|
|
29
30
|
"description": {
|
|
30
31
|
"type": "string",
|
|
@@ -47,13 +48,8 @@
|
|
|
47
48
|
"type": "boolean",
|
|
48
49
|
"default": false,
|
|
49
50
|
"description": "Do not eslint configuration for plugin json files."
|
|
50
|
-
},
|
|
51
|
-
"nameAndDirectoryFormat": {
|
|
52
|
-
"description": "Whether to generate the migration in the directory as provided, relative to the current working directory and ignoring the project (`as-provided`) or generate it using the project and directory relative to the workspace root (`derived`).",
|
|
53
|
-
"type": "string",
|
|
54
|
-
"enum": ["as-provided", "derived"]
|
|
55
51
|
}
|
|
56
52
|
},
|
|
57
|
-
"required": ["packageVersion"],
|
|
53
|
+
"required": ["packageVersion", "path"],
|
|
58
54
|
"additionalProperties": false
|
|
59
55
|
}
|
|
@@ -4,6 +4,7 @@ exports.pluginGenerator = pluginGenerator;
|
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const js_1 = require("@nx/js");
|
|
6
6
|
const add_swc_dependencies_1 = require("@nx/js/src/utils/swc/add-swc-dependencies");
|
|
7
|
+
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
7
8
|
const eslint_1 = require("@nx/eslint");
|
|
8
9
|
const path = require("path");
|
|
9
10
|
const e2e_1 = require("../e2e-project/e2e");
|
|
@@ -51,6 +52,7 @@ function updatePluginConfig(host, options) {
|
|
|
51
52
|
}
|
|
52
53
|
}
|
|
53
54
|
async function pluginGenerator(host, schema) {
|
|
55
|
+
(0, ts_solution_setup_1.assertNotUsingTsSolutionSetup)(host, 'plugin', 'plugin');
|
|
54
56
|
const options = await (0, normalize_schema_1.normalizeOptions)(host, schema);
|
|
55
57
|
const tasks = [];
|
|
56
58
|
tasks.push(await (0, js_1.libraryGenerator)(host, {
|
|
@@ -61,7 +63,6 @@ async function pluginGenerator(host, schema) {
|
|
|
61
63
|
bundler: options.bundler,
|
|
62
64
|
publishable: options.publishable,
|
|
63
65
|
importPath: options.npmPackageName,
|
|
64
|
-
projectNameAndRootFormat: 'as-provided',
|
|
65
66
|
skipFormat: true,
|
|
66
67
|
}));
|
|
67
68
|
if (options.bundler === 'tsc') {
|
|
@@ -88,7 +89,6 @@ async function pluginGenerator(host, schema) {
|
|
|
88
89
|
npmPackageName: options.npmPackageName,
|
|
89
90
|
skipFormat: true,
|
|
90
91
|
rootProject: options.rootProject,
|
|
91
|
-
projectNameAndRootFormat: options.projectNameAndRootFormat,
|
|
92
92
|
}));
|
|
93
93
|
}
|
|
94
94
|
if (options.linter === eslint_1.Linter.EsLint && !options.skipLintChecks) {
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import type { ProjectNameAndRootFormat } from '@nx/devkit/src/generators/project-name-and-root-utils';
|
|
2
1
|
import type { Linter, LinterType } from '@nx/eslint';
|
|
3
2
|
|
|
4
3
|
export interface Schema {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
projectNameAndRootFormat?: ProjectNameAndRootFormat;
|
|
4
|
+
directory: string;
|
|
5
|
+
name?: string;
|
|
8
6
|
importPath?: string;
|
|
9
7
|
skipTsConfig?: boolean; // default is false
|
|
10
8
|
skipFormat?: boolean; // default is false
|
|
@@ -12,25 +12,19 @@
|
|
|
12
12
|
}
|
|
13
13
|
],
|
|
14
14
|
"properties": {
|
|
15
|
-
"
|
|
15
|
+
"directory": {
|
|
16
16
|
"type": "string",
|
|
17
|
-
"description": "
|
|
17
|
+
"description": "A directory where the plugin is placed.",
|
|
18
18
|
"$default": {
|
|
19
19
|
"$source": "argv",
|
|
20
20
|
"index": 0
|
|
21
21
|
},
|
|
22
|
-
"x-prompt": "
|
|
23
|
-
"x-priority": "important",
|
|
24
|
-
"pattern": "(?:^@[a-zA-Z0-9-*~][a-zA-Z0-9-*._~]*\\/[a-zA-Z0-9-~][a-zA-Z0-9-._~]*|^[a-zA-Z][^:]*)$"
|
|
22
|
+
"x-prompt": "Which directory do you want to create the plugin in?"
|
|
25
23
|
},
|
|
26
|
-
"
|
|
27
|
-
"type": "string",
|
|
28
|
-
"description": "A directory where the plugin is placed."
|
|
29
|
-
},
|
|
30
|
-
"projectNameAndRootFormat": {
|
|
31
|
-
"description": "Whether to generate the project name and root directory as provided (`as-provided`) or generate them composing their values and taking the configured layout into account (`derived`).",
|
|
24
|
+
"name": {
|
|
32
25
|
"type": "string",
|
|
33
|
-
"
|
|
26
|
+
"description": "Plugin name",
|
|
27
|
+
"x-priority": "important"
|
|
34
28
|
},
|
|
35
29
|
"importPath": {
|
|
36
30
|
"type": "string",
|
|
@@ -100,5 +94,5 @@
|
|
|
100
94
|
"default": false
|
|
101
95
|
}
|
|
102
96
|
},
|
|
103
|
-
"required": ["
|
|
97
|
+
"required": ["directory"]
|
|
104
98
|
}
|
|
@@ -3,15 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.normalizeOptions = normalizeOptions;
|
|
4
4
|
const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
|
|
5
5
|
async function normalizeOptions(host, options) {
|
|
6
|
-
|
|
6
|
+
await (0, project_name_and_root_utils_1.ensureProjectName)(host, options, 'application');
|
|
7
|
+
const { projectName, projectRoot, importPath: npmPackageName, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
|
|
7
8
|
name: options.name,
|
|
8
9
|
projectType: 'library',
|
|
9
10
|
directory: options.directory,
|
|
10
11
|
importPath: options.importPath,
|
|
11
|
-
projectNameAndRootFormat: options.projectNameAndRootFormat,
|
|
12
12
|
rootProject: options.rootProject,
|
|
13
13
|
});
|
|
14
|
-
options.projectNameAndRootFormat = projectNameAndRootFormat;
|
|
15
14
|
options.rootProject = projectRoot === '.';
|
|
16
15
|
const projectDirectory = projectRoot;
|
|
17
16
|
const parsedTags = options.tags
|
|
@@ -3,9 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.default = default_1;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const eslint_1 = require("@nx/eslint");
|
|
6
|
+
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
6
7
|
const plugin_1 = require("../plugin/plugin");
|
|
7
8
|
const create_package_1 = require("../create-package/create-package");
|
|
8
9
|
async function default_1(tree, options) {
|
|
10
|
+
(0, ts_solution_setup_1.assertNotUsingTsSolutionSetup)(tree, 'plugin', 'preset');
|
|
9
11
|
const tasks = [];
|
|
10
12
|
const pluginProjectName = (0, devkit_1.names)(options.pluginName.includes('/')
|
|
11
13
|
? options.pluginName.split('/')[1]
|
|
@@ -17,7 +19,6 @@ async function default_1(tree, options) {
|
|
|
17
19
|
const pluginTask = await (0, plugin_1.pluginGenerator)(tree, {
|
|
18
20
|
compiler: 'tsc',
|
|
19
21
|
linter: eslint_1.Linter.EsLint,
|
|
20
|
-
name: pluginProjectName,
|
|
21
22
|
skipFormat: true,
|
|
22
23
|
unitTestRunner: 'jest',
|
|
23
24
|
importPath: options.pluginName,
|
|
@@ -26,7 +27,7 @@ async function default_1(tree, options) {
|
|
|
26
27
|
// when creating a CLI package, the plugin will be in the packages folder
|
|
27
28
|
directory: options.createPackageName && options.createPackageName !== 'false'
|
|
28
29
|
? `packages/${pluginProjectName}`
|
|
29
|
-
:
|
|
30
|
+
: pluginProjectName,
|
|
30
31
|
rootProject: options.createPackageName ? false : true,
|
|
31
32
|
});
|
|
32
33
|
tasks.push(pluginTask);
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.updateCliPropsForPlugins = updateCliPropsForPlugins;
|
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const package_json_1 = require("nx/src/utils/package-json");
|
|
6
|
-
const path_1 = require("path");
|
|
7
|
-
function updateCliPropsForPlugins(tree) {
|
|
8
|
-
const projects = (0, devkit_1.getProjects)(tree);
|
|
9
|
-
for (const project of projects.values()) {
|
|
10
|
-
if (tree.exists((0, devkit_1.joinPathFragments)(project.root, 'package.json'))) {
|
|
11
|
-
const packageJson = (0, devkit_1.readJson)(tree, (0, devkit_1.joinPathFragments)(project.root, 'package.json'));
|
|
12
|
-
const migrateConfig = (0, package_json_1.readNxMigrateConfig)(packageJson);
|
|
13
|
-
if (migrateConfig.migrations) {
|
|
14
|
-
const migrationsPath = (0, devkit_1.joinPathFragments)(project.root, migrateConfig.migrations);
|
|
15
|
-
if (tree.exists(migrationsPath)) {
|
|
16
|
-
updateMigrationsJsonForPlugin(tree, migrationsPath);
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
devkit_1.output.warn({
|
|
20
|
-
title: `Migrations file specified for ${packageJson.name} does not exist: ${migrationsPath}`,
|
|
21
|
-
bodyLines: [
|
|
22
|
-
'Please ensure that migrations that use the Angular Devkit are placed inside the `schematics` property, and migrations that use the Nx Devkit are placed inside the `generators` property.',
|
|
23
|
-
],
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
if (packageJson.generators) {
|
|
28
|
-
const generatorsPath = (0, devkit_1.joinPathFragments)(project.root, packageJson.generators);
|
|
29
|
-
if (tree.exists(generatorsPath)) {
|
|
30
|
-
removeCliFromGeneratorSchemaJsonFiles(tree, generatorsPath);
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
devkit_1.output.warn({
|
|
34
|
-
title: `Generators file specified for ${packageJson.name} does not exist: ${generatorsPath}`,
|
|
35
|
-
bodyLines: [
|
|
36
|
-
"The `cli` property inside generator's `schema.json` files is no longer supported.",
|
|
37
|
-
],
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
if (packageJson.executors) {
|
|
42
|
-
const executorsPath = (0, devkit_1.joinPathFragments)(project.root, packageJson.executors);
|
|
43
|
-
if (tree.exists(executorsPath)) {
|
|
44
|
-
removeCliFromExecutorSchemaJsonFiles(tree, executorsPath);
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
devkit_1.output.warn({
|
|
48
|
-
title: `Executors file specified for ${packageJson.name} does not exist: ${executorsPath}`,
|
|
49
|
-
bodyLines: [
|
|
50
|
-
"The `cli` property inside executor's `schema.json` files is no longer supported.",
|
|
51
|
-
],
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
if (packageJson.builders) {
|
|
56
|
-
const buildersPath = (0, devkit_1.joinPathFragments)(project.root, packageJson.builders);
|
|
57
|
-
if (tree.exists(buildersPath)) {
|
|
58
|
-
removeCliFromExecutorSchemaJsonFiles(tree, buildersPath);
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
devkit_1.output.warn({
|
|
62
|
-
title: `Builders file specified for ${packageJson.name} does not exist: ${buildersPath}`,
|
|
63
|
-
bodyLines: [
|
|
64
|
-
"The `cli` property inside builder's `schema.json` files is no longer supported.",
|
|
65
|
-
],
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
if (packageJson.schematics) {
|
|
70
|
-
const schematicsPath = (0, devkit_1.joinPathFragments)(project.root, packageJson.schematics);
|
|
71
|
-
if (tree.exists(schematicsPath)) {
|
|
72
|
-
removeCliFromGeneratorSchemaJsonFiles(tree, schematicsPath);
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
devkit_1.output.warn({
|
|
76
|
-
title: `Schematics file specified for ${packageJson.name} does not exist: ${schematicsPath}`,
|
|
77
|
-
bodyLines: [
|
|
78
|
-
"The `cli` property inside schematic's `schema.json` files is no longer supported.",
|
|
79
|
-
],
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
function removeCliFromExecutorSchemaJsonFiles(tree, collectionPath) {
|
|
87
|
-
const collection = (0, devkit_1.readJson)(tree, collectionPath);
|
|
88
|
-
for (const [name, entry] of Object.entries(collection.executors ?? {}).concat(Object.entries(collection.builders ?? {}))) {
|
|
89
|
-
deleteCliPropFromSchemaFile(collectionPath, entry, tree);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
function removeCliFromGeneratorSchemaJsonFiles(tree, collectionPath) {
|
|
93
|
-
const collection = (0, devkit_1.readJson)(tree, collectionPath);
|
|
94
|
-
for (const [name, entry] of Object.entries(collection.generators ?? {}).concat(Object.entries(collection.schematics ?? {}))) {
|
|
95
|
-
deleteCliPropFromSchemaFile(collectionPath, entry, tree);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
function updateMigrationsJsonForPlugin(tree, collectionPath) {
|
|
99
|
-
(0, devkit_1.updateJson)(tree, collectionPath, (json) => {
|
|
100
|
-
for (const migration in json.generators ?? {}) {
|
|
101
|
-
if (!(json.generators[migration].cli === 'nx')) {
|
|
102
|
-
json.schematics ??= {};
|
|
103
|
-
json.schematics[migration] = json.generators[migration];
|
|
104
|
-
delete json.generators[migration];
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
for (const migration in json.schematics ?? {}) {
|
|
108
|
-
if (json.schematics[migration].cli === 'nx') {
|
|
109
|
-
json.generators ??= {};
|
|
110
|
-
json.generators[migration] = json.schematics[migration];
|
|
111
|
-
delete json.schematics[migration];
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
return json;
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
exports.default = updateCliPropsForPlugins;
|
|
118
|
-
function deleteCliPropFromSchemaFile(collectionPath, entry, tree) {
|
|
119
|
-
if (typeof entry === 'string' || !entry.schema) {
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
const schemaPath = (0, devkit_1.joinPathFragments)((0, path_1.dirname)(collectionPath), entry.schema);
|
|
123
|
-
if (tree.exists(schemaPath)) {
|
|
124
|
-
(0, devkit_1.updateJson)(tree, schemaPath, (json) => {
|
|
125
|
-
if (json.cli) {
|
|
126
|
-
delete json.cli;
|
|
127
|
-
}
|
|
128
|
-
return json;
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
else {
|
|
132
|
-
console.warn(`Could not find schema file ${schemaPath}`);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = replacePackage;
|
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const replace_package_1 = require("@nx/devkit/src/utils/replace-package");
|
|
6
|
-
async function replacePackage(tree) {
|
|
7
|
-
await (0, replace_package_1.replaceNrwlPackageWithNxPackage)(tree, '@nrwl/nx-plugin', '@nx/plugin');
|
|
8
|
-
await (0, devkit_1.formatFiles)(tree);
|
|
9
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Tree } from '@nx/devkit';
|
|
2
|
-
import { JestExecutorOptions } from '@nx/jest/src/executors/jest/schema';
|
|
3
|
-
export interface NxPluginE2EExecutorOptions extends JestExecutorOptions {
|
|
4
|
-
target: string;
|
|
5
|
-
jestConfig: string;
|
|
6
|
-
}
|
|
7
|
-
export default function replaceE2EExecutor(tree: Tree): Promise<void>;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = replaceE2EExecutor;
|
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
|
|
6
|
-
async function replaceE2EExecutor(tree) {
|
|
7
|
-
const projects = (0, devkit_1.getProjects)(tree);
|
|
8
|
-
for (const executor of ['@nx/plugin:e2e', '@nrwl/nx-plugin:e2e']) {
|
|
9
|
-
(0, executor_options_utils_1.forEachExecutorOptions)(tree, executor, (options, project, target, configuration) => {
|
|
10
|
-
const projectConfiguration = projects.get(project);
|
|
11
|
-
const config = {
|
|
12
|
-
...options,
|
|
13
|
-
target: undefined,
|
|
14
|
-
runInBand: true,
|
|
15
|
-
};
|
|
16
|
-
if (configuration) {
|
|
17
|
-
projectConfiguration.targets[target].configurations[configuration] =
|
|
18
|
-
config;
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
projectConfiguration.targets[target].dependsOn = [
|
|
22
|
-
...(projectConfiguration.targets[target].dependsOn ?? []),
|
|
23
|
-
options.target,
|
|
24
|
-
];
|
|
25
|
-
projectConfiguration.targets[target].executor = '@nx/jest:jest';
|
|
26
|
-
projectConfiguration.targets[target].options = config;
|
|
27
|
-
}
|
|
28
|
-
(0, devkit_1.updateProjectConfiguration)(tree, project, projectConfiguration);
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
await (0, devkit_1.formatFiles)(tree);
|
|
32
|
-
}
|