@nx/node 0.0.0-pr-11-e92ae29 → 0.0.0-pr-29464-ce29f31

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-11-e92ae29",
3
+ "version": "0.0.0-pr-29464-ce29f31",
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-11-e92ae29",
36
- "@nx/jest": "0.0.0-pr-11-e92ae29",
37
- "@nx/js": "0.0.0-pr-11-e92ae29",
38
- "@nx/eslint": "0.0.0-pr-11-e92ae29"
35
+ "@nx/devkit": "0.0.0-pr-29464-ce29f31",
36
+ "@nx/jest": "0.0.0-pr-29464-ce29f31",
37
+ "@nx/js": "0.0.0-pr-29464-ce29f31",
38
+ "@nx/eslint": "0.0.0-pr-29464-ce29f31"
39
39
  },
40
40
  "publishConfig": {
41
41
  "access": "public"
@@ -1,9 +1,10 @@
1
1
  import { GeneratorCallback, Tree } from '@nx/devkit';
2
2
  import { Schema } from './schema';
3
- export interface NormalizedSchema extends Schema {
3
+ export interface NormalizedSchema extends Omit<Schema, 'useTsSolution'> {
4
4
  appProjectRoot: string;
5
5
  parsedTags: string[];
6
6
  outputPath: string;
7
+ importPath: string;
7
8
  isUsingTsSolutionConfig: boolean;
8
9
  }
9
10
  export declare function addLintingToApplication(tree: Tree, options: NormalizedSchema): Promise<GeneratorCallback>;
@@ -3,7 +3,6 @@ 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");
7
6
  const devkit_1 = require("@nx/devkit");
8
7
  const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
9
8
  const jest_1 = require("@nx/jest");
@@ -79,7 +78,6 @@ function getEsBuildConfig(project, options) {
79
78
  }
80
79
  function getServeConfig(options) {
81
80
  return {
82
- continuous: true,
83
81
  executor: '@nx/js:node',
84
82
  defaultConfiguration: 'development',
85
83
  // Run build, which includes dependency on "^build" by default, so the first run
@@ -141,13 +139,11 @@ function addProject(tree, options) {
141
139
  project.targets.serve = getServeConfig(options);
142
140
  if (options.isUsingTsSolutionConfig) {
143
141
  (0, devkit_1.writeJson)(tree, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'package.json'), {
144
- name: (0, get_import_path_1.getImportPath)(tree, options.name),
142
+ name: options.importPath,
145
143
  version: '0.0.1',
146
144
  private: true,
147
145
  nx: {
148
- name: options.name,
149
- projectType: 'application',
150
- sourceRoot: project.sourceRoot,
146
+ name: options.name !== options.importPath ? options.name : undefined,
151
147
  targets: project.targets,
152
148
  tags: project.tags?.length ? project.tags : undefined,
153
149
  },
@@ -195,16 +191,10 @@ function addAppFiles(tree, options) {
195
191
  }
196
192
  function addProxy(tree, options) {
197
193
  const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.frontendProject);
198
- if (projectConfig.targets &&
199
- ['serve', 'dev'].find((t) => !!projectConfig.targets[t])) {
200
- const targetName = ['serve', 'dev'].find((t) => !!projectConfig.targets[t]);
201
- projectConfig.targets[targetName].dependsOn = [
202
- ...(projectConfig.targets[targetName].dependsOn ?? []),
203
- `${options.name}:serve`,
204
- ];
194
+ if (projectConfig.targets && projectConfig.targets.serve) {
205
195
  const pathToProxyFile = `${projectConfig.root}/proxy.conf.json`;
206
- projectConfig.targets[targetName].options = {
207
- ...projectConfig.targets[targetName].options,
196
+ projectConfig.targets.serve.options = {
197
+ ...projectConfig.targets.serve.options,
208
198
  proxyConfig: pathToProxyFile,
209
199
  };
210
200
  if (!tree.exists(pathToProxyFile)) {
@@ -381,6 +371,11 @@ async function applicationGeneratorInternal(tree, schema) {
381
371
  }
382
372
  addAppFiles(tree, options);
383
373
  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
+ }
384
379
  updateTsConfigOptions(tree, options);
385
380
  if (options.linter === eslint_1.Linter.EsLint) {
386
381
  const lintTask = await addLintingToApplication(tree, options);
@@ -445,11 +440,6 @@ async function applicationGeneratorInternal(tree, schema) {
445
440
  ? ['eslint.config.js', 'eslint.config.cjs', 'eslint.config.mjs']
446
441
  : undefined);
447
442
  }
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
- }
453
443
  (0, sort_fields_1.sortPackageJsonFields)(tree, options.appProjectRoot);
454
444
  if (!options.skipFormat) {
455
445
  await (0, devkit_1.formatFiles)(tree);
@@ -460,8 +450,8 @@ async function applicationGeneratorInternal(tree, schema) {
460
450
  return (0, devkit_1.runTasksInSerial)(...tasks);
461
451
  }
462
452
  async function normalizeOptions(host, options) {
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, {
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, {
465
455
  name: options.name,
466
456
  projectType: 'application',
467
457
  directory: options.directory,
@@ -478,6 +468,7 @@ async function normalizeOptions(host, options) {
478
468
  nxJson.useInferencePlugins !== false;
479
469
  const isUsingTsSolutionConfig = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host);
480
470
  const swcJest = options.swcJest ?? isUsingTsSolutionConfig;
471
+ const appProjectName = !isUsingTsSolutionConfig || options.name ? projectName : importPath;
481
472
  return {
482
473
  addPlugin,
483
474
  ...options,
@@ -486,6 +477,7 @@ async function normalizeOptions(host, options) {
486
477
  ? (0, devkit_1.names)(options.frontendProject).fileName
487
478
  : undefined,
488
479
  appProjectRoot,
480
+ importPath,
489
481
  parsedTags,
490
482
  linter: options.linter ?? eslint_1.Linter.EsLint,
491
483
  unitTestRunner: options.unitTestRunner ?? 'jest',
@@ -493,7 +485,7 @@ async function normalizeOptions(host, options) {
493
485
  port: options.port ?? 3000,
494
486
  outputPath: isUsingTsSolutionConfig
495
487
  ? (0, devkit_1.joinPathFragments)(appProjectRoot, 'dist')
496
- : (0, devkit_1.joinPathFragments)('dist', options.rootProject ? options.name : appProjectRoot),
488
+ : (0, devkit_1.joinPathFragments)('dist', options.rootProject ? appProjectName : appProjectRoot),
497
489
  isUsingTsSolutionConfig,
498
490
  swcJest,
499
491
  };
@@ -12,7 +12,6 @@ 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");
16
15
  const posix_1 = require("node:path/posix");
17
16
  const add_swc_config_1 = require("@nx/js/src/utils/swc/add-swc-config");
18
17
  async function e2eProjectGenerator(host, options) {
@@ -29,17 +28,18 @@ async function e2eProjectGeneratorInternal(host, _options) {
29
28
  // TODO(@ndcunningham): This is broken.. the outputs are wrong.. and this isn't using the jest generator
30
29
  if (isUsingTsSolutionConfig) {
31
30
  (0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'package.json'), {
32
- name: (0, get_import_path_1.getImportPath)(host, options.e2eProjectName),
31
+ name: options.importPath,
33
32
  version: '0.0.1',
34
33
  private: true,
35
34
  nx: {
36
- name: options.e2eProjectName,
37
- projectType: 'application',
35
+ name: options.e2eProjectName !== options.importPath
36
+ ? options.e2eProjectName
37
+ : undefined,
38
38
  implicitDependencies: [options.project],
39
39
  targets: {
40
40
  e2e: {
41
41
  executor: '@nx/jest:jest',
42
- outputs: ['{workspaceRoot}/coverage/{e2eProjectRoot}'],
42
+ outputs: ['{projectRoot}/test-output/jest/coverage'],
43
43
  options: {
44
44
  jestConfig: `${options.e2eProjectRoot}/jest.config.ts`,
45
45
  passWithNoTests: true,
@@ -101,10 +101,11 @@ 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();
104
105
  if (options.projectType === 'server') {
105
106
  (0, devkit_1.generateFiles)(host, path.join(__dirname, 'files/server/common'), options.e2eProjectRoot, {
106
107
  ...options,
107
- ...(0, devkit_1.names)(options.rootProject ? 'server' : options.project),
108
+ ...(0, devkit_1.names)(options.rootProject ? 'server' : projectSimpleName),
108
109
  tsConfigFile,
109
110
  offsetFromRoot: rootOffset,
110
111
  jestPreset,
@@ -115,7 +116,7 @@ async function e2eProjectGeneratorInternal(host, _options) {
115
116
  if (options.isNest) {
116
117
  (0, devkit_1.generateFiles)(host, path.join(__dirname, 'files/server/nest'), options.e2eProjectRoot, {
117
118
  ...options,
118
- ...(0, devkit_1.names)(options.rootProject ? 'server' : options.project),
119
+ ...(0, devkit_1.names)(options.rootProject ? 'server' : projectSimpleName),
119
120
  tsConfigFile,
120
121
  offsetFromRoot: rootOffset,
121
122
  tmpl: '',
@@ -126,7 +127,7 @@ async function e2eProjectGeneratorInternal(host, _options) {
126
127
  const mainFile = appProject.targets.build?.options?.outputPath;
127
128
  (0, devkit_1.generateFiles)(host, path.join(__dirname, 'files/cli'), options.e2eProjectRoot, {
128
129
  ...options,
129
- ...(0, devkit_1.names)(options.rootProject ? 'cli' : options.project),
130
+ ...(0, devkit_1.names)(options.rootProject ? 'cli' : projectSimpleName),
130
131
  mainFile,
131
132
  tsConfigFile,
132
133
  offsetFromRoot: rootOffset,
@@ -201,11 +202,15 @@ async function e2eProjectGeneratorInternal(host, _options) {
201
202
  return (0, devkit_1.runTasksInSerial)(...tasks);
202
203
  }
203
204
  async function normalizeOptions(tree, options) {
204
- options.directory = options.directory ?? `${options.project}-e2e`;
205
- const { projectName: e2eProjectName, projectRoot: e2eProjectRoot } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(tree, {
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, {
206
211
  name: options.name,
207
- projectType: 'library',
208
- directory: options.rootProject ? 'e2e' : options.directory,
212
+ projectType: 'application',
213
+ directory,
209
214
  });
210
215
  const nxJson = (0, devkit_1.readNxJson)(tree);
211
216
  const addPlugin = process.env.NX_ADD_PLUGINS !== 'false' &&
@@ -215,6 +220,7 @@ async function normalizeOptions(tree, options) {
215
220
  ...options,
216
221
  e2eProjectRoot,
217
222
  e2eProjectName,
223
+ importPath,
218
224
  port: options.port ?? 3000,
219
225
  rootProject: !!options.rootProject,
220
226
  };
@@ -12,7 +12,6 @@ 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");
16
15
  const sort_fields_1 = require("@nx/js/src/utils/package-json/sort-fields");
17
16
  async function libraryGenerator(tree, schema) {
18
17
  return await libraryGeneratorInternal(tree, {
@@ -36,7 +35,7 @@ async function libraryGeneratorInternal(tree, schema) {
36
35
  options.publishable ||
37
36
  options.buildable) {
38
37
  (0, devkit_1.writeJson)(tree, (0, devkit_1.joinPathFragments)(options.projectRoot, 'package.json'), {
39
- name: (0, get_import_path_1.getImportPath)(tree, options.name),
38
+ name: options.importPath,
40
39
  version: '0.0.1',
41
40
  private: true,
42
41
  files: options.publishable ? ['dist', '!**/*.tsbuildinfo'] : undefined,
@@ -75,7 +74,7 @@ async function libraryGeneratorInternal(tree, schema) {
75
74
  }
76
75
  exports.default = libraryGenerator;
77
76
  async function normalizeOptions(tree, options) {
78
- await (0, project_name_and_root_utils_1.ensureProjectName)(tree, options, 'library');
77
+ await (0, project_name_and_root_utils_1.ensureRootProjectName)(options, 'library');
79
78
  const { projectName, names: projectNames, projectRoot, importPath, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(tree, {
80
79
  name: options.name,
81
80
  projectType: 'library',
@@ -96,9 +95,7 @@ async function normalizeOptions(tree, options) {
96
95
  return {
97
96
  ...options,
98
97
  fileName,
99
- projectName: isUsingTsSolutionConfig
100
- ? (0, get_import_path_1.getImportPath)(tree, projectName)
101
- : projectName,
98
+ projectName: isUsingTsSolutionConfig && !options.name ? importPath : projectName,
102
99
  projectRoot,
103
100
  parsedTags,
104
101
  importPath,