@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,22 +0,0 @@
1
- {
2
- "$schema": "https://json-schema.org/schema",
3
- "version": 2,
4
- "title": "Release publish executor",
5
- "description": "Push the packaged root Helm chart to an OCI registry during nx release publish.",
6
- "type": "object",
7
- "properties": {
8
- "outputPath": {
9
- "type": "string",
10
- "description": "Workspace-relative directory containing the packaged chart archive."
11
- },
12
- "registry": {
13
- "type": "string",
14
- "description": "OCI registry repository without chart name or version tag."
15
- },
16
- "dryRun": {
17
- "type": "boolean",
18
- "description": "Report the publish operation without pushing an archive."
19
- }
20
- },
21
- "required": ["outputPath"]
22
- }
@@ -1,7 +0,0 @@
1
- /**
2
- * Runs one Helm command without invoking a shell.
3
- * @param arguments_ Helm command arguments.
4
- * @param cwd Working directory for the Helm process.
5
- * @returns Whether Helm exited successfully.
6
- */
7
- export declare function runHelm(arguments_: string[], cwd: string): Promise<boolean>;
@@ -1,32 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.runHelm = runHelm;
4
- const node_child_process_1 = require("node:child_process");
5
- /**
6
- * Runs one Helm command without invoking a shell.
7
- * @param arguments_ Helm command arguments.
8
- * @param cwd Working directory for the Helm process.
9
- * @returns Whether Helm exited successfully.
10
- */
11
- function runHelm(arguments_, cwd) {
12
- return new Promise((resolveCommand) => {
13
- // Resolve Helm from the user's PATH so the workspace controls the CLI version.
14
- // eslint-disable-next-line sonarjs/no-os-command-from-path
15
- const child = (0, node_child_process_1.spawn)('helm', arguments_, {
16
- cwd,
17
- stdio: 'inherit',
18
- });
19
- let settled = false;
20
- const settle = (success) => {
21
- if (!settled) {
22
- settled = true;
23
- resolveCommand(success);
24
- }
25
- };
26
- child.once('error', (error) => {
27
- console.error(`[nx-helm] Could not run Helm: ${error.message}`);
28
- settle(false);
29
- });
30
- child.once('close', (code) => settle(code === 0));
31
- });
32
- }
@@ -1,11 +0,0 @@
1
- /** Options accepted by the Helm validation executor. */
2
- export interface ValidateExecutorSchema {
3
- /** Kubernetes version passed to `helm template`. */
4
- kubeVersion?: string;
5
- /** Whether `helm lint` should fail on warnings. */
6
- strict?: boolean;
7
- /** Release name passed to `helm template`; defaults to the Nx project name. */
8
- releaseName?: string;
9
- /** Values files passed to both Helm commands. */
10
- valuesFiles?: string[];
11
- }
@@ -1,29 +0,0 @@
1
- {
2
- "$schema": "https://json-schema.org/schema",
3
- "version": 2,
4
- "title": "Validate executor",
5
- "description": "Lint and render the root Helm chart.",
6
- "type": "object",
7
- "properties": {
8
- "kubeVersion": {
9
- "type": "string",
10
- "description": "Kubernetes version passed to helm template."
11
- },
12
- "strict": {
13
- "type": "boolean",
14
- "description": "Fail helm lint when it reports warnings.",
15
- "default": false
16
- },
17
- "releaseName": {
18
- "type": "string",
19
- "description": "Release name passed to helm template. Defaults to the Nx project name."
20
- },
21
- "valuesFiles": {
22
- "type": "array",
23
- "description": "Values files, relative to the owning Nx project root.",
24
- "items": {
25
- "type": "string"
26
- }
27
- }
28
- }
29
- }
@@ -1,16 +0,0 @@
1
- import type { PromiseExecutor } from '@nx/devkit';
2
- import type { ValidateExecutorSchema } from './schema';
3
- /**
4
- * Lints and renders the root chart owned by an Nx project.
5
- * @param options Executor options supplied by Nx.
6
- * @param context Nx's executor context.
7
- * @returns Whether every Helm command completed successfully.
8
- */
9
- declare const runExecutor: PromiseExecutor<ValidateExecutorSchema>;
10
- /**
11
- * Builds repeated `--values` arguments without invoking a shell.
12
- * @param valuesFiles Values files to pass to Helm.
13
- * @returns Flattened Helm argument pairs.
14
- */
15
- export declare function createValuesArguments(valuesFiles?: string[]): string[];
16
- export default runExecutor;
@@ -1,50 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createValuesArguments = createValuesArguments;
4
- const project_directory_1 = require("../project-directory");
5
- const run_helm_1 = require("../run-helm");
6
- const fallbackReleaseName = 'helm-validate';
7
- /**
8
- * Lints and renders the root chart owned by an Nx project.
9
- * @param options Executor options supplied by Nx.
10
- * @param context Nx's executor context.
11
- * @returns Whether every Helm command completed successfully.
12
- */
13
- const runExecutor = async (options, context) => {
14
- const projectDirectory = (0, project_directory_1.getProjectDirectory)(context, 'validation');
15
- if (!projectDirectory) {
16
- return { success: false };
17
- }
18
- const releaseName = options.releaseName ?? context.projectName ?? fallbackReleaseName;
19
- const valuesArguments = createValuesArguments(options.valuesFiles);
20
- const lintArguments = [
21
- 'lint',
22
- '.',
23
- ...(options.strict ? ['--strict'] : []),
24
- ...valuesArguments,
25
- ];
26
- const templateArguments = [
27
- 'template',
28
- releaseName,
29
- '.',
30
- ...(options.kubeVersion ? ['--kube-version', options.kubeVersion] : []),
31
- ...valuesArguments,
32
- ];
33
- console.log(`[nx-helm] Validating chart ${projectDirectory}`);
34
- if (!(await (0, run_helm_1.runHelm)(lintArguments, projectDirectory))) {
35
- return { success: false };
36
- }
37
- if (!(await (0, run_helm_1.runHelm)(templateArguments, projectDirectory))) {
38
- return { success: false };
39
- }
40
- return { success: true };
41
- };
42
- /**
43
- * Builds repeated `--values` arguments without invoking a shell.
44
- * @param valuesFiles Values files to pass to Helm.
45
- * @returns Flattened Helm argument pairs.
46
- */
47
- function createValuesArguments(valuesFiles = []) {
48
- return valuesFiles.flatMap((valuesFile) => ['--values', valuesFile]);
49
- }
50
- exports.default = runExecutor;
@@ -1,10 +0,0 @@
1
- import { type Tree } from '@nx/devkit';
2
- import type { ChartGeneratorSchema } from './schema';
3
- /**
4
- * Creates a Helm chart with Helm's own starter implementation and adds only
5
- * the Nx project marker required for inferred Helm targets.
6
- * @param tree Workspace tree to update.
7
- * @param options Generator options supplied by Nx.
8
- * @returns A promise that resolves after generated files are written.
9
- */
10
- export default function chartGenerator(tree: Tree, options: ChartGeneratorSchema): Promise<void>;
@@ -1,101 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = chartGenerator;
4
- const devkit_1 = require("@nx/devkit");
5
- const node_child_process_1 = require("node:child_process");
6
- const node_fs_1 = require("node:fs");
7
- const node_path_1 = require("node:path");
8
- const node_os_1 = require("node:os");
9
- const defaultDirectory = 'charts';
10
- /**
11
- * Creates a Helm chart with Helm's own starter implementation and adds only
12
- * the Nx project marker required for inferred Helm targets.
13
- * @param tree Workspace tree to update.
14
- * @param options Generator options supplied by Nx.
15
- * @returns A promise that resolves after generated files are written.
16
- */
17
- async function chartGenerator(tree, options) {
18
- if (!options.name.trim()) {
19
- throw new Error('[nx-helm] A chart name is required.');
20
- }
21
- const chartDirectoryName = (0, devkit_1.names)(options.name).fileName;
22
- const projectRoot = (0, devkit_1.joinPathFragments)(options.directory ?? defaultDirectory, chartDirectoryName);
23
- const projectName = options.projectName ?? `helm-${chartDirectoryName}`;
24
- if (tree.exists((0, devkit_1.joinPathFragments)(projectRoot, 'Chart.yaml'))) {
25
- throw new Error(`[nx-helm] A Helm chart already exists at ${projectRoot}.`);
26
- }
27
- const temporaryDirectory = (0, node_fs_1.mkdtempSync)((0, node_path_1.join)((0, node_os_1.tmpdir)(), 'nx-helm-'));
28
- const temporaryChartDirectory = (0, node_path_1.join)(temporaryDirectory, chartDirectoryName);
29
- try {
30
- runHelmCreate(temporaryChartDirectory, options.starter);
31
- copyGeneratedChartToTree(tree, temporaryChartDirectory, projectRoot);
32
- }
33
- finally {
34
- (0, node_fs_1.rmSync)(temporaryDirectory, { recursive: true, force: true });
35
- }
36
- (0, devkit_1.addProjectConfiguration)(tree, projectName, {
37
- root: projectRoot,
38
- projectType: 'application',
39
- tags: options.tags,
40
- });
41
- }
42
- /**
43
- * Runs Helm's documented chart scaffolder without invoking a shell.
44
- * @param chartDirectory Temporary chart output directory.
45
- * @param starter Optional Helm starter name or absolute path.
46
- */
47
- function runHelmCreate(chartDirectory, starter) {
48
- const arguments_ = ['create', chartDirectory];
49
- if (starter?.trim()) {
50
- arguments_.push('--starter', starter.trim());
51
- }
52
- try {
53
- // Resolve Helm from the user's PATH so the workspace controls the CLI version.
54
- // eslint-disable-next-line sonarjs/no-os-command-from-path
55
- (0, node_child_process_1.execFileSync)('helm', arguments_, {
56
- encoding: 'utf8',
57
- stdio: 'pipe',
58
- });
59
- }
60
- catch (error) {
61
- const processError = new Error(`[nx-helm] helm create failed: ${getProcessErrorMessage(error)}`);
62
- Object.defineProperty(processError, 'cause', { value: error });
63
- throw processError;
64
- }
65
- }
66
- /**
67
- * Imports Helm's generated chart files into the Nx virtual tree.
68
- * @param tree Workspace tree to update.
69
- * @param sourceDirectory Temporary Helm chart directory.
70
- * @param targetDirectory Workspace-relative chart project root.
71
- */
72
- function copyGeneratedChartToTree(tree, sourceDirectory, targetDirectory) {
73
- for (const entry of (0, node_fs_1.readdirSync)(sourceDirectory, { withFileTypes: true })) {
74
- const sourcePath = (0, node_path_1.join)(sourceDirectory, entry.name);
75
- const targetPath = (0, devkit_1.joinPathFragments)(targetDirectory, entry.name);
76
- if (entry.isDirectory()) {
77
- copyGeneratedChartToTree(tree, sourcePath, targetPath);
78
- continue;
79
- }
80
- if (entry.isFile()) {
81
- tree.write(targetPath, (0, node_fs_1.readFileSync)(sourcePath));
82
- }
83
- }
84
- }
85
- /**
86
- * Converts a Helm process failure into actionable generator output.
87
- * @param error Process failure from execFileSync.
88
- * @returns Standard error text or the caught error message.
89
- */
90
- function getProcessErrorMessage(error) {
91
- if (error instanceof Error && 'stderr' in error) {
92
- const stderr = error.stderr;
93
- if (typeof stderr === 'string' && stderr.trim()) {
94
- return stderr.trim();
95
- }
96
- if (Buffer.isBuffer(stderr) && stderr.length > 0) {
97
- return stderr.toString('utf8').trim();
98
- }
99
- }
100
- return error instanceof Error ? error.message : String(error);
101
- }
@@ -1,13 +0,0 @@
1
- /** Options accepted by the standalone Helm chart generator. */
2
- export interface ChartGeneratorSchema {
3
- /** Chart directory name and project suffix. */
4
- name: string;
5
- /** Parent directory for the generated chart project. */
6
- directory?: string;
7
- /** Explicit Nx project name. */
8
- projectName?: string;
9
- /** Helm starter name or absolute starter path passed to helm create. */
10
- starter?: string;
11
- /** Nx project tags assigned to the generated chart. */
12
- tags?: string[];
13
- }
@@ -1,43 +0,0 @@
1
- {
2
- "$schema": "https://json-schema.org/schema",
3
- "$id": "ChartGeneratorSchema",
4
- "title": "Standalone Helm chart generator",
5
- "description": "Run helm create and add a minimal Nx project marker for one Helm chart.",
6
- "type": "object",
7
- "properties": {
8
- "name": {
9
- "type": "string",
10
- "description": "Chart directory name and project suffix.",
11
- "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]*$",
12
- "$default": {
13
- "$source": "argv",
14
- "index": 0
15
- },
16
- "x-prompt": "What is the chart name?",
17
- "x-priority": "important"
18
- },
19
- "directory": {
20
- "type": "string",
21
- "description": "Parent directory for the generated chart project.",
22
- "default": "charts"
23
- },
24
- "projectName": {
25
- "type": "string",
26
- "description": "Nx project name. Uses helm-<name> when omitted.",
27
- "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]*$"
28
- },
29
- "starter": {
30
- "type": "string",
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
- }
39
- }
40
- },
41
- "required": ["name"],
42
- "additionalProperties": false
43
- }
@@ -1,9 +0,0 @@
1
- import { type Tree } from '@nx/devkit';
2
- import type { InitGeneratorSchema } from './schema';
3
- /**
4
- * Registers `@otwld/nx-helm` without adding workspace target defaults.
5
- * @param tree Workspace tree to update.
6
- * @param options Init options supplied by Nx.
7
- * @returns A promise that resolves after optional formatting.
8
- */
9
- export default function initGenerator(tree: Tree, options: InitGeneratorSchema): Promise<void>;
@@ -1,37 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = initGenerator;
4
- const devkit_1 = require("@nx/devkit");
5
- const pluginName = '@otwld/nx-helm';
6
- /**
7
- * Registers `@otwld/nx-helm` without adding workspace target defaults.
8
- * @param tree Workspace tree to update.
9
- * @param options Init options supplied by Nx.
10
- * @returns A promise that resolves after optional formatting.
11
- */
12
- async function initGenerator(tree, options) {
13
- if (!tree.exists('nx.json')) {
14
- devkit_1.logger.warn('[nx-helm] nx.json was not found; plugin registration was skipped.');
15
- return;
16
- }
17
- const nxJson = (0, devkit_1.readNxJson)(tree) ?? {};
18
- const existingPlugin = findPlugin(nxJson.plugins);
19
- if (!existingPlugin) {
20
- nxJson.plugins = [...(nxJson.plugins ?? []), pluginName];
21
- devkit_1.logger.info(`[nx-helm] Added ${pluginName} to nx.json.`);
22
- }
23
- (0, devkit_1.updateNxJson)(tree, nxJson);
24
- if (!options.skipFormat) {
25
- await (0, devkit_1.formatFiles)(tree);
26
- }
27
- }
28
- /**
29
- * Finds an existing string or object plugin registration.
30
- * @param plugins Nx plugin registrations.
31
- * @returns Existing Helm registration, or undefined.
32
- */
33
- function findPlugin(plugins) {
34
- return plugins?.find((plugin) => typeof plugin === 'string'
35
- ? plugin === pluginName
36
- : plugin?.plugin === pluginName);
37
- }
@@ -1,5 +0,0 @@
1
- /** Options accepted by the `@otwld/nx-helm` init generator. */
2
- export interface InitGeneratorSchema {
3
- /** Skip Prettier formatting after nx.json is updated. */
4
- skipFormat?: boolean;
5
- }
@@ -1,15 +0,0 @@
1
- {
2
- "$schema": "https://json-schema.org/schema",
3
- "$id": "NxHelmInitSchema",
4
- "title": "Nx Helm init generator",
5
- "description": "Register @otwld/nx-helm in nx.json.",
6
- "type": "object",
7
- "properties": {
8
- "skipFormat": {
9
- "type": "boolean",
10
- "description": "Skip Prettier formatting after nx.json is updated.",
11
- "default": false
12
- }
13
- },
14
- "additionalProperties": false
15
- }
@@ -1,27 +0,0 @@
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
- }
@@ -1,50 +0,0 @@
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
- }
@@ -1,4 +0,0 @@
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>;