@otwld/nx-helm 0.0.2

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 (47) hide show
  1. package/README.md +134 -0
  2. package/executors.json +21 -0
  3. package/generators.json +17 -0
  4. package/package.json +38 -0
  5. package/src/chart-manifest.d.ts +22 -0
  6. package/src/chart-manifest.js +57 -0
  7. package/src/chart-manifest.js.map +1 -0
  8. package/src/executors/package/package.d.ts +10 -0
  9. package/src/executors/package/package.js +59 -0
  10. package/src/executors/package/package.js.map +1 -0
  11. package/src/executors/package/schema.d.ts +7 -0
  12. package/src/executors/package/schema.json +18 -0
  13. package/src/executors/project-directory.d.ts +8 -0
  14. package/src/executors/project-directory.js +24 -0
  15. package/src/executors/project-directory.js.map +1 -0
  16. package/src/executors/release-publish/release-publish.d.ts +10 -0
  17. package/src/executors/release-publish/release-publish.js +106 -0
  18. package/src/executors/release-publish/release-publish.js.map +1 -0
  19. package/src/executors/release-publish/schema.d.ts +9 -0
  20. package/src/executors/release-publish/schema.json +22 -0
  21. package/src/executors/run-helm.d.ts +7 -0
  22. package/src/executors/run-helm.js +33 -0
  23. package/src/executors/run-helm.js.map +1 -0
  24. package/src/executors/validate/schema.d.ts +11 -0
  25. package/src/executors/validate/schema.json +29 -0
  26. package/src/executors/validate/validate.d.ts +16 -0
  27. package/src/executors/validate/validate.js +53 -0
  28. package/src/executors/validate/validate.js.map +1 -0
  29. package/src/generators/chart/chart.d.ts +10 -0
  30. package/src/generators/chart/chart.js +106 -0
  31. package/src/generators/chart/chart.js.map +1 -0
  32. package/src/generators/chart/schema.d.ts +11 -0
  33. package/src/generators/chart/schema.json +36 -0
  34. package/src/generators/init/init.d.ts +9 -0
  35. package/src/generators/init/init.js +136 -0
  36. package/src/generators/init/init.js.map +1 -0
  37. package/src/generators/init/schema.d.ts +15 -0
  38. package/src/generators/init/schema.json +41 -0
  39. package/src/index.d.ts +4 -0
  40. package/src/index.js +10 -0
  41. package/src/index.js.map +1 -0
  42. package/src/plugins/plugin.d.ts +34 -0
  43. package/src/plugins/plugin.js +214 -0
  44. package/src/plugins/plugin.js.map +1 -0
  45. package/src/release/version-actions.d.ts +67 -0
  46. package/src/release/version-actions.js +131 -0
  47. package/src/release/version-actions.js.map +1 -0
@@ -0,0 +1,11 @@
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
+ }
@@ -0,0 +1,29 @@
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
+ }
@@ -0,0 +1,16 @@
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;
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createValuesArguments = createValuesArguments;
4
+ const tslib_1 = require("tslib");
5
+ const project_directory_1 = require("../project-directory");
6
+ const run_helm_1 = require("../run-helm");
7
+ const fallbackReleaseName = 'helm-validate';
8
+ /**
9
+ * Lints and renders the root chart owned by an Nx project.
10
+ * @param options Executor options supplied by Nx.
11
+ * @param context Nx's executor context.
12
+ * @returns Whether every Helm command completed successfully.
13
+ */
14
+ const runExecutor = (options, context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
15
+ var _a, _b;
16
+ const projectDirectory = (0, project_directory_1.getProjectDirectory)(context, 'validation');
17
+ if (!projectDirectory) {
18
+ return { success: false };
19
+ }
20
+ const releaseName = (_b = (_a = options.releaseName) !== null && _a !== void 0 ? _a : context.projectName) !== null && _b !== void 0 ? _b : fallbackReleaseName;
21
+ const valuesArguments = createValuesArguments(options.valuesFiles);
22
+ const lintArguments = [
23
+ 'lint',
24
+ '.',
25
+ ...(options.strict ? ['--strict'] : []),
26
+ ...valuesArguments,
27
+ ];
28
+ const templateArguments = [
29
+ 'template',
30
+ releaseName,
31
+ '.',
32
+ ...(options.kubeVersion ? ['--kube-version', options.kubeVersion] : []),
33
+ ...valuesArguments,
34
+ ];
35
+ console.log(`[nx-helm] Validating chart ${projectDirectory}`);
36
+ if (!(yield (0, run_helm_1.runHelm)(lintArguments, projectDirectory))) {
37
+ return { success: false };
38
+ }
39
+ if (!(yield (0, run_helm_1.runHelm)(templateArguments, projectDirectory))) {
40
+ return { success: false };
41
+ }
42
+ return { success: true };
43
+ });
44
+ /**
45
+ * Builds repeated `--values` arguments without invoking a shell.
46
+ * @param valuesFiles Values files to pass to Helm.
47
+ * @returns Flattened Helm argument pairs.
48
+ */
49
+ function createValuesArguments(valuesFiles = []) {
50
+ return valuesFiles.flatMap((valuesFile) => ['--values', valuesFile]);
51
+ }
52
+ exports.default = runExecutor;
53
+ //# sourceMappingURL=validate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.js","sourceRoot":"","sources":["../../../../../../../plugins/nx/helm/src/executors/validate/validate.ts"],"names":[],"mappings":";;AAwDA,sDAEC;;AAxDD,4DAA2D;AAC3D,0CAAsC;AAGtC,MAAM,mBAAmB,GAAG,eAAe,CAAC;AAE5C;;;;;GAKG;AACH,MAAM,WAAW,GAA4C,CAC3D,OAAO,EACP,OAAO,EACP,EAAE;;IACF,MAAM,gBAAgB,GAAG,IAAA,uCAAmB,EAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IACpE,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACtB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC5B,CAAC;IACD,MAAM,WAAW,GACf,MAAA,MAAA,OAAO,CAAC,WAAW,mCAAI,OAAO,CAAC,WAAW,mCAAI,mBAAmB,CAAC;IACpE,MAAM,eAAe,GAAG,qBAAqB,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IACnE,MAAM,aAAa,GAAG;QACpB,MAAM;QACN,GAAG;QACH,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACvC,GAAG,eAAe;KACnB,CAAC;IACF,MAAM,iBAAiB,GAAG;QACxB,UAAU;QACV,WAAW;QACX,GAAG;QACH,GAAG,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,gBAAgB,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACvE,GAAG,eAAe;KACnB,CAAC;IAEF,OAAO,CAAC,GAAG,CAAC,8BAA8B,gBAAgB,EAAE,CAAC,CAAC;IAE9D,IAAI,CAAC,CAAC,MAAM,IAAA,kBAAO,EAAC,aAAa,EAAE,gBAAgB,CAAC,CAAC,EAAE,CAAC;QACtD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC5B,CAAC;IACD,IAAI,CAAC,CAAC,MAAM,IAAA,kBAAO,EAAC,iBAAiB,EAAE,gBAAgB,CAAC,CAAC,EAAE,CAAC;QAC1D,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC5B,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAC3B,CAAC,CAAA,CAAC;AAEF;;;;GAIG;AACH,SAAgB,qBAAqB,CAAC,cAAwB,EAAE;IAC9D,OAAO,WAAW,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC;AACvE,CAAC;AAED,kBAAe,WAAW,CAAC"}
@@ -0,0 +1,10 @@
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>;
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = chartGenerator;
4
+ const tslib_1 = require("tslib");
5
+ const devkit_1 = require("@nx/devkit");
6
+ const node_child_process_1 = require("node:child_process");
7
+ const node_fs_1 = require("node:fs");
8
+ const node_path_1 = require("node:path");
9
+ const node_os_1 = require("node:os");
10
+ const defaultDirectory = 'charts';
11
+ /**
12
+ * Creates a Helm chart with Helm's own starter implementation and adds only
13
+ * the Nx project marker required for inferred Helm targets.
14
+ * @param tree Workspace tree to update.
15
+ * @param options Generator options supplied by Nx.
16
+ * @returns A promise that resolves after generated files are written.
17
+ */
18
+ function chartGenerator(tree, options) {
19
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
20
+ var _a, _b;
21
+ if (!options.name.trim()) {
22
+ throw new Error('[nx-helm] A chart name is required.');
23
+ }
24
+ const chartDirectoryName = (0, devkit_1.names)(options.name).fileName;
25
+ const projectRoot = (0, devkit_1.joinPathFragments)((_a = options.directory) !== null && _a !== void 0 ? _a : defaultDirectory, chartDirectoryName);
26
+ const projectName = (_b = options.projectName) !== null && _b !== void 0 ? _b : `helm-${chartDirectoryName}`;
27
+ if (tree.exists((0, devkit_1.joinPathFragments)(projectRoot, 'Chart.yaml'))) {
28
+ throw new Error(`[nx-helm] A Helm chart already exists at ${projectRoot}.`);
29
+ }
30
+ const temporaryDirectory = (0, node_fs_1.mkdtempSync)((0, node_path_1.join)((0, node_os_1.tmpdir)(), 'nx-helm-'));
31
+ const temporaryChartDirectory = (0, node_path_1.join)(temporaryDirectory, chartDirectoryName);
32
+ try {
33
+ runHelmCreate(temporaryChartDirectory, options.starter);
34
+ copyGeneratedChartToTree(tree, temporaryChartDirectory, projectRoot);
35
+ }
36
+ finally {
37
+ (0, node_fs_1.rmSync)(temporaryDirectory, { recursive: true, force: true });
38
+ }
39
+ (0, devkit_1.addProjectConfiguration)(tree, projectName, {
40
+ root: projectRoot,
41
+ projectType: 'application',
42
+ tags: ['scope:workspace', 'layer:infra', 'runtime:helm'],
43
+ });
44
+ });
45
+ }
46
+ /**
47
+ * Runs Helm's documented chart scaffolder without invoking a shell.
48
+ * @param chartDirectory Temporary chart output directory.
49
+ * @param starter Optional Helm starter name or absolute path.
50
+ */
51
+ function runHelmCreate(chartDirectory, starter) {
52
+ const arguments_ = ['create', chartDirectory];
53
+ if (starter === null || starter === void 0 ? void 0 : starter.trim()) {
54
+ arguments_.push('--starter', starter.trim());
55
+ }
56
+ try {
57
+ // Helm is intentionally resolved from the user's PATH.
58
+ // eslint-disable-next-line sonarjs/no-os-command-from-path
59
+ (0, node_child_process_1.execFileSync)('helm', arguments_, {
60
+ encoding: 'utf8',
61
+ stdio: 'pipe',
62
+ });
63
+ }
64
+ catch (error) {
65
+ const processError = new Error(`[nx-helm] helm create failed: ${getProcessErrorMessage(error)}`);
66
+ Object.defineProperty(processError, 'cause', { value: error });
67
+ throw processError;
68
+ }
69
+ }
70
+ /**
71
+ * Imports Helm's generated chart files into the Nx virtual tree.
72
+ * @param tree Workspace tree to update.
73
+ * @param sourceDirectory Temporary Helm chart directory.
74
+ * @param targetDirectory Workspace-relative chart project root.
75
+ */
76
+ function copyGeneratedChartToTree(tree, sourceDirectory, targetDirectory) {
77
+ for (const entry of (0, node_fs_1.readdirSync)(sourceDirectory, { withFileTypes: true })) {
78
+ const sourcePath = (0, node_path_1.join)(sourceDirectory, entry.name);
79
+ const targetPath = (0, devkit_1.joinPathFragments)(targetDirectory, entry.name);
80
+ if (entry.isDirectory()) {
81
+ copyGeneratedChartToTree(tree, sourcePath, targetPath);
82
+ continue;
83
+ }
84
+ if (entry.isFile()) {
85
+ tree.write(targetPath, (0, node_fs_1.readFileSync)(sourcePath));
86
+ }
87
+ }
88
+ }
89
+ /**
90
+ * Converts a Helm process failure into actionable generator output.
91
+ * @param error Process failure from execFileSync.
92
+ * @returns Standard error text or the caught error message.
93
+ */
94
+ function getProcessErrorMessage(error) {
95
+ if (error instanceof Error && 'stderr' in error) {
96
+ const stderr = error.stderr;
97
+ if (typeof stderr === 'string' && stderr.trim()) {
98
+ return stderr.trim();
99
+ }
100
+ if (Buffer.isBuffer(stderr) && stderr.length > 0) {
101
+ return stderr.toString('utf8').trim();
102
+ }
103
+ }
104
+ return error instanceof Error ? error.message : String(error);
105
+ }
106
+ //# sourceMappingURL=chart.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chart.js","sourceRoot":"","sources":["../../../../../../../plugins/nx/helm/src/generators/chart/chart.ts"],"names":[],"mappings":";;AAsBA,iCAkCC;;AAxDD,uCAKoB;AACpB,2DAAkD;AAClD,qCAAyE;AACzE,yCAAiC;AACjC,q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E,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;YACxB,wBAAwB,CAAC,IAAI,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;YACvD,SAAS;QACX,CAAC;QAED,IAAI,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC;YACnB,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,IAAA,sBAAY,EAAC,UAAU,CAAC,CAAC,CAAC;QACnD,CAAC;IACH,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,SAAS,sBAAsB,CAAC,KAAc;IAC5C,IAAI,KAAK,YAAY,KAAK,IAAI,QAAQ,IAAI,KAAK,EAAE,CAAC;QAChD,MAAM,MAAM,GAAI,KAA8B,CAAC,MAAM,CAAC;QACtD,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC;YAChD,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC;QACvB,CAAC;QACD,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACjD,OAAO,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC;QACxC,CAAC;IACH,CAAC;IAED,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAChE,CAAC"}
@@ -0,0 +1,11 @@
1
+ /** Options accepted by the standalone Helm chart generator. */
2
+ export interface ChartGeneratorSchema {
3
+ /** Chart directory name and default 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
+ }
@@ -0,0 +1,36 @@
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 default 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": "Explicit Nx project name. Defaults to helm-<name>.",
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
+ },
34
+ "required": ["name"],
35
+ "additionalProperties": false
36
+ }
@@ -0,0 +1,9 @@
1
+ import { type Tree } from '@nx/devkit';
2
+ import type { InitGeneratorSchema } from './schema';
3
+ /**
4
+ * Registers `@otwld/nx-helm` and fills missing shared 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>;
@@ -0,0 +1,136 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = initGenerator;
4
+ const tslib_1 = require("tslib");
5
+ const devkit_1 = require("@nx/devkit");
6
+ const pluginName = '@otwld/nx-helm';
7
+ const defaultValidateTargetName = 'helm:validate';
8
+ const defaultPackageTargetName = 'helm:package';
9
+ const defaultKubeVersion = '1.32.0';
10
+ const defaultRegistry = 'oci://harbor.otwld.com/monorepo-starter';
11
+ /**
12
+ * Registers `@otwld/nx-helm` and fills missing shared target defaults.
13
+ * @param tree Workspace tree to update.
14
+ * @param options Init options supplied by Nx.
15
+ * @returns A promise that resolves after optional formatting.
16
+ */
17
+ function initGenerator(tree, options) {
18
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
19
+ var _a, _b;
20
+ if (!tree.exists('nx.json')) {
21
+ devkit_1.logger.warn('[nx-helm] nx.json was not found; plugin registration was skipped.');
22
+ return;
23
+ }
24
+ const nxJson = (_a = (0, devkit_1.readNxJson)(tree)) !== null && _a !== void 0 ? _a : {};
25
+ const existingPlugin = findPlugin(nxJson.plugins);
26
+ const pluginOptions = existingPlugin
27
+ ? readPluginOptions(existingPlugin)
28
+ : createPluginOptions(options);
29
+ if (!existingPlugin) {
30
+ nxJson.plugins = [
31
+ ...((_b = nxJson.plugins) !== null && _b !== void 0 ? _b : []),
32
+ {
33
+ plugin: pluginName,
34
+ options: pluginOptions,
35
+ },
36
+ ];
37
+ devkit_1.logger.info(`[nx-helm] Added ${pluginName} to nx.json.`);
38
+ }
39
+ addTargetDefaults(nxJson, pluginOptions);
40
+ (0, devkit_1.updateNxJson)(tree, nxJson);
41
+ if (!options.skipFormat) {
42
+ yield (0, devkit_1.formatFiles)(tree);
43
+ }
44
+ });
45
+ }
46
+ /**
47
+ * Finds an existing string or object plugin registration.
48
+ * @param plugins Nx plugin registrations.
49
+ * @returns Existing Helm registration, or undefined.
50
+ */
51
+ function findPlugin(plugins) {
52
+ return plugins === null || plugins === void 0 ? void 0 : plugins.find((plugin) => typeof plugin === 'string'
53
+ ? plugin === pluginName
54
+ : (plugin === null || plugin === void 0 ? void 0 : plugin.plugin) === pluginName);
55
+ }
56
+ /**
57
+ * Builds default plugin options for a new registration.
58
+ * @param options Init generator options.
59
+ * @returns Plugin options written to nx.json.
60
+ */
61
+ function createPluginOptions(options) {
62
+ var _a, _b, _c, _d, _e;
63
+ const validateTargetName = ((_a = options.validateTargetName) === null || _a === void 0 ? void 0 : _a.trim()) || defaultValidateTargetName;
64
+ const packageTargetName = ((_b = options.packageTargetName) === null || _b === void 0 ? void 0 : _b.trim()) || defaultPackageTargetName;
65
+ return {
66
+ validateTarget: {
67
+ name: validateTargetName,
68
+ kubeVersion: ((_c = options.kubeVersion) === null || _c === void 0 ? void 0 : _c.trim()) || defaultKubeVersion,
69
+ strict: (_d = options.strict) !== null && _d !== void 0 ? _d : false,
70
+ },
71
+ packageTarget: {
72
+ name: packageTargetName,
73
+ },
74
+ registry: ((_e = options.registry) === null || _e === void 0 ? void 0 : _e.trim()) || defaultRegistry,
75
+ };
76
+ }
77
+ /**
78
+ * Reads target names from an existing object registration without changing it.
79
+ * @param plugin Existing Helm registration.
80
+ * @returns Existing plugin options or empty options for default resolution.
81
+ */
82
+ function readPluginOptions(plugin) {
83
+ if (typeof plugin === 'string' || !isRecord(plugin.options)) {
84
+ return {};
85
+ }
86
+ return plugin.options;
87
+ }
88
+ /**
89
+ * Adds shared cache/input defaults only when a target has no existing default.
90
+ * @param nxJson Nx workspace configuration.
91
+ * @param pluginOptions Helm plugin options.
92
+ */
93
+ function addTargetDefaults(nxJson, pluginOptions) {
94
+ var _a, _b, _c, _d, _e;
95
+ var _f, _g;
96
+ (_a = nxJson.targetDefaults) !== null && _a !== void 0 ? _a : (nxJson.targetDefaults = {});
97
+ const validateTargetName = (_b = getNestedString(pluginOptions, 'validateTarget', 'name')) !== null && _b !== void 0 ? _b : defaultValidateTargetName;
98
+ const packageTargetName = (_c = getNestedString(pluginOptions, 'packageTarget', 'name')) !== null && _c !== void 0 ? _c : defaultPackageTargetName;
99
+ (_d = (_f = nxJson.targetDefaults)[validateTargetName]) !== null && _d !== void 0 ? _d : (_f[validateTargetName] = {
100
+ cache: true,
101
+ inputs: helmInputs,
102
+ });
103
+ (_e = (_g = nxJson.targetDefaults)[packageTargetName]) !== null && _e !== void 0 ? _e : (_g[packageTargetName] = {
104
+ cache: true,
105
+ dependsOn: [validateTargetName],
106
+ inputs: helmInputs,
107
+ });
108
+ }
109
+ const helmInputs = [
110
+ '{projectRoot}/**/*',
111
+ { runtime: "helm version --template '{{.Version}}'" },
112
+ ];
113
+ /**
114
+ * Reads a nested string option from an unknown plugin options object.
115
+ * @param options Plugin options.
116
+ * @param parent Parent property name.
117
+ * @param property Nested property name.
118
+ * @returns Non-empty nested string, or undefined.
119
+ */
120
+ function getNestedString(options, parent, property) {
121
+ const parentValue = options[parent];
122
+ if (!isRecord(parentValue)) {
123
+ return undefined;
124
+ }
125
+ const value = parentValue[property];
126
+ return typeof value === 'string' && value.trim() ? value.trim() : undefined;
127
+ }
128
+ /**
129
+ * Narrows unknown values to object records used by init configuration parsing.
130
+ * @param value Value to inspect.
131
+ * @returns Whether value is a non-null object record.
132
+ */
133
+ function isRecord(value) {
134
+ return typeof value === 'object' && value !== null;
135
+ }
136
+ //# sourceMappingURL=init.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.js","sourceRoot":"","sources":["../../../../../../../plugins/nx/helm/src/generators/init/init.ts"],"names":[],"mappings":";;AAuBA,gCAkCC;;AAzDD,uCAOoB;AAIpB,MAAM,UAAU,GAAG,gBAAgB,CAAC;AACpC,MAAM,yBAAyB,GAAG,eAAe,CAAC;AAClD,MAAM,wBAAwB,GAAG,cAAc,CAAC;AAChD,MAAM,kBAAkB,GAAG,QAAQ,CAAC;AACpC,MAAM,eAAe,GAAG,yCAAyC,CAAC;AAElE;;;;;GAKG;AACH,SAA8B,aAAa,CACzC,IAAU,EACV,OAA4B;;;QAE5B,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC;YAC5B,eAAM,CAAC,IAAI,CACT,mEAAmE,CACpE,CAAC;YACF,OAAO;QACT,CAAC;QAED,MAAM,MAAM,GAAG,MAAA,IAAA,mBAAU,EAAC,IAAI,CAAC,mCAAI,EAAE,CAAC;QACtC,MAAM,cAAc,GAAG,UAAU,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAClD,MAAM,aAAa,GAAG,cAAc;YAClC,CAAC,CAAC,iBAAiB,CAAC,cAAc,CAAC;YACnC,CAAC,CAAC,mBAAmB,CA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,MAAc,EACd,QAAgB;IAEhB,MAAM,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACpC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;QAC3B,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,KAAK,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC;IACpC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AAC9E,CAAC;AAED;;;;GAIG;AACH,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC;AACrD,CAAC"}
@@ -0,0 +1,15 @@
1
+ /** Options accepted by the `@otwld/nx-helm` init generator. */
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
+ /** Skip Prettier formatting after nx.json is updated. */
14
+ skipFormat?: boolean;
15
+ }
@@ -0,0 +1,41 @@
1
+ {
2
+ "$schema": "https://json-schema.org/schema",
3
+ "$id": "NxHelmInitSchema",
4
+ "title": "Nx Helm init generator",
5
+ "description": "Register @otwld/nx-helm and its inferred-task defaults in nx.json.",
6
+ "type": "object",
7
+ "properties": {
8
+ "registry": {
9
+ "type": "string",
10
+ "description": "OCI repository used by inferred release publishing.",
11
+ "pattern": "^oci://",
12
+ "default": "oci://harbor.otwld.com/monorepo-starter"
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
+ "skipFormat": {
35
+ "type": "boolean",
36
+ "description": "Skip Prettier formatting after nx.json is updated.",
37
+ "default": false
38
+ }
39
+ },
40
+ "additionalProperties": false
41
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ /** Public inferred-task, generator, and release exports for the Helm package. */
2
+ export { createNodes, type HelmPackageTargetOptions, type HelmPluginOptions, type HelmValidateTargetOptions, } from './plugins/plugin';
3
+ export { default as chartGenerator } from './generators/chart/chart';
4
+ export type { ChartGeneratorSchema } from './generators/chart/schema';
package/src/index.js ADDED
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.chartGenerator = exports.createNodes = void 0;
4
+ const tslib_1 = require("tslib");
5
+ /** Public inferred-task, generator, and release exports for the Helm package. */
6
+ var plugin_1 = require("./plugins/plugin");
7
+ Object.defineProperty(exports, "createNodes", { enumerable: true, get: function () { return plugin_1.createNodes; } });
8
+ var chart_1 = require("./generators/chart/chart");
9
+ Object.defineProperty(exports, "chartGenerator", { enumerable: true, get: function () { return tslib_1.__importDefault(chart_1).default; } });
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../plugins/nx/helm/src/index.ts"],"names":[],"mappings":";;;;AAAA,iFAAiF;AACjF,2CAK0B;AAJxB,qGAAA,WAAW,OAAA;AAKb,kDAAqE;AAA5D,gIAAA,OAAO,OAAkB"}
@@ -0,0 +1,34 @@
1
+ import { type CreateNodes } from '@nx/devkit';
2
+ /** Options for the inferred Helm validation target. */
3
+ export interface HelmValidateTargetOptions {
4
+ /** Target name used for Helm lint and template. */
5
+ name?: string;
6
+ /** Kubernetes version passed to helm template. */
7
+ kubeVersion?: string;
8
+ /** Whether helm lint should fail on warnings. */
9
+ strict?: boolean;
10
+ /** Workspace-wide Helm release name override. */
11
+ releaseName?: string;
12
+ /** Values files passed to helm lint and helm template. */
13
+ valuesFiles?: string[];
14
+ }
15
+ /** Options for the inferred Helm packaging target. */
16
+ export interface HelmPackageTargetOptions {
17
+ /** Target name used for Helm packaging. */
18
+ name?: string;
19
+ }
20
+ /** Workspace options for the Helm inferred-target plugin. */
21
+ export interface HelmPluginOptions {
22
+ /** Configuration for the inferred validation target. */
23
+ validateTarget?: HelmValidateTargetOptions;
24
+ /** Configuration for the inferred packaging target. */
25
+ packageTarget?: HelmPackageTargetOptions;
26
+ /** OCI repository used by the inferred Nx Release publish target. */
27
+ registry?: string;
28
+ }
29
+ /**
30
+ * Infers Helm targets for standalone projects whose root contains Chart.yaml.
31
+ * A sibling project.json is required so nested charts and app-owned chart
32
+ * directories remain outside the Helm project graph.
33
+ */
34
+ export declare const createNodes: CreateNodes<HelmPluginOptions>;