@nx/docker 0.0.0-pr-32120-8333cfc → 0.0.0-pr-32149-2d2cbf3

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/index.d.ts CHANGED
@@ -1,3 +1,2 @@
1
1
  export { createNodesV2, DockerPluginOptions } from './src/plugins/plugin';
2
- export { initGenerator } from './src/generators/init/init';
3
2
  //# sourceMappingURL=index.d.ts.map
package/index.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../packages/docker/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../packages/docker/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC"}
package/index.js CHANGED
@@ -1,7 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.initGenerator = exports.createNodesV2 = void 0;
3
+ exports.createNodesV2 = void 0;
4
4
  var plugin_1 = require("./src/plugins/plugin");
5
5
  Object.defineProperty(exports, "createNodesV2", { enumerable: true, get: function () { return plugin_1.createNodesV2; } });
6
- var init_1 = require("./src/generators/init/init");
7
- Object.defineProperty(exports, "initGenerator", { enumerable: true, get: function () { return init_1.initGenerator; } });
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-32120-8333cfc",
4
+ "version": "0.0.0-pr-32149-2d2cbf3",
5
5
  "type": "commonjs",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -43,12 +43,12 @@
43
43
  "executors": "./executors.json",
44
44
  "generators": "./generators.json",
45
45
  "dependencies": {
46
- "@nx/devkit": "0.0.0-pr-32120-8333cfc",
46
+ "@nx/devkit": "0.0.0-pr-32149-2d2cbf3",
47
47
  "enquirer": "~2.3.6",
48
48
  "tslib": "^2.3.0"
49
49
  },
50
50
  "devDependencies": {
51
- "nx": "0.0.0-pr-32120-8333cfc"
51
+ "nx": "0.0.0-pr-32149-2d2cbf3"
52
52
  },
53
53
  "types": "./src/index.d.ts"
54
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;;GAiBzB"}
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;;GAmBzB"}
@@ -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 = normalizeOptions(projectConfig, schema);
12
+ const options = await normalizeOptions(projectConfig, schema);
13
13
  if (!options.dryRun) {
14
- const digest = dockerPush(options.imageReference, options.quiet);
15
- devkit_1.logger.log(`Successfully pushed ${options.imageReference}. Digest: ${digest}`);
14
+ const digest = await dockerPush(options.imageReference, options.quiet);
15
+ devkit_1.logger.log(`Successfully pushed ${options.imageReference}. ${options.quiet && `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
- function normalizeOptions(projectConfig, schema) {
24
+ async function normalizeOptions(projectConfig, schema) {
25
25
  return {
26
26
  quiet: schema.quiet ?? false,
27
- imageReference: findImageReference(projectConfig, schema),
27
+ imageReference: await findImageReference(projectConfig, schema),
28
28
  dryRun: process.env.NX_DRY_RUN === 'true' || schema.dryRun || false,
29
29
  };
30
30
  }
31
- function findImageReference(projectConfig, schema) {
31
+ async function findImageReference(projectConfig, schema) {
32
32
  let imageRef = readVersionFromFile(projectConfig.data.root);
33
33
  if (imageRef) {
34
- if (checkDockerImageExistsLocally(imageRef)) {
34
+ if (await 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,21 +45,47 @@ function readVersionFromFile(projectRoot) {
45
45
  const version = (0, fs_1.readFileSync)(versionFilePath, { encoding: 'utf8' });
46
46
  return version.trim();
47
47
  }
48
- function checkDockerImageExistsLocally(imageRef) {
48
+ async function checkDockerImageExistsLocally(imageRef) {
49
49
  try {
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;
50
+ return await new Promise((res) => {
51
+ const childProcess = (0, child_process_1.exec)(`docker images --filter "reference=${imageRef}" --quiet`, { encoding: 'utf8' });
52
+ let result = '';
53
+ childProcess.stdout?.on('data', (data) => {
54
+ result += data;
55
+ });
56
+ childProcess.stderr?.on('data', (data) => {
57
+ console.error(data);
58
+ });
59
+ childProcess.on('exit', () => {
60
+ res(result.trim().length > 0);
61
+ });
62
+ });
52
63
  }
53
64
  catch {
54
65
  return false;
55
66
  }
56
67
  }
57
- function dockerPush(imageReference, quiet) {
68
+ async function dockerPush(imageReference, quiet) {
58
69
  try {
59
- const result = (0, child_process_1.execSync)(`docker push ${imageReference}${quiet ? ' --quiet' : ''}`, {
60
- encoding: 'utf8',
70
+ return await new Promise((res) => {
71
+ const childProcess = (0, child_process_1.exec)(`docker push ${imageReference}${quiet ? ' --quiet' : ''}`, {
72
+ encoding: 'utf8',
73
+ maxBuffer: exports.LARGE_BUFFER,
74
+ });
75
+ let result = '';
76
+ childProcess.stdout?.on('data', (data) => {
77
+ result += data;
78
+ if (!quiet) {
79
+ console.log(data);
80
+ }
81
+ });
82
+ childProcess.stderr?.on('data', (data) => {
83
+ console.error(data);
84
+ });
85
+ childProcess.on('exit', () => {
86
+ res(result.trim());
87
+ });
61
88
  });
62
- return result.trim();
63
89
  }
64
90
  catch (e) {
65
91
  devkit_1.logger.error(`Failed to push ${imageReference}`);
@@ -4,4 +4,5 @@ export interface InitGeneratorSchema {
4
4
  updatePackageScripts?: boolean;
5
5
  skipFormat?: boolean;
6
6
  skipPackageJson?: boolean;
7
+ addPlugin?: boolean;
7
8
  }
@@ -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": []