@nx/plugin 17.0.0-beta.6 → 17.0.0-beta.8
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 +6 -6
- package/src/generators/create-package/create-package.js +2 -1
- package/src/generators/create-package/schema.d.ts +1 -1
- package/src/generators/e2e-project/e2e.js +4 -4
- package/src/generators/e2e-project/schema.d.ts +1 -1
- package/src/generators/executor/executor.js +4 -9
- package/src/generators/executor/schema.d.ts +5 -1
- package/src/generators/executor/schema.json +13 -10
- package/src/generators/generator/generator.d.ts +2 -1
- package/src/generators/generator/generator.js +36 -17
- package/src/generators/generator/schema.d.ts +9 -1
- package/src/generators/generator/schema.json +18 -12
- package/src/generators/lint-checks/generator.d.ts +1 -1
- package/src/generators/lint-checks/generator.js +7 -4
- package/src/generators/migration/migration.d.ts +2 -1
- package/src/generators/migration/migration.js +37 -13
- package/src/generators/migration/schema.d.ts +9 -1
- package/src/generators/migration/schema.json +15 -11
- package/src/generators/plugin/plugin.js +2 -2
- package/src/generators/plugin/schema.d.ts +1 -1
- package/src/generators/preset/generator.js +3 -3
- /package/src/generators/generator/files/generator/{__fileName__/generator.spec.ts.template → generator.spec.ts.template} +0 -0
- /package/src/generators/generator/files/generator/{__fileName__/generator.ts.template → generator.ts.template} +0 -0
- /package/src/generators/generator/files/generator/{__fileName__/schema.d.ts.template → schema.d.ts.template} +0 -0
- /package/src/generators/generator/files/generator/{__fileName__/schema.json.template → schema.json.template} +0 -0
- /package/src/generators/migration/files/migration/{__name__/__name__.spec.ts__tmpl__ → __name__.spec.ts__tmpl__} +0 -0
- /package/src/generators/migration/files/migration/{__name__/__name__.ts__tmpl__ → __name__.ts__tmpl__} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/plugin",
|
|
3
|
-
"version": "17.0.0-beta.
|
|
3
|
+
"version": "17.0.0-beta.8",
|
|
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": {
|
|
@@ -31,11 +31,11 @@
|
|
|
31
31
|
"@phenomnomnominal/tsquery": "~5.0.1",
|
|
32
32
|
"fs-extra": "^11.1.0",
|
|
33
33
|
"tslib": "^2.3.0",
|
|
34
|
-
"@nx/devkit": "17.0.0-beta.
|
|
35
|
-
"@nx/jest": "17.0.0-beta.
|
|
36
|
-
"@nx/js": "17.0.0-beta.
|
|
37
|
-
"@nx/
|
|
38
|
-
"@nrwl/nx-plugin": "17.0.0-beta.
|
|
34
|
+
"@nx/devkit": "17.0.0-beta.8",
|
|
35
|
+
"@nx/jest": "17.0.0-beta.8",
|
|
36
|
+
"@nx/js": "17.0.0-beta.8",
|
|
37
|
+
"@nx/eslint": "17.0.0-beta.8",
|
|
38
|
+
"@nrwl/nx-plugin": "17.0.0-beta.8"
|
|
39
39
|
},
|
|
40
40
|
"publishConfig": {
|
|
41
41
|
"access": "public"
|
|
@@ -44,9 +44,10 @@ async function addPresetGenerator(host, schema) {
|
|
|
44
44
|
if (!(0, has_generator_1.hasGenerator)(host, schema.project, 'preset')) {
|
|
45
45
|
await (0, generator_1.default)(host, {
|
|
46
46
|
name: 'preset',
|
|
47
|
-
|
|
47
|
+
directory: (0, path_1.join)(projectRoot, 'src/generators/preset'),
|
|
48
48
|
unitTestRunner: schema.unitTestRunner,
|
|
49
49
|
skipFormat: true,
|
|
50
|
+
nameAndDirectoryFormat: 'as-provided',
|
|
50
51
|
});
|
|
51
52
|
}
|
|
52
53
|
return (0, devkit_1.readJson)(host, (0, devkit_1.joinPathFragments)(projectRoot, 'package.json'))?.name;
|
|
@@ -7,7 +7,7 @@ const jest_1 = require("@nx/jest");
|
|
|
7
7
|
const js_1 = require("@nx/js");
|
|
8
8
|
const generator_1 = require("@nx/js/src/generators/setup-verdaccio/generator");
|
|
9
9
|
const add_local_registry_scripts_1 = require("@nx/js/src/utils/add-local-registry-scripts");
|
|
10
|
-
const
|
|
10
|
+
const eslint_1 = require("@nx/eslint");
|
|
11
11
|
const path_1 = require("path");
|
|
12
12
|
async function normalizeOptions(host, options) {
|
|
13
13
|
const projectName = options.rootProject ? 'e2e' : `${options.pluginName}-e2e`;
|
|
@@ -38,7 +38,7 @@ async function normalizeOptions(host, options) {
|
|
|
38
38
|
return {
|
|
39
39
|
...options,
|
|
40
40
|
projectName,
|
|
41
|
-
linter: options.linter ??
|
|
41
|
+
linter: options.linter ?? eslint_1.Linter.EsLint,
|
|
42
42
|
pluginPropertyName,
|
|
43
43
|
projectRoot,
|
|
44
44
|
};
|
|
@@ -97,7 +97,7 @@ async function addJest(host, options) {
|
|
|
97
97
|
return jestTask;
|
|
98
98
|
}
|
|
99
99
|
async function addLintingToApplication(tree, options) {
|
|
100
|
-
const lintTask = await (0,
|
|
100
|
+
const lintTask = await (0, eslint_1.lintProjectGenerator)(tree, {
|
|
101
101
|
linter: options.linter,
|
|
102
102
|
project: options.projectName,
|
|
103
103
|
tsConfigPaths: [
|
|
@@ -126,7 +126,7 @@ async function e2eProjectGeneratorInternal(host, schema) {
|
|
|
126
126
|
skipFormat: true,
|
|
127
127
|
}));
|
|
128
128
|
tasks.push(await addJest(host, options));
|
|
129
|
-
if (options.linter !==
|
|
129
|
+
if (options.linter !== eslint_1.Linter.None) {
|
|
130
130
|
tasks.push(await addLintingToApplication(host, {
|
|
131
131
|
...options,
|
|
132
132
|
}));
|
|
@@ -5,7 +5,6 @@ const devkit_1 = require("@nx/devkit");
|
|
|
5
5
|
const path = require("path");
|
|
6
6
|
const generator_1 = require("../lint-checks/generator");
|
|
7
7
|
const versions_1 = require("../../utils/versions");
|
|
8
|
-
const get_npm_scope_1 = require("@nx/js/src/utils/package-json/get-npm-scope");
|
|
9
8
|
const artifact_name_and_directory_utils_1 = require("@nx/devkit/src/generators/artifact-name-and-directory-utils");
|
|
10
9
|
const path_1 = require("path");
|
|
11
10
|
function addFiles(host, options) {
|
|
@@ -63,20 +62,19 @@ async function updateExecutorJson(host, options) {
|
|
|
63
62
|
let executors = json.executors ?? json.builders;
|
|
64
63
|
executors ||= {};
|
|
65
64
|
executors[options.name] = {
|
|
66
|
-
implementation: `./${(0, devkit_1.
|
|
67
|
-
schema: `./${(0, devkit_1.
|
|
65
|
+
implementation: `./${(0, devkit_1.joinPathFragments)((0, path_1.relative)(options.projectRoot, options.directory), 'executor')}`,
|
|
66
|
+
schema: `./${(0, devkit_1.joinPathFragments)((0, path_1.relative)(options.projectRoot, options.directory), 'schema.json')}`,
|
|
68
67
|
description: options.description,
|
|
69
68
|
};
|
|
70
69
|
if (options.includeHasher) {
|
|
71
|
-
executors[options.name].hasher = `./${(0, devkit_1.
|
|
70
|
+
executors[options.name].hasher = `./${(0, devkit_1.joinPathFragments)((0, path_1.relative)(options.projectRoot, options.directory), 'hasher')}`;
|
|
72
71
|
}
|
|
73
72
|
json.executors = executors;
|
|
74
73
|
return json;
|
|
75
74
|
});
|
|
76
75
|
}
|
|
77
76
|
async function normalizeOptions(tree, options) {
|
|
78
|
-
const
|
|
79
|
-
const res = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(tree, {
|
|
77
|
+
const { project, artifactName, filePath, directory } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(tree, {
|
|
80
78
|
artifactType: 'executor',
|
|
81
79
|
callingGenerator: '@nx/plugin:executor',
|
|
82
80
|
name: options.name,
|
|
@@ -86,7 +84,6 @@ async function normalizeOptions(tree, options) {
|
|
|
86
84
|
fileName: 'executor',
|
|
87
85
|
derivedDirectory: 'executors',
|
|
88
86
|
});
|
|
89
|
-
const { project, fileName, artifactName, filePath, directory } = res;
|
|
90
87
|
const { className, propertyName } = (0, devkit_1.names)(artifactName);
|
|
91
88
|
const { root: projectRoot } = (0, devkit_1.readProjectConfiguration)(tree, project);
|
|
92
89
|
let description;
|
|
@@ -101,12 +98,10 @@ async function normalizeOptions(tree, options) {
|
|
|
101
98
|
filePath,
|
|
102
99
|
project,
|
|
103
100
|
directory,
|
|
104
|
-
fileName,
|
|
105
101
|
className,
|
|
106
102
|
propertyName,
|
|
107
103
|
description,
|
|
108
104
|
projectRoot,
|
|
109
|
-
npmScope,
|
|
110
105
|
};
|
|
111
106
|
}
|
|
112
107
|
async function executorGenerator(tree, rawOptions) {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { NameAndDirectoryFormat } from '@nx/devkit/src/generators/artifact-name-and-directory-utils';
|
|
2
2
|
|
|
3
3
|
export interface Schema {
|
|
4
|
-
project?: string;
|
|
5
4
|
name: string;
|
|
6
5
|
directory?: string;
|
|
7
6
|
description?: string;
|
|
@@ -10,4 +9,9 @@ export interface Schema {
|
|
|
10
9
|
nameAndDirectoryFormat?: NameAndDirectoryFormat;
|
|
11
10
|
skipLintChecks?: boolean;
|
|
12
11
|
skipFormat?: boolean;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated Provide the `directory` option instead. The project will be determined from the directory provided. It will be removed in Nx v18.
|
|
15
|
+
*/
|
|
16
|
+
project?: string;
|
|
13
17
|
}
|
|
@@ -13,14 +13,6 @@
|
|
|
13
13
|
}
|
|
14
14
|
],
|
|
15
15
|
"properties": {
|
|
16
|
-
"project": {
|
|
17
|
-
"type": "string",
|
|
18
|
-
"description": "The name of the project.",
|
|
19
|
-
"alias": "p",
|
|
20
|
-
"$default": {
|
|
21
|
-
"$source": "projectName"
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
16
|
"name": {
|
|
25
17
|
"type": "string",
|
|
26
18
|
"description": "Executor name.",
|
|
@@ -34,11 +26,13 @@
|
|
|
34
26
|
"directory": {
|
|
35
27
|
"type": "string",
|
|
36
28
|
"description": "The directory at which to create the executor file. When `--nameAndDirectoryFormat=as-provided`, it will be relative to the current working directory. Otherwise, it will be relative to the workspace root.",
|
|
37
|
-
"aliases": ["dir"]
|
|
29
|
+
"aliases": ["dir"],
|
|
30
|
+
"x-priority": "important"
|
|
38
31
|
},
|
|
39
32
|
"description": {
|
|
40
33
|
"type": "string",
|
|
41
|
-
"description": "Executor description."
|
|
34
|
+
"description": "Executor description.",
|
|
35
|
+
"x-priority": "important"
|
|
42
36
|
},
|
|
43
37
|
"unitTestRunner": {
|
|
44
38
|
"type": "string",
|
|
@@ -61,6 +55,15 @@
|
|
|
61
55
|
"type": "string",
|
|
62
56
|
"enum": ["as-provided", "derived"]
|
|
63
57
|
},
|
|
58
|
+
"project": {
|
|
59
|
+
"type": "string",
|
|
60
|
+
"description": "The name of the project.",
|
|
61
|
+
"alias": "p",
|
|
62
|
+
"$default": {
|
|
63
|
+
"$source": "projectName"
|
|
64
|
+
},
|
|
65
|
+
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v18."
|
|
66
|
+
},
|
|
64
67
|
"skipFormat": {
|
|
65
68
|
"type": "boolean",
|
|
66
69
|
"description": "Skip formatting files.",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Tree } from '@nx/devkit';
|
|
2
2
|
import type { Schema } from './schema';
|
|
3
3
|
export declare function createGeneratorsJson(host: Tree, projectRoot: string, projectName: string, skipLintChecks?: boolean, skipFormat?: boolean): Promise<void>;
|
|
4
|
-
export declare function generatorGenerator(
|
|
4
|
+
export declare function generatorGenerator(tree: Tree, rawOptions: Schema): Promise<void>;
|
|
5
|
+
export declare function generatorGeneratorInternal(host: Tree, schema: Schema): Promise<void>;
|
|
5
6
|
export default generatorGenerator;
|
|
@@ -1,15 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generatorGenerator = exports.createGeneratorsJson = void 0;
|
|
3
|
+
exports.generatorGeneratorInternal = exports.generatorGenerator = exports.createGeneratorsJson = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const path = require("path");
|
|
6
5
|
const has_generator_1 = require("../../utils/has-generator");
|
|
7
6
|
const generator_1 = require("../lint-checks/generator");
|
|
8
7
|
const versions_1 = require("../../utils/versions");
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const
|
|
8
|
+
const artifact_name_and_directory_utils_1 = require("@nx/devkit/src/generators/artifact-name-and-directory-utils");
|
|
9
|
+
const path_1 = require("path");
|
|
10
|
+
async function normalizeOptions(tree, options) {
|
|
11
|
+
const { project, fileName, artifactName, filePath, directory } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(tree, {
|
|
12
|
+
artifactType: 'generator',
|
|
13
|
+
callingGenerator: '@nx/plugin:generator',
|
|
14
|
+
name: options.name,
|
|
15
|
+
nameAndDirectoryFormat: options.nameAndDirectoryFormat,
|
|
16
|
+
project: options.project,
|
|
17
|
+
directory: options.directory,
|
|
18
|
+
fileName: 'generator',
|
|
19
|
+
derivedDirectory: 'generators',
|
|
20
|
+
});
|
|
21
|
+
const { className, propertyName } = (0, devkit_1.names)(artifactName);
|
|
22
|
+
const { root: projectRoot, sourceRoot: projectSourceRoot } = (0, devkit_1.readProjectConfiguration)(tree, project);
|
|
13
23
|
let description;
|
|
14
24
|
if (options.description) {
|
|
15
25
|
description = options.description;
|
|
@@ -19,26 +29,28 @@ function normalizeOptions(host, options) {
|
|
|
19
29
|
}
|
|
20
30
|
return {
|
|
21
31
|
...options,
|
|
22
|
-
|
|
32
|
+
project,
|
|
33
|
+
directory,
|
|
34
|
+
fileName,
|
|
35
|
+
className,
|
|
36
|
+
propertyName,
|
|
23
37
|
description,
|
|
24
38
|
projectRoot,
|
|
25
39
|
projectSourceRoot,
|
|
26
|
-
npmScope,
|
|
27
|
-
npmPackageName,
|
|
28
40
|
};
|
|
29
41
|
}
|
|
30
42
|
function addFiles(host, options) {
|
|
31
|
-
const indexPath =
|
|
43
|
+
const indexPath = (0, path_1.join)(options.directory, 'files/src/index.ts.template');
|
|
32
44
|
if (!host.exists(indexPath)) {
|
|
33
45
|
host.write(indexPath, 'const variable = "<%= name %>";');
|
|
34
46
|
}
|
|
35
|
-
(0, devkit_1.generateFiles)(host,
|
|
47
|
+
(0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, './files/generator'), options.directory, {
|
|
36
48
|
...options,
|
|
37
49
|
generatorFnName: `${options.propertyName}Generator`,
|
|
38
50
|
schemaInterfaceName: `${options.className}GeneratorSchema`,
|
|
39
51
|
});
|
|
40
52
|
if (options.unitTestRunner === 'none') {
|
|
41
|
-
host.delete(
|
|
53
|
+
host.delete((0, path_1.join)(options.directory, `generator.spec.ts`));
|
|
42
54
|
}
|
|
43
55
|
}
|
|
44
56
|
async function createGeneratorsJson(host, projectRoot, projectName, skipLintChecks, skipFormat) {
|
|
@@ -81,8 +93,8 @@ async function updateGeneratorJson(host, options) {
|
|
|
81
93
|
let generators = json.generators ?? json.schematics;
|
|
82
94
|
generators = generators || {};
|
|
83
95
|
generators[options.name] = {
|
|
84
|
-
factory:
|
|
85
|
-
schema:
|
|
96
|
+
factory: `./${(0, devkit_1.joinPathFragments)((0, path_1.relative)(options.projectRoot, options.directory), 'generator')}`,
|
|
97
|
+
schema: `./${(0, devkit_1.joinPathFragments)((0, path_1.relative)(options.projectRoot, options.directory), 'schema.json')}`,
|
|
86
98
|
description: options.description,
|
|
87
99
|
};
|
|
88
100
|
// @todo(v17): Remove this, prop is defunct.
|
|
@@ -93,8 +105,15 @@ async function updateGeneratorJson(host, options) {
|
|
|
93
105
|
return json;
|
|
94
106
|
});
|
|
95
107
|
}
|
|
96
|
-
async function generatorGenerator(
|
|
97
|
-
|
|
108
|
+
async function generatorGenerator(tree, rawOptions) {
|
|
109
|
+
await generatorGeneratorInternal(tree, {
|
|
110
|
+
nameAndDirectoryFormat: 'derived',
|
|
111
|
+
...rawOptions,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
exports.generatorGenerator = generatorGenerator;
|
|
115
|
+
async function generatorGeneratorInternal(host, schema) {
|
|
116
|
+
const options = await normalizeOptions(host, schema);
|
|
98
117
|
if ((0, has_generator_1.hasGenerator)(host, options.project, options.name)) {
|
|
99
118
|
throw new Error(`Generator ${options.name} already exists.`);
|
|
100
119
|
}
|
|
@@ -104,5 +123,5 @@ async function generatorGenerator(host, schema) {
|
|
|
104
123
|
await (0, devkit_1.formatFiles)(host);
|
|
105
124
|
}
|
|
106
125
|
}
|
|
107
|
-
exports.
|
|
126
|
+
exports.generatorGeneratorInternal = generatorGeneratorInternal;
|
|
108
127
|
exports.default = generatorGenerator;
|
|
@@ -1,8 +1,16 @@
|
|
|
1
|
+
import { NameAndDirectoryFormat } from '@nx/devkit/src/generators/artifact-name-and-directory-utils';
|
|
2
|
+
|
|
1
3
|
export interface Schema {
|
|
2
|
-
|
|
4
|
+
directory?: string;
|
|
3
5
|
name: string;
|
|
4
6
|
description?: string;
|
|
5
7
|
unitTestRunner: 'jest' | 'none';
|
|
6
8
|
skipLintChecks?: boolean;
|
|
7
9
|
skipFormat?: boolean;
|
|
10
|
+
nameAndDirectoryFormat?: NameAndDirectoryFormat;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @deprecated Provide the `directory` option instead. The project will be determined from the directory provided. It will be removed in Nx v18.
|
|
14
|
+
*/
|
|
15
|
+
project?: string;
|
|
8
16
|
}
|
|
@@ -12,16 +12,6 @@
|
|
|
12
12
|
}
|
|
13
13
|
],
|
|
14
14
|
"properties": {
|
|
15
|
-
"project": {
|
|
16
|
-
"type": "string",
|
|
17
|
-
"description": "The name of the project.",
|
|
18
|
-
"alias": "p",
|
|
19
|
-
"$default": {
|
|
20
|
-
"$source": "projectName"
|
|
21
|
-
},
|
|
22
|
-
"x-prompt": "What is the name of the project for the generator?",
|
|
23
|
-
"x-priority": "important"
|
|
24
|
-
},
|
|
25
15
|
"name": {
|
|
26
16
|
"type": "string",
|
|
27
17
|
"description": "Generator name.",
|
|
@@ -32,10 +22,17 @@
|
|
|
32
22
|
"x-prompt": "What name would you like to use for the generator?",
|
|
33
23
|
"x-priority": "important"
|
|
34
24
|
},
|
|
25
|
+
"directory": {
|
|
26
|
+
"type": "string",
|
|
27
|
+
"description": "The directory at which to create the generator file. When `--nameAndDirectoryFormat=as-provided`, it will be relative to the current working directory. Otherwise, it will be relative to the workspace root.",
|
|
28
|
+
"aliases": ["dir"],
|
|
29
|
+
"x-priority": "important"
|
|
30
|
+
},
|
|
35
31
|
"description": {
|
|
36
32
|
"type": "string",
|
|
37
33
|
"description": "Generator description.",
|
|
38
|
-
"alias": "d"
|
|
34
|
+
"alias": "d",
|
|
35
|
+
"x-priority": "important"
|
|
39
36
|
},
|
|
40
37
|
"unitTestRunner": {
|
|
41
38
|
"type": "string",
|
|
@@ -48,6 +45,15 @@
|
|
|
48
45
|
"default": false,
|
|
49
46
|
"description": "Do not add an eslint configuration for plugin json files."
|
|
50
47
|
},
|
|
48
|
+
"project": {
|
|
49
|
+
"type": "string",
|
|
50
|
+
"description": "The name of the project.",
|
|
51
|
+
"alias": "p",
|
|
52
|
+
"$default": {
|
|
53
|
+
"$source": "projectName"
|
|
54
|
+
},
|
|
55
|
+
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v18."
|
|
56
|
+
},
|
|
51
57
|
"skipFormat": {
|
|
52
58
|
"type": "boolean",
|
|
53
59
|
"default": false,
|
|
@@ -55,6 +61,6 @@
|
|
|
55
61
|
"x-priority": "internal"
|
|
56
62
|
}
|
|
57
63
|
},
|
|
58
|
-
"required": ["
|
|
64
|
+
"required": ["name"],
|
|
59
65
|
"additionalProperties": false
|
|
60
66
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ProjectConfiguration, TargetConfiguration, Tree } from '@nx/devkit';
|
|
2
|
-
import type { Schema as EsLintExecutorOptions } from '@nx/
|
|
2
|
+
import type { Schema as EsLintExecutorOptions } from '@nx/eslint/src/executors/lint/schema';
|
|
3
3
|
import { PluginLintChecksGeneratorSchema } from './schema';
|
|
4
4
|
import { PackageJson } from 'nx/src/utils/package-json';
|
|
5
5
|
export default function pluginLintCheckGenerator(host: Tree, options: PluginLintChecksGeneratorSchema): Promise<void>;
|
|
@@ -4,8 +4,8 @@ exports.getEsLintOptions = exports.addMigrationJsonChecks = void 0;
|
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const logger_1 = require("nx/src/utils/logger");
|
|
6
6
|
const package_json_1 = require("nx/src/utils/package-json");
|
|
7
|
-
const eslint_file_1 = require("@nx/
|
|
8
|
-
const flat_config_1 = require("@nx/
|
|
7
|
+
const eslint_file_1 = require("@nx/eslint/src/generators/utils/eslint-file");
|
|
8
|
+
const flat_config_1 = require("@nx/eslint/src/utils/flat-config");
|
|
9
9
|
async function pluginLintCheckGenerator(host, options) {
|
|
10
10
|
const project = (0, devkit_1.readProjectConfiguration)(host, options.projectName);
|
|
11
11
|
const packageJson = (0, devkit_1.readJson)(host, (0, devkit_1.joinPathFragments)(project.root, 'package.json'));
|
|
@@ -68,7 +68,8 @@ function updateProjectTarget(host, options, packageJson) {
|
|
|
68
68
|
return;
|
|
69
69
|
}
|
|
70
70
|
for (const [target, configuration] of Object.entries(project.targets)) {
|
|
71
|
-
if (configuration.executor === '@nx/
|
|
71
|
+
if (configuration.executor === '@nx/eslint:lint' ||
|
|
72
|
+
configuration.executor === '@nx/linter:eslint' ||
|
|
72
73
|
configuration.executor === '@nrwl/linter:eslint') {
|
|
73
74
|
const opts = configuration.options ?? {};
|
|
74
75
|
opts.lintFilePatterns ??= [];
|
|
@@ -181,6 +182,8 @@ function projectIsEsLintEnabled(project) {
|
|
|
181
182
|
return !!getEsLintOptions(project);
|
|
182
183
|
}
|
|
183
184
|
function getEsLintOptions(project) {
|
|
184
|
-
return Object.entries(project.targets || {}).find(([, x]) => x.executor === '@nx/
|
|
185
|
+
return Object.entries(project.targets || {}).find(([, x]) => x.executor === '@nx/eslint:lint' ||
|
|
186
|
+
x.executor === '@nx/linter:eslint' ||
|
|
187
|
+
x.executor === '@nrwl/linter:eslint');
|
|
185
188
|
}
|
|
186
189
|
exports.getEsLintOptions = getEsLintOptions;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Tree } from '@nx/devkit';
|
|
2
2
|
import type { Schema } from './schema';
|
|
3
|
-
export declare function migrationGenerator(
|
|
3
|
+
export declare function migrationGenerator(tree: Tree, rawOptions: Schema): Promise<void>;
|
|
4
|
+
export declare function migrationGeneratorInternal(host: Tree, schema: Schema): Promise<void>;
|
|
4
5
|
export default migrationGenerator;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.migrationGenerator = void 0;
|
|
3
|
+
exports.migrationGeneratorInternal = exports.migrationGenerator = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const path = require("path");
|
|
6
6
|
const generator_1 = require("../lint-checks/generator");
|
|
7
7
|
const package_json_1 = require("nx/src/utils/package-json");
|
|
8
8
|
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
|
+
const path_1 = require("path");
|
|
11
|
+
async function normalizeOptions(tree, options) {
|
|
10
12
|
let name;
|
|
11
13
|
if (options.name) {
|
|
12
14
|
name = (0, devkit_1.names)(options.name).fileName;
|
|
@@ -14,11 +16,26 @@ function normalizeOptions(host, options) {
|
|
|
14
16
|
else {
|
|
15
17
|
name = (0, devkit_1.names)(`update-${options.packageVersion}`).fileName;
|
|
16
18
|
}
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
+
const { project, fileName, artifactName, filePath, directory } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(tree, {
|
|
20
|
+
artifactType: 'migration',
|
|
21
|
+
callingGenerator: '@nx/plugin:migration',
|
|
22
|
+
name: name,
|
|
23
|
+
nameAndDirectoryFormat: options.nameAndDirectoryFormat,
|
|
24
|
+
project: options.project,
|
|
25
|
+
directory: options.directory,
|
|
26
|
+
fileName: name,
|
|
27
|
+
derivedDirectory: 'migrations',
|
|
28
|
+
});
|
|
29
|
+
const { className, propertyName } = (0, devkit_1.names)(artifactName);
|
|
30
|
+
const { root: projectRoot, sourceRoot: projectSourceRoot } = (0, devkit_1.readProjectConfiguration)(tree, project);
|
|
31
|
+
const description = options.description ?? `Migration for v${options.packageVersion}`;
|
|
32
|
+
// const { root: projectRoot, sourceRoot: projectSourceRoot } =
|
|
33
|
+
// readProjectConfiguration(host, options.project);
|
|
19
34
|
const normalized = {
|
|
20
35
|
...options,
|
|
21
|
-
|
|
36
|
+
project,
|
|
37
|
+
name: artifactName,
|
|
38
|
+
directory,
|
|
22
39
|
description,
|
|
23
40
|
projectRoot,
|
|
24
41
|
projectSourceRoot,
|
|
@@ -26,7 +43,7 @@ function normalizeOptions(host, options) {
|
|
|
26
43
|
return normalized;
|
|
27
44
|
}
|
|
28
45
|
function addFiles(host, options) {
|
|
29
|
-
(0, devkit_1.generateFiles)(host, path.join(__dirname, 'files/migration'),
|
|
46
|
+
(0, devkit_1.generateFiles)(host, path.join(__dirname, 'files/migration'), options.directory, { ...options, tmpl: '' });
|
|
30
47
|
}
|
|
31
48
|
function updateMigrationsJson(host, options) {
|
|
32
49
|
const configuredMigrationPath = (0, package_json_1.readNxMigrateConfig)((0, devkit_1.readJson)(host, (0, devkit_1.joinPathFragments)(options.projectRoot, 'package.json'))).migrations;
|
|
@@ -38,7 +55,7 @@ function updateMigrationsJson(host, options) {
|
|
|
38
55
|
generators[options.name] = {
|
|
39
56
|
version: options.packageVersion,
|
|
40
57
|
description: options.description,
|
|
41
|
-
implementation:
|
|
58
|
+
implementation: `./${(0, devkit_1.joinPathFragments)((0, path_1.relative)(options.projectRoot, options.directory), options.name)}`,
|
|
42
59
|
};
|
|
43
60
|
migrations.generators = generators;
|
|
44
61
|
if (options.packageJsonUpdates) {
|
|
@@ -76,7 +93,7 @@ function updatePackageJson(host, options) {
|
|
|
76
93
|
return json;
|
|
77
94
|
});
|
|
78
95
|
}
|
|
79
|
-
function
|
|
96
|
+
function updateProjectConfig(host, options) {
|
|
80
97
|
const project = (0, devkit_1.readProjectConfiguration)(host, options.project);
|
|
81
98
|
const assets = project.targets.build?.options?.assets;
|
|
82
99
|
if (assets &&
|
|
@@ -92,20 +109,27 @@ function updateWorkspaceJson(host, options) {
|
|
|
92
109
|
(0, devkit_1.updateProjectConfiguration)(host, options.project, project);
|
|
93
110
|
}
|
|
94
111
|
}
|
|
95
|
-
async function migrationGenerator(
|
|
96
|
-
|
|
112
|
+
async function migrationGenerator(tree, rawOptions) {
|
|
113
|
+
await migrationGeneratorInternal(tree, {
|
|
114
|
+
nameAndDirectoryFormat: 'derived',
|
|
115
|
+
...rawOptions,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
exports.migrationGenerator = migrationGenerator;
|
|
119
|
+
async function migrationGeneratorInternal(host, schema) {
|
|
120
|
+
const options = await normalizeOptions(host, schema);
|
|
97
121
|
addFiles(host, options);
|
|
98
122
|
updateMigrationsJson(host, options);
|
|
99
|
-
|
|
123
|
+
updateProjectConfig(host, options);
|
|
100
124
|
updateMigrationsJson(host, options);
|
|
101
125
|
updatePackageJson(host, options);
|
|
102
126
|
if (!host.exists('migrations.json')) {
|
|
103
127
|
const packageJsonPath = (0, devkit_1.joinPathFragments)(options.projectRoot, 'package.json');
|
|
104
|
-
(0, generator_1.addMigrationJsonChecks)(host, { projectName:
|
|
128
|
+
(0, generator_1.addMigrationJsonChecks)(host, { projectName: options.project }, (0, devkit_1.readJson)(host, packageJsonPath));
|
|
105
129
|
}
|
|
106
130
|
if (!options.skipFormat) {
|
|
107
131
|
await (0, devkit_1.formatFiles)(host);
|
|
108
132
|
}
|
|
109
133
|
}
|
|
110
|
-
exports.
|
|
134
|
+
exports.migrationGeneratorInternal = migrationGeneratorInternal;
|
|
111
135
|
exports.default = migrationGenerator;
|
|
@@ -1,8 +1,16 @@
|
|
|
1
|
+
import { NameAndDirectoryFormat } from '@nx/devkit/src/generators/artifact-name-and-directory-utils';
|
|
2
|
+
|
|
1
3
|
export interface Schema {
|
|
2
|
-
project: string;
|
|
3
4
|
name?: string;
|
|
5
|
+
directory?: string;
|
|
4
6
|
description?: string;
|
|
5
7
|
packageVersion: string;
|
|
6
8
|
packageJsonUpdates?: boolean;
|
|
7
9
|
skipFormat?: boolean;
|
|
10
|
+
nameAndDirectoryFormat?: NameAndDirectoryFormat;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @deprecated Provide the `directory` option instead. The project will be determined from the directory provided. It will be removed in Nx v18.
|
|
14
|
+
*/
|
|
15
|
+
project?: string;
|
|
8
16
|
}
|
|
@@ -12,16 +12,6 @@
|
|
|
12
12
|
}
|
|
13
13
|
],
|
|
14
14
|
"properties": {
|
|
15
|
-
"project": {
|
|
16
|
-
"type": "string",
|
|
17
|
-
"description": "The name of the project.",
|
|
18
|
-
"alias": "p",
|
|
19
|
-
"$default": {
|
|
20
|
-
"$source": "projectName"
|
|
21
|
-
},
|
|
22
|
-
"x-prompt": "What is the name of the project for the migration?",
|
|
23
|
-
"x-priority": "important"
|
|
24
|
-
},
|
|
25
15
|
"name": {
|
|
26
16
|
"type": "string",
|
|
27
17
|
"description": "Migration name.",
|
|
@@ -31,6 +21,11 @@
|
|
|
31
21
|
},
|
|
32
22
|
"x-priority": "important"
|
|
33
23
|
},
|
|
24
|
+
"directory": {
|
|
25
|
+
"type": "string",
|
|
26
|
+
"description": "The directory at which to create the migration file. When `--nameAndDirectoryFormat=as-provided`, it will be relative to the current working directory. Otherwise, it will be relative to the workspace root.",
|
|
27
|
+
"aliases": ["dir"]
|
|
28
|
+
},
|
|
34
29
|
"description": {
|
|
35
30
|
"type": "string",
|
|
36
31
|
"description": "Migration description."
|
|
@@ -42,6 +37,15 @@
|
|
|
42
37
|
"x-prompt": "What version would you like to use for the migration?",
|
|
43
38
|
"x-priority": "important"
|
|
44
39
|
},
|
|
40
|
+
"project": {
|
|
41
|
+
"type": "string",
|
|
42
|
+
"description": "The name of the project.",
|
|
43
|
+
"alias": "p",
|
|
44
|
+
"$default": {
|
|
45
|
+
"$source": "projectName"
|
|
46
|
+
},
|
|
47
|
+
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v18."
|
|
48
|
+
},
|
|
45
49
|
"packageJsonUpdates": {
|
|
46
50
|
"type": "boolean",
|
|
47
51
|
"description": "Whether or not to include `package.json` updates.",
|
|
@@ -54,6 +58,6 @@
|
|
|
54
58
|
"description": "Do not eslint configuration for plugin json files."
|
|
55
59
|
}
|
|
56
60
|
},
|
|
57
|
-
"required": ["
|
|
61
|
+
"required": ["packageVersion"],
|
|
58
62
|
"additionalProperties": false
|
|
59
63
|
}
|
|
@@ -4,7 +4,7 @@ exports.pluginGeneratorInternal = exports.pluginGenerator = void 0;
|
|
|
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
|
|
7
|
+
const eslint_1 = require("@nx/eslint");
|
|
8
8
|
const path = require("path");
|
|
9
9
|
const e2e_1 = require("../e2e-project/e2e");
|
|
10
10
|
const generator_1 = require("../lint-checks/generator");
|
|
@@ -95,7 +95,7 @@ async function pluginGeneratorInternal(host, schema) {
|
|
|
95
95
|
projectNameAndRootFormat: options.projectNameAndRootFormat,
|
|
96
96
|
}));
|
|
97
97
|
}
|
|
98
|
-
if (options.linter ===
|
|
98
|
+
if (options.linter === eslint_1.Linter.EsLint && !options.skipLintChecks) {
|
|
99
99
|
await (0, generator_1.default)(host, { projectName: options.name });
|
|
100
100
|
}
|
|
101
101
|
if (!options.skipFormat) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const devkit_1 = require("@nx/devkit");
|
|
4
|
-
const
|
|
4
|
+
const eslint_1 = require("@nx/eslint");
|
|
5
5
|
const plugin_1 = require("../plugin/plugin");
|
|
6
6
|
const create_package_1 = require("../create-package/create-package");
|
|
7
7
|
async function default_1(tree, options) {
|
|
@@ -15,7 +15,7 @@ async function default_1(tree, options) {
|
|
|
15
15
|
: options.createPackageName;
|
|
16
16
|
const pluginTask = await (0, plugin_1.pluginGenerator)(tree, {
|
|
17
17
|
compiler: 'tsc',
|
|
18
|
-
linter:
|
|
18
|
+
linter: eslint_1.Linter.EsLint,
|
|
19
19
|
name: pluginProjectName,
|
|
20
20
|
skipFormat: true,
|
|
21
21
|
unitTestRunner: 'jest',
|
|
@@ -40,7 +40,7 @@ async function default_1(tree, options) {
|
|
|
40
40
|
project: options.pluginName,
|
|
41
41
|
skipFormat: true,
|
|
42
42
|
unitTestRunner: 'jest',
|
|
43
|
-
linter:
|
|
43
|
+
linter: eslint_1.Linter.EsLint,
|
|
44
44
|
compiler: 'tsc',
|
|
45
45
|
});
|
|
46
46
|
tasks.push(cliTask);
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|