@nx/plugin 0.0.0-pr-28218-5048fd1 → 0.0.0-pr-28229-afe192c
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/package.json +5 -5
- package/src/generators/create-package/create-package.js +2 -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 +7 -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 +0 -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 +1 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/plugin",
|
|
3
|
-
"version": "0.0.0-pr-
|
|
3
|
+
"version": "0.0.0-pr-28229-afe192c",
|
|
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,10 +28,10 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"tslib": "^2.3.0",
|
|
31
|
-
"@nx/devkit": "0.0.0-pr-
|
|
32
|
-
"@nx/jest": "0.0.0-pr-
|
|
33
|
-
"@nx/js": "0.0.0-pr-
|
|
34
|
-
"@nx/eslint": "0.0.0-pr-
|
|
31
|
+
"@nx/devkit": "0.0.0-pr-28229-afe192c",
|
|
32
|
+
"@nx/jest": "0.0.0-pr-28229-afe192c",
|
|
33
|
+
"@nx/js": "0.0.0-pr-28229-afe192c",
|
|
34
|
+
"@nx/eslint": "0.0.0-pr-28229-afe192c"
|
|
35
35
|
},
|
|
36
36
|
"publishConfig": {
|
|
37
37
|
"access": "public"
|
|
@@ -41,10 +41,9 @@ async function addPresetGenerator(host, schema) {
|
|
|
41
41
|
if (!(0, has_generator_1.hasGenerator)(host, schema.project, 'preset')) {
|
|
42
42
|
await (0, generator_1.default)(host, {
|
|
43
43
|
name: 'preset',
|
|
44
|
-
|
|
44
|
+
path: (0, path_1.join)(projectRoot, 'src/generators/preset'),
|
|
45
45
|
unitTestRunner: schema.unitTestRunner,
|
|
46
46
|
skipFormat: true,
|
|
47
|
-
nameAndDirectoryFormat: 'as-provided',
|
|
48
47
|
});
|
|
49
48
|
}
|
|
50
49
|
return (0, devkit_1.readJson)(host, (0, devkit_1.joinPathFragments)(projectRoot, 'package.json'))?.name;
|
|
@@ -52,6 +51,7 @@ async function addPresetGenerator(host, schema) {
|
|
|
52
51
|
async function createCliPackage(host, options, pluginPackageName) {
|
|
53
52
|
await (0, js_1.libraryGenerator)(host, {
|
|
54
53
|
...options,
|
|
54
|
+
directory: options.directory,
|
|
55
55
|
rootProject: false,
|
|
56
56
|
config: 'project',
|
|
57
57
|
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',
|
|
@@ -17,27 +17,14 @@ async function normalizeOptions(host, options) {
|
|
|
17
17
|
nxJson.useInferencePlugins !== false;
|
|
18
18
|
options.addPlugin ??= addPlugin;
|
|
19
19
|
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
|
|
20
|
+
const projectNameAndRootOptions = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
|
|
21
|
+
name: projectName,
|
|
22
|
+
projectType: 'application',
|
|
23
|
+
directory: options.rootProject || !options.projectDirectory
|
|
36
24
|
? projectName
|
|
37
|
-
: projectDirectory
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
25
|
+
: `${options.projectDirectory}-e2e`,
|
|
26
|
+
});
|
|
27
|
+
projectRoot = projectNameAndRootOptions.projectRoot;
|
|
41
28
|
const pluginPropertyName = (0, devkit_1.names)(options.pluginName).propertyName;
|
|
42
29
|
return {
|
|
43
30
|
...options,
|
|
@@ -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
|
}
|
|
@@ -61,7 +61,6 @@ async function pluginGenerator(host, schema) {
|
|
|
61
61
|
bundler: options.bundler,
|
|
62
62
|
publishable: options.publishable,
|
|
63
63
|
importPath: options.npmPackageName,
|
|
64
|
-
projectNameAndRootFormat: 'as-provided',
|
|
65
64
|
skipFormat: true,
|
|
66
65
|
}));
|
|
67
66
|
if (options.bundler === 'tsc') {
|
|
@@ -88,7 +87,6 @@ async function pluginGenerator(host, schema) {
|
|
|
88
87
|
npmPackageName: options.npmPackageName,
|
|
89
88
|
skipFormat: true,
|
|
90
89
|
rootProject: options.rootProject,
|
|
91
|
-
projectNameAndRootFormat: options.projectNameAndRootFormat,
|
|
92
90
|
}));
|
|
93
91
|
}
|
|
94
92
|
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
|
|
@@ -17,7 +17,6 @@ async function default_1(tree, options) {
|
|
|
17
17
|
const pluginTask = await (0, plugin_1.pluginGenerator)(tree, {
|
|
18
18
|
compiler: 'tsc',
|
|
19
19
|
linter: eslint_1.Linter.EsLint,
|
|
20
|
-
name: pluginProjectName,
|
|
21
20
|
skipFormat: true,
|
|
22
21
|
unitTestRunner: 'jest',
|
|
23
22
|
importPath: options.pluginName,
|
|
@@ -26,7 +25,7 @@ async function default_1(tree, options) {
|
|
|
26
25
|
// when creating a CLI package, the plugin will be in the packages folder
|
|
27
26
|
directory: options.createPackageName && options.createPackageName !== 'false'
|
|
28
27
|
? `packages/${pluginProjectName}`
|
|
29
|
-
:
|
|
28
|
+
: pluginProjectName,
|
|
30
29
|
rootProject: options.createPackageName ? false : true,
|
|
31
30
|
});
|
|
32
31
|
tasks.push(pluginTask);
|