@payfit/nx-core 4.26.1 → 4.27.0
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 +1 -1
- package/src/executors/publisher/docker.js +2 -14
- package/src/executors/publisher/docker.js.map +1 -1
- package/src/utils/docker.js +4 -2
- package/src/utils/docker.js.map +1 -1
- package/src/utils/exec.d.ts +2 -2
- package/src/utils/exec.js +36 -3
- package/src/utils/exec.js.map +1 -1
package/package.json
CHANGED
|
@@ -32,25 +32,13 @@ async function publishDocker(options, context, version, projectRoot) {
|
|
|
32
32
|
await (0, docker_1.buildDockerImage)(options.ecrRegistry, projectDockerfile, version, await (0, github_1.getSanitizedCurrentGitRepoUrl)(), await (0, github_1.getCurrentGitCommitSha)(), registry);
|
|
33
33
|
logger_1.consola.success('Docker image built!');
|
|
34
34
|
logger_1.consola.start('Pushing docker image');
|
|
35
|
-
|
|
36
|
-
if (pushResult.exitCode !== 0) {
|
|
37
|
-
logger_1.consola.error(`Failed to push docker image to ECR registry ${registry}/${options.ecrRegistry} with version ${version} :\n ${pushResult.stderr}`);
|
|
38
|
-
return {
|
|
39
|
-
success: false,
|
|
40
|
-
};
|
|
41
|
-
}
|
|
35
|
+
await (0, docker_1.pushImageToEcr)(options.ecrRegistry, version, registry);
|
|
42
36
|
logger_1.consola.success('Docker image pushed successfully!');
|
|
43
37
|
// If the image is public, and the version is not ephemeral, we need to tag it as latest
|
|
44
38
|
if (options.isPublicRegistry && !version.includes('ephemeral')) {
|
|
45
39
|
logger_1.consola.start('Tagging docker image as latest');
|
|
46
40
|
await (0, docker_1.tagLatestImage)(registry, options.ecrRegistry, version);
|
|
47
|
-
|
|
48
|
-
if (tagResult.exitCode !== 0) {
|
|
49
|
-
logger_1.consola.error(`Failed to tag docker image as latest in ECR registry ${registry}/${options.ecrRegistry} :\n ${tagResult.stderr}`);
|
|
50
|
-
return {
|
|
51
|
-
success: false,
|
|
52
|
-
};
|
|
53
|
-
}
|
|
41
|
+
await (0, docker_1.pushImageToEcr)(options.ecrRegistry, 'latest', registry);
|
|
54
42
|
logger_1.consola.success('Docker image tagged as latest successfully!');
|
|
55
43
|
}
|
|
56
44
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"docker.js","sourceRoot":"","sources":["../../../../../../packages/nx-core/src/executors/publisher/docker.ts"],"names":[],"mappings":";;AAkBA,
|
|
1
|
+
{"version":3,"file":"docker.js","sourceRoot":"","sources":["../../../../../../packages/nx-core/src/executors/publisher/docker.ts"],"names":[],"mappings":";;AAkBA,sCA+DC;AAjFD,8BAA6B;AAI7B,mDAA+D;AAC/D,qDAA2D;AAC3D,+CAI2B;AAC3B,+CAG2B;AAC3B,+CAA4C;AAGrC,KAAK,UAAU,aAAa,CACjC,OAAiC,EACjC,OAAwB,EACxB,OAAe,EACf,WAAmB;IAInB,MAAM,iBAAiB,GAAG,GAAG,WAAW,aAAa,CAAA;IAErD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,iBAAiB,CAAC,EAAE,CAAC;QACtC,gBAAO,CAAC,IAAI,CAAC,2BAA2B,iBAAiB,gBAAgB,CAAC,CAAA;QAC1E,OAAO;YACL,OAAO,EAAE,IAAI;SACd,CAAA;IACH,CAAC;IACD,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;QACzB,gBAAO,CAAC,KAAK,CACX,mGAAmG,CACpG,CAAA;QACD,OAAO;YACL,OAAO,EAAE,KAAK;SACf,CAAA;IACH,CAAC;IAED,mEAAmE;IACnE,MAAM,QAAQ,GAAG,OAAO,CAAC,gBAAgB;QACvC,CAAC,CAAC,+BAAmB;QACrB,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAA;IAEhC,MAAM,IAAA,uBAAY,GAAE,CAAA;IACpB,MAAM,IAAA,qBAAU,EAAC,QAAQ,CAAC,CAAA;IAE1B,gBAAO,CAAC,GAAG,CACT,8BAA8B,QAAQ,IAAI,OAAO,CAAC,WAAW,iBAAiB,OAAO,EAAE,CACxF,CAAA;IAED,gBAAO,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAA;IACtC,MAAM,IAAA,yBAAgB,EACpB,OAAO,CAAC,WAAW,EACnB,iBAAiB,EACjB,OAAO,EACP,MAAM,IAAA,sCAA6B,GAAE,EACrC,MAAM,IAAA,+BAAsB,GAAE,EAC9B,QAAQ,CACT,CAAA;IACD,gBAAO,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAA;IAEtC,gBAAO,CAAC,KAAK,CAAC,sBAAsB,CAAC,CAAA;IACrC,MAAM,IAAA,uBAAc,EAAC,OAAO,CAAC,WAAW,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAA;IAC5D,gBAAO,CAAC,OAAO,CAAC,mCAAmC,CAAC,CAAA;IAEpD,wFAAwF;IACxF,IAAI,OAAO,CAAC,gBAAgB,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;QAC/D,gBAAO,CAAC,KAAK,CAAC,gCAAgC,CAAC,CAAA;QAC/C,MAAM,IAAA,uBAAc,EAAC,QAAQ,EAAE,OAAO,CAAC,WAAW,EAAE,OAAO,CAAC,CAAA;QAC5D,MAAM,IAAA,uBAAc,EAAC,OAAO,CAAC,WAAW,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAA;QAC7D,gBAAO,CAAC,OAAO,CAAC,6CAA6C,CAAC,CAAA;IAChE,CAAC;IAED,OAAO;QACL,OAAO,EAAE,IAAI;KACd,CAAA;AACH,CAAC"}
|
package/src/utils/docker.js
CHANGED
|
@@ -48,9 +48,11 @@ async function buildDockerImage(imageName, dockerfilePath, version, gitRepoUrl,
|
|
|
48
48
|
* @returns A promise that resolves to the result of the push command
|
|
49
49
|
*/
|
|
50
50
|
async function pushImageToEcr(repositoryName, version, registry) {
|
|
51
|
-
|
|
51
|
+
const dockerOrPodman = await getDockerOrPodman();
|
|
52
|
+
return (0, exec_1.exec)(`${dockerOrPodman} push ${registry}/${repositoryName}:${version}`);
|
|
52
53
|
}
|
|
53
54
|
async function tagLatestImage(repositoryName, version, registry) {
|
|
54
|
-
|
|
55
|
+
const dockerOrPodman = await getDockerOrPodman();
|
|
56
|
+
return (0, exec_1.exec)(`${dockerOrPodman} tag ${registry}/${repositoryName}:${version} ${registry}/${repositoryName}:latest`);
|
|
55
57
|
}
|
|
56
58
|
//# sourceMappingURL=docker.js.map
|
package/src/utils/docker.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"docker.js","sourceRoot":"","sources":["../../../../../packages/nx-core/src/utils/docker.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"docker.js","sourceRoot":"","sources":["../../../../../packages/nx-core/src/utils/docker.ts"],"names":[],"mappings":";;AASA,8CAQC;AAaD,4CAkBC;AAUD,wCAOC;AAED,wCASC;AA1ED,iCAA6B;AAE7B;;;;GAIG;AACI,KAAK,UAAU,iBAAiB;IACrC,IAAI,CAAC;QACH,MAAM,IAAA,WAAI,EAAC,kBAAkB,CAAC,CAAA;QAC9B,OAAO,QAAQ,CAAA;IACjB,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,GAAG,CAAC,iCAAiC,CAAC,CAAA;QAC9C,OAAO,QAAQ,CAAA;IACjB,CAAC;AACH,CAAC;AAED;;;;;;;;;;GAUG;AACI,KAAK,UAAU,gBAAgB,CACpC,SAAiB,EACjB,cAAsB,EACtB,OAAe,EACf,UAAkB,EAClB,SAAiB,EACjB,QAAgB;IAEhB,MAAM,cAAc,GAAG,MAAM,iBAAiB,EAAE,CAAA;IAChD,OAAO,IAAA,WAAI,EACT,GAAG,cAAc,oBAAoB,QAAQ,IAAI,SAAS,IAAI,OAAO,OAAO,cAAc,yEAAyE,UAAU,mDAAmD,SAAS,sCAAsC,UAAU,kCAAkC,SAAS,EAAE,EACtU,IAAI,EACJ;QACE,WAAW,EAAE;YACX,KAAK,EAAE,SAAS;SACjB;KACF,CACF,CAAA;AACH,CAAC;AAED;;;;;;;GAOG;AACI,KAAK,UAAU,cAAc,CAClC,cAAsB,EACtB,OAAe,EACf,QAAgB;IAEhB,MAAM,cAAc,GAAG,MAAM,iBAAiB,EAAE,CAAA;IAChD,OAAO,IAAA,WAAI,EAAC,GAAG,cAAc,SAAS,QAAQ,IAAI,cAAc,IAAI,OAAO,EAAE,CAAC,CAAA;AAChF,CAAC;AAEM,KAAK,UAAU,cAAc,CAClC,cAAsB,EACtB,OAAe,EACf,QAAgB;IAEhB,MAAM,cAAc,GAAG,MAAM,iBAAiB,EAAE,CAAA;IAChD,OAAO,IAAA,WAAI,EACT,GAAG,cAAc,QAAQ,QAAQ,IAAI,cAAc,IAAI,OAAO,IAAI,QAAQ,IAAI,cAAc,SAAS,CACtG,CAAA;AACH,CAAC"}
|
package/src/utils/exec.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Options } from 'tinyexec';
|
|
2
|
-
declare function execWrapperFromString(cmd: string, throwOnError?: boolean, options?: Partial<Options>):
|
|
1
|
+
import type { Options, Result } from 'tinyexec';
|
|
2
|
+
declare function execWrapperFromString(cmd: string, throwOnError?: boolean, options?: Partial<Options>): Result;
|
|
3
3
|
export declare const exec: typeof execWrapperFromString;
|
|
4
4
|
export {};
|
package/src/utils/exec.js
CHANGED
|
@@ -3,21 +3,54 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.exec = void 0;
|
|
4
4
|
const args_tokenizer_1 = require("args-tokenizer");
|
|
5
5
|
const tinyexec_1 = require("tinyexec");
|
|
6
|
+
const logger_1 = require("./logger");
|
|
6
7
|
function createLoggingExecWrapper(execFn) {
|
|
7
8
|
return (command, args = [], options = {}) => {
|
|
8
|
-
// consola.log(`Running '${command} ${args.join(' ')}'...`)
|
|
9
9
|
return execFn(command, args, options);
|
|
10
10
|
};
|
|
11
11
|
}
|
|
12
12
|
// Accepts a single string, splits it, and runs with logging
|
|
13
|
-
function execWrapperFromString(cmd, throwOnError =
|
|
13
|
+
function execWrapperFromString(cmd, throwOnError = false, options = {}) {
|
|
14
14
|
const [command, ...args] = (0, args_tokenizer_1.tokenizeArgs)(cmd);
|
|
15
15
|
// Remove throwOnError from options if present, to avoid conflicts
|
|
16
16
|
const { throwOnError: _, ...restOptions } = options;
|
|
17
|
-
|
|
17
|
+
const wrappedExec = createLoggingExecWrapper(tinyexec_1.x);
|
|
18
|
+
// Set throwOnError to false to handle errors ourselves
|
|
19
|
+
const result = wrappedExec(command, args, {
|
|
18
20
|
...restOptions,
|
|
19
21
|
throwOnError,
|
|
20
22
|
});
|
|
23
|
+
// Add a then handler to check for errors
|
|
24
|
+
// Use .then() with both success and error handlers
|
|
25
|
+
const processedResult = result.then(
|
|
26
|
+
// Success handler
|
|
27
|
+
output => {
|
|
28
|
+
// Check if the command failed
|
|
29
|
+
if (output.exitCode !== 0) {
|
|
30
|
+
// Log the error to have it visible in the console
|
|
31
|
+
// Throw if requested
|
|
32
|
+
if (throwOnError) {
|
|
33
|
+
throw new Error(`Command '${cmd}' failed with exit code ${output.exitCode}:\n ${output.stderr}`);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
logger_1.consola.error(`Command '${cmd}' failed with exit code ${output.exitCode} :\n ${output.stderr}`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return output;
|
|
40
|
+
},
|
|
41
|
+
// Error handler (instead of .catch())
|
|
42
|
+
error => {
|
|
43
|
+
// Don't log here to avoid double logging
|
|
44
|
+
if (throwOnError) {
|
|
45
|
+
throw error;
|
|
46
|
+
}
|
|
47
|
+
// If we don't throw, return a rejected promise with the error
|
|
48
|
+
return Promise.reject(error);
|
|
49
|
+
});
|
|
50
|
+
// Create a new object that combines the original result (for OutputApi methods)
|
|
51
|
+
// with the processed promise result (for then/catch behavior)
|
|
52
|
+
const combinedResult = Object.assign(Object.create(Object.getPrototypeOf(result)), result, { then: processedResult.then.bind(processedResult) });
|
|
53
|
+
return combinedResult;
|
|
21
54
|
}
|
|
22
55
|
exports.exec = execWrapperFromString;
|
|
23
56
|
//# sourceMappingURL=exec.js.map
|
package/src/utils/exec.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exec.js","sourceRoot":"","sources":["../../../../../packages/nx-core/src/utils/exec.ts"],"names":[],"mappings":";;;AAEA,mDAA6C;
|
|
1
|
+
{"version":3,"file":"exec.js","sourceRoot":"","sources":["../../../../../packages/nx-core/src/utils/exec.ts"],"names":[],"mappings":";;;AAEA,mDAA6C;AAC7C,uCAA4B;AAE5B,qCAAkC;AAElC,SAAS,wBAAwB,CAAC,MAAgB;IAChD,OAAO,CACL,OAAe,EACf,OAAiB,EAAE,EACnB,UAA4B,EAAE,EAC9B,EAAE;QACF,OAAO,MAAM,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,CAAA;IACvC,CAAC,CAAA;AACH,CAAC;AAED,4DAA4D;AAC5D,SAAS,qBAAqB,CAC5B,GAAW,EACX,YAAY,GAAG,KAAK,EACpB,UAA4B,EAAE;IAE9B,MAAM,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,GAAG,IAAA,6BAAY,EAAC,GAAG,CAAC,CAAA;IAC5C,kEAAkE;IAClE,MAAM,EAAE,YAAY,EAAE,CAAC,EAAE,GAAG,WAAW,EAAE,GAAG,OAAO,CAAA;IAEnD,MAAM,WAAW,GAAG,wBAAwB,CAAC,YAAC,CAAC,CAAA;IAE/C,uDAAuD;IACvD,MAAM,MAAM,GAAG,WAAW,CAAC,OAAO,EAAE,IAAI,EAAE;QACxC,GAAG,WAAW;QACd,YAAY;KACb,CAAC,CAAA;IAEF,yCAAyC;IACzC,mDAAmD;IACnD,MAAM,eAAe,GAAG,MAAM,CAAC,IAAI;IACjC,kBAAkB;IAClB,MAAM,CAAC,EAAE;QACP,8BAA8B;QAC9B,IAAI,MAAM,CAAC,QAAQ,KAAK,CAAC,EAAE,CAAC;YAC1B,kDAAkD;YAClD,qBAAqB;YACrB,IAAI,YAAY,EAAE,CAAC;gBACjB,MAAM,IAAI,KAAK,CACb,YAAY,GAAG,2BAA2B,MAAM,CAAC,QAAQ,OAAO,MAAM,CAAC,MAAM,EAAE,CAChF,CAAA;YACH,CAAC;iBAAM,CAAC;gBACN,gBAAO,CAAC,KAAK,CACX,YAAY,GAAG,2BAA2B,MAAM,CAAC,QAAQ,QAAQ,MAAM,CAAC,MAAM,EAAE,CACjF,CAAA;YACH,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAA;IACf,CAAC;IACD,sCAAsC;IACtC,KAAK,CAAC,EAAE;QACN,yCAAyC;QACzC,IAAI,YAAY,EAAE,CAAC;YACjB,MAAM,KAAK,CAAA;QACb,CAAC;QAED,8DAA8D;QAC9D,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;IAC9B,CAAC,CACF,CAAA;IAED,gFAAgF;IAChF,8DAA8D;IAC9D,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAClC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,EAC5C,MAAM,EACN,EAAE,IAAI,EAAE,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,EAAE,CACrD,CAAA;IAED,OAAO,cAAwB,CAAA;AACjC,CAAC;AAEY,QAAA,IAAI,GAAG,qBAAqB,CAAA"}
|