@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.
Files changed (63) hide show
  1. package/README.md +2 -1
  2. package/dist/src/executors/publisher/docker.d.ts +5 -0
  3. package/dist/src/executors/publisher/docker.js +21 -0
  4. package/dist/src/executors/publisher/docker.js.map +1 -0
  5. package/dist/src/executors/publisher/executor.d.ts +4 -0
  6. package/dist/src/executors/publisher/executor.js +23 -0
  7. package/dist/src/executors/publisher/executor.js.map +1 -0
  8. package/dist/src/executors/publisher/helm.d.ts +7 -0
  9. package/dist/src/executors/publisher/helm.js +40 -0
  10. package/dist/src/executors/publisher/helm.js.map +1 -0
  11. package/dist/src/index.d.ts +4 -0
  12. package/dist/src/index.js +62 -0
  13. package/dist/src/index.js.map +1 -0
  14. package/dist/src/scripts/version-actions.d.ts +25 -0
  15. package/dist/src/scripts/version-actions.js +59 -0
  16. package/dist/src/scripts/version-actions.js.map +1 -0
  17. package/dist/src/utils/aws-auth.d.ts +39 -0
  18. package/dist/src/utils/aws-auth.js +84 -0
  19. package/dist/src/utils/aws-auth.js.map +1 -0
  20. package/{src/utils/docker.ts → dist/src/utils/docker.d.ts} +6 -22
  21. package/dist/src/utils/docker.js +33 -0
  22. package/dist/src/utils/docker.js.map +1 -0
  23. package/dist/src/utils/exec.d.ts +7 -0
  24. package/dist/src/utils/exec.js +25 -0
  25. package/dist/src/utils/exec.js.map +1 -0
  26. package/dist/src/utils/get-version.d.ts +6 -0
  27. package/dist/src/utils/get-version.js +14 -0
  28. package/dist/src/utils/get-version.js.map +1 -0
  29. package/dist/src/utils/github.d.ts +4 -0
  30. package/dist/src/utils/github.js +17 -0
  31. package/dist/src/utils/github.js.map +1 -0
  32. package/dist/src/utils/helm.d.ts +48 -0
  33. package/dist/src/utils/helm.js +91 -0
  34. package/dist/src/utils/helm.js.map +1 -0
  35. package/dist/src/utils/import-esm.d.ts +2 -0
  36. package/dist/src/utils/import-esm.js +12 -0
  37. package/dist/src/utils/import-esm.js.map +1 -0
  38. package/dist/src/utils/tsh.d.ts +10 -0
  39. package/dist/src/utils/tsh.js +107 -0
  40. package/dist/src/utils/tsh.js.map +1 -0
  41. package/package.json +24 -7
  42. package/.env.test +0 -0
  43. package/eslint.config.mjs +0 -31
  44. package/project.json +0 -43
  45. package/src/executors/publisher/docker.ts +0 -34
  46. package/src/executors/publisher/executor.ts +0 -30
  47. package/src/executors/publisher/helm.ts +0 -55
  48. package/src/index.ts +0 -77
  49. package/src/scripts/version-action.ts +0 -89
  50. package/src/utils/aws-auth.ts +0 -100
  51. package/src/utils/exec.spec.ts +0 -16
  52. package/src/utils/exec.ts +0 -31
  53. package/src/utils/get-version.ts +0 -11
  54. package/src/utils/github.ts +0 -14
  55. package/src/utils/helm.ts +0 -125
  56. package/src/utils/import-esm.ts +0 -10
  57. package/src/utils/tsh.ts +0 -127
  58. package/tsconfig.json +0 -19
  59. package/tsconfig.lib.json +0 -22
  60. package/tsconfig.spec.json +0 -28
  61. package/vite.config.ts +0 -28
  62. /package/{src → dist/src}/executors/publisher/schema.d.ts +0 -0
  63. /package/{src → dist/src}/executors/publisher/schema.json +0 -0
@@ -0,0 +1,48 @@
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
+ }>;
@@ -0,0 +1,91 @@
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} --app-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
@@ -0,0 +1 @@
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,EAA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Ac,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"}
@@ -0,0 +1,2 @@
1
+ export declare function importKy(): Promise<typeof import('ky')>;
2
+ export declare function importGetPort(): Promise<typeof import('get-port')>;
@@ -0,0 +1,12 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,10 @@
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
+ }>;
@@ -0,0 +1,107 @@
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
@@ -0,0 +1 @@
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,GA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Ae,OAAO,IAAI,EAAE,CAAA;IAC7C,MAAM,UAAU,GAAG,IAAA,eAAQ,EAAC,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;QACrD,WAAW,EAAE;YACX,GAAG,EAAE,8BAAa;SACnB;KACF,CAAC,CAAA;IAEF,MAAM,OAAO,GAAG,KAAK,IAAsB,EAAE;QAC3C,IAAI,KAAK,EAAE,MAAM,IAAI,IAAI,UAAU,EAAE,CAAC;YACpC,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,EAAE,CAAC,CAAA;YAC5B,IAAI,IAAI,CAAC,QAAQ,CAAC,sBAAsB,CAAC,EAAE,CAAC;gBAC1C,OAAO,IAAI,CAAA;YACb,CAAC;QACH,CAAC;QACD,sEAAsE;QACtE,OAAO,KAAK,CAAA;IACd,CAAC,CAAA;IAED,MAAM,WAAW,GAAG,EAAE,CAAC,MAAM,CAAC;QAC5B,SAAS,EAAE,oBAAoB,IAAI,EAAE;KACtC,CAAC,CAAA;IAEF,OAAO;QACL,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,KAAK,IAAI,EAAE;YAC3B,OAAO,CAAC,GAAG,CAAC,iCAAiC,IAAI,EAAE,CAAC,CAAA;YACpD,UAAU,CAAC,IAAI,EAAE,CAAA;QACnB,CAAC;QACD,WAAW;QACX,OAAO;QACP,IAAI;KACL,CAAA;AACH,CAAC,CAAA;AA3CY,QAAA,0BAA0B,8BA2CtC"}
package/package.json CHANGED
@@ -1,19 +1,36 @@
1
1
  {
2
2
  "name": "@payfit/nx-core",
3
- "version": "4.10.0-ephemeral.0",
3
+ "version": "4.10.0",
4
4
  "type": "commonjs",
5
- "main": "./src/index.js",
6
- "types": "./src/index.d.ts",
5
+ "main": "dist/src/index.js",
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
+ },
7
13
  "dependencies": {
8
- "@nx/devkit": "21.0.1",
14
+ "@nx/devkit": "21.0.3",
9
15
  "get-port": "^7.1.0",
10
16
  "ky": "^1.8.1",
11
- "nx": "21.0.1",
12
- "semver": "7.7.1",
17
+ "nx": "21.0.3",
18
+ "semver": "7.7.2",
13
19
  "tinyexec": "0.3.2",
14
20
  "tslib": "^2.8.1",
15
21
  "yaml": "^2.7.0",
16
22
  "zod": "^3.24.3"
17
23
  },
18
- "executors": "./executors.json"
24
+ "executors": "./executors.json",
25
+ "files": [
26
+ "dist",
27
+ "!**/*.tsbuildinfo",
28
+ "generators.json",
29
+ "executors.json"
30
+ ],
31
+ "exports": {
32
+ ".": "./dist/src/index.js",
33
+ "./package.json": "./package.json",
34
+ "./versionActions": "./dist/src/scripts/version-actions.js"
35
+ }
19
36
  }
package/.env.test DELETED
File without changes
package/eslint.config.mjs DELETED
@@ -1,31 +0,0 @@
1
- import baseConfig from '../../eslint.config.mjs'
2
-
3
- export default [
4
- ...baseConfig,
5
- {
6
- files: ['**/*.json'],
7
- rules: {
8
- '@nx/dependency-checks': [
9
- 'error',
10
- {
11
- ignoredFiles: [
12
- '{projectRoot}/eslint.config.{js,cjs,mjs}',
13
- '{projectRoot}/vite.config.{js,ts,mjs,mts}',
14
- ],
15
- },
16
- ],
17
- },
18
- languageOptions: {
19
- parser: await import('jsonc-eslint-parser'),
20
- },
21
- },
22
- {
23
- files: ['**/package.json', '**/executors.json'],
24
- rules: {
25
- '@nx/nx-plugin-checks': 'error',
26
- },
27
- languageOptions: {
28
- parser: await import('jsonc-eslint-parser'),
29
- },
30
- },
31
- ]
package/project.json DELETED
@@ -1,43 +0,0 @@
1
- {
2
- "name": "@payfit/nx-core",
3
- "$schema": "../../node_modules/nx/schemas/project-schema.json",
4
- "sourceRoot": "packages/nx-core/src",
5
- "projectType": "library",
6
- "tags": ["scope:tooling"],
7
- "targets": {
8
- "build": {
9
- "executor": "@nx/js:tsc",
10
- "outputs": ["{options.outputPath}"],
11
- "options": {
12
- "outputPath": "dist/packages/nx-core",
13
- "main": "packages/nx-core/src/index.ts",
14
- "tsConfig": "packages/nx-core/tsconfig.lib.json",
15
- "assets": [
16
- "./packages/nx-core/*.md",
17
- {
18
- "input": "./packages/nx-core/src",
19
- "glob": "**/!(*.ts)",
20
- "output": "./src"
21
- },
22
- {
23
- "input": "./packages/nx-core/src",
24
- "glob": "**/*.d.ts",
25
- "output": "./src"
26
- },
27
- {
28
- "input": "./packages/nx-core",
29
- "glob": "executors.json",
30
- "output": "."
31
- }
32
- ]
33
- }
34
- },
35
- "test": {
36
- "executor": "@nx/vite:test",
37
- "outputs": ["{options.reportsDirectory}"],
38
- "options": {
39
- "reportsDirectory": "../../coverage/packages/nx-core"
40
- }
41
- }
42
- }
43
- }
@@ -1,34 +0,0 @@
1
- import * as fs from 'node:fs'
2
- import { join } from 'path'
3
-
4
- import { ExecutorContext } from '@nx/devkit'
5
-
6
- import { checkAwsAuth, loginToEcr, pushImageToEcr } from '../../utils/aws-auth'
7
- import { buildDockerImage } from '../../utils/docker'
8
- import { PublisherExecutorOptions } from './schema'
9
-
10
- export async function publishDocker(
11
- options: PublisherExecutorOptions,
12
- context: ExecutorContext,
13
- version: string,
14
- ): Promise<{
15
- success: boolean
16
- }> {
17
- await checkAwsAuth()
18
- await loginToEcr()
19
-
20
- const projectRoot =
21
- context.projectsConfigurations.projects[context.projectName].root
22
- const projectDockerfile = join(projectRoot, 'Dockerfile')
23
-
24
- if (!fs.existsSync(projectDockerfile)) {
25
- throw new Error('Dockerfile not found in project root')
26
- }
27
- console.log('Building docker image with version ' + version)
28
- await buildDockerImage(options.ecrRegistry, projectDockerfile, version)
29
-
30
- console.log(
31
- `Publishing docker image to ${options.ecrRegistry} with version ${version}`,
32
- )
33
- return await pushImageToEcr(options.ecrRegistry, version)
34
- }
@@ -1,30 +0,0 @@
1
- import { ExecutorContext } from '@nx/devkit'
2
-
3
- import { getVersion } from '../../utils/get-version'
4
- import { publishDocker } from './docker'
5
- import { publishHelm } from './helm'
6
- import { PublisherExecutorOptions, PublisherExecutorSchema } from './schema'
7
-
8
- const runExecutor: (
9
- options: PublisherExecutorOptions,
10
- context: ExecutorContext,
11
- ) => Promise<PublisherExecutorSchema> = async (
12
- options: PublisherExecutorOptions,
13
- context: ExecutorContext,
14
- ) => {
15
- try {
16
- const version = getVersion(context.projectName)
17
- await publishDocker(options, context, version)
18
- await publishHelm(options, context, version)
19
- } catch (error) {
20
- console.error(error)
21
- return {
22
- success: false,
23
- }
24
- }
25
- return {
26
- success: true,
27
- }
28
- }
29
-
30
- export default runExecutor
@@ -1,55 +0,0 @@
1
- import * as fs from 'node:fs'
2
-
3
- import { ExecutorContext } from '@nx/devkit'
4
-
5
- import { checkAwsAuth } from '../../utils/aws-auth'
6
- import { getSanitizedCurrentGitBranch } from '../../utils/github'
7
- import {
8
- installHelmRepo,
9
- packageHelm,
10
- pushPackagedHelm,
11
- resetTeleportProxyHelmChartFile,
12
- setupTeleportProxyHelmChartFile,
13
- } from '../../utils/helm'
14
- import { getLocalPortForChartMuseum } from '../../utils/tsh'
15
- import { PublisherExecutorOptions } from './schema'
16
-
17
- export async function publishHelm(
18
- options: PublisherExecutorOptions,
19
- context: ExecutorContext,
20
- version: string,
21
- ): Promise<{
22
- success: boolean
23
- stdout: any
24
- stderr: any
25
- }> {
26
- const projectHelmFolder = `apps/${context.projectName}/.deploy`
27
- const destinationHelmFolder = `dist/apps/${context.projectName}/chart/`
28
- const gitBranchName = await getSanitizedCurrentGitBranch()
29
-
30
- if (!gitBranchName) throw new Error('Unable to get current Git branch')
31
-
32
- await checkAwsAuth()
33
-
34
- if (!fs.existsSync(projectHelmFolder)) {
35
- throw new Error(
36
- `.deploy folder not found for project ${context.projectName}`,
37
- )
38
- }
39
- console.log(
40
- `Publishing Helm chart to ${options.chartRegistry}/${gitBranchName} with version ${version}`,
41
- )
42
- // connect to the chartmuseum through teleport
43
- using proxyData = await getLocalPortForChartMuseum()
44
- await proxyData.isReady()
45
-
46
- await setupTeleportProxyHelmChartFile(projectHelmFolder, proxyData.port)
47
- await installHelmRepo(projectHelmFolder)
48
- await packageHelm(projectHelmFolder, version, destinationHelmFolder)
49
- await resetTeleportProxyHelmChartFile(projectHelmFolder, proxyData.port)
50
- return pushPackagedHelm(
51
- `${destinationHelmFolder}${context.projectName}-${version}.tgz`,
52
- options.chartRegistry,
53
- gitBranchName,
54
- )
55
- }
package/src/index.ts DELETED
@@ -1,77 +0,0 @@
1
- import { existsSync } from 'fs'
2
- import { dirname, join } from 'path'
3
-
4
- import {
5
- CreateNodesContextV2,
6
- createNodesFromFiles,
7
- CreateNodesV2,
8
- readJsonFile,
9
- } from '@nx/devkit'
10
-
11
- // eslint-disable-next-line @typescript-eslint/no-empty-interface, @typescript-eslint/no-empty-object-type
12
- export interface MyPluginOptions {}
13
-
14
- export const createNodesV2: CreateNodesV2<MyPluginOptions> = [
15
- '**/project.json',
16
- async (configFiles, options, context) => {
17
- return await createNodesFromFiles(
18
- (configFile, options, context) =>
19
- createNodesInternal(configFile, options, context),
20
- configFiles,
21
- options,
22
- context,
23
- )
24
- },
25
- ]
26
-
27
- async function createNodesInternal(
28
- configFilePath: string,
29
- options: MyPluginOptions,
30
- context: CreateNodesContextV2,
31
- ) {
32
- const projectConfiguration = readJsonFile(configFilePath)
33
- const projectRoot = dirname(configFilePath)
34
-
35
- const isDockerProject = existsSync(join(projectRoot, 'Dockerfile'))
36
- const isHelmProject = existsSync(join(projectRoot, '.deploy/Chart.yaml'))
37
-
38
- const targets = {}
39
-
40
- const ecrRegistry = isDockerProject
41
- ? projectConfiguration.metadata &&
42
- projectConfiguration.metadata['ecrRepository']
43
- : undefined
44
- const chartRegistry = isHelmProject
45
- ? projectConfiguration.metadata &&
46
- projectConfiguration.metadata['chartRegistry']
47
- : undefined
48
-
49
- if (isHelmProject || isDockerProject) {
50
- const publisherConfig = readJsonFile(
51
- join(__dirname, '/executors/publisher/schema.json'),
52
- )
53
- targets['nx-release-publish'] = {
54
- executor: '@payfit/nx-core:publisher',
55
- options: {
56
- ecrRegistry,
57
- chartRegistry,
58
- },
59
- cache: true,
60
- inputs: ['production', '^production'],
61
- outputs: [`{workspaceRoot}/dist/apps/${projectConfiguration.name}/chart`],
62
- metadata: {
63
- technologies: ['helm', 'docker'],
64
- description: publisherConfig.description,
65
- },
66
- }
67
- }
68
-
69
- return {
70
- projects: {
71
- [projectRoot]: {
72
- ...projectConfiguration,
73
- targets,
74
- },
75
- },
76
- }
77
- }