@nx/express 17.0.3 → 17.0.5

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  (The MIT License)
2
2
 
3
- Copyright (c) 2017-2023 Narwhal Technologies Inc.
3
+ Copyright (c) 2017-2024 Narwhal Technologies Inc.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
package/README.md CHANGED
@@ -1,4 +1,9 @@
1
- <p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600" alt="Nx - Smart, Fast and Extensible Build System"></p>
1
+ <p style="text-align: center;">
2
+ <picture>
3
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-dark.svg">
4
+ <img alt="Nx - Smart Monorepos · Fast CI" src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-light.svg" width="100%">
5
+ </picture>
6
+ </p>
2
7
 
3
8
  <div style="text-align: center;">
4
9
 
@@ -15,9 +20,9 @@
15
20
 
16
21
  <hr>
17
22
 
18
- # Nx: Smart, Fast and Extensible Build System
23
+ # Nx: Smart Monorepos · Fast CI
19
24
 
20
- Nx is a next generation build system with first class monorepo support and powerful integrations.
25
+ Nx is a build system with built-in tooling and advanced CI capabilities. It helps you maintain and scale monorepos, both locally and on CI.
21
26
 
22
27
  This package is an [Express plugin for Nx](https://nx.dev/express/overview).
23
28
 
@@ -59,5 +64,5 @@ npx nx@latest init
59
64
  - [Blog Posts About Nx](https://blog.nrwl.io/nx/home)
60
65
 
61
66
  <p style="text-align: center;"><a href="https://nx.dev/#learning-materials" target="_blank" rel="noreferrer"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-courses-and-videos.svg"
62
- width="100%" alt="Nx - Smart, Fast and Extensible Build System"></a></p>
67
+ width="100%" alt="Nx - Smart Monorepos · Fast CI"></a></p>
63
68
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/express",
3
- "version": "17.0.3",
3
+ "version": "17.0.5",
4
4
  "private": false,
5
5
  "description": "The Nx Plugin for Express contains executors and generators for allowing your workspace to create powerful Express Node applications and APIs.",
6
6
  "repository": {
@@ -30,10 +30,10 @@
30
30
  "migrations": "./migrations.json"
31
31
  },
32
32
  "dependencies": {
33
- "@nx/devkit": "17.0.3",
34
- "@nx/node": "17.0.3",
33
+ "@nx/devkit": "17.0.5",
34
+ "@nx/node": "17.0.5",
35
35
  "tslib": "^2.3.0",
36
- "@nrwl/express": "17.0.3"
36
+ "@nrwl/express": "17.0.5"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "express": "^4.18.1"
@@ -1,5 +1,5 @@
1
- import type { Tree } from '@nx/devkit';
1
+ import type { GeneratorCallback, Tree } from '@nx/devkit';
2
2
  import type { Schema } from './schema';
3
- export declare function applicationGenerator(tree: Tree, schema: Schema): Promise<() => Promise<void>>;
4
- export declare function applicationGeneratorInternal(tree: Tree, schema: Schema): Promise<() => Promise<void>>;
3
+ export declare function applicationGenerator(tree: Tree, schema: Schema): Promise<GeneratorCallback>;
4
+ export declare function applicationGeneratorInternal(tree: Tree, schema: Schema): Promise<GeneratorCallback>;
5
5
  export default applicationGenerator;
@@ -4,7 +4,9 @@ exports.applicationGeneratorInternal = exports.applicationGenerator = void 0;
4
4
  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 node_1 = require("@nx/node");
7
+ const versions_1 = require("@nx/node/src/utils/versions");
7
8
  const path_1 = require("path");
9
+ const versions_2 = require("../../utils/versions");
8
10
  const init_1 = require("../init/init");
9
11
  function addTypes(tree, options) {
10
12
  (0, devkit_1.updateJson)(tree, (0, path_1.join)(options.appProjectRoot, 'tsconfig.app.json'), (json) => {
@@ -41,6 +43,7 @@ server.on('error', console.error);
41
43
  }
42
44
  async function applicationGenerator(tree, schema) {
43
45
  return await applicationGeneratorInternal(tree, {
46
+ addPlugin: false,
44
47
  projectNameAndRootFormat: 'derived',
45
48
  ...schema,
46
49
  });
@@ -48,21 +51,24 @@ async function applicationGenerator(tree, schema) {
48
51
  exports.applicationGenerator = applicationGenerator;
49
52
  async function applicationGeneratorInternal(tree, schema) {
50
53
  const options = await normalizeOptions(tree, schema);
54
+ const tasks = [];
51
55
  const initTask = await (0, init_1.initGenerator)(tree, { ...options, skipFormat: true });
56
+ tasks.push(initTask);
52
57
  const applicationTask = await (0, node_1.applicationGenerator)(tree, {
53
- ...schema,
58
+ ...options,
54
59
  bundler: 'webpack',
55
60
  skipFormat: true,
56
61
  });
62
+ tasks.push(applicationTask);
57
63
  addMainFile(tree, options);
58
64
  addTypes(tree, options);
65
+ if (!options.skipPackageJson) {
66
+ tasks.push(ensureDependencies(tree));
67
+ }
59
68
  if (!options.skipFormat) {
60
69
  await (0, devkit_1.formatFiles)(tree);
61
70
  }
62
- return async () => {
63
- await initTask();
64
- await applicationTask();
65
- };
71
+ return (0, devkit_1.runTasksInSerial)(...tasks);
66
72
  }
67
73
  exports.applicationGeneratorInternal = applicationGeneratorInternal;
68
74
  exports.default = applicationGenerator;
@@ -75,9 +81,16 @@ async function normalizeOptions(host, options) {
75
81
  callingGenerator: '@nx/express:application',
76
82
  });
77
83
  options.projectNameAndRootFormat = projectNameAndRootFormat;
84
+ const nxJson = (0, devkit_1.readNxJson)(host);
85
+ const addPlugin = process.env.NX_ADD_PLUGINS !== 'false' &&
86
+ nxJson.useInferencePlugins !== false;
87
+ options.addPlugin ??= addPlugin;
78
88
  return {
79
89
  ...options,
80
90
  appProjectName,
81
91
  appProjectRoot,
82
92
  };
83
93
  }
94
+ function ensureDependencies(tree) {
95
+ return (0, devkit_1.addDependenciesToPackageJson)(tree, { tslib: versions_1.tslibVersion }, { '@nx/express': versions_2.nxVersion });
96
+ }
@@ -19,4 +19,5 @@ export interface Schema {
19
19
  pascalCaseFiles: boolean;
20
20
  standaloneConfig?: boolean;
21
21
  setParserOptionsProject?: boolean;
22
+ addPlugin?: boolean;
22
23
  }
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "http://json-schema.org/schema",
2
+ "$schema": "https://json-schema.org/schema",
3
3
  "cli": "nx",
4
4
  "$id": "SchematicsNxExpressApp",
5
5
  "title": "Nx Application Options Schema",
@@ -1,4 +1,4 @@
1
- import { Tree } from '@nx/devkit';
1
+ import { GeneratorCallback, Tree } from '@nx/devkit';
2
2
  import type { Schema } from './schema';
3
- export declare function initGenerator(tree: Tree, schema: Schema): Promise<() => Promise<void>>;
3
+ export declare function initGenerator(tree: Tree, schema: Schema): Promise<GeneratorCallback>;
4
4
  export default initGenerator;
@@ -2,32 +2,22 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.initGenerator = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
- const node_1 = require("@nx/node");
6
- const versions_1 = require("@nx/node/src/utils/versions");
7
- const versions_2 = require("../../utils/versions");
8
- function updateDependencies(tree) {
9
- (0, devkit_1.removeDependenciesFromPackageJson)(tree, ['@nx/express'], []);
10
- return (0, devkit_1.addDependenciesToPackageJson)(tree, {
11
- express: versions_2.expressVersion,
12
- tslib: versions_1.tslibVersion,
13
- }, {
14
- '@types/express': versions_2.expressTypingsVersion,
15
- '@nx/express': versions_2.nxVersion,
16
- });
5
+ const versions_1 = require("../../utils/versions");
6
+ function updateDependencies(tree, schema) {
7
+ const tasks = [];
8
+ tasks.push((0, devkit_1.removeDependenciesFromPackageJson)(tree, ['@nx/express'], []));
9
+ tasks.push((0, devkit_1.addDependenciesToPackageJson)(tree, { express: versions_1.expressVersion }, { '@nx/express': versions_1.nxVersion }, undefined, schema.keepExistingVersions));
10
+ return (0, devkit_1.runTasksInSerial)(...tasks);
17
11
  }
18
12
  async function initGenerator(tree, schema) {
19
- const initTask = await (0, node_1.initGenerator)(tree, {
20
- ...schema,
21
- skipFormat: true,
22
- });
23
- const installTask = updateDependencies(tree);
13
+ let installTask = () => { };
14
+ if (!schema.skipPackageJson) {
15
+ installTask = updateDependencies(tree, schema);
16
+ }
24
17
  if (!schema.skipFormat) {
25
18
  await (0, devkit_1.formatFiles)(tree);
26
19
  }
27
- return async () => {
28
- await initTask();
29
- await installTask();
30
- };
20
+ return installTask;
31
21
  }
32
22
  exports.initGenerator = initGenerator;
33
23
  exports.default = initGenerator;
@@ -1,4 +1,5 @@
1
1
  export interface Schema {
2
- unitTestRunner?: 'jest' | 'none';
3
2
  skipFormat?: boolean;
3
+ skipPackageJson?: boolean;
4
+ keepExistingVersions?: boolean;
4
5
  }
@@ -1,21 +1,26 @@
1
1
  {
2
- "$schema": "http://json-schema.org/schema",
2
+ "$schema": "https://json-schema.org/schema",
3
3
  "cli": "nx",
4
4
  "$id": "NxExpressInit",
5
5
  "title": "Init Express Plugin",
6
6
  "description": "Init Express Plugin.",
7
7
  "type": "object",
8
8
  "properties": {
9
- "unitTestRunner": {
10
- "description": "Adds the specified unit test runner.",
11
- "type": "string",
12
- "enum": ["jest", "none"],
13
- "default": "jest"
14
- },
15
9
  "skipFormat": {
16
10
  "description": "Skip formatting files.",
17
11
  "type": "boolean",
18
12
  "default": false
13
+ },
14
+ "skipPackageJson": {
15
+ "type": "boolean",
16
+ "default": false,
17
+ "description": "Do not add dependencies to `package.json`."
18
+ },
19
+ "keepExistingVersions": {
20
+ "type": "boolean",
21
+ "x-priority": "internal",
22
+ "description": "Keep existing dependencies versions",
23
+ "default": false
19
24
  }
20
25
  },
21
26
  "required": []