@nx/plugin 16.8.0-beta.4 → 16.8.0-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +7 -7
- package/src/executors/e2e/e2e.impl.js +30 -63
- package/src/generators/create-package/create-package.js +70 -64
- package/src/generators/create-package/utils/normalize-schema.js +15 -14
- package/src/generators/e2e-project/e2e.js +105 -93
- package/src/generators/executor/executor.js +67 -65
- package/src/generators/generator/generator.js +67 -66
- package/src/generators/lint-checks/generator.js +54 -54
- package/src/generators/migration/migration.js +29 -29
- package/src/generators/plugin/plugin.js +54 -50
- package/src/generators/plugin/utils/normalize-schema.js +36 -33
- package/src/generators/preset/generator.js +41 -44
- package/src/migrations/update-14-1-9/add-swc-deps-if-needed.js +4 -7
- package/src/migrations/update-15-0-0/specify-output-capture.js +39 -42
- package/src/migrations/update-15-9-0/jest-29-configs.js +28 -34
- package/src/migrations/update-15-9-0/jest-29-tests.js +11 -14
- package/src/migrations/update-16-0-0/cli-in-schema-json.js +6 -9
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +3 -6
- package/src/migrations/update-16-2-0/replace-e2e-executor.js +26 -26
- package/src/utils/has-generator.js +3 -3
- package/src/utils/testing-utils/async-commands.js +2 -3
- package/src/utils/testing-utils/commands.js +4 -6
- package/src/utils/testing-utils/nx-project.js +8 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/plugin",
|
|
3
|
-
"version": "16.8.0-beta.
|
|
3
|
+
"version": "16.8.0-beta.6",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "This plugin is used to create Nx plugins! It contains generators for generating common plugin features like generators, executors, migrations and more.",
|
|
6
6
|
"repository": {
|
|
@@ -28,11 +28,11 @@
|
|
|
28
28
|
"migrations": "./migrations.json"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@nrwl/nx-plugin": "16.8.0-beta.
|
|
32
|
-
"@nx/devkit": "16.8.0-beta.
|
|
33
|
-
"@nx/jest": "16.8.0-beta.
|
|
34
|
-
"@nx/js": "16.8.0-beta.
|
|
35
|
-
"@nx/linter": "16.8.0-beta.
|
|
31
|
+
"@nrwl/nx-plugin": "16.8.0-beta.6",
|
|
32
|
+
"@nx/devkit": "16.8.0-beta.6",
|
|
33
|
+
"@nx/jest": "16.8.0-beta.6",
|
|
34
|
+
"@nx/js": "16.8.0-beta.6",
|
|
35
|
+
"@nx/linter": "16.8.0-beta.6",
|
|
36
36
|
"@phenomnomnominal/tsquery": "~5.0.1",
|
|
37
37
|
"fs-extra": "^11.1.0",
|
|
38
38
|
"tslib": "^2.3.0"
|
|
@@ -41,5 +41,5 @@
|
|
|
41
41
|
"access": "public"
|
|
42
42
|
},
|
|
43
43
|
"type": "commonjs",
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "0cc6ba996f2ef09f00b932c8eacf42de642457f3"
|
|
45
45
|
}
|
|
@@ -1,77 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.nxPluginE2EExecutor = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
6
5
|
const jest_impl_1 = require("@nx/jest/src/executors/jest/jest.impl");
|
|
7
6
|
// TODO(v18): remove this
|
|
8
|
-
function nxPluginE2EExecutor(options, context) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
let success;
|
|
7
|
+
async function* nxPluginE2EExecutor(options, context) {
|
|
8
|
+
const { target, ...jestOptions } = options;
|
|
9
|
+
devkit_1.output.warn({
|
|
10
|
+
title: `"@nx/plugin:e2e" is deprecated and will be removed in Nx 18`,
|
|
11
|
+
bodyLines: [
|
|
12
|
+
'Use the "@nx/jest:jest" executor instead and set the following:',
|
|
13
|
+
`"dependsOn": ["${target}"]`,
|
|
14
|
+
],
|
|
15
|
+
});
|
|
16
|
+
let success;
|
|
17
|
+
for await (const _ of runBuildTarget(target, context)) {
|
|
20
18
|
try {
|
|
21
|
-
|
|
22
|
-
_c = _f.value;
|
|
23
|
-
_d = false;
|
|
24
|
-
const _ = _c;
|
|
25
|
-
try {
|
|
26
|
-
success = yield tslib_1.__await(runTests(jestOptions, context));
|
|
27
|
-
}
|
|
28
|
-
catch (e) {
|
|
29
|
-
devkit_1.logger.error(e.message);
|
|
30
|
-
success = false;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
19
|
+
success = await runTests(jestOptions, context);
|
|
33
20
|
}
|
|
34
|
-
catch (
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if (!_d && !_a && (_b = _e.return)) yield tslib_1.__await(_b.call(_e));
|
|
38
|
-
}
|
|
39
|
-
finally { if (e_1) throw e_1.error; }
|
|
21
|
+
catch (e) {
|
|
22
|
+
devkit_1.logger.error(e.message);
|
|
23
|
+
success = false;
|
|
40
24
|
}
|
|
41
|
-
|
|
42
|
-
}
|
|
25
|
+
}
|
|
26
|
+
return { success };
|
|
43
27
|
}
|
|
44
28
|
exports.nxPluginE2EExecutor = nxPluginE2EExecutor;
|
|
45
|
-
function runBuildTarget(buildTarget, context) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
_d = false;
|
|
56
|
-
const output = _c;
|
|
57
|
-
if (!output.success)
|
|
58
|
-
throw new Error('Could not compile application files.');
|
|
59
|
-
yield yield tslib_1.__await(output.success);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
63
|
-
finally {
|
|
64
|
-
try {
|
|
65
|
-
if (!_d && !_a && (_b = _e.return)) yield tslib_1.__await(_b.call(_e));
|
|
66
|
-
}
|
|
67
|
-
finally { if (e_2) throw e_2.error; }
|
|
68
|
-
}
|
|
69
|
-
});
|
|
29
|
+
async function* runBuildTarget(buildTarget, context) {
|
|
30
|
+
const graph = await (0, devkit_1.createProjectGraphAsync)();
|
|
31
|
+
const { project, target, configuration } = (0, devkit_1.parseTargetString)(buildTarget, graph);
|
|
32
|
+
const buildTargetOptions = (0, devkit_1.readTargetOptions)({ project, target, configuration }, context);
|
|
33
|
+
const targetSupportsWatch = Object.keys(buildTargetOptions).includes('watch');
|
|
34
|
+
for await (const output of await (0, devkit_1.runExecutor)({ project, target, configuration }, targetSupportsWatch ? { watch: false } : {}, context)) {
|
|
35
|
+
if (!output.success)
|
|
36
|
+
throw new Error('Could not compile application files.');
|
|
37
|
+
yield output.success;
|
|
38
|
+
}
|
|
70
39
|
}
|
|
71
|
-
function runTests(jestOptions, context) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
return success;
|
|
75
|
-
});
|
|
40
|
+
async function runTests(jestOptions, context) {
|
|
41
|
+
const { success } = await (0, jest_impl_1.jestExecutor)({ ...jestOptions, watch: false }, context);
|
|
42
|
+
return success;
|
|
76
43
|
}
|
|
77
44
|
exports.default = nxPluginE2EExecutor;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createPackageSchematic = exports.createPackageGeneratorInternal = exports.createPackageGenerator = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
6
5
|
const js_1 = require("@nx/js");
|
|
7
6
|
const versions_1 = require("nx/src/utils/versions");
|
|
@@ -9,30 +8,29 @@ const generator_1 = require("../generator/generator");
|
|
|
9
8
|
const normalize_schema_1 = require("./utils/normalize-schema");
|
|
10
9
|
const has_generator_1 = require("../../utils/has-generator");
|
|
11
10
|
const path_1 = require("path");
|
|
12
|
-
function createPackageGenerator(host, schema) {
|
|
13
|
-
return
|
|
14
|
-
|
|
11
|
+
async function createPackageGenerator(host, schema) {
|
|
12
|
+
return await createPackageGeneratorInternal(host, {
|
|
13
|
+
projectNameAndRootFormat: 'derived',
|
|
14
|
+
...schema,
|
|
15
15
|
});
|
|
16
16
|
}
|
|
17
17
|
exports.createPackageGenerator = createPackageGenerator;
|
|
18
|
-
function createPackageGeneratorInternal(host, schema) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
35
|
-
});
|
|
18
|
+
async function createPackageGeneratorInternal(host, schema) {
|
|
19
|
+
const tasks = [];
|
|
20
|
+
const options = await (0, normalize_schema_1.normalizeSchema)(host, schema);
|
|
21
|
+
const pluginPackageName = await addPresetGenerator(host, options);
|
|
22
|
+
const installTask = (0, devkit_1.addDependenciesToPackageJson)(host, {
|
|
23
|
+
'create-nx-workspace': versions_1.nxVersion,
|
|
24
|
+
}, {});
|
|
25
|
+
tasks.push(installTask);
|
|
26
|
+
await createCliPackage(host, options, pluginPackageName);
|
|
27
|
+
if (options.e2eProject) {
|
|
28
|
+
addE2eProject(host, options);
|
|
29
|
+
}
|
|
30
|
+
if (!options.skipFormat) {
|
|
31
|
+
await (0, devkit_1.formatFiles)(host);
|
|
32
|
+
}
|
|
33
|
+
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
36
34
|
}
|
|
37
35
|
exports.createPackageGeneratorInternal = createPackageGeneratorInternal;
|
|
38
36
|
/**
|
|
@@ -41,49 +39,57 @@ exports.createPackageGeneratorInternal = createPackageGeneratorInternal;
|
|
|
41
39
|
* @param schema
|
|
42
40
|
* @returns package name of the plugin
|
|
43
41
|
*/
|
|
44
|
-
function addPresetGenerator(host, schema) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
unitTestRunner: schema.unitTestRunner,
|
|
53
|
-
skipFormat: true,
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
return (_a = (0, devkit_1.readJson)(host, (0, devkit_1.joinPathFragments)(projectRoot, 'package.json'))) === null || _a === void 0 ? void 0 : _a.name;
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
function createCliPackage(host, options, pluginPackageName) {
|
|
60
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
61
|
-
yield (0, js_1.libraryGenerator)(host, Object.assign(Object.assign({}, options), { rootProject: false, config: 'project', publishable: true, bundler: options.bundler, importPath: options.name, skipFormat: true, skipTsConfig: true }));
|
|
62
|
-
host.delete((0, devkit_1.joinPathFragments)(options.projectRoot, 'src'));
|
|
63
|
-
// Add the bin entry to the package.json
|
|
64
|
-
(0, devkit_1.updateJson)(host, (0, devkit_1.joinPathFragments)(options.projectRoot, 'package.json'), (packageJson) => {
|
|
65
|
-
packageJson.bin = {
|
|
66
|
-
[options.name]: './bin/index.js',
|
|
67
|
-
};
|
|
68
|
-
packageJson.dependencies = {
|
|
69
|
-
'create-nx-workspace': versions_1.nxVersion,
|
|
70
|
-
};
|
|
71
|
-
return packageJson;
|
|
72
|
-
});
|
|
73
|
-
// update project build target to use the bin entry
|
|
74
|
-
const projectConfiguration = (0, devkit_1.readProjectConfiguration)(host, options.projectName);
|
|
75
|
-
projectConfiguration.sourceRoot = (0, devkit_1.joinPathFragments)(options.projectRoot, 'bin');
|
|
76
|
-
projectConfiguration.targets.build.options.main = (0, devkit_1.joinPathFragments)(options.projectRoot, 'bin/index.ts');
|
|
77
|
-
projectConfiguration.targets.build.options.updateBuildableProjectDepsInPackageJson =
|
|
78
|
-
false;
|
|
79
|
-
projectConfiguration.implicitDependencies = [options.project];
|
|
80
|
-
(0, devkit_1.updateProjectConfiguration)(host, options.projectName, projectConfiguration);
|
|
81
|
-
// Add bin files to tsconfg.lib.json
|
|
82
|
-
(0, devkit_1.updateJson)(host, (0, devkit_1.joinPathFragments)(options.projectRoot, 'tsconfig.lib.json'), (tsConfig) => {
|
|
83
|
-
tsConfig.include.push('bin/**/*.ts');
|
|
84
|
-
return tsConfig;
|
|
42
|
+
async function addPresetGenerator(host, schema) {
|
|
43
|
+
const { root: projectRoot } = (0, devkit_1.readProjectConfiguration)(host, schema.project);
|
|
44
|
+
if (!(0, has_generator_1.hasGenerator)(host, schema.project, 'preset')) {
|
|
45
|
+
await (0, generator_1.default)(host, {
|
|
46
|
+
name: 'preset',
|
|
47
|
+
project: schema.project,
|
|
48
|
+
unitTestRunner: schema.unitTestRunner,
|
|
49
|
+
skipFormat: true,
|
|
85
50
|
});
|
|
86
|
-
|
|
51
|
+
}
|
|
52
|
+
return (0, devkit_1.readJson)(host, (0, devkit_1.joinPathFragments)(projectRoot, 'package.json'))?.name;
|
|
53
|
+
}
|
|
54
|
+
async function createCliPackage(host, options, pluginPackageName) {
|
|
55
|
+
await (0, js_1.libraryGenerator)(host, {
|
|
56
|
+
...options,
|
|
57
|
+
rootProject: false,
|
|
58
|
+
config: 'project',
|
|
59
|
+
publishable: true,
|
|
60
|
+
bundler: options.bundler,
|
|
61
|
+
importPath: options.name,
|
|
62
|
+
skipFormat: true,
|
|
63
|
+
skipTsConfig: true,
|
|
64
|
+
});
|
|
65
|
+
host.delete((0, devkit_1.joinPathFragments)(options.projectRoot, 'src'));
|
|
66
|
+
// Add the bin entry to the package.json
|
|
67
|
+
(0, devkit_1.updateJson)(host, (0, devkit_1.joinPathFragments)(options.projectRoot, 'package.json'), (packageJson) => {
|
|
68
|
+
packageJson.bin = {
|
|
69
|
+
[options.name]: './bin/index.js',
|
|
70
|
+
};
|
|
71
|
+
packageJson.dependencies = {
|
|
72
|
+
'create-nx-workspace': versions_1.nxVersion,
|
|
73
|
+
};
|
|
74
|
+
return packageJson;
|
|
75
|
+
});
|
|
76
|
+
// update project build target to use the bin entry
|
|
77
|
+
const projectConfiguration = (0, devkit_1.readProjectConfiguration)(host, options.projectName);
|
|
78
|
+
projectConfiguration.sourceRoot = (0, devkit_1.joinPathFragments)(options.projectRoot, 'bin');
|
|
79
|
+
projectConfiguration.targets.build.options.main = (0, devkit_1.joinPathFragments)(options.projectRoot, 'bin/index.ts');
|
|
80
|
+
projectConfiguration.targets.build.options.updateBuildableProjectDepsInPackageJson =
|
|
81
|
+
false;
|
|
82
|
+
projectConfiguration.implicitDependencies = [options.project];
|
|
83
|
+
(0, devkit_1.updateProjectConfiguration)(host, options.projectName, projectConfiguration);
|
|
84
|
+
// Add bin files to tsconfg.lib.json
|
|
85
|
+
(0, devkit_1.updateJson)(host, (0, devkit_1.joinPathFragments)(options.projectRoot, 'tsconfig.lib.json'), (tsConfig) => {
|
|
86
|
+
tsConfig.include.push('bin/**/*.ts');
|
|
87
|
+
return tsConfig;
|
|
88
|
+
});
|
|
89
|
+
(0, devkit_1.generateFiles)(host, (0, devkit_1.joinPathFragments)(__dirname, './files/create-framework-package'), options.projectRoot, {
|
|
90
|
+
...options,
|
|
91
|
+
preset: pluginPackageName,
|
|
92
|
+
tmpl: '',
|
|
87
93
|
});
|
|
88
94
|
}
|
|
89
95
|
/**
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.normalizeSchema = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
|
|
6
|
-
function normalizeSchema(host, schema) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
projectNameAndRootFormat: schema.projectNameAndRootFormat,
|
|
14
|
-
callingGenerator: '@nx/plugin:create-package',
|
|
15
|
-
});
|
|
16
|
-
schema.projectNameAndRootFormat = projectNameAndRootFormat;
|
|
17
|
-
return Object.assign(Object.assign({}, schema), { bundler: (_a = schema.compiler) !== null && _a !== void 0 ? _a : 'tsc', projectName,
|
|
18
|
-
projectRoot, name: projectNames.projectSimpleName });
|
|
5
|
+
async function normalizeSchema(host, schema) {
|
|
6
|
+
const { projectName, names: projectNames, projectRoot, projectNameAndRootFormat, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
|
|
7
|
+
name: schema.name,
|
|
8
|
+
projectType: 'library',
|
|
9
|
+
directory: schema.directory,
|
|
10
|
+
projectNameAndRootFormat: schema.projectNameAndRootFormat,
|
|
11
|
+
callingGenerator: '@nx/plugin:create-package',
|
|
19
12
|
});
|
|
13
|
+
schema.projectNameAndRootFormat = projectNameAndRootFormat;
|
|
14
|
+
return {
|
|
15
|
+
...schema,
|
|
16
|
+
bundler: schema.compiler ?? 'tsc',
|
|
17
|
+
projectName,
|
|
18
|
+
projectRoot,
|
|
19
|
+
name: projectNames.projectSimpleName,
|
|
20
|
+
};
|
|
20
21
|
}
|
|
21
22
|
exports.normalizeSchema = normalizeSchema;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.e2eProjectSchematic = exports.e2eProjectGeneratorInternal = exports.e2eProjectGenerator = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
6
5
|
const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
|
|
7
6
|
const jest_1 = require("@nx/jest");
|
|
@@ -10,119 +9,132 @@ const generator_1 = require("@nx/js/src/generators/setup-verdaccio/generator");
|
|
|
10
9
|
const add_local_registry_scripts_1 = require("@nx/js/src/utils/add-local-registry-scripts");
|
|
11
10
|
const linter_1 = require("@nx/linter");
|
|
12
11
|
const path_1 = require("path");
|
|
13
|
-
function normalizeOptions(host, options) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
projectType: 'application',
|
|
22
|
-
directory: options.rootProject || !options.projectDirectory
|
|
23
|
-
? projectName
|
|
24
|
-
: `${options.projectDirectory}-e2e`,
|
|
25
|
-
projectNameAndRootFormat: `as-provided`,
|
|
26
|
-
callingGenerator: '@nx/plugin:e2e-project',
|
|
27
|
-
});
|
|
28
|
-
projectRoot = projectNameAndRootOptions.projectRoot;
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
const { layoutDirectory, projectDirectory } = (0, devkit_1.extractLayoutDirectory)(options.projectDirectory);
|
|
32
|
-
const { appsDir: defaultAppsDir } = (0, devkit_1.getWorkspaceLayout)(host);
|
|
33
|
-
const appsDir = layoutDirectory !== null && layoutDirectory !== void 0 ? layoutDirectory : defaultAppsDir;
|
|
34
|
-
projectRoot = options.rootProject
|
|
12
|
+
async function normalizeOptions(host, options) {
|
|
13
|
+
const projectName = options.rootProject ? 'e2e' : `${options.pluginName}-e2e`;
|
|
14
|
+
let projectRoot;
|
|
15
|
+
if (options.projectNameAndRootFormat === 'as-provided') {
|
|
16
|
+
const projectNameAndRootOptions = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
|
|
17
|
+
name: projectName,
|
|
18
|
+
projectType: 'application',
|
|
19
|
+
directory: options.rootProject || !options.projectDirectory
|
|
35
20
|
? projectName
|
|
36
|
-
: projectDirectory
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
21
|
+
: `${options.projectDirectory}-e2e`,
|
|
22
|
+
projectNameAndRootFormat: `as-provided`,
|
|
23
|
+
callingGenerator: '@nx/plugin:e2e-project',
|
|
24
|
+
});
|
|
25
|
+
projectRoot = projectNameAndRootOptions.projectRoot;
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
const { layoutDirectory, projectDirectory } = (0, devkit_1.extractLayoutDirectory)(options.projectDirectory);
|
|
29
|
+
const { appsDir: defaultAppsDir } = (0, devkit_1.getWorkspaceLayout)(host);
|
|
30
|
+
const appsDir = layoutDirectory ?? defaultAppsDir;
|
|
31
|
+
projectRoot = options.rootProject
|
|
32
|
+
? projectName
|
|
33
|
+
: projectDirectory
|
|
34
|
+
? (0, devkit_1.joinPathFragments)(appsDir, `${projectDirectory}-e2e`)
|
|
35
|
+
: (0, devkit_1.joinPathFragments)(appsDir, projectName);
|
|
36
|
+
}
|
|
37
|
+
const pluginPropertyName = (0, devkit_1.names)(options.pluginName).propertyName;
|
|
38
|
+
return {
|
|
39
|
+
...options,
|
|
40
|
+
projectName,
|
|
41
|
+
linter: options.linter ?? linter_1.Linter.EsLint,
|
|
42
|
+
pluginPropertyName,
|
|
43
|
+
projectRoot,
|
|
44
|
+
};
|
|
44
45
|
}
|
|
45
46
|
function validatePlugin(host, pluginName) {
|
|
46
47
|
try {
|
|
47
48
|
(0, devkit_1.readProjectConfiguration)(host, pluginName);
|
|
48
49
|
}
|
|
49
|
-
catch
|
|
50
|
+
catch {
|
|
50
51
|
throw new Error(`Project name "${pluginName}" doesn't not exist.`);
|
|
51
52
|
}
|
|
52
53
|
}
|
|
53
54
|
function addFiles(host, options) {
|
|
54
55
|
const projectConfiguration = (0, devkit_1.readProjectConfiguration)(host, options.pluginName);
|
|
55
56
|
const { name: pluginPackageName } = (0, devkit_1.readJson)(host, (0, path_1.join)(projectConfiguration.root, 'package.json'));
|
|
56
|
-
(0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, './files'), options.projectRoot,
|
|
57
|
+
(0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, './files'), options.projectRoot, {
|
|
58
|
+
...options,
|
|
59
|
+
tmpl: '',
|
|
60
|
+
rootTsConfigPath: (0, js_1.getRelativePathToRootTsConfig)(host, options.projectRoot),
|
|
61
|
+
packageManagerCommands: (0, devkit_1.getPackageManagerCommand)('npm'),
|
|
62
|
+
pluginPackageName,
|
|
63
|
+
});
|
|
57
64
|
}
|
|
58
|
-
function addJest(host, options) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
implicitDependencies: [options.pluginName],
|
|
66
|
-
});
|
|
67
|
-
const jestTask = yield (0, jest_1.configurationGenerator)(host, {
|
|
68
|
-
project: options.projectName,
|
|
69
|
-
setupFile: 'none',
|
|
70
|
-
supportTsx: false,
|
|
71
|
-
skipSerializers: true,
|
|
72
|
-
skipFormat: true,
|
|
73
|
-
});
|
|
74
|
-
const { startLocalRegistryPath, stopLocalRegistryPath } = (0, add_local_registry_scripts_1.addLocalRegistryScripts)(host);
|
|
75
|
-
(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));
|
|
76
|
-
(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));
|
|
77
|
-
const project = (0, devkit_1.readProjectConfiguration)(host, options.projectName);
|
|
78
|
-
const testTarget = project.targets.test;
|
|
79
|
-
project.targets.e2e = Object.assign(Object.assign({}, testTarget), { dependsOn: [`^build`], options: Object.assign(Object.assign({}, testTarget.options), { runInBand: true }), configurations: testTarget.configurations });
|
|
80
|
-
// remove the jest build target
|
|
81
|
-
delete project.targets.test;
|
|
82
|
-
(0, devkit_1.updateProjectConfiguration)(host, options.projectName, project);
|
|
83
|
-
return jestTask;
|
|
65
|
+
async function addJest(host, options) {
|
|
66
|
+
(0, devkit_1.addProjectConfiguration)(host, options.projectName, {
|
|
67
|
+
root: options.projectRoot,
|
|
68
|
+
projectType: 'application',
|
|
69
|
+
sourceRoot: `${options.projectRoot}/tests`,
|
|
70
|
+
targets: {},
|
|
71
|
+
implicitDependencies: [options.pluginName],
|
|
84
72
|
});
|
|
73
|
+
const jestTask = await (0, jest_1.configurationGenerator)(host, {
|
|
74
|
+
project: options.projectName,
|
|
75
|
+
setupFile: 'none',
|
|
76
|
+
supportTsx: false,
|
|
77
|
+
skipSerializers: true,
|
|
78
|
+
skipFormat: true,
|
|
79
|
+
});
|
|
80
|
+
const { startLocalRegistryPath, stopLocalRegistryPath } = (0, add_local_registry_scripts_1.addLocalRegistryScripts)(host);
|
|
81
|
+
(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
|
+
(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
|
+
const project = (0, devkit_1.readProjectConfiguration)(host, options.projectName);
|
|
84
|
+
const testTarget = project.targets.test;
|
|
85
|
+
project.targets.e2e = {
|
|
86
|
+
...testTarget,
|
|
87
|
+
dependsOn: [`^build`],
|
|
88
|
+
options: {
|
|
89
|
+
...testTarget.options,
|
|
90
|
+
runInBand: true,
|
|
91
|
+
},
|
|
92
|
+
configurations: testTarget.configurations,
|
|
93
|
+
};
|
|
94
|
+
// remove the jest build target
|
|
95
|
+
delete project.targets.test;
|
|
96
|
+
(0, devkit_1.updateProjectConfiguration)(host, options.projectName, project);
|
|
97
|
+
return jestTask;
|
|
85
98
|
}
|
|
86
|
-
function addLintingToApplication(tree, options) {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
setParserOptionsProject: false,
|
|
98
|
-
});
|
|
99
|
-
return lintTask;
|
|
99
|
+
async function addLintingToApplication(tree, options) {
|
|
100
|
+
const lintTask = await (0, linter_1.lintProjectGenerator)(tree, {
|
|
101
|
+
linter: options.linter,
|
|
102
|
+
project: options.projectName,
|
|
103
|
+
tsConfigPaths: [
|
|
104
|
+
(0, devkit_1.joinPathFragments)(options.projectRoot, 'tsconfig.app.json'),
|
|
105
|
+
],
|
|
106
|
+
eslintFilePatterns: [`${options.projectRoot}/**/*.ts`],
|
|
107
|
+
unitTestRunner: 'jest',
|
|
108
|
+
skipFormat: true,
|
|
109
|
+
setParserOptionsProject: false,
|
|
100
110
|
});
|
|
111
|
+
return lintTask;
|
|
101
112
|
}
|
|
102
|
-
function e2eProjectGenerator(host, schema) {
|
|
103
|
-
return
|
|
104
|
-
|
|
113
|
+
async function e2eProjectGenerator(host, schema) {
|
|
114
|
+
return await e2eProjectGeneratorInternal(host, {
|
|
115
|
+
projectNameAndRootFormat: 'derived',
|
|
116
|
+
...schema,
|
|
105
117
|
});
|
|
106
118
|
}
|
|
107
119
|
exports.e2eProjectGenerator = e2eProjectGenerator;
|
|
108
|
-
function e2eProjectGeneratorInternal(host, schema) {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
120
|
+
async function e2eProjectGeneratorInternal(host, schema) {
|
|
121
|
+
const tasks = [];
|
|
122
|
+
validatePlugin(host, schema.pluginName);
|
|
123
|
+
const options = await normalizeOptions(host, schema);
|
|
124
|
+
addFiles(host, options);
|
|
125
|
+
tasks.push(await (0, generator_1.setupVerdaccio)(host, {
|
|
126
|
+
skipFormat: true,
|
|
127
|
+
}));
|
|
128
|
+
tasks.push(await addJest(host, options));
|
|
129
|
+
if (options.linter !== linter_1.Linter.None) {
|
|
130
|
+
tasks.push(await addLintingToApplication(host, {
|
|
131
|
+
...options,
|
|
116
132
|
}));
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
yield (0, devkit_1.formatFiles)(host);
|
|
123
|
-
}
|
|
124
|
-
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
125
|
-
});
|
|
133
|
+
}
|
|
134
|
+
if (!options.skipFormat) {
|
|
135
|
+
await (0, devkit_1.formatFiles)(host);
|
|
136
|
+
}
|
|
137
|
+
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
126
138
|
}
|
|
127
139
|
exports.e2eProjectGeneratorInternal = e2eProjectGeneratorInternal;
|
|
128
140
|
exports.default = e2eProjectGenerator;
|