@nx/node 0.0.0-pr-30111-5026d75 → 0.0.0-pr-30250-ec5f231

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/node",
3
- "version": "0.0.0-pr-30111-5026d75",
3
+ "version": "0.0.0-pr-30250-ec5f231",
4
4
  "private": false,
5
5
  "description": "The Node Plugin for Nx contains generators to manage Node applications within an Nx workspace.",
6
6
  "repository": {
@@ -32,10 +32,10 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "tslib": "^2.3.0",
35
- "@nx/devkit": "0.0.0-pr-30111-5026d75",
36
- "@nx/jest": "0.0.0-pr-30111-5026d75",
37
- "@nx/js": "0.0.0-pr-30111-5026d75",
38
- "@nx/eslint": "0.0.0-pr-30111-5026d75"
35
+ "@nx/devkit": "0.0.0-pr-30250-ec5f231",
36
+ "@nx/jest": "0.0.0-pr-30250-ec5f231",
37
+ "@nx/js": "0.0.0-pr-30250-ec5f231",
38
+ "@nx/eslint": "0.0.0-pr-30250-ec5f231"
39
39
  },
40
40
  "publishConfig": {
41
41
  "access": "public"
@@ -1,10 +1,9 @@
1
1
  import { GeneratorCallback, Tree } from '@nx/devkit';
2
2
  import { Schema } from './schema';
3
- export interface NormalizedSchema extends Omit<Schema, 'useTsSolution'> {
3
+ export interface NormalizedSchema extends Schema {
4
4
  appProjectRoot: string;
5
5
  parsedTags: string[];
6
6
  outputPath: string;
7
- importPath: string;
8
7
  isUsingTsSolutionConfig: boolean;
9
8
  }
10
9
  export declare function addLintingToApplication(tree: Tree, options: NormalizedSchema): Promise<GeneratorCallback>;
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addLintingToApplication = addLintingToApplication;
4
4
  exports.applicationGenerator = applicationGenerator;
5
5
  exports.applicationGeneratorInternal = applicationGeneratorInternal;
6
+ const get_import_path_1 = require("@nx/js/src/utils/get-import-path");
6
7
  const devkit_1 = require("@nx/devkit");
7
8
  const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
8
9
  const jest_1 = require("@nx/jest");
@@ -139,11 +140,13 @@ function addProject(tree, options) {
139
140
  project.targets.serve = getServeConfig(options);
140
141
  if (options.isUsingTsSolutionConfig) {
141
142
  (0, devkit_1.writeJson)(tree, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'package.json'), {
142
- name: options.importPath,
143
+ name: (0, get_import_path_1.getImportPath)(tree, options.name),
143
144
  version: '0.0.1',
144
145
  private: true,
145
146
  nx: {
146
- name: options.name !== options.importPath ? options.name : undefined,
147
+ name: options.name,
148
+ projectType: 'application',
149
+ sourceRoot: project.sourceRoot,
147
150
  targets: project.targets,
148
151
  tags: project.tags?.length ? project.tags : undefined,
149
152
  },
@@ -371,11 +374,6 @@ async function applicationGeneratorInternal(tree, schema) {
371
374
  }
372
375
  addAppFiles(tree, options);
373
376
  addProject(tree, options);
374
- // If we are using the new TS solution
375
- // We need to update the workspace file (package.json or pnpm-workspaces.yaml) to include the new project
376
- if (options.isUsingTsSolutionConfig) {
377
- (0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(tree, options.appProjectRoot);
378
- }
379
377
  updateTsConfigOptions(tree, options);
380
378
  if (options.linter === eslint_1.Linter.EsLint) {
381
379
  const lintTask = await addLintingToApplication(tree, options);
@@ -440,6 +438,11 @@ async function applicationGeneratorInternal(tree, schema) {
440
438
  ? ['eslint.config.js', 'eslint.config.cjs', 'eslint.config.mjs']
441
439
  : undefined);
442
440
  }
441
+ // If we are using the new TS solution
442
+ // We need to update the workspace file (package.json or pnpm-workspaces.yaml) to include the new project
443
+ if (options.isUsingTsSolutionConfig) {
444
+ (0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(tree, options.appProjectRoot);
445
+ }
443
446
  (0, sort_fields_1.sortPackageJsonFields)(tree, options.appProjectRoot);
444
447
  if (!options.skipFormat) {
445
448
  await (0, devkit_1.formatFiles)(tree);
@@ -450,8 +453,8 @@ async function applicationGeneratorInternal(tree, schema) {
450
453
  return (0, devkit_1.runTasksInSerial)(...tasks);
451
454
  }
452
455
  async function normalizeOptions(host, options) {
453
- await (0, project_name_and_root_utils_1.ensureRootProjectName)(options, 'application');
454
- const { projectName, projectRoot: appProjectRoot, importPath, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
456
+ await (0, project_name_and_root_utils_1.ensureProjectName)(host, options, 'application');
457
+ const { projectName: appProjectName, projectRoot: appProjectRoot } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
455
458
  name: options.name,
456
459
  projectType: 'application',
457
460
  directory: options.directory,
@@ -468,7 +471,6 @@ async function normalizeOptions(host, options) {
468
471
  nxJson.useInferencePlugins !== false;
469
472
  const isUsingTsSolutionConfig = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host);
470
473
  const swcJest = options.swcJest ?? isUsingTsSolutionConfig;
471
- const appProjectName = !isUsingTsSolutionConfig || options.name ? projectName : importPath;
472
474
  return {
473
475
  addPlugin,
474
476
  ...options,
@@ -477,7 +479,6 @@ async function normalizeOptions(host, options) {
477
479
  ? (0, devkit_1.names)(options.frontendProject).fileName
478
480
  : undefined,
479
481
  appProjectRoot,
480
- importPath,
481
482
  parsedTags,
482
483
  linter: options.linter ?? eslint_1.Linter.EsLint,
483
484
  unitTestRunner: options.unitTestRunner ?? 'jest',
@@ -485,7 +486,7 @@ async function normalizeOptions(host, options) {
485
486
  port: options.port ?? 3000,
486
487
  outputPath: isUsingTsSolutionConfig
487
488
  ? (0, devkit_1.joinPathFragments)(appProjectRoot, 'dist')
488
- : (0, devkit_1.joinPathFragments)('dist', options.rootProject ? appProjectName : appProjectRoot),
489
+ : (0, devkit_1.joinPathFragments)('dist', options.rootProject ? options.name : appProjectRoot),
489
490
  isUsingTsSolutionConfig,
490
491
  swcJest,
491
492
  };
@@ -12,6 +12,7 @@ const eslint_file_1 = require("@nx/eslint/src/generators/utils/eslint-file");
12
12
  const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-project-command");
13
13
  const config_file_1 = require("@nx/jest/src/utils/config/config-file");
14
14
  const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
15
+ const get_import_path_1 = require("@nx/js/src/utils/get-import-path");
15
16
  const posix_1 = require("node:path/posix");
16
17
  const add_swc_config_1 = require("@nx/js/src/utils/swc/add-swc-config");
17
18
  async function e2eProjectGenerator(host, options) {
@@ -28,18 +29,17 @@ async function e2eProjectGeneratorInternal(host, _options) {
28
29
  // TODO(@ndcunningham): This is broken.. the outputs are wrong.. and this isn't using the jest generator
29
30
  if (isUsingTsSolutionConfig) {
30
31
  (0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'package.json'), {
31
- name: options.importPath,
32
+ name: (0, get_import_path_1.getImportPath)(host, options.e2eProjectName),
32
33
  version: '0.0.1',
33
34
  private: true,
34
35
  nx: {
35
- name: options.e2eProjectName !== options.importPath
36
- ? options.e2eProjectName
37
- : undefined,
36
+ name: options.e2eProjectName,
37
+ projectType: 'application',
38
38
  implicitDependencies: [options.project],
39
39
  targets: {
40
40
  e2e: {
41
41
  executor: '@nx/jest:jest',
42
- outputs: ['{projectRoot}/test-output/jest/coverage'],
42
+ outputs: ['{workspaceRoot}/coverage/{e2eProjectRoot}'],
43
43
  options: {
44
44
  jestConfig: `${options.e2eProjectRoot}/jest.config.ts`,
45
45
  passWithNoTests: true,
@@ -101,11 +101,10 @@ async function e2eProjectGeneratorInternal(host, _options) {
101
101
  const coverageDirectory = isUsingTsSolutionConfig
102
102
  ? 'test-output/jest/coverage'
103
103
  : (0, devkit_1.joinPathFragments)(rootOffset, 'coverage', options.e2eProjectName);
104
- const projectSimpleName = options.project.split('/').pop();
105
104
  if (options.projectType === 'server') {
106
105
  (0, devkit_1.generateFiles)(host, path.join(__dirname, 'files/server/common'), options.e2eProjectRoot, {
107
106
  ...options,
108
- ...(0, devkit_1.names)(options.rootProject ? 'server' : projectSimpleName),
107
+ ...(0, devkit_1.names)(options.rootProject ? 'server' : options.project),
109
108
  tsConfigFile,
110
109
  offsetFromRoot: rootOffset,
111
110
  jestPreset,
@@ -116,7 +115,7 @@ async function e2eProjectGeneratorInternal(host, _options) {
116
115
  if (options.isNest) {
117
116
  (0, devkit_1.generateFiles)(host, path.join(__dirname, 'files/server/nest'), options.e2eProjectRoot, {
118
117
  ...options,
119
- ...(0, devkit_1.names)(options.rootProject ? 'server' : projectSimpleName),
118
+ ...(0, devkit_1.names)(options.rootProject ? 'server' : options.project),
120
119
  tsConfigFile,
121
120
  offsetFromRoot: rootOffset,
122
121
  tmpl: '',
@@ -127,7 +126,7 @@ async function e2eProjectGeneratorInternal(host, _options) {
127
126
  const mainFile = appProject.targets.build?.options?.outputPath;
128
127
  (0, devkit_1.generateFiles)(host, path.join(__dirname, 'files/cli'), options.e2eProjectRoot, {
129
128
  ...options,
130
- ...(0, devkit_1.names)(options.rootProject ? 'cli' : projectSimpleName),
129
+ ...(0, devkit_1.names)(options.rootProject ? 'cli' : options.project),
131
130
  mainFile,
132
131
  tsConfigFile,
133
132
  offsetFromRoot: rootOffset,
@@ -202,15 +201,11 @@ async function e2eProjectGeneratorInternal(host, _options) {
202
201
  return (0, devkit_1.runTasksInSerial)(...tasks);
203
202
  }
204
203
  async function normalizeOptions(tree, options) {
205
- let directory = options.rootProject ? 'e2e' : options.directory;
206
- if (!directory) {
207
- const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
208
- directory = `${projectConfig.root}-e2e`;
209
- }
210
- const { projectName: e2eProjectName, projectRoot: e2eProjectRoot, importPath, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(tree, {
204
+ options.directory = options.directory ?? `${options.project}-e2e`;
205
+ const { projectName: e2eProjectName, projectRoot: e2eProjectRoot } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(tree, {
211
206
  name: options.name,
212
- projectType: 'application',
213
- directory,
207
+ projectType: 'library',
208
+ directory: options.rootProject ? 'e2e' : options.directory,
214
209
  });
215
210
  const nxJson = (0, devkit_1.readNxJson)(tree);
216
211
  const addPlugin = process.env.NX_ADD_PLUGINS !== 'false' &&
@@ -220,7 +215,6 @@ async function normalizeOptions(tree, options) {
220
215
  ...options,
221
216
  e2eProjectRoot,
222
217
  e2eProjectName,
223
- importPath,
224
218
  port: options.port ?? 3000,
225
219
  rootProject: !!options.rootProject,
226
220
  };
@@ -12,6 +12,7 @@ const versions_1 = require("../../utils/versions");
12
12
  const init_1 = require("../init/init");
13
13
  const target_defaults_utils_1 = require("@nx/devkit/src/generators/target-defaults-utils");
14
14
  const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
15
+ const get_import_path_1 = require("@nx/js/src/utils/get-import-path");
15
16
  const sort_fields_1 = require("@nx/js/src/utils/package-json/sort-fields");
16
17
  async function libraryGenerator(tree, schema) {
17
18
  return await libraryGeneratorInternal(tree, {
@@ -35,7 +36,7 @@ async function libraryGeneratorInternal(tree, schema) {
35
36
  options.publishable ||
36
37
  options.buildable) {
37
38
  (0, devkit_1.writeJson)(tree, (0, devkit_1.joinPathFragments)(options.projectRoot, 'package.json'), {
38
- name: options.importPath,
39
+ name: (0, get_import_path_1.getImportPath)(tree, options.name),
39
40
  version: '0.0.1',
40
41
  private: true,
41
42
  files: options.publishable ? ['dist', '!**/*.tsbuildinfo'] : undefined,
@@ -74,7 +75,7 @@ async function libraryGeneratorInternal(tree, schema) {
74
75
  }
75
76
  exports.default = libraryGenerator;
76
77
  async function normalizeOptions(tree, options) {
77
- await (0, project_name_and_root_utils_1.ensureRootProjectName)(options, 'library');
78
+ await (0, project_name_and_root_utils_1.ensureProjectName)(tree, options, 'library');
78
79
  const { projectName, names: projectNames, projectRoot, importPath, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(tree, {
79
80
  name: options.name,
80
81
  projectType: 'library',
@@ -95,7 +96,9 @@ async function normalizeOptions(tree, options) {
95
96
  return {
96
97
  ...options,
97
98
  fileName,
98
- projectName: isUsingTsSolutionConfig && !options.name ? importPath : projectName,
99
+ projectName: isUsingTsSolutionConfig
100
+ ? (0, get_import_path_1.getImportPath)(tree, projectName)
101
+ : projectName,
99
102
  projectRoot,
100
103
  parsedTags,
101
104
  importPath,