@payfit/nx-core 4.10.0-ephemeral.0 → 4.10.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/README.md +2 -1
- package/dist/src/executors/publisher/docker.d.ts +5 -0
- package/dist/src/executors/publisher/docker.js +21 -0
- package/dist/src/executors/publisher/docker.js.map +1 -0
- package/dist/src/executors/publisher/executor.d.ts +4 -0
- package/dist/src/executors/publisher/executor.js +23 -0
- package/dist/src/executors/publisher/executor.js.map +1 -0
- package/dist/src/executors/publisher/helm.d.ts +7 -0
- package/dist/src/executors/publisher/helm.js +40 -0
- package/dist/src/executors/publisher/helm.js.map +1 -0
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.js +62 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/scripts/version-actions.d.ts +25 -0
- package/dist/src/scripts/version-actions.js +59 -0
- package/dist/src/scripts/version-actions.js.map +1 -0
- package/dist/src/utils/aws-auth.d.ts +39 -0
- package/dist/src/utils/aws-auth.js +84 -0
- package/dist/src/utils/aws-auth.js.map +1 -0
- package/{src/utils/docker.ts → dist/src/utils/docker.d.ts} +6 -22
- package/dist/src/utils/docker.js +33 -0
- package/dist/src/utils/docker.js.map +1 -0
- package/dist/src/utils/exec.d.ts +7 -0
- package/dist/src/utils/exec.js +25 -0
- package/dist/src/utils/exec.js.map +1 -0
- package/dist/src/utils/get-version.d.ts +6 -0
- package/dist/src/utils/get-version.js +14 -0
- package/dist/src/utils/get-version.js.map +1 -0
- package/dist/src/utils/github.d.ts +4 -0
- package/dist/src/utils/github.js +17 -0
- package/dist/src/utils/github.js.map +1 -0
- package/dist/src/utils/helm.d.ts +48 -0
- package/dist/src/utils/helm.js +91 -0
- package/dist/src/utils/helm.js.map +1 -0
- package/dist/src/utils/import-esm.d.ts +2 -0
- package/dist/src/utils/import-esm.js +12 -0
- package/dist/src/utils/import-esm.js.map +1 -0
- package/dist/src/utils/tsh.d.ts +10 -0
- package/dist/src/utils/tsh.js +107 -0
- package/dist/src/utils/tsh.js.map +1 -0
- package/package.json +24 -7
- package/.env.test +0 -0
- package/eslint.config.mjs +0 -31
- package/project.json +0 -43
- package/src/executors/publisher/docker.ts +0 -34
- package/src/executors/publisher/executor.ts +0 -30
- package/src/executors/publisher/helm.ts +0 -55
- package/src/index.ts +0 -77
- package/src/scripts/version-action.ts +0 -89
- package/src/utils/aws-auth.ts +0 -100
- package/src/utils/exec.spec.ts +0 -16
- package/src/utils/exec.ts +0 -31
- package/src/utils/get-version.ts +0 -11
- package/src/utils/github.ts +0 -14
- package/src/utils/helm.ts +0 -125
- package/src/utils/import-esm.ts +0 -10
- package/src/utils/tsh.ts +0 -127
- package/tsconfig.json +0 -19
- package/tsconfig.lib.json +0 -22
- package/tsconfig.spec.json +0 -28
- package/vite.config.ts +0 -28
- /package/{src → dist/src}/executors/publisher/schema.d.ts +0 -0
- /package/{src → dist/src}/executors/publisher/schema.json +0 -0
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# nx-core
|
|
1
|
+
# nx-core packagee
|
|
2
2
|
|
|
3
3
|
This library was generated with [Nx](https://nx.dev).
|
|
4
4
|
|
|
@@ -13,6 +13,7 @@ yarn add -D @payfit/nx-core
|
|
|
13
13
|
## Building
|
|
14
14
|
|
|
15
15
|
Run `nx build nx-core` to build the library.
|
|
16
|
+
The build artifacts will be stored in the `dist/packages/nx-core` directory.
|
|
16
17
|
|
|
17
18
|
## Running unit tests
|
|
18
19
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.publishDocker = publishDocker;
|
|
4
|
+
const fs = require("node:fs");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const aws_auth_1 = require("../../utils/aws-auth");
|
|
7
|
+
const docker_1 = require("../../utils/docker");
|
|
8
|
+
async function publishDocker(options, context, version) {
|
|
9
|
+
await (0, aws_auth_1.checkAwsAuth)();
|
|
10
|
+
await (0, aws_auth_1.loginToEcr)();
|
|
11
|
+
const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
|
|
12
|
+
const projectDockerfile = (0, path_1.join)(projectRoot, 'Dockerfile');
|
|
13
|
+
if (!fs.existsSync(projectDockerfile)) {
|
|
14
|
+
throw new Error('Dockerfile not found in project root');
|
|
15
|
+
}
|
|
16
|
+
console.log('Building docker image with version ' + version);
|
|
17
|
+
await (0, docker_1.buildDockerImage)(options.ecrRegistry, projectDockerfile, version);
|
|
18
|
+
console.log(`Publishing docker image to ${options.ecrRegistry} with version ${version}`);
|
|
19
|
+
return await (0, aws_auth_1.pushImageToEcr)(options.ecrRegistry, version);
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=docker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docker.js","sourceRoot":"","sources":["../../../../src/executors/publisher/docker.ts"],"names":[],"mappings":";;AASA,sCAwBC;AAjCD,8BAA6B;AAC7B,+BAA2B;AAI3B,mDAA+E;AAC/E,+CAAqD;AAG9C,KAAK,UAAU,aAAa,CACjC,OAAiC,EACjC,OAAwB,EACxB,OAAe;IAIf,MAAM,IAAA,uBAAY,GAAE,CAAA;IACpB,MAAM,IAAA,qBAAU,GAAE,CAAA;IAElB,MAAM,WAAW,GACf,OAAO,CAAC,sBAAsB,CAAC,QAAQ,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,IAAI,CAAA;IACnE,MAAM,iBAAiB,GAAG,IAAA,WAAI,EAAC,WAAW,EAAE,YAAY,CAAC,CAAA;IAEzD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,iBAAiB,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAA;IACzD,CAAC;IACD,OAAO,CAAC,GAAG,CAAC,qCAAqC,GAAG,OAAO,CAAC,CAAA;IAC5D,MAAM,IAAA,yBAAgB,EAAC,OAAO,CAAC,WAAW,EAAE,iBAAiB,EAAE,OAAO,CAAC,CAAA;IAEvE,OAAO,CAAC,GAAG,CACT,8BAA8B,OAAO,CAAC,WAAW,iBAAiB,OAAO,EAAE,CAC5E,CAAA;IACD,OAAO,MAAM,IAAA,yBAAc,EAAC,OAAO,CAAC,WAAW,EAAE,OAAO,CAAC,CAAA;AAC3D,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ExecutorContext } from '@nx/devkit';
|
|
2
|
+
import { PublisherExecutorOptions, PublisherExecutorSchema } from './schema';
|
|
3
|
+
declare const runExecutor: (options: PublisherExecutorOptions, context: ExecutorContext) => Promise<PublisherExecutorSchema>;
|
|
4
|
+
export default runExecutor;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const get_version_1 = require("../../utils/get-version");
|
|
4
|
+
const docker_1 = require("./docker");
|
|
5
|
+
const helm_1 = require("./helm");
|
|
6
|
+
const runExecutor = async (options, context) => {
|
|
7
|
+
try {
|
|
8
|
+
const version = (0, get_version_1.getVersion)(context.projectName);
|
|
9
|
+
await (0, docker_1.publishDocker)(options, context, version);
|
|
10
|
+
await (0, helm_1.publishHelm)(options, context, version);
|
|
11
|
+
}
|
|
12
|
+
catch (error) {
|
|
13
|
+
console.error(error);
|
|
14
|
+
return {
|
|
15
|
+
success: false,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
success: true,
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
exports.default = runExecutor;
|
|
23
|
+
//# sourceMappingURL=executor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../../src/executors/publisher/executor.ts"],"names":[],"mappings":";;AAEA,yDAAoD;AACpD,qCAAwC;AACxC,iCAAoC;AAGpC,MAAM,WAAW,GAGuB,KAAK,EAC3C,OAAiC,EACjC,OAAwB,EACxB,EAAE;IACF,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,IAAA,wBAAU,EAAC,OAAO,CAAC,WAAW,CAAC,CAAA;QAC/C,MAAM,IAAA,sBAAa,EAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAA;QAC9C,MAAM,IAAA,kBAAW,EAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAA;IAC9C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QACpB,OAAO;YACL,OAAO,EAAE,KAAK;SACf,CAAA;IACH,CAAC;IACD,OAAO;QACL,OAAO,EAAE,IAAI;KACd,CAAA;AACH,CAAC,CAAA;AAED,kBAAe,WAAW,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ExecutorContext } from '@nx/devkit';
|
|
2
|
+
import { PublisherExecutorOptions } from './schema';
|
|
3
|
+
export declare function publishHelm(options: PublisherExecutorOptions, context: ExecutorContext, version: string): Promise<{
|
|
4
|
+
success: boolean;
|
|
5
|
+
stdout: any;
|
|
6
|
+
stderr: any;
|
|
7
|
+
}>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.publishHelm = publishHelm;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const fs = require("node:fs");
|
|
6
|
+
const aws_auth_1 = require("../../utils/aws-auth");
|
|
7
|
+
const github_1 = require("../../utils/github");
|
|
8
|
+
const helm_1 = require("../../utils/helm");
|
|
9
|
+
const tsh_1 = require("../../utils/tsh");
|
|
10
|
+
async function publishHelm(options, context, version) {
|
|
11
|
+
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
12
|
+
try {
|
|
13
|
+
const projectHelmFolder = `apps/${context.projectName}/.deploy`;
|
|
14
|
+
const destinationHelmFolder = `dist/apps/${context.projectName}/chart/`;
|
|
15
|
+
const gitBranchName = await (0, github_1.getSanitizedCurrentGitBranch)();
|
|
16
|
+
if (!gitBranchName)
|
|
17
|
+
throw new Error('Unable to get current Git branch');
|
|
18
|
+
await (0, aws_auth_1.checkAwsAuth)();
|
|
19
|
+
if (!fs.existsSync(projectHelmFolder)) {
|
|
20
|
+
throw new Error(`.deploy folder not found for project ${context.projectName}`);
|
|
21
|
+
}
|
|
22
|
+
console.log(`Publishing Helm chart to ${options.chartRegistry}/${gitBranchName} with version ${version}`);
|
|
23
|
+
// connect to the chartmuseum through teleport
|
|
24
|
+
const proxyData = tslib_1.__addDisposableResource(env_1, await (0, tsh_1.getLocalPortForChartMuseum)(), false);
|
|
25
|
+
await proxyData.isReady();
|
|
26
|
+
await (0, helm_1.setupTeleportProxyHelmChartFile)(projectHelmFolder, proxyData.port);
|
|
27
|
+
await (0, helm_1.installHelmRepo)(projectHelmFolder);
|
|
28
|
+
await (0, helm_1.packageHelm)(projectHelmFolder, version, destinationHelmFolder);
|
|
29
|
+
await (0, helm_1.resetTeleportProxyHelmChartFile)(projectHelmFolder, proxyData.port);
|
|
30
|
+
return (0, helm_1.pushPackagedHelm)(`${destinationHelmFolder}${context.projectName}-${version}.tgz`, options.chartRegistry, gitBranchName);
|
|
31
|
+
}
|
|
32
|
+
catch (e_1) {
|
|
33
|
+
env_1.error = e_1;
|
|
34
|
+
env_1.hasError = true;
|
|
35
|
+
}
|
|
36
|
+
finally {
|
|
37
|
+
tslib_1.__disposeResources(env_1);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=helm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helm.js","sourceRoot":"","sources":["../../../../src/executors/publisher/helm.ts"],"names":[],"mappings":";;AAgBA,kCAsCC;;AAtDD,8BAA6B;AAI7B,mDAAmD;AACnD,+CAAiE;AACjE,2CAMyB;AACzB,yCAA4D;AAGrD,KAAK,UAAU,WAAW,CAC/B,OAAiC,EACjC,OAAwB,EACxB,OAAe;;;QAMf,MAAM,iBAAiB,GAAG,QAAQ,OAAO,CAAC,WAAW,UAAU,CAAA;QAC/D,MAAM,qBAAqB,GAAG,aAAa,OAAO,CAAC,WAAW,SAAS,CAAA;QACvE,MAAM,aAAa,GAAG,MAAM,IAAA,qCAA4B,GAAE,CAAA;QAE1D,IAAI,CAAC,aAAa;YAAE,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAA;QAEvE,MAAM,IAAA,uBAAY,GAAE,CAAA;QAEpB,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,iBAAiB,CAAC,EAAE,CAAC;YACtC,MAAM,IAAI,KAAK,CACb,wCAAwC,OAAO,CAAC,WAAW,EAAE,CAC9D,CAAA;QACH,CAAC;QACD,OAAO,CAAC,GAAG,CACT,4BAA4B,OAAO,CAAC,aAAa,IAAI,aAAa,iBAAiB,OAAO,EAAE,CAC7F,CAAA;QACD,8CAA8C;QAC9C,MAAM,SAAS,0CAAG,MAAM,IAAA,gCAA0B,GAAE,QAAA,CAAA;QACpD,MAAM,SAAS,CAAC,OAAO,EAAE,CAAA;QAEzB,MAAM,IAAA,sCAA+B,EAAC,iBAAiB,EAAE,SAAS,CAAC,IAAI,CAAC,CAAA;QACxE,MAAM,IAAA,sBAAe,EAAC,iBAAiB,CAAC,CAAA;QACxC,MAAM,IAAA,kBAAW,EAAC,iBAAiB,EAAE,OAAO,EAAE,qBAAqB,CAAC,CAAA;QACpE,MAAM,IAAA,sCAA+B,EAAC,iBAAiB,EAAE,SAAS,CAAC,IAAI,CAAC,CAAA;QACxE,OAAO,IAAA,uBAAgB,EACrB,GAAG,qBAAqB,GAAG,OAAO,CAAC,WAAW,IAAI,OAAO,MAAM,EAC/D,OAAO,CAAC,aAAa,EACrB,aAAa,CACd,CAAA;;;;;;;;;CACF"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createNodesV2 = void 0;
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const devkit_1 = require("@nx/devkit");
|
|
7
|
+
exports.createNodesV2 = [
|
|
8
|
+
'**/project.json',
|
|
9
|
+
async (configFiles, options, context) => {
|
|
10
|
+
return await (0, devkit_1.createNodesFromFiles)((configFile, options, context) => createNodesInternal(configFile, options, context), configFiles, options, context);
|
|
11
|
+
},
|
|
12
|
+
];
|
|
13
|
+
async function createNodesInternal(configFilePath, options, context) {
|
|
14
|
+
const projectConfiguration = (0, devkit_1.readJsonFile)(configFilePath);
|
|
15
|
+
const projectRoot = (0, path_1.dirname)(configFilePath);
|
|
16
|
+
const isDockerProject = (0, fs_1.existsSync)((0, path_1.join)(projectRoot, 'Dockerfile'));
|
|
17
|
+
const isHelmProject = (0, fs_1.existsSync)((0, path_1.join)(projectRoot, '.deploy/Chart.yaml'));
|
|
18
|
+
const targets = {};
|
|
19
|
+
const ecrRegistry = isDockerProject
|
|
20
|
+
? projectConfiguration.metadata &&
|
|
21
|
+
projectConfiguration.metadata['ecrRepository']
|
|
22
|
+
: undefined;
|
|
23
|
+
const chartRegistry = isHelmProject
|
|
24
|
+
? projectConfiguration.metadata &&
|
|
25
|
+
projectConfiguration.metadata['chartRegistry']
|
|
26
|
+
: undefined;
|
|
27
|
+
let release = null;
|
|
28
|
+
if (isHelmProject || isDockerProject) {
|
|
29
|
+
const publisherConfig = (0, devkit_1.readJsonFile)((0, path_1.join)(__dirname, '/executors/publisher/schema.json'));
|
|
30
|
+
targets['nx-release-publish'] = {
|
|
31
|
+
// infer the custom publisher target to handle publishing docker & helm artefacts
|
|
32
|
+
executor: '@payfit/nx-core:publisher',
|
|
33
|
+
options: {
|
|
34
|
+
ecrRegistry,
|
|
35
|
+
chartRegistry,
|
|
36
|
+
},
|
|
37
|
+
cache: true,
|
|
38
|
+
inputs: ['production', '^production'],
|
|
39
|
+
outputs: [`{workspaceRoot}/dist/apps/${projectConfiguration.name}/chart`],
|
|
40
|
+
metadata: {
|
|
41
|
+
technologies: ['helm', 'docker'],
|
|
42
|
+
description: publisherConfig.description,
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
release = {
|
|
46
|
+
// infer the version actions to handle the custom versioning
|
|
47
|
+
version: {
|
|
48
|
+
versionActions: '@payfit/nx-core/versionActions',
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
projects: {
|
|
54
|
+
[projectRoot]: {
|
|
55
|
+
...projectConfiguration,
|
|
56
|
+
targets,
|
|
57
|
+
release,
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,2BAA+B;AAC/B,+BAAoC;AAEpC,uCAKmB;AAKN,QAAA,aAAa,GAAmC;IAC3D,iBAAiB;IACjB,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE;QACtC,OAAO,MAAM,IAAA,6BAAoB,EAC/B,CAAC,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,CAC/B,mBAAmB,CAAC,UAAU,EAAE,OAAO,EAAE,OAAO,CAAC,EACnD,WAAW,EACX,OAAO,EACP,OAAO,CACR,CAAA;IACH,CAAC;CACF,CAAA;AAED,KAAK,UAAU,mBAAmB,CAChC,cAAsB,EACtB,OAAwB,EACxB,OAA6B;IAE7B,MAAM,oBAAoB,GAAG,IAAA,qBAAY,EAAC,cAAc,CAAC,CAAA;IACzD,MAAM,WAAW,GAAG,IAAA,cAAO,EAAC,cAAc,CAAC,CAAA;IAE3C,MAAM,eAAe,GAAG,IAAA,eAAU,EAAC,IAAA,WAAI,EAAC,WAAW,EAAE,YAAY,CAAC,CAAC,CAAA;IACnE,MAAM,aAAa,GAAG,IAAA,eAAU,EAAC,IAAA,WAAI,EAAC,WAAW,EAAE,oBAAoB,CAAC,CAAC,CAAA;IAEzE,MAAM,OAAO,GAAG,EAAE,CAAA;IAElB,MAAM,WAAW,GAAG,eAAe;QACjC,CAAC,CAAC,oBAAoB,CAAC,QAAQ;YAC7B,oBAAoB,CAAC,QAAQ,CAAC,eAAe,CAAC;QAChD,CAAC,CAAC,SAAS,CAAA;IACb,MAAM,aAAa,GAAG,aAAa;QACjC,CAAC,CAAC,oBAAoB,CAAC,QAAQ;YAC7B,oBAAoB,CAAC,QAAQ,CAAC,eAAe,CAAC;QAChD,CAAC,CAAC,SAAS,CAAA;IAEb,IAAI,OAAO,GAAG,IAAI,CAAA;IAElB,IAAI,aAAa,IAAI,eAAe,EAAE,CAAC;QACrC,MAAM,eAAe,GAAG,IAAA,qBAAY,EAClC,IAAA,WAAI,EAAC,SAAS,EAAE,kCAAkC,CAAC,CACpD,CAAA;QACD,OAAO,CAAC,oBAAoB,CAAC,GAAG;YAC9B,iFAAiF;YACjF,QAAQ,EAAE,2BAA2B;YACrC,OAAO,EAAE;gBACP,WAAW;gBACX,aAAa;aACd;YACD,KAAK,EAAE,IAAI;YACX,MAAM,EAAE,CAAC,YAAY,EAAE,aAAa,CAAC;YACrC,OAAO,EAAE,CAAC,6BAA6B,oBAAoB,CAAC,IAAI,QAAQ,CAAC;YACzE,QAAQ,EAAE;gBACR,YAAY,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC;gBAChC,WAAW,EAAE,eAAe,CAAC,WAAW;aACzC;SACF,CAAA;QACD,OAAO,GAAG;YACR,4DAA4D;YAC5D,OAAO,EAAE;gBACP,cAAc,EAAE,gCAAgC;aACjD;SACF,CAAA;IACH,CAAC;IAED,OAAO;QACL,QAAQ,EAAE;YACR,CAAC,WAAW,CAAC,EAAE;gBACb,GAAG,oBAAoB;gBACvB,OAAO;gBACP,OAAO;aACR;SACF;KACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ProjectGraph, Tree } from '@nx/devkit';
|
|
2
|
+
import { VersionActions } from 'nx/release';
|
|
3
|
+
import { NxReleaseVersionConfiguration } from 'nx/src/config/nx-json';
|
|
4
|
+
export default class customVersionAction extends VersionActions {
|
|
5
|
+
validManifestFilenames: string[];
|
|
6
|
+
readCurrentVersionFromSourceManifest(tree: Tree): Promise<{
|
|
7
|
+
currentVersion: string;
|
|
8
|
+
manifestPath: string;
|
|
9
|
+
} | null>;
|
|
10
|
+
readCurrentVersionFromRegistry(tree: Tree, currentVersionResolverMetadata: NxReleaseVersionConfiguration['currentVersionResolverMetadata']): Promise<{
|
|
11
|
+
currentVersion: string | null;
|
|
12
|
+
logText: string;
|
|
13
|
+
} | null>;
|
|
14
|
+
readCurrentVersionOfDependency(tree: Tree, projectGraph: ProjectGraph, dependencyProjectName: string): Promise<{
|
|
15
|
+
currentVersion: string | null;
|
|
16
|
+
dependencyCollection: string | null;
|
|
17
|
+
}>;
|
|
18
|
+
isLocalDependencyProtocol(versionSpecifier: string): Promise<boolean>;
|
|
19
|
+
updateProjectVersion(tree: Tree, newVersion: string): Promise<string[]>;
|
|
20
|
+
updateProjectDependencies(tree: Tree, projectGraph: ProjectGraph, dependenciesToUpdate: Record<string, string>): Promise<string[]>;
|
|
21
|
+
calculateNewVersion(currentVersion: string | null, newVersionInput: string, newVersionInputReason: string, newVersionInputReasonData: Record<string, unknown>, preid: string): Promise<{
|
|
22
|
+
newVersion: string;
|
|
23
|
+
logText: string;
|
|
24
|
+
}>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const release_1 = require("nx/release");
|
|
4
|
+
const semver_1 = require("semver");
|
|
5
|
+
class customVersionAction extends release_1.VersionActions {
|
|
6
|
+
async readCurrentVersionFromSourceManifest(tree) {
|
|
7
|
+
return {
|
|
8
|
+
currentVersion: '0.0.0',
|
|
9
|
+
manifestPath: 'apps/my-nest-app/project.json',
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
async readCurrentVersionFromRegistry(tree, currentVersionResolverMetadata) {
|
|
13
|
+
return {
|
|
14
|
+
currentVersion: '0.0.0',
|
|
15
|
+
logText: 'Current version from registry',
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
async readCurrentVersionOfDependency(tree, projectGraph, dependencyProjectName) {
|
|
19
|
+
return {
|
|
20
|
+
currentVersion: '0.0.0',
|
|
21
|
+
dependencyCollection: '0.0.0',
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
async isLocalDependencyProtocol(versionSpecifier) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
async updateProjectVersion(tree, newVersion) {
|
|
28
|
+
// Update the version in the VERSION file
|
|
29
|
+
const currentProject = this.projectGraphNode.name;
|
|
30
|
+
const versionFilePath = `dist/apps/${currentProject}/VERSION`;
|
|
31
|
+
tree.write(versionFilePath, newVersion);
|
|
32
|
+
return [];
|
|
33
|
+
}
|
|
34
|
+
async updateProjectDependencies(tree, projectGraph, dependenciesToUpdate) {
|
|
35
|
+
return [];
|
|
36
|
+
}
|
|
37
|
+
async calculateNewVersion(currentVersion, newVersionInput, newVersionInputReason, newVersionInputReasonData, preid) {
|
|
38
|
+
function formatDate() {
|
|
39
|
+
const date = new Date();
|
|
40
|
+
const year = date.getFullYear();
|
|
41
|
+
const month = String(date.getMonth() + 1).padStart(2, '0'); // getMonth() returns 0-11
|
|
42
|
+
const day = date.getDate();
|
|
43
|
+
return `${year}${month}.${day}.`;
|
|
44
|
+
}
|
|
45
|
+
function getNewVersionFromCurrentVersion(currentVersion) {
|
|
46
|
+
const expectedPattern = formatDate();
|
|
47
|
+
return !currentVersion.startsWith(expectedPattern)
|
|
48
|
+
? `${expectedPattern}0`
|
|
49
|
+
: (0, semver_1.inc)(currentVersion, 'patch');
|
|
50
|
+
}
|
|
51
|
+
const finalVersion = `${getNewVersionFromCurrentVersion(currentVersion)}${preid.trim() ? '-' + preid : ''}`;
|
|
52
|
+
return {
|
|
53
|
+
newVersion: finalVersion,
|
|
54
|
+
logText: `New version: ${finalVersion}`,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.default = customVersionAction;
|
|
59
|
+
//# sourceMappingURL=version-actions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version-actions.js","sourceRoot":"","sources":["../../../src/scripts/version-actions.ts"],"names":[],"mappings":";;AACA,wCAA2C;AAE3C,mCAA4B;AAE5B,MAAqB,mBAAoB,SAAQ,wBAAc;IAE7D,KAAK,CAAC,oCAAoC,CACxC,IAAU;QAEV,OAAO;YACL,cAAc,EAAE,OAAO;YACvB,YAAY,EAAE,+BAA+B;SAC9C,CAAA;IACH,CAAC;IACD,KAAK,CAAC,8BAA8B,CAClC,IAAU,EACV,8BAA+F;QAE/F,OAAO;YACL,cAAc,EAAE,OAAO;YACvB,OAAO,EAAE,+BAA+B;SACzC,CAAA;IACH,CAAC;IACD,KAAK,CAAC,8BAA8B,CAClC,IAAU,EACV,YAA0B,EAC1B,qBAA6B;QAK7B,OAAO;YACL,cAAc,EAAE,OAAO;YACvB,oBAAoB,EAAE,OAAO;SAC9B,CAAA;IACH,CAAC;IACD,KAAK,CAAC,yBAAyB,CAAC,gBAAwB;QACtD,OAAO,KAAK,CAAA;IACd,CAAC;IACD,KAAK,CAAC,oBAAoB,CACxB,IAAU,EACV,UAAkB;QAElB,yCAAyC;QACzC,MAAM,cAAc,GAAG,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAA;QACjD,MAAM,eAAe,GAAG,aAAa,cAAc,UAAU,CAAA;QAC7D,IAAI,CAAC,KAAK,CAAC,eAAe,EAAE,UAAU,CAAC,CAAA;QACvC,OAAO,EAAE,CAAA;IACX,CAAC;IACD,KAAK,CAAC,yBAAyB,CAC7B,IAAU,EACV,YAA0B,EAC1B,oBAA4C;QAE5C,OAAO,EAAE,CAAA;IACX,CAAC;IACD,KAAK,CAAC,mBAAmB,CACvB,cAA6B,EAC7B,eAAuB,EACvB,qBAA6B,EAC7B,yBAAkD,EAClD,KAAa;QAKb,SAAS,UAAU;YACjB,MAAM,IAAI,GAAG,IAAI,IAAI,EAAE,CAAA;YACvB,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,EAAE,CAAA;YAC/B,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA,CAAC,0BAA0B;YACrF,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,EAAE,CAAA;YAE1B,OAAO,GAAG,IAAI,GAAG,KAAK,IAAI,GAAG,GAAG,CAAA;QAClC,CAAC;QAED,SAAS,+BAA+B,CAAC,cAAsB;YAC7D,MAAM,eAAe,GAAG,UAAU,EAAE,CAAA;YACpC,OAAO,CAAC,cAAc,CAAC,UAAU,CAAC,eAAe,CAAC;gBAChD,CAAC,CAAC,GAAG,eAAe,GAAG;gBACvB,CAAC,CAAC,IAAA,YAAG,EAAC,cAAc,EAAE,OAAO,CAAC,CAAA;QAClC,CAAC;QAED,MAAM,YAAY,GAAG,GAAG,+BAA+B,CAAC,cAAc,CAAC,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAA;QAE3G,OAAO;YACL,UAAU,EAAE,YAAY;YACxB,OAAO,EAAE,gBAAgB,YAAY,EAAE;SACxC,CAAA;IACH,CAAC;CACF;AArFD,sCAqFC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Return the AWS profile name to use in AWS cli commands
|
|
3
|
+
*/
|
|
4
|
+
export declare function getProfileName(): string;
|
|
5
|
+
/**
|
|
6
|
+
* Retrieves the AWS credentials from environment variables.
|
|
7
|
+
* Ensures that `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, and `AWS_DEFAULT_REGION` are properly set.
|
|
8
|
+
* Throws an error if credentials or region are missing.
|
|
9
|
+
*
|
|
10
|
+
* @return {Object} An object containing AWS credentials.
|
|
11
|
+
* @return {string} return.accessKeyId The AWS Access Key ID.
|
|
12
|
+
* @return {string} return.secretAccessKey The AWS Secret Access Key.
|
|
13
|
+
* @return {string} return.region The AWS Region.
|
|
14
|
+
*/
|
|
15
|
+
export declare function getAwsCredentialsSet(): {
|
|
16
|
+
accessKeyId: string;
|
|
17
|
+
secretAccessKey: string;
|
|
18
|
+
region: string;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Retrieves the authentication information for a given OIDC profile.
|
|
22
|
+
* If the specified profile exists, it fetches the configuration; otherwise, it returns false.
|
|
23
|
+
*
|
|
24
|
+
* @return {Promise<string | boolean>} The authentication details if the profile exists, or false if the profile does not exist.
|
|
25
|
+
*/
|
|
26
|
+
export declare function getAuthWithOidcProfile(): Promise<string | boolean>;
|
|
27
|
+
export declare function loginToEcr(): Promise<{
|
|
28
|
+
success: boolean;
|
|
29
|
+
stdout: string;
|
|
30
|
+
stderr: string;
|
|
31
|
+
}>;
|
|
32
|
+
/**
|
|
33
|
+
* Check AWS CLI with the OIDC profile otherwise use the default credentials
|
|
34
|
+
* @returns {string} the profile's name
|
|
35
|
+
*/
|
|
36
|
+
export declare function checkAwsAuth(): Promise<string>;
|
|
37
|
+
export declare function pushImageToEcr(repositoryName: string, version: string): Promise<{
|
|
38
|
+
success: boolean;
|
|
39
|
+
}>;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getProfileName = getProfileName;
|
|
4
|
+
exports.getAwsCredentialsSet = getAwsCredentialsSet;
|
|
5
|
+
exports.getAuthWithOidcProfile = getAuthWithOidcProfile;
|
|
6
|
+
exports.loginToEcr = loginToEcr;
|
|
7
|
+
exports.checkAwsAuth = checkAwsAuth;
|
|
8
|
+
exports.pushImageToEcr = pushImageToEcr;
|
|
9
|
+
const docker_1 = require("./docker");
|
|
10
|
+
const exec_1 = require("./exec");
|
|
11
|
+
let profileName = 'OIDC-PROFILE';
|
|
12
|
+
/**
|
|
13
|
+
* Return the AWS profile name to use in AWS cli commands
|
|
14
|
+
*/
|
|
15
|
+
function getProfileName() {
|
|
16
|
+
return profileName;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Retrieves the AWS credentials from environment variables.
|
|
20
|
+
* Ensures that `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, and `AWS_DEFAULT_REGION` are properly set.
|
|
21
|
+
* Throws an error if credentials or region are missing.
|
|
22
|
+
*
|
|
23
|
+
* @return {Object} An object containing AWS credentials.
|
|
24
|
+
* @return {string} return.accessKeyId The AWS Access Key ID.
|
|
25
|
+
* @return {string} return.secretAccessKey The AWS Secret Access Key.
|
|
26
|
+
* @return {string} return.region The AWS Region.
|
|
27
|
+
*/
|
|
28
|
+
function getAwsCredentialsSet() {
|
|
29
|
+
const accessKeyId = process.env.AWS_ACCESS_KEY_ID;
|
|
30
|
+
const secretAccessKey = process.env.AWS_SECRET_ACCESS_KEY;
|
|
31
|
+
const region = process.env.AWS_DEFAULT_REGION;
|
|
32
|
+
if (!accessKeyId || !secretAccessKey) {
|
|
33
|
+
throw new Error('AWS credentials not found, please set AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables (or attach GLOBAL_ORG context if you are using CircleCI)');
|
|
34
|
+
}
|
|
35
|
+
if (!region) {
|
|
36
|
+
throw new Error('AWS region not found, please set AWS_DEFAULT_REGION environment variable (or attach GLOBAL_ORG context if you are using CircleCI)');
|
|
37
|
+
}
|
|
38
|
+
return { accessKeyId, secretAccessKey, region };
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Retrieves the authentication information for a given OIDC profile.
|
|
42
|
+
* If the specified profile exists, it fetches the configuration; otherwise, it returns false.
|
|
43
|
+
*
|
|
44
|
+
* @return {Promise<string | boolean>} The authentication details if the profile exists, or false if the profile does not exist.
|
|
45
|
+
*/
|
|
46
|
+
async function getAuthWithOidcProfile() {
|
|
47
|
+
try {
|
|
48
|
+
const profileExist = await (0, exec_1.exec_command)(`aws configure list-profiles | grep ${profileName}`);
|
|
49
|
+
if (profileExist.success) {
|
|
50
|
+
return profileExist.stdout;
|
|
51
|
+
}
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
catch (e) {
|
|
55
|
+
console.error(e);
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
async function loginToEcr() {
|
|
60
|
+
return (0, exec_1.exec_command)(`aws ecr get-login-password --profile ${profileName} --region eu-west-3 | ${await (0, docker_1.getDockerOrPodman)()} login --username AWS --password-stdin ${process.env.AWS_ECR_REGISTRY}`);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Check AWS CLI with the OIDC profile otherwise use the default credentials
|
|
64
|
+
* @returns {string} the profile's name
|
|
65
|
+
*/
|
|
66
|
+
async function checkAwsAuth() {
|
|
67
|
+
const profileExist = await getAuthWithOidcProfile();
|
|
68
|
+
if (profileExist) {
|
|
69
|
+
console.log('OIDC profile found, using it');
|
|
70
|
+
profileName = 'OIDC-PROFILE';
|
|
71
|
+
}
|
|
72
|
+
else if (getAwsCredentialsSet()) {
|
|
73
|
+
console.log('OIDC profile not found, using AWS_KEY_ID and AWS_SECRET_ACCESS_KEY');
|
|
74
|
+
profileName = 'default';
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
throw new Error('AWS credentials not found, please attach CORE-PLATFORM_SHARED_ENV context if you are using CircleCI or export AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables');
|
|
78
|
+
}
|
|
79
|
+
return profileName;
|
|
80
|
+
}
|
|
81
|
+
function pushImageToEcr(repositoryName, version) {
|
|
82
|
+
return (0, exec_1.exec_command)(`docker push ${process.env.AWS_ECR_REGISTRY}/${repositoryName}:${version}`);
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=aws-auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aws-auth.js","sourceRoot":"","sources":["../../../src/utils/aws-auth.ts"],"names":[],"mappings":";;AAQA,wCAEC;AAYD,oDAmBC;AAQD,wDAaC;AAED,gCAIC;AAMD,oCAgBC;AAED,wCAOC;AAnGD,qCAA4C;AAC5C,iCAAqC;AAErC,IAAI,WAAW,GAAG,cAAc,CAAA;AAEhC;;GAEG;AACH,SAAgB,cAAc;IAC5B,OAAO,WAAW,CAAA;AACpB,CAAC;AAED;;;;;;;;;GASG;AACH,SAAgB,oBAAoB;IAKlC,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAA;IACjD,MAAM,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAA;IACzD,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAA;IAC7C,IAAI,CAAC,WAAW,IAAI,CAAC,eAAe,EAAE,CAAC;QACrC,MAAM,IAAI,KAAK,CACb,kKAAkK,CACnK,CAAA;IACH,CAAC;IACD,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CACb,mIAAmI,CACpI,CAAA;IACH,CAAC;IACD,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,EAAE,CAAA;AACjD,CAAC;AAED;;;;;GAKG;AACI,KAAK,UAAU,sBAAsB;IAC1C,IAAI,CAAC;QACH,MAAM,YAAY,GAAG,MAAM,IAAA,mBAAY,EACrC,sCAAsC,WAAW,EAAE,CACpD,CAAA;QACD,IAAI,YAAY,CAAC,OAAO,EAAE,CAAC;YACzB,OAAO,YAAY,CAAC,MAAM,CAAA;QAC5B,CAAC;QACD,OAAO,KAAK,CAAA;IACd,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;QAChB,OAAO,KAAK,CAAA;IACd,CAAC;AACH,CAAC;AAEM,KAAK,UAAU,UAAU;IAC9B,OAAO,IAAA,mBAAY,EACjB,wCAAwC,WAAW,yBAAyB,MAAM,IAAA,0BAAiB,GAAE,0CAA0C,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAC9K,CAAA;AACH,CAAC;AAED;;;GAGG;AACI,KAAK,UAAU,YAAY;IAChC,MAAM,YAAY,GAAG,MAAM,sBAAsB,EAAE,CAAA;IACnD,IAAI,YAAY,EAAE,CAAC;QACjB,OAAO,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAA;QAC3C,WAAW,GAAG,cAAc,CAAA;IAC9B,CAAC;SAAM,IAAI,oBAAoB,EAAE,EAAE,CAAC;QAClC,OAAO,CAAC,GAAG,CACT,oEAAoE,CACrE,CAAA;QACD,WAAW,GAAG,SAAS,CAAA;IACzB,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,KAAK,CACb,iLAAiL,CAClL,CAAA;IACH,CAAC;IACD,OAAO,WAAW,CAAA;AACpB,CAAC;AAED,SAAgB,cAAc,CAC5B,cAAsB,EACtB,OAAe;IAEf,OAAO,IAAA,mBAAY,EACjB,eAAe,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,cAAc,IAAI,OAAO,EAAE,CAC3E,CAAA;AACH,CAAC"}
|
|
@@ -1,20 +1,9 @@
|
|
|
1
|
-
import { exec_command } from './exec'
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* Determines the available container management tool by checking for Docker and fallback to Podman if Docker is unavailable.
|
|
5
3
|
*
|
|
6
4
|
* @return {Promise<string>} A promise that resolves to the string 'docker' if Docker is available, or 'podman' if Podman is used as a fallback.
|
|
7
5
|
*/
|
|
8
|
-
export
|
|
9
|
-
try {
|
|
10
|
-
await exec_command('docker --version')
|
|
11
|
-
return 'docker'
|
|
12
|
-
} catch (e) {
|
|
13
|
-
console.log('docker not found, trying podman')
|
|
14
|
-
return 'podman'
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
6
|
+
export declare function getDockerOrPodman(): Promise<string>;
|
|
18
7
|
/**
|
|
19
8
|
* Builds a Docker image using the provided Dockerfile.
|
|
20
9
|
*
|
|
@@ -23,13 +12,8 @@ export async function getDockerOrPodman(): Promise<string> {
|
|
|
23
12
|
* @param version The version of the image to build.
|
|
24
13
|
* @return {Promise<{success: boolean, stdout: string, stderr: string}>} A promise that resolves to an object containing the success status, stdout, and stderr of the command.
|
|
25
14
|
*/
|
|
26
|
-
export
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const dockerOrPodman = await getDockerOrPodman()
|
|
32
|
-
return exec_command(
|
|
33
|
-
`${dockerOrPodman} buildx build -t ${process.env.AWS_ECR_REGISTRY}/${imageName}:${version} -f ${dockerfilePath} --secret id=NPM_TOKEN .`,
|
|
34
|
-
)
|
|
35
|
-
}
|
|
15
|
+
export declare function buildDockerImage(imageName: string, dockerfilePath: string, version: string): Promise<{
|
|
16
|
+
success: boolean;
|
|
17
|
+
stdout: string;
|
|
18
|
+
stderr: string;
|
|
19
|
+
}>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDockerOrPodman = getDockerOrPodman;
|
|
4
|
+
exports.buildDockerImage = buildDockerImage;
|
|
5
|
+
const exec_1 = require("./exec");
|
|
6
|
+
/**
|
|
7
|
+
* Determines the available container management tool by checking for Docker and fallback to Podman if Docker is unavailable.
|
|
8
|
+
*
|
|
9
|
+
* @return {Promise<string>} A promise that resolves to the string 'docker' if Docker is available, or 'podman' if Podman is used as a fallback.
|
|
10
|
+
*/
|
|
11
|
+
async function getDockerOrPodman() {
|
|
12
|
+
try {
|
|
13
|
+
await (0, exec_1.exec_command)('docker --version');
|
|
14
|
+
return 'docker';
|
|
15
|
+
}
|
|
16
|
+
catch (e) {
|
|
17
|
+
console.log('docker not found, trying podman');
|
|
18
|
+
return 'podman';
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Builds a Docker image using the provided Dockerfile.
|
|
23
|
+
*
|
|
24
|
+
* @param imageName The name of the image to build.
|
|
25
|
+
* @param dockerfilePath The path to the Dockerfile.
|
|
26
|
+
* @param version The version of the image to build.
|
|
27
|
+
* @return {Promise<{success: boolean, stdout: string, stderr: string}>} A promise that resolves to an object containing the success status, stdout, and stderr of the command.
|
|
28
|
+
*/
|
|
29
|
+
async function buildDockerImage(imageName, dockerfilePath, version) {
|
|
30
|
+
const dockerOrPodman = await getDockerOrPodman();
|
|
31
|
+
return (0, exec_1.exec_command)(`${dockerOrPodman} buildx build -t ${process.env.AWS_ECR_REGISTRY}/${imageName}:${version} -f ${dockerfilePath} --secret id=NPM_TOKEN .`);
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=docker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docker.js","sourceRoot":"","sources":["../../../src/utils/docker.ts"],"names":[],"mappings":";;AAOA,8CAQC;AAUD,4CASC;AAlCD,iCAAqC;AAErC;;;;GAIG;AACI,KAAK,UAAU,iBAAiB;IACrC,IAAI,CAAC;QACH,MAAM,IAAA,mBAAY,EAAC,kBAAkB,CAAC,CAAA;QACtC,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;;;;;;;GAOG;AACI,KAAK,UAAU,gBAAgB,CACpC,SAAiB,EACjB,cAAsB,EACtB,OAAe;IAEf,MAAM,cAAc,GAAG,MAAM,iBAAiB,EAAE,CAAA;IAChD,OAAO,IAAA,mBAAY,EACjB,GAAG,cAAc,oBAAoB,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,SAAS,IAAI,OAAO,OAAO,cAAc,2BAA2B,CAC1I,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.execTiny = void 0;
|
|
4
|
+
exports.exec_command = exec_command;
|
|
5
|
+
const child_process_1 = require("child_process");
|
|
6
|
+
const util_1 = require("util");
|
|
7
|
+
const tinyexec_1 = require("tinyexec");
|
|
8
|
+
async function exec_command(command) {
|
|
9
|
+
const { stdout, stderr } = await (0, util_1.promisify)(child_process_1.exec)(command);
|
|
10
|
+
console.log(stdout);
|
|
11
|
+
console.error(stderr);
|
|
12
|
+
const success = !stderr;
|
|
13
|
+
return { success, stdout, stderr };
|
|
14
|
+
}
|
|
15
|
+
function createLoggingExecWrapper(execFn) {
|
|
16
|
+
return (command, args = [], options = {}) => {
|
|
17
|
+
console.log(`Running '${command} ${args.join(' ')}'...`);
|
|
18
|
+
return execFn(command, args, {
|
|
19
|
+
throwOnError: true,
|
|
20
|
+
...options,
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
exports.execTiny = createLoggingExecWrapper(tinyexec_1.x);
|
|
25
|
+
//# sourceMappingURL=exec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exec.js","sourceRoot":"","sources":["../../../src/utils/exec.ts"],"names":[],"mappings":";;;AAOA,oCAOC;AAdD,iDAAoC;AACpC,+BAAgC;AAIhC,uCAA4B;AAErB,KAAK,UAAU,YAAY,CAAC,OAAe;IAChD,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,IAAA,gBAAS,EAAC,oBAAI,CAAC,CAAC,OAAO,CAAC,CAAA;IACzD,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;IACnB,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;IAErB,MAAM,OAAO,GAAG,CAAC,MAAM,CAAA;IACvB,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAA;AACpC,CAAC;AAED,SAAS,wBAAwB,CAAC,MAAgB;IAChD,OAAO,CACL,OAAe,EACf,OAAiB,EAAE,EACnB,UAA4B,EAAE,EAC9B,EAAE;QACF,OAAO,CAAC,GAAG,CAAC,YAAY,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;QACxD,OAAO,MAAM,CAAC,OAAO,EAAE,IAAI,EAAE;YAC3B,YAAY,EAAE,IAAI;YAClB,GAAG,OAAO;SACX,CAAC,CAAA;IACJ,CAAC,CAAA;AACH,CAAC;AAEY,QAAA,QAAQ,GAAG,wBAAwB,CAAC,YAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getVersion = getVersion;
|
|
4
|
+
const fs = require("node:fs");
|
|
5
|
+
/**
|
|
6
|
+
* Get the version of a project
|
|
7
|
+
* @param projectName
|
|
8
|
+
* @returns {string}
|
|
9
|
+
*/
|
|
10
|
+
function getVersion(projectName) {
|
|
11
|
+
const versionFilePath = `dist/apps/${projectName}/VERSION`;
|
|
12
|
+
return fs.readFileSync(versionFilePath, 'utf8');
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=get-version.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-version.js","sourceRoot":"","sources":["../../../src/utils/get-version.ts"],"names":[],"mappings":";;AAOA,gCAGC;AAVD,8BAA6B;AAE7B;;;;GAIG;AACH,SAAgB,UAAU,CAAC,WAAmB;IAC5C,MAAM,eAAe,GAAG,aAAa,WAAW,UAAU,CAAA;IAC1D,OAAO,EAAE,CAAC,YAAY,CAAC,eAAe,EAAE,MAAM,CAAC,CAAA;AACjD,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getSanitizedCurrentGitBranch = getSanitizedCurrentGitBranch;
|
|
4
|
+
const exec_1 = require("./exec");
|
|
5
|
+
/**
|
|
6
|
+
* Get sanitized current git branch name
|
|
7
|
+
*/
|
|
8
|
+
async function getSanitizedCurrentGitBranch() {
|
|
9
|
+
const branchName = await (0, exec_1.exec_command)(`git branch --show-current`);
|
|
10
|
+
return branchName.success
|
|
11
|
+
? branchName.stdout
|
|
12
|
+
.trim()
|
|
13
|
+
.toLowerCase()
|
|
14
|
+
.replace(/[^a-z0-9]/g, '')
|
|
15
|
+
: '';
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=github.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github.js","sourceRoot":"","sources":["../../../src/utils/github.ts"],"names":[],"mappings":";;AAKA,oEAQC;AAbD,iCAAqC;AAErC;;GAEG;AACI,KAAK,UAAU,4BAA4B;IAChD,MAAM,UAAU,GAAG,MAAM,IAAA,mBAAY,EAAC,2BAA2B,CAAC,CAAA;IAClE,OAAO,UAAU,CAAC,OAAO;QACvB,CAAC,CAAC,UAAU,CAAC,MAAM;aACd,IAAI,EAAE;aACN,WAAW,EAAE;aACb,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC;QAC9B,CAAC,CAAC,EAAE,CAAA;AACR,CAAC"}
|