@nx/plugin 0.0.0-pr-22179-271588f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/README.md +72 -0
- package/executors.json +10 -0
- package/generators.d.ts +6 -0
- package/generators.js +9 -0
- package/generators.json +49 -0
- package/index.d.ts +0 -0
- package/index.js +0 -0
- package/migrations.json +40 -0
- package/package.json +44 -0
- package/src/executors/e2e/e2e.impl.d.ts +6 -0
- package/src/executors/e2e/e2e.impl.js +43 -0
- package/src/executors/e2e/schema.d.ts +6 -0
- package/src/executors/e2e/schema.json +220 -0
- package/src/generators/create-package/create-package.d.ts +5 -0
- package/src/generators/create-package/create-package.js +112 -0
- package/src/generators/create-package/files/create-framework-package/bin/index.ts__tmpl__ +27 -0
- package/src/generators/create-package/files/e2e/__cliName__.spec.ts__tmpl__ +56 -0
- package/src/generators/create-package/schema.d.ts +19 -0
- package/src/generators/create-package/schema.json +79 -0
- package/src/generators/create-package/utils/normalize-schema.d.ts +8 -0
- package/src/generators/create-package/utils/normalize-schema.js +22 -0
- package/src/generators/e2e-project/e2e.d.ts +6 -0
- package/src/generators/e2e-project/e2e.js +144 -0
- package/src/generators/e2e-project/files/src/__pluginName__.spec.ts__tmpl__ +66 -0
- package/src/generators/e2e-project/files/tsconfig.json__tmpl__ +6 -0
- package/src/generators/e2e-project/schema.d.ts +15 -0
- package/src/generators/e2e-project/schema.json +57 -0
- package/src/generators/executor/executor.d.ts +6 -0
- package/src/generators/executor/executor.js +126 -0
- package/src/generators/executor/files/executor/executor.spec.ts.template +11 -0
- package/src/generators/executor/files/executor/executor.ts.template +11 -0
- package/src/generators/executor/files/executor/schema.d.ts.template +1 -0
- package/src/generators/executor/files/executor/schema.json.template +9 -0
- package/src/generators/executor/files/hasher/hasher.spec.ts.template +23 -0
- package/src/generators/executor/files/hasher/hasher.ts.template +12 -0
- package/src/generators/executor/schema.d.ts +17 -0
- package/src/generators/executor/schema.json +76 -0
- package/src/generators/generator/files/generator/generator.spec.ts.template +20 -0
- package/src/generators/generator/files/generator/generator.ts.template +26 -0
- package/src/generators/generator/files/generator/schema.d.ts.template +3 -0
- package/src/generators/generator/files/generator/schema.json.template +18 -0
- package/src/generators/generator/generator.d.ts +6 -0
- package/src/generators/generator/generator.js +127 -0
- package/src/generators/generator/schema.d.ts +16 -0
- package/src/generators/generator/schema.json +70 -0
- package/src/generators/lint-checks/generator.d.ts +7 -0
- package/src/generators/lint-checks/generator.js +187 -0
- package/src/generators/lint-checks/schema.d.ts +4 -0
- package/src/generators/lint-checks/schema.json +31 -0
- package/src/generators/migration/files/migration/__name__.spec.ts__tmpl__ +17 -0
- package/src/generators/migration/files/migration/__name__.ts__tmpl__ +6 -0
- package/src/generators/migration/migration.d.ts +5 -0
- package/src/generators/migration/migration.js +135 -0
- package/src/generators/migration/schema.d.ts +16 -0
- package/src/generators/migration/schema.json +68 -0
- package/src/generators/plugin/files/plugin/src/index.ts__tmpl__ +0 -0
- package/src/generators/plugin/plugin.d.ts +5 -0
- package/src/generators/plugin/plugin.js +107 -0
- package/src/generators/plugin/schema.d.ts +20 -0
- package/src/generators/plugin/schema.json +104 -0
- package/src/generators/plugin/utils/normalize-schema.d.ts +13 -0
- package/src/generators/plugin/utils/normalize-schema.js +44 -0
- package/src/generators/preset/generator.d.ts +3 -0
- package/src/generators/preset/generator.js +58 -0
- package/src/generators/preset/schema.d.ts +4 -0
- package/src/generators/preset/schema.json +30 -0
- package/src/migrations/update-15-0-0/specify-output-capture.d.ts +2 -0
- package/src/migrations/update-15-0-0/specify-output-capture.js +53 -0
- package/src/migrations/update-15-9-0/jest-29-configs.d.ts +3 -0
- package/src/migrations/update-15-9-0/jest-29-configs.js +147 -0
- package/src/migrations/update-15-9-0/jest-29-tests.d.ts +5 -0
- package/src/migrations/update-15-9-0/jest-29-tests.js +61 -0
- package/src/migrations/update-16-0-0/cli-in-schema-json.d.ts +3 -0
- package/src/migrations/update-16-0-0/cli-in-schema-json.js +135 -0
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +2 -0
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +9 -0
- package/src/migrations/update-16-2-0/replace-e2e-executor.d.ts +2 -0
- package/src/migrations/update-16-2-0/replace-e2e-executor.js +32 -0
- package/src/utils/has-generator.d.ts +2 -0
- package/src/utils/has-generator.js +16 -0
- package/src/utils/testing-utils/async-commands.d.ts +28 -0
- package/src/utils/testing-utils/async-commands.js +50 -0
- package/src/utils/testing-utils/commands.d.ts +17 -0
- package/src/utils/testing-utils/commands.js +63 -0
- package/src/utils/testing-utils/index.d.ts +5 -0
- package/src/utils/testing-utils/index.js +8 -0
- package/src/utils/testing-utils/nx-project.d.ts +25 -0
- package/src/utils/testing-utils/nx-project.js +70 -0
- package/src/utils/testing-utils/paths.d.ts +15 -0
- package/src/utils/testing-utils/paths.js +32 -0
- package/src/utils/testing-utils/utils.d.ts +80 -0
- package/src/utils/testing-utils/utils.js +144 -0
- package/src/utils/versions.d.ts +2 -0
- package/src/utils/versions.js +5 -0
- package/testing.d.ts +1 -0
- package/testing.js +4 -0
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateCliPropsForPlugins = void 0;
|
|
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
|
+
exports.updateCliPropsForPlugins = updateCliPropsForPlugins;
|
|
87
|
+
function removeCliFromExecutorSchemaJsonFiles(tree, collectionPath) {
|
|
88
|
+
const collection = (0, devkit_1.readJson)(tree, collectionPath);
|
|
89
|
+
for (const [name, entry] of Object.entries(collection.executors ?? {}).concat(Object.entries(collection.builders ?? {}))) {
|
|
90
|
+
deleteCliPropFromSchemaFile(collectionPath, entry, tree);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
function removeCliFromGeneratorSchemaJsonFiles(tree, collectionPath) {
|
|
94
|
+
const collection = (0, devkit_1.readJson)(tree, collectionPath);
|
|
95
|
+
for (const [name, entry] of Object.entries(collection.generators ?? {}).concat(Object.entries(collection.schematics ?? {}))) {
|
|
96
|
+
deleteCliPropFromSchemaFile(collectionPath, entry, tree);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function updateMigrationsJsonForPlugin(tree, collectionPath) {
|
|
100
|
+
(0, devkit_1.updateJson)(tree, collectionPath, (json) => {
|
|
101
|
+
for (const migration in json.generators ?? {}) {
|
|
102
|
+
if (!(json.generators[migration].cli === 'nx')) {
|
|
103
|
+
json.schematics ??= {};
|
|
104
|
+
json.schematics[migration] = json.generators[migration];
|
|
105
|
+
delete json.generators[migration];
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
for (const migration in json.schematics ?? {}) {
|
|
109
|
+
if (json.schematics[migration].cli === 'nx') {
|
|
110
|
+
json.generators ??= {};
|
|
111
|
+
json.generators[migration] = json.schematics[migration];
|
|
112
|
+
delete json.schematics[migration];
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return json;
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
exports.default = updateCliPropsForPlugins;
|
|
119
|
+
function deleteCliPropFromSchemaFile(collectionPath, entry, tree) {
|
|
120
|
+
if (!entry.schema) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
const schemaPath = (0, devkit_1.joinPathFragments)((0, path_1.dirname)(collectionPath), entry.schema);
|
|
124
|
+
if (tree.exists(schemaPath)) {
|
|
125
|
+
(0, devkit_1.updateJson)(tree, schemaPath, (json) => {
|
|
126
|
+
if (json.cli) {
|
|
127
|
+
delete json.cli;
|
|
128
|
+
}
|
|
129
|
+
return json;
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
console.warn(`Could not find schema file ${schemaPath}`);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const devkit_1 = require("@nx/devkit");
|
|
4
|
+
const replace_package_1 = require("@nx/devkit/src/utils/replace-package");
|
|
5
|
+
async function replacePackage(tree) {
|
|
6
|
+
await (0, replace_package_1.replaceNrwlPackageWithNxPackage)(tree, '@nrwl/nx-plugin', '@nx/plugin');
|
|
7
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
8
|
+
}
|
|
9
|
+
exports.default = replacePackage;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const devkit_1 = require("@nx/devkit");
|
|
4
|
+
const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
|
|
5
|
+
async function replaceE2EExecutor(tree) {
|
|
6
|
+
const projects = (0, devkit_1.getProjects)(tree);
|
|
7
|
+
for (const executor of ['@nx/plugin:e2e', '@nrwl/nx-plugin:e2e']) {
|
|
8
|
+
(0, executor_options_utils_1.forEachExecutorOptions)(tree, executor, (options, project, target, configuration) => {
|
|
9
|
+
const projectConfiguration = projects.get(project);
|
|
10
|
+
const config = {
|
|
11
|
+
...options,
|
|
12
|
+
target: undefined,
|
|
13
|
+
runInBand: true,
|
|
14
|
+
};
|
|
15
|
+
if (configuration) {
|
|
16
|
+
projectConfiguration.targets[target].configurations[configuration] =
|
|
17
|
+
config;
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
projectConfiguration.targets[target].dependsOn = [
|
|
21
|
+
...(projectConfiguration.targets[target].dependsOn ?? []),
|
|
22
|
+
options.target,
|
|
23
|
+
];
|
|
24
|
+
projectConfiguration.targets[target].executor = '@nx/jest:jest';
|
|
25
|
+
projectConfiguration.targets[target].options = config;
|
|
26
|
+
}
|
|
27
|
+
(0, devkit_1.updateProjectConfiguration)(tree, project, projectConfiguration);
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
31
|
+
}
|
|
32
|
+
exports.default = replaceE2EExecutor;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hasGenerator = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
function hasGenerator(tree, projectName, generatorName) {
|
|
6
|
+
const project = (0, devkit_1.readProjectConfiguration)(tree, projectName);
|
|
7
|
+
const packageJson = (0, devkit_1.readJson)(tree, (0, devkit_1.joinPathFragments)(project.root, 'package.json'));
|
|
8
|
+
if (!packageJson.generators && !packageJson.schematics) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
const generatorsPath = (0, devkit_1.joinPathFragments)(project.root, packageJson.generators ?? packageJson.schematics);
|
|
12
|
+
const generatorsJson = (0, devkit_1.readJson)(tree, generatorsPath);
|
|
13
|
+
return ((generatorsJson.generators?.[generatorName] ??
|
|
14
|
+
generatorsJson.schematics?.[generatorName]) !== undefined);
|
|
15
|
+
}
|
|
16
|
+
exports.hasGenerator = hasGenerator;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/**
|
|
3
|
+
* Run a command asynchronously inside the e2e directory.
|
|
4
|
+
*
|
|
5
|
+
* @param command
|
|
6
|
+
* @param opts
|
|
7
|
+
*/
|
|
8
|
+
export declare function runCommandAsync(command: string, opts?: {
|
|
9
|
+
silenceError?: boolean;
|
|
10
|
+
env?: NodeJS.ProcessEnv;
|
|
11
|
+
cwd?: string;
|
|
12
|
+
}): Promise<{
|
|
13
|
+
stdout: string;
|
|
14
|
+
stderr: string;
|
|
15
|
+
}>;
|
|
16
|
+
/**
|
|
17
|
+
* Run a nx command asynchronously inside the e2e directory
|
|
18
|
+
* @param command
|
|
19
|
+
* @param opts
|
|
20
|
+
*/
|
|
21
|
+
export declare function runNxCommandAsync(command: string, opts?: {
|
|
22
|
+
silenceError?: boolean;
|
|
23
|
+
env?: NodeJS.ProcessEnv;
|
|
24
|
+
cwd?: string;
|
|
25
|
+
}): Promise<{
|
|
26
|
+
stdout: string;
|
|
27
|
+
stderr: string;
|
|
28
|
+
}>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runNxCommandAsync = exports.runCommandAsync = void 0;
|
|
4
|
+
const child_process_1 = require("child_process");
|
|
5
|
+
const paths_1 = require("./paths");
|
|
6
|
+
const devkit_1 = require("@nx/devkit");
|
|
7
|
+
const utils_1 = require("./utils");
|
|
8
|
+
/**
|
|
9
|
+
* Run a command asynchronously inside the e2e directory.
|
|
10
|
+
*
|
|
11
|
+
* @param command
|
|
12
|
+
* @param opts
|
|
13
|
+
*/
|
|
14
|
+
function runCommandAsync(command, opts = {
|
|
15
|
+
silenceError: false,
|
|
16
|
+
}) {
|
|
17
|
+
return new Promise((resolve, reject) => {
|
|
18
|
+
(0, child_process_1.exec)(command, {
|
|
19
|
+
cwd: opts.cwd ?? (0, paths_1.tmpProjPath)(),
|
|
20
|
+
env: { ...process.env, ...opts.env },
|
|
21
|
+
}, (err, stdout, stderr) => {
|
|
22
|
+
if (!opts.silenceError && err) {
|
|
23
|
+
reject(err);
|
|
24
|
+
}
|
|
25
|
+
resolve({ stdout, stderr });
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
exports.runCommandAsync = runCommandAsync;
|
|
30
|
+
/**
|
|
31
|
+
* Run a nx command asynchronously inside the e2e directory
|
|
32
|
+
* @param command
|
|
33
|
+
* @param opts
|
|
34
|
+
*/
|
|
35
|
+
function runNxCommandAsync(command, opts = {
|
|
36
|
+
silenceError: false,
|
|
37
|
+
}) {
|
|
38
|
+
const cwd = opts.cwd ?? (0, paths_1.tmpProjPath)();
|
|
39
|
+
if ((0, utils_1.fileExists)((0, paths_1.tmpProjPath)('package.json'))) {
|
|
40
|
+
const pmc = (0, devkit_1.getPackageManagerCommand)((0, devkit_1.detectPackageManager)(cwd));
|
|
41
|
+
return runCommandAsync(`${pmc.exec} nx ${command}`, opts);
|
|
42
|
+
}
|
|
43
|
+
else if (process.platform === 'win32') {
|
|
44
|
+
return runCommandAsync(`./nx.bat %${command}`, opts);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
return runCommandAsync(`./nx %${command}`, opts);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.runNxCommandAsync = runNxCommandAsync;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/**
|
|
3
|
+
* Run a nx command inside the e2e directory
|
|
4
|
+
* @param command
|
|
5
|
+
* @param opts
|
|
6
|
+
*
|
|
7
|
+
* @see tmpProjPath
|
|
8
|
+
*/
|
|
9
|
+
export declare function runNxCommand(command?: string, opts?: {
|
|
10
|
+
silenceError?: boolean;
|
|
11
|
+
env?: NodeJS.ProcessEnv;
|
|
12
|
+
cwd?: string;
|
|
13
|
+
}): string;
|
|
14
|
+
export declare function runCommand(command: string, opts: {
|
|
15
|
+
env?: NodeJS.ProcessEnv;
|
|
16
|
+
cwd?: string;
|
|
17
|
+
}): string;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runCommand = exports.runNxCommand = void 0;
|
|
4
|
+
const child_process_1 = require("child_process");
|
|
5
|
+
const paths_1 = require("./paths");
|
|
6
|
+
const devkit_1 = require("@nx/devkit");
|
|
7
|
+
const utils_1 = require("./utils");
|
|
8
|
+
/**
|
|
9
|
+
* Run a nx command inside the e2e directory
|
|
10
|
+
* @param command
|
|
11
|
+
* @param opts
|
|
12
|
+
*
|
|
13
|
+
* @see tmpProjPath
|
|
14
|
+
*/
|
|
15
|
+
function runNxCommand(command, opts = {
|
|
16
|
+
silenceError: false,
|
|
17
|
+
}) {
|
|
18
|
+
function _runNxCommand(c) {
|
|
19
|
+
const cwd = opts.cwd ?? (0, paths_1.tmpProjPath)();
|
|
20
|
+
const execSyncOptions = {
|
|
21
|
+
cwd,
|
|
22
|
+
env: { ...process.env, ...opts.env },
|
|
23
|
+
};
|
|
24
|
+
if ((0, utils_1.fileExists)((0, paths_1.tmpProjPath)('package.json'))) {
|
|
25
|
+
const pmc = (0, devkit_1.getPackageManagerCommand)((0, devkit_1.detectPackageManager)(cwd));
|
|
26
|
+
return (0, child_process_1.execSync)(`${pmc.exec} nx ${command}`, execSyncOptions);
|
|
27
|
+
}
|
|
28
|
+
else if (process.platform === 'win32') {
|
|
29
|
+
return (0, child_process_1.execSync)(`./nx.bat %${command}`, execSyncOptions);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
return (0, child_process_1.execSync)(`./nx %${command}`, execSyncOptions);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
try {
|
|
36
|
+
return _runNxCommand(command)
|
|
37
|
+
.toString()
|
|
38
|
+
.replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, '');
|
|
39
|
+
}
|
|
40
|
+
catch (e) {
|
|
41
|
+
if (opts.silenceError) {
|
|
42
|
+
return e.stdout.toString();
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
console.log(e.stdout.toString(), e.stderr.toString());
|
|
46
|
+
throw e;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.runNxCommand = runNxCommand;
|
|
51
|
+
function runCommand(command, opts) {
|
|
52
|
+
try {
|
|
53
|
+
return (0, child_process_1.execSync)(command, {
|
|
54
|
+
cwd: opts.cwd ?? (0, paths_1.tmpProjPath)(),
|
|
55
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
56
|
+
env: { ...process.env, ...opts?.env },
|
|
57
|
+
}).toString();
|
|
58
|
+
}
|
|
59
|
+
catch (e) {
|
|
60
|
+
return e.stdout.toString() + e.stderr.toString();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
exports.runCommand = runCommand;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./async-commands"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./commands"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./paths"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./nx-project"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./utils"), exports);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare function patchPackageJsonForPlugin(npmPackageName: string, distPath: string): void;
|
|
2
|
+
/**
|
|
3
|
+
* Generate a unique name for running CLI commands
|
|
4
|
+
* @param prefix
|
|
5
|
+
*
|
|
6
|
+
* @returns `'<prefix><random number>'`
|
|
7
|
+
*/
|
|
8
|
+
export declare function uniq(prefix: string): string;
|
|
9
|
+
/**
|
|
10
|
+
* Run the appropriate package manager install command in the e2e directory
|
|
11
|
+
* @param silent silent output from the install
|
|
12
|
+
*/
|
|
13
|
+
export declare function runPackageManagerInstall(silent?: boolean): string;
|
|
14
|
+
/**
|
|
15
|
+
* Creates a new nx project in the e2e directory
|
|
16
|
+
*
|
|
17
|
+
* @param npmPackageName package name to test
|
|
18
|
+
* @param pluginDistPath dist path where the plugin was outputted to
|
|
19
|
+
*/
|
|
20
|
+
export declare function newNxProject(npmPackageName: string, pluginDistPath: string): void;
|
|
21
|
+
/**
|
|
22
|
+
* Ensures that a project has been setup in the e2e directory
|
|
23
|
+
* It will also copy `@nx` packages to the e2e directory
|
|
24
|
+
*/
|
|
25
|
+
export declare function ensureNxProject(npmPackageName?: string, pluginDistPath?: string): void;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ensureNxProject = exports.newNxProject = exports.runPackageManagerInstall = exports.uniq = exports.patchPackageJsonForPlugin = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const devkit_2 = require("@nx/devkit");
|
|
6
|
+
const child_process_1 = require("child_process");
|
|
7
|
+
const path_1 = require("path");
|
|
8
|
+
const fs_extra_1 = require("fs-extra");
|
|
9
|
+
const paths_1 = require("./paths");
|
|
10
|
+
const utils_1 = require("./utils");
|
|
11
|
+
function runNxNewCommand(args, silent) {
|
|
12
|
+
const localTmpDir = (0, path_1.dirname)((0, paths_1.tmpProjPath)());
|
|
13
|
+
return (0, child_process_1.execSync)(`node ${require.resolve('nx')} new proj --nx-workspace-root=${localTmpDir} --no-interactive --skip-install --collection=@nx/workspace --npmScope=proj --preset=apps ${args || ''}`, {
|
|
14
|
+
cwd: localTmpDir,
|
|
15
|
+
...(silent && false ? { stdio: ['ignore', 'ignore', 'ignore'] } : {}),
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
function patchPackageJsonForPlugin(npmPackageName, distPath) {
|
|
19
|
+
const path = (0, paths_1.tmpProjPath)('package.json');
|
|
20
|
+
const json = (0, devkit_2.readJsonFile)(path);
|
|
21
|
+
json.devDependencies[npmPackageName] = `file:${devkit_1.workspaceRoot}/${distPath}`;
|
|
22
|
+
(0, devkit_2.writeJsonFile)(path, json);
|
|
23
|
+
}
|
|
24
|
+
exports.patchPackageJsonForPlugin = patchPackageJsonForPlugin;
|
|
25
|
+
/**
|
|
26
|
+
* Generate a unique name for running CLI commands
|
|
27
|
+
* @param prefix
|
|
28
|
+
*
|
|
29
|
+
* @returns `'<prefix><random number>'`
|
|
30
|
+
*/
|
|
31
|
+
function uniq(prefix) {
|
|
32
|
+
return `${prefix}${Math.floor(Math.random() * 10000000)}`;
|
|
33
|
+
}
|
|
34
|
+
exports.uniq = uniq;
|
|
35
|
+
/**
|
|
36
|
+
* Run the appropriate package manager install command in the e2e directory
|
|
37
|
+
* @param silent silent output from the install
|
|
38
|
+
*/
|
|
39
|
+
function runPackageManagerInstall(silent = true) {
|
|
40
|
+
const cwd = (0, paths_1.tmpProjPath)();
|
|
41
|
+
const pmc = (0, devkit_2.getPackageManagerCommand)((0, devkit_1.detectPackageManager)(cwd));
|
|
42
|
+
const install = (0, child_process_1.execSync)(pmc.install, {
|
|
43
|
+
cwd,
|
|
44
|
+
...(silent ? { stdio: ['ignore', 'ignore', 'ignore'] } : {}),
|
|
45
|
+
});
|
|
46
|
+
return install ? install.toString() : '';
|
|
47
|
+
}
|
|
48
|
+
exports.runPackageManagerInstall = runPackageManagerInstall;
|
|
49
|
+
/**
|
|
50
|
+
* Creates a new nx project in the e2e directory
|
|
51
|
+
*
|
|
52
|
+
* @param npmPackageName package name to test
|
|
53
|
+
* @param pluginDistPath dist path where the plugin was outputted to
|
|
54
|
+
*/
|
|
55
|
+
function newNxProject(npmPackageName, pluginDistPath) {
|
|
56
|
+
(0, utils_1.cleanup)();
|
|
57
|
+
runNxNewCommand('', true);
|
|
58
|
+
patchPackageJsonForPlugin(npmPackageName, pluginDistPath);
|
|
59
|
+
runPackageManagerInstall();
|
|
60
|
+
}
|
|
61
|
+
exports.newNxProject = newNxProject;
|
|
62
|
+
/**
|
|
63
|
+
* Ensures that a project has been setup in the e2e directory
|
|
64
|
+
* It will also copy `@nx` packages to the e2e directory
|
|
65
|
+
*/
|
|
66
|
+
function ensureNxProject(npmPackageName, pluginDistPath) {
|
|
67
|
+
(0, fs_extra_1.ensureDirSync)((0, paths_1.tmpProjPath)());
|
|
68
|
+
newNxProject(npmPackageName, pluginDistPath);
|
|
69
|
+
}
|
|
70
|
+
exports.ensureNxProject = ensureNxProject;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare function tmpFolder(): string;
|
|
2
|
+
/**
|
|
3
|
+
* The directory where the e2e workspace resides in.
|
|
4
|
+
*
|
|
5
|
+
* @param path path within the e2e directory
|
|
6
|
+
* @returns `'${process.cwd()}/tmp/nx-e2e/proj/<path>'`
|
|
7
|
+
*/
|
|
8
|
+
export declare function tmpProjPath(path?: string): string;
|
|
9
|
+
/**
|
|
10
|
+
* The workspace backup directory. This is used for caching of the creation of the workspace.
|
|
11
|
+
*
|
|
12
|
+
* @param path path within the e2e directory
|
|
13
|
+
* @returns `'${process.cwd()}/tmp/nx-e2e/proj-backup/<path>'`
|
|
14
|
+
*/
|
|
15
|
+
export declare function tmpBackupProjPath(path?: string): string;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.tmpBackupProjPath = exports.tmpProjPath = exports.tmpFolder = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
function tmpFolder() {
|
|
6
|
+
return `${devkit_1.workspaceRoot}/tmp`;
|
|
7
|
+
}
|
|
8
|
+
exports.tmpFolder = tmpFolder;
|
|
9
|
+
/**
|
|
10
|
+
* The directory where the e2e workspace resides in.
|
|
11
|
+
*
|
|
12
|
+
* @param path path within the e2e directory
|
|
13
|
+
* @returns `'${process.cwd()}/tmp/nx-e2e/proj/<path>'`
|
|
14
|
+
*/
|
|
15
|
+
function tmpProjPath(path) {
|
|
16
|
+
return path
|
|
17
|
+
? `${tmpFolder()}/nx-e2e/proj/${path}`
|
|
18
|
+
: `${tmpFolder()}/nx-e2e/proj`;
|
|
19
|
+
}
|
|
20
|
+
exports.tmpProjPath = tmpProjPath;
|
|
21
|
+
/**
|
|
22
|
+
* The workspace backup directory. This is used for caching of the creation of the workspace.
|
|
23
|
+
*
|
|
24
|
+
* @param path path within the e2e directory
|
|
25
|
+
* @returns `'${process.cwd()}/tmp/nx-e2e/proj-backup/<path>'`
|
|
26
|
+
*/
|
|
27
|
+
function tmpBackupProjPath(path) {
|
|
28
|
+
return path
|
|
29
|
+
? `${devkit_1.workspaceRoot}/tmp/nx-e2e/proj-backup/${path}`
|
|
30
|
+
: `${devkit_1.workspaceRoot}/tmp/nx-e2e/proj-backup`;
|
|
31
|
+
}
|
|
32
|
+
exports.tmpBackupProjPath = tmpBackupProjPath;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { JsonParseOptions } from '@nx/devkit';
|
|
2
|
+
import { directoryExists, fileExists } from 'nx/src/utils/fileutils';
|
|
3
|
+
export { directoryExists, fileExists };
|
|
4
|
+
/**
|
|
5
|
+
* Copies module folders from the working directory to the e2e directory
|
|
6
|
+
* @param modules a list of module names or scopes to copy
|
|
7
|
+
*/
|
|
8
|
+
export declare function copyNodeModules(modules: string[]): void;
|
|
9
|
+
/**
|
|
10
|
+
* Assert test output from a asynchronous CLI command.
|
|
11
|
+
*
|
|
12
|
+
* @param output Output from an asynchronous command
|
|
13
|
+
*/
|
|
14
|
+
export declare function expectTestsPass(output: {
|
|
15
|
+
stdout: string;
|
|
16
|
+
stderr: string;
|
|
17
|
+
}): void;
|
|
18
|
+
/**
|
|
19
|
+
* Update a file's content in the e2e directory.
|
|
20
|
+
*
|
|
21
|
+
* If the `content` param is a callback, it will provide the original file content as an argument.
|
|
22
|
+
*
|
|
23
|
+
* @param file Path of the file in the e2e directory
|
|
24
|
+
* @param content Content to replace the original content with
|
|
25
|
+
*/
|
|
26
|
+
export declare function updateFile(file: string, content: string | ((originalFileContent: string) => string)): void;
|
|
27
|
+
/**
|
|
28
|
+
* Rename a file or directory within the e2e directory.
|
|
29
|
+
* @param path Original path
|
|
30
|
+
* @param newPath New path
|
|
31
|
+
*/
|
|
32
|
+
export declare function renameFile(path: string, newPath: string): void;
|
|
33
|
+
/**
|
|
34
|
+
* Check if the file or directory exists.
|
|
35
|
+
*
|
|
36
|
+
* If a path starts with `/` or `C:/`, it will check it as absolute. Otherwise it will check within the e2e directory.
|
|
37
|
+
*
|
|
38
|
+
* @param expectedPaths Files or directories to check
|
|
39
|
+
* @usage `checkFileExists('file1', 'file2', '/var/user/file')`
|
|
40
|
+
*/
|
|
41
|
+
export declare function checkFilesExist(...expectedPaths: string[]): void;
|
|
42
|
+
/**
|
|
43
|
+
* Get a list of all files within a directory.
|
|
44
|
+
* @param dirName Directory name within the e2e directory.
|
|
45
|
+
*/
|
|
46
|
+
export declare function listFiles(dirName: string): string[];
|
|
47
|
+
/**
|
|
48
|
+
* Read a JSON file.
|
|
49
|
+
* @param path Path to the JSON file. Absolute or relative to the e2e directory.
|
|
50
|
+
* @param options JSON parse options
|
|
51
|
+
*/
|
|
52
|
+
export declare function readJson<T extends object = any>(path: string, options?: JsonParseOptions): T;
|
|
53
|
+
/**
|
|
54
|
+
* Read a file.
|
|
55
|
+
* @param path Path to the file. Absolute or relative to the e2e directory.
|
|
56
|
+
*/
|
|
57
|
+
export declare function readFile(path: string): string;
|
|
58
|
+
/**
|
|
59
|
+
* Deletes the e2e directory
|
|
60
|
+
*/
|
|
61
|
+
export declare function cleanup(): void;
|
|
62
|
+
/**
|
|
63
|
+
* Remove the dist folder from the e2e directory
|
|
64
|
+
*/
|
|
65
|
+
export declare function rmDist(): void;
|
|
66
|
+
export declare function removeTmpProject(project: string): void;
|
|
67
|
+
/**
|
|
68
|
+
* Get the currend `cwd` in the process
|
|
69
|
+
*/
|
|
70
|
+
export declare function getCwd(): string;
|
|
71
|
+
/**
|
|
72
|
+
* Check if a file or directory exists.
|
|
73
|
+
* @param path Path to file or directory
|
|
74
|
+
*/
|
|
75
|
+
export declare function exists(path: string): boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Get the size of a file on disk
|
|
78
|
+
* @param filePath Path to the file
|
|
79
|
+
*/
|
|
80
|
+
export declare function getSize(filePath: string): number;
|