@nx/docker 0.0.0-pr-32117-ebf1c19 → 0.0.0-pr-32111-2ec6a92
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 -7
- package/src/executors/release-publish/release-publish.impl.d.ts.map +1 -1
- package/src/executors/release-publish/release-publish.impl.js +14 -56
- package/src/generators/init/schema.d.ts +1 -0
- package/src/generators/init/schema.json +5 -0
- package/README.md +0 -70
- package/generators.d.ts +0 -2
- package/generators.d.ts.map +0 -1
- package/generators.js +0 -4
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": "0.0.0-pr-
|
|
4
|
+
"version": "0.0.0-pr-32111-2ec6a92",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -32,10 +32,6 @@
|
|
|
32
32
|
"types": "./src/release/version-utils.d.ts",
|
|
33
33
|
"default": "./src/release/version-utils.js"
|
|
34
34
|
},
|
|
35
|
-
"./generators": {
|
|
36
|
-
"types": "./generators.d.ts",
|
|
37
|
-
"default": "./generators.js"
|
|
38
|
-
},
|
|
39
35
|
"./package.json": "./package.json",
|
|
40
36
|
"./generators.json": "./generators.json",
|
|
41
37
|
"./executors.json": "./executors.json",
|
|
@@ -47,12 +43,12 @@
|
|
|
47
43
|
"executors": "./executors.json",
|
|
48
44
|
"generators": "./generators.json",
|
|
49
45
|
"dependencies": {
|
|
50
|
-
"@nx/devkit": "0.0.0-pr-
|
|
46
|
+
"@nx/devkit": "0.0.0-pr-32111-2ec6a92",
|
|
51
47
|
"enquirer": "~2.3.6",
|
|
52
48
|
"tslib": "^2.3.0"
|
|
53
49
|
},
|
|
54
50
|
"devDependencies": {
|
|
55
|
-
"nx": "0.0.0-pr-
|
|
51
|
+
"nx": "0.0.0-pr-32111-2ec6a92"
|
|
56
52
|
},
|
|
57
53
|
"types": "./src/index.d.ts"
|
|
58
54
|
}
|
|
@@ -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;AAEpB,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;;
|
|
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;AAEpB,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;;GAiBzB"}
|
|
@@ -9,10 +9,10 @@ const version_utils_1 = require("../../release/version-utils");
|
|
|
9
9
|
exports.LARGE_BUFFER = 1024 * 1000000;
|
|
10
10
|
async function dockerReleasePublish(schema, context) {
|
|
11
11
|
const projectConfig = context.projectGraph.nodes[context.projectName];
|
|
12
|
-
const options =
|
|
12
|
+
const options = normalizeOptions(projectConfig, schema);
|
|
13
13
|
if (!options.dryRun) {
|
|
14
|
-
const digest =
|
|
15
|
-
devkit_1.logger.log(`Successfully pushed ${options.imageReference}
|
|
14
|
+
const digest = dockerPush(options.imageReference, options.quiet);
|
|
15
|
+
devkit_1.logger.log(`Successfully pushed ${options.imageReference}. Digest: ${digest}`);
|
|
16
16
|
}
|
|
17
17
|
else {
|
|
18
18
|
devkit_1.logger.log(`Docker Image ${options.imageReference} was not pushed as --dry-run is enabled.`);
|
|
@@ -21,17 +21,17 @@ async function dockerReleasePublish(schema, context) {
|
|
|
21
21
|
success: true,
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
|
-
|
|
24
|
+
function normalizeOptions(projectConfig, schema) {
|
|
25
25
|
return {
|
|
26
26
|
quiet: schema.quiet ?? false,
|
|
27
|
-
imageReference:
|
|
27
|
+
imageReference: findImageReference(projectConfig, schema),
|
|
28
28
|
dryRun: process.env.NX_DRY_RUN === 'true' || schema.dryRun || false,
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
|
-
|
|
31
|
+
function findImageReference(projectConfig, schema) {
|
|
32
32
|
let imageRef = readVersionFromFile(projectConfig.data.root);
|
|
33
33
|
if (imageRef) {
|
|
34
|
-
if (
|
|
34
|
+
if (checkDockerImageExistsLocally(imageRef)) {
|
|
35
35
|
return imageRef;
|
|
36
36
|
}
|
|
37
37
|
throw new Error(`Could not find Docker Image ${imageRef}. Did you run 'nx release version'?`);
|
|
@@ -45,63 +45,21 @@ function readVersionFromFile(projectRoot) {
|
|
|
45
45
|
const version = (0, fs_1.readFileSync)(versionFilePath, { encoding: 'utf8' });
|
|
46
46
|
return version.trim();
|
|
47
47
|
}
|
|
48
|
-
|
|
48
|
+
function checkDockerImageExistsLocally(imageRef) {
|
|
49
49
|
try {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const normalizedImageRef = imageRef.startsWith('docker.io/')
|
|
53
|
-
? imageRef.split('docker.io/')[1]
|
|
54
|
-
: imageRef;
|
|
55
|
-
const childProcess = (0, child_process_1.exec)(`docker images --filter "reference=${normalizedImageRef}" --quiet`, { encoding: 'utf8' });
|
|
56
|
-
let result = '';
|
|
57
|
-
childProcess.stdout?.on('data', (data) => {
|
|
58
|
-
result += data;
|
|
59
|
-
});
|
|
60
|
-
childProcess.stderr?.on('data', (data) => {
|
|
61
|
-
console.error(data);
|
|
62
|
-
});
|
|
63
|
-
childProcess.on('error', (error) => {
|
|
64
|
-
console.error('Docker command failed:', error);
|
|
65
|
-
res(false);
|
|
66
|
-
});
|
|
67
|
-
childProcess.on('exit', () => {
|
|
68
|
-
res(result.trim().length > 0);
|
|
69
|
-
});
|
|
70
|
-
});
|
|
50
|
+
const result = (0, child_process_1.execSync)(`docker images --filter "reference=${imageRef}" --quiet`, { encoding: 'utf8', stdio: 'inherit', maxBuffer: exports.LARGE_BUFFER });
|
|
51
|
+
return result.trim().length > 0;
|
|
71
52
|
}
|
|
72
53
|
catch {
|
|
73
54
|
return false;
|
|
74
55
|
}
|
|
75
56
|
}
|
|
76
|
-
|
|
57
|
+
function dockerPush(imageReference, quiet) {
|
|
77
58
|
try {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
encoding: 'utf8',
|
|
81
|
-
maxBuffer: exports.LARGE_BUFFER,
|
|
82
|
-
});
|
|
83
|
-
let result = '';
|
|
84
|
-
childProcess.stdout?.on('data', (data) => {
|
|
85
|
-
result += data;
|
|
86
|
-
if (!quiet) {
|
|
87
|
-
console.log(data);
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
childProcess.stderr?.on('data', (data) => {
|
|
91
|
-
console.error(data);
|
|
92
|
-
});
|
|
93
|
-
childProcess.on('error', (error) => {
|
|
94
|
-
rej(error);
|
|
95
|
-
});
|
|
96
|
-
childProcess.on('exit', (code) => {
|
|
97
|
-
if (code === 0) {
|
|
98
|
-
res(result.trim());
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
rej(new Error(`Docker push failed with exit code ${code}`));
|
|
102
|
-
}
|
|
103
|
-
});
|
|
59
|
+
const result = (0, child_process_1.execSync)(`docker push ${imageReference}${quiet ? ' --quiet' : ''}`, {
|
|
60
|
+
encoding: 'utf8',
|
|
104
61
|
});
|
|
62
|
+
return result.trim();
|
|
105
63
|
}
|
|
106
64
|
catch (e) {
|
|
107
65
|
devkit_1.logger.error(`Failed to push ${imageReference}`);
|
|
@@ -30,6 +30,11 @@
|
|
|
30
30
|
"description": "Do not add dependencies to `package.json`.",
|
|
31
31
|
"type": "boolean",
|
|
32
32
|
"default": false
|
|
33
|
+
},
|
|
34
|
+
"addPlugin": {
|
|
35
|
+
"type": "boolean",
|
|
36
|
+
"description": "Add the plugin to the nx.json file.",
|
|
37
|
+
"default": true
|
|
33
38
|
}
|
|
34
39
|
},
|
|
35
40
|
"required": []
|
package/README.md
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
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 Repos · Fast Builds" src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-light.svg" width="100%">
|
|
5
|
-
</picture>
|
|
6
|
-
</p>
|
|
7
|
-
|
|
8
|
-
<div style="text-align: center;">
|
|
9
|
-
|
|
10
|
-
[](https://circleci.com/gh/nrwl/nx)
|
|
11
|
-
[]()
|
|
12
|
-
[](https://www.npmjs.com/package/nx)
|
|
13
|
-
[]()
|
|
14
|
-
[](http://commitizen.github.io/cz-cli/)
|
|
15
|
-
[](https://gitter.im/nrwl-nx/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
|
16
|
-
[](https://go.nx.dev/community)
|
|
17
|
-
|
|
18
|
-
</div>
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
<hr>
|
|
22
|
-
|
|
23
|
-
# Nx: Smart Repos · Fast Builds
|
|
24
|
-
|
|
25
|
-
An AI-first build platform that connects everything from your editor to CI. Helping you deliver fast, without breaking things.
|
|
26
|
-
|
|
27
|
-
This package is a [Docker plugin for Nx](https://nx.dev/nx-api/docker).
|
|
28
|
-
|
|
29
|
-
**Experimental**: Support for Docker is currently experimental. Breaking changes may occur and not adhere to semver versioning.
|
|
30
|
-
|
|
31
|
-
## Getting Started
|
|
32
|
-
|
|
33
|
-
### Creating an Nx Workspace
|
|
34
|
-
|
|
35
|
-
**Using `npx`**
|
|
36
|
-
|
|
37
|
-
```bash
|
|
38
|
-
npx create-nx-workspace
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
**Using `npm init`**
|
|
42
|
-
|
|
43
|
-
```bash
|
|
44
|
-
npm init nx-workspace
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
**Using `yarn create`**
|
|
48
|
-
|
|
49
|
-
```bash
|
|
50
|
-
yarn create nx-workspace
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
### Adding Nx to an Existing Repository
|
|
54
|
-
|
|
55
|
-
Run:
|
|
56
|
-
|
|
57
|
-
```bash
|
|
58
|
-
npx nx@latest init
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
## Documentation & Resources
|
|
62
|
-
|
|
63
|
-
- [Nx.Dev: Documentation, Guides, Tutorials](https://nx.dev)
|
|
64
|
-
- [Intro to Nx](https://nx.dev/getting-started/intro)
|
|
65
|
-
- [Official Nx YouTube Channel](https://www.youtube.com/@NxDevtools)
|
|
66
|
-
- [Blog Posts About Nx](https://nx.dev/blog)
|
|
67
|
-
|
|
68
|
-
<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"
|
|
69
|
-
width="100%" alt="Nx - Smart Repos · Fast Builds"></a></p>
|
|
70
|
-
|
package/generators.d.ts
DELETED
package/generators.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generators.d.ts","sourceRoot":"","sources":["../../../packages/docker/generators.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC"}
|
package/generators.js
DELETED