@nx/node 21.4.0-beta.3 → 21.4.0-beta.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/package.json +7 -6
- package/src/generators/application/application.d.ts.map +1 -1
- package/src/generators/application/application.js +3 -2
- package/src/generators/application/lib/add-dependencies.d.ts +4 -1
- package/src/generators/application/lib/add-dependencies.d.ts.map +1 -1
- package/src/generators/application/lib/add-dependencies.js +11 -8
- package/src/generators/application/lib/create-project.d.ts +1 -1
- package/src/generators/application/lib/create-project.d.ts.map +1 -1
- package/src/generators/application/lib/create-project.js +3 -2
- package/src/generators/application/lib/create-targets.d.ts +1 -1
- package/src/generators/application/lib/create-targets.d.ts.map +1 -1
- package/src/generators/application/lib/create-targets.js +12 -2
- package/src/generators/application/schema.d.ts +1 -0
- package/src/generators/application/schema.json +5 -0
- package/src/generators/setup-docker/files/Dockerfile__tmpl__ +16 -13
- package/src/generators/setup-docker/schema.d.ts +1 -0
- package/src/generators/setup-docker/schema.json +6 -1
- package/src/generators/setup-docker/setup-docker.d.ts.map +1 -1
- package/src/generators/setup-docker/setup-docker.js +52 -11
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@nx/node",
|
3
|
-
"version": "21.4.0-beta.
|
3
|
+
"version": "21.4.0-beta.5",
|
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,15 +32,16 @@
|
|
32
32
|
},
|
33
33
|
"dependencies": {
|
34
34
|
"tslib": "^2.3.0",
|
35
|
-
"@nx/devkit": "21.4.0-beta.
|
36
|
-
"@nx/jest": "21.4.0-beta.
|
37
|
-
"@nx/js": "21.4.0-beta.
|
38
|
-
"@nx/eslint": "21.4.0-beta.
|
35
|
+
"@nx/devkit": "21.4.0-beta.5",
|
36
|
+
"@nx/jest": "21.4.0-beta.5",
|
37
|
+
"@nx/js": "21.4.0-beta.5",
|
38
|
+
"@nx/eslint": "21.4.0-beta.5",
|
39
|
+
"@nx/docker": "21.4.0-beta.5",
|
39
40
|
"tcp-port-used": "^1.0.2",
|
40
41
|
"kill-port": "^1.6.1"
|
41
42
|
},
|
42
43
|
"devDependencies": {
|
43
|
-
"nx": "21.4.0-beta.
|
44
|
+
"nx": "21.4.0-beta.5"
|
44
45
|
},
|
45
46
|
"publishConfig": {
|
46
47
|
"access": "public"
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"application.d.ts","sourceRoot":"","sources":["../../../../../../packages/node/src/generators/application/application.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,iBAAiB,EAIjB,IAAI,EAIL,MAAM,YAAY,CAAC;AAapB,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAwClC,wBAAsB,oBAAoB,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,8BAMpE;AAED,wBAAsB,4BAA4B,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,
|
1
|
+
{"version":3,"file":"application.d.ts","sourceRoot":"","sources":["../../../../../../packages/node/src/generators/application/application.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,iBAAiB,EAIjB,IAAI,EAIL,MAAM,YAAY,CAAC;AAapB,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAwClC,wBAAsB,oBAAoB,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,8BAMpE;AAED,wBAAsB,4BAA4B,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,8BAmL5E;AAED,eAAe,oBAAoB,CAAC"}
|
@@ -86,7 +86,7 @@ async function applicationGeneratorInternal(tree, schema) {
|
|
86
86
|
skipFormat: true,
|
87
87
|
});
|
88
88
|
tasks.push(initTask);
|
89
|
-
const installTask = (0, lib_1.addProjectDependencies)(tree, options);
|
89
|
+
const { installTask, frameworkDependencies } = (0, lib_1.addProjectDependencies)(tree, options);
|
90
90
|
tasks.push(installTask);
|
91
91
|
if (options.bundler === 'webpack') {
|
92
92
|
const { webpackInitGenerator } = (0, devkit_1.ensurePackage)('@nx/webpack', versions_1.nxVersion);
|
@@ -104,7 +104,7 @@ async function applicationGeneratorInternal(tree, schema) {
|
|
104
104
|
}
|
105
105
|
}
|
106
106
|
(0, lib_1.addAppFiles)(tree, options);
|
107
|
-
(0, lib_1.addProject)(tree, options);
|
107
|
+
(0, lib_1.addProject)(tree, options, frameworkDependencies);
|
108
108
|
// If we are using the new TS solution
|
109
109
|
// We need to update the workspace file (package.json or pnpm-workspaces.yaml) to include the new project
|
110
110
|
if (options.isUsingTsSolutionConfig) {
|
@@ -167,6 +167,7 @@ async function applicationGeneratorInternal(tree, schema) {
|
|
167
167
|
...options,
|
168
168
|
project: options.name,
|
169
169
|
skipFormat: true,
|
170
|
+
skipDockerPlugin: options.skipDockerPlugin ?? false,
|
170
171
|
});
|
171
172
|
tasks.push(dockerTask);
|
172
173
|
}
|
@@ -1,4 +1,7 @@
|
|
1
1
|
import { GeneratorCallback, Tree } from '@nx/devkit';
|
2
2
|
import { NormalizedSchema } from './normalized-schema';
|
3
|
-
export declare function addProjectDependencies(tree: Tree, options: NormalizedSchema):
|
3
|
+
export declare function addProjectDependencies(tree: Tree, options: NormalizedSchema): {
|
4
|
+
installTask: GeneratorCallback;
|
5
|
+
frameworkDependencies: Record<string, string>;
|
6
|
+
};
|
4
7
|
//# sourceMappingURL=add-dependencies.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"add-dependencies.d.ts","sourceRoot":"","sources":["../../../../../../../packages/node/src/generators/application/lib/add-dependencies.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,
|
1
|
+
{"version":3,"file":"add-dependencies.d.ts","sourceRoot":"","sources":["../../../../../../../packages/node/src/generators/application/lib/add-dependencies.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EAEjB,IAAI,EAEL,MAAM,YAAY,CAAC;AAepB,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,gBAAgB,GACxB;IACD,WAAW,EAAE,iBAAiB,CAAC;IAC/B,qBAAqB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC/C,CAkDA"}
|
@@ -37,12 +37,15 @@ function addProjectDependencies(tree, options) {
|
|
37
37
|
},
|
38
38
|
fastify: {},
|
39
39
|
};
|
40
|
-
return
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
40
|
+
return {
|
41
|
+
installTask: (0, devkit_1.addDependenciesToPackageJson)(tree, {
|
42
|
+
...frameworkDependencies[options.framework],
|
43
|
+
tslib: versions_2.tslibVersion,
|
44
|
+
}, {
|
45
|
+
...frameworkDevDependencies[options.framework],
|
46
|
+
...bundlers[options.bundler],
|
47
|
+
'@types/node': versions_2.typesNodeVersion,
|
48
|
+
}),
|
49
|
+
frameworkDependencies: frameworkDependencies[options.framework],
|
50
|
+
};
|
48
51
|
}
|
@@ -1,4 +1,4 @@
|
|
1
1
|
import { Tree } from '@nx/devkit';
|
2
2
|
import { NormalizedSchema } from './normalized-schema';
|
3
|
-
export declare function addProject(tree: Tree, options: NormalizedSchema): void;
|
3
|
+
export declare function addProject(tree: Tree, options: NormalizedSchema, frameworkDependencies: Record<string, string>): void;
|
4
4
|
//# sourceMappingURL=create-project.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"create-project.d.ts","sourceRoot":"","sources":["../../../../../../../packages/node/src/generators/application/lib/create-project.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,IAAI,EAEL,MAAM,YAAY,CAAC;AAIpB,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AASvD,wBAAgB,UAAU,
|
1
|
+
{"version":3,"file":"create-project.d.ts","sourceRoot":"","sources":["../../../../../../../packages/node/src/generators/application/lib/create-project.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,IAAI,EAEL,MAAM,YAAY,CAAC;AAIpB,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AASvD,wBAAgB,UAAU,CACxB,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,gBAAgB,EACzB,qBAAqB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,QA0D9C"}
|
@@ -5,7 +5,7 @@ const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const target_defaults_utils_1 = require("@nx/devkit/src/generators/target-defaults-utils");
|
6
6
|
const has_webpack_plugin_1 = require("../../../utils/has-webpack-plugin");
|
7
7
|
const create_targets_1 = require("./create-targets");
|
8
|
-
function addProject(tree, options) {
|
8
|
+
function addProject(tree, options, frameworkDependencies) {
|
9
9
|
const project = {
|
10
10
|
root: options.appProjectRoot,
|
11
11
|
sourceRoot: (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'src'),
|
@@ -30,13 +30,14 @@ function addProject(tree, options) {
|
|
30
30
|
}
|
31
31
|
project.targets = {
|
32
32
|
...project.targets,
|
33
|
-
...(0, create_targets_1.getPruneTargets)('build'),
|
33
|
+
...(0, create_targets_1.getPruneTargets)('build', options.outputPath),
|
34
34
|
};
|
35
35
|
project.targets.serve = (0, create_targets_1.getServeConfig)(options);
|
36
36
|
const packageJson = {
|
37
37
|
name: options.importPath,
|
38
38
|
version: '0.0.1',
|
39
39
|
private: true,
|
40
|
+
dependencies: { ...frameworkDependencies },
|
40
41
|
};
|
41
42
|
if (!options.useProjectJson) {
|
42
43
|
packageJson.nx = {
|
@@ -4,7 +4,7 @@ export declare function getWebpackBuildConfig(tree: Tree, project: ProjectConfig
|
|
4
4
|
export declare function getEsBuildConfig(tree: Tree, project: ProjectConfiguration, options: NormalizedSchema): TargetConfiguration;
|
5
5
|
export declare function getServeConfig(options: NormalizedSchema): TargetConfiguration;
|
6
6
|
export declare function getNestWebpackBuildConfig(): TargetConfiguration;
|
7
|
-
export declare function getPruneTargets(buildTarget: string): {
|
7
|
+
export declare function getPruneTargets(buildTarget: string, outputPath: string): {
|
8
8
|
prune: TargetConfiguration;
|
9
9
|
'prune-lockfile': TargetConfiguration;
|
10
10
|
'copy-workspace-modules': TargetConfiguration;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"create-targets.d.ts","sourceRoot":"","sources":["../../../../../../../packages/node/src/generators/application/lib/create-targets.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,oBAAoB,EACpB,IAAI,EACJ,mBAAmB,
|
1
|
+
{"version":3,"file":"create-targets.d.ts","sourceRoot":"","sources":["../../../../../../../packages/node/src/generators/application/lib/create-targets.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,oBAAoB,EACpB,IAAI,EACJ,mBAAmB,EAEpB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAGvD,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,oBAAoB,EAC7B,OAAO,EAAE,gBAAgB,GACxB,mBAAmB,CA+BrB;AAED,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,oBAAoB,EAC7B,OAAO,EAAE,gBAAgB,GACxB,mBAAmB,CAqCrB;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,gBAAgB,GAAG,mBAAmB,CAuB7E;AAED,wBAAgB,yBAAyB,IAAI,mBAAmB,CAa/D;AAED,wBAAgB,eAAe,CAC7B,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,GACjB;IACD,KAAK,EAAE,mBAAmB,CAAC;IAC3B,gBAAgB,EAAE,mBAAmB,CAAC;IACtC,wBAAwB,EAAE,mBAAmB,CAAC;CAC/C,CAgCA"}
|
@@ -7,6 +7,7 @@ exports.getNestWebpackBuildConfig = getNestWebpackBuildConfig;
|
|
7
7
|
exports.getPruneTargets = getPruneTargets;
|
8
8
|
const devkit_1 = require("@nx/devkit");
|
9
9
|
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
10
|
+
const js_1 = require("@nx/js");
|
10
11
|
function getWebpackBuildConfig(tree, project, options) {
|
11
12
|
const sourceRoot = (0, ts_solution_setup_1.getProjectSourceRoot)(project, tree);
|
12
13
|
return {
|
@@ -106,24 +107,33 @@ function getNestWebpackBuildConfig() {
|
|
106
107
|
},
|
107
108
|
};
|
108
109
|
}
|
109
|
-
function getPruneTargets(buildTarget) {
|
110
|
+
function getPruneTargets(buildTarget, outputPath) {
|
111
|
+
const lockFileName = (0, js_1.getLockFileName)((0, devkit_1.detectPackageManager)() ?? 'npm') ?? 'package-lock.json';
|
110
112
|
return {
|
111
113
|
'prune-lockfile': {
|
114
|
+
dependsOn: ['build'],
|
112
115
|
cache: true,
|
113
116
|
executor: '@nx/js:prune-lockfile',
|
117
|
+
outputs: [
|
118
|
+
`{workspaceRoot}/${(0, devkit_1.joinPathFragments)(outputPath, 'package.json')}`,
|
119
|
+
`{workspaceRoot}/${(0, devkit_1.joinPathFragments)(outputPath, lockFileName)}`,
|
120
|
+
],
|
114
121
|
options: {
|
115
122
|
buildTarget,
|
116
123
|
},
|
117
124
|
},
|
118
125
|
'copy-workspace-modules': {
|
126
|
+
dependsOn: ['build'],
|
119
127
|
cache: true,
|
128
|
+
outputs: [
|
129
|
+
`{workspaceRoot}/${(0, devkit_1.joinPathFragments)(outputPath, 'workspace_modules')}`,
|
130
|
+
],
|
120
131
|
executor: '@nx/js:copy-workspace-modules',
|
121
132
|
options: {
|
122
133
|
buildTarget,
|
123
134
|
},
|
124
135
|
},
|
125
136
|
prune: {
|
126
|
-
cache: true,
|
127
137
|
dependsOn: ['prune-lockfile', 'copy-workspace-modules'],
|
128
138
|
executor: 'nx:noop',
|
129
139
|
},
|
@@ -124,6 +124,11 @@
|
|
124
124
|
"type": "boolean",
|
125
125
|
"description": "Add a docker build target"
|
126
126
|
},
|
127
|
+
"skipDockerPlugin": {
|
128
|
+
"type": "boolean",
|
129
|
+
"description": "Skip the @nx/docker plugin and use the legacy docker build target instead.",
|
130
|
+
"default": false
|
131
|
+
},
|
127
132
|
"useProjectJson": {
|
128
133
|
"type": "boolean",
|
129
134
|
"description": "Use a `project.json` configuration file instead of inlining the Nx configuration in the `package.json` file."
|
@@ -1,25 +1,28 @@
|
|
1
1
|
# This file is generated by Nx.
|
2
|
-
#
|
3
|
-
#
|
4
|
-
|
5
|
-
#
|
2
|
+
# Build the docker image with `npx nx docker:build <%= project %>`.
|
3
|
+
# Tip: Modify "docker:build" options in project.json to change docker build args.
|
4
|
+
#<% if (skipDockerPlugin) { %>
|
6
5
|
# Run the container with `docker run -p 3000:3000 -t <%= sanitizedProjectName %>`.
|
6
|
+
#<% } else { %>
|
7
|
+
# Run the container with `nx docker:run <%= project %> -p 3000:3000`.
|
8
|
+
#<% } %>
|
7
9
|
FROM docker.io/node:lts-alpine
|
8
10
|
|
9
11
|
ENV HOST=0.0.0.0
|
10
12
|
ENV PORT=3000
|
13
|
+
<% if(packageManager === "pnpm" || packageManager === 'yarn') { %>
|
14
|
+
RUN corepack enable
|
15
|
+
<% } %>
|
11
16
|
|
12
17
|
WORKDIR /app
|
13
18
|
|
14
|
-
|
15
|
-
adduser --system -G <%= sanitizedProjectName %> <%= sanitizedProjectName %>
|
16
|
-
|
17
|
-
COPY <%= buildLocation %> <%= sanitizedProjectName %>/
|
18
|
-
COPY <%= projectPath %>/package.json <%= sanitizedProjectName %>/
|
19
|
-
RUN chown -R <%= sanitizedProjectName %>:<%= sanitizedProjectName %> .
|
19
|
+
COPY <%= buildLocation %> .
|
20
20
|
|
21
21
|
# You can remove this install step if you build with `--bundle` option.
|
22
22
|
# The bundled output will include external dependencies.
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
<% if(packageManager === 'npm') { %>
|
24
|
+
RUN npm --omit=dev -f install
|
25
|
+
<% } else { %>
|
26
|
+
RUN <%= packageManager %> install
|
27
|
+
<% } %>
|
28
|
+
CMD [ "node", "main.js" ]
|
@@ -18,7 +18,7 @@
|
|
18
18
|
"targetName": {
|
19
19
|
"description": "The name of the target to create",
|
20
20
|
"type": "string",
|
21
|
-
"default": "docker
|
21
|
+
"default": "docker:build"
|
22
22
|
},
|
23
23
|
"buildTargetName": {
|
24
24
|
"description": "The name of the build target",
|
@@ -28,6 +28,11 @@
|
|
28
28
|
"outputPath": {
|
29
29
|
"description": "The output path for the node application",
|
30
30
|
"type": "string"
|
31
|
+
},
|
32
|
+
"skipDockerPlugin": {
|
33
|
+
"type": "boolean",
|
34
|
+
"description": "Skip the @nx/docker plugin and use the legacy docker build target instead.",
|
35
|
+
"default": false
|
31
36
|
}
|
32
37
|
}
|
33
38
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"setup-docker.d.ts","sourceRoot":"","sources":["../../../../../../packages/node/src/generators/setup-docker/setup-docker.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,iBAAiB,
|
1
|
+
{"version":3,"file":"setup-docker.d.ts","sourceRoot":"","sources":["../../../../../../packages/node/src/generators/setup-docker/setup-docker.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,iBAAiB,EAIjB,IAAI,EAML,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAsF9C,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,kBAAkB,QAqB1E;AAED,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,IAAI,EACV,YAAY,EAAE,kBAAkB,8BAcjC;AAED,eAAe,oBAAoB,CAAC"}
|
@@ -3,13 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.updateProjectConfig = updateProjectConfig;
|
4
4
|
exports.setupDockerGenerator = setupDockerGenerator;
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
6
|
+
const generators_1 = require("@nx/docker/generators");
|
6
7
|
const path_1 = require("path");
|
8
|
+
const fs_1 = require("fs");
|
7
9
|
function normalizeOptions(tree, setupOptions) {
|
8
10
|
return {
|
9
11
|
...setupOptions,
|
10
12
|
project: setupOptions.project ?? (0, devkit_1.readNxJson)(tree).defaultProject,
|
11
|
-
targetName: setupOptions.targetName ?? 'docker
|
13
|
+
targetName: setupOptions.targetName ?? 'docker:build',
|
12
14
|
buildTarget: setupOptions.buildTarget ?? 'build',
|
15
|
+
skipDockerPlugin: setupOptions.skipDockerPlugin ?? false,
|
13
16
|
};
|
14
17
|
}
|
15
18
|
function sanitizeProjectName(projectName) {
|
@@ -20,7 +23,11 @@ function sanitizeProjectName(projectName) {
|
|
20
23
|
.replace(/-+/g, '-')
|
21
24
|
.replace(/^-|-$/g, '');
|
22
25
|
}
|
23
|
-
function addDocker(tree, options) {
|
26
|
+
async function addDocker(tree, options) {
|
27
|
+
let installTask = () => { };
|
28
|
+
if (!options.skipDockerPlugin) {
|
29
|
+
installTask = await (0, generators_1.initGenerator)(tree, { skipFormat: true });
|
30
|
+
}
|
24
31
|
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
25
32
|
const outputPath = projectConfig.targets[options.buildTarget]?.options['outputPath'];
|
26
33
|
if (!projectConfig) {
|
@@ -30,29 +37,63 @@ function addDocker(tree, options) {
|
|
30
37
|
throw new Error(`The output path for the project ${options.project} is not defined. Please provide it as an option to the generator.`);
|
31
38
|
}
|
32
39
|
const sanitizedProjectName = sanitizeProjectName(options.project);
|
40
|
+
const finalOutputPath = options.outputPath ?? outputPath;
|
41
|
+
// Calculate build location based on skipDockerPlugin flag
|
42
|
+
let buildLocation;
|
43
|
+
if (options.skipDockerPlugin) {
|
44
|
+
// Legacy mode: use workspace-relative paths
|
45
|
+
// docker target is set to run at project root, so ensure offset to workspace root
|
46
|
+
buildLocation = (0, devkit_1.joinPathFragments)((0, devkit_1.offsetFromRoot)(projectConfig.root), finalOutputPath);
|
47
|
+
}
|
48
|
+
else {
|
49
|
+
// New mode: use project-relative paths
|
50
|
+
// Remove the project root prefix from the output path
|
51
|
+
const projectRootWithSlash = projectConfig.root + '/';
|
52
|
+
buildLocation = finalOutputPath.startsWith(projectRootWithSlash)
|
53
|
+
? finalOutputPath.substring(projectRootWithSlash.length)
|
54
|
+
: finalOutputPath.startsWith(projectConfig.root)
|
55
|
+
? finalOutputPath.substring(projectConfig.root.length)
|
56
|
+
: 'dist';
|
57
|
+
}
|
58
|
+
const packageManager = (0, fs_1.existsSync)(projectConfig.root)
|
59
|
+
? (0, devkit_1.detectPackageManager)(projectConfig.root)
|
60
|
+
: (0, devkit_1.detectPackageManager)(devkit_1.workspaceRoot);
|
33
61
|
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, './files'), projectConfig.root, {
|
34
62
|
tmpl: '',
|
35
|
-
buildLocation
|
63
|
+
buildLocation,
|
36
64
|
project: options.project,
|
37
65
|
projectPath: projectConfig.root,
|
38
66
|
sanitizedProjectName,
|
67
|
+
skipDockerPlugin: options.skipDockerPlugin,
|
68
|
+
packageManager,
|
39
69
|
});
|
70
|
+
return installTask;
|
40
71
|
}
|
41
72
|
function updateProjectConfig(tree, options) {
|
42
73
|
let projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
74
|
+
if (options.skipDockerPlugin) {
|
75
|
+
// Use sanitized project name for Docker image tag
|
76
|
+
const sanitizedProjectName = sanitizeProjectName(options.project);
|
77
|
+
projectConfig.targets[`${options.targetName}`] = {
|
78
|
+
dependsOn: [`${options.buildTarget}`, 'prune'],
|
79
|
+
command: `docker build . -t ${sanitizedProjectName}`,
|
80
|
+
options: {
|
81
|
+
cwd: projectConfig.root,
|
82
|
+
},
|
83
|
+
};
|
84
|
+
}
|
85
|
+
else {
|
86
|
+
projectConfig.targets[`${options.targetName}`] = {
|
87
|
+
dependsOn: [`${options.buildTarget}`, 'prune'],
|
88
|
+
};
|
89
|
+
}
|
49
90
|
(0, devkit_1.updateProjectConfiguration)(tree, options.project, projectConfig);
|
50
91
|
}
|
51
92
|
async function setupDockerGenerator(tree, setupOptions) {
|
52
93
|
const tasks = [];
|
53
94
|
const options = normalizeOptions(tree, setupOptions);
|
54
|
-
|
55
|
-
|
95
|
+
const installTask = await addDocker(tree, options);
|
96
|
+
tasks.push(installTask);
|
56
97
|
updateProjectConfig(tree, options);
|
57
98
|
if (!options.skipFormat) {
|
58
99
|
await (0, devkit_1.formatFiles)(tree);
|