@nx/node 21.1.2 → 21.1.3

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/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  <p style="text-align: center;">
2
2
  <picture>
3
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%">
4
+ <img alt="Nx - Smart Repos · Fast Builds" src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-light.svg" width="100%">
5
5
  </picture>
6
6
  </p>
7
7
 
@@ -20,9 +20,9 @@
20
20
 
21
21
  <hr>
22
22
 
23
- # Nx: Smart Monorepos · Fast CI
23
+ # Nx: Smart Repos · Fast Builds
24
24
 
25
- Nx is a build system, optimized for monorepos, with plugins for popular frameworks and tools and advanced CI capabilities including caching and distribution.
25
+ An AI-first build platform that connects everything from your editor to CI. Helping you deliver fast, without breaking things.
26
26
 
27
27
  ## Getting Started
28
28
 
@@ -62,5 +62,5 @@ npx nx@latest init
62
62
  - [Blog Posts About Nx](https://nx.dev/blog)
63
63
 
64
64
  <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"
65
- width="100%" alt="Nx - Smart Monorepos · Fast CI"></a></p>
65
+ width="100%" alt="Nx - Smart Repos · Fast Builds"></a></p>
66
66
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/node",
3
- "version": "21.1.2",
3
+ "version": "21.1.3",
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": "21.1.2",
36
- "@nx/jest": "21.1.2",
37
- "@nx/js": "21.1.2",
38
- "@nx/eslint": "21.1.2",
35
+ "@nx/devkit": "21.1.3",
36
+ "@nx/jest": "21.1.3",
37
+ "@nx/js": "21.1.3",
38
+ "@nx/eslint": "21.1.3",
39
39
  "tcp-port-used": "^1.0.2",
40
40
  "kill-port": "^1.6.1"
41
41
  },
@@ -35,7 +35,9 @@ function getWebpackBuildConfig(project, options) {
35
35
  generatePackageJson: options.isUsingTsSolutionConfig ? undefined : true,
36
36
  },
37
37
  configurations: {
38
- development: {},
38
+ development: {
39
+ outputHashing: 'none',
40
+ },
39
41
  production: {
40
42
  ...(options.docker && { generateLockfile: true }),
41
43
  },
@@ -127,7 +129,7 @@ function addProject(tree, options) {
127
129
  project.targets.build = getEsBuildConfig(project, options);
128
130
  }
129
131
  else if (options.bundler === 'webpack') {
130
- if (!(0, has_webpack_plugin_1.hasWebpackPlugin)(tree)) {
132
+ if (!(0, has_webpack_plugin_1.hasWebpackPlugin)(tree) && options.addPlugin === false) {
131
133
  (0, target_defaults_utils_1.addBuildTargetDefaults)(tree, `@nx/webpack:webpack`);
132
134
  project.targets.build = getWebpackBuildConfig(project, options);
133
135
  }
@@ -165,7 +167,7 @@ function addAppFiles(tree, options) {
165
167
  root: options.appProjectRoot,
166
168
  offset: (0, devkit_1.offsetFromRoot)(options.appProjectRoot),
167
169
  rootTsConfigPath: (0, js_1.getRelativePathToRootTsConfig)(tree, options.appProjectRoot),
168
- webpackPluginOptions: (0, has_webpack_plugin_1.hasWebpackPlugin)(tree)
170
+ webpackPluginOptions: (0, has_webpack_plugin_1.hasWebpackPlugin)(tree) && options.addPlugin !== false
169
171
  ? {
170
172
  outputPath: options.isUsingTsSolutionConfig
171
173
  ? 'dist'
@@ -3,7 +3,7 @@
3
3
  # Build the docker image with `npx nx docker-build <%= project %>`.
4
4
  # Tip: Modify "docker-build" options in project.json to change docker build args.
5
5
  #
6
- # Run the container with `docker run -p 3000:3000 -t <%= project %>`.
6
+ # Run the container with `docker run -p 3000:3000 -t <%= sanitizedProjectName %>`.
7
7
  FROM docker.io/node:lts-alpine
8
8
 
9
9
  ENV HOST=0.0.0.0
@@ -11,14 +11,15 @@ ENV PORT=3000
11
11
 
12
12
  WORKDIR /app
13
13
 
14
- RUN addgroup --system <%= project %> && \
15
- adduser --system -G <%= project %> <%= project %>
14
+ RUN addgroup --system <%= sanitizedProjectName %> && \
15
+ adduser --system -G <%= sanitizedProjectName %> <%= sanitizedProjectName %>
16
16
 
17
- COPY <%= buildLocation %> <%= project %>/
18
- RUN chown -R <%= project %>:<%= project %> .
17
+ COPY <%= buildLocation %> <%= sanitizedProjectName %>/
18
+ COPY <%= projectPath %>/package.json <%= sanitizedProjectName %>/
19
+ RUN chown -R <%= sanitizedProjectName %>:<%= sanitizedProjectName %> .
19
20
 
20
21
  # You can remove this install step if you build with `--bundle` option.
21
22
  # The bundled output will include external dependencies.
22
- RUN npm --prefix <%= project %> --omit=dev -f install
23
+ RUN npm --prefix <%= sanitizedProjectName %> --omit=dev -f install
23
24
 
24
- CMD [ "node", "<%= project %>" ]
25
+ CMD [ "node", "<%= sanitizedProjectName %>" ]
@@ -12,6 +12,14 @@ function normalizeOptions(tree, setupOptions) {
12
12
  buildTarget: setupOptions.buildTarget ?? 'build',
13
13
  };
14
14
  }
15
+ function sanitizeProjectName(projectName) {
16
+ return projectName
17
+ .toLowerCase()
18
+ .replace(/[@\/]/g, '-')
19
+ .replace(/[^a-z0-9._-]/g, '-')
20
+ .replace(/-+/g, '-')
21
+ .replace(/^-|-$/g, '');
22
+ }
15
23
  function addDocker(tree, options) {
16
24
  const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
17
25
  const outputPath = projectConfig.targets[options.buildTarget]?.options['outputPath'];
@@ -21,17 +29,22 @@ function addDocker(tree, options) {
21
29
  if (!outputPath && !options.outputPath) {
22
30
  throw new Error(`The output path for the project ${options.project} is not defined. Please provide it as an option to the generator.`);
23
31
  }
32
+ const sanitizedProjectName = sanitizeProjectName(options.project);
24
33
  (0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, './files'), projectConfig.root, {
25
34
  tmpl: '',
26
35
  buildLocation: options.outputPath ?? outputPath,
27
36
  project: options.project,
37
+ projectPath: projectConfig.root,
38
+ sanitizedProjectName,
28
39
  });
29
40
  }
30
41
  function updateProjectConfig(tree, options) {
31
42
  let projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
43
+ // Use sanitized project name for Docker image tag
44
+ const sanitizedProjectName = sanitizeProjectName(options.project);
32
45
  projectConfig.targets[`${options.targetName}`] = {
33
46
  dependsOn: [`${options.buildTarget}`],
34
- command: `docker build -f ${(0, devkit_1.joinPathFragments)(projectConfig.root, 'Dockerfile')} . -t ${options.project}`,
47
+ command: `docker build -f ${(0, devkit_1.joinPathFragments)(projectConfig.root, 'Dockerfile')} . -t ${sanitizedProjectName}`,
35
48
  };
36
49
  (0, devkit_1.updateProjectConfiguration)(tree, options.project, projectConfig);
37
50
  }