@nx/node 0.0.0-pr-29993-f89d4dd → 0.0.0-pr-3-e51e28c

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-29993-f89d4dd",
3
+ "version": "0.0.0-pr-3-e51e28c",
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-29993-f89d4dd",
36
- "@nx/jest": "0.0.0-pr-29993-f89d4dd",
37
- "@nx/js": "0.0.0-pr-29993-f89d4dd",
38
- "@nx/eslint": "0.0.0-pr-29993-f89d4dd"
35
+ "@nx/devkit": "0.0.0-pr-3-e51e28c",
36
+ "@nx/jest": "0.0.0-pr-3-e51e28c",
37
+ "@nx/js": "0.0.0-pr-3-e51e28c",
38
+ "@nx/eslint": "0.0.0-pr-3-e51e28c"
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");
@@ -140,11 +141,13 @@ function addProject(tree, options) {
140
141
  project.targets.serve = getServeConfig(options);
141
142
  if (options.isUsingTsSolutionConfig) {
142
143
  (0, devkit_1.writeJson)(tree, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'package.json'), {
143
- name: options.importPath,
144
+ name: (0, get_import_path_1.getImportPath)(tree, options.name),
144
145
  version: '0.0.1',
145
146
  private: true,
146
147
  nx: {
147
- name: options.name !== options.importPath ? options.name : undefined,
148
+ name: options.name,
149
+ projectType: 'application',
150
+ sourceRoot: project.sourceRoot,
148
151
  targets: project.targets,
149
152
  tags: project.tags?.length ? project.tags : undefined,
150
153
  },
@@ -378,11 +381,6 @@ async function applicationGeneratorInternal(tree, schema) {
378
381
  }
379
382
  addAppFiles(tree, options);
380
383
  addProject(tree, options);
381
- // If we are using the new TS solution
382
- // We need to update the workspace file (package.json or pnpm-workspaces.yaml) to include the new project
383
- if (options.isUsingTsSolutionConfig) {
384
- (0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(tree, options.appProjectRoot);
385
- }
386
384
  updateTsConfigOptions(tree, options);
387
385
  if (options.linter === eslint_1.Linter.EsLint) {
388
386
  const lintTask = await addLintingToApplication(tree, options);
@@ -447,6 +445,11 @@ async function applicationGeneratorInternal(tree, schema) {
447
445
  ? ['eslint.config.js', 'eslint.config.cjs', 'eslint.config.mjs']
448
446
  : undefined);
449
447
  }
448
+ // If we are using the new TS solution
449
+ // We need to update the workspace file (package.json or pnpm-workspaces.yaml) to include the new project
450
+ if (options.isUsingTsSolutionConfig) {
451
+ (0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(tree, options.appProjectRoot);
452
+ }
450
453
  (0, sort_fields_1.sortPackageJsonFields)(tree, options.appProjectRoot);
451
454
  if (!options.skipFormat) {
452
455
  await (0, devkit_1.formatFiles)(tree);
@@ -457,8 +460,8 @@ async function applicationGeneratorInternal(tree, schema) {
457
460
  return (0, devkit_1.runTasksInSerial)(...tasks);
458
461
  }
459
462
  async function normalizeOptions(host, options) {
460
- await (0, project_name_and_root_utils_1.ensureRootProjectName)(options, 'application');
461
- const { projectName, projectRoot: appProjectRoot, importPath, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
463
+ await (0, project_name_and_root_utils_1.ensureProjectName)(host, options, 'application');
464
+ const { projectName: appProjectName, projectRoot: appProjectRoot } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
462
465
  name: options.name,
463
466
  projectType: 'application',
464
467
  directory: options.directory,
@@ -475,7 +478,6 @@ async function normalizeOptions(host, options) {
475
478
  nxJson.useInferencePlugins !== false;
476
479
  const isUsingTsSolutionConfig = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host);
477
480
  const swcJest = options.swcJest ?? isUsingTsSolutionConfig;
478
- const appProjectName = !isUsingTsSolutionConfig || options.name ? projectName : importPath;
479
481
  return {
480
482
  addPlugin,
481
483
  ...options,
@@ -484,7 +486,6 @@ async function normalizeOptions(host, options) {
484
486
  ? (0, devkit_1.names)(options.frontendProject).fileName
485
487
  : undefined,
486
488
  appProjectRoot,
487
- importPath,
488
489
  parsedTags,
489
490
  linter: options.linter ?? eslint_1.Linter.EsLint,
490
491
  unitTestRunner: options.unitTestRunner ?? 'jest',
@@ -492,7 +493,7 @@ async function normalizeOptions(host, options) {
492
493
  port: options.port ?? 3000,
493
494
  outputPath: isUsingTsSolutionConfig
494
495
  ? (0, devkit_1.joinPathFragments)(appProjectRoot, 'dist')
495
- : (0, devkit_1.joinPathFragments)('dist', options.rootProject ? appProjectName : appProjectRoot),
496
+ : (0, devkit_1.joinPathFragments)('dist', options.rootProject ? options.name : appProjectRoot),
496
497
  isUsingTsSolutionConfig,
497
498
  swcJest,
498
499
  };
@@ -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,