@otwld/nx-helm 0.0.4 → 0.0.6
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/CHANGELOG.md +24 -0
- package/README.md +52 -10
- package/generators.json +5 -0
- package/package.json +1 -1
- package/src/executors/release-publish/release-publish.js +1 -1
- package/src/generators/chart/chart.js +1 -1
- package/src/generators/chart/schema.d.ts +2 -0
- package/src/generators/chart/schema.json +7 -0
- package/src/generators/init/init.d.ts +1 -1
- package/src/generators/init/init.js +2 -95
- package/src/generators/init/schema.d.ts +0 -10
- package/src/generators/init/schema.json +1 -27
- package/src/generators/stack/schema.d.ts +27 -0
- package/src/generators/stack/schema.json +50 -0
- package/src/generators/stack/stack.d.ts +4 -0
- package/src/generators/stack/stack.js +90 -0
- package/src/index.d.ts +3 -1
- package/src/index.js +3 -1
- package/src/plugins/plugin.d.ts +12 -7
- package/src/plugins/plugin.js +202 -65
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
## 0.0.5 (2026-08-12)
|
|
2
|
+
|
|
3
|
+
### Breaking Changes
|
|
4
|
+
|
|
5
|
+
- Infer cache, outputs, and Helm-version runtime inputs directly on standalone
|
|
6
|
+
chart targets.
|
|
7
|
+
- Replace workspace `validateTarget`, `packageTarget`, and `registry` options
|
|
8
|
+
with `validate`, `package`, and `publish.registry`.
|
|
9
|
+
- Infer `nx-release-publish` only for configured OCI registries; project
|
|
10
|
+
`metadata.helm` can override registry and validation settings or disable
|
|
11
|
+
publishing.
|
|
12
|
+
- Stop injecting target defaults during plugin initialization and stop adding
|
|
13
|
+
organization-specific chart tags.
|
|
14
|
+
|
|
15
|
+
## 0.0.4 (2026-08-12)
|
|
16
|
+
|
|
17
|
+
### 🚀 Features
|
|
18
|
+
|
|
19
|
+
- **plugins:** add nx helm and argo plugins ([eb30b828](https://github.com/otwld/devops/commit/eb30b828))
|
|
20
|
+
|
|
21
|
+
### ❤️ Thank You
|
|
22
|
+
|
|
23
|
+
- Tréhout Nathan
|
|
24
|
+
|
|
1
25
|
## 0.0.3 (2026-08-12)
|
|
2
26
|
|
|
3
27
|
### 🚀 Features
|
package/README.md
CHANGED
|
@@ -19,9 +19,23 @@ charts/service/
|
|
|
19
19
|
└── project.json
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
-
Generated projects use the `helm-<name>` project name
|
|
23
|
-
`
|
|
24
|
-
|
|
22
|
+
Generated projects use the `helm-<name>` project name. The `directory`,
|
|
23
|
+
`projectName`, `starter`, and `tags` options customize generation.
|
|
24
|
+
|
|
25
|
+
## Generate an Umbrella Stack
|
|
26
|
+
|
|
27
|
+
Use `stack` when one chart should package several app-owned charts and other
|
|
28
|
+
Helm dependencies:
|
|
29
|
+
|
|
30
|
+
```shell
|
|
31
|
+
pnpm exec nx g @otwld/nx-helm:stack public \
|
|
32
|
+
--dependencies='[{"name":"public-app","version":"0.1.0","repository":"file://../../apps/public/chart","condition":"public-app.enabled"}]'
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
The generator creates `charts/public/Chart.yaml`, `values.yaml`, a generic
|
|
36
|
+
resources template, and the `helm-public` Nx project marker. Run `helm dependency
|
|
37
|
+
update charts/public` after adding dependencies so the generated `Chart.lock` is
|
|
38
|
+
committed; validation and packaging then use `helm dependency build`.
|
|
25
39
|
|
|
26
40
|
## Inferred Targets
|
|
27
41
|
|
|
@@ -29,7 +43,15 @@ Charts with sibling `Chart.yaml` and `project.json` files receive these targets:
|
|
|
29
43
|
|
|
30
44
|
- `helm:validate` runs `helm lint` and `helm template`.
|
|
31
45
|
- `helm:package` packages the chart into `dist/<project-root>/helm`.
|
|
32
|
-
- `
|
|
46
|
+
- `helm:dependency-build` is inferred when `Chart.yaml` declares dependencies.
|
|
47
|
+
It builds the dependency output before validation and packaging.
|
|
48
|
+
- `nx-release-publish` is inferred only when an OCI registry is configured.
|
|
49
|
+
|
|
50
|
+
Each inferred validate and package target is cacheable, declares its direct
|
|
51
|
+
output where applicable, and includes the installed Helm version as a runtime
|
|
52
|
+
input. Local dependency directories are also inputs, and the dependency-build
|
|
53
|
+
target declares Helm's generated `charts` directory and `Chart.lock` as outputs.
|
|
54
|
+
Charts without local dependencies keep the original target graph.
|
|
33
55
|
|
|
34
56
|
## Configuration
|
|
35
57
|
|
|
@@ -39,21 +61,41 @@ Charts with sibling `Chart.yaml` and `project.json` files receive these targets:
|
|
|
39
61
|
{
|
|
40
62
|
"plugin": "@otwld/nx-helm",
|
|
41
63
|
"options": {
|
|
42
|
-
"
|
|
43
|
-
"
|
|
64
|
+
"validate": {
|
|
65
|
+
"target": "helm:validate",
|
|
44
66
|
"kubeVersion": "1.32.0",
|
|
45
67
|
"strict": false,
|
|
68
|
+
"validationValues": ["values-ci.yaml"],
|
|
69
|
+
},
|
|
70
|
+
"package": {
|
|
71
|
+
"target": "helm:package",
|
|
46
72
|
},
|
|
47
|
-
"
|
|
48
|
-
"
|
|
73
|
+
"publish": {
|
|
74
|
+
"registry": "oci://registry.company.test/charts",
|
|
49
75
|
},
|
|
50
|
-
"registry": "oci://registry.example.com/charts",
|
|
51
76
|
},
|
|
52
77
|
},
|
|
53
78
|
],
|
|
54
79
|
}
|
|
55
80
|
```
|
|
56
81
|
|
|
82
|
+
Project-specific settings belong in `project.json` under `metadata.helm`.
|
|
83
|
+
`registry`, `publish`, `kubeVersion`, `strict`, `releaseName`, and
|
|
84
|
+
`validationValues` override workspace options; `publish: false` suppresses the
|
|
85
|
+
release target.
|
|
86
|
+
|
|
87
|
+
```jsonc
|
|
88
|
+
{
|
|
89
|
+
"metadata": {
|
|
90
|
+
"helm": {
|
|
91
|
+
"registry": "oci://registry.company.test/team-charts",
|
|
92
|
+
"releaseName": "service",
|
|
93
|
+
"validationValues": ["values-ci.yaml"],
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
57
99
|
## Helm Release
|
|
58
100
|
|
|
59
101
|
```shell
|
|
@@ -65,7 +107,7 @@ pnpm exec nx release publish --groups=helm --dry-run
|
|
|
65
107
|
Authenticate with the OCI registry before publishing:
|
|
66
108
|
|
|
67
109
|
```shell
|
|
68
|
-
helm registry login registry.
|
|
110
|
+
helm registry login registry.company.test
|
|
69
111
|
pnpm exec nx release --groups=helm --first-release
|
|
70
112
|
```
|
|
71
113
|
|
package/generators.json
CHANGED
|
@@ -12,6 +12,11 @@
|
|
|
12
12
|
"factory": "./src/generators/chart/chart",
|
|
13
13
|
"schema": "./src/generators/chart/schema.json",
|
|
14
14
|
"description": "Create a standalone Helm chart Nx project."
|
|
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."
|
|
15
20
|
}
|
|
16
21
|
}
|
|
17
22
|
}
|
package/package.json
CHANGED
|
@@ -19,7 +19,7 @@ const runExecutor = async (options, context) => {
|
|
|
19
19
|
const registry = normalizeRegistry(options.registry);
|
|
20
20
|
if (!registry) {
|
|
21
21
|
console.error('[nx-helm] Helm release publishing requires an OCI registry such as ' +
|
|
22
|
-
'oci://registry.
|
|
22
|
+
'oci://registry.company.test/charts.');
|
|
23
23
|
return { success: false };
|
|
24
24
|
}
|
|
25
25
|
const outputDirectory = (0, node_path_1.resolve)(context.root, options.outputPath);
|
|
@@ -36,7 +36,7 @@ async function chartGenerator(tree, options) {
|
|
|
36
36
|
(0, devkit_1.addProjectConfiguration)(tree, projectName, {
|
|
37
37
|
root: projectRoot,
|
|
38
38
|
projectType: 'application',
|
|
39
|
-
tags:
|
|
39
|
+
tags: options.tags,
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
@@ -29,6 +29,13 @@
|
|
|
29
29
|
"starter": {
|
|
30
30
|
"type": "string",
|
|
31
31
|
"description": "Helm starter name or absolute starter path passed to helm create."
|
|
32
|
+
},
|
|
33
|
+
"tags": {
|
|
34
|
+
"type": "array",
|
|
35
|
+
"description": "Nx project tags assigned to the generated chart.",
|
|
36
|
+
"items": {
|
|
37
|
+
"type": "string"
|
|
38
|
+
}
|
|
32
39
|
}
|
|
33
40
|
},
|
|
34
41
|
"required": ["name"],
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Tree } from '@nx/devkit';
|
|
2
2
|
import type { InitGeneratorSchema } from './schema';
|
|
3
3
|
/**
|
|
4
|
-
* Registers `@otwld/nx-helm`
|
|
4
|
+
* Registers `@otwld/nx-helm` without adding workspace target defaults.
|
|
5
5
|
* @param tree Workspace tree to update.
|
|
6
6
|
* @param options Init options supplied by Nx.
|
|
7
7
|
* @returns A promise that resolves after optional formatting.
|
|
@@ -3,12 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.default = initGenerator;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const pluginName = '@otwld/nx-helm';
|
|
6
|
-
const defaultValidateTargetName = 'helm:validate';
|
|
7
|
-
const defaultPackageTargetName = 'helm:package';
|
|
8
|
-
const defaultKubeVersion = '1.32.0';
|
|
9
|
-
const defaultRegistry = 'oci://registry.example.com/charts';
|
|
10
6
|
/**
|
|
11
|
-
* Registers `@otwld/nx-helm`
|
|
7
|
+
* Registers `@otwld/nx-helm` without adding workspace target defaults.
|
|
12
8
|
* @param tree Workspace tree to update.
|
|
13
9
|
* @param options Init options supplied by Nx.
|
|
14
10
|
* @returns A promise that resolves after optional formatting.
|
|
@@ -20,20 +16,10 @@ async function initGenerator(tree, options) {
|
|
|
20
16
|
}
|
|
21
17
|
const nxJson = (0, devkit_1.readNxJson)(tree) ?? {};
|
|
22
18
|
const existingPlugin = findPlugin(nxJson.plugins);
|
|
23
|
-
const pluginOptions = existingPlugin
|
|
24
|
-
? readPluginOptions(existingPlugin)
|
|
25
|
-
: createPluginOptions(options);
|
|
26
19
|
if (!existingPlugin) {
|
|
27
|
-
nxJson.plugins = [
|
|
28
|
-
...(nxJson.plugins ?? []),
|
|
29
|
-
{
|
|
30
|
-
plugin: pluginName,
|
|
31
|
-
options: pluginOptions,
|
|
32
|
-
},
|
|
33
|
-
];
|
|
20
|
+
nxJson.plugins = [...(nxJson.plugins ?? []), pluginName];
|
|
34
21
|
devkit_1.logger.info(`[nx-helm] Added ${pluginName} to nx.json.`);
|
|
35
22
|
}
|
|
36
|
-
addTargetDefaults(nxJson, pluginOptions);
|
|
37
23
|
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
38
24
|
if (!options.skipFormat) {
|
|
39
25
|
await (0, devkit_1.formatFiles)(tree);
|
|
@@ -49,82 +35,3 @@ function findPlugin(plugins) {
|
|
|
49
35
|
? plugin === pluginName
|
|
50
36
|
: plugin?.plugin === pluginName);
|
|
51
37
|
}
|
|
52
|
-
/**
|
|
53
|
-
* Builds default plugin options for a new registration.
|
|
54
|
-
* @param options Init generator options.
|
|
55
|
-
* @returns Plugin options written to nx.json.
|
|
56
|
-
*/
|
|
57
|
-
function createPluginOptions(options) {
|
|
58
|
-
const validateTargetName = options.validateTargetName?.trim() || defaultValidateTargetName;
|
|
59
|
-
const packageTargetName = options.packageTargetName?.trim() || defaultPackageTargetName;
|
|
60
|
-
return {
|
|
61
|
-
validateTarget: {
|
|
62
|
-
name: validateTargetName,
|
|
63
|
-
kubeVersion: options.kubeVersion?.trim() || defaultKubeVersion,
|
|
64
|
-
strict: options.strict ?? false,
|
|
65
|
-
},
|
|
66
|
-
packageTarget: {
|
|
67
|
-
name: packageTargetName,
|
|
68
|
-
},
|
|
69
|
-
registry: options.registry?.trim() || defaultRegistry,
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Reads target names from an existing object registration without changing it.
|
|
74
|
-
* @param plugin Existing Helm registration.
|
|
75
|
-
* @returns Existing plugin options or empty options for default resolution.
|
|
76
|
-
*/
|
|
77
|
-
function readPluginOptions(plugin) {
|
|
78
|
-
if (typeof plugin === 'string' || !isRecord(plugin.options)) {
|
|
79
|
-
return {};
|
|
80
|
-
}
|
|
81
|
-
return plugin.options;
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Adds shared cache/input defaults only when a target has no existing default.
|
|
85
|
-
* @param nxJson Nx workspace configuration.
|
|
86
|
-
* @param pluginOptions Helm plugin options.
|
|
87
|
-
*/
|
|
88
|
-
function addTargetDefaults(nxJson, pluginOptions) {
|
|
89
|
-
nxJson.targetDefaults ??= {};
|
|
90
|
-
const validateTargetName = getNestedString(pluginOptions, 'validateTarget', 'name') ??
|
|
91
|
-
defaultValidateTargetName;
|
|
92
|
-
const packageTargetName = getNestedString(pluginOptions, 'packageTarget', 'name') ??
|
|
93
|
-
defaultPackageTargetName;
|
|
94
|
-
nxJson.targetDefaults[validateTargetName] ??= {
|
|
95
|
-
cache: true,
|
|
96
|
-
inputs: helmInputs,
|
|
97
|
-
};
|
|
98
|
-
nxJson.targetDefaults[packageTargetName] ??= {
|
|
99
|
-
cache: true,
|
|
100
|
-
dependsOn: [validateTargetName],
|
|
101
|
-
inputs: helmInputs,
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
const helmInputs = [
|
|
105
|
-
'{projectRoot}/**/*',
|
|
106
|
-
{ runtime: "helm version --template '{{.Version}}'" },
|
|
107
|
-
];
|
|
108
|
-
/**
|
|
109
|
-
* Reads a nested string option from an unknown plugin options object.
|
|
110
|
-
* @param options Plugin options.
|
|
111
|
-
* @param parent Parent property name.
|
|
112
|
-
* @param property Nested property name.
|
|
113
|
-
* @returns Non-empty nested string, or undefined.
|
|
114
|
-
*/
|
|
115
|
-
function getNestedString(options, parent, property) {
|
|
116
|
-
const parentValue = options[parent];
|
|
117
|
-
if (!isRecord(parentValue)) {
|
|
118
|
-
return undefined;
|
|
119
|
-
}
|
|
120
|
-
const value = parentValue[property];
|
|
121
|
-
return typeof value === 'string' && value.trim() ? value.trim() : undefined;
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Narrows unknown values to object records used by init configuration parsing.
|
|
125
|
-
* @param value Value to inspect.
|
|
126
|
-
* @returns Whether value is a non-null object record.
|
|
127
|
-
*/
|
|
128
|
-
function isRecord(value) {
|
|
129
|
-
return typeof value === 'object' && value !== null;
|
|
130
|
-
}
|
|
@@ -1,15 +1,5 @@
|
|
|
1
1
|
/** Options accepted by the `@otwld/nx-helm` init generator. */
|
|
2
2
|
export interface InitGeneratorSchema {
|
|
3
|
-
/** OCI repository used by inferred release publishing. */
|
|
4
|
-
registry?: string;
|
|
5
|
-
/** Kubernetes version passed to inferred helm template targets. */
|
|
6
|
-
kubeVersion?: string;
|
|
7
|
-
/** Whether inferred helm lint should fail on warnings. */
|
|
8
|
-
strict?: boolean;
|
|
9
|
-
/** Inferred Helm validation target name. */
|
|
10
|
-
validateTargetName?: string;
|
|
11
|
-
/** Inferred Helm packaging target name. */
|
|
12
|
-
packageTargetName?: string;
|
|
13
3
|
/** Skip Prettier formatting after nx.json is updated. */
|
|
14
4
|
skipFormat?: boolean;
|
|
15
5
|
}
|
|
@@ -2,35 +2,9 @@
|
|
|
2
2
|
"$schema": "https://json-schema.org/schema",
|
|
3
3
|
"$id": "NxHelmInitSchema",
|
|
4
4
|
"title": "Nx Helm init generator",
|
|
5
|
-
"description": "Register @otwld/nx-helm
|
|
5
|
+
"description": "Register @otwld/nx-helm in nx.json.",
|
|
6
6
|
"type": "object",
|
|
7
7
|
"properties": {
|
|
8
|
-
"registry": {
|
|
9
|
-
"type": "string",
|
|
10
|
-
"description": "OCI repository used by inferred release publishing.",
|
|
11
|
-
"pattern": "^oci://",
|
|
12
|
-
"default": "oci://registry.example.com/charts"
|
|
13
|
-
},
|
|
14
|
-
"kubeVersion": {
|
|
15
|
-
"type": "string",
|
|
16
|
-
"description": "Kubernetes version passed to inferred helm template targets.",
|
|
17
|
-
"default": "1.32.0"
|
|
18
|
-
},
|
|
19
|
-
"strict": {
|
|
20
|
-
"type": "boolean",
|
|
21
|
-
"description": "Whether inferred helm lint should fail on warnings.",
|
|
22
|
-
"default": false
|
|
23
|
-
},
|
|
24
|
-
"validateTargetName": {
|
|
25
|
-
"type": "string",
|
|
26
|
-
"description": "Inferred Helm validation target name.",
|
|
27
|
-
"default": "helm:validate"
|
|
28
|
-
},
|
|
29
|
-
"packageTargetName": {
|
|
30
|
-
"type": "string",
|
|
31
|
-
"description": "Inferred Helm packaging target name.",
|
|
32
|
-
"default": "helm:package"
|
|
33
|
-
},
|
|
34
8
|
"skipFormat": {
|
|
35
9
|
"type": "boolean",
|
|
36
10
|
"description": "Skip Prettier formatting after nx.json is updated.",
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** A Helm dependency used by the umbrella chart generator. */
|
|
2
|
+
export interface StackDependency {
|
|
3
|
+
/** Dependency chart name and values key. */
|
|
4
|
+
name: string;
|
|
5
|
+
/** Semver version required by Chart.yaml. */
|
|
6
|
+
version: string;
|
|
7
|
+
/** Helm repository URL, including file:// for app-owned charts. */
|
|
8
|
+
repository: string;
|
|
9
|
+
/** Optional values condition controlling dependency rendering. */
|
|
10
|
+
condition?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** Options accepted by the generic Helm stack generator. */
|
|
14
|
+
export interface StackGeneratorSchema {
|
|
15
|
+
/** Stack chart name and directory suffix. */
|
|
16
|
+
name: string;
|
|
17
|
+
/** Parent directory for the generated chart. */
|
|
18
|
+
directory?: string;
|
|
19
|
+
/** Explicit Nx project name. */
|
|
20
|
+
projectName?: string;
|
|
21
|
+
/** Chart dependencies rendered by the umbrella chart. */
|
|
22
|
+
dependencies?: StackDependency[];
|
|
23
|
+
/** Nx project tags assigned to the chart. */
|
|
24
|
+
tags?: string[];
|
|
25
|
+
/** Skip Prettier formatting after generation. */
|
|
26
|
+
skipFormat?: boolean;
|
|
27
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
|
+
"$id": "NxHelmStackGeneratorSchema",
|
|
4
|
+
"title": "Helm stack generator",
|
|
5
|
+
"description": "Create a generic Helm umbrella chart project.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"name": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"description": "Stack chart name and directory suffix.",
|
|
11
|
+
"$default": { "source": "argv", "index": 0 },
|
|
12
|
+
"x-priority": "important"
|
|
13
|
+
},
|
|
14
|
+
"directory": {
|
|
15
|
+
"type": "string",
|
|
16
|
+
"description": "Parent directory for the generated chart.",
|
|
17
|
+
"default": "charts"
|
|
18
|
+
},
|
|
19
|
+
"projectName": {
|
|
20
|
+
"type": "string",
|
|
21
|
+
"description": "Explicit Nx project name."
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"type": "array",
|
|
25
|
+
"description": "Dependencies declared in the umbrella Chart.yaml.",
|
|
26
|
+
"items": {
|
|
27
|
+
"type": "object",
|
|
28
|
+
"properties": {
|
|
29
|
+
"name": { "type": "string", "minLength": 1 },
|
|
30
|
+
"version": { "type": "string", "minLength": 1 },
|
|
31
|
+
"repository": { "type": "string", "minLength": 1 },
|
|
32
|
+
"condition": { "type": "string", "minLength": 1 }
|
|
33
|
+
},
|
|
34
|
+
"required": ["name", "version", "repository"],
|
|
35
|
+
"additionalProperties": false
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"tags": {
|
|
39
|
+
"type": "array",
|
|
40
|
+
"items": { "type": "string" },
|
|
41
|
+
"default": ["type:chart", "type:stack"]
|
|
42
|
+
},
|
|
43
|
+
"skipFormat": {
|
|
44
|
+
"type": "boolean",
|
|
45
|
+
"default": false
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
"required": ["name"],
|
|
49
|
+
"additionalProperties": false
|
|
50
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type Tree } from '@nx/devkit';
|
|
2
|
+
import type { StackGeneratorSchema } from './schema';
|
|
3
|
+
/** Creates a generic Helm umbrella chart without repository-specific services. */
|
|
4
|
+
export default function stackGenerator(tree: Tree, options: StackGeneratorSchema): Promise<void>;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = stackGenerator;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const yaml_1 = require("yaml");
|
|
6
|
+
/** Creates a generic Helm umbrella chart without repository-specific services. */
|
|
7
|
+
async function stackGenerator(tree, options) {
|
|
8
|
+
const chartName = normalizeName(options.name, 'name');
|
|
9
|
+
const projectRoot = (0, devkit_1.joinPathFragments)(options.directory?.trim() || 'charts', chartName);
|
|
10
|
+
const chartFile = (0, devkit_1.joinPathFragments)(projectRoot, 'Chart.yaml');
|
|
11
|
+
const projectName = options.projectName?.trim() || `helm-${chartName}`;
|
|
12
|
+
if (tree.exists(chartFile)) {
|
|
13
|
+
throw new Error(`[nx-helm] A Helm chart already exists at ${projectRoot}.`);
|
|
14
|
+
}
|
|
15
|
+
const dependencies = normalizeDependencies(options.dependencies);
|
|
16
|
+
tree.write(chartFile, (0, yaml_1.stringify)({
|
|
17
|
+
apiVersion: 'v2',
|
|
18
|
+
name: chartName,
|
|
19
|
+
description: `Umbrella chart for the ${chartName} application stack.`,
|
|
20
|
+
type: 'application',
|
|
21
|
+
version: '0.1.0',
|
|
22
|
+
appVersion: '0.1.0',
|
|
23
|
+
...(dependencies.length ? { dependencies } : {}),
|
|
24
|
+
}, { lineWidth: 0 }));
|
|
25
|
+
tree.write((0, devkit_1.joinPathFragments)(projectRoot, 'values.yaml'), (0, yaml_1.stringify)(createValues(dependencies), { lineWidth: 0 }));
|
|
26
|
+
tree.write((0, devkit_1.joinPathFragments)(projectRoot, 'templates/resources.yaml'), '{{/* Render stack-owned namespaced resources. */}}\n{{- range .Values.resources }}\n---\n{{ tpl (toYaml .) $ }}\n{{- end }}\n');
|
|
27
|
+
(0, devkit_1.writeJson)(tree, (0, devkit_1.joinPathFragments)(projectRoot, 'project.json'), {
|
|
28
|
+
name: projectName,
|
|
29
|
+
root: projectRoot,
|
|
30
|
+
projectType: 'application',
|
|
31
|
+
tags: options.tags?.length ? options.tags : ['type:chart', 'type:stack'],
|
|
32
|
+
metadata: { helm: { publish: false, releaseName: chartName } },
|
|
33
|
+
});
|
|
34
|
+
if (!options.skipFormat) {
|
|
35
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/** Builds the minimal generic values contract for dependency toggles. */
|
|
39
|
+
function createValues(dependencies) {
|
|
40
|
+
const values = {
|
|
41
|
+
global: {
|
|
42
|
+
environment: 'local',
|
|
43
|
+
imagePullPolicy: 'IfNotPresent',
|
|
44
|
+
imagePullSecrets: [],
|
|
45
|
+
previewId: '',
|
|
46
|
+
previewDomain: '',
|
|
47
|
+
sourceRevision: '',
|
|
48
|
+
},
|
|
49
|
+
resources: [],
|
|
50
|
+
};
|
|
51
|
+
for (const dependency of dependencies) {
|
|
52
|
+
values[dependency.name] = { enabled: false };
|
|
53
|
+
}
|
|
54
|
+
return values;
|
|
55
|
+
}
|
|
56
|
+
/** Normalizes dependency values while preserving Helm repository URLs. */
|
|
57
|
+
function normalizeDependencies(dependencies) {
|
|
58
|
+
if (!dependencies)
|
|
59
|
+
return [];
|
|
60
|
+
return dependencies.map((dependency, index) => {
|
|
61
|
+
if (!dependency || typeof dependency !== 'object') {
|
|
62
|
+
throw new Error(`[nx-helm] Dependency ${index} must be an object.`);
|
|
63
|
+
}
|
|
64
|
+
const name = normalizeName(dependency.name, `dependencies[${index}].name`);
|
|
65
|
+
const version = requireValue(dependency.version, `dependencies[${index}].version`);
|
|
66
|
+
const repository = requireValue(dependency.repository, `dependencies[${index}].repository`);
|
|
67
|
+
return {
|
|
68
|
+
name,
|
|
69
|
+
version,
|
|
70
|
+
repository,
|
|
71
|
+
...(dependency.condition?.trim()
|
|
72
|
+
? { condition: dependency.condition.trim() }
|
|
73
|
+
: {}),
|
|
74
|
+
};
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
/** Normalizes an identifier used by the chart and project paths. */
|
|
78
|
+
function normalizeName(value, label) {
|
|
79
|
+
const normalized = (0, devkit_1.names)(requireValue(value, label)).fileName;
|
|
80
|
+
if (!normalized)
|
|
81
|
+
throw new Error(`[nx-helm] A ${label} is required.`);
|
|
82
|
+
return normalized;
|
|
83
|
+
}
|
|
84
|
+
/** Requires a non-empty option. */
|
|
85
|
+
function requireValue(value, label) {
|
|
86
|
+
const normalized = value?.trim();
|
|
87
|
+
if (!normalized)
|
|
88
|
+
throw new Error(`[nx-helm] A ${label} is required.`);
|
|
89
|
+
return normalized;
|
|
90
|
+
}
|
package/src/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
/** Public inferred-task, generator, and release exports for the Helm package. */
|
|
2
|
-
export { createNodes, type HelmPackageTargetOptions, type HelmPluginOptions, type HelmValidateTargetOptions, } from './plugins/plugin';
|
|
2
|
+
export { createNodes, type HelmPackageTargetOptions, type HelmPluginOptions, type HelmPublishTargetOptions, type HelmValidateTargetOptions, } from './plugins/plugin';
|
|
3
3
|
export { default as chartGenerator } from './generators/chart/chart';
|
|
4
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';
|
package/src/index.js
CHANGED
|
@@ -3,9 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.chartGenerator = exports.createNodes = void 0;
|
|
6
|
+
exports.stackGenerator = exports.chartGenerator = exports.createNodes = void 0;
|
|
7
7
|
/** Public inferred-task, generator, and release exports for the Helm package. */
|
|
8
8
|
var plugin_1 = require("./plugins/plugin");
|
|
9
9
|
Object.defineProperty(exports, "createNodes", { enumerable: true, get: function () { return plugin_1.createNodes; } });
|
|
10
10
|
var chart_1 = require("./generators/chart/chart");
|
|
11
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; } });
|
package/src/plugins/plugin.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { type CreateNodes } from '@nx/devkit';
|
|
|
2
2
|
/** Options for the inferred Helm validation target. */
|
|
3
3
|
export interface HelmValidateTargetOptions {
|
|
4
4
|
/** Target name used for Helm lint and template. */
|
|
5
|
-
|
|
5
|
+
target?: string;
|
|
6
6
|
/** Kubernetes version passed to helm template. */
|
|
7
7
|
kubeVersion?: string;
|
|
8
8
|
/** Whether helm lint should fail on warnings. */
|
|
@@ -10,21 +10,26 @@ export interface HelmValidateTargetOptions {
|
|
|
10
10
|
/** Workspace-wide Helm release name override. */
|
|
11
11
|
releaseName?: string;
|
|
12
12
|
/** Values files passed to helm lint and helm template. */
|
|
13
|
-
|
|
13
|
+
validationValues?: string[];
|
|
14
14
|
}
|
|
15
15
|
/** Options for the inferred Helm packaging target. */
|
|
16
16
|
export interface HelmPackageTargetOptions {
|
|
17
17
|
/** Target name used for Helm packaging. */
|
|
18
|
-
|
|
18
|
+
target?: string;
|
|
19
|
+
}
|
|
20
|
+
/** Options for inferred Helm publishing. */
|
|
21
|
+
export interface HelmPublishTargetOptions {
|
|
22
|
+
/** OCI registry repository used by inferred Nx Release publishing. */
|
|
23
|
+
registry?: string;
|
|
19
24
|
}
|
|
20
25
|
/** Workspace options for the Helm inferred-target plugin. */
|
|
21
26
|
export interface HelmPluginOptions {
|
|
22
27
|
/** Configuration for the inferred validation target. */
|
|
23
|
-
|
|
28
|
+
validate?: HelmValidateTargetOptions;
|
|
24
29
|
/** Configuration for the inferred packaging target. */
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
|
|
30
|
+
package?: HelmPackageTargetOptions;
|
|
31
|
+
/** Configuration for inferred Nx Release publishing. */
|
|
32
|
+
publish?: HelmPublishTargetOptions;
|
|
28
33
|
}
|
|
29
34
|
/**
|
|
30
35
|
* Infers Helm targets for standalone projects whose root contains Chart.yaml.
|
package/src/plugins/plugin.js
CHANGED
|
@@ -4,12 +4,17 @@ exports.createNodes = void 0;
|
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const node_fs_1 = require("node:fs");
|
|
6
6
|
const node_path_1 = require("node:path");
|
|
7
|
+
const yaml_1 = require("yaml");
|
|
7
8
|
const chartFilePattern = '**/Chart.yaml';
|
|
8
9
|
const defaultValidateTargetName = 'helm:validate';
|
|
9
10
|
const defaultPackageTargetName = 'helm:package';
|
|
11
|
+
const dependencyBuildTargetName = 'helm:dependency-build';
|
|
10
12
|
const releasePublishTargetName = 'nx-release-publish';
|
|
11
13
|
const defaultKubeVersion = '1.32.0';
|
|
12
|
-
const
|
|
14
|
+
const helmInputs = [
|
|
15
|
+
'{projectRoot}/**/*',
|
|
16
|
+
{ runtime: "helm version --template '{{.Version}}'" },
|
|
17
|
+
];
|
|
13
18
|
/**
|
|
14
19
|
* Infers Helm targets for standalone projects whose root contains Chart.yaml.
|
|
15
20
|
* A sibling project.json identifies the chart as an Nx project.
|
|
@@ -41,58 +46,99 @@ function createNodesInternal(chartFilePath, options, context) {
|
|
|
41
46
|
if (!chartRoot) {
|
|
42
47
|
return {};
|
|
43
48
|
}
|
|
44
|
-
const
|
|
45
|
-
if (!
|
|
49
|
+
const project = getProject(chartRoot.projectRoot, chartRoot.directory);
|
|
50
|
+
if (!project) {
|
|
46
51
|
return {};
|
|
47
52
|
}
|
|
48
|
-
const validateTargetName = getTargetName(options.
|
|
49
|
-
const packageTargetName = getTargetName(options.
|
|
50
|
-
assertTargetNamesAreUnique(validateTargetName, packageTargetName);
|
|
53
|
+
const validateTargetName = getTargetName(options.validate?.target, defaultValidateTargetName);
|
|
54
|
+
const packageTargetName = getTargetName(options.package?.target, defaultPackageTargetName);
|
|
51
55
|
const outputPath = getPackageOutputPath(chartRoot.projectRoot);
|
|
52
|
-
const
|
|
56
|
+
const dependencies = getChartDependencies(chartRoot.directory, context.workspaceRoot);
|
|
57
|
+
const chartInputs = [...helmInputs, ...dependencies.localInputs];
|
|
58
|
+
const dependencyInputs = [
|
|
59
|
+
'{projectRoot}/Chart.yaml',
|
|
60
|
+
'{projectRoot}/Chart.lock',
|
|
61
|
+
helmInputs[1],
|
|
62
|
+
...dependencies.localInputs,
|
|
63
|
+
];
|
|
64
|
+
const hasDependencies = dependencies.hasDependencies;
|
|
65
|
+
const releaseName = project.metadata.releaseName?.trim() ||
|
|
66
|
+
options.validate?.releaseName?.trim() ||
|
|
67
|
+
project.name;
|
|
53
68
|
const validateOptions = {
|
|
54
|
-
kubeVersion:
|
|
69
|
+
kubeVersion: project.metadata.kubeVersion?.trim() ||
|
|
70
|
+
options.validate?.kubeVersion?.trim() ||
|
|
71
|
+
defaultKubeVersion,
|
|
55
72
|
releaseName,
|
|
56
|
-
strict: options.
|
|
73
|
+
strict: project.metadata.strict ?? options.validate?.strict ?? false,
|
|
57
74
|
};
|
|
58
|
-
const
|
|
59
|
-
if (
|
|
60
|
-
validateOptions['valuesFiles'] =
|
|
61
|
-
}
|
|
62
|
-
const targets = {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
|
-
[packageTargetName]: {
|
|
72
|
-
executor: '@otwld/nx-helm:package',
|
|
73
|
-
dependsOn: [validateTargetName],
|
|
74
|
-
outputs: [`{workspaceRoot}/${outputPath}`],
|
|
75
|
+
const validationValues = project.metadata.validationValues ?? options.validate?.validationValues;
|
|
76
|
+
if (validationValues?.length) {
|
|
77
|
+
validateOptions['valuesFiles'] = validationValues;
|
|
78
|
+
}
|
|
79
|
+
const targets = {};
|
|
80
|
+
if (hasDependencies) {
|
|
81
|
+
targets[dependencyBuildTargetName] = {
|
|
82
|
+
executor: 'nx:run-commands',
|
|
83
|
+
cache: true,
|
|
84
|
+
inputs: dependencyInputs,
|
|
85
|
+
outputs: ['{projectRoot}/charts', '{projectRoot}/Chart.lock'],
|
|
75
86
|
options: {
|
|
76
|
-
|
|
87
|
+
command: 'helm dependency build .',
|
|
88
|
+
cwd: chartRoot.projectRoot,
|
|
77
89
|
},
|
|
78
90
|
metadata: {
|
|
79
91
|
technologies: ['helm'],
|
|
80
|
-
description: '
|
|
92
|
+
description: 'Build local and remote Helm chart dependencies.',
|
|
81
93
|
},
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
const dependencyTarget = hasDependencies ? [dependencyBuildTargetName] : [];
|
|
97
|
+
targets[validateTargetName] = {
|
|
98
|
+
executor: '@otwld/nx-helm:validate',
|
|
99
|
+
cache: true,
|
|
100
|
+
...(dependencyTarget.length ? { dependsOn: dependencyTarget } : {}),
|
|
101
|
+
inputs: chartInputs,
|
|
102
|
+
options: validateOptions,
|
|
103
|
+
metadata: {
|
|
104
|
+
technologies: ['helm'],
|
|
105
|
+
description: 'Lint and render the root Helm chart.',
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
targets[packageTargetName] = {
|
|
109
|
+
executor: '@otwld/nx-helm:package',
|
|
110
|
+
cache: true,
|
|
111
|
+
dependsOn: [...dependencyTarget, validateTargetName],
|
|
112
|
+
inputs: chartInputs,
|
|
113
|
+
outputs: [`{workspaceRoot}/${outputPath}`],
|
|
114
|
+
options: {
|
|
115
|
+
outputPath,
|
|
116
|
+
},
|
|
117
|
+
metadata: {
|
|
118
|
+
technologies: ['helm'],
|
|
119
|
+
description: 'Package the root Helm chart.',
|
|
82
120
|
},
|
|
83
|
-
|
|
121
|
+
};
|
|
122
|
+
const registry = normalizeRegistry(project.metadata.registry ?? options.publish?.registry);
|
|
123
|
+
if (registry && project.metadata.publish !== false) {
|
|
124
|
+
targets[releasePublishTargetName] = {
|
|
84
125
|
executor: '@otwld/nx-helm:release-publish',
|
|
85
126
|
dependsOn: [packageTargetName],
|
|
86
|
-
options: {
|
|
87
|
-
outputPath,
|
|
88
|
-
registry: options.registry ?? defaultRegistry,
|
|
89
|
-
},
|
|
127
|
+
options: { outputPath, registry },
|
|
90
128
|
metadata: {
|
|
91
129
|
technologies: ['helm'],
|
|
92
130
|
description: 'Publish the Helm chart to an OCI registry.',
|
|
93
131
|
},
|
|
94
|
-
}
|
|
95
|
-
}
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
const targetNames = [validateTargetName, packageTargetName];
|
|
135
|
+
if (hasDependencies) {
|
|
136
|
+
targetNames.unshift(dependencyBuildTargetName);
|
|
137
|
+
}
|
|
138
|
+
if (releasePublishTargetName in targets) {
|
|
139
|
+
targetNames.push(releasePublishTargetName);
|
|
140
|
+
}
|
|
141
|
+
assertTargetNamesAreUnique(targetNames);
|
|
96
142
|
return {
|
|
97
143
|
projects: {
|
|
98
144
|
[chartRoot.projectRoot]: {
|
|
@@ -100,17 +146,57 @@ function createNodesInternal(chartFilePath, options, context) {
|
|
|
100
146
|
targets,
|
|
101
147
|
metadata: {
|
|
102
148
|
targetGroups: {
|
|
103
|
-
Helm:
|
|
104
|
-
validateTargetName,
|
|
105
|
-
packageTargetName,
|
|
106
|
-
releasePublishTargetName,
|
|
107
|
-
],
|
|
149
|
+
Helm: targetNames,
|
|
108
150
|
},
|
|
109
151
|
},
|
|
110
152
|
},
|
|
111
153
|
},
|
|
112
154
|
};
|
|
113
155
|
}
|
|
156
|
+
/**
|
|
157
|
+
* Finds declared chart dependencies and workspace-local dependency directories.
|
|
158
|
+
* @param chartDirectory Absolute chart directory.
|
|
159
|
+
* @param workspaceRoot Absolute workspace root.
|
|
160
|
+
* @returns Whether dependencies exist and Nx input globs for local content.
|
|
161
|
+
*/
|
|
162
|
+
function getChartDependencies(chartDirectory, workspaceRoot) {
|
|
163
|
+
const chartFilePath = (0, node_path_1.join)(chartDirectory, 'Chart.yaml');
|
|
164
|
+
const document = (0, yaml_1.parseDocument)((0, node_fs_1.readFileSync)(chartFilePath, 'utf8'), {
|
|
165
|
+
prettyErrors: false,
|
|
166
|
+
});
|
|
167
|
+
if (document.errors.length > 0) {
|
|
168
|
+
throw new Error(`[nx-helm] Chart ${chartFilePath} contains invalid YAML: ${document.errors[0].message}`);
|
|
169
|
+
}
|
|
170
|
+
const manifest = document.toJS();
|
|
171
|
+
const dependencies = manifest.dependencies;
|
|
172
|
+
if (!Array.isArray(dependencies)) {
|
|
173
|
+
return { hasDependencies: false, localInputs: [] };
|
|
174
|
+
}
|
|
175
|
+
const paths = new Set();
|
|
176
|
+
for (const dependency of dependencies) {
|
|
177
|
+
if (!dependency ||
|
|
178
|
+
typeof dependency !== 'object' ||
|
|
179
|
+
Array.isArray(dependency)) {
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
const repository = dependency['repository'];
|
|
183
|
+
if (typeof repository !== 'string' || !repository.startsWith('file://')) {
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
186
|
+
const dependencyPath = (0, node_path_1.resolve)(chartDirectory, decodeURIComponent(repository.slice('file://'.length)));
|
|
187
|
+
const workspacePath = (0, node_path_1.relative)(workspaceRoot, dependencyPath)
|
|
188
|
+
.split(node_path_1.sep)
|
|
189
|
+
.join('/');
|
|
190
|
+
if (!workspacePath ||
|
|
191
|
+
workspacePath === '..' ||
|
|
192
|
+
workspacePath.startsWith('../') ||
|
|
193
|
+
(0, node_path_1.isAbsolute)(workspacePath)) {
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
196
|
+
paths.add(`{workspaceRoot}/${workspacePath}/**/*`);
|
|
197
|
+
}
|
|
198
|
+
return { hasDependencies: dependencies.length > 0, localInputs: [...paths] };
|
|
199
|
+
}
|
|
114
200
|
/**
|
|
115
201
|
* Resolves a Chart.yaml directory and verifies the standalone project marker.
|
|
116
202
|
* @param chartFilePath Chart.yaml path matched by Nx.
|
|
@@ -130,22 +216,27 @@ function getChartRoot(chartFilePath, workspaceRoot) {
|
|
|
130
216
|
return { directory, projectRoot };
|
|
131
217
|
}
|
|
132
218
|
/**
|
|
133
|
-
* Reads
|
|
219
|
+
* Reads project metadata used to configure inferred Helm targets.
|
|
134
220
|
* @param projectRoot Workspace-relative project root.
|
|
135
221
|
* @param projectDirectory Absolute project directory.
|
|
136
|
-
* @returns The project name, or undefined for invalid
|
|
222
|
+
* @returns The project name and Helm metadata, or undefined for invalid input.
|
|
137
223
|
*/
|
|
138
|
-
function
|
|
224
|
+
function getProject(projectRoot, projectDirectory) {
|
|
139
225
|
const projectConfiguration = (0, devkit_1.readJsonFile)((0, node_path_1.join)(projectDirectory, 'project.json'));
|
|
226
|
+
const metadata = readHelmMetadata(projectConfiguration.metadata?.helm);
|
|
140
227
|
if (typeof projectConfiguration.name === 'string') {
|
|
141
228
|
const projectName = projectConfiguration.name.trim();
|
|
142
229
|
if (projectName) {
|
|
143
|
-
return projectName;
|
|
230
|
+
return { name: projectName, metadata };
|
|
144
231
|
}
|
|
145
232
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
233
|
+
if (projectRoot === '.') {
|
|
234
|
+
return undefined;
|
|
235
|
+
}
|
|
236
|
+
return {
|
|
237
|
+
name: projectRoot.replace(/[\\/\s]+/g, '-').toLowerCase(),
|
|
238
|
+
metadata,
|
|
239
|
+
};
|
|
149
240
|
}
|
|
150
241
|
/**
|
|
151
242
|
* Normalizes optional plugin options while preserving explicit values.
|
|
@@ -154,15 +245,15 @@ function getProjectName(projectRoot, projectDirectory) {
|
|
|
154
245
|
*/
|
|
155
246
|
function normalizeOptions(options) {
|
|
156
247
|
return {
|
|
157
|
-
|
|
158
|
-
...options?.
|
|
159
|
-
|
|
248
|
+
validate: {
|
|
249
|
+
...options?.validate,
|
|
250
|
+
target: getTargetName(options?.validate?.target, defaultValidateTargetName),
|
|
160
251
|
},
|
|
161
|
-
|
|
162
|
-
...options?.
|
|
163
|
-
|
|
252
|
+
package: {
|
|
253
|
+
...options?.package,
|
|
254
|
+
target: getTargetName(options?.package?.target, defaultPackageTargetName),
|
|
164
255
|
},
|
|
165
|
-
|
|
256
|
+
publish: { ...options?.publish },
|
|
166
257
|
};
|
|
167
258
|
}
|
|
168
259
|
/**
|
|
@@ -175,21 +266,67 @@ function getTargetName(configuredName, defaultName) {
|
|
|
175
266
|
return configuredName?.trim() || defaultName;
|
|
176
267
|
}
|
|
177
268
|
/**
|
|
178
|
-
* Prevents
|
|
179
|
-
*
|
|
180
|
-
* @param validateTargetName Validation target name.
|
|
181
|
-
* @param packageTargetName Packaging target name.
|
|
269
|
+
* Prevents inferred target names from colliding.
|
|
270
|
+
* @param targetNames Inferred target names.
|
|
182
271
|
*/
|
|
183
|
-
function assertTargetNamesAreUnique(
|
|
184
|
-
const targetNames = [
|
|
185
|
-
validateTargetName,
|
|
186
|
-
packageTargetName,
|
|
187
|
-
releasePublishTargetName,
|
|
188
|
-
];
|
|
272
|
+
function assertTargetNamesAreUnique(targetNames) {
|
|
189
273
|
if (new Set(targetNames).size !== targetNames.length) {
|
|
190
|
-
throw new Error('[nx-helm]
|
|
274
|
+
throw new Error('[nx-helm] Inferred Helm target names must be unique.');
|
|
191
275
|
}
|
|
192
276
|
}
|
|
277
|
+
/**
|
|
278
|
+
* Reads supported Helm project metadata without exposing arbitrary project data.
|
|
279
|
+
* @param value Potential `metadata.helm` value from project.json.
|
|
280
|
+
* @returns Recognized Helm metadata.
|
|
281
|
+
*/
|
|
282
|
+
function readHelmMetadata(value) {
|
|
283
|
+
if (!isRecord(value)) {
|
|
284
|
+
return {};
|
|
285
|
+
}
|
|
286
|
+
return {
|
|
287
|
+
registry: readString(value['registry']),
|
|
288
|
+
publish: typeof value['publish'] === 'boolean' ? value['publish'] : undefined,
|
|
289
|
+
kubeVersion: readString(value['kubeVersion']),
|
|
290
|
+
strict: typeof value['strict'] === 'boolean' ? value['strict'] : undefined,
|
|
291
|
+
releaseName: readString(value['releaseName']),
|
|
292
|
+
validationValues: readStringArray(value['validationValues']),
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Validates an OCI repository reference for inferred publishing.
|
|
297
|
+
* @param registry Configured registry repository.
|
|
298
|
+
* @returns Normalized OCI repository, or undefined when no valid registry exists.
|
|
299
|
+
*/
|
|
300
|
+
function normalizeRegistry(registry) {
|
|
301
|
+
const normalized = registry?.trim().replace(/\/+$/, '');
|
|
302
|
+
return normalized?.startsWith('oci://') ? normalized : undefined;
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Narrows an unknown value to a non-empty string.
|
|
306
|
+
* @param value Value to inspect.
|
|
307
|
+
* @returns Trimmed string, or undefined.
|
|
308
|
+
*/
|
|
309
|
+
function readString(value) {
|
|
310
|
+
return typeof value === 'string' && value.trim() ? value.trim() : undefined;
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Narrows an unknown value to a string array.
|
|
314
|
+
* @param value Value to inspect.
|
|
315
|
+
* @returns Values array, or undefined for invalid input.
|
|
316
|
+
*/
|
|
317
|
+
function readStringArray(value) {
|
|
318
|
+
return Array.isArray(value) && value.every((item) => typeof item === 'string')
|
|
319
|
+
? value
|
|
320
|
+
: undefined;
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Narrows an unknown value to an object record.
|
|
324
|
+
* @param value Value to inspect.
|
|
325
|
+
* @returns Whether the value is a non-null object record.
|
|
326
|
+
*/
|
|
327
|
+
function isRecord(value) {
|
|
328
|
+
return typeof value === 'object' && value !== null;
|
|
329
|
+
}
|
|
193
330
|
/**
|
|
194
331
|
* Computes the workspace-relative package output directory for a chart.
|
|
195
332
|
* @param projectRoot Workspace-relative chart project root.
|