@nx/plugin 17.0.3 → 17.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +9 -4
- package/executors.json +1 -1
- package/generators.json +1 -1
- package/package.json +7 -7
- package/src/executors/e2e/e2e.impl.js +2 -2
- package/src/generators/create-package/files/create-framework-package/bin/index.ts__tmpl__ +1 -1
- package/src/generators/create-package/schema.d.ts +1 -1
- package/src/generators/create-package/schema.json +1 -1
- package/src/generators/e2e-project/e2e.js +11 -7
- package/src/generators/e2e-project/files/src/__pluginName__.spec.ts__tmpl__ +1 -1
- package/src/generators/e2e-project/schema.d.ts +2 -1
- package/src/generators/e2e-project/schema.json +1 -1
- package/src/generators/executor/files/executor/schema.json.template +1 -1
- package/src/generators/executor/schema.d.ts +1 -1
- package/src/generators/executor/schema.json +2 -2
- package/src/generators/generator/files/generator/schema.json.template +1 -1
- package/src/generators/generator/schema.d.ts +1 -1
- package/src/generators/generator/schema.json +2 -2
- package/src/generators/lint-checks/generator.js +25 -27
- package/src/generators/lint-checks/schema.json +1 -1
- package/src/generators/migration/migration.js +1 -1
- package/src/generators/migration/schema.d.ts +1 -1
- package/src/generators/migration/schema.json +2 -2
- package/src/generators/plugin/plugin.js +3 -0
- package/src/generators/plugin/schema.d.ts +1 -1
- package/src/generators/plugin/schema.json +1 -1
- package/src/generators/preset/schema.json +1 -1
- package/src/utils/testing-utils/async-commands.js +2 -1
- package/src/utils/testing-utils/commands.js +3 -2
- package/src/utils/testing-utils/nx-project.js +3 -2
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
<p style="text-align: center;"
|
|
1
|
+
<p style="text-align: center;">
|
|
2
|
+
<picture>
|
|
3
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-dark.svg">
|
|
4
|
+
<img alt="Nx - Smart Monorepos · Fast CI" src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-light.svg" width="100%">
|
|
5
|
+
</picture>
|
|
6
|
+
</p>
|
|
2
7
|
|
|
3
8
|
<div style="text-align: center;">
|
|
4
9
|
|
|
@@ -15,9 +20,9 @@
|
|
|
15
20
|
|
|
16
21
|
<hr>
|
|
17
22
|
|
|
18
|
-
# Nx: Smart
|
|
23
|
+
# Nx: Smart Monorepos · Fast CI
|
|
19
24
|
|
|
20
|
-
Nx is a
|
|
25
|
+
Nx is a build system with built-in tooling and advanced CI capabilities. It helps you maintain and scale monorepos, both locally and on CI.
|
|
21
26
|
|
|
22
27
|
## What is It?
|
|
23
28
|
|
|
@@ -63,5 +68,5 @@ npx nx@latest init
|
|
|
63
68
|
- [Blog Posts About Nx](https://blog.nrwl.io/nx/home)
|
|
64
69
|
|
|
65
70
|
<p style="text-align: center;"><a href="https://nx.dev/#learning-materials" target="_blank" rel="noreferrer"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-courses-and-videos.svg"
|
|
66
|
-
width="100%" alt="Nx - Smart
|
|
71
|
+
width="100%" alt="Nx - Smart Monorepos · Fast CI"></a></p>
|
|
67
72
|
|
package/executors.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"implementation": "./src/executors/e2e/e2e.impl",
|
|
5
5
|
"schema": "./src/executors/e2e/schema.json",
|
|
6
6
|
"description": "Creates and runs the E2E tests for an Nx Plugin.",
|
|
7
|
-
"x-deprecated": "@nx/plugin:e2e is deprecated and will be removed in Nx
|
|
7
|
+
"x-deprecated": "@nx/plugin:e2e is deprecated and will be removed in Nx v19. Use @nx/jest:jest instead."
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
10
|
}
|
package/generators.json
CHANGED
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"preset": {
|
|
42
42
|
"factory": "./src/generators/preset/generator",
|
|
43
43
|
"schema": "./src/generators/preset/schema.json",
|
|
44
|
-
"description": "Initializes a workspace with an nx-plugin inside of it. Use as: `create-nx-workspace --preset @
|
|
44
|
+
"description": "Initializes a workspace with an nx-plugin inside of it. Use as: `create-nx-workspace --preset @nx/plugin`.",
|
|
45
45
|
"hidden": true,
|
|
46
46
|
"x-use-standalone-layout": true
|
|
47
47
|
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/plugin",
|
|
3
|
-
"version": "17.0.
|
|
3
|
+
"version": "17.0.5",
|
|
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": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "https://github.com/nrwl/nx.git",
|
|
9
|
-
"directory": "packages/
|
|
9
|
+
"directory": "packages/plugin"
|
|
10
10
|
},
|
|
11
11
|
"keywords": [
|
|
12
12
|
"Monorepo",
|
|
@@ -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.
|
|
35
|
-
"@nx/jest": "17.0.
|
|
36
|
-
"@nx/js": "17.0.
|
|
37
|
-
"@nx/eslint": "17.0.
|
|
38
|
-
"@nrwl/nx-plugin": "17.0.
|
|
34
|
+
"@nx/devkit": "17.0.5",
|
|
35
|
+
"@nx/jest": "17.0.5",
|
|
36
|
+
"@nx/js": "17.0.5",
|
|
37
|
+
"@nx/eslint": "17.0.5",
|
|
38
|
+
"@nrwl/nx-plugin": "17.0.5"
|
|
39
39
|
},
|
|
40
40
|
"publishConfig": {
|
|
41
41
|
"access": "public"
|
|
@@ -3,11 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.nxPluginE2EExecutor = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const jest_impl_1 = require("@nx/jest/src/executors/jest/jest.impl");
|
|
6
|
-
// TODO(
|
|
6
|
+
// TODO(v19): remove this
|
|
7
7
|
async function* nxPluginE2EExecutor(options, context) {
|
|
8
8
|
const { target, ...jestOptions } = options;
|
|
9
9
|
devkit_1.output.warn({
|
|
10
|
-
title: `"@nx/plugin:e2e" is deprecated and will be removed in Nx
|
|
10
|
+
title: `"@nx/plugin:e2e" is deprecated and will be removed in Nx 19`,
|
|
11
11
|
bodyLines: [
|
|
12
12
|
'Use the "@nx/jest:jest" executor instead and set the following:',
|
|
13
13
|
`"dependsOn": ["${target}"]`,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ProjectNameAndRootFormat } from '@nx/devkit/src/generators/project-name-
|
|
1
|
+
import type { ProjectNameAndRootFormat } from '@nx/devkit/src/generators/project-name-and-root-utils';
|
|
2
2
|
import type { Linter } from '@nx/eslint';
|
|
3
3
|
|
|
4
4
|
export interface CreatePackageSchema {
|
|
@@ -11,6 +11,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`;
|
|
14
|
+
const nxJson = (0, devkit_1.readNxJson)(host);
|
|
15
|
+
const addPlugin = process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
16
|
+
nxJson.useInferencePlugins !== false;
|
|
17
|
+
options.addPlugin ??= addPlugin;
|
|
14
18
|
let projectRoot;
|
|
15
19
|
if (options.projectNameAndRootFormat === 'as-provided') {
|
|
16
20
|
const projectNameAndRootOptions = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
|
|
@@ -72,27 +76,26 @@ async function addJest(host, options) {
|
|
|
72
76
|
});
|
|
73
77
|
const jestTask = await (0, jest_1.configurationGenerator)(host, {
|
|
74
78
|
project: options.projectName,
|
|
79
|
+
targetName: 'e2e',
|
|
75
80
|
setupFile: 'none',
|
|
76
81
|
supportTsx: false,
|
|
77
82
|
skipSerializers: true,
|
|
78
83
|
skipFormat: true,
|
|
84
|
+
addPlugin: options.addPlugin,
|
|
79
85
|
});
|
|
80
86
|
const { startLocalRegistryPath, stopLocalRegistryPath } = (0, add_local_registry_scripts_1.addLocalRegistryScripts)(host);
|
|
81
87
|
(0, jest_1.addPropertyToJestConfig)(host, (0, path_1.join)(options.projectRoot, 'jest.config.ts'), 'globalSetup', (0, path_1.join)((0, devkit_1.offsetFromRoot)(options.projectRoot), startLocalRegistryPath));
|
|
82
88
|
(0, jest_1.addPropertyToJestConfig)(host, (0, path_1.join)(options.projectRoot, 'jest.config.ts'), 'globalTeardown', (0, path_1.join)((0, devkit_1.offsetFromRoot)(options.projectRoot), stopLocalRegistryPath));
|
|
83
89
|
const project = (0, devkit_1.readProjectConfiguration)(host, options.projectName);
|
|
84
|
-
const
|
|
90
|
+
const e2eTarget = project.targets.e2e;
|
|
85
91
|
project.targets.e2e = {
|
|
86
|
-
...
|
|
92
|
+
...e2eTarget,
|
|
87
93
|
dependsOn: [`^build`],
|
|
88
94
|
options: {
|
|
89
|
-
...
|
|
95
|
+
...e2eTarget.options,
|
|
90
96
|
runInBand: true,
|
|
91
97
|
},
|
|
92
|
-
configurations: testTarget.configurations,
|
|
93
98
|
};
|
|
94
|
-
// remove the jest build target
|
|
95
|
-
delete project.targets.test;
|
|
96
99
|
(0, devkit_1.updateProjectConfiguration)(host, options.projectName, project);
|
|
97
100
|
return jestTask;
|
|
98
101
|
}
|
|
@@ -103,15 +106,16 @@ async function addLintingToApplication(tree, options) {
|
|
|
103
106
|
tsConfigPaths: [
|
|
104
107
|
(0, devkit_1.joinPathFragments)(options.projectRoot, 'tsconfig.app.json'),
|
|
105
108
|
],
|
|
106
|
-
eslintFilePatterns: [`${options.projectRoot}/**/*.ts`],
|
|
107
109
|
unitTestRunner: 'jest',
|
|
108
110
|
skipFormat: true,
|
|
109
111
|
setParserOptionsProject: false,
|
|
112
|
+
addPlugin: options.addPlugin,
|
|
110
113
|
});
|
|
111
114
|
return lintTask;
|
|
112
115
|
}
|
|
113
116
|
async function e2eProjectGenerator(host, schema) {
|
|
114
117
|
return await e2eProjectGeneratorInternal(host, {
|
|
118
|
+
addPlugin: false,
|
|
115
119
|
projectNameAndRootFormat: 'derived',
|
|
116
120
|
...schema,
|
|
117
121
|
});
|
|
@@ -53,7 +53,7 @@ function createTestProject() {
|
|
|
53
53
|
});
|
|
54
54
|
|
|
55
55
|
execSync(
|
|
56
|
-
`<%= packageManagerCommands.exec %> --yes create-nx-workspace@latest ${projectName} --preset apps --
|
|
56
|
+
`<%= packageManagerCommands.exec %> --yes create-nx-workspace@latest ${projectName} --preset apps --nxCloud=skip --no-interactive`,
|
|
57
57
|
{
|
|
58
58
|
cwd: dirname(projectDirectory),
|
|
59
59
|
stdio: 'inherit',
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ProjectNameAndRootFormat } from '@nx/devkit/src/generators/project-name-
|
|
1
|
+
import type { ProjectNameAndRootFormat } from '@nx/devkit/src/generators/project-name-and-root-utils';
|
|
2
2
|
import type { Linter } from '@nx/eslint';
|
|
3
3
|
|
|
4
4
|
export interface Schema {
|
|
@@ -11,4 +11,5 @@ export interface Schema {
|
|
|
11
11
|
linter?: Linter;
|
|
12
12
|
skipFormat?: boolean;
|
|
13
13
|
rootProject?: boolean;
|
|
14
|
+
addPlugin?: boolean;
|
|
14
15
|
}
|
|
@@ -11,7 +11,7 @@ export interface Schema {
|
|
|
11
11
|
skipFormat?: boolean;
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
|
-
* @deprecated Provide the `directory` option instead. The project will be determined from the directory provided. It will be removed in Nx
|
|
14
|
+
* @deprecated Provide the `directory` option instead. The project will be determined from the directory provided. It will be removed in Nx v19.
|
|
15
15
|
*/
|
|
16
16
|
project?: string;
|
|
17
17
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$schema": "
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
3
|
"cli": "nx",
|
|
4
4
|
"$id": "NxPluginExecutor",
|
|
5
5
|
"title": "Create an Executor for an Nx Plugin",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"$default": {
|
|
63
63
|
"$source": "projectName"
|
|
64
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
|
|
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 v19."
|
|
66
66
|
},
|
|
67
67
|
"skipFormat": {
|
|
68
68
|
"type": "boolean",
|
|
@@ -10,7 +10,7 @@ export interface Schema {
|
|
|
10
10
|
nameAndDirectoryFormat?: NameAndDirectoryFormat;
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
* @deprecated Provide the `directory` option instead. The project will be determined from the directory provided. It will be removed in Nx
|
|
13
|
+
* @deprecated Provide the `directory` option instead. The project will be determined from the directory provided. It will be removed in Nx v19.
|
|
14
14
|
*/
|
|
15
15
|
project?: string;
|
|
16
16
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$schema": "
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
3
|
"cli": "nx",
|
|
4
4
|
"$id": "NxPluginGenerator",
|
|
5
5
|
"title": "Create a Generator for an Nx Plugin",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"$default": {
|
|
52
52
|
"$source": "projectName"
|
|
53
53
|
},
|
|
54
|
-
"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
|
|
54
|
+
"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 v19."
|
|
55
55
|
},
|
|
56
56
|
"skipFormat": {
|
|
57
57
|
"type": "boolean",
|
|
@@ -10,7 +10,7 @@ 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'));
|
|
12
12
|
// This rule is eslint **only**
|
|
13
|
-
if (projectIsEsLintEnabled(project)) {
|
|
13
|
+
if (projectIsEsLintEnabled(host, project)) {
|
|
14
14
|
updateRootEslintConfig(host);
|
|
15
15
|
updateProjectEslintConfig(host, project, packageJson);
|
|
16
16
|
updateProjectTarget(host, options, packageJson);
|
|
@@ -18,12 +18,6 @@ async function pluginLintCheckGenerator(host, options) {
|
|
|
18
18
|
if (host.exists('.vscode')) {
|
|
19
19
|
setupVsCodeLintingForJsonFiles(host);
|
|
20
20
|
}
|
|
21
|
-
// Project contains migrations.json
|
|
22
|
-
const migrationsPath = (0, package_json_1.readNxMigrateConfig)(packageJson).migrations;
|
|
23
|
-
if (migrationsPath &&
|
|
24
|
-
host.exists((0, devkit_1.joinPathFragments)(project.root, migrationsPath))) {
|
|
25
|
-
addMigrationJsonChecks(host, options, packageJson);
|
|
26
|
-
}
|
|
27
21
|
}
|
|
28
22
|
else {
|
|
29
23
|
devkit_1.logger.error(`${logger_1.NX_PREFIX} plugin lint checks can only be added to plugins which use eslint for linting`);
|
|
@@ -35,31 +29,34 @@ async function pluginLintCheckGenerator(host, options) {
|
|
|
35
29
|
exports.default = pluginLintCheckGenerator;
|
|
36
30
|
function addMigrationJsonChecks(host, options, packageJson) {
|
|
37
31
|
const projectConfiguration = (0, devkit_1.readProjectConfiguration)(host, options.projectName);
|
|
38
|
-
if (!projectIsEsLintEnabled(projectConfiguration)) {
|
|
32
|
+
if (!projectIsEsLintEnabled(host, projectConfiguration)) {
|
|
39
33
|
return;
|
|
40
34
|
}
|
|
41
|
-
const [eslintTarget, eslintTargetConfiguration] = getEsLintOptions(projectConfiguration);
|
|
35
|
+
const [eslintTarget, eslintTargetConfiguration] = getEsLintOptions(projectConfiguration) ?? [];
|
|
42
36
|
const relativeMigrationsJsonPath = (0, package_json_1.readNxMigrateConfig)(packageJson).migrations;
|
|
43
37
|
if (!relativeMigrationsJsonPath) {
|
|
44
38
|
return;
|
|
45
39
|
}
|
|
46
40
|
const migrationsJsonPath = (0, devkit_1.joinPathFragments)(projectConfiguration.root, relativeMigrationsJsonPath);
|
|
47
|
-
if (eslintTarget
|
|
48
|
-
|
|
49
|
-
|
|
41
|
+
if (!eslintTarget) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
// Add path to lintFilePatterns if different than default "{projectRoot}"
|
|
45
|
+
if (eslintTargetConfiguration.options?.lintFilePatterns &&
|
|
46
|
+
!eslintTargetConfiguration.options.lintFilePatterns.includes(migrationsJsonPath)) {
|
|
50
47
|
eslintTargetConfiguration.options.lintFilePatterns.push(migrationsJsonPath);
|
|
51
48
|
(0, devkit_1.updateProjectConfiguration)(host, options.projectName, projectConfiguration);
|
|
52
|
-
// Update project level eslintrc
|
|
53
|
-
(0, eslint_file_1.updateOverrideInLintConfig)(host, projectConfiguration.root, (o) => Object.keys(o.rules ?? {})?.includes('@nx/nx-plugin-checks') ||
|
|
54
|
-
Object.keys(o.rules ?? {})?.includes('@nrwl/nx/nx-plugin-checks'), (o) => {
|
|
55
|
-
const fileSet = new Set(Array.isArray(o.files) ? o.files : [o.files]);
|
|
56
|
-
fileSet.add(relativeMigrationsJsonPath);
|
|
57
|
-
return {
|
|
58
|
-
...o,
|
|
59
|
-
files: Array.from(fileSet),
|
|
60
|
-
};
|
|
61
|
-
});
|
|
62
49
|
}
|
|
50
|
+
// Update project level eslintrc
|
|
51
|
+
(0, eslint_file_1.updateOverrideInLintConfig)(host, projectConfiguration.root, (o) => Object.keys(o.rules ?? {})?.includes('@nx/nx-plugin-checks') ||
|
|
52
|
+
Object.keys(o.rules ?? {})?.includes('@nrwl/nx/nx-plugin-checks'), (o) => {
|
|
53
|
+
const fileSet = new Set(Array.isArray(o.files) ? o.files : [o.files]);
|
|
54
|
+
fileSet.add(relativeMigrationsJsonPath);
|
|
55
|
+
return {
|
|
56
|
+
...o,
|
|
57
|
+
files: Array.from(fileSet),
|
|
58
|
+
};
|
|
59
|
+
});
|
|
63
60
|
}
|
|
64
61
|
exports.addMigrationJsonChecks = addMigrationJsonChecks;
|
|
65
62
|
function updateProjectTarget(host, options, packageJson) {
|
|
@@ -68,9 +65,9 @@ function updateProjectTarget(host, options, packageJson) {
|
|
|
68
65
|
return;
|
|
69
66
|
}
|
|
70
67
|
for (const [target, configuration] of Object.entries(project.targets)) {
|
|
71
|
-
if (configuration.executor === '@nx/eslint:lint'
|
|
72
|
-
|
|
73
|
-
configuration.
|
|
68
|
+
if (configuration.executor === '@nx/eslint:lint' &&
|
|
69
|
+
// only add patterns if there are already hardcoded ones
|
|
70
|
+
configuration.options?.lintFilePatterns) {
|
|
74
71
|
const opts = configuration.options ?? {};
|
|
75
72
|
opts.lintFilePatterns ??= [];
|
|
76
73
|
if (packageJson.generators) {
|
|
@@ -104,6 +101,7 @@ function updateProjectEslintConfig(host, options, packageJson) {
|
|
|
104
101
|
packageJson.executors,
|
|
105
102
|
packageJson.schematics,
|
|
106
103
|
packageJson.builders,
|
|
104
|
+
(0, package_json_1.readNxMigrateConfig)(packageJson).migrations,
|
|
107
105
|
].filter((f) => !!f);
|
|
108
106
|
const parser = (0, flat_config_1.useFlatConfig)(host)
|
|
109
107
|
? { languageOptions: { parser: 'jsonc-eslint-parser' } }
|
|
@@ -178,8 +176,8 @@ function setupVsCodeLintingForJsonFiles(host) {
|
|
|
178
176
|
}
|
|
179
177
|
(0, devkit_1.writeJson)(host, '.vscode/settings.json', existing);
|
|
180
178
|
}
|
|
181
|
-
function projectIsEsLintEnabled(project) {
|
|
182
|
-
return !!
|
|
179
|
+
function projectIsEsLintEnabled(tree, project) {
|
|
180
|
+
return !!(0, eslint_file_1.findEslintFile)(tree, project.root);
|
|
183
181
|
}
|
|
184
182
|
function getEsLintOptions(project) {
|
|
185
183
|
return Object.entries(project.targets || {}).find(([, x]) => x.executor === '@nx/eslint:lint' ||
|
|
@@ -3,11 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.migrationGeneratorInternal = exports.migrationGenerator = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const path = require("path");
|
|
6
|
+
const path_1 = require("path");
|
|
6
7
|
const generator_1 = require("../lint-checks/generator");
|
|
7
8
|
const package_json_1 = require("nx/src/utils/package-json");
|
|
8
9
|
const versions_1 = require("../../utils/versions");
|
|
9
10
|
const artifact_name_and_directory_utils_1 = require("@nx/devkit/src/generators/artifact-name-and-directory-utils");
|
|
10
|
-
const path_1 = require("path");
|
|
11
11
|
async function normalizeOptions(tree, options) {
|
|
12
12
|
let name;
|
|
13
13
|
if (options.name) {
|
|
@@ -10,7 +10,7 @@ export interface Schema {
|
|
|
10
10
|
nameAndDirectoryFormat?: NameAndDirectoryFormat;
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
* @deprecated Provide the `directory` option instead. The project will be determined from the directory provided. It will be removed in Nx
|
|
13
|
+
* @deprecated Provide the `directory` option instead. The project will be determined from the directory provided. It will be removed in Nx v19.
|
|
14
14
|
*/
|
|
15
15
|
project?: string;
|
|
16
16
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$schema": "
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
3
|
"cli": "nx",
|
|
4
4
|
"$id": "NxPluginMigration",
|
|
5
5
|
"title": "Create a Migration for an Nx Plugin",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"$default": {
|
|
45
45
|
"$source": "projectName"
|
|
46
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
|
|
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 v19."
|
|
48
48
|
},
|
|
49
49
|
"packageJsonUpdates": {
|
|
50
50
|
"type": "boolean",
|
|
@@ -62,10 +62,13 @@ async function pluginGeneratorInternal(host, schema) {
|
|
|
62
62
|
const tasks = [];
|
|
63
63
|
tasks.push(await (0, js_1.libraryGenerator)(host, {
|
|
64
64
|
...schema,
|
|
65
|
+
name: options.name,
|
|
66
|
+
directory: options.projectRoot,
|
|
65
67
|
config: 'project',
|
|
66
68
|
bundler: options.bundler,
|
|
67
69
|
publishable: options.publishable,
|
|
68
70
|
importPath: options.npmPackageName,
|
|
71
|
+
projectNameAndRootFormat: 'as-provided',
|
|
69
72
|
skipFormat: true,
|
|
70
73
|
}));
|
|
71
74
|
if (options.bundler === 'tsc') {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ProjectNameAndRootFormat } from '@nx/devkit/src/generators/project-name-
|
|
1
|
+
import type { ProjectNameAndRootFormat } from '@nx/devkit/src/generators/project-name-and-root-utils';
|
|
2
2
|
import type { Linter } from '@nx/eslint';
|
|
3
3
|
|
|
4
4
|
export interface Schema {
|
|
@@ -35,8 +35,9 @@ exports.runCommandAsync = runCommandAsync;
|
|
|
35
35
|
function runNxCommandAsync(command, opts = {
|
|
36
36
|
silenceError: false,
|
|
37
37
|
}) {
|
|
38
|
+
const cwd = opts.cwd ?? (0, paths_1.tmpProjPath)();
|
|
38
39
|
if ((0, utils_1.fileExists)((0, paths_1.tmpProjPath)('package.json'))) {
|
|
39
|
-
const pmc = (0, devkit_1.getPackageManagerCommand)();
|
|
40
|
+
const pmc = (0, devkit_1.getPackageManagerCommand)((0, devkit_1.detectPackageManager)(cwd));
|
|
40
41
|
return runCommandAsync(`${pmc.exec} nx ${command}`, opts);
|
|
41
42
|
}
|
|
42
43
|
else if (process.platform === 'win32') {
|
|
@@ -16,12 +16,13 @@ function runNxCommand(command, opts = {
|
|
|
16
16
|
silenceError: false,
|
|
17
17
|
}) {
|
|
18
18
|
function _runNxCommand(c) {
|
|
19
|
+
const cwd = opts.cwd ?? (0, paths_1.tmpProjPath)();
|
|
19
20
|
const execSyncOptions = {
|
|
20
|
-
cwd
|
|
21
|
+
cwd,
|
|
21
22
|
env: { ...process.env, ...opts.env },
|
|
22
23
|
};
|
|
23
24
|
if ((0, utils_1.fileExists)((0, paths_1.tmpProjPath)('package.json'))) {
|
|
24
|
-
const pmc = (0, devkit_1.getPackageManagerCommand)();
|
|
25
|
+
const pmc = (0, devkit_1.getPackageManagerCommand)((0, devkit_1.detectPackageManager)(cwd));
|
|
25
26
|
return (0, child_process_1.execSync)(`${pmc.exec} nx ${command}`, execSyncOptions);
|
|
26
27
|
}
|
|
27
28
|
else if (process.platform === 'win32') {
|
|
@@ -37,9 +37,10 @@ exports.uniq = uniq;
|
|
|
37
37
|
* @param silent silent output from the install
|
|
38
38
|
*/
|
|
39
39
|
function runPackageManagerInstall(silent = true) {
|
|
40
|
-
const
|
|
40
|
+
const cwd = (0, paths_1.tmpProjPath)();
|
|
41
|
+
const pmc = (0, devkit_2.getPackageManagerCommand)((0, devkit_1.detectPackageManager)(cwd));
|
|
41
42
|
const install = (0, child_process_1.execSync)(pmc.install, {
|
|
42
|
-
cwd
|
|
43
|
+
cwd,
|
|
43
44
|
...(silent ? { stdio: ['ignore', 'ignore', 'ignore'] } : {}),
|
|
44
45
|
});
|
|
45
46
|
return install ? install.toString() : '';
|