@nx/docker 22.1.0-beta.0 → 22.1.0-beta.2
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 +3 -3
- package/src/executors/release-publish/release-publish.impl.d.ts.map +1 -1
- package/src/executors/release-publish/release-publish.impl.js +4 -1
- package/src/generators/init/init.d.ts.map +1 -1
- package/src/generators/init/init.js +30 -8
- package/src/plugins/plugin.d.ts +1 -0
- package/src/plugins/plugin.d.ts.map +1 -1
- package/src/plugins/plugin.js +14 -5
- package/src/release/version-utils.d.ts +1 -1
- package/src/release/version-utils.d.ts.map +1 -1
- package/src/release/version-utils.js +7 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/docker",
|
|
3
3
|
"description": "The Nx Plugin for Docker to aid in containerizing projects.",
|
|
4
|
-
"version": "22.1.0-beta.
|
|
4
|
+
"version": "22.1.0-beta.2",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -47,12 +47,12 @@
|
|
|
47
47
|
"executors": "./executors.json",
|
|
48
48
|
"generators": "./generators.json",
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@nx/devkit": "22.1.0-beta.
|
|
50
|
+
"@nx/devkit": "22.1.0-beta.2",
|
|
51
51
|
"enquirer": "~2.3.6",
|
|
52
52
|
"tslib": "^2.3.0"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"nx": "22.1.0-beta.
|
|
55
|
+
"nx": "22.1.0-beta.2"
|
|
56
56
|
},
|
|
57
57
|
"types": "./src/index.d.ts"
|
|
58
58
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"release-publish.impl.d.ts","sourceRoot":"","sources":["../../../../../../packages/docker/src/executors/release-publish/release-publish.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,eAAe,EAIrB,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"release-publish.impl.d.ts","sourceRoot":"","sources":["../../../../../../packages/docker/src/executors/release-publish/release-publish.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,eAAe,EAIrB,MAAM,YAAY,CAAC;AAGpB,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,UAAU,CAAC;AAI3D,MAAM,WAAW,oCAAoC;IACnD,KAAK,EAAE,OAAO,CAAC;IACf,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,eAAO,MAAM,YAAY,QAAiB,CAAC;AAE3C,wBAA8B,oBAAoB,CAChD,MAAM,EAAE,0BAA0B,EAClC,OAAO,EAAE,eAAe;;GAmBzB"}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.LARGE_BUFFER = void 0;
|
|
4
4
|
exports.default = dockerReleasePublish;
|
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
6
7
|
const child_process_1 = require("child_process");
|
|
7
8
|
const fs_1 = require("fs");
|
|
8
9
|
const version_utils_1 = require("../../release/version-utils");
|
|
@@ -93,7 +94,9 @@ async function dockerPush(imageReference, quiet) {
|
|
|
93
94
|
childProcess.on('error', (error) => {
|
|
94
95
|
rej(error);
|
|
95
96
|
});
|
|
96
|
-
childProcess.on('exit', (code) => {
|
|
97
|
+
childProcess.on('exit', (code, signal) => {
|
|
98
|
+
if (code === null)
|
|
99
|
+
code = (0, internal_1.signalToCode)(signal);
|
|
97
100
|
if (code === 0) {
|
|
98
101
|
res(result.trim());
|
|
99
102
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../../../../packages/docker/src/generators/init/init.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,IAAI,EACT,KAAK,iBAAiB,
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../../../../packages/docker/src/generators/init/init.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,IAAI,EACT,KAAK,iBAAiB,EAQvB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAI/C,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,mBAAmB,qBAUzE;AAwCD,wBAAsB,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,mBAAmB,8BAiB1E;AAED,eAAe,aAAa,CAAC"}
|
|
@@ -3,25 +3,47 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.updateDependencies = updateDependencies;
|
|
4
4
|
exports.initGenerator = initGenerator;
|
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
|
6
|
-
const add_plugin_1 = require("@nx/devkit/src/utils/add-plugin");
|
|
7
|
-
const plugin_1 = require("../../plugins/plugin");
|
|
8
6
|
const versions_1 = require("../../utils/versions");
|
|
9
7
|
function updateDependencies(tree, schema) {
|
|
10
8
|
return (0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
|
|
11
9
|
'@nx/docker': versions_1.nxVersion,
|
|
12
10
|
}, undefined, schema.keepExistingVersions);
|
|
13
11
|
}
|
|
12
|
+
function addPluginToNxJson(tree, updatePackageScripts) {
|
|
13
|
+
if (!tree.exists('nx.json')) {
|
|
14
|
+
devkit_1.logger.warn('"nx.json" not found. Skipping "@nx/docker" plugin registration.');
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
18
|
+
if (!nxJson) {
|
|
19
|
+
devkit_1.logger.warn('Unable to read "nx.json" content. Skipping "@nx/docker" plugin registration.');
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
nxJson.plugins ??= [];
|
|
23
|
+
const pluginExists = nxJson.plugins.some((plugin) => typeof plugin === 'string'
|
|
24
|
+
? plugin === '@nx/docker'
|
|
25
|
+
: plugin?.plugin === '@nx/docker');
|
|
26
|
+
if (pluginExists) {
|
|
27
|
+
devkit_1.logger.info('"@nx/docker" plugin is already registered in "nx.json".');
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
nxJson.plugins.push({
|
|
31
|
+
plugin: '@nx/docker',
|
|
32
|
+
options: {
|
|
33
|
+
buildTarget: { name: 'docker:build' },
|
|
34
|
+
runTarget: { name: 'docker:run' },
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
38
|
+
devkit_1.logger.info('Added "@nx/docker" to plugins array in "nx.json".');
|
|
39
|
+
}
|
|
14
40
|
async function initGenerator(tree, schema) {
|
|
15
41
|
devkit_1.logger.warn(`Docker support is experimental. Breaking changes may occur and not adhere to semver versioning.`);
|
|
16
|
-
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
17
|
-
await (0, add_plugin_1.addPlugin)(tree, await (0, devkit_1.createProjectGraphAsync)(), '@nx/docker', plugin_1.createNodesV2, {
|
|
18
|
-
buildTarget: ['docker:build', 'docker-build', 'build-docker'],
|
|
19
|
-
runTarget: ['docker:run', 'docker-run', 'run-docker'],
|
|
20
|
-
}, schema.updatePackageScripts);
|
|
21
42
|
const tasks = [];
|
|
22
|
-
if (!schema.skipPackageJson) {
|
|
43
|
+
if (!schema.skipPackageJson && tree.exists('package.json')) {
|
|
23
44
|
tasks.push(updateDependencies(tree, schema));
|
|
24
45
|
}
|
|
46
|
+
addPluginToNxJson(tree, schema.updatePackageScripts);
|
|
25
47
|
if (!schema.skipFormat) {
|
|
26
48
|
await (0, devkit_1.formatFiles)(tree);
|
|
27
49
|
}
|
package/src/plugins/plugin.d.ts
CHANGED
|
@@ -12,4 +12,5 @@ export interface DockerPluginOptions {
|
|
|
12
12
|
runTarget?: string | DockerTargetOptions;
|
|
13
13
|
}
|
|
14
14
|
export declare const createNodesV2: CreateNodesV2<DockerPluginOptions>;
|
|
15
|
+
export declare function getProjectNameFromPath(projectRoot: string, workspaceRoot: string): string;
|
|
15
16
|
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../../packages/docker/src/plugins/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../../packages/docker/src/plugins/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAQnB,MAAM,YAAY,CAAC;AAUpB,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,cAAc,CAAC,EAAE,MAAM,CACrB,MAAM,EACN,IAAI,CAAC,mBAAmB,EAAE,gBAAgB,GAAG,MAAM,CAAC,CACrD,CAAC;CACH;AAED,MAAM,WAAW,mBAAmB;IAClC,WAAW,CAAC,EAAE,MAAM,GAAG,mBAAmB,CAAC;IAC3C,SAAS,CAAC,EAAE,MAAM,GAAG,mBAAmB,CAAC;CAC1C;AAsBD,eAAO,MAAM,aAAa,EAAE,aAAa,CAAC,mBAAmB,CAmC5D,CAAC;AAmDF,wBAAgB,sBAAsB,CACpC,WAAW,EAAE,MAAM,EACnB,aAAa,EAAE,MAAM,GACpB,MAAM,CAOR"}
|
package/src/plugins/plugin.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createNodesV2 = void 0;
|
|
4
|
+
exports.getProjectNameFromPath = getProjectNameFromPath;
|
|
4
5
|
const devkit_1 = require("@nx/devkit");
|
|
5
6
|
const calculate_hash_for_create_nodes_1 = require("@nx/devkit/src/utils/calculate-hash-for-create-nodes");
|
|
6
7
|
const file_hasher_1 = require("nx/src/hasher/file-hasher");
|
|
@@ -58,10 +59,18 @@ function interpolateDockerTargetOptions(options, projectRoot, imageRef, context)
|
|
|
58
59
|
imageRef,
|
|
59
60
|
currentDate: new Date(),
|
|
60
61
|
commitSha,
|
|
61
|
-
shortCommitSha: commitSha.slice(0, 7),
|
|
62
|
+
shortCommitSha: commitSha ? commitSha.slice(0, 7) : null,
|
|
62
63
|
};
|
|
63
64
|
return (0, interpolate_pattern_1.interpolateObject)(options, tokens);
|
|
64
65
|
}
|
|
66
|
+
function getProjectNameFromPath(projectRoot, workspaceRoot) {
|
|
67
|
+
const root = projectRoot === '.' ? workspaceRoot : projectRoot;
|
|
68
|
+
const normalized = root
|
|
69
|
+
.replace(/^[\\/]/, '')
|
|
70
|
+
.replace(/[\\/\s]+/g, '-')
|
|
71
|
+
.toLowerCase();
|
|
72
|
+
return normalized.length > 128 ? normalized.slice(-128) : normalized;
|
|
73
|
+
}
|
|
65
74
|
function getProjectName(projectRoot, workspaceRoot) {
|
|
66
75
|
const projectJsonPath = (0, path_1.join)(workspaceRoot, projectRoot, 'project.json');
|
|
67
76
|
if ((0, fs_1.existsSync)(projectJsonPath)) {
|
|
@@ -77,7 +86,7 @@ function getProjectName(projectRoot, workspaceRoot) {
|
|
|
77
86
|
return packageJson.name;
|
|
78
87
|
}
|
|
79
88
|
}
|
|
80
|
-
return projectRoot
|
|
89
|
+
return getProjectNameFromPath(projectRoot, workspaceRoot);
|
|
81
90
|
}
|
|
82
91
|
function buildTargetOptions(interpolatedTarget, projectRoot, imageRef, isRunTarget = false) {
|
|
83
92
|
const options = {
|
|
@@ -113,7 +122,7 @@ function buildTargetConfigurations(interpolatedTarget, projectRoot, imageRef, is
|
|
|
113
122
|
return configurations;
|
|
114
123
|
}
|
|
115
124
|
async function createDockerTargets(projectRoot, options, context) {
|
|
116
|
-
const imageRef = projectRoot
|
|
125
|
+
const imageRef = getProjectNameFromPath(projectRoot, devkit_1.workspaceRoot);
|
|
117
126
|
const interpolatedBuildTarget = interpolateDockerTargetOptions(options.buildTarget, projectRoot, imageRef, context);
|
|
118
127
|
const interpolatedRunTarget = interpolateDockerTargetOptions(options.runTarget, projectRoot, imageRef, context);
|
|
119
128
|
const namedInputs = (0, get_named_inputs_1.getNamedInputs)(projectRoot, context);
|
|
@@ -194,7 +203,7 @@ function normalizePluginOptions(options) {
|
|
|
194
203
|
return { name: defaultName };
|
|
195
204
|
};
|
|
196
205
|
return {
|
|
197
|
-
buildTarget: normalizeTarget(options
|
|
198
|
-
runTarget: normalizeTarget(options
|
|
206
|
+
buildTarget: normalizeTarget(options?.buildTarget, 'docker:build'),
|
|
207
|
+
runTarget: normalizeTarget(options?.runTarget, 'docker:run'),
|
|
199
208
|
};
|
|
200
209
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ProjectGraphProjectNode } from '@nx/devkit';
|
|
2
2
|
import type { FinalConfigForProject } from 'nx/src/command-line/release/utils/release-graph';
|
|
3
3
|
export declare const getDockerVersionPath: (workspaceRoot: string, projectRoot: string) => string;
|
|
4
4
|
export declare function handleDockerVersion(workspaceRoot: string, projectGraphNode: ProjectGraphProjectNode, finalConfigForProject: FinalConfigForProject, dockerVersionScheme?: string, dockerVersion?: string, versionActionsVersion?: string): Promise<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version-utils.d.ts","sourceRoot":"","sources":["../../../../../packages/docker/src/release/version-utils.ts"],"names":[],"mappings":"AAIA,OAAO,
|
|
1
|
+
{"version":3,"file":"version-utils.d.ts","sourceRoot":"","sources":["../../../../../packages/docker/src/release/version-utils.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,uBAAuB,EAAiB,MAAM,YAAY,CAAC;AACpE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iDAAiD,CAAC;AAQ7F,eAAO,MAAM,oBAAoB,GAC/B,eAAe,MAAM,EACrB,aAAa,MAAM,WAGpB,CAAC;AAEF,wBAAsB,mBAAmB,CACvC,aAAa,EAAE,MAAM,EACrB,gBAAgB,EAAE,uBAAuB,EACzC,qBAAqB,EAAE,qBAAqB,EAC5C,mBAAmB,CAAC,EAAE,MAAM,EAC5B,aAAa,CAAC,EAAE,MAAM,EACtB,qBAAqB,CAAC,EAAE,MAAM;;;GA6C/B"}
|
|
@@ -6,6 +6,7 @@ const child_process_1 = require("child_process");
|
|
|
6
6
|
const fs_1 = require("fs");
|
|
7
7
|
const path_1 = require("path");
|
|
8
8
|
const enquirer_1 = require("enquirer");
|
|
9
|
+
const devkit_1 = require("@nx/devkit");
|
|
9
10
|
const version_pattern_utils_1 = require("./version-pattern-utils");
|
|
10
11
|
const DEFAULT_VERSION_SCHEMES = {
|
|
11
12
|
production: '{currentDate|YYMM.DD}.{shortCommitSha}',
|
|
@@ -91,5 +92,10 @@ function getImageReference(projectRoot, repositoryName, registry) {
|
|
|
91
92
|
return imageRef;
|
|
92
93
|
}
|
|
93
94
|
function getDefaultImageReference(projectRoot) {
|
|
94
|
-
|
|
95
|
+
const root = projectRoot === '.' ? devkit_1.workspaceRoot : projectRoot;
|
|
96
|
+
const normalized = root
|
|
97
|
+
.replace(/^[\\/]/, '')
|
|
98
|
+
.replace(/[\\/\s]+/g, '-')
|
|
99
|
+
.toLowerCase();
|
|
100
|
+
return normalized.length > 128 ? normalized.slice(-128) : normalized;
|
|
95
101
|
}
|