@nx/plugin 0.0.0-pr-27957-a99d5ea → 0.0.0-pr-28229-afe192c

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.
Files changed (33) hide show
  1. package/generators.json +5 -5
  2. package/package.json +6 -8
  3. package/src/generators/create-package/create-package.d.ts +0 -1
  4. package/src/generators/create-package/create-package.js +2 -9
  5. package/src/generators/create-package/files/create-framework-package/bin/index.ts__tmpl__ +9 -6
  6. package/src/generators/create-package/schema.d.ts +1 -3
  7. package/src/generators/create-package/schema.json +9 -14
  8. package/src/generators/create-package/utils/normalize-schema.js +4 -4
  9. package/src/generators/e2e-project/e2e.js +7 -22
  10. package/src/generators/e2e-project/schema.d.ts +0 -2
  11. package/src/generators/e2e-project/schema.json +0 -5
  12. package/src/generators/executor/executor.d.ts +1 -2
  13. package/src/generators/executor/executor.js +9 -21
  14. package/src/generators/executor/schema.d.ts +2 -10
  15. package/src/generators/executor/schema.json +7 -21
  16. package/src/generators/generator/generator.d.ts +1 -2
  17. package/src/generators/generator/generator.js +8 -20
  18. package/src/generators/generator/schema.d.ts +2 -8
  19. package/src/generators/generator/schema.json +8 -22
  20. package/src/generators/migration/migration.d.ts +1 -2
  21. package/src/generators/migration/migration.js +8 -18
  22. package/src/generators/migration/schema.d.ts +1 -7
  23. package/src/generators/migration/schema.json +9 -22
  24. package/src/generators/plugin/plugin.d.ts +0 -1
  25. package/src/generators/plugin/plugin.js +0 -9
  26. package/src/generators/plugin/schema.d.ts +2 -4
  27. package/src/generators/plugin/schema.json +7 -13
  28. package/src/generators/plugin/utils/normalize-schema.js +3 -16
  29. package/src/generators/preset/generator.js +3 -4
  30. package/src/utils/testing-utils/async-commands.js +1 -0
  31. package/src/utils/testing-utils/commands.js +1 -0
  32. package/src/utils/testing-utils/nx-project.js +4 -2
  33. package/src/utils/testing-utils/utils.js +17 -14
package/generators.json CHANGED
@@ -4,12 +4,12 @@
4
4
  "extends": ["@nx/workspace"],
5
5
  "generators": {
6
6
  "plugin": {
7
- "factory": "./src/generators/plugin/plugin#pluginGeneratorInternal",
7
+ "factory": "./src/generators/plugin/plugin",
8
8
  "schema": "./src/generators/plugin/schema.json",
9
9
  "description": "Create a Nx Plugin."
10
10
  },
11
11
  "create-package": {
12
- "factory": "./src/generators/create-package/create-package#createPackageGeneratorInternal",
12
+ "factory": "./src/generators/create-package/create-package",
13
13
  "schema": "./src/generators/create-package/schema.json",
14
14
  "description": "Create a package which can be used by npx to create a new workspace"
15
15
  },
@@ -19,17 +19,17 @@
19
19
  "description": "Create a E2E application for a Nx Plugin."
20
20
  },
21
21
  "migration": {
22
- "factory": "./src/generators/migration/migration#migrationGeneratorInternal",
22
+ "factory": "./src/generators/migration/migration",
23
23
  "schema": "./src/generators/migration/schema.json",
24
24
  "description": "Create a migration for an Nx Plugin."
25
25
  },
26
26
  "generator": {
27
- "factory": "./src/generators/generator/generator#generatorGeneratorInternal",
27
+ "factory": "./src/generators/generator/generator",
28
28
  "schema": "./src/generators/generator/schema.json",
29
29
  "description": "Create a generator for an Nx Plugin."
30
30
  },
31
31
  "executor": {
32
- "factory": "./src/generators/executor/executor#executorGeneratorInternal",
32
+ "factory": "./src/generators/executor/executor",
33
33
  "schema": "./src/generators/executor/schema.json",
34
34
  "description": "Create an executor for an Nx Plugin."
35
35
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/plugin",
3
- "version": "0.0.0-pr-27957-a99d5ea",
3
+ "version": "0.0.0-pr-28229-afe192c",
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": {
@@ -27,16 +27,14 @@
27
27
  "migrations": "./migrations.json"
28
28
  },
29
29
  "dependencies": {
30
- "fs-extra": "^11.1.0",
31
30
  "tslib": "^2.3.0",
32
- "@nx/devkit": "0.0.0-pr-27957-a99d5ea",
33
- "@nx/jest": "0.0.0-pr-27957-a99d5ea",
34
- "@nx/js": "0.0.0-pr-27957-a99d5ea",
35
- "@nx/eslint": "0.0.0-pr-27957-a99d5ea",
36
- "@nrwl/nx-plugin": "0.0.0-pr-27957-a99d5ea"
31
+ "@nx/devkit": "0.0.0-pr-28229-afe192c",
32
+ "@nx/jest": "0.0.0-pr-28229-afe192c",
33
+ "@nx/js": "0.0.0-pr-28229-afe192c",
34
+ "@nx/eslint": "0.0.0-pr-28229-afe192c"
37
35
  },
38
36
  "publishConfig": {
39
37
  "access": "public"
40
38
  },
41
39
  "type": "commonjs"
42
- }
40
+ }
@@ -1,5 +1,4 @@
1
1
  import { GeneratorCallback, Tree } from '@nx/devkit';
2
2
  import { CreatePackageSchema } from './schema';
3
3
  export declare function createPackageGenerator(host: Tree, schema: CreatePackageSchema): Promise<GeneratorCallback>;
4
- export declare function createPackageGeneratorInternal(host: Tree, schema: CreatePackageSchema): Promise<GeneratorCallback>;
5
4
  export default createPackageGenerator;
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createPackageGenerator = createPackageGenerator;
4
- exports.createPackageGeneratorInternal = createPackageGeneratorInternal;
5
4
  const devkit_1 = require("@nx/devkit");
6
5
  const js_1 = require("@nx/js");
7
6
  const add_tslib_dependencies_1 = require("@nx/js/src/utils/typescript/add-tslib-dependencies");
@@ -12,12 +11,6 @@ const has_generator_1 = require("../../utils/has-generator");
12
11
  const path_1 = require("path");
13
12
  const versions_2 = require("@nx/js/src/utils/versions");
14
13
  async function createPackageGenerator(host, schema) {
15
- return await createPackageGeneratorInternal(host, {
16
- projectNameAndRootFormat: 'derived',
17
- ...schema,
18
- });
19
- }
20
- async function createPackageGeneratorInternal(host, schema) {
21
14
  const tasks = [];
22
15
  const options = await (0, normalize_schema_1.normalizeSchema)(host, schema);
23
16
  const pluginPackageName = await addPresetGenerator(host, options);
@@ -48,10 +41,9 @@ async function addPresetGenerator(host, schema) {
48
41
  if (!(0, has_generator_1.hasGenerator)(host, schema.project, 'preset')) {
49
42
  await (0, generator_1.default)(host, {
50
43
  name: 'preset',
51
- directory: (0, path_1.join)(projectRoot, 'src/generators/preset'),
44
+ path: (0, path_1.join)(projectRoot, 'src/generators/preset'),
52
45
  unitTestRunner: schema.unitTestRunner,
53
46
  skipFormat: true,
54
- nameAndDirectoryFormat: 'as-provided',
55
47
  });
56
48
  }
57
49
  return (0, devkit_1.readJson)(host, (0, devkit_1.joinPathFragments)(projectRoot, 'package.json'))?.name;
@@ -59,6 +51,7 @@ async function addPresetGenerator(host, schema) {
59
51
  async function createCliPackage(host, options, pluginPackageName) {
60
52
  await (0, js_1.libraryGenerator)(host, {
61
53
  ...options,
54
+ directory: options.directory,
62
55
  rootProject: false,
63
56
  config: 'project',
64
57
  publishable: true,
@@ -12,14 +12,17 @@ async function main() {
12
12
 
13
13
  // This assumes "<%= preset %>" and "<%= projectName %>" are at the same version
14
14
  // eslint-disable-next-line @typescript-eslint/no-var-requires
15
- const presetVersion = require('../package.json').version,
15
+ const presetVersion = require('../package.json').version;
16
16
 
17
17
  // TODO: update below to customize the workspace
18
- const { directory } = await createWorkspace(`<%= preset %>@${presetVersion}`, {
19
- name,
20
- nxCloud: 'skip',
21
- packageManager: 'npm',
22
- });
18
+ const { directory } = await createWorkspace(
19
+ `<%= preset %>@${presetVersion}`,
20
+ {
21
+ name,
22
+ nxCloud: 'skip',
23
+ packageManager: 'npm',
24
+ }
25
+ );
23
26
 
24
27
  console.log(`Successfully created the workspace: ${directory}.`);
25
28
  }
@@ -1,13 +1,11 @@
1
- import type { ProjectNameAndRootFormat } from '@nx/devkit/src/generators/project-name-and-root-utils';
2
1
  import type { Linter, LinterType } from '@nx/eslint';
3
2
 
4
3
  export interface CreatePackageSchema {
5
4
  name: string;
6
5
  project: string;
6
+ directory: string;
7
7
 
8
8
  // options to create cli package, passed to js library generator
9
- directory?: string;
10
- projectNameAndRootFormat?: ProjectNameAndRootFormat;
11
9
  skipFormat: boolean;
12
10
  tags?: string;
13
11
  unitTestRunner: 'jest' | 'none';
@@ -7,14 +7,18 @@
7
7
  "examplesFile": "../../../docs/generators/create-package-examples.md",
8
8
  "type": "object",
9
9
  "properties": {
10
- "name": {
10
+ "directory": {
11
11
  "type": "string",
12
- "description": "The package name of cli, e.g. `create-framework-package`. Note this must be a valid NPM name to be published.",
13
- "pattern": "create-.+|^@.+/create(?:-.+)?",
12
+ "description": "A directory where the app is placed.",
14
13
  "$default": {
15
14
  "$source": "argv",
16
15
  "index": 0
17
- },
16
+ }
17
+ },
18
+ "name": {
19
+ "type": "string",
20
+ "description": "The package name of cli, e.g. `create-framework-package`. Note this must be a valid NPM name to be published.",
21
+ "pattern": "create-.+|^@.+/create(?:-.+)?",
18
22
  "x-priority": "important"
19
23
  },
20
24
  "project": {
@@ -33,15 +37,6 @@
33
37
  "description": "Test runner to use for unit tests.",
34
38
  "default": "jest"
35
39
  },
36
- "directory": {
37
- "type": "string",
38
- "description": "A directory where the app is placed."
39
- },
40
- "projectNameAndRootFormat": {
41
- "description": "Whether to generate the project name and root directory as provided (`as-provided`) or generate them composing their values and taking the configured layout into account (`derived`).",
42
- "type": "string",
43
- "enum": ["as-provided", "derived"]
44
- },
45
40
  "linter": {
46
41
  "description": "The tool to use for running lint checks.",
47
42
  "type": "string",
@@ -71,5 +66,5 @@
71
66
  "x-prompt": "What is the name of the e2e project? Leave blank to skip e2e tests"
72
67
  }
73
68
  },
74
- "required": ["name", "project"]
69
+ "required": ["directory", "name", "project"]
75
70
  }
@@ -3,14 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.normalizeSchema = normalizeSchema;
4
4
  const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
5
5
  async function normalizeSchema(host, schema) {
6
- const { projectName, names: projectNames, projectRoot, projectNameAndRootFormat, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
6
+ if (!schema.directory) {
7
+ throw new Error(`Please provide the --directory option. It should be the directory containing the project '${schema.project}'.`);
8
+ }
9
+ const { projectName, names: projectNames, projectRoot, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
7
10
  name: schema.name,
8
11
  projectType: 'library',
9
12
  directory: schema.directory,
10
- projectNameAndRootFormat: schema.projectNameAndRootFormat,
11
- callingGenerator: '@nx/plugin:create-package',
12
13
  });
13
- schema.projectNameAndRootFormat = projectNameAndRootFormat;
14
14
  return {
15
15
  ...schema,
16
16
  bundler: schema.compiler ?? 'tsc',
@@ -17,28 +17,14 @@ async function normalizeOptions(host, options) {
17
17
  nxJson.useInferencePlugins !== false;
18
18
  options.addPlugin ??= addPlugin;
19
19
  let projectRoot;
20
- if (options.projectNameAndRootFormat === 'as-provided') {
21
- const projectNameAndRootOptions = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
22
- name: projectName,
23
- projectType: 'application',
24
- directory: options.rootProject || !options.projectDirectory
25
- ? projectName
26
- : `${options.projectDirectory}-e2e`,
27
- projectNameAndRootFormat: `as-provided`,
28
- callingGenerator: '@nx/plugin:e2e-project',
29
- });
30
- projectRoot = projectNameAndRootOptions.projectRoot;
31
- }
32
- else {
33
- const { layoutDirectory, projectDirectory } = (0, devkit_1.extractLayoutDirectory)(options.projectDirectory);
34
- const { appsDir: defaultAppsDir } = (0, devkit_1.getWorkspaceLayout)(host);
35
- const appsDir = layoutDirectory ?? defaultAppsDir;
36
- projectRoot = options.rootProject
20
+ const projectNameAndRootOptions = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
21
+ name: projectName,
22
+ projectType: 'application',
23
+ directory: options.rootProject || !options.projectDirectory
37
24
  ? projectName
38
- : projectDirectory
39
- ? (0, devkit_1.joinPathFragments)(appsDir, `${projectDirectory}-e2e`)
40
- : (0, devkit_1.joinPathFragments)(appsDir, projectName);
41
- }
25
+ : `${options.projectDirectory}-e2e`,
26
+ });
27
+ projectRoot = projectNameAndRootOptions.projectRoot;
42
28
  const pluginPropertyName = (0, devkit_1.names)(options.pluginName).propertyName;
43
29
  return {
44
30
  ...options,
@@ -117,7 +103,6 @@ async function addLintingToApplication(tree, options) {
117
103
  async function e2eProjectGenerator(host, schema) {
118
104
  return await e2eProjectGeneratorInternal(host, {
119
105
  addPlugin: false,
120
- projectNameAndRootFormat: 'derived',
121
106
  ...schema,
122
107
  });
123
108
  }
@@ -1,11 +1,9 @@
1
- import type { ProjectNameAndRootFormat } from '@nx/devkit/src/generators/project-name-and-root-utils';
2
1
  import type { Linter, LinterType } from '@nx/eslint';
3
2
 
4
3
  export interface Schema {
5
4
  pluginName: string;
6
5
  npmPackageName: string;
7
6
  projectDirectory?: string;
8
- projectNameAndRootFormat?: ProjectNameAndRootFormat;
9
7
  pluginOutputPath?: string;
10
8
  jestConfig?: string;
11
9
  linter?: Linter | LinterType;
@@ -21,11 +21,6 @@
21
21
  "type": "string",
22
22
  "description": "the directory where the plugin is placed."
23
23
  },
24
- "projectNameAndRootFormat": {
25
- "description": "Whether to generate the project name and root directory as provided (`as-provided`) or generate them composing their values and taking the configured layout into account (`derived`).",
26
- "type": "string",
27
- "enum": ["as-provided", "derived"]
28
- },
29
24
  "pluginOutputPath": {
30
25
  "type": "string",
31
26
  "description": "the output path of the plugin after it builds.",
@@ -1,6 +1,5 @@
1
1
  import type { Tree } from '@nx/devkit';
2
2
  import type { Schema } from './schema';
3
3
  export declare function createExecutorsJson(host: Tree, projectRoot: string, projectName: string, skipLintChecks?: boolean): Promise<void>;
4
- export declare function executorGenerator(tree: Tree, rawOptions: Schema): Promise<void>;
5
- export declare function executorGeneratorInternal(host: Tree, schema: Schema): Promise<void>;
4
+ export declare function executorGenerator(host: Tree, schema: Schema): Promise<void>;
6
5
  export default executorGenerator;
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createExecutorsJson = createExecutorsJson;
4
4
  exports.executorGenerator = executorGenerator;
5
- exports.executorGeneratorInternal = executorGeneratorInternal;
6
5
  const devkit_1 = require("@nx/devkit");
7
6
  const path = require("path");
8
7
  const generator_1 = require("../lint-checks/generator");
@@ -10,19 +9,19 @@ const versions_1 = require("../../utils/versions");
10
9
  const artifact_name_and_directory_utils_1 = require("@nx/devkit/src/generators/artifact-name-and-directory-utils");
11
10
  const path_1 = require("path");
12
11
  function addFiles(host, options) {
13
- (0, devkit_1.generateFiles)(host, path.join(__dirname, './files/executor'), options.directory, {
12
+ (0, devkit_1.generateFiles)(host, path.join(__dirname, './files/executor'), options.path, {
14
13
  ...options,
15
14
  });
16
15
  if (options.unitTestRunner === 'none') {
17
- host.delete((0, devkit_1.joinPathFragments)(options.directory, `executor.spec.ts`));
16
+ host.delete((0, devkit_1.joinPathFragments)(options.path, `executor.spec.ts`));
18
17
  }
19
18
  }
20
19
  function addHasherFiles(host, options) {
21
- (0, devkit_1.generateFiles)(host, path.join(__dirname, './files/hasher'), options.directory, {
20
+ (0, devkit_1.generateFiles)(host, path.join(__dirname, './files/hasher'), options.path, {
22
21
  ...options,
23
22
  });
24
23
  if (options.unitTestRunner === 'none') {
25
- host.delete((0, devkit_1.joinPathFragments)(options.directory, 'hasher.spec.ts'));
24
+ host.delete((0, devkit_1.joinPathFragments)(options.path, 'hasher.spec.ts'));
26
25
  }
27
26
  }
28
27
  async function createExecutorsJson(host, projectRoot, projectName, skipLintChecks) {
@@ -63,12 +62,12 @@ async function updateExecutorJson(host, options) {
63
62
  let executors = json.executors ?? json.builders;
64
63
  executors ||= {};
65
64
  executors[options.name] = {
66
- implementation: `./${(0, devkit_1.joinPathFragments)((0, path_1.relative)(options.projectRoot, options.directory), 'executor')}`,
67
- schema: `./${(0, devkit_1.joinPathFragments)((0, path_1.relative)(options.projectRoot, options.directory), 'schema.json')}`,
65
+ implementation: `./${(0, devkit_1.joinPathFragments)((0, path_1.relative)(options.projectRoot, options.path), 'executor')}`,
66
+ schema: `./${(0, devkit_1.joinPathFragments)((0, path_1.relative)(options.projectRoot, options.path), 'schema.json')}`,
68
67
  description: options.description,
69
68
  };
70
69
  if (options.includeHasher) {
71
- executors[options.name].hasher = `./${(0, devkit_1.joinPathFragments)((0, path_1.relative)(options.projectRoot, options.directory), 'hasher')}`;
70
+ executors[options.name].hasher = `./${(0, devkit_1.joinPathFragments)((0, path_1.relative)(options.projectRoot, options.path), 'hasher')}`;
72
71
  }
73
72
  json.executors = executors;
74
73
  return json;
@@ -76,14 +75,9 @@ async function updateExecutorJson(host, options) {
76
75
  }
77
76
  async function normalizeOptions(tree, options) {
78
77
  const { project, artifactName, filePath, directory } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(tree, {
79
- artifactType: 'executor',
80
- callingGenerator: '@nx/plugin:executor',
81
78
  name: options.name,
82
- nameAndDirectoryFormat: options.nameAndDirectoryFormat,
83
- project: options.project,
84
- directory: options.directory,
79
+ path: options.path,
85
80
  fileName: 'executor',
86
- derivedDirectory: 'executors',
87
81
  });
88
82
  const { className, propertyName } = (0, devkit_1.names)(artifactName);
89
83
  const { root: projectRoot } = (0, devkit_1.readProjectConfiguration)(tree, project);
@@ -105,13 +99,7 @@ async function normalizeOptions(tree, options) {
105
99
  projectRoot,
106
100
  };
107
101
  }
108
- async function executorGenerator(tree, rawOptions) {
109
- await executorGeneratorInternal(tree, {
110
- nameAndDirectoryFormat: 'derived',
111
- ...rawOptions,
112
- });
113
- }
114
- async function executorGeneratorInternal(host, schema) {
102
+ async function executorGenerator(host, schema) {
115
103
  const options = await normalizeOptions(host, schema);
116
104
  addFiles(host, options);
117
105
  if (options.includeHasher) {
@@ -1,17 +1,9 @@
1
- import type { NameAndDirectoryFormat } from '@nx/devkit/src/generators/artifact-name-and-directory-utils';
2
-
3
1
  export interface Schema {
4
- name: string;
5
- directory?: string;
2
+ path: string;
3
+ name?: string;
6
4
  description?: string;
7
5
  unitTestRunner: 'jest' | 'none';
8
6
  includeHasher: boolean;
9
- nameAndDirectoryFormat?: NameAndDirectoryFormat;
10
7
  skipLintChecks?: boolean;
11
8
  skipFormat?: boolean;
12
-
13
- /**
14
- * @deprecated Provide the `directory` option instead. The project will be determined from the directory provided. It will be removed in Nx v20.
15
- */
16
- project?: string;
17
9
  }
@@ -13,20 +13,20 @@
13
13
  }
14
14
  ],
15
15
  "properties": {
16
- "name": {
16
+ "path": {
17
17
  "type": "string",
18
- "description": "Executor name.",
18
+ "description": "Path at which to generate the executor file.",
19
+ "x-prompt": "What path would you like to use for the executor?",
19
20
  "$default": {
20
21
  "$source": "argv",
21
22
  "index": 0
22
23
  },
23
- "x-prompt": "What name would you like to use for the executor?",
24
24
  "x-priority": "important"
25
25
  },
26
- "directory": {
26
+ "name": {
27
27
  "type": "string",
28
- "description": "The directory at which to create the executor file. When `--nameAndDirectoryFormat=as-provided`, it will be relative to the current working directory. Otherwise, it will be relative to the workspace root.",
29
- "aliases": ["dir"],
28
+ "description": "Executor name.",
29
+ "x-prompt": "What name would you like to use for the executor?",
30
30
  "x-priority": "important"
31
31
  },
32
32
  "description": {
@@ -50,20 +50,6 @@
50
50
  "default": false,
51
51
  "description": "Do not add an eslint configuration for plugin json files."
52
52
  },
53
- "nameAndDirectoryFormat": {
54
- "description": "Whether to generate the executor in the directory as provided, relative to the current working directory and ignoring the project (`as-provided`) or generate it using the project and directory relative to the workspace root (`derived`).",
55
- "type": "string",
56
- "enum": ["as-provided", "derived"]
57
- },
58
- "project": {
59
- "type": "string",
60
- "description": "The name of the project.",
61
- "alias": "p",
62
- "$default": {
63
- "$source": "projectName"
64
- },
65
- "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v20."
66
- },
67
53
  "skipFormat": {
68
54
  "type": "boolean",
69
55
  "description": "Skip formatting files.",
@@ -71,6 +57,6 @@
71
57
  "x-priority": "internal"
72
58
  }
73
59
  },
74
- "required": ["name"],
60
+ "required": ["path"],
75
61
  "additionalProperties": false
76
62
  }
@@ -1,6 +1,5 @@
1
1
  import { Tree } from '@nx/devkit';
2
2
  import type { Schema } from './schema';
3
3
  export declare function createGeneratorsJson(host: Tree, projectRoot: string, projectName: string, skipLintChecks?: boolean, skipFormat?: boolean): Promise<void>;
4
- export declare function generatorGenerator(tree: Tree, rawOptions: Schema): Promise<void>;
5
- export declare function generatorGeneratorInternal(host: Tree, schema: Schema): Promise<void>;
4
+ export declare function generatorGenerator(host: Tree, schema: Schema): Promise<void>;
6
5
  export default generatorGenerator;
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createGeneratorsJson = createGeneratorsJson;
4
4
  exports.generatorGenerator = generatorGenerator;
5
- exports.generatorGeneratorInternal = generatorGeneratorInternal;
6
5
  const devkit_1 = require("@nx/devkit");
7
6
  const has_generator_1 = require("../../utils/has-generator");
8
7
  const generator_1 = require("../lint-checks/generator");
@@ -11,14 +10,9 @@ const artifact_name_and_directory_utils_1 = require("@nx/devkit/src/generators/a
11
10
  const path_1 = require("path");
12
11
  async function normalizeOptions(tree, options) {
13
12
  const { project, fileName, artifactName, filePath, directory } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(tree, {
14
- artifactType: 'generator',
15
- callingGenerator: '@nx/plugin:generator',
16
13
  name: options.name,
17
- nameAndDirectoryFormat: options.nameAndDirectoryFormat,
18
- project: options.project,
19
- directory: options.directory,
14
+ path: options.path,
20
15
  fileName: 'generator',
21
- derivedDirectory: 'generators',
22
16
  });
23
17
  const { className, propertyName } = (0, devkit_1.names)(artifactName);
24
18
  const { root: projectRoot, sourceRoot: projectSourceRoot } = (0, devkit_1.readProjectConfiguration)(tree, project);
@@ -31,8 +25,8 @@ async function normalizeOptions(tree, options) {
31
25
  }
32
26
  return {
33
27
  ...options,
34
- project,
35
28
  directory,
29
+ project,
36
30
  fileName,
37
31
  className,
38
32
  propertyName,
@@ -42,17 +36,17 @@ async function normalizeOptions(tree, options) {
42
36
  };
43
37
  }
44
38
  function addFiles(host, options) {
45
- const indexPath = (0, path_1.join)(options.directory, 'files/src/index.ts.template');
39
+ const indexPath = (0, path_1.join)(options.path, 'files/src/index.ts.template');
46
40
  if (!host.exists(indexPath)) {
47
41
  host.write(indexPath, 'const variable = "<%= name %>";');
48
42
  }
49
- (0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, './files/generator'), options.directory, {
43
+ (0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, './files/generator'), options.path, {
50
44
  ...options,
51
45
  generatorFnName: `${options.propertyName}Generator`,
52
46
  schemaInterfaceName: `${options.className}GeneratorSchema`,
53
47
  });
54
48
  if (options.unitTestRunner === 'none') {
55
- host.delete((0, path_1.join)(options.directory, `generator.spec.ts`));
49
+ host.delete((0, path_1.join)(options.path, `generator.spec.ts`));
56
50
  }
57
51
  }
58
52
  async function createGeneratorsJson(host, projectRoot, projectName, skipLintChecks, skipFormat) {
@@ -94,8 +88,8 @@ async function updateGeneratorJson(host, options) {
94
88
  let generators = json.generators ?? json.schematics;
95
89
  generators = generators || {};
96
90
  generators[options.name] = {
97
- factory: `./${(0, devkit_1.joinPathFragments)((0, path_1.relative)(options.projectRoot, options.directory), 'generator')}`,
98
- schema: `./${(0, devkit_1.joinPathFragments)((0, path_1.relative)(options.projectRoot, options.directory), 'schema.json')}`,
91
+ factory: `./${(0, devkit_1.joinPathFragments)((0, path_1.relative)(options.projectRoot, options.path), 'generator')}`,
92
+ schema: `./${(0, devkit_1.joinPathFragments)((0, path_1.relative)(options.projectRoot, options.path), 'schema.json')}`,
99
93
  description: options.description,
100
94
  };
101
95
  // @todo(v17): Remove this, prop is defunct.
@@ -106,13 +100,7 @@ async function updateGeneratorJson(host, options) {
106
100
  return json;
107
101
  });
108
102
  }
109
- async function generatorGenerator(tree, rawOptions) {
110
- await generatorGeneratorInternal(tree, {
111
- nameAndDirectoryFormat: 'derived',
112
- ...rawOptions,
113
- });
114
- }
115
- async function generatorGeneratorInternal(host, schema) {
103
+ async function generatorGenerator(host, schema) {
116
104
  const options = await normalizeOptions(host, schema);
117
105
  if ((0, has_generator_1.hasGenerator)(host, options.project, options.name)) {
118
106
  throw new Error(`Generator ${options.name} already exists.`);
@@ -1,16 +1,10 @@
1
1
  import { NameAndDirectoryFormat } from '@nx/devkit/src/generators/artifact-name-and-directory-utils';
2
2
 
3
3
  export interface Schema {
4
- directory?: string;
5
- name: string;
4
+ path: string;
5
+ name?: string;
6
6
  description?: string;
7
7
  unitTestRunner: 'jest' | 'none';
8
8
  skipLintChecks?: boolean;
9
9
  skipFormat?: boolean;
10
- nameAndDirectoryFormat?: NameAndDirectoryFormat;
11
-
12
- /**
13
- * @deprecated Provide the `directory` option instead. The project will be determined from the directory provided. It will be removed in Nx v20.
14
- */
15
- project?: string;
16
10
  }
@@ -7,25 +7,25 @@
7
7
  "type": "object",
8
8
  "examples": [
9
9
  {
10
- "command": "nx g generator my-generator --project=my-plugin",
10
+ "command": "nx g generator libs/my-plugin/src/generators//my-generator",
11
11
  "description": "Generate `libs/my-plugin/src/generators/my-generator`"
12
12
  }
13
13
  ],
14
14
  "properties": {
15
- "name": {
15
+ "path": {
16
16
  "type": "string",
17
- "description": "Generator name.",
17
+ "description": "Path where the generator will be generated.",
18
18
  "$default": {
19
19
  "$source": "argv",
20
20
  "index": 0
21
21
  },
22
- "x-prompt": "What name would you like to use for the generator?",
22
+ "x-prompt": "Where should the generator be generated?",
23
23
  "x-priority": "important"
24
24
  },
25
- "directory": {
25
+ "name": {
26
26
  "type": "string",
27
- "description": "The directory at which to create the generator file. When `--nameAndDirectoryFormat=as-provided`, it will be relative to the current working directory. Otherwise, it will be relative to the workspace root.",
28
- "aliases": ["dir"],
27
+ "description": "Generator name.",
28
+ "x-prompt": "What name would you like to use for the generator?",
29
29
  "x-priority": "important"
30
30
  },
31
31
  "description": {
@@ -44,27 +44,13 @@
44
44
  "default": false,
45
45
  "description": "Do not add an eslint configuration for plugin json files."
46
46
  },
47
- "project": {
48
- "type": "string",
49
- "description": "The name of the project.",
50
- "alias": "p",
51
- "$default": {
52
- "$source": "projectName"
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 v20."
55
- },
56
47
  "skipFormat": {
57
48
  "type": "boolean",
58
49
  "default": false,
59
50
  "description": "Do not format files with prettier.",
60
51
  "x-priority": "internal"
61
- },
62
- "nameAndDirectoryFormat": {
63
- "description": "Whether to generate the generator in the directory as provided, relative to the current working directory and ignoring the project (`as-provided`) or generate it using the project and directory relative to the workspace root (`derived`).",
64
- "type": "string",
65
- "enum": ["as-provided", "derived"]
66
52
  }
67
53
  },
68
- "required": ["name"],
54
+ "required": ["path"],
69
55
  "additionalProperties": false
70
56
  }
@@ -1,5 +1,4 @@
1
1
  import type { Tree } from '@nx/devkit';
2
2
  import type { Schema } from './schema';
3
- export declare function migrationGenerator(tree: Tree, rawOptions: Schema): Promise<void>;
4
- export declare function migrationGeneratorInternal(host: Tree, schema: Schema): Promise<void>;
3
+ export declare function migrationGenerator(host: Tree, schema: Schema): Promise<void>;
5
4
  export default migrationGenerator;
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.migrationGenerator = migrationGenerator;
4
- exports.migrationGeneratorInternal = migrationGeneratorInternal;
5
4
  const devkit_1 = require("@nx/devkit");
6
5
  const path = require("path");
7
6
  const path_1 = require("path");
@@ -18,25 +17,19 @@ async function normalizeOptions(tree, options) {
18
17
  name = (0, devkit_1.names)(`update-${options.packageVersion}`).fileName;
19
18
  }
20
19
  const { project, fileName, artifactName, filePath, directory } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(tree, {
21
- artifactType: 'migration',
22
- callingGenerator: '@nx/plugin:migration',
23
20
  name: name,
24
- nameAndDirectoryFormat: options.nameAndDirectoryFormat,
25
- project: options.project,
26
- directory: options.directory,
21
+ path: options.path,
27
22
  fileName: name,
28
- derivedDirectory: 'migrations',
29
23
  });
30
- const { className, propertyName } = (0, devkit_1.names)(artifactName);
31
24
  const { root: projectRoot, sourceRoot: projectSourceRoot } = (0, devkit_1.readProjectConfiguration)(tree, project);
32
25
  const description = options.description ?? `Migration for v${options.packageVersion}`;
33
26
  // const { root: projectRoot, sourceRoot: projectSourceRoot } =
34
27
  // readProjectConfiguration(host, options.project);
35
28
  const normalized = {
36
29
  ...options,
30
+ directory,
37
31
  project,
38
32
  name: artifactName,
39
- directory,
40
33
  description,
41
34
  projectRoot,
42
35
  projectSourceRoot,
@@ -44,7 +37,10 @@ async function normalizeOptions(tree, options) {
44
37
  return normalized;
45
38
  }
46
39
  function addFiles(host, options) {
47
- (0, devkit_1.generateFiles)(host, path.join(__dirname, 'files/migration'), options.directory, { ...options, tmpl: '' });
40
+ (0, devkit_1.generateFiles)(host, path.join(__dirname, 'files/migration'), options.path, {
41
+ ...options,
42
+ tmpl: '',
43
+ });
48
44
  }
49
45
  function updateMigrationsJson(host, options) {
50
46
  const configuredMigrationPath = (0, package_json_1.readNxMigrateConfig)((0, devkit_1.readJson)(host, (0, devkit_1.joinPathFragments)(options.projectRoot, 'package.json'))).migrations;
@@ -56,7 +52,7 @@ function updateMigrationsJson(host, options) {
56
52
  generators[options.name] = {
57
53
  version: options.packageVersion,
58
54
  description: options.description,
59
- implementation: `./${(0, devkit_1.joinPathFragments)((0, path_1.relative)(options.projectRoot, options.directory), options.name)}`,
55
+ implementation: `./${(0, devkit_1.joinPathFragments)((0, path_1.relative)(options.projectRoot, options.path), options.name)}`,
60
56
  };
61
57
  migrations.generators = generators;
62
58
  if (options.packageJsonUpdates) {
@@ -110,13 +106,7 @@ function updateProjectConfig(host, options) {
110
106
  (0, devkit_1.updateProjectConfiguration)(host, options.project, project);
111
107
  }
112
108
  }
113
- async function migrationGenerator(tree, rawOptions) {
114
- await migrationGeneratorInternal(tree, {
115
- nameAndDirectoryFormat: 'derived',
116
- ...rawOptions,
117
- });
118
- }
119
- async function migrationGeneratorInternal(host, schema) {
109
+ async function migrationGenerator(host, schema) {
120
110
  const options = await normalizeOptions(host, schema);
121
111
  addFiles(host, options);
122
112
  updateMigrationsJson(host, options);
@@ -1,16 +1,10 @@
1
1
  import { NameAndDirectoryFormat } from '@nx/devkit/src/generators/artifact-name-and-directory-utils';
2
2
 
3
3
  export interface Schema {
4
+ path: string;
4
5
  name?: string;
5
- directory?: string;
6
6
  description?: string;
7
7
  packageVersion: string;
8
8
  packageJsonUpdates?: boolean;
9
9
  skipFormat?: boolean;
10
- nameAndDirectoryFormat?: NameAndDirectoryFormat;
11
-
12
- /**
13
- * @deprecated Provide the `directory` option instead. The project will be determined from the directory provided. It will be removed in Nx v20.
14
- */
15
- project?: string;
16
10
  }
@@ -7,24 +7,25 @@
7
7
  "type": "object",
8
8
  "examples": [
9
9
  {
10
- "command": "nx g migration my-migration --project=my-plugin --version=1.0.0",
11
- "description": "Adds a new migration to the project `my-plugin`, which will be triggered when migrating to version 1.0.0 or above from a previous version."
10
+ "command": "nx g migration my-plugin/my-migration --version=1.0.0",
11
+ "description": "Adds a new migration inside `my-plugin`, which will be triggered when migrating to version 1.0.0 or above from a previous version."
12
12
  }
13
13
  ],
14
14
  "properties": {
15
- "name": {
15
+ "path": {
16
16
  "type": "string",
17
- "description": "Migration name.",
17
+ "description": "Path where the migration will be generated.",
18
18
  "$default": {
19
19
  "$source": "argv",
20
20
  "index": 0
21
21
  },
22
+ "x-prompt": "Where should the migration be generated?",
22
23
  "x-priority": "important"
23
24
  },
24
- "directory": {
25
+ "name": {
25
26
  "type": "string",
26
- "description": "The directory at which to create the migration file. When `--nameAndDirectoryFormat=as-provided`, it will be relative to the current working directory. Otherwise, it will be relative to the workspace root.",
27
- "aliases": ["dir"]
27
+ "description": "Migration name.",
28
+ "x-priority": "important"
28
29
  },
29
30
  "description": {
30
31
  "type": "string",
@@ -37,15 +38,6 @@
37
38
  "x-prompt": "What version would you like to use for the migration?",
38
39
  "x-priority": "important"
39
40
  },
40
- "project": {
41
- "type": "string",
42
- "description": "The name of the project.",
43
- "alias": "p",
44
- "$default": {
45
- "$source": "projectName"
46
- },
47
- "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v20."
48
- },
49
41
  "packageJsonUpdates": {
50
42
  "type": "boolean",
51
43
  "description": "Whether or not to include `package.json` updates.",
@@ -56,13 +48,8 @@
56
48
  "type": "boolean",
57
49
  "default": false,
58
50
  "description": "Do not eslint configuration for plugin json files."
59
- },
60
- "nameAndDirectoryFormat": {
61
- "description": "Whether to generate the migration in the directory as provided, relative to the current working directory and ignoring the project (`as-provided`) or generate it using the project and directory relative to the workspace root (`derived`).",
62
- "type": "string",
63
- "enum": ["as-provided", "derived"]
64
51
  }
65
52
  },
66
- "required": ["packageVersion"],
53
+ "required": ["packageVersion", "path"],
67
54
  "additionalProperties": false
68
55
  }
@@ -1,5 +1,4 @@
1
1
  import { GeneratorCallback, Tree } from '@nx/devkit';
2
2
  import type { Schema } from './schema';
3
3
  export declare function pluginGenerator(host: Tree, schema: Schema): Promise<GeneratorCallback>;
4
- export declare function pluginGeneratorInternal(host: Tree, schema: Schema): Promise<GeneratorCallback>;
5
4
  export default pluginGenerator;
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.pluginGenerator = pluginGenerator;
4
- exports.pluginGeneratorInternal = pluginGeneratorInternal;
5
4
  const devkit_1 = require("@nx/devkit");
6
5
  const js_1 = require("@nx/js");
7
6
  const add_swc_dependencies_1 = require("@nx/js/src/utils/swc/add-swc-dependencies");
@@ -52,12 +51,6 @@ function updatePluginConfig(host, options) {
52
51
  }
53
52
  }
54
53
  async function pluginGenerator(host, schema) {
55
- return await pluginGeneratorInternal(host, {
56
- projectNameAndRootFormat: 'derived',
57
- ...schema,
58
- });
59
- }
60
- async function pluginGeneratorInternal(host, schema) {
61
54
  const options = await (0, normalize_schema_1.normalizeOptions)(host, schema);
62
55
  const tasks = [];
63
56
  tasks.push(await (0, js_1.libraryGenerator)(host, {
@@ -68,7 +61,6 @@ async function pluginGeneratorInternal(host, schema) {
68
61
  bundler: options.bundler,
69
62
  publishable: options.publishable,
70
63
  importPath: options.npmPackageName,
71
- projectNameAndRootFormat: 'as-provided',
72
64
  skipFormat: true,
73
65
  }));
74
66
  if (options.bundler === 'tsc') {
@@ -95,7 +87,6 @@ async function pluginGeneratorInternal(host, schema) {
95
87
  npmPackageName: options.npmPackageName,
96
88
  skipFormat: true,
97
89
  rootProject: options.rootProject,
98
- projectNameAndRootFormat: options.projectNameAndRootFormat,
99
90
  }));
100
91
  }
101
92
  if (options.linter === eslint_1.Linter.EsLint && !options.skipLintChecks) {
@@ -1,10 +1,8 @@
1
- import type { ProjectNameAndRootFormat } from '@nx/devkit/src/generators/project-name-and-root-utils';
2
1
  import type { Linter, LinterType } from '@nx/eslint';
3
2
 
4
3
  export interface Schema {
5
- name: string;
6
- directory?: string;
7
- projectNameAndRootFormat?: ProjectNameAndRootFormat;
4
+ directory: string;
5
+ name?: string;
8
6
  importPath?: string;
9
7
  skipTsConfig?: boolean; // default is false
10
8
  skipFormat?: boolean; // default is false
@@ -12,25 +12,19 @@
12
12
  }
13
13
  ],
14
14
  "properties": {
15
- "name": {
15
+ "directory": {
16
16
  "type": "string",
17
- "description": "Plugin name",
17
+ "description": "A directory where the plugin is placed.",
18
18
  "$default": {
19
19
  "$source": "argv",
20
20
  "index": 0
21
21
  },
22
- "x-prompt": "What name would you like to use for the plugin?",
23
- "x-priority": "important",
24
- "pattern": "(?:^@[a-zA-Z0-9-*~][a-zA-Z0-9-*._~]*\\/[a-zA-Z0-9-~][a-zA-Z0-9-._~]*|^[a-zA-Z][^:]*)$"
22
+ "x-prompt": "Which directory do you want to create the plugin in?"
25
23
  },
26
- "directory": {
27
- "type": "string",
28
- "description": "A directory where the plugin is placed."
29
- },
30
- "projectNameAndRootFormat": {
31
- "description": "Whether to generate the project name and root directory as provided (`as-provided`) or generate them composing their values and taking the configured layout into account (`derived`).",
24
+ "name": {
32
25
  "type": "string",
33
- "enum": ["as-provided", "derived"]
26
+ "description": "Plugin name",
27
+ "x-priority": "important"
34
28
  },
35
29
  "importPath": {
36
30
  "type": "string",
@@ -100,5 +94,5 @@
100
94
  "default": false
101
95
  }
102
96
  },
103
- "required": ["name"]
97
+ "required": ["directory"]
104
98
  }
@@ -1,31 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.normalizeOptions = normalizeOptions;
4
- const devkit_1 = require("@nx/devkit");
5
4
  const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
6
5
  async function normalizeOptions(host, options) {
7
- const { projectName, projectRoot, importPath: npmPackageName, projectNameAndRootFormat, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
6
+ await (0, project_name_and_root_utils_1.ensureProjectName)(host, options, 'application');
7
+ const { projectName, projectRoot, importPath: npmPackageName, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
8
8
  name: options.name,
9
9
  projectType: 'library',
10
10
  directory: options.directory,
11
11
  importPath: options.importPath,
12
- projectNameAndRootFormat: options.projectNameAndRootFormat,
13
12
  rootProject: options.rootProject,
14
- callingGenerator: '@nx/plugin:plugin',
15
13
  });
16
- options.projectNameAndRootFormat = projectNameAndRootFormat;
17
14
  options.rootProject = projectRoot === '.';
18
- let projectDirectory = projectRoot;
19
- if (options.projectNameAndRootFormat === 'derived') {
20
- let { layoutDirectory } = (0, devkit_1.extractLayoutDirectory)(options.directory);
21
- if (!layoutDirectory) {
22
- const { libsDir } = (0, devkit_1.getWorkspaceLayout)(host);
23
- layoutDirectory = libsDir;
24
- }
25
- if (projectRoot.startsWith(`${layoutDirectory}/`)) {
26
- projectDirectory = projectRoot.replace(`${layoutDirectory}/`, '');
27
- }
28
- }
15
+ const projectDirectory = projectRoot;
29
16
  const parsedTags = options.tags
30
17
  ? options.tags.split(',').map((s) => s.trim())
31
18
  : [];
@@ -17,7 +17,6 @@ async function default_1(tree, options) {
17
17
  const pluginTask = await (0, plugin_1.pluginGenerator)(tree, {
18
18
  compiler: 'tsc',
19
19
  linter: eslint_1.Linter.EsLint,
20
- name: pluginProjectName,
21
20
  skipFormat: true,
22
21
  unitTestRunner: 'jest',
23
22
  importPath: options.pluginName,
@@ -25,8 +24,8 @@ async function default_1(tree, options) {
25
24
  publishable: true,
26
25
  // when creating a CLI package, the plugin will be in the packages folder
27
26
  directory: options.createPackageName && options.createPackageName !== 'false'
28
- ? 'packages'
29
- : undefined,
27
+ ? `packages/${pluginProjectName}`
28
+ : pluginProjectName,
30
29
  rootProject: options.createPackageName ? false : true,
31
30
  });
32
31
  tasks.push(pluginTask);
@@ -34,7 +33,7 @@ async function default_1(tree, options) {
34
33
  if (options.createPackageName) {
35
34
  const e2eProject = `${options.pluginName}-e2e`;
36
35
  const cliTask = await (0, create_package_1.default)(tree, {
37
- directory: 'packages',
36
+ directory: `packages/${options.createPackageName}`,
38
37
  name: options.createPackageName,
39
38
  e2eProject: e2eProject,
40
39
  project: options.pluginName,
@@ -19,6 +19,7 @@ function runCommandAsync(command, opts = {
19
19
  (0, child_process_1.exec)(command, {
20
20
  cwd: opts.cwd ?? (0, paths_1.tmpProjPath)(),
21
21
  env: { ...process.env, ...opts.env },
22
+ windowsHide: true,
22
23
  }, (err, stdout, stderr) => {
23
24
  if (!opts.silenceError && err) {
24
25
  reject(err);
@@ -21,6 +21,7 @@ function runNxCommand(command, opts = {
21
21
  const execSyncOptions = {
22
22
  cwd,
23
23
  env: { ...process.env, ...opts.env },
24
+ windowsHide: true,
24
25
  };
25
26
  if ((0, utils_1.fileExists)((0, paths_1.tmpProjPath)('package.json'))) {
26
27
  const pmc = (0, devkit_1.getPackageManagerCommand)((0, devkit_1.detectPackageManager)(cwd));
@@ -8,8 +8,8 @@ exports.ensureNxProject = ensureNxProject;
8
8
  const devkit_1 = require("@nx/devkit");
9
9
  const devkit_2 = require("@nx/devkit");
10
10
  const child_process_1 = require("child_process");
11
+ const node_fs_1 = require("node:fs");
11
12
  const path_1 = require("path");
12
- const fs_extra_1 = require("fs-extra");
13
13
  const paths_1 = require("./paths");
14
14
  const utils_1 = require("./utils");
15
15
  function runNxNewCommand(args, silent) {
@@ -17,6 +17,7 @@ function runNxNewCommand(args, silent) {
17
17
  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 || ''}`, {
18
18
  cwd: localTmpDir,
19
19
  ...(silent && false ? { stdio: ['ignore', 'ignore', 'ignore'] } : {}),
20
+ windowsHide: true,
20
21
  });
21
22
  }
22
23
  function patchPackageJsonForPlugin(npmPackageName, distPath) {
@@ -44,6 +45,7 @@ function runPackageManagerInstall(silent = true) {
44
45
  const install = (0, child_process_1.execSync)(pmc.install, {
45
46
  cwd,
46
47
  ...(silent ? { stdio: ['ignore', 'ignore', 'ignore'] } : {}),
48
+ windowsHide: true,
47
49
  });
48
50
  return install ? install.toString() : '';
49
51
  }
@@ -64,6 +66,6 @@ function newNxProject(npmPackageName, pluginDistPath) {
64
66
  * It will also copy `@nx` packages to the e2e directory
65
67
  */
66
68
  function ensureNxProject(npmPackageName, pluginDistPath) {
67
- (0, fs_extra_1.ensureDirSync)((0, paths_1.tmpProjPath)());
69
+ (0, node_fs_1.mkdirSync)((0, paths_1.tmpProjPath)(), { recursive: true });
68
70
  newNxProject(npmPackageName, pluginDistPath);
69
71
  }
@@ -15,7 +15,7 @@ exports.removeTmpProject = removeTmpProject;
15
15
  exports.getCwd = getCwd;
16
16
  exports.exists = exists;
17
17
  exports.getSize = getSize;
18
- const fs_extra_1 = require("fs-extra");
18
+ const node_fs_1 = require("node:fs");
19
19
  const path_1 = require("path");
20
20
  const paths_1 = require("./paths");
21
21
  const devkit_1 = require("@nx/devkit");
@@ -28,8 +28,11 @@ Object.defineProperty(exports, "fileExists", { enumerable: true, get: function (
28
28
  */
29
29
  function copyNodeModules(modules) {
30
30
  modules.forEach((module) => {
31
- (0, fs_extra_1.removeSync)(`${(0, paths_1.tmpProjPath)()}/node_modules/${module}`);
32
- (0, fs_extra_1.copySync)(`./node_modules/${module}`, `${(0, paths_1.tmpProjPath)()}/node_modules/${module}`);
31
+ (0, node_fs_1.rmSync)(`${(0, paths_1.tmpProjPath)()}/node_modules/${module}`, {
32
+ recursive: true,
33
+ force: true,
34
+ });
35
+ (0, node_fs_1.cpSync)(`./node_modules/${module}`, `${(0, paths_1.tmpProjPath)()}/node_modules/${module}`, { recursive: true });
33
36
  });
34
37
  }
35
38
  /**
@@ -51,12 +54,12 @@ function expectTestsPass(output) {
51
54
  * @param content Content to replace the original content with
52
55
  */
53
56
  function updateFile(file, content) {
54
- (0, fs_extra_1.ensureDirSync)((0, path_1.dirname)((0, paths_1.tmpProjPath)(file)));
57
+ (0, node_fs_1.mkdirSync)((0, path_1.dirname)((0, paths_1.tmpProjPath)(file)), { recursive: true });
55
58
  if (typeof content === 'string') {
56
- (0, fs_extra_1.writeFileSync)((0, paths_1.tmpProjPath)(file), content);
59
+ (0, node_fs_1.writeFileSync)((0, paths_1.tmpProjPath)(file), content);
57
60
  }
58
61
  else {
59
- (0, fs_extra_1.writeFileSync)((0, paths_1.tmpProjPath)(file), content((0, fs_extra_1.readFileSync)((0, paths_1.tmpProjPath)(file)).toString()));
62
+ (0, node_fs_1.writeFileSync)((0, paths_1.tmpProjPath)(file), content((0, node_fs_1.readFileSync)((0, paths_1.tmpProjPath)(file)).toString()));
60
63
  }
61
64
  }
62
65
  /**
@@ -65,8 +68,8 @@ function updateFile(file, content) {
65
68
  * @param newPath New path
66
69
  */
67
70
  function renameFile(path, newPath) {
68
- (0, fs_extra_1.ensureDirSync)((0, path_1.dirname)((0, paths_1.tmpProjPath)(newPath)));
69
- (0, fs_extra_1.renameSync)((0, paths_1.tmpProjPath)(path), (0, paths_1.tmpProjPath)(newPath));
71
+ (0, node_fs_1.mkdirSync)((0, path_1.dirname)((0, paths_1.tmpProjPath)(newPath)), { recursive: true });
72
+ (0, node_fs_1.renameSync)((0, paths_1.tmpProjPath)(path), (0, paths_1.tmpProjPath)(newPath));
70
73
  }
71
74
  /**
72
75
  * Check if the file or directory exists.
@@ -89,7 +92,7 @@ function checkFilesExist(...expectedPaths) {
89
92
  * @param dirName Directory name within the e2e directory.
90
93
  */
91
94
  function listFiles(dirName) {
92
- return (0, fs_extra_1.readdirSync)((0, paths_1.tmpProjPath)(dirName));
95
+ return (0, node_fs_1.readdirSync)((0, paths_1.tmpProjPath)(dirName));
93
96
  }
94
97
  /**
95
98
  * Read a JSON file.
@@ -105,22 +108,22 @@ function readJson(path, options) {
105
108
  */
106
109
  function readFile(path) {
107
110
  const filePath = (0, path_1.isAbsolute)(path) ? path : (0, paths_1.tmpProjPath)(path);
108
- return (0, fs_extra_1.readFileSync)(filePath, 'utf-8');
111
+ return (0, node_fs_1.readFileSync)(filePath, 'utf-8');
109
112
  }
110
113
  /**
111
114
  * Deletes the e2e directory
112
115
  */
113
116
  function cleanup() {
114
- (0, fs_extra_1.removeSync)((0, paths_1.tmpProjPath)());
117
+ (0, node_fs_1.rmSync)((0, paths_1.tmpProjPath)(), { recursive: true, force: true });
115
118
  }
116
119
  /**
117
120
  * Remove the dist folder from the e2e directory
118
121
  */
119
122
  function rmDist() {
120
- (0, fs_extra_1.removeSync)(`${(0, paths_1.tmpProjPath)()}/dist`);
123
+ (0, node_fs_1.rmSync)(`${(0, paths_1.tmpProjPath)()}/dist`, { recursive: true, force: true });
121
124
  }
122
125
  function removeTmpProject(project) {
123
- (0, fs_extra_1.removeSync)(`${(0, paths_1.tmpFolder)()}/${project}`);
126
+ (0, node_fs_1.rmSync)(`${(0, paths_1.tmpFolder)()}/${project}`, { recursive: true, force: true });
124
127
  }
125
128
  /**
126
129
  * Get the currend `cwd` in the process
@@ -140,5 +143,5 @@ function exists(path) {
140
143
  * @param filePath Path to the file
141
144
  */
142
145
  function getSize(filePath) {
143
- return (0, fs_extra_1.statSync)(filePath).size;
146
+ return (0, node_fs_1.statSync)(filePath).size;
144
147
  }