@otwld/nx-argo 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.
package/README.md ADDED
@@ -0,0 +1,78 @@
1
+ # @otwld/nx-argo
2
+
3
+ An explicit Nx generator for CI-driven Argo CD Applications. This package does
4
+ not register an Nx plugin, inspect the project graph, or impose a workspace
5
+ directory layout.
6
+
7
+ ## Generate an Application
8
+
9
+ Pass the complete deployment context and choose any workspace-relative output
10
+ directory:
11
+
12
+ ```shell
13
+ pnpm exec nx g @otwld/nx-argo:application \
14
+ --directory=gitops/applications/backend/development \
15
+ --name=backend-development \
16
+ --chart=backend \
17
+ --chartRepository=oci://harbor.otwld.com/monorepo-starter \
18
+ --chartVersion=0.1.0 \
19
+ --valuesRepoUrl=https://github.com/otwld/monorepo-starter.git \
20
+ --valuesRevision=main \
21
+ --project=default \
22
+ --destinationServer=https://kubernetes.default.svc \
23
+ --namespace=backend-development
24
+ ```
25
+
26
+ The generator writes exactly two files:
27
+
28
+ ```text
29
+ gitops/applications/backend/development/
30
+ ├── application.yaml
31
+ └── values.yaml
32
+ ```
33
+
34
+ `application.yaml` always uses Argo CD's multi-source Helm pattern:
35
+
36
+ ```yaml
37
+ spec:
38
+ sources:
39
+ - repoURL: harbor.otwld.com/monorepo-starter
40
+ chart: backend
41
+ targetRevision: 0.1.0
42
+ helm:
43
+ releaseName: backend
44
+ valueFiles:
45
+ - $values/gitops/applications/backend/development/values.yaml
46
+ - repoURL: https://github.com/otwld/monorepo-starter.git
47
+ targetRevision: main
48
+ ref: values
49
+ ```
50
+
51
+ The generated values file is the environment override layer; the chart's
52
+ packaged `values.yaml` remains the default layer. The values repository must use
53
+ HTTPS. The chart source accepts standard HTTP(S) Helm repositories and OCI
54
+ registries; `oci://` is removed from OCI chart-source URLs for Argo CD.
55
+
56
+ No sync policy is generated. Prune, self-heal, and other deployment governance
57
+ belong to the target environment rather than an organization-wide generator
58
+ default.
59
+
60
+ ## Plugin Targets
61
+
62
+ - `nx build nx-argo` builds the generator package.
63
+ - `nx lint nx-argo` runs ESLint through the workspace ESLint plugin.
64
+ - `nx test nx-argo` runs focused generator tests with Vitest.
65
+
66
+ ## npm Release
67
+
68
+ `@otwld/nx-argo` is an independently versioned member of Nx's `npm` release
69
+ group. Nx derives its version from Conventional Commits, builds the package
70
+ before versioning, and publishes `dist/plugins/nx/argo`.
71
+
72
+ ```shell
73
+ pnpm exec nx release version --groups=npm --first-release --dry-run
74
+ pnpm exec nx release publish --groups=npm --first-release --dry-run --access=public
75
+ ```
76
+
77
+ Release tags use `npm/{projectName}/{version}`. Authenticate npm before a real
78
+ release with `pnpm exec nx release --groups=npm --first-release`.
@@ -0,0 +1,10 @@
1
+ {
2
+ "$schema": "https://json-schema.org/schema",
3
+ "generators": {
4
+ "application": {
5
+ "factory": "./src/generators/application/application",
6
+ "schema": "./src/generators/application/schema.json",
7
+ "description": "Create an Argo CD Application and its Helm values file."
8
+ }
9
+ }
10
+ }
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "@otwld/nx-argo",
3
+ "version": "0.0.2",
4
+ "private": false,
5
+ "type": "commonjs",
6
+ "exports": {
7
+ ".": {
8
+ "@nx/nx-source": "./src/index.ts",
9
+ "types": "./src/index.d.ts",
10
+ "default": "./src/index.js"
11
+ },
12
+ "./package.json": "./package.json",
13
+ "./generators.json": "./generators.json"
14
+ },
15
+ "main": "./src/index.js",
16
+ "types": "./src/index.d.ts",
17
+ "dependencies": {
18
+ "@nx/devkit": "23.1.1",
19
+ "semver": "^7.8.5",
20
+ "tslib": "^2.3.0",
21
+ "yaml": "^2.9.0"
22
+ },
23
+ "peerDependencies": {
24
+ "nx": ">=22 <=24 || ^23.0.0-0"
25
+ },
26
+ "publishConfig": {
27
+ "access": "public"
28
+ },
29
+ "generators": "./generators.json"
30
+ }
@@ -0,0 +1,9 @@
1
+ import { type Tree } from '@nx/devkit';
2
+ import type { ApplicationGeneratorSchema } from './schema';
3
+ /**
4
+ * Creates a multi-source Argo CD Application and its Helm values file.
5
+ * @param tree Workspace tree to update.
6
+ * @param options Generator options supplied by Nx.
7
+ * @returns A promise that resolves after optional formatting.
8
+ */
9
+ export default function applicationGenerator(tree: Tree, options: ApplicationGeneratorSchema): Promise<void>;
@@ -0,0 +1,268 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = applicationGenerator;
4
+ const tslib_1 = require("tslib");
5
+ const devkit_1 = require("@nx/devkit");
6
+ const node_path_1 = require("node:path");
7
+ const semver_1 = require("semver");
8
+ const yaml_1 = require("yaml");
9
+ const applicationApiVersion = 'argoproj.io/v1alpha1';
10
+ const defaultArgoNamespace = 'argocd';
11
+ const valuesFileName = 'values.yaml';
12
+ const valuesSourceRef = 'values';
13
+ /**
14
+ * Creates a multi-source Argo CD Application and its Helm values file.
15
+ * @param tree Workspace tree to update.
16
+ * @param options Generator options supplied by Nx.
17
+ * @returns A promise that resolves after optional formatting.
18
+ */
19
+ function applicationGenerator(tree, options) {
20
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
21
+ const input = resolveInput(options);
22
+ const applicationFile = (0, devkit_1.joinPathFragments)(input.directory, 'application.yaml');
23
+ const valuesFile = (0, devkit_1.joinPathFragments)(input.directory, valuesFileName);
24
+ if (tree.exists(applicationFile) || tree.exists(valuesFile)) {
25
+ throw new Error(`[nx-argo] An Application already exists at ${input.directory}.`);
26
+ }
27
+ tree.write(applicationFile, createApplicationYaml(input));
28
+ tree.write(valuesFile, createValuesYaml(input.applicationName));
29
+ if (!options.skipFormat) {
30
+ yield (0, devkit_1.formatFiles)(tree);
31
+ }
32
+ });
33
+ }
34
+ /**
35
+ * Resolves and validates all generator inputs without reading workspace config.
36
+ * @param options Generator options supplied by Nx.
37
+ * @returns Normalized Application input.
38
+ */
39
+ function resolveInput(options) {
40
+ var _a, _b;
41
+ const applicationName = getRequiredName(options.name, 'application name');
42
+ const chartName = (0, devkit_1.names)(((_a = options.chart) === null || _a === void 0 ? void 0 : _a.trim()) || applicationName).fileName;
43
+ const directory = normalizeDirectory(options.directory);
44
+ const project = getRequiredString(options.project, 'Argo CD project');
45
+ const destinationServer = getRequiredString(options.destinationServer, 'destination server');
46
+ const namespace = getKubernetesName(options.namespace, 'namespace');
47
+ const chartVersion = getSemver(options.chartVersion);
48
+ const valuesRepoUrl = getValuesRepositoryUrl(options.valuesRepoUrl);
49
+ const valuesRevision = getRequiredString(options.valuesRevision, 'values repository revision');
50
+ const chartRepository = getChartRepositoryUrl(options.chartRepository);
51
+ const argocdNamespace = ((_b = options.argocdNamespace) === null || _b === void 0 ? void 0 : _b.trim()) || defaultArgoNamespace;
52
+ const valuesPath = (0, devkit_1.joinPathFragments)(directory, valuesFileName);
53
+ return {
54
+ applicationName,
55
+ argocdNamespace,
56
+ chartName,
57
+ chartRepository,
58
+ chartVersion,
59
+ destinationServer,
60
+ directory,
61
+ namespace,
62
+ project,
63
+ valuesPath,
64
+ valuesRepoUrl,
65
+ valuesRevision,
66
+ };
67
+ }
68
+ /**
69
+ * Renders a Helm chart source and a Git values source in one Application.
70
+ * @param input Resolved Application source values.
71
+ * @returns YAML Application manifest contents.
72
+ */
73
+ function createApplicationYaml(input) {
74
+ const manifest = {
75
+ apiVersion: applicationApiVersion,
76
+ kind: 'Application',
77
+ metadata: {
78
+ name: input.applicationName,
79
+ namespace: input.argocdNamespace,
80
+ },
81
+ spec: {
82
+ project: input.project,
83
+ sources: [
84
+ {
85
+ repoURL: input.chartRepository,
86
+ chart: input.chartName,
87
+ targetRevision: input.chartVersion,
88
+ helm: {
89
+ releaseName: input.chartName,
90
+ valueFiles: [`$${valuesSourceRef}/${input.valuesPath}`],
91
+ },
92
+ },
93
+ {
94
+ repoURL: input.valuesRepoUrl,
95
+ targetRevision: input.valuesRevision,
96
+ ref: valuesSourceRef,
97
+ },
98
+ ],
99
+ destination: {
100
+ server: input.destinationServer,
101
+ namespace: input.namespace,
102
+ },
103
+ },
104
+ };
105
+ return `# Generated by @otwld/nx-argo.\n${(0, yaml_1.stringify)(manifest, { lineWidth: 0 })}`;
106
+ }
107
+ /**
108
+ * Creates the initial environment-specific values document.
109
+ * @param applicationName Application name used in the comment.
110
+ * @returns Initial values.yaml contents.
111
+ */
112
+ function createValuesYaml(applicationName) {
113
+ return `# Environment-specific Helm overrides for ${applicationName}.\n{}\n`;
114
+ }
115
+ /**
116
+ * Requires a non-empty application name and normalizes it for Kubernetes.
117
+ * @param value Raw name.
118
+ * @param label Human-readable input label.
119
+ * @returns Normalized name.
120
+ */
121
+ function getRequiredName(value, label) {
122
+ const normalizedName = (0, devkit_1.names)((value === null || value === void 0 ? void 0 : value.trim()) || '').fileName;
123
+ if (!normalizedName) {
124
+ throw new Error(`[nx-argo] A ${label} is required.`);
125
+ }
126
+ return normalizedName;
127
+ }
128
+ /**
129
+ * Requires a non-empty string input.
130
+ * @param value Raw input.
131
+ * @param label Human-readable input label.
132
+ * @returns Trimmed input.
133
+ */
134
+ function getRequiredString(value, label) {
135
+ const normalizedValue = value === null || value === void 0 ? void 0 : value.trim();
136
+ if (!normalizedValue) {
137
+ throw new Error(`[nx-argo] A ${label} is required.`);
138
+ }
139
+ return normalizedValue;
140
+ }
141
+ /**
142
+ * Validates an exact semantic version for chart promotion.
143
+ * @param version Raw chart version.
144
+ * @returns Valid semantic version.
145
+ */
146
+ function getSemver(version) {
147
+ const normalizedVersion = getRequiredString(version, 'chart version');
148
+ const parsedVersion = (0, semver_1.valid)(normalizedVersion);
149
+ if (!parsedVersion || parsedVersion !== normalizedVersion) {
150
+ throw new Error(`[nx-argo] Chart version must be an exact semantic version: ${version}`);
151
+ }
152
+ return normalizedVersion;
153
+ }
154
+ /**
155
+ * Normalizes a workspace-relative output directory.
156
+ * @param directory Raw output directory.
157
+ * @returns POSIX workspace-relative directory.
158
+ */
159
+ function normalizeDirectory(directory) {
160
+ const normalizedDirectory = trimTrailingSlashes(getRequiredString(directory, 'output directory')
161
+ .split('\\')
162
+ .join('/')
163
+ .replace(/^\.\//, ''));
164
+ if ((0, node_path_1.isAbsolute)(normalizedDirectory) ||
165
+ normalizedDirectory === '..' ||
166
+ normalizedDirectory.startsWith('../') ||
167
+ normalizedDirectory.split('/').includes('..')) {
168
+ throw new Error(`[nx-argo] Output directory must be workspace-relative: ${directory}`);
169
+ }
170
+ return normalizedDirectory;
171
+ }
172
+ /**
173
+ * Validates a Kubernetes DNS label.
174
+ * @param value Raw Kubernetes name.
175
+ * @param label Human-readable input label.
176
+ * @returns Valid Kubernetes name.
177
+ */
178
+ function getKubernetesName(value, label) {
179
+ const normalizedName = getRequiredString(value, label);
180
+ if (!isKubernetesName(normalizedName)) {
181
+ throw new Error(`[nx-argo] ${label} is not a valid Kubernetes name: ${value}`);
182
+ }
183
+ return normalizedName;
184
+ }
185
+ /**
186
+ * Converts a Helm repository input into Argo's Helm chart source syntax.
187
+ * @param repositoryUrl Helm repository or OCI registry URL.
188
+ * @returns Argo-compatible repository URL.
189
+ */
190
+ function getChartRepositoryUrl(repositoryUrl) {
191
+ const normalizedUrl = trimTrailingSlashes(getRequiredString(repositoryUrl, 'chart repository URL'));
192
+ if (normalizedUrl.toLowerCase().startsWith('oci://')) {
193
+ return normalizedUrl.slice('oci://'.length);
194
+ }
195
+ if (hasHttpScheme(normalizedUrl)) {
196
+ return normalizedUrl;
197
+ }
198
+ if (normalizedUrl.includes('://')) {
199
+ throw new Error(`[nx-argo] Unsupported chart repository URL scheme: ${repositoryUrl}`);
200
+ }
201
+ return normalizedUrl;
202
+ }
203
+ /**
204
+ * Requires an HTTPS Git repository for environment values.
205
+ * @param repositoryUrl Git values repository URL.
206
+ * @returns Normalized HTTPS repository URL.
207
+ */
208
+ function getValuesRepositoryUrl(repositoryUrl) {
209
+ const normalizedUrl = trimTrailingSlashes(getRequiredString(repositoryUrl, 'values repository URL'));
210
+ if (!normalizedUrl.toLowerCase().startsWith('https://')) {
211
+ throw new Error('[nx-argo] Values repository URL must use https://.');
212
+ }
213
+ return normalizedUrl;
214
+ }
215
+ /**
216
+ * Checks whether a repository URL uses HTTP or HTTPS.
217
+ * @param value Repository URL to inspect.
218
+ * @returns Whether the URL starts with an HTTP scheme.
219
+ */
220
+ function hasHttpScheme(value) {
221
+ const normalizedValue = value.toLowerCase();
222
+ return (normalizedValue.startsWith('http://') ||
223
+ normalizedValue.startsWith('https://'));
224
+ }
225
+ /**
226
+ * Checks the DNS label shape required for Kubernetes names.
227
+ * @param value Name to inspect.
228
+ * @returns Whether the value is a lowercase Kubernetes DNS label.
229
+ */
230
+ function isKubernetesName(value) {
231
+ if (!value || value.length > 63) {
232
+ return false;
233
+ }
234
+ if (!isLowercaseAlphaNumeric(value[0]) ||
235
+ !isLowercaseAlphaNumeric(value[value.length - 1])) {
236
+ return false;
237
+ }
238
+ for (const character of value) {
239
+ if (!isLowercaseAlphaNumeric(character) && character !== '-') {
240
+ return false;
241
+ }
242
+ }
243
+ return true;
244
+ }
245
+ /**
246
+ * Checks one lowercase ASCII alphanumeric character.
247
+ * @param character Character to inspect.
248
+ * @returns Whether the character is valid in a Kubernetes name boundary.
249
+ */
250
+ function isLowercaseAlphaNumeric(character) {
251
+ return (typeof character === 'string' &&
252
+ character.length === 1 &&
253
+ ((character >= 'a' && character <= 'z') ||
254
+ (character >= '0' && character <= '9')));
255
+ }
256
+ /**
257
+ * Removes path separators from the end of a normalized path.
258
+ * @param value Path value to normalize.
259
+ * @returns Path without trailing separators.
260
+ */
261
+ function trimTrailingSlashes(value) {
262
+ let end = value.length;
263
+ while (end > 0 && value[end - 1] === '/') {
264
+ end -= 1;
265
+ }
266
+ return value.slice(0, end);
267
+ }
268
+ //# sourceMappingURL=application.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"application.js","sourceRoot":"","sources":["../../../../../../../plugins/nx/argo/src/generators/application/application.ts"],"names":[],"mappings":";;AAkBA,uCAuBC;;AAzCD,uCAA8E;AAC9E,yCAAuC;AACvC,mCAA+B;AAC/B,+BAAiC;AAIjC,MAAM,qBAA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AAE,CAAC;QAChC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IACE,CAAC,uBAAuB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAClC,CAAC,uBAAuB,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,EACjD,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,KAAK,MAAM,SAAS,IAAI,KAAK,EAAE,CAAC;QAC9B,IAAI,CAAC,uBAAuB,CAAC,SAAS,CAAC,IAAI,SAAS,KAAK,GAAG,EAAE,CAAC;YAC7D,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;GAIG;AACH,SAAS,uBAAuB,CAAC,SAA6B;IAC5D,OAAO,CACL,OAAO,SAAS,KAAK,QAAQ;QAC7B,SAAS,CAAC,MAAM,KAAK,CAAC;QACtB,CAAC,CAAC,SAAS,IAAI,GAAG,IAAI,SAAS,IAAI,GAAG,CAAC;YACrC,CAAC,SAAS,IAAI,GAAG,IAAI,SAAS,IAAI,GAAG,CAAC,CAAC,CAC1C,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,SAAS,mBAAmB,CAAC,KAAa;IACxC,IAAI,GAAG,GAAG,KAAK,CAAC,MAAM,CAAC;IACvB,OAAO,GAAG,GAAG,CAAC,IAAI,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;QACzC,GAAG,IAAI,CAAC,CAAC;IACX,CAAC;IAED,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AAC7B,CAAC"}
@@ -0,0 +1,27 @@
1
+ /** Options accepted by the `@otwld/nx-argo:application` generator. */
2
+ export interface ApplicationGeneratorSchema {
3
+ /** Application metadata name. */
4
+ name: string;
5
+ /** Workspace-relative output directory for both generated files. */
6
+ directory: string;
7
+ /** Helm chart name; defaults to the application name. */
8
+ chart?: string;
9
+ /** Helm repository or OCI registry URL. */
10
+ chartRepository: string;
11
+ /** Exact semantic chart version promoted by CI. */
12
+ chartVersion: string;
13
+ /** HTTPS Git repository containing the generated values file. */
14
+ valuesRepoUrl: string;
15
+ /** Git revision containing the generated values file. */
16
+ valuesRevision: string;
17
+ /** Argo CD AppProject name. */
18
+ project: string;
19
+ /** Kubernetes API server URL. */
20
+ destinationServer: string;
21
+ /** Kubernetes namespace for the deployed chart. */
22
+ namespace: string;
23
+ /** Namespace where the Argo CD Application is created. */
24
+ argocdNamespace?: string;
25
+ /** Skip Prettier formatting after generation. */
26
+ skipFormat?: boolean;
27
+ }
@@ -0,0 +1,97 @@
1
+ {
2
+ "$schema": "https://json-schema.org/schema",
3
+ "$id": "NxArgoApplicationGeneratorSchema",
4
+ "title": "Argo CD Application generator",
5
+ "description": "Create a multi-source Argo CD Application and its Helm values file.",
6
+ "type": "object",
7
+ "properties": {
8
+ "name": {
9
+ "type": "string",
10
+ "description": "Application metadata name.",
11
+ "pattern": "^[a-z0-9][a-z0-9-]*[a-z0-9]$|^[a-z0-9]$",
12
+ "$default": {
13
+ "$source": "argv",
14
+ "index": 0
15
+ },
16
+ "x-prompt": "What is the Application name?",
17
+ "x-priority": "important"
18
+ },
19
+ "directory": {
20
+ "type": "string",
21
+ "description": "Workspace-relative output directory for application.yaml and values.yaml.",
22
+ "x-prompt": "Where should the Application files be generated?",
23
+ "x-priority": "important"
24
+ },
25
+ "chart": {
26
+ "type": "string",
27
+ "description": "Helm chart name. Defaults to the Application name.",
28
+ "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]*$"
29
+ },
30
+ "chartRepository": {
31
+ "type": "string",
32
+ "description": "HTTP(S) Helm repository or OCI registry URL.",
33
+ "x-prompt": "What Helm repository or OCI registry contains the chart?",
34
+ "x-priority": "important"
35
+ },
36
+ "chartVersion": {
37
+ "type": "string",
38
+ "description": "Exact semantic version promoted by CI.",
39
+ "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+(?:-[0-9A-Za-z.-]+)?(?:\\+[0-9A-Za-z.-]+)?$",
40
+ "x-prompt": "What Helm chart version should Argo CD deploy?",
41
+ "x-priority": "important"
42
+ },
43
+ "valuesRepoUrl": {
44
+ "type": "string",
45
+ "description": "HTTPS Git repository containing the generated values file.",
46
+ "pattern": "^https://",
47
+ "x-prompt": "What HTTPS Git repository contains the values file?",
48
+ "x-priority": "important"
49
+ },
50
+ "valuesRevision": {
51
+ "type": "string",
52
+ "description": "Git revision containing the generated values file.",
53
+ "x-prompt": "Which Git revision contains the values file?",
54
+ "x-priority": "important"
55
+ },
56
+ "project": {
57
+ "type": "string",
58
+ "description": "Argo CD AppProject name.",
59
+ "x-prompt": "Which Argo CD AppProject should own the Application?",
60
+ "x-priority": "important"
61
+ },
62
+ "destinationServer": {
63
+ "type": "string",
64
+ "description": "Kubernetes API server URL.",
65
+ "x-prompt": "Which Kubernetes API server should receive the Application?",
66
+ "x-priority": "important"
67
+ },
68
+ "namespace": {
69
+ "type": "string",
70
+ "description": "Kubernetes namespace for the deployed chart.",
71
+ "x-prompt": "Which Kubernetes namespace should receive the chart?",
72
+ "x-priority": "important"
73
+ },
74
+ "argocdNamespace": {
75
+ "type": "string",
76
+ "description": "Namespace where the Argo CD Application is created.",
77
+ "default": "argocd"
78
+ },
79
+ "skipFormat": {
80
+ "type": "boolean",
81
+ "description": "Skip Prettier formatting after the files are generated.",
82
+ "default": false
83
+ }
84
+ },
85
+ "required": [
86
+ "name",
87
+ "directory",
88
+ "chartRepository",
89
+ "chartVersion",
90
+ "valuesRepoUrl",
91
+ "valuesRevision",
92
+ "project",
93
+ "destinationServer",
94
+ "namespace"
95
+ ],
96
+ "additionalProperties": false
97
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ /** Public generator exports for the Argo CD package. */
2
+ export { default as applicationGenerator } from './generators/application/application';
3
+ export type { ApplicationGeneratorSchema } from './generators/application/schema';
package/src/index.js ADDED
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.applicationGenerator = void 0;
4
+ const tslib_1 = require("tslib");
5
+ /** Public generator exports for the Argo CD package. */
6
+ var application_1 = require("./generators/application/application");
7
+ Object.defineProperty(exports, "applicationGenerator", { enumerable: true, get: function () { return tslib_1.__importDefault(application_1).default; } });
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../plugins/nx/argo/src/index.ts"],"names":[],"mappings":";;;;AAAA,wDAAwD;AACxD,oEAAuF;AAA9E,4IAAA,OAAO,OAAwB"}