@payfit/nx-core 4.9.1-ephemeral.10 → 4.9.1-ephemeral.2
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 -9
- package/dist/src/executors/publisher/docker.d.ts +0 -5
- package/dist/src/executors/publisher/docker.js +0 -21
- package/dist/src/executors/publisher/docker.js.map +0 -1
- package/dist/src/executors/publisher/executor.d.ts +0 -4
- package/dist/src/executors/publisher/executor.js +0 -23
- package/dist/src/executors/publisher/executor.js.map +0 -1
- package/dist/src/executors/publisher/helm.d.ts +0 -7
- package/dist/src/executors/publisher/helm.js +0 -40
- package/dist/src/executors/publisher/helm.js.map +0 -1
- package/dist/src/executors/publisher/schema.d.ts +0 -5
- package/dist/src/executors/publisher/schema.json +0 -18
- package/dist/src/index.d.ts +0 -4
- package/dist/src/index.js +0 -53
- package/dist/src/index.js.map +0 -1
- package/dist/src/scripts/version-action.d.ts +0 -25
- package/dist/src/scripts/version-action.js +0 -58
- package/dist/src/scripts/version-action.js.map +0 -1
- package/dist/src/utils/aws-auth.d.ts +0 -39
- package/dist/src/utils/aws-auth.js +0 -84
- package/dist/src/utils/aws-auth.js.map +0 -1
- package/dist/src/utils/docker.d.ts +0 -19
- package/dist/src/utils/docker.js +0 -33
- package/dist/src/utils/docker.js.map +0 -1
- package/dist/src/utils/exec.d.ts +0 -7
- package/dist/src/utils/exec.js +0 -25
- package/dist/src/utils/exec.js.map +0 -1
- package/dist/src/utils/get-version.d.ts +0 -6
- package/dist/src/utils/get-version.js +0 -14
- package/dist/src/utils/get-version.js.map +0 -1
- package/dist/src/utils/github.d.ts +0 -4
- package/dist/src/utils/github.js +0 -17
- package/dist/src/utils/github.js.map +0 -1
- package/dist/src/utils/helm.d.ts +0 -48
- package/dist/src/utils/helm.js +0 -91
- package/dist/src/utils/helm.js.map +0 -1
- package/dist/src/utils/import-esm.d.ts +0 -2
- package/dist/src/utils/import-esm.js +0 -12
- package/dist/src/utils/import-esm.js.map +0 -1
- package/dist/src/utils/tsh.d.ts +0 -10
- package/dist/src/utils/tsh.js +0 -107
- package/dist/src/utils/tsh.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,20 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payfit/nx-core",
|
|
3
|
-
"version": "4.9.1-ephemeral.
|
|
3
|
+
"version": "4.9.1-ephemeral.2",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"types": "dist/src/index.d.ts",
|
|
7
|
-
"typings": "dist/src/index.d.ts",
|
|
8
|
-
"repository": {
|
|
9
|
-
"type": "git",
|
|
10
|
-
"url": "https://github.com/payfit/nx-common-packages.git",
|
|
11
|
-
"directory": "packages/nx-core"
|
|
12
|
-
},
|
|
13
7
|
"dependencies": {
|
|
14
|
-
"@nx/devkit": "21.0.
|
|
8
|
+
"@nx/devkit": "21.0.1",
|
|
15
9
|
"get-port": "^7.1.0",
|
|
16
10
|
"ky": "^1.8.1",
|
|
17
|
-
"nx": "21.0.
|
|
11
|
+
"nx": "21.0.1",
|
|
18
12
|
"semver": "7.7.1",
|
|
19
13
|
"tinyexec": "0.3.2",
|
|
20
14
|
"tslib": "^2.8.1",
|
|
@@ -1,21 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,4 +0,0 @@
|
|
|
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;
|
|
@@ -1,23 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,7 +0,0 @@
|
|
|
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
|
-
}>;
|
|
@@ -1,40 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://json-schema.org/schema",
|
|
3
|
-
"version": 2,
|
|
4
|
-
"title": "Publisher executor",
|
|
5
|
-
"description": "Publish the helm chart to the chartmuseum and docker image to ECR",
|
|
6
|
-
"type": "object",
|
|
7
|
-
"properties": {
|
|
8
|
-
"chartRegistry": {
|
|
9
|
-
"type": "string",
|
|
10
|
-
"description": "The helm chart registry"
|
|
11
|
-
},
|
|
12
|
-
"ecrRegistry": {
|
|
13
|
-
"type": "string",
|
|
14
|
-
"description": "The docker registry"
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
|
-
"required": []
|
|
18
|
-
}
|
package/dist/src/index.d.ts
DELETED
package/dist/src/index.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
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
|
-
if (isHelmProject || isDockerProject) {
|
|
28
|
-
const publisherConfig = (0, devkit_1.readJsonFile)((0, path_1.join)(__dirname, '/executors/publisher/schema.json'));
|
|
29
|
-
targets['nx-release-publish'] = {
|
|
30
|
-
executor: '@payfit/nx-core:publisher',
|
|
31
|
-
options: {
|
|
32
|
-
ecrRegistry,
|
|
33
|
-
chartRegistry,
|
|
34
|
-
},
|
|
35
|
-
cache: true,
|
|
36
|
-
inputs: ['production', '^production'],
|
|
37
|
-
outputs: [`{workspaceRoot}/dist/apps/${projectConfiguration.name}/chart`],
|
|
38
|
-
metadata: {
|
|
39
|
-
technologies: ['helm', 'docker'],
|
|
40
|
-
description: publisherConfig.description,
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
return {
|
|
45
|
-
projects: {
|
|
46
|
-
[projectRoot]: {
|
|
47
|
-
...projectConfiguration,
|
|
48
|
-
targets,
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
//# sourceMappingURL=index.js.map
|
package/dist/src/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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,EA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
-
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
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
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
|
-
return {
|
|
52
|
-
newVersion: getNewVersionFromCurrentVersion(currentVersion),
|
|
53
|
-
logText: `New version: ${getNewVersionFromCurrentVersion(currentVersion)}`,
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
exports.default = customVersionAction;
|
|
58
|
-
//# sourceMappingURL=version-action.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"version-action.js","sourceRoot":"","sources":["../../../src/scripts/version-action.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,OAAO;YACL,UAAU,EAAE,+BAA+B,CAAC,cAAc,CAAC;YAC3D,OAAO,EAAE,gBAAgB,+BAA+B,CAAC,cAAc,CAAC,EAAE;SAC3E,CAAA;IACH,CAAC;CACF;AAnFD,sCAmFC"}
|
|
@@ -1,39 +0,0 @@
|
|
|
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
|
-
}>;
|
|
@@ -1,84 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
1
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AA,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,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Determines the available container management tool by checking for Docker and fallback to Podman if Docker is unavailable.
|
|
3
|
-
*
|
|
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.
|
|
5
|
-
*/
|
|
6
|
-
export declare function getDockerOrPodman(): Promise<string>;
|
|
7
|
-
/**
|
|
8
|
-
* Builds a Docker image using the provided Dockerfile.
|
|
9
|
-
*
|
|
10
|
-
* @param imageName The name of the image to build.
|
|
11
|
-
* @param dockerfilePath The path to the Dockerfile.
|
|
12
|
-
* @param version The version of the image to build.
|
|
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.
|
|
14
|
-
*/
|
|
15
|
-
export declare function buildDockerImage(imageName: string, dockerfilePath: string, version: string): Promise<{
|
|
16
|
-
success: boolean;
|
|
17
|
-
stdout: string;
|
|
18
|
-
stderr: string;
|
|
19
|
-
}>;
|
package/dist/src/utils/docker.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/dist/src/utils/exec.d.ts
DELETED
package/dist/src/utils/exec.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,14 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/dist/src/utils/github.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/dist/src/utils/helm.d.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Read & parse the Helm chart.yaml file
|
|
3
|
-
* @param helmFolderPath
|
|
4
|
-
*/
|
|
5
|
-
export declare function getHelmChartFile(helmFolderPath: string): Promise<any>;
|
|
6
|
-
/**
|
|
7
|
-
* Prepare the Chart.yaml config file for the Tsh proxy
|
|
8
|
-
* @param helmFolderPath
|
|
9
|
-
* @param tshPort
|
|
10
|
-
*/
|
|
11
|
-
export declare function setupTeleportProxyHelmChartFile(helmFolderPath: string, tshPort: number): Promise<void>;
|
|
12
|
-
/**
|
|
13
|
-
* Revert the Tsh proxy config in the Chart.yaml config file
|
|
14
|
-
* @param helmFolderPath
|
|
15
|
-
* @param tshPort
|
|
16
|
-
*/
|
|
17
|
-
export declare function resetTeleportProxyHelmChartFile(helmFolderPath: string, tshPort: number): Promise<void>;
|
|
18
|
-
/**
|
|
19
|
-
* Install all the helm repositories defined in the Chart config
|
|
20
|
-
* @param helmFolderPath
|
|
21
|
-
*/
|
|
22
|
-
export declare function installHelmRepo(helmFolderPath: string): Promise<{
|
|
23
|
-
success: boolean;
|
|
24
|
-
stdout: string;
|
|
25
|
-
stderr: string;
|
|
26
|
-
}>;
|
|
27
|
-
/**
|
|
28
|
-
* Package the Helm chart
|
|
29
|
-
* @param helmFolderPath
|
|
30
|
-
* @param version
|
|
31
|
-
* @param destinationPath
|
|
32
|
-
*/
|
|
33
|
-
export declare function packageHelm(helmFolderPath: string, version: string, destinationPath: string): Promise<{
|
|
34
|
-
success: boolean;
|
|
35
|
-
stdout: string;
|
|
36
|
-
stderr: string;
|
|
37
|
-
}>;
|
|
38
|
-
/**
|
|
39
|
-
* Push the packaged Helm chart in the chartmuseum
|
|
40
|
-
* @param packagedHelmChartFilePath
|
|
41
|
-
* @param projectName
|
|
42
|
-
* @param branch
|
|
43
|
-
*/
|
|
44
|
-
export declare function pushPackagedHelm(packagedHelmChartFilePath: string, projectName: string, branch: string): Promise<{
|
|
45
|
-
success: boolean;
|
|
46
|
-
stdout: string;
|
|
47
|
-
stderr: string;
|
|
48
|
-
}>;
|
package/dist/src/utils/helm.js
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getHelmChartFile = getHelmChartFile;
|
|
4
|
-
exports.setupTeleportProxyHelmChartFile = setupTeleportProxyHelmChartFile;
|
|
5
|
-
exports.resetTeleportProxyHelmChartFile = resetTeleportProxyHelmChartFile;
|
|
6
|
-
exports.installHelmRepo = installHelmRepo;
|
|
7
|
-
exports.packageHelm = packageHelm;
|
|
8
|
-
exports.pushPackagedHelm = pushPackagedHelm;
|
|
9
|
-
const fs = require("node:fs");
|
|
10
|
-
const process = require("node:process");
|
|
11
|
-
const yaml_1 = require("yaml");
|
|
12
|
-
const aws_auth_1 = require("./aws-auth");
|
|
13
|
-
const exec_1 = require("./exec");
|
|
14
|
-
const tshProxy = 'http://localhost';
|
|
15
|
-
/**
|
|
16
|
-
* Read & parse the Helm chart.yaml file
|
|
17
|
-
* @param helmFolderPath
|
|
18
|
-
*/
|
|
19
|
-
async function getHelmChartFile(helmFolderPath) {
|
|
20
|
-
return (0, yaml_1.parse)(fs.readFileSync(`${helmFolderPath}/Chart.yaml`, 'utf8'));
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Prepare the Chart.yaml config file for the Tsh proxy
|
|
24
|
-
* @param helmFolderPath
|
|
25
|
-
* @param tshPort
|
|
26
|
-
*/
|
|
27
|
-
async function setupTeleportProxyHelmChartFile(helmFolderPath, tshPort) {
|
|
28
|
-
console.log(`Replacing charts.shared.payfit.tech -> localhost:${tshPort} for the Teleport proxy`);
|
|
29
|
-
let chartConfigStr = (0, yaml_1.stringify)(await getHelmChartFile(helmFolderPath));
|
|
30
|
-
chartConfigStr = chartConfigStr.replace(/(https?:\/\/)charts(\.shared)?\.payfit\.tech/gi, `${tshProxy}:${tshPort}`);
|
|
31
|
-
return fs.writeFileSync(`${helmFolderPath}/Chart.yaml`, chartConfigStr);
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Revert the Tsh proxy config in the Chart.yaml config file
|
|
35
|
-
* @param helmFolderPath
|
|
36
|
-
* @param tshPort
|
|
37
|
-
*/
|
|
38
|
-
async function resetTeleportProxyHelmChartFile(helmFolderPath, tshPort) {
|
|
39
|
-
let chartConfigStr = (0, yaml_1.stringify)(await getHelmChartFile(helmFolderPath));
|
|
40
|
-
chartConfigStr = chartConfigStr.replace(`${tshProxy}:${tshPort}`, 'https://charts.shared.payfit.tech');
|
|
41
|
-
return fs.writeFileSync(`${helmFolderPath}/Chart.yaml`, chartConfigStr);
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Install all the helm repositories defined in the Chart config
|
|
45
|
-
* @param helmFolderPath
|
|
46
|
-
*/
|
|
47
|
-
async function installHelmRepo(helmFolderPath) {
|
|
48
|
-
const chartConfig = await getHelmChartFile(helmFolderPath);
|
|
49
|
-
if (chartConfig.dependencies) {
|
|
50
|
-
for (let i = 0; i < chartConfig.dependencies.length; i++) {
|
|
51
|
-
const dep = chartConfig.dependencies[i];
|
|
52
|
-
const repoName = `tsh-${dep.name}-${dep.alias}`;
|
|
53
|
-
// check if the repository is our private payfit repo or a public one
|
|
54
|
-
if (dep.repository.includes(tshProxy)) {
|
|
55
|
-
// if it's our repo, we need the username and password to authenticate
|
|
56
|
-
if (!process.env.CHARTMUSEUM_USERNAME ||
|
|
57
|
-
!process.env.CHARTMUSEUM_PASSWORD)
|
|
58
|
-
throw new Error('Missing CHARTMUSEUM_USERNAME, CHARTMUSEUM_PASSWORD in environment!');
|
|
59
|
-
await (0, exec_1.exec_command)(`helm repo add --username '${process.env.CHARTMUSEUM_USERNAME}' --password '${process.env.CHARTMUSEUM_PASSWORD}' '${repoName}' '${dep.repository}' --force-update`);
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
await (0, exec_1.exec_command)(`helm repo add '${repoName}' '${dep.repository}' --force-update`);
|
|
63
|
-
}
|
|
64
|
-
await (0, exec_1.exec_command)(`helm repo update ${repoName}`);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return (0, exec_1.exec_command)(`helm dependency update ${helmFolderPath}`);
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Package the Helm chart
|
|
71
|
-
* @param helmFolderPath
|
|
72
|
-
* @param version
|
|
73
|
-
* @param destinationPath
|
|
74
|
-
*/
|
|
75
|
-
async function packageHelm(helmFolderPath, version, destinationPath) {
|
|
76
|
-
return (0, exec_1.exec_command)(`helm package ${helmFolderPath} --version ${version} --destination ${destinationPath}`);
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Push the packaged Helm chart in the chartmuseum
|
|
80
|
-
* @param packagedHelmChartFilePath
|
|
81
|
-
* @param projectName
|
|
82
|
-
* @param branch
|
|
83
|
-
*/
|
|
84
|
-
async function pushPackagedHelm(packagedHelmChartFilePath, projectName, branch) {
|
|
85
|
-
if (!process.env.CHARTMUSEUM_BUCKET_NAME)
|
|
86
|
-
throw new Error('Missing CHARTMUSEUM_BUCKET_NAME in environment!');
|
|
87
|
-
// aws s3api put-object-tagging --bucket ${process.env.CHARTMUSEUM_BUCKET_NAME} --key ${projectName}/${branch}/${packagedHelmChartFilePath} --tagging '{"TagSet": [{ "Key": "auto-purge", "Value": "false" }]}' // todo
|
|
88
|
-
const profile = (0, aws_auth_1.getProfileName)() === 'default' ? '' : `--profile ${(0, aws_auth_1.getProfileName)()}`;
|
|
89
|
-
return (0, exec_1.exec_command)(`aws s3 cp ${profile} --sse AES256 ${packagedHelmChartFilePath} s3://${process.env.CHARTMUSEUM_BUCKET_NAME}/${projectName}/${branch}/`);
|
|
90
|
-
}
|
|
91
|
-
//# sourceMappingURL=helm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"helm.js","sourceRoot":"","sources":["../../../src/utils/helm.ts"],"names":[],"mappings":";;AAcA,4CAEC;AAOD,0EAaC;AAOD,0EAUC;AAMD,0CA4BC;AAQD,kCAQC;AAQD,4CAaC;AA5HD,8BAA6B;AAC7B,wCAAuC;AAEvC,+BAAuC;AAEvC,yCAA2C;AAC3C,iCAAqC;AAErC,MAAM,QAAQ,GAAG,kBAAkB,CAAA;AAEnC;;;GAGG;AACI,KAAK,UAAU,gBAAgB,CAAC,cAAsB;IAC3D,OAAO,IAAA,YAAK,EAAC,EAAE,CAAC,YAAY,CAAC,GAAG,cAAc,aAAa,EAAE,MAAM,CAAC,CAAC,CAAA;AACvE,CAAC;AAED;;;;GAIG;AACI,KAAK,UAAU,+BAA+B,CACnD,cAAsB,EACtB,OAAe;IAEf,OAAO,CAAC,GAAG,CACT,oDAAoD,OAAO,yBAAyB,CACrF,CAAA;IACD,IAAI,cAAc,GAAG,IAAA,gBAAS,EAAC,MAAM,gBAAgB,CAAC,cAAc,CAAC,CAAC,CAAA;IACtE,cAAc,GAAG,cAAc,CAAC,OAAO,CACrC,gDAAgD,EAChD,GAAG,QAAQ,IAAI,OAAO,EAAE,CACzB,CAAA;IACD,OAAO,EAAE,CAAC,aAAa,CAAC,GAAG,cAAc,aAAa,EAAE,cAAc,CAAC,CAAA;AACzE,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IAAA,mBAAY,EAChB,kBAAkB,QAAQ,MAAM,GAAG,CAAC,UAAU,kBAAkB,CACjE,CAAA;YACH,CAAC;YACD,MAAM,IAAA,mBAAY,EAAC,oBAAoB,QAAQ,EAAE,CAAC,CAAA;QACpD,CAAC;IACH,CAAC;IACD,OAAO,IAAA,mBAAY,EAAC,0BAA0B,cAAc,EAAE,CAAC,CAAA;AACjE,CAAC;AAED;;;;;GAKG;AACI,KAAK,UAAU,WAAW,CAC/B,cAAsB,EACtB,OAAe,EACf,eAAuB;IAEvB,OAAO,IAAA,mBAAY,EACjB,gBAAgB,cAAc,cAAc,OAAO,kBAAkB,eAAe,EAAE,CACvF,CAAA;AACH,CAAC;AAED;;;;;GAKG;AACI,KAAK,UAAU,gBAAgB,CACpC,yBAAiC,EACjC,WAAmB,EACnB,MAAc;IAEd,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,uBAAuB;QACtC,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAA;IACpE,uNAAuN;IACvN,MAAM,OAAO,GACX,IAAA,yBAAc,GAAE,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,aAAa,IAAA,yBAAc,GAAE,EAAE,CAAA;IACvE,OAAO,IAAA,mBAAY,EACjB,aAAa,OAAO,iBAAiB,yBAAyB,SAAS,OAAO,CAAC,GAAG,CAAC,uBAAuB,IAAI,WAAW,IAAI,MAAM,GAAG,CACvI,CAAA;AACH,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.importKy = importKy;
|
|
4
|
-
exports.importGetPort = importGetPort;
|
|
5
|
-
// Needed since we have to have dynamic import to esm module, since we are stuck with cjs on the nx tool runner
|
|
6
|
-
function importKy() {
|
|
7
|
-
return Function('return import("ky")')();
|
|
8
|
-
}
|
|
9
|
-
function importGetPort() {
|
|
10
|
-
return Function('return import("get-port")')();
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=import-esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"import-esm.js","sourceRoot":"","sources":["../../../src/utils/import-esm.ts"],"names":[],"mappings":";;AACA,4BAEC;AAED,sCAIC;AATD,+GAA+G;AAC/G,SAAgB,QAAQ;IACtB,OAAO,QAAQ,CAAC,qBAAqB,CAAC,EAAkC,CAAA;AAC1E,CAAC;AAED,SAAgB,aAAa;IAC3B,OAAO,QAAQ,CAAC,2BAA2B,CAAC,EAE3C,CAAA;AACH,CAAC"}
|
package/dist/src/utils/tsh.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export declare function isLoggedInToTsh(): Promise<boolean>;
|
|
2
|
-
export declare function ensureIsLoggedInToTsh(): Promise<boolean>;
|
|
3
|
-
export declare function isConnectedToChartMuseum(): Promise<boolean>;
|
|
4
|
-
export declare function ensureAppIsChartMuseum(): Promise<boolean>;
|
|
5
|
-
export declare const getLocalPortForChartMuseum: () => Promise<{
|
|
6
|
-
[Symbol.dispose]: () => Promise<void>;
|
|
7
|
-
fetchClient: import("ky").KyInstance;
|
|
8
|
-
isReady: () => Promise<boolean>;
|
|
9
|
-
port: number;
|
|
10
|
-
}>;
|
package/dist/src/utils/tsh.js
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getLocalPortForChartMuseum = void 0;
|
|
4
|
-
exports.isLoggedInToTsh = isLoggedInToTsh;
|
|
5
|
-
exports.ensureIsLoggedInToTsh = ensureIsLoggedInToTsh;
|
|
6
|
-
exports.isConnectedToChartMuseum = isConnectedToChartMuseum;
|
|
7
|
-
exports.ensureAppIsChartMuseum = ensureAppIsChartMuseum;
|
|
8
|
-
const workspace_root_1 = require("nx/src/utils/workspace-root");
|
|
9
|
-
const zod_1 = require("zod");
|
|
10
|
-
const exec_1 = require("./exec");
|
|
11
|
-
const import_esm_1 = require("./import-esm");
|
|
12
|
-
const expectedProfileUrl = 'https://payfit.teleport.sh:443';
|
|
13
|
-
const expectedAppName = 'charts-shared';
|
|
14
|
-
const profile = zod_1.z.object({
|
|
15
|
-
profile_url: zod_1.z.string(),
|
|
16
|
-
});
|
|
17
|
-
const statusSchema = zod_1.z.object({
|
|
18
|
-
active: profile,
|
|
19
|
-
profiles: zod_1.z.array(profile).optional(),
|
|
20
|
-
});
|
|
21
|
-
const getStatusOfTsh = async () => {
|
|
22
|
-
const { stdout } = await (0, exec_1.execTiny)('tsh', `status -f json`.split(' '));
|
|
23
|
-
return statusSchema.parse(JSON.parse(stdout));
|
|
24
|
-
};
|
|
25
|
-
async function isLoggedInToTsh() {
|
|
26
|
-
try {
|
|
27
|
-
const status = await getStatusOfTsh();
|
|
28
|
-
return status.active.profile_url === expectedProfileUrl;
|
|
29
|
-
}
|
|
30
|
-
catch {
|
|
31
|
-
return false;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
async function ensureIsLoggedInToTsh() {
|
|
35
|
-
if (await isLoggedInToTsh()) {
|
|
36
|
-
return true;
|
|
37
|
-
}
|
|
38
|
-
await (0, exec_1.execTiny)('tsh', `login --proxy=${expectedProfileUrl} --auth=okta`.split(' '), {
|
|
39
|
-
throwOnError: true,
|
|
40
|
-
});
|
|
41
|
-
return await isLoggedInToTsh();
|
|
42
|
-
}
|
|
43
|
-
const getAppConfigOfTsh = async () => {
|
|
44
|
-
const { stdout } = await (0, exec_1.execTiny)('tsh', `apps config -f json --proxy=${expectedProfileUrl} ${expectedAppName}`.split(' '), {
|
|
45
|
-
throwOnError: true,
|
|
46
|
-
});
|
|
47
|
-
return JSON.parse(stdout);
|
|
48
|
-
};
|
|
49
|
-
async function isConnectedToChartMuseum() {
|
|
50
|
-
try {
|
|
51
|
-
const apps = await getAppConfigOfTsh();
|
|
52
|
-
return apps.name === expectedAppName;
|
|
53
|
-
}
|
|
54
|
-
catch {
|
|
55
|
-
return false;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
async function ensureAppIsChartMuseum() {
|
|
59
|
-
if (await isConnectedToChartMuseum()) {
|
|
60
|
-
return true;
|
|
61
|
-
}
|
|
62
|
-
await (0, exec_1.execTiny)('tsh', `apps login ${expectedAppName} --proxy=${expectedProfileUrl}`.split(' '), {
|
|
63
|
-
throwOnError: true,
|
|
64
|
-
});
|
|
65
|
-
return await isConnectedToChartMuseum();
|
|
66
|
-
}
|
|
67
|
-
const getLocalPortForChartMuseum = async () => {
|
|
68
|
-
if (!process.env.CI) {
|
|
69
|
-
await ensureIsLoggedInToTsh();
|
|
70
|
-
await ensureAppIsChartMuseum();
|
|
71
|
-
}
|
|
72
|
-
const { default: getPort } = await (0, import_esm_1.importGetPort)();
|
|
73
|
-
const { default: ky } = await (0, import_esm_1.importKy)();
|
|
74
|
-
const port = await getPort();
|
|
75
|
-
const command = process.env.CI
|
|
76
|
-
? `-i ./certs/identity --proxy payfit.teleport.sh:443 proxy app ${expectedAppName} --port ${port}`
|
|
77
|
-
: `proxy app ${expectedAppName} -p ${port}`;
|
|
78
|
-
const execHandle = (0, exec_1.execTiny)('tsh', command.split(' '), {
|
|
79
|
-
nodeOptions: {
|
|
80
|
-
cwd: workspace_root_1.workspaceRoot,
|
|
81
|
-
},
|
|
82
|
-
});
|
|
83
|
-
const isReady = async () => {
|
|
84
|
-
for await (const line of execHandle) {
|
|
85
|
-
console.log(`[TSH] ${line}`);
|
|
86
|
-
if (line.includes('Proxying connections')) {
|
|
87
|
-
return true;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
// line will be from stderr/stdout in the order you'd see it in a term
|
|
91
|
-
return false;
|
|
92
|
-
};
|
|
93
|
-
const fetchClient = ky.create({
|
|
94
|
-
prefixUrl: `http://localhost:${port}`,
|
|
95
|
-
});
|
|
96
|
-
return {
|
|
97
|
-
[Symbol.dispose]: async () => {
|
|
98
|
-
console.log(`Terminating tsh proxy on port ${port}`);
|
|
99
|
-
execHandle.kill();
|
|
100
|
-
},
|
|
101
|
-
fetchClient,
|
|
102
|
-
isReady,
|
|
103
|
-
port,
|
|
104
|
-
};
|
|
105
|
-
};
|
|
106
|
-
exports.getLocalPortForChartMuseum = getLocalPortForChartMuseum;
|
|
107
|
-
//# sourceMappingURL=tsh.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tsh.js","sourceRoot":"","sources":["../../../src/utils/tsh.ts"],"names":[],"mappings":";;;AAuBA,0CAOC;AAED,sDAYC;AAgBD,4DAOC;AAED,wDAYC;AAjFD,gEAA2D;AAC3D,6BAAuB;AAEvB,iCAAiC;AACjC,6CAAsD;AAEtD,MAAM,kBAAkB,GAAG,gCAAgC,CAAA;AAC3D,MAAM,eAAe,GAAG,eAAe,CAAA;AAEvC,MAAM,OAAO,GAAG,OAAC,CAAC,MAAM,CAAC;IACvB,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE;CACxB,CAAC,CAAA;AAEF,MAAM,YAAY,GAAG,OAAC,CAAC,MAAM,CAAC;IAC5B,MAAM,EAAE,OAAO;IACf,QAAQ,EAAE,OAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE;CACtC,CAAC,CAAA;AAEF,MAAM,cAAc,GAAG,KAAK,IAAI,EAAE;IAChC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,IAAA,eAAQ,EAAC,KAAK,EAAE,gBAAgB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAA;IACrE,OAAO,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAA;AAC/C,CAAC,CAAA;AAEM,KAAK,UAAU,eAAe;IACnC,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,cAAc,EAAE,CAAA;QACrC,OAAO,MAAM,CAAC,MAAM,CAAC,WAAW,KAAK,kBAAkB,CAAA;IACzD,CAAC;IAAC,MAAM,CAAC;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