@nx/docker 23.2.0-beta.3 → 23.2.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/dist/src/executors/release-publish/release-publish.impl.js +11 -2
- package/dist/src/executors/release-publish/schema.d.ts +9 -0
- package/dist/src/plugins/plugin.js +4 -6
- package/dist/src/release/version-pattern-utils.js +2 -2
- package/dist/src/release/version-utils.d.ts +2 -2
- package/dist/src/release/version-utils.js +12 -1
- package/package.json +3 -3
|
@@ -9,6 +9,13 @@ const fs_1 = require("fs");
|
|
|
9
9
|
const version_utils_1 = require("../../release/version-utils");
|
|
10
10
|
exports.LARGE_BUFFER = 1024 * 1000000;
|
|
11
11
|
async function dockerReleasePublish(schema, context) {
|
|
12
|
+
const projectVersionData = schema.nxReleaseVersionData?.[context.projectName];
|
|
13
|
+
if (projectVersionData?.dockerVersion === null) {
|
|
14
|
+
console.warn(`Skipped Docker image for project "${context.projectName}", because no new Docker version was resolved for this project.`);
|
|
15
|
+
return {
|
|
16
|
+
success: true,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
12
19
|
const projectConfig = context.projectGraph.nodes[context.projectName];
|
|
13
20
|
const options = await normalizeOptions(projectConfig, schema);
|
|
14
21
|
if (!options.dryRun) {
|
|
@@ -53,7 +60,9 @@ async function checkDockerImageExistsLocally(imageRef) {
|
|
|
53
60
|
const normalizedImageRef = imageRef.startsWith('docker.io/')
|
|
54
61
|
? imageRef.split('docker.io/')[1]
|
|
55
62
|
: imageRef;
|
|
56
|
-
|
|
63
|
+
// Pass args as an array (no shell) so the reference read back from the
|
|
64
|
+
// .docker-version file can't break out into command injection.
|
|
65
|
+
const childProcess = (0, child_process_1.execFile)('docker', ['images', '--filter', `reference=${normalizedImageRef}`, '--quiet'], { encoding: 'utf8', windowsHide: true });
|
|
57
66
|
let result = '';
|
|
58
67
|
childProcess.stdout?.on('data', (data) => {
|
|
59
68
|
result += data;
|
|
@@ -77,7 +86,7 @@ async function checkDockerImageExistsLocally(imageRef) {
|
|
|
77
86
|
async function dockerPush(imageReference, quiet) {
|
|
78
87
|
try {
|
|
79
88
|
return await new Promise((res, rej) => {
|
|
80
|
-
const childProcess = (0, child_process_1.
|
|
89
|
+
const childProcess = (0, child_process_1.execFile)('docker', ['push', imageReference, ...(quiet ? ['--quiet'] : [])], {
|
|
81
90
|
encoding: 'utf8',
|
|
82
91
|
maxBuffer: exports.LARGE_BUFFER,
|
|
83
92
|
windowsHide: true,
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
export interface DockerReleasePublishSchema {
|
|
2
2
|
dryRun?: boolean;
|
|
3
3
|
quiet?: boolean;
|
|
4
|
+
nxReleaseVersionData?: Record<
|
|
5
|
+
string,
|
|
6
|
+
{
|
|
7
|
+
currentVersion: string | null;
|
|
8
|
+
newVersion: string | null;
|
|
9
|
+
dockerVersion: string | null;
|
|
10
|
+
[key: string]: any;
|
|
11
|
+
}
|
|
12
|
+
>;
|
|
4
13
|
}
|
|
@@ -4,18 +4,16 @@ exports.createNodesV2 = exports.createNodes = void 0;
|
|
|
4
4
|
exports.getProjectNameFromPath = getProjectNameFromPath;
|
|
5
5
|
const internal_1 = require("@nx/devkit/internal");
|
|
6
6
|
const devkit_1 = require("@nx/devkit");
|
|
7
|
-
const file_hasher_1 = require("nx/src/hasher/file-hasher");
|
|
8
|
-
const cache_directory_1 = require("nx/src/utils/cache-directory");
|
|
9
7
|
const fs_1 = require("fs");
|
|
10
8
|
const path_1 = require("path");
|
|
11
|
-
const
|
|
9
|
+
const internal_2 = require("@nx/devkit/internal");
|
|
12
10
|
const interpolate_pattern_1 = require("../utils/interpolate-pattern");
|
|
13
11
|
const dockerfileGlob = '**/Dockerfile';
|
|
14
12
|
exports.createNodes = [
|
|
15
13
|
dockerfileGlob,
|
|
16
14
|
async (configFilePaths, options, context) => {
|
|
17
|
-
const optionsHash = (0,
|
|
18
|
-
const cachePath = (0, path_1.join)(
|
|
15
|
+
const optionsHash = (0, internal_1.hashObject)(options);
|
|
16
|
+
const cachePath = (0, path_1.join)(internal_2.workspaceDataDirectory, `docker-${optionsHash}.hash`);
|
|
19
17
|
const targetsCache = new internal_1.PluginCache(cachePath);
|
|
20
18
|
const projectRoots = configFilePaths.map((c) => (0, path_1.dirname)(c));
|
|
21
19
|
const normalizedOptions = normalizePluginOptions(options);
|
|
@@ -50,7 +48,7 @@ async function createNodesInternal(configFilePath, hash, normalizedOptions, cont
|
|
|
50
48
|
};
|
|
51
49
|
}
|
|
52
50
|
function interpolateDockerTargetOptions(options, projectRoot, imageRef, context) {
|
|
53
|
-
const commitSha = (0,
|
|
51
|
+
const commitSha = (0, internal_2.getLatestCommitSha)();
|
|
54
52
|
const projectName = getProjectName(projectRoot, context.workspaceRoot);
|
|
55
53
|
const tokens = {
|
|
56
54
|
projectRoot,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.interpolateVersionPattern = interpolateVersionPattern;
|
|
4
|
-
const
|
|
4
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
5
5
|
const interpolate_pattern_1 = require("../utils/interpolate-pattern");
|
|
6
6
|
function interpolateVersionPattern(versionPattern, data) {
|
|
7
|
-
const commitSha = (0,
|
|
7
|
+
const commitSha = (0, internal_1.getLatestCommitSha)();
|
|
8
8
|
const substitutions = {
|
|
9
9
|
projectName: data.projectName ?? '',
|
|
10
10
|
currentDate: data.currentDate ?? new Date(),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ProjectGraphProjectNode } from '@nx/devkit';
|
|
2
|
-
import type
|
|
2
|
+
import { type FinalConfigForProject } from '@nx/devkit/internal';
|
|
3
3
|
export declare const getDockerVersionPath: (workspaceRoot: string, projectRoot: string) => string;
|
|
4
|
-
export declare function handleDockerVersion(workspaceRoot: string, projectGraphNode: ProjectGraphProjectNode, finalConfigForProject: FinalConfigForProject, dockerVersionScheme?: string, dockerVersion?: string, versionActionsVersion?: string): Promise<{
|
|
4
|
+
export declare function handleDockerVersion(workspaceRoot: string, projectGraphNode: ProjectGraphProjectNode, finalConfigForProject: FinalConfigForProject, dockerVersionScheme?: string, dockerVersion?: string, versionActionsVersion?: string | null): Promise<{
|
|
5
5
|
newVersion: string;
|
|
6
6
|
logs: string[];
|
|
7
7
|
}>;
|
|
@@ -33,6 +33,15 @@ async function handleDockerVersion(workspaceRoot, projectGraphNode, finalConfigF
|
|
|
33
33
|
: Object.keys(availableVersionSchemes).length === 1
|
|
34
34
|
? Object.keys(availableVersionSchemes)[0]
|
|
35
35
|
: await promptForNewVersion(availableVersionSchemes, projectGraphNode.name);
|
|
36
|
+
if (availableVersionSchemes[versionScheme].includes('{versionActionsVersion}') &&
|
|
37
|
+
versionActionsVersion == null) {
|
|
38
|
+
return {
|
|
39
|
+
newVersion: null,
|
|
40
|
+
logs: [
|
|
41
|
+
`Skipped ${projectGraphNode.name}, because no new version was resolved for this project.`,
|
|
42
|
+
],
|
|
43
|
+
};
|
|
44
|
+
}
|
|
36
45
|
newVersion = calculateNewVersion(projectGraphNode.name, versionScheme, availableVersionSchemes, versionActionsVersion);
|
|
37
46
|
}
|
|
38
47
|
}
|
|
@@ -80,7 +89,9 @@ function updateProjectVersion(newVersion, nxDockerImageRefEnvOverride, workspace
|
|
|
80
89
|
const newImageRef = getImageReference(projectRoot, repositoryName, registry);
|
|
81
90
|
const fullImageRef = nxDockerImageRefEnvOverride ?? `${newImageRef}:${newVersion}`;
|
|
82
91
|
if (!isDryRun) {
|
|
83
|
-
|
|
92
|
+
// argv array, not a shell string - the image ref is assembled from workspace
|
|
93
|
+
// config, CLI flags and env, so it can't be trusted as shell input.
|
|
94
|
+
(0, child_process_1.execFileSync)('docker', ['tag', imageRef, fullImageRef], {
|
|
84
95
|
windowsHide: true,
|
|
85
96
|
});
|
|
86
97
|
}
|
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": "23.2.0-beta.
|
|
4
|
+
"version": "23.2.0-beta.5",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist",
|
|
@@ -87,9 +87,9 @@
|
|
|
87
87
|
"dependencies": {
|
|
88
88
|
"enquirer": "~2.3.6",
|
|
89
89
|
"tslib": "^2.3.0",
|
|
90
|
-
"@nx/devkit": "23.2.0-beta.
|
|
90
|
+
"@nx/devkit": "23.2.0-beta.5"
|
|
91
91
|
},
|
|
92
92
|
"devDependencies": {
|
|
93
|
-
"nx": "23.2.0-beta.
|
|
93
|
+
"nx": "23.2.0-beta.5"
|
|
94
94
|
}
|
|
95
95
|
}
|