@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.
Files changed (57) hide show
  1. package/executors.json +15 -10
  2. package/generators.json +3 -15
  3. package/package.json +8 -8
  4. package/src/executors/commands.d.ts +22 -0
  5. package/src/executors/commands.js +113 -0
  6. package/src/executors/commands.js.map +1 -0
  7. package/src/executors/lint.schema.json +9 -0
  8. package/src/executors/package.schema.json +7 -0
  9. package/src/executors/release-publish.schema.json +9 -0
  10. package/src/executors/template.schema.json +12 -0
  11. package/src/generators/chart.d.ts +9 -0
  12. package/src/generators/chart.js +97 -0
  13. package/src/generators/chart.js.map +1 -0
  14. package/src/generators/chart.schema.json +17 -0
  15. package/src/index.d.ts +3 -6
  16. package/src/index.js +4 -13
  17. package/src/index.js.map +1 -0
  18. package/src/plugin.d.ts +7 -0
  19. package/src/plugin.js +65 -0
  20. package/src/plugin.js.map +1 -0
  21. package/src/release/version-actions.d.ts +10 -56
  22. package/src/release/version-actions.js +32 -101
  23. package/src/release/version-actions.js.map +1 -0
  24. package/CHANGELOG.md +0 -48
  25. package/README.md +0 -131
  26. package/src/chart-manifest.d.ts +0 -22
  27. package/src/chart-manifest.js +0 -56
  28. package/src/executors/package/package.d.ts +0 -10
  29. package/src/executors/package/package.js +0 -57
  30. package/src/executors/package/schema.d.ts +0 -7
  31. package/src/executors/package/schema.json +0 -18
  32. package/src/executors/project-directory.d.ts +0 -8
  33. package/src/executors/project-directory.js +0 -23
  34. package/src/executors/release-publish/release-publish.d.ts +0 -10
  35. package/src/executors/release-publish/release-publish.js +0 -102
  36. package/src/executors/release-publish/schema.d.ts +0 -9
  37. package/src/executors/release-publish/schema.json +0 -22
  38. package/src/executors/run-helm.d.ts +0 -7
  39. package/src/executors/run-helm.js +0 -32
  40. package/src/executors/validate/schema.d.ts +0 -11
  41. package/src/executors/validate/schema.json +0 -29
  42. package/src/executors/validate/validate.d.ts +0 -16
  43. package/src/executors/validate/validate.js +0 -50
  44. package/src/generators/chart/chart.d.ts +0 -10
  45. package/src/generators/chart/chart.js +0 -101
  46. package/src/generators/chart/schema.d.ts +0 -13
  47. package/src/generators/chart/schema.json +0 -43
  48. package/src/generators/init/init.d.ts +0 -9
  49. package/src/generators/init/init.js +0 -37
  50. package/src/generators/init/schema.d.ts +0 -5
  51. package/src/generators/init/schema.json +0 -15
  52. package/src/generators/stack/schema.d.ts +0 -27
  53. package/src/generators/stack/schema.json +0 -50
  54. package/src/generators/stack/stack.d.ts +0 -4
  55. package/src/generators/stack/stack.js +0 -214
  56. package/src/plugins/plugin.d.ts +0 -38
  57. package/src/plugins/plugin.js +0 -352
@@ -1,114 +1,45 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const node_path_1 = require("node:path");
4
- const release_1 = require("nx/release");
5
- const chart_manifest_1 = require("../chart-manifest");
6
- /**
7
- * Updates the root Chart.yaml owned by one standalone Helm Nx project.
8
- * Chart appVersion values remain independent application metadata.
9
- */
10
- class HelmVersionActions extends release_1.VersionActions {
11
- constructor() {
12
- super(...arguments);
13
- /** Chart.yaml is the only source manifest managed by this implementation. */
14
- this.validManifestFilenames = ['Chart.yaml'];
15
- }
16
- /**
17
- * Configures the one root manifest for the release lifecycle.
18
- * @returns Nothing; the root manifest path is stored for the release lifecycle.
19
- */
20
- async init() {
21
- const preserveLocalDependencyProtocols = this.finalConfigForProject.preserveLocalDependencyProtocols ?? true;
22
- this.manifestsToUpdate = [
23
- {
24
- manifestPath: this.chartManifestPath,
25
- preserveLocalDependencyProtocols,
26
- },
27
- ];
28
- }
29
- /**
30
- * Validates the root Chart.yaml and its release metadata.
31
- * @param tree Nx's release file tree.
32
- * @returns A resolved promise after validation succeeds.
33
- */
34
- async validate(tree) {
35
- const content = tree.read(this.chartManifestPath, 'utf8');
36
- if (content === null) {
37
- throw new Error(`[nx-helm] Could not find Helm manifest ${this.chartManifestPath}.`);
38
- }
39
- (0, chart_manifest_1.readChartMetadata)(content, this.chartManifestPath);
40
- }
41
- /**
42
- * Reads the current chart version from the root Chart.yaml.
43
- * @param tree Nx's release file tree.
44
- * @returns The current version and manifest path.
45
- */
1
+ import { VersionActions } from 'nx/release';
2
+ import { join } from 'node:path';
3
+ import { parseDocument } from 'yaml';
4
+ /** Nx Release version-phase actions for standalone Helm charts. */
5
+ export default class HelmVersionActions extends VersionActions {
6
+ validManifestFilenames = ['Chart.yaml'];
46
7
  async readCurrentVersionFromSourceManifest(tree) {
47
- const metadata = this.readMetadata(tree);
48
- return {
49
- currentVersion: metadata.version,
50
- manifestPath: this.chartManifestPath,
51
- };
8
+ const manifestPath = join(this.projectGraphNode.data.root, 'Chart.yaml');
9
+ const chart = readChart(tree, manifestPath);
10
+ if (typeof chart.get('version') !== 'string')
11
+ throw new Error(`[nx-helm] ${manifestPath} requires a string version.`);
12
+ return { currentVersion: chart.get('version'), manifestPath };
52
13
  }
53
- /**
54
- * Helm OCI registries are not used for version resolution.
55
- * @returns Null so Nx can report an unsupported registry resolver clearly.
56
- */
57
14
  async readCurrentVersionFromRegistry() {
58
15
  return null;
59
16
  }
60
- /**
61
- * Helm chart dependencies are not represented as Nx package dependencies.
62
- * @returns No dependency version information.
63
- */
64
17
  async readCurrentVersionOfDependency() {
65
- return {
66
- currentVersion: null,
67
- dependencyCollection: null,
68
- };
18
+ return { currentVersion: null, dependencyCollection: null };
69
19
  }
70
- /**
71
- * Writes the new chart version to the root Chart.yaml.
72
- * @param tree Nx's release file tree.
73
- * @param newVersion New semantic chart version.
74
- * @returns A log message for the Nx release output.
75
- */
76
20
  async updateProjectVersion(tree, newVersion) {
77
- const content = tree.read(this.chartManifestPath, 'utf8');
78
- if (content === null) {
79
- throw new Error(`[nx-helm] Could not find Helm manifest ${this.chartManifestPath}.`);
21
+ const messages = [];
22
+ for (const manifest of this.manifestsToUpdate) {
23
+ const chart = readChart(tree, manifest.manifestPath);
24
+ chart.set('version', newVersion);
25
+ tree.write(manifest.manifestPath, chart.toString());
26
+ messages.push(`✍️ New version ${newVersion} written to manifest: ${manifest.manifestPath}`);
80
27
  }
81
- tree.write(this.chartManifestPath, (0, chart_manifest_1.updateChartVersion)(content, this.chartManifestPath, newVersion));
82
- return [
83
- `New Helm chart version ${newVersion} written to ${this.chartManifestPath}`,
84
- ];
28
+ return messages;
85
29
  }
86
- /**
87
- * Helm dependency updates are not supported until chart dependencies have
88
- * corresponding Nx project graph edges.
89
- * @returns No dependency update log messages.
90
- */
91
- async updateProjectDependencies() {
30
+ async updateProjectDependencies(_tree, _projectGraph, dependenciesToUpdate) {
31
+ if (Object.keys(dependenciesToUpdate).length)
32
+ throw new Error('[nx-helm] Helm charts do not update Nx project dependencies during versioning.');
92
33
  return [];
93
34
  }
94
- /**
95
- * Workspace-relative root Chart.yaml path for this release project.
96
- * @returns The root Chart.yaml path.
97
- */
98
- get chartManifestPath() {
99
- return (0, node_path_1.join)(this.projectGraphNode.data.root, 'Chart.yaml');
100
- }
101
- /**
102
- * Reads metadata from the root chart manifest.
103
- * @param tree Nx's release file tree.
104
- * @returns Chart metadata.
105
- */
106
- readMetadata(tree) {
107
- const content = tree.read(this.chartManifestPath, 'utf8');
108
- if (content === null) {
109
- throw new Error(`[nx-helm] Could not find Helm manifest ${this.chartManifestPath}.`);
110
- }
111
- return (0, chart_manifest_1.readChartMetadata)(content, this.chartManifestPath);
112
- }
113
35
  }
114
- exports.default = HelmVersionActions;
36
+ function readChart(tree, path) {
37
+ const content = tree.read(path, 'utf8');
38
+ if (!content)
39
+ throw new Error(`[nx-helm] Missing ${path}.`);
40
+ const chart = parseDocument(content);
41
+ if (chart.errors.length)
42
+ throw new Error(`[nx-helm] Invalid ${path}: ${chart.errors[0].message}`);
43
+ return chart;
44
+ }
45
+ //# sourceMappingURL=version-actions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version-actions.js","sourceRoot":"","sources":["../../../../../../plugins/nx/helm/src/release/version-actions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAG5C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AAErC,mEAAmE;AACnE,MAAM,CAAC,OAAO,OAAO,kBAAmB,SAAQ,cAAc;IAC5D,sBAAsB,GAAG,CAAC,YAAY,CAAC,CAAC;IAExC,KAAK,CAAC,oCAAoC,CACxC,IAAU;QAEV,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;QACzE,MAAM,KAAK,GAAG,SAAS,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;QAC5C,IAAI,OAAO,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,KAAK,QAAQ;YAC1C,MAAM,IAAI,KAAK,CAAC,aAAa,YAAY,6BAA6B,CAAC,CAAC;QAC1E,OAAO,EAAE,cAAc,EAAE,KAAK,CAAC,GAAG,CAAC,SAAS,CAAW,EAAE,YAAY,EAAE,CAAC;IAC1E,CAAC;IAED,KAAK,CAAC,8BAA8B;QAIlC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,8BAA8B;QAIlC,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,oBAAoB,EAAE,IAAI,EAAE,CAAC;IAC9D,CAAC;IAED,KAAK,CAAC,oBAAoB,CACxB,IAAU,EACV,UAAkB;QAElB,MAAM,QAAQ,GAAa,EAAE,CAAC;QAC9B,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,iBAAiB,EAAE,CAAC;YAC9C,MAAM,KAAK,GAAG,SAAS,CAAC,IAAI,EAAE,QAAQ,CAAC,YAAY,CAAC,CAAC;YACrD,KAAK,CAAC,GAAG,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;YACjC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,YAAY,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;YACpD,QAAQ,CAAC,IAAI,CACX,mBAAmB,UAAU,yBAAyB,QAAQ,CAAC,YAAY,EAAE,CAC9E,CAAC;QACJ,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,KAAK,CAAC,yBAAyB,CAC7B,KAAW,EACX,aAA2B,EAC3B,oBAA4C;QAE5C,IAAI,MAAM,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC,MAAM;YAC1C,MAAM,IAAI,KAAK,CACb,gFAAgF,CACjF,CAAC;QACJ,OAAO,EAAE,CAAC;IACZ,CAAC;CACF;AAED,SAAS,SAAS,CAAC,IAAU,EAAE,IAAY;IACzC,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACxC,IAAI,CAAC,OAAO;QAAE,MAAM,IAAI,KAAK,CAAC,qBAAqB,IAAI,GAAG,CAAC,CAAC;IAC5D,MAAM,KAAK,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;IACrC,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM;QACrB,MAAM,IAAI,KAAK,CAAC,qBAAqB,IAAI,KAAK,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;IAC3E,OAAO,KAAK,CAAC;AACf,CAAC"}
package/CHANGELOG.md DELETED
@@ -1,48 +0,0 @@
1
- ## Unreleased
2
-
3
- ### Breaking Changes
4
-
5
- - Build chart dependencies from the committed lockfile without refreshing Helm
6
- repositories.
7
-
8
- ## 0.0.5 (2026-08-12)
9
-
10
- ### Breaking Changes
11
-
12
- - Infer cache, outputs, and Helm-version runtime inputs directly on standalone
13
- chart targets.
14
- - Replace workspace `validateTarget`, `packageTarget`, and `registry` options
15
- with `validate`, `package`, and `publish.registry`.
16
- - Infer `nx-release-publish` only for configured OCI registries; project
17
- `metadata.helm` can override registry and validation settings or disable
18
- publishing.
19
- - Stop injecting target defaults during plugin initialization and stop adding
20
- organization-specific chart tags.
21
-
22
- ## 0.0.4 (2026-08-12)
23
-
24
- ### 🚀 Features
25
-
26
- - **plugins:** add nx helm and argo plugins ([eb30b828](https://github.com/otwld/devops/commit/eb30b828))
27
-
28
- ### ❤️ Thank You
29
-
30
- - Tréhout Nathan
31
-
32
- ## 0.0.3 (2026-08-12)
33
-
34
- ### 🚀 Features
35
-
36
- - **helm:** add inferred chart projects and nx add setup ([2061556](https://github.com/otwld/monorepo-starter/commit/2061556))
37
- - create nx-helm plugin with validate as a the first executor ([b7784f3](https://github.com/otwld/monorepo-starter/commit/b7784f3))
38
-
39
- ### ❤️ Thank You
40
-
41
- - Tréhout Nathan
42
-
43
- ## 0.0.2 (2026-08-12)
44
-
45
- ### Features
46
-
47
- - Add inferred Helm chart projects and initialization.
48
- - Add Helm validation, packaging, and release publishing.
package/README.md DELETED
@@ -1,131 +0,0 @@
1
- # @otwld/nx-helm
2
-
3
- Nx generators, inferred targets, and executors for Helm charts.
4
-
5
- ## Generate a Chart
6
-
7
- ```shell
8
- pnpm exec nx add @otwld/nx-helm
9
- pnpm exec nx g @otwld/nx-helm:chart service
10
- ```
11
-
12
- The chart generator runs `helm create` and adds `project.json`:
13
-
14
- ```text
15
- charts/service/
16
- ├── Chart.yaml
17
- ├── templates/
18
- ├── values.yaml
19
- └── project.json
20
- ```
21
-
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 chart template,
36
- and the `helm-public` Nx project marker. Run `helm dependency update charts/public`
37
- after adding dependencies so the generated `Chart.lock` is committed; validation
38
- and packaging then use `helm dependency build --skip-refresh`.
39
-
40
- ## Inferred Targets
41
-
42
- Charts with sibling `Chart.yaml` and `project.json` files receive these targets:
43
-
44
- - `helm:validate` runs `helm lint` and `helm template`.
45
- - `helm:package` packages the chart into `dist/<project-root>/helm`.
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
- Dependency builds use the committed lockfile without refreshing Helm repositories.
55
- Charts without local dependencies keep the original target graph.
56
-
57
- ## Configuration
58
-
59
- ```jsonc
60
- {
61
- "plugins": [
62
- {
63
- "plugin": "@otwld/nx-helm",
64
- "options": {
65
- "validate": {
66
- "target": "helm:validate",
67
- "kubeVersion": "1.32.0",
68
- "strict": false,
69
- "validationValues": ["values-ci.yaml"],
70
- },
71
- "package": {
72
- "target": "helm:package",
73
- },
74
- "publish": {
75
- "registry": "oci://registry.company.test/charts",
76
- },
77
- },
78
- },
79
- ],
80
- }
81
- ```
82
-
83
- Project-specific settings belong in `project.json` under `metadata.helm`.
84
- `registry`, `publish`, `kubeVersion`, `strict`, `releaseName`, and
85
- `validationValues` override workspace options; `publish: false` suppresses the
86
- release target.
87
-
88
- ```jsonc
89
- {
90
- "metadata": {
91
- "helm": {
92
- "registry": "oci://registry.company.test/team-charts",
93
- "releaseName": "service",
94
- "validationValues": ["values-ci.yaml"],
95
- },
96
- },
97
- }
98
- ```
99
-
100
- ## Helm Release
101
-
102
- ```shell
103
- pnpm exec nx release version patch --groups=helm --first-release --dry-run
104
- pnpm exec nx release changelog 0.1.1 --groups=helm --first-release --dry-run
105
- pnpm exec nx release publish --groups=helm --dry-run
106
- ```
107
-
108
- Authenticate with the OCI registry before publishing:
109
-
110
- ```shell
111
- helm registry login registry.company.test
112
- pnpm exec nx release --groups=helm --first-release
113
- ```
114
-
115
- ## npm Release
116
-
117
- The npm release group versions packages independently with Conventional
118
- Commits, updates source and distribution manifests, and publishes distribution
119
- packages.
120
-
121
- ```shell
122
- pnpm exec nx release version --groups=npm --first-release --dry-run
123
- pnpm exec nx release publish --groups=npm --first-release --dry-run --access=public
124
- pnpm exec nx release --groups=npm --first-release
125
- ```
126
-
127
- ## Package Targets
128
-
129
- - `nx build nx-helm`
130
- - `nx lint nx-helm`
131
- - `nx test nx-helm`
@@ -1,22 +0,0 @@
1
- /** Metadata required to package and publish a Helm chart. */
2
- export interface ChartMetadata {
3
- /** The chart name used in the packaged archive name. */
4
- name: string;
5
- /** The chart version used in the packaged archive name and OCI tag. */
6
- version: string;
7
- }
8
- /**
9
- * Reads and validates the package metadata in a Chart.yaml document.
10
- * @param content Chart.yaml contents.
11
- * @param filePath Chart.yaml path used in validation errors.
12
- * @returns The chart name and semantic version.
13
- */
14
- export declare function readChartMetadata(content: string, filePath: string): ChartMetadata;
15
- /**
16
- * Updates only the Chart.yaml version while retaining the document structure.
17
- * @param content Chart.yaml contents.
18
- * @param filePath Chart.yaml path used in validation errors.
19
- * @param newVersion New semantic chart version.
20
- * @returns Updated Chart.yaml contents.
21
- */
22
- export declare function updateChartVersion(content: string, filePath: string, newVersion: string): string;
@@ -1,56 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.readChartMetadata = readChartMetadata;
4
- exports.updateChartVersion = updateChartVersion;
5
- const semver_1 = require("semver");
6
- const yaml_1 = require("yaml");
7
- /**
8
- * Reads and validates the package metadata in a Chart.yaml document.
9
- * @param content Chart.yaml contents.
10
- * @param filePath Chart.yaml path used in validation errors.
11
- * @returns The chart name and semantic version.
12
- */
13
- function readChartMetadata(content, filePath) {
14
- const document = parseChartDocument(content, filePath);
15
- const name = document.get('name');
16
- const version = document.get('version');
17
- if (typeof name !== 'string' || !name.trim()) {
18
- throw new Error(`Chart ${filePath} must define a non-empty name.`);
19
- }
20
- if (typeof version !== 'string' || !(0, semver_1.valid)(version)) {
21
- throw new Error(`Chart ${filePath} must define a valid semantic version in version.`);
22
- }
23
- return { name, version };
24
- }
25
- /**
26
- * Updates only the Chart.yaml version while retaining the document structure.
27
- * @param content Chart.yaml contents.
28
- * @param filePath Chart.yaml path used in validation errors.
29
- * @param newVersion New semantic chart version.
30
- * @returns Updated Chart.yaml contents.
31
- */
32
- function updateChartVersion(content, filePath, newVersion) {
33
- const document = parseChartDocument(content, filePath);
34
- const currentVersion = document.get('version');
35
- if (typeof currentVersion !== 'string' || !(0, semver_1.valid)(currentVersion)) {
36
- throw new Error(`Chart ${filePath} must define a valid semantic version in version.`);
37
- }
38
- if (!(0, semver_1.valid)(newVersion)) {
39
- throw new Error(`Release version ${newVersion} is not valid semantic version.`);
40
- }
41
- document.set('version', newVersion);
42
- return document.toString();
43
- }
44
- /**
45
- * Parses one Chart.yaml document and reports syntax errors with its path.
46
- * @param content Chart.yaml contents.
47
- * @param filePath Chart.yaml path used in validation errors.
48
- * @returns Parsed YAML document.
49
- */
50
- function parseChartDocument(content, filePath) {
51
- const document = (0, yaml_1.parseDocument)(content, { prettyErrors: false });
52
- if (document.errors.length > 0) {
53
- throw new Error(`Chart ${filePath} contains invalid YAML: ${document.errors[0].message}`);
54
- }
55
- return document;
56
- }
@@ -1,10 +0,0 @@
1
- import type { PromiseExecutor } from '@nx/devkit';
2
- import type { PackageExecutorSchema } from './schema';
3
- /**
4
- * Packages the root chart owned by an Nx project into a versioned archive.
5
- * @param options Executor options supplied by Nx.
6
- * @param context Nx's executor context.
7
- * @returns Whether the Helm package operation completed successfully.
8
- */
9
- declare const runExecutor: PromiseExecutor<PackageExecutorSchema>;
10
- export default runExecutor;
@@ -1,57 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const node_fs_1 = require("node:fs");
4
- const node_path_1 = require("node:path");
5
- const chart_manifest_1 = require("../../chart-manifest");
6
- const project_directory_1 = require("../project-directory");
7
- const run_helm_1 = require("../run-helm");
8
- /**
9
- * Packages the root chart owned by an Nx project into a versioned archive.
10
- * @param options Executor options supplied by Nx.
11
- * @param context Nx's executor context.
12
- * @returns Whether the Helm package operation completed successfully.
13
- */
14
- const runExecutor = async (options, context) => {
15
- const projectDirectory = (0, project_directory_1.getProjectDirectory)(context, 'packaging');
16
- if (!projectDirectory) {
17
- return { success: false };
18
- }
19
- const outputDirectory = (0, node_path_1.resolve)(context.root, options.outputPath);
20
- const dryRun = isDryRun(options.dryRun);
21
- try {
22
- const chartFilePath = (0, node_path_1.join)(projectDirectory, 'Chart.yaml');
23
- const metadata = (0, chart_manifest_1.readChartMetadata)((0, node_fs_1.readFileSync)(chartFilePath, 'utf8'), chartFilePath);
24
- const archivePath = (0, node_path_1.join)(outputDirectory, `${metadata.name}-${metadata.version}.tgz`);
25
- if (dryRun) {
26
- console.log(`[nx-helm] Would package chart to ${archivePath}`);
27
- return { success: true };
28
- }
29
- (0, node_fs_1.mkdirSync)(outputDirectory, { recursive: true });
30
- console.log(`[nx-helm] Packaging chart ${projectDirectory}`);
31
- if (!(await (0, run_helm_1.runHelm)(['package', '.', '--destination', outputDirectory], projectDirectory))) {
32
- return { success: false };
33
- }
34
- }
35
- catch (error) {
36
- console.error(`[nx-helm] Could not package chart ${projectDirectory}: ${getErrorMessage(error)}`);
37
- return { success: false };
38
- }
39
- return { success: true };
40
- };
41
- /**
42
- * Checks the Nx dry-run environment and executor option.
43
- * @param optionDryRun Explicit executor dry-run option.
44
- * @returns Whether the operation must avoid filesystem changes.
45
- */
46
- function isDryRun(optionDryRun) {
47
- return optionDryRun === true || process.env['NX_DRY_RUN'] === 'true';
48
- }
49
- /**
50
- * Converts unknown caught values into useful command-line text.
51
- * @param error Caught value.
52
- * @returns Human-readable error text.
53
- */
54
- function getErrorMessage(error) {
55
- return error instanceof Error ? error.message : String(error);
56
- }
57
- exports.default = runExecutor;
@@ -1,7 +0,0 @@
1
- /** Options accepted by the Helm package executor. */
2
- export interface PackageExecutorSchema {
3
- /** Workspace-relative directory where the chart archive is written. */
4
- outputPath: string;
5
- /** Whether to report the package operation without writing an archive. */
6
- dryRun?: boolean;
7
- }
@@ -1,18 +0,0 @@
1
- {
2
- "$schema": "https://json-schema.org/schema",
3
- "version": 2,
4
- "title": "Package executor",
5
- "description": "Package the root Helm chart into a versioned archive.",
6
- "type": "object",
7
- "properties": {
8
- "outputPath": {
9
- "type": "string",
10
- "description": "Workspace-relative directory where the chart archive is written."
11
- },
12
- "dryRun": {
13
- "type": "boolean",
14
- "description": "Report the package operation without writing an archive."
15
- }
16
- },
17
- "required": ["outputPath"]
18
- }
@@ -1,8 +0,0 @@
1
- import type { ExecutorContext } from '@nx/devkit';
2
- /**
3
- * Resolves the owning Nx project directory for a Helm executor.
4
- * @param context Nx's executor context.
5
- * @param operation Operation requiring the project directory.
6
- * @returns The absolute project directory, or undefined when unavailable.
7
- */
8
- export declare function getProjectDirectory(context: ExecutorContext, operation: string): string | undefined;
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getProjectDirectory = getProjectDirectory;
4
- const node_path_1 = require("node:path");
5
- /**
6
- * Resolves the owning Nx project directory for a Helm executor.
7
- * @param context Nx's executor context.
8
- * @param operation Operation requiring the project directory.
9
- * @returns The absolute project directory, or undefined when unavailable.
10
- */
11
- function getProjectDirectory(context, operation) {
12
- const projectName = context.projectName;
13
- if (!projectName) {
14
- console.error(`[nx-helm] Helm ${operation} requires an Nx project context.`);
15
- return undefined;
16
- }
17
- const project = context.projectsConfigurations.projects[projectName];
18
- if (!project) {
19
- console.error(`[nx-helm] Could not resolve Nx project "${projectName}".`);
20
- return undefined;
21
- }
22
- return (0, node_path_1.resolve)(context.root, project.root);
23
- }
@@ -1,10 +0,0 @@
1
- import type { PromiseExecutor } from '@nx/devkit';
2
- import type { ReleasePublishExecutorSchema } from './schema';
3
- /**
4
- * Pushes the root chart archive during `nx release publish`.
5
- * @param options Executor options supplied by Nx.
6
- * @param context Nx's executor context.
7
- * @returns Whether the Helm chart was published successfully.
8
- */
9
- declare const runExecutor: PromiseExecutor<ReleasePublishExecutorSchema>;
10
- export default runExecutor;
@@ -1,102 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const node_fs_1 = require("node:fs");
4
- const node_path_1 = require("node:path");
5
- const chart_manifest_1 = require("../../chart-manifest");
6
- const project_directory_1 = require("../project-directory");
7
- const run_helm_1 = require("../run-helm");
8
- /**
9
- * Pushes the root chart archive during `nx release publish`.
10
- * @param options Executor options supplied by Nx.
11
- * @param context Nx's executor context.
12
- * @returns Whether the Helm chart was published successfully.
13
- */
14
- const runExecutor = async (options, context) => {
15
- const projectDirectory = (0, project_directory_1.getProjectDirectory)(context, 'publishing');
16
- if (!projectDirectory) {
17
- return { success: false };
18
- }
19
- const registry = normalizeRegistry(options.registry);
20
- if (!registry) {
21
- console.error('[nx-helm] Helm release publishing requires an OCI registry such as ' +
22
- 'oci://registry.company.test/charts.');
23
- return { success: false };
24
- }
25
- const outputDirectory = (0, node_path_1.resolve)(context.root, options.outputPath);
26
- const dryRun = isDryRun(options.dryRun);
27
- if (!(await publishChart(projectDirectory, outputDirectory, registry, dryRun))) {
28
- return { success: false };
29
- }
30
- return { success: true };
31
- };
32
- /**
33
- * Normalizes and validates the Helm OCI repository reference.
34
- * @param registry Configured registry repository.
35
- * @returns A normalized OCI repository, or undefined when invalid.
36
- */
37
- function normalizeRegistry(registry) {
38
- let normalized = registry?.trim();
39
- if (!normalized) {
40
- return undefined;
41
- }
42
- while (normalized.endsWith('/')) {
43
- normalized = normalized.slice(0, -1);
44
- }
45
- return normalized.startsWith('oci://') ? normalized : undefined;
46
- }
47
- /**
48
- * Packages an absent archive and pushes one chart archive.
49
- * @param projectDirectory Owning Nx project directory.
50
- * @param outputDirectory Workspace package output directory.
51
- * @param registry OCI repository to receive the chart.
52
- * @param dryRun Whether to avoid package and push operations.
53
- * @returns Whether the chart publish operation succeeded.
54
- */
55
- async function publishChart(projectDirectory, outputDirectory, registry, dryRun) {
56
- try {
57
- const chartFilePath = (0, node_path_1.join)(projectDirectory, 'Chart.yaml');
58
- const metadata = (0, chart_manifest_1.readChartMetadata)((0, node_fs_1.readFileSync)(chartFilePath, 'utf8'), chartFilePath);
59
- const archivePath = (0, node_path_1.join)(outputDirectory, `${metadata.name}-${metadata.version}.tgz`);
60
- if (dryRun) {
61
- if (!(0, node_fs_1.existsSync)(archivePath)) {
62
- console.log(`[nx-helm] Would package chart to ${archivePath}`);
63
- }
64
- console.log(`[nx-helm] Would push ${archivePath} to ${registry}`);
65
- return true;
66
- }
67
- if (!(0, node_fs_1.existsSync)(archivePath)) {
68
- (0, node_fs_1.mkdirSync)(outputDirectory, { recursive: true });
69
- console.log(`[nx-helm] Packaging chart ${projectDirectory}`);
70
- if (!(await (0, run_helm_1.runHelm)(['package', '.', '--destination', outputDirectory], projectDirectory))) {
71
- return false;
72
- }
73
- }
74
- if (!(0, node_fs_1.existsSync)(archivePath)) {
75
- console.error(`[nx-helm] Helm did not create ${archivePath}.`);
76
- return false;
77
- }
78
- console.log(`[nx-helm] Publishing chart ${metadata.name}:${metadata.version}`);
79
- return (0, run_helm_1.runHelm)(['push', archivePath, registry], projectDirectory);
80
- }
81
- catch (error) {
82
- console.error(`[nx-helm] Could not publish chart ${projectDirectory}: ${getErrorMessage(error)}`);
83
- return false;
84
- }
85
- }
86
- /**
87
- * Checks the Nx dry-run environment and executor option.
88
- * @param optionDryRun Explicit executor dry-run option.
89
- * @returns Whether the operation must avoid publishing.
90
- */
91
- function isDryRun(optionDryRun) {
92
- return optionDryRun === true || process.env['NX_DRY_RUN'] === 'true';
93
- }
94
- /**
95
- * Converts unknown caught values into useful command-line text.
96
- * @param error Caught value.
97
- * @returns Human-readable error text.
98
- */
99
- function getErrorMessage(error) {
100
- return error instanceof Error ? error.message : String(error);
101
- }
102
- exports.default = runExecutor;
@@ -1,9 +0,0 @@
1
- /** Options accepted by the Helm Nx Release publish executor. */
2
- export interface ReleasePublishExecutorSchema {
3
- /** Workspace-relative directory containing the packaged chart archive. */
4
- outputPath: string;
5
- /** OCI registry repository without chart name or version tag. */
6
- registry?: string;
7
- /** Whether to report the publish operation without pushing an archive. */
8
- dryRun?: boolean;
9
- }