@otwld/nx-helm 0.0.8 → 0.0.10
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/executors.json +15 -10
- package/generators.json +3 -15
- package/package.json +8 -8
- package/src/executors/commands.d.ts +22 -0
- package/src/executors/commands.js +113 -0
- package/src/executors/commands.js.map +1 -0
- package/src/executors/lint.schema.json +9 -0
- package/src/executors/package.schema.json +7 -0
- package/src/executors/release-publish.schema.json +9 -0
- package/src/executors/template.schema.json +12 -0
- package/src/generators/chart.d.ts +9 -0
- package/src/generators/chart.js +97 -0
- package/src/generators/chart.js.map +1 -0
- package/src/generators/chart.schema.json +17 -0
- package/src/index.d.ts +3 -6
- package/src/index.js +4 -13
- package/src/index.js.map +1 -0
- package/src/plugin.d.ts +7 -0
- package/src/plugin.js +65 -0
- package/src/plugin.js.map +1 -0
- package/src/release/version-actions.d.ts +10 -56
- package/src/release/version-actions.js +32 -101
- package/src/release/version-actions.js.map +1 -0
- package/CHANGELOG.md +0 -48
- package/README.md +0 -131
- package/src/chart-manifest.d.ts +0 -22
- package/src/chart-manifest.js +0 -56
- package/src/executors/package/package.d.ts +0 -10
- package/src/executors/package/package.js +0 -57
- package/src/executors/package/schema.d.ts +0 -7
- package/src/executors/package/schema.json +0 -18
- package/src/executors/project-directory.d.ts +0 -8
- package/src/executors/project-directory.js +0 -23
- package/src/executors/release-publish/release-publish.d.ts +0 -10
- package/src/executors/release-publish/release-publish.js +0 -102
- package/src/executors/release-publish/schema.d.ts +0 -9
- package/src/executors/release-publish/schema.json +0 -22
- package/src/executors/run-helm.d.ts +0 -7
- package/src/executors/run-helm.js +0 -32
- package/src/executors/validate/schema.d.ts +0 -11
- package/src/executors/validate/schema.json +0 -29
- package/src/executors/validate/validate.d.ts +0 -16
- package/src/executors/validate/validate.js +0 -50
- package/src/generators/chart/chart.d.ts +0 -10
- package/src/generators/chart/chart.js +0 -101
- package/src/generators/chart/schema.d.ts +0 -13
- package/src/generators/chart/schema.json +0 -43
- package/src/generators/init/init.d.ts +0 -9
- package/src/generators/init/init.js +0 -37
- package/src/generators/init/schema.d.ts +0 -5
- package/src/generators/init/schema.json +0 -15
- package/src/generators/stack/schema.d.ts +0 -27
- package/src/generators/stack/schema.json +0 -50
- package/src/generators/stack/stack.d.ts +0 -4
- package/src/generators/stack/stack.js +0 -214
- package/src/plugins/plugin.d.ts +0 -38
- package/src/plugins/plugin.js +0 -352
package/executors.json
CHANGED
|
@@ -1,20 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json-schema.org/schema",
|
|
3
3
|
"executors": {
|
|
4
|
-
"
|
|
5
|
-
"implementation": "./src/executors/
|
|
6
|
-
"schema": "./src/executors/
|
|
7
|
-
"description": "
|
|
4
|
+
"lint": {
|
|
5
|
+
"implementation": "./src/executors/commands#lintExecutor",
|
|
6
|
+
"schema": "./src/executors/lint.schema.json",
|
|
7
|
+
"description": "Run helm lint for a standalone chart."
|
|
8
|
+
},
|
|
9
|
+
"template": {
|
|
10
|
+
"implementation": "./src/executors/commands#templateExecutor",
|
|
11
|
+
"schema": "./src/executors/template.schema.json",
|
|
12
|
+
"description": "Render a standalone chart with Helm."
|
|
8
13
|
},
|
|
9
14
|
"package": {
|
|
10
|
-
"implementation": "./src/executors/
|
|
11
|
-
"schema": "./src/executors/package
|
|
12
|
-
"description": "Package
|
|
15
|
+
"implementation": "./src/executors/commands#packageExecutor",
|
|
16
|
+
"schema": "./src/executors/package.schema.json",
|
|
17
|
+
"description": "Package a standalone chart with Helm."
|
|
13
18
|
},
|
|
14
19
|
"release-publish": {
|
|
15
|
-
"implementation": "./src/executors/
|
|
16
|
-
"schema": "./src/executors/release-publish
|
|
17
|
-
"description": "
|
|
20
|
+
"implementation": "./src/executors/commands#releasePublishExecutor",
|
|
21
|
+
"schema": "./src/executors/release-publish.schema.json",
|
|
22
|
+
"description": "Nx Release lifecycle publisher for Helm charts.",
|
|
18
23
|
"hidden": true
|
|
19
24
|
}
|
|
20
25
|
}
|
package/generators.json
CHANGED
|
@@ -1,22 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json-schema.org/schema",
|
|
3
3
|
"generators": {
|
|
4
|
-
"init": {
|
|
5
|
-
"factory": "./src/generators/init/init",
|
|
6
|
-
"schema": "./src/generators/init/schema.json",
|
|
7
|
-
"description": "Initialize the @otwld/nx-helm plugin.",
|
|
8
|
-
"aliases": ["ng-add"],
|
|
9
|
-
"hidden": true
|
|
10
|
-
},
|
|
11
4
|
"chart": {
|
|
12
|
-
"factory": "./src/generators/chart
|
|
13
|
-
"schema": "./src/generators/chart
|
|
14
|
-
"description": "Create a standalone Helm chart
|
|
15
|
-
},
|
|
16
|
-
"stack": {
|
|
17
|
-
"factory": "./src/generators/stack/stack",
|
|
18
|
-
"schema": "./src/generators/stack/schema.json",
|
|
19
|
-
"description": "Create a generic Helm umbrella chart Nx project."
|
|
5
|
+
"factory": "./src/generators/chart",
|
|
6
|
+
"schema": "./src/generators/chart.schema.json",
|
|
7
|
+
"description": "Create a standalone Helm chart project."
|
|
20
8
|
}
|
|
21
9
|
}
|
|
22
10
|
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@otwld/nx-helm",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10",
|
|
4
4
|
"private": false,
|
|
5
|
-
"type": "
|
|
5
|
+
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
8
8
|
"@nx/nx-source": "./src/index.ts",
|
|
9
9
|
"types": "./src/index.d.ts",
|
|
10
|
+
"import": "./src/index.js",
|
|
10
11
|
"default": "./src/index.js"
|
|
11
12
|
},
|
|
12
13
|
"./release": {
|
|
@@ -16,19 +17,18 @@
|
|
|
16
17
|
},
|
|
17
18
|
"./package.json": "./package.json",
|
|
18
19
|
"./executors.json": "./executors.json",
|
|
19
|
-
"./generators.json": "./generators.json"
|
|
20
|
-
"./release/version-actions": "./src/release/version-actions.js"
|
|
20
|
+
"./generators.json": "./generators.json"
|
|
21
21
|
},
|
|
22
22
|
"main": "./src/index.js",
|
|
23
|
+
"module": "./src/index.js",
|
|
23
24
|
"types": "./src/index.d.ts",
|
|
24
25
|
"dependencies": {
|
|
25
26
|
"@nx/devkit": "23.1.1",
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"yaml": "^2.9.0"
|
|
27
|
+
"tslib": "^2.8.1",
|
|
28
|
+
"yaml": "2.9.0"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"nx": "
|
|
31
|
+
"nx": "23.1.1"
|
|
32
32
|
},
|
|
33
33
|
"publishConfig": {
|
|
34
34
|
"access": "public"
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { PromiseExecutor } from '@nx/devkit';
|
|
2
|
+
interface LintOptions {
|
|
3
|
+
strict?: boolean;
|
|
4
|
+
valuesFiles?: string[];
|
|
5
|
+
}
|
|
6
|
+
interface TemplateOptions {
|
|
7
|
+
outputPath: string;
|
|
8
|
+
releaseName?: string;
|
|
9
|
+
valuesFiles?: string[];
|
|
10
|
+
}
|
|
11
|
+
interface PackageOptions {
|
|
12
|
+
outputPath: string;
|
|
13
|
+
}
|
|
14
|
+
interface ReleasePublishOptions {
|
|
15
|
+
registry: string;
|
|
16
|
+
outputPath: string;
|
|
17
|
+
}
|
|
18
|
+
export declare const lintExecutor: PromiseExecutor<LintOptions>;
|
|
19
|
+
export declare const templateExecutor: PromiseExecutor<TemplateOptions>;
|
|
20
|
+
export declare const packageExecutor: PromiseExecutor<PackageOptions>;
|
|
21
|
+
export declare const releasePublishExecutor: PromiseExecutor<ReleasePublishOptions>;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { spawnSync } from 'node:child_process';
|
|
2
|
+
import { existsSync, mkdirSync, readdirSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { dirname, join, resolve } from 'node:path';
|
|
4
|
+
export const lintExecutor = async (options, context) => {
|
|
5
|
+
try {
|
|
6
|
+
const root = chartRoot(context);
|
|
7
|
+
buildDependencies(root);
|
|
8
|
+
helm([
|
|
9
|
+
'lint',
|
|
10
|
+
'.',
|
|
11
|
+
...(options.strict ? ['--strict'] : []),
|
|
12
|
+
...valueArguments(options.valuesFiles),
|
|
13
|
+
], root);
|
|
14
|
+
return { success: true };
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
console.error(error instanceof Error ? error.message : error);
|
|
18
|
+
return { success: false };
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
export const templateExecutor = async (options, context) => {
|
|
22
|
+
try {
|
|
23
|
+
const root = chartRoot(context);
|
|
24
|
+
buildDependencies(root);
|
|
25
|
+
const output = resolve(context.root, interpolate(options.outputPath, context));
|
|
26
|
+
mkdirSync(dirname(output), { recursive: true });
|
|
27
|
+
writeFileSync(output, helm([
|
|
28
|
+
'template',
|
|
29
|
+
options.releaseName
|
|
30
|
+
? interpolate(options.releaseName, context)
|
|
31
|
+
: (context.projectName ?? 'chart'),
|
|
32
|
+
'.',
|
|
33
|
+
...valueArguments(options.valuesFiles),
|
|
34
|
+
], root));
|
|
35
|
+
return { success: true };
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
console.error(error instanceof Error ? error.message : error);
|
|
39
|
+
return { success: false };
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
export const packageExecutor = async (options, context) => {
|
|
43
|
+
try {
|
|
44
|
+
const root = chartRoot(context);
|
|
45
|
+
buildDependencies(root);
|
|
46
|
+
const output = resolve(context.root, interpolate(options.outputPath, context));
|
|
47
|
+
mkdirSync(output, { recursive: true });
|
|
48
|
+
helm(['package', '.', '--destination', output], root);
|
|
49
|
+
return { success: true };
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
console.error(error instanceof Error ? error.message : error);
|
|
53
|
+
return { success: false };
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
export const releasePublishExecutor = async (options, context) => {
|
|
57
|
+
try {
|
|
58
|
+
if (!options.registry.startsWith('oci://'))
|
|
59
|
+
throw new Error('[nx-helm] registry must be an OCI repository.');
|
|
60
|
+
const root = chartRoot(context);
|
|
61
|
+
buildDependencies(root, true);
|
|
62
|
+
helm(['lint', '.'], root);
|
|
63
|
+
helm(['template', context.projectName ?? 'chart', '.'], root);
|
|
64
|
+
const output = resolve(context.root, interpolate(options.outputPath, context));
|
|
65
|
+
mkdirSync(output, { recursive: true });
|
|
66
|
+
const before = new Set(readdirSync(output));
|
|
67
|
+
// Helm, not this adapter, reads Chart.yaml and chooses the versioned archive.
|
|
68
|
+
helm(['package', '.', '--destination', output], root);
|
|
69
|
+
const archives = readdirSync(output).filter((file) => file.endsWith('.tgz') && !before.has(file));
|
|
70
|
+
if (archives.length !== 1)
|
|
71
|
+
throw new Error('[nx-helm] Helm must create exactly one new chart archive for publication.');
|
|
72
|
+
helm(['push', join(output, archives[0]), options.registry], root);
|
|
73
|
+
return { success: true };
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
console.error(error instanceof Error ? error.message : error);
|
|
77
|
+
return { success: false };
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
function chartRoot(context) {
|
|
81
|
+
const project = context.projectName &&
|
|
82
|
+
context.projectsConfigurations?.projects[context.projectName];
|
|
83
|
+
if (!project)
|
|
84
|
+
throw new Error('[nx-helm] The executor requires an Nx project context.');
|
|
85
|
+
return resolve(context.root, project.root);
|
|
86
|
+
}
|
|
87
|
+
function interpolate(value, context) {
|
|
88
|
+
return value
|
|
89
|
+
.replaceAll('{projectName}', context.projectName ?? '')
|
|
90
|
+
.replaceAll('{projectRoot}', context.projectsConfigurations?.projects[context.projectName ?? '']
|
|
91
|
+
?.root ?? '');
|
|
92
|
+
}
|
|
93
|
+
function helm(args, cwd) {
|
|
94
|
+
const result = spawnSync('/usr/bin/env', ['helm', ...args], {
|
|
95
|
+
cwd,
|
|
96
|
+
encoding: 'utf8',
|
|
97
|
+
});
|
|
98
|
+
if (result.status !== 0)
|
|
99
|
+
throw new Error(`[nx-helm] helm ${args[0]} failed: ${(result.stderr || result.stdout).trim()}`);
|
|
100
|
+
return result.stdout;
|
|
101
|
+
}
|
|
102
|
+
function buildDependencies(root, requireLock = false) {
|
|
103
|
+
if (!existsSync(join(root, 'Chart.lock'))) {
|
|
104
|
+
if (requireLock)
|
|
105
|
+
throw new Error(`[nx-helm] ${join(root, 'Chart.lock')} is required for release publication.`);
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
helm(['dependency', 'build', '--skip-refresh', '.'], root);
|
|
109
|
+
}
|
|
110
|
+
function valueArguments(valuesFiles) {
|
|
111
|
+
return valuesFiles?.flatMap((file) => ['--values', file]) ?? [];
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=commands.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commands.js","sourceRoot":"","sources":["../../../../../../plugins/nx/helm/src/executors/commands.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC5E,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAsBnD,MAAM,CAAC,MAAM,YAAY,GAAiC,KAAK,EAC7D,OAAO,EACP,OAAO,EACP,EAAE;IACF,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;QAChC,iBAAiB,CAAC,IAAI,CAAC,CAAC;QACxB,IAAI,CACF;YACE,MAAM;YACN,GAAG;YACH,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAC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AK,CACb,aAAa,IAAI,CAAC,IAAI,EAAE,YAAY,CAAC,uCAAuC,CAC7E,CAAC;QACJ,OAAO;IACT,CAAC;IACD,IAAI,CAAC,CAAC,YAAY,EAAE,OAAO,EAAE,gBAAgB,EAAE,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC;AAC7D,CAAC;AAED,SAAS,cAAc,CAAC,WAAsB;IAC5C,OAAO,WAAW,EAAE,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC;AAClE,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
|
+
"type": "object",
|
|
4
|
+
"additionalProperties": false,
|
|
5
|
+
"properties": {
|
|
6
|
+
"outputPath": { "type": "string" },
|
|
7
|
+
"releaseName": { "type": "string" },
|
|
8
|
+
"valuesFiles": { "type": "array", "items": { "type": "string" } },
|
|
9
|
+
"configuration": { "type": "string" }
|
|
10
|
+
},
|
|
11
|
+
"required": ["outputPath"]
|
|
12
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type Tree } from '@nx/devkit';
|
|
2
|
+
export interface ChartGeneratorOptions {
|
|
3
|
+
name: string;
|
|
4
|
+
directory?: string;
|
|
5
|
+
projectName?: string;
|
|
6
|
+
registry?: string;
|
|
7
|
+
tags?: string[];
|
|
8
|
+
}
|
|
9
|
+
export default function chartGenerator(tree: Tree, options: ChartGeneratorOptions): Promise<void>;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { addProjectConfiguration, getProjects, joinPathFragments, readNxJson, updateNxJson, } from '@nx/devkit';
|
|
2
|
+
import { spawnSync } from 'node:child_process';
|
|
3
|
+
import { mkdtempSync, readdirSync, readFileSync, rmSync, writeFileSync, } from 'node:fs';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
import { tmpdir } from 'node:os';
|
|
6
|
+
const chartName = /^[a-z0-9](?:[-a-z0-9]*[a-z0-9])?$/;
|
|
7
|
+
export default async function chartGenerator(tree, options) {
|
|
8
|
+
if (!chartName.test(options.name) || options.name.length > 63)
|
|
9
|
+
throw new Error('[nx-helm] Chart names must be lower-case DNS labels of at most 63 characters.');
|
|
10
|
+
const root = joinPathFragments(options.directory ?? 'charts', options.name);
|
|
11
|
+
const projectName = options.projectName ?? options.name;
|
|
12
|
+
const releaseGroup = `helm-${projectName}`;
|
|
13
|
+
if (tree.exists(root) || tree.exists(joinPathFragments(root, 'project.json')))
|
|
14
|
+
throw new Error(`[nx-helm] Refusing to overwrite ${root}.`);
|
|
15
|
+
if (getProjects(tree).has(projectName))
|
|
16
|
+
throw new Error(`[nx-helm] Refusing to overwrite existing Nx project ${projectName}.`);
|
|
17
|
+
const nxJson = readNxJson(tree) ?? {};
|
|
18
|
+
if (nxJson.release?.groups?.[releaseGroup])
|
|
19
|
+
throw new Error(`[nx-helm] Refusing to overwrite existing Nx Release group ${releaseGroup}.`);
|
|
20
|
+
const temporary = mkdtempSync(join(tmpdir(), 'otwld-helm-'));
|
|
21
|
+
try {
|
|
22
|
+
const generated = join(temporary, options.name);
|
|
23
|
+
helm(['create', generated], temporary);
|
|
24
|
+
prepareDependencyLock(generated);
|
|
25
|
+
copyDirectory(tree, generated, root);
|
|
26
|
+
}
|
|
27
|
+
finally {
|
|
28
|
+
rmSync(temporary, { recursive: true, force: true });
|
|
29
|
+
}
|
|
30
|
+
addProjectConfiguration(tree, projectName, {
|
|
31
|
+
root,
|
|
32
|
+
projectType: 'application',
|
|
33
|
+
tags: options.tags ?? [
|
|
34
|
+
'type:chart',
|
|
35
|
+
`scope:${options.name}`,
|
|
36
|
+
'artifact:oci-chart',
|
|
37
|
+
],
|
|
38
|
+
metadata: { helm: options.registry ? { registry: options.registry } : {} },
|
|
39
|
+
});
|
|
40
|
+
updateNxJson(tree, {
|
|
41
|
+
...nxJson,
|
|
42
|
+
release: {
|
|
43
|
+
...nxJson.release,
|
|
44
|
+
groups: {
|
|
45
|
+
...nxJson.release?.groups,
|
|
46
|
+
[releaseGroup]: {
|
|
47
|
+
projects: [projectName],
|
|
48
|
+
projectsRelationship: 'independent',
|
|
49
|
+
releaseTag: {
|
|
50
|
+
pattern: 'helm/{projectName}/{version}',
|
|
51
|
+
requireSemver: true,
|
|
52
|
+
},
|
|
53
|
+
version: {
|
|
54
|
+
versionActions: '@otwld/nx-helm/release',
|
|
55
|
+
versionActionsOptions: { registry: options.registry ?? '' },
|
|
56
|
+
currentVersionResolver: 'git-tag',
|
|
57
|
+
fallbackCurrentVersionResolver: 'disk',
|
|
58
|
+
specifierSource: 'conventional-commits',
|
|
59
|
+
updateDependents: 'never',
|
|
60
|
+
},
|
|
61
|
+
changelog: { createRelease: false },
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
/** Runs Helm's dependency workflow to create the committed Chart.lock. */
|
|
68
|
+
function prepareDependencyLock(chartDirectory) {
|
|
69
|
+
const chartPath = join(chartDirectory, 'Chart.yaml');
|
|
70
|
+
const chart = readFileSync(chartPath, 'utf8');
|
|
71
|
+
writeFileSync(chartPath, `${chart.trimEnd()}\ndependencies: []\n`);
|
|
72
|
+
helm(['dependency', 'update', '--skip-refresh', '.'], chartDirectory);
|
|
73
|
+
const ignorePath = join(chartDirectory, '.helmignore');
|
|
74
|
+
const ignore = readFileSync(ignorePath, 'utf8');
|
|
75
|
+
if (!ignore.split(/\r?\n/).includes('charts/'))
|
|
76
|
+
writeFileSync(ignorePath, `${ignore.trimEnd()}\ncharts/\n`);
|
|
77
|
+
}
|
|
78
|
+
function copyDirectory(tree, source, destination) {
|
|
79
|
+
for (const entry of readdirSync(source, { withFileTypes: true })) {
|
|
80
|
+
const from = join(source, entry.name);
|
|
81
|
+
const to = joinPathFragments(destination, entry.name);
|
|
82
|
+
if (entry.isDirectory())
|
|
83
|
+
copyDirectory(tree, from, to);
|
|
84
|
+
else if (entry.isFile())
|
|
85
|
+
tree.write(to, readFileSync(from));
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
function helm(args, cwd) {
|
|
89
|
+
const result = spawnSync('/usr/bin/env', ['helm', ...args], {
|
|
90
|
+
cwd,
|
|
91
|
+
encoding: 'utf8',
|
|
92
|
+
});
|
|
93
|
+
if (result.status !== 0)
|
|
94
|
+
throw new Error(`[nx-helm] helm ${args[0]} failed: ${(result.stderr || result.stdout).trim()}`);
|
|
95
|
+
return result.stdout;
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=chart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chart.js","sourceRoot":"","sources":["../../../../../../plugins/nx/helm/src/generators/chart.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,WAAW,EACX,iBAAiB,EACjB,UAAU,EACV,YAAY,GAEb,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EACL,WAAW,EACX,WAAW,EACX,YAAY,EACZ,MAAM,EACN,aAAa,GACd,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAUjC,MAAM,SAAS,GAAG,mCAAmC,CAAC;AAEtD,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,cAAc,CAC1C,IAAU,EACV,OAA8B;IAE9B,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,GAAG,EAAE;QAC3D,MAAM,IAAI,KAAK,CACb,+EAA+E,CAChF,CAAC;IACJ,MAAM,IAAI,GAAG,iBAAiB,CAAC,OAAO,CAAC,SAAS,IAAI,QAAQ,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5E,MAAM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,CAAC,CAAC,IAAI,EAAE,EAAE,CAC/E,CAAC;IACJ,OAAO,MAAM,CAAC,MAAM,CAAC;AACvB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
|
+
"type": "object",
|
|
4
|
+
"additionalProperties": false,
|
|
5
|
+
"properties": {
|
|
6
|
+
"name": {
|
|
7
|
+
"type": "string",
|
|
8
|
+
"pattern": "^[a-z0-9]([-a-z0-9]*[a-z0-9])?$",
|
|
9
|
+
"$default": { "source": "argv", "index": 0 }
|
|
10
|
+
},
|
|
11
|
+
"directory": { "type": "string", "default": "charts" },
|
|
12
|
+
"projectName": { "type": "string" },
|
|
13
|
+
"registry": { "type": "string" },
|
|
14
|
+
"tags": { "type": "array", "items": { "type": "string" } }
|
|
15
|
+
},
|
|
16
|
+
"required": ["name"]
|
|
17
|
+
}
|
package/src/index.d.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export type { ChartGeneratorSchema } from './generators/chart/schema';
|
|
5
|
-
export { default as stackGenerator } from './generators/stack/stack';
|
|
6
|
-
export type { StackDependency, StackGeneratorSchema, } from './generators/stack/schema';
|
|
1
|
+
export { createNodes } from './plugin.js';
|
|
2
|
+
export { default as chartGenerator } from './generators/chart.js';
|
|
3
|
+
export { lintExecutor, packageExecutor, releasePublishExecutor, templateExecutor, } from './executors/commands.js';
|
package/src/index.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.stackGenerator = exports.chartGenerator = exports.createNodes = void 0;
|
|
7
|
-
/** Public inferred-task, generator, and release exports for the Helm package. */
|
|
8
|
-
var plugin_1 = require("./plugins/plugin");
|
|
9
|
-
Object.defineProperty(exports, "createNodes", { enumerable: true, get: function () { return plugin_1.createNodes; } });
|
|
10
|
-
var chart_1 = require("./generators/chart/chart");
|
|
11
|
-
Object.defineProperty(exports, "chartGenerator", { enumerable: true, get: function () { return __importDefault(chart_1).default; } });
|
|
12
|
-
var stack_1 = require("./generators/stack/stack");
|
|
13
|
-
Object.defineProperty(exports, "stackGenerator", { enumerable: true, get: function () { return __importDefault(stack_1).default; } });
|
|
1
|
+
export { createNodes } from './plugin.js';
|
|
2
|
+
export { default as chartGenerator } from './generators/chart.js';
|
|
3
|
+
export { lintExecutor, packageExecutor, releasePublishExecutor, templateExecutor, } from './executors/commands.js';
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../plugins/nx/helm/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EACL,YAAY,EACZ,eAAe,EACf,sBAAsB,EACtB,gBAAgB,GACjB,MAAM,yBAAyB,CAAC"}
|
package/src/plugin.d.ts
ADDED
package/src/plugin.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { createNodesFromFiles, readJsonFile } from '@nx/devkit';
|
|
2
|
+
import { existsSync } from 'node:fs';
|
|
3
|
+
import { dirname, join, relative } from 'node:path';
|
|
4
|
+
const helmRuntime = { runtime: "helm version --template '{{.Version}}'" };
|
|
5
|
+
export const createNodes = [
|
|
6
|
+
'**/Chart.yaml',
|
|
7
|
+
async (files, options, context) => createNodesFromFiles((file, pluginOptions, callbackContext) => createChartNodes(file, pluginOptions, callbackContext), files, options, context),
|
|
8
|
+
];
|
|
9
|
+
function createChartNodes(file, options, context) {
|
|
10
|
+
const absoluteRoot = dirname(join(context.workspaceRoot, file));
|
|
11
|
+
const root = relative(context.workspaceRoot, absoluteRoot).replaceAll('\\', '/');
|
|
12
|
+
if (!root ||
|
|
13
|
+
root.startsWith('..') ||
|
|
14
|
+
!existsSync(join(absoluteRoot, 'project.json')))
|
|
15
|
+
return {};
|
|
16
|
+
const inputs = ['{projectRoot}/**/*', helmRuntime];
|
|
17
|
+
const targets = {
|
|
18
|
+
'helm:lint': { executor: '@otwld/nx-helm:lint', cache: true, inputs },
|
|
19
|
+
'helm:template': {
|
|
20
|
+
executor: '@otwld/nx-helm:template',
|
|
21
|
+
cache: true,
|
|
22
|
+
inputs,
|
|
23
|
+
outputs: ['{workspaceRoot}/dist/{projectName}/helm-template.yaml'],
|
|
24
|
+
options: {
|
|
25
|
+
outputPath: 'dist/{projectName}/helm-template.yaml',
|
|
26
|
+
releaseName: '{projectName}',
|
|
27
|
+
},
|
|
28
|
+
configurations: { staging: {}, production: {} },
|
|
29
|
+
},
|
|
30
|
+
'helm:package': {
|
|
31
|
+
executor: '@otwld/nx-helm:package',
|
|
32
|
+
cache: true,
|
|
33
|
+
inputs,
|
|
34
|
+
outputs: ['{workspaceRoot}/dist/{projectName}'],
|
|
35
|
+
options: { outputPath: 'dist/{projectName}' },
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
// A chart owns its OCI repository in project metadata. A workspace plugin
|
|
39
|
+
// option is deliberately only an explicit cross-chart override.
|
|
40
|
+
const registry = readRegistry(options?.publish?.registry) ??
|
|
41
|
+
readProjectRegistry(absoluteRoot);
|
|
42
|
+
if (registry)
|
|
43
|
+
targets['nx-release-publish'] = {
|
|
44
|
+
executor: '@otwld/nx-helm:release-publish',
|
|
45
|
+
cache: false,
|
|
46
|
+
options: { registry, outputPath: 'dist/{projectName}' },
|
|
47
|
+
};
|
|
48
|
+
return {
|
|
49
|
+
projects: {
|
|
50
|
+
[root]: {
|
|
51
|
+
root,
|
|
52
|
+
targets,
|
|
53
|
+
metadata: { targetGroups: { Helm: Object.keys(targets) } },
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function readProjectRegistry(root) {
|
|
59
|
+
const project = readJsonFile(join(root, 'project.json'));
|
|
60
|
+
return readRegistry(project.metadata?.helm?.registry);
|
|
61
|
+
}
|
|
62
|
+
function readRegistry(value) {
|
|
63
|
+
return typeof value === 'string' && value.trim() ? value.trim() : undefined;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../../../../plugins/nx/helm/src/plugin.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAUpD,MAAM,WAAW,GAAG,EAAE,OAAO,EAAE,wCAAwC,EAAE,CAAC;AAE1E,MAAM,CAAC,MAAM,WAAW,GAAmC;IACzD,eAAe;IACf,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,CAChC,oBAAoB,CAClB,CAAC,IAAI,EAAE,aAAa,EAAE,eAAe,EAAE,EAAE,CACvC,gBAAgB,CAAC,IAAI,EAAE,aAAa,EAAE,eAAe,CAAC,EACxD,KAAK,EACL,OAAO,EACP,OAAO,CACR;CACJ,CAAC;AACF,SAAS,gBAAgB,CACvB,IAAY,EACZ,OAAsC,EACtC,OAA2B;IAE3B,MAAM,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC,CAAC;IAChE,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC,UAAU,CACnE,IAAI,EACJ,GAAG,CACJ,CAAC;IACF,IACE,CAAC,IAAI;QACL,IAAI,CAAC,UAAU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C,OAAO,CAAC,EAAE,EAAE;aAC3D;SACF;KACF,CAAC;AACJ,CAAC;AAED,SAAS,mBAAmB,CAAC,IAAY;IACvC,MAAM,OAAO,GAAG,YAAY,CAAkB,IAAI,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC;IAC1E,OAAO,YAAY,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;AACxD,CAAC;AAED,SAAS,YAAY,CAAC,KAAc;IAClC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AAC9E,CAAC"}
|
|
@@ -1,67 +1,21 @@
|
|
|
1
|
-
import type { Tree } from '@nx/devkit';
|
|
2
1
|
import { VersionActions } from 'nx/release';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
*/
|
|
2
|
+
import type { ProjectGraph } from '@nx/devkit';
|
|
3
|
+
import type { Tree } from '@nx/devkit';
|
|
4
|
+
/** Nx Release version-phase actions for standalone Helm charts. */
|
|
7
5
|
export default class HelmVersionActions extends VersionActions {
|
|
8
|
-
/** Chart.yaml is the only source manifest managed by this implementation. */
|
|
9
6
|
validManifestFilenames: string[];
|
|
10
|
-
/**
|
|
11
|
-
* Configures the one root manifest for the release lifecycle.
|
|
12
|
-
* @returns Nothing; the root manifest path is stored for the release lifecycle.
|
|
13
|
-
*/
|
|
14
|
-
init(): Promise<void>;
|
|
15
|
-
/**
|
|
16
|
-
* Validates the root Chart.yaml and its release metadata.
|
|
17
|
-
* @param tree Nx's release file tree.
|
|
18
|
-
* @returns A resolved promise after validation succeeds.
|
|
19
|
-
*/
|
|
20
|
-
validate(tree: Tree): Promise<void>;
|
|
21
|
-
/**
|
|
22
|
-
* Reads the current chart version from the root Chart.yaml.
|
|
23
|
-
* @param tree Nx's release file tree.
|
|
24
|
-
* @returns The current version and manifest path.
|
|
25
|
-
*/
|
|
26
7
|
readCurrentVersionFromSourceManifest(tree: Tree): Promise<{
|
|
27
8
|
currentVersion: string;
|
|
28
9
|
manifestPath: string;
|
|
29
10
|
}>;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
readCurrentVersionFromRegistry(): Promise<null>;
|
|
35
|
-
/**
|
|
36
|
-
* Helm chart dependencies are not represented as Nx package dependencies.
|
|
37
|
-
* @returns No dependency version information.
|
|
38
|
-
*/
|
|
11
|
+
readCurrentVersionFromRegistry(): Promise<{
|
|
12
|
+
currentVersion: string | null;
|
|
13
|
+
logText: string;
|
|
14
|
+
} | null>;
|
|
39
15
|
readCurrentVersionOfDependency(): Promise<{
|
|
40
|
-
currentVersion: null;
|
|
41
|
-
dependencyCollection: null;
|
|
16
|
+
currentVersion: string | null;
|
|
17
|
+
dependencyCollection: string | null;
|
|
42
18
|
}>;
|
|
43
|
-
/**
|
|
44
|
-
* Writes the new chart version to the root Chart.yaml.
|
|
45
|
-
* @param tree Nx's release file tree.
|
|
46
|
-
* @param newVersion New semantic chart version.
|
|
47
|
-
* @returns A log message for the Nx release output.
|
|
48
|
-
*/
|
|
49
19
|
updateProjectVersion(tree: Tree, newVersion: string): Promise<string[]>;
|
|
50
|
-
|
|
51
|
-
* Helm dependency updates are not supported until chart dependencies have
|
|
52
|
-
* corresponding Nx project graph edges.
|
|
53
|
-
* @returns No dependency update log messages.
|
|
54
|
-
*/
|
|
55
|
-
updateProjectDependencies(): Promise<string[]>;
|
|
56
|
-
/**
|
|
57
|
-
* Workspace-relative root Chart.yaml path for this release project.
|
|
58
|
-
* @returns The root Chart.yaml path.
|
|
59
|
-
*/
|
|
60
|
-
private get chartManifestPath();
|
|
61
|
-
/**
|
|
62
|
-
* Reads metadata from the root chart manifest.
|
|
63
|
-
* @param tree Nx's release file tree.
|
|
64
|
-
* @returns Chart metadata.
|
|
65
|
-
*/
|
|
66
|
-
private readMetadata;
|
|
20
|
+
updateProjectDependencies(_tree: Tree, _projectGraph: ProjectGraph, dependenciesToUpdate: Record<string, string>): Promise<string[]>;
|
|
67
21
|
}
|