@storm-software/k8s-tools
Version:
Tools for managing Kubernetes (k8s) infrastructure within a Nx workspace.
70 lines (67 loc) • 1.72 kB
JavaScript
import {
withRunGenerator
} from "./chunk-C2QUOGWD.mjs";
import {
writeDebug
} from "./chunk-XLWMBELQ.mjs";
import {
__dirname
} from "./chunk-RSHYWSQP.mjs";
// src/generators/helm-chart/generator.ts
import {
formatFiles,
generateFiles,
readProjectConfiguration,
updateProjectConfiguration
} from "@nx/devkit";
import { join } from "path";
async function helmChartGeneratorFn(tree, options, config) {
writeDebug("\u{1F4DD} Preparing to write Helm Chart", config);
const project = readProjectConfiguration(tree, options.project);
if (project.targets?.["helm-package"]) {
throw new Error(
`Project ${options.project} already has a helm target. Please remove it before running this command.`
);
}
updateProjectConfiguration(tree, options.project, {
...project,
targets: {
...project.targets,
"helm-package": {
executor: "@storm-software/k8s-tools:helm-package",
outputs: ["{options.outputFolder}"],
options: {
chartFolder: `${project.root}/${options.chartFolder}`,
outputFolder: "{workspaceRoot}/dist/charts/{projectRoot}",
push: false,
remote: "oci://localhost:5000/helm-charts",
dependencies: {
update: true,
build: true,
repositories: []
}
}
}
}
});
generateFiles(
tree,
join(__dirname, "files", "chart"),
join(project.root, options.chartFolder ?? ""),
options
);
if (options.format) {
await formatFiles(tree);
}
return {
success: true
};
}
var generator_default = withRunGenerator(
"Helm Chart",
helmChartGeneratorFn
);
export {
helmChartGeneratorFn,
generator_default
};