@nx/plugin 16.8.0-beta.4 → 16.8.0-beta.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/plugin",
3
- "version": "16.8.0-beta.4",
3
+ "version": "16.8.0-beta.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": {
@@ -28,11 +28,11 @@
28
28
  "migrations": "./migrations.json"
29
29
  },
30
30
  "dependencies": {
31
- "@nrwl/nx-plugin": "16.8.0-beta.4",
32
- "@nx/devkit": "16.8.0-beta.4",
33
- "@nx/jest": "16.8.0-beta.4",
34
- "@nx/js": "16.8.0-beta.4",
35
- "@nx/linter": "16.8.0-beta.4",
31
+ "@nrwl/nx-plugin": "16.8.0-beta.5",
32
+ "@nx/devkit": "16.8.0-beta.5",
33
+ "@nx/jest": "16.8.0-beta.5",
34
+ "@nx/js": "16.8.0-beta.5",
35
+ "@nx/linter": "16.8.0-beta.5",
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": "c9aad2dc8c2b34531cf61549bff872e68c481e4e"
44
+ "gitHead": "ad2d1e8a55b2d1b358bb5e7483343d9757ff2c53"
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
- return tslib_1.__asyncGenerator(this, arguments, function* nxPluginE2EExecutor_1() {
10
- var _a, e_1, _b, _c;
11
- const { target } = options, jestOptions = tslib_1.__rest(options, ["target"]);
12
- devkit_1.output.warn({
13
- title: `"@nx/plugin:e2e" is deprecated and will be removed in Nx 18`,
14
- bodyLines: [
15
- 'Use the "@nx/jest:jest" executor instead and set the following:',
16
- `"dependsOn": ["${target}"]`,
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
- for (var _d = true, _e = tslib_1.__asyncValues(runBuildTarget(target, context)), _f; _f = yield tslib_1.__await(_e.next()), _a = _f.done, !_a; _d = true) {
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 (e_1_1) { e_1 = { error: e_1_1 }; }
35
- finally {
36
- try {
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
- return yield tslib_1.__await({ success });
42
- });
25
+ }
26
+ return { success };
43
27
  }
44
28
  exports.nxPluginE2EExecutor = nxPluginE2EExecutor;
45
- function runBuildTarget(buildTarget, context) {
46
- return tslib_1.__asyncGenerator(this, arguments, function* runBuildTarget_1() {
47
- var _a, e_2, _b, _c;
48
- const graph = yield tslib_1.__await((0, devkit_1.createProjectGraphAsync)());
49
- const { project, target, configuration } = (0, devkit_1.parseTargetString)(buildTarget, graph);
50
- const buildTargetOptions = (0, devkit_1.readTargetOptions)({ project, target, configuration }, context);
51
- const targetSupportsWatch = Object.keys(buildTargetOptions).includes('watch');
52
- try {
53
- for (var _d = true, _e = tslib_1.__asyncValues(yield tslib_1.__await((0, devkit_1.runExecutor)({ project, target, configuration }, targetSupportsWatch ? { watch: false } : {}, context))), _f; _f = yield tslib_1.__await(_e.next()), _a = _f.done, !_a; _d = true) {
54
- _c = _f.value;
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
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
73
- const { success } = yield (0, jest_impl_1.jestExecutor)(Object.assign(Object.assign({}, jestOptions), { watch: false }), context);
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 tslib_1.__awaiter(this, void 0, void 0, function* () {
14
- return yield createPackageGeneratorInternal(host, Object.assign({ projectNameAndRootFormat: 'derived' }, schema));
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
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
20
- const tasks = [];
21
- const options = yield (0, normalize_schema_1.normalizeSchema)(host, schema);
22
- const pluginPackageName = yield addPresetGenerator(host, options);
23
- const installTask = (0, devkit_1.addDependenciesToPackageJson)(host, {
24
- 'create-nx-workspace': versions_1.nxVersion,
25
- }, {});
26
- tasks.push(installTask);
27
- yield createCliPackage(host, options, pluginPackageName);
28
- if (options.e2eProject) {
29
- addE2eProject(host, options);
30
- }
31
- if (!options.skipFormat) {
32
- yield (0, devkit_1.formatFiles)(host);
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
- var _a;
46
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
47
- const { root: projectRoot } = (0, devkit_1.readProjectConfiguration)(host, schema.project);
48
- if (!(0, has_generator_1.hasGenerator)(host, schema.project, 'preset')) {
49
- yield (0, generator_1.default)(host, {
50
- name: 'preset',
51
- project: schema.project,
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
- (0, devkit_1.generateFiles)(host, (0, devkit_1.joinPathFragments)(__dirname, './files/create-framework-package'), options.projectRoot, Object.assign(Object.assign({}, options), { preset: pluginPackageName, tmpl: '' }));
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
- var _a;
8
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
9
- const { projectName, names: projectNames, projectRoot, projectNameAndRootFormat, } = yield (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
10
- name: schema.name,
11
- projectType: 'library',
12
- directory: schema.directory,
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
- var _a;
15
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
16
- const projectName = options.rootProject ? 'e2e' : `${options.pluginName}-e2e`;
17
- let projectRoot;
18
- if (options.projectNameAndRootFormat === 'as-provided') {
19
- const projectNameAndRootOptions = yield (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
20
- name: projectName,
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
- ? (0, devkit_1.joinPathFragments)(appsDir, `${projectDirectory}-e2e`)
38
- : (0, devkit_1.joinPathFragments)(appsDir, projectName);
39
- }
40
- const pluginPropertyName = (0, devkit_1.names)(options.pluginName).propertyName;
41
- return Object.assign(Object.assign({}, options), { projectName, linter: (_a = options.linter) !== null && _a !== void 0 ? _a : linter_1.Linter.EsLint, pluginPropertyName,
42
- projectRoot });
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 (_a) {
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, Object.assign(Object.assign({}, options), { tmpl: '', rootTsConfigPath: (0, js_1.getRelativePathToRootTsConfig)(host, options.projectRoot), packageManagerCommands: (0, devkit_1.getPackageManagerCommand)('npm'), pluginPackageName }));
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
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
60
- (0, devkit_1.addProjectConfiguration)(host, options.projectName, {
61
- root: options.projectRoot,
62
- projectType: 'application',
63
- sourceRoot: `${options.projectRoot}/tests`,
64
- targets: {},
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
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
88
- const lintTask = yield (0, linter_1.lintProjectGenerator)(tree, {
89
- linter: options.linter,
90
- project: options.projectName,
91
- tsConfigPaths: [
92
- (0, devkit_1.joinPathFragments)(options.projectRoot, 'tsconfig.app.json'),
93
- ],
94
- eslintFilePatterns: [`${options.projectRoot}/**/*.ts`],
95
- unitTestRunner: 'jest',
96
- skipFormat: true,
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 tslib_1.__awaiter(this, void 0, void 0, function* () {
104
- return yield e2eProjectGeneratorInternal(host, Object.assign({ projectNameAndRootFormat: 'derived' }, schema));
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
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
110
- const tasks = [];
111
- validatePlugin(host, schema.pluginName);
112
- const options = yield normalizeOptions(host, schema);
113
- addFiles(host, options);
114
- tasks.push(yield (0, generator_1.setupVerdaccio)(host, {
115
- skipFormat: true,
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
- tasks.push(yield addJest(host, options));
118
- if (options.linter !== linter_1.Linter.None) {
119
- tasks.push(yield addLintingToApplication(host, Object.assign({}, options)));
120
- }
121
- if (!options.skipFormat) {
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;