@nx/plugin 20.4.0-beta.1 → 20.4.0-beta.2

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": "20.4.0-beta.1",
3
+ "version": "20.4.0-beta.2",
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,10 +28,10 @@
28
28
  },
29
29
  "dependencies": {
30
30
  "tslib": "^2.3.0",
31
- "@nx/devkit": "20.4.0-beta.1",
32
- "@nx/jest": "20.4.0-beta.1",
33
- "@nx/js": "20.4.0-beta.1",
34
- "@nx/eslint": "20.4.0-beta.1"
31
+ "@nx/devkit": "20.4.0-beta.2",
32
+ "@nx/jest": "20.4.0-beta.2",
33
+ "@nx/js": "20.4.0-beta.2",
34
+ "@nx/eslint": "20.4.0-beta.2"
35
35
  },
36
36
  "publishConfig": {
37
37
  "access": "public"
@@ -88,6 +88,7 @@ async function addJest(host, options) {
88
88
  skipSerializers: true,
89
89
  skipFormat: true,
90
90
  addPlugin: options.addPlugin,
91
+ compiler: options.isTsSolutionSetup ? 'swc' : undefined,
91
92
  });
92
93
  const { startLocalRegistryPath, stopLocalRegistryPath } = (0, add_local_registry_scripts_1.addLocalRegistryScripts)(host);
93
94
  (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));
@@ -109,7 +109,7 @@ async function normalizeOptions(tree, options) {
109
109
  propertyName,
110
110
  description,
111
111
  projectRoot,
112
- projectSourceRoot,
112
+ projectSourceRoot: projectSourceRoot ?? (0, path_1.join)(projectRoot, 'src'),
113
113
  isTsSolutionSetup: (0, ts_solution_setup_1.isUsingTsSolutionSetup)(tree),
114
114
  };
115
115
  }
@@ -36,7 +36,7 @@ async function normalizeOptions(tree, options) {
36
36
  propertyName,
37
37
  description,
38
38
  projectRoot,
39
- projectSourceRoot,
39
+ projectSourceRoot: projectSourceRoot ?? (0, node_path_1.join)(projectRoot, 'src'),
40
40
  isTsSolutionSetup: (0, ts_solution_setup_1.isUsingTsSolutionSetup)(tree),
41
41
  };
42
42
  }
@@ -26,7 +26,7 @@ async function normalizeOptions(tree, options) {
26
26
  name,
27
27
  description,
28
28
  projectRoot,
29
- projectSourceRoot,
29
+ projectSourceRoot: projectSourceRoot ?? (0, node_path_1.join)(projectRoot, 'src'),
30
30
  isTsSolutionSetup: (0, ts_solution_setup_1.isUsingTsSolutionSetup)(tree),
31
31
  };
32
32
  return normalized;
@@ -20,10 +20,11 @@ async function addFiles(host, options) {
20
20
  });
21
21
  }
22
22
  function updatePluginConfig(host, options) {
23
- const project = (0, devkit_1.readProjectConfiguration)(host, options.name);
23
+ const project = (0, devkit_1.readProjectConfiguration)(host, options.projectName);
24
24
  if (project.targets.build) {
25
25
  if (options.isTsSolutionSetup && options.bundler === 'tsc') {
26
- project.targets.build.options.rootDir = project.sourceRoot;
26
+ project.targets.build.options.rootDir =
27
+ project.sourceRoot ?? (0, devkit_1.joinPathFragments)(project.root, 'src');
27
28
  project.targets.build.options.generatePackageJson = false;
28
29
  }
29
30
  project.targets.build.options.assets = [
@@ -36,7 +37,7 @@ function updatePluginConfig(host, options) {
36
37
  else {
37
38
  project.targets.build.options.assets.push({ input: `${root}/src`, glob: '**/!(*.ts)', output: './src' }, { input: `${root}/src`, glob: '**/*.d.ts', output: './src' }, { input: root, glob: 'generators.json', output: '.' }, { input: root, glob: 'executors.json', output: '.' });
38
39
  }
39
- (0, devkit_1.updateProjectConfiguration)(host, options.name, project);
40
+ (0, devkit_1.updateProjectConfiguration)(host, options.projectName, project);
40
41
  }
41
42
  }
42
43
  async function pluginGenerator(tree, schema) {
@@ -64,6 +65,12 @@ async function pluginGeneratorInternal(host, schema) {
64
65
  skipFormat: true,
65
66
  useTscExecutor: true,
66
67
  }));
68
+ if (options.isTsSolutionSetup) {
69
+ (0, devkit_1.updateJson)(host, (0, devkit_1.joinPathFragments)(options.projectRoot, 'package.json'), (json) => {
70
+ delete json.type;
71
+ return json;
72
+ });
73
+ }
67
74
  if (options.bundler === 'tsc') {
68
75
  tasks.push((0, add_tslib_dependencies_1.addTsLibDependencies)(host));
69
76
  }
@@ -82,7 +89,7 @@ async function pluginGeneratorInternal(host, schema) {
82
89
  updatePluginConfig(host, options);
83
90
  if (options.e2eTestRunner !== 'none') {
84
91
  tasks.push(await (0, e2e_1.e2eProjectGenerator)(host, {
85
- pluginName: options.name,
92
+ pluginName: options.projectName,
86
93
  projectDirectory: options.projectDirectory,
87
94
  pluginOutputPath: (0, devkit_1.joinPathFragments)('dist', options.rootProject ? options.name : options.projectRoot),
88
95
  npmPackageName: options.npmPackageName,
@@ -94,7 +101,7 @@ async function pluginGeneratorInternal(host, schema) {
94
101
  }));
95
102
  }
96
103
  if (options.linter === eslint_1.Linter.EsLint && !options.skipLintChecks) {
97
- await (0, generator_1.default)(host, { projectName: options.name });
104
+ await (0, generator_1.default)(host, { projectName: options.projectName });
98
105
  }
99
106
  if (!options.skipFormat) {
100
107
  await (0, devkit_1.formatFiles)(host);
@@ -3,6 +3,7 @@ import type { LinterType } from '@nx/eslint';
3
3
  import type { Schema } from '../schema';
4
4
  export interface NormalizedSchema extends Schema {
5
5
  name: string;
6
+ projectName: string;
6
7
  fileName: string;
7
8
  projectRoot: string;
8
9
  projectDirectory: string;
@@ -5,6 +5,7 @@ const devkit_1 = require("@nx/devkit");
5
5
  const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
6
6
  const generator_prompts_1 = require("@nx/js/src/utils/generator-prompts");
7
7
  const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
8
+ const get_import_path_1 = require("@nx/js/src/utils/get-import-path");
8
9
  async function normalizeOptions(host, options) {
9
10
  const linter = await (0, generator_prompts_1.normalizeLinterOption)(host, options.linter);
10
11
  const unitTestRunner = await (0, generator_prompts_1.normalizeUnitTestRunnerOption)(host, options.unitTestRunner, ['jest', 'vitest']);
@@ -32,6 +33,9 @@ async function normalizeOptions(host, options) {
32
33
  bundler: options.compiler ?? 'tsc',
33
34
  fileName: projectName,
34
35
  name: projectName,
36
+ projectName: isTsSolutionSetup
37
+ ? (0, get_import_path_1.getImportPath)(host, projectName)
38
+ : projectName,
35
39
  projectRoot,
36
40
  projectDirectory,
37
41
  parsedTags,