@camunda8/cli 4.7.0-alpha.2 → 4.7.0-alpha.4

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 (38) hide show
  1. package/README.md +1 -0
  2. package/dist/commands/deploy.d.ts.map +1 -1
  3. package/dist/commands/deploy.js +46 -7
  4. package/dist/commands/deploy.js.map +1 -1
  5. package/dist/commands/helpers/deploy-helpers.d.ts +83 -2
  6. package/dist/commands/helpers/deploy-helpers.d.ts.map +1 -1
  7. package/dist/commands/helpers/deploy-helpers.js +204 -65
  8. package/dist/commands/helpers/deploy-helpers.js.map +1 -1
  9. package/dist/commands/watch.d.ts.map +1 -1
  10. package/dist/commands/watch.js +301 -16
  11. package/dist/commands/watch.js.map +1 -1
  12. package/dist/default-plugins/cluster/README.md +3 -1
  13. package/dist/default-plugins/cluster/c8ctl-plugin.js +37 -1
  14. package/dist/utils/command-local/setup-detectors.d.ts +51 -0
  15. package/dist/utils/command-local/setup-detectors.d.ts.map +1 -0
  16. package/dist/utils/command-local/setup-detectors.js +115 -0
  17. package/dist/utils/command-local/setup-detectors.js.map +1 -0
  18. package/dist/utils/command-local/setup-prerequisites.d.ts +67 -0
  19. package/dist/utils/command-local/setup-prerequisites.d.ts.map +1 -0
  20. package/dist/utils/command-local/setup-prerequisites.js +238 -0
  21. package/dist/utils/command-local/setup-prerequisites.js.map +1 -0
  22. package/dist/utils/index.d.ts +3 -0
  23. package/dist/utils/index.d.ts.map +1 -1
  24. package/dist/utils/index.js +3 -0
  25. package/dist/utils/index.js.map +1 -1
  26. package/dist/utils/shared/camunda-json.d.ts +8 -0
  27. package/dist/utils/shared/camunda-json.d.ts.map +1 -1
  28. package/dist/utils/shared/camunda-json.js +3 -0
  29. package/dist/utils/shared/camunda-json.js.map +1 -1
  30. package/dist/utils/shared/deploy-resource-selection.d.ts +173 -0
  31. package/dist/utils/shared/deploy-resource-selection.d.ts.map +1 -0
  32. package/dist/utils/shared/deploy-resource-selection.js +476 -0
  33. package/dist/utils/shared/deploy-resource-selection.js.map +1 -0
  34. package/dist/utils/shared/ignore.d.ts +26 -0
  35. package/dist/utils/shared/ignore.d.ts.map +1 -1
  36. package/dist/utils/shared/ignore.js +6 -2
  37. package/dist/utils/shared/ignore.js.map +1 -1
  38. package/package.json +1 -1
@@ -0,0 +1,173 @@
1
+ /**
2
+ * `deployResources` — descriptor-based selection of a project's resources.
3
+ *
4
+ * The optional top-level `deployResources` array in `camunda.json` selects
5
+ * which project files are deployed (and watched with `watch --project`).
6
+ *
7
+ * Patterns use the same engine and syntax as `.c8ignore` (`parsePattern`
8
+ * from `ignore.ts`, evaluated with `node:path#matchesGlob` relative to the
9
+ * project root with `/` separators), with two deliberate differences:
10
+ *
11
+ * - **Inverted polarity.** Selection starts empty; a positive pattern
12
+ * selects, a `!` pattern deselects, and the last matching pattern wins
13
+ * per file.
14
+ * - **Direct descendant selection.** There is no gitignore "excluded
15
+ * parent" rule: a later positive pattern restores a file below an
16
+ * earlier excluded directory. The directory walk therefore never prunes
17
+ * a directory because a negative pattern matched it — it only skips a
18
+ * directory when no positive pattern can match anything below it.
19
+ *
20
+ * Defaults: `node_modules/`, `target/`, `.git/` and the project-root
21
+ * `camunda.json` are evaluated as implicit leading `!` patterns, so any
22
+ * later positive pattern that matches a file inside them overrides them.
23
+ *
24
+ * Hidden files: the engine's wildcards (`*`, `?`, `**`, `[...]`) never
25
+ * match a path segment that starts with `.`. A pattern selects a
26
+ * dot-prefixed file — or anything inside a dot-prefixed directory — only
27
+ * when it names that segment explicitly (e.g. `resources/.prompt.md`,
28
+ * `.config/**`). The walker still descends into hidden directories so
29
+ * such explicit patterns can reach them.
30
+ */
31
+ import { type CamundaProject } from "./camunda-json.ts";
32
+ /** Name of the descriptor field. */
33
+ export declare const DEPLOY_RESOURCES_FIELD = "deployResources";
34
+ /**
35
+ * Default exclusions, applied as implicit leading negations before the
36
+ * user's patterns. The root descriptor is anchored; the directories match
37
+ * at any depth (same as the `.c8ignore` defaults).
38
+ */
39
+ export declare const DEPLOY_RESOURCES_DEFAULT_EXCLUSIONS: readonly string[];
40
+ /** Tool-agnostic error codes, shared with the parity fixtures. */
41
+ export type DeployResourcesErrorCode = "invalid-config" | "empty-selection" | "read-error";
42
+ /**
43
+ * Raised for an invalid `deployResources` configuration, an empty final
44
+ * selection, or a selected path that cannot be read (`read-error`). `code` matches the `error` value used by the shared parity
45
+ * fixtures.
46
+ */
47
+ export declare class DeployResourcesError extends Error {
48
+ readonly code: DeployResourcesErrorCode;
49
+ constructor(code: DeployResourcesErrorCode, message: string);
50
+ }
51
+ /**
52
+ * Validate the raw `deployResources` value read from `camunda.json`.
53
+ *
54
+ * @param value - The raw field value (`CamundaProject.deployResources`).
55
+ * @param source - Descriptor path used in error messages.
56
+ * @returns The validated pattern list (possibly empty).
57
+ * @throws {DeployResourcesError} `invalid-config` when the value is not an
58
+ * array of valid pattern strings.
59
+ */
60
+ export declare function parseDeployResources(value: unknown, source?: string): string[];
61
+ /**
62
+ * Strictly read the `camunda.json` descriptor of a directory that is being
63
+ * resolved for deployment or watching.
64
+ *
65
+ * Unlike `readCamundaProject` (lenient marker detection), a descriptor
66
+ * that exists but cannot be read — a directory named `camunda.json`, no
67
+ * permission, an I/O error — is an `invalid-config` error. Degrading to
68
+ * "no descriptor" would silently fall back to the default scan and
69
+ * bypass a `deployResources` allowlist.
70
+ *
71
+ * @returns The parsed descriptor, or `null` only when no `camunda.json`
72
+ * exists.
73
+ * @throws {DeployResourcesError} `invalid-config` when the file exists but
74
+ * cannot be read.
75
+ * @throws {Error} When `camunda.json` is not valid JSON.
76
+ */
77
+ export declare function readProjectDescriptor(dirPath: string): CamundaProject | null;
78
+ /** Outcome of reading a project's `deployResources` configuration. */
79
+ export type DeployResourcesState = {
80
+ kind: "no-descriptor";
81
+ } | {
82
+ kind: "no-field";
83
+ } | {
84
+ kind: "patterns";
85
+ patterns: string[];
86
+ };
87
+ /**
88
+ * Read a project's `deployResources` state, distinguishing a missing
89
+ * descriptor from a descriptor without the field.
90
+ *
91
+ * @throws {DeployResourcesError} `invalid-config` when the descriptor
92
+ * cannot be read or the field is invalid.
93
+ * @throws {Error} When `camunda.json` is not valid JSON.
94
+ */
95
+ export declare function readDeployResourcesState(projectRoot: string): DeployResourcesState;
96
+ /**
97
+ * The `deployResources` state of an already-read descriptor (`null` when
98
+ * there is none), so a caller can decide from a single read.
99
+ *
100
+ * @throws {DeployResourcesError} `invalid-config` when the field is invalid.
101
+ */
102
+ export declare function deployResourcesStateOf(project: CamundaProject | null, projectRoot: string): DeployResourcesState;
103
+ /**
104
+ * Read the validated `deployResources` patterns of the project rooted at
105
+ * `projectRoot`.
106
+ *
107
+ * @returns The patterns, or `null` when there is no descriptor or the
108
+ * descriptor has no `deployResources` key (default scan applies).
109
+ * @throws {Error} When `camunda.json` is not valid JSON.
110
+ * @throws {DeployResourcesError} `invalid-config` when the descriptor
111
+ * cannot be read or the field is invalid.
112
+ */
113
+ export declare function readDeployResources(projectRoot: string): string[] | null;
114
+ /** A compiled `deployResources` pattern list. */
115
+ export interface ResourceSelector {
116
+ /** The user's patterns, in order. */
117
+ readonly patterns: readonly string[];
118
+ /** Whether the project-relative file path is selected. */
119
+ selects(relPath: string): boolean;
120
+ /**
121
+ * Whether any file below the project-relative directory could be
122
+ * selected. Conservative: `true` whenever a positive pattern might
123
+ * match below `relDir`. Used only to skip walking directories that can
124
+ * never contribute (e.g. `.git/` under `["**\/*"]`).
125
+ */
126
+ couldSelectUnder(relDir: string): boolean;
127
+ /**
128
+ * Whether the folder is excluded: a `!` pattern matches it (e.g.
129
+ * `!vendor/`, or a default exclusion) and no later positive pattern
130
+ * matches it or can reach below it. Used to skip a folder that can't be
131
+ * read only when nothing inside it can be selected.
132
+ */
133
+ excludesFolder(relDir: string): boolean;
134
+ }
135
+ /**
136
+ * Compile validated `deployResources` patterns into a selector.
137
+ * Call {@link parseDeployResources} first to validate raw input.
138
+ */
139
+ export declare function compileDeployResources(patterns: readonly string[]): ResourceSelector;
140
+ /**
141
+ * Walk `projectRoot` and return the project-relative (`/`-separated)
142
+ * paths of every file the selector selects, sorted.
143
+ *
144
+ * - Symlinks are followed (same as the default deploy discovery). A
145
+ * directory reachable under several project-relative paths (a symlink
146
+ * alias and its real path) is walked under each of them, because
147
+ * patterns are evaluated against the project-relative path. Cycles are
148
+ * cut by skipping a directory whose real path is already on the
149
+ * current descent (an active ancestor). Files that resolve to the same
150
+ * real path are kept once (first path in sorted order wins).
151
+ * - Hidden files and directories are not skipped by the walker — the
152
+ * pattern engine decides (see module docs).
153
+ * - Nested `camunda.json` folders are ordinary folders here: nested
154
+ * projects are unsupported and are not excluded from the selection.
155
+ */
156
+ export declare function selectProjectFiles(projectRoot: string, selector: ResourceSelector): string[];
157
+ /**
158
+ * The `read-error` raised when a path a `deployResources` pattern can
159
+ * select cannot be read. Names the path and, for a dangling symlink,
160
+ * says so.
161
+ */
162
+ export declare function unreadablePath(path: string, error: unknown,
163
+ /** Project-relative path, used to suggest an exclusion pattern. */
164
+ rel?: string): DeployResourcesError;
165
+ /**
166
+ * Resolve the deployed resource set of a project from its validated
167
+ * `deployResources` patterns.
168
+ *
169
+ * @throws {DeployResourcesError} `empty-selection` when nothing is
170
+ * selected (an unmatched pattern alone is silently ignored).
171
+ */
172
+ export declare function resolveDeployResources(projectRoot: string, patterns: readonly string[]): string[];
173
+ //# sourceMappingURL=deploy-resource-selection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deploy-resource-selection.d.ts","sourceRoot":"","sources":["../../../src/utils/shared/deploy-resource-selection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAWH,OAAO,EAEN,KAAK,cAAc,EAGnB,MAAM,mBAAmB,CAAC;AAO3B,oCAAoC;AACpC,eAAO,MAAM,sBAAsB,oBAAoB,CAAC;AAExD;;;;GAIG;AACH,eAAO,MAAM,mCAAmC,EAAE,SAAS,MAAM,EAKhE,CAAC;AAEF,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C1C;;;;;OAKG;IACH,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;CACxC;AAoHD;;;GAGG;AACH,wBAAgB,sBAAsB,CACrC,QAAQ,EAAE,SAAS,MAAM,EAAE,GACzB,gBAAgB,CA8ClB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,kBAAkB,CACjC,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,gBAAgB,GACxB,MAAM,EAAE,CAkEV;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAC7B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,OAAO;AACd,mEAAmE;AACnE,GAAG,CAAC,EAAE,MAAM,GACV,oBAAoB,CAsBtB;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACrC,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,SAAS,MAAM,EAAE,GACzB,MAAM,EAAE,CAaV"}
@@ -0,0 +1,476 @@
1
+ /**
2
+ * `deployResources` — descriptor-based selection of a project's resources.
3
+ *
4
+ * The optional top-level `deployResources` array in `camunda.json` selects
5
+ * which project files are deployed (and watched with `watch --project`).
6
+ *
7
+ * Patterns use the same engine and syntax as `.c8ignore` (`parsePattern`
8
+ * from `ignore.ts`, evaluated with `node:path#matchesGlob` relative to the
9
+ * project root with `/` separators), with two deliberate differences:
10
+ *
11
+ * - **Inverted polarity.** Selection starts empty; a positive pattern
12
+ * selects, a `!` pattern deselects, and the last matching pattern wins
13
+ * per file.
14
+ * - **Direct descendant selection.** There is no gitignore "excluded
15
+ * parent" rule: a later positive pattern restores a file below an
16
+ * earlier excluded directory. The directory walk therefore never prunes
17
+ * a directory because a negative pattern matched it — it only skips a
18
+ * directory when no positive pattern can match anything below it.
19
+ *
20
+ * Defaults: `node_modules/`, `target/`, `.git/` and the project-root
21
+ * `camunda.json` are evaluated as implicit leading `!` patterns, so any
22
+ * later positive pattern that matches a file inside them overrides them.
23
+ *
24
+ * Hidden files: the engine's wildcards (`*`, `?`, `**`, `[...]`) never
25
+ * match a path segment that starts with `.`. A pattern selects a
26
+ * dot-prefixed file — or anything inside a dot-prefixed directory — only
27
+ * when it names that segment explicitly (e.g. `resources/.prompt.md`,
28
+ * `.config/**`). The walker still descends into hidden directories so
29
+ * such explicit patterns can reach them.
30
+ */
31
+ import { lstatSync, readdirSync, readFileSync, realpathSync, statSync, } from "node:fs";
32
+ import { join, matchesGlob } from "node:path";
33
+ import { isRecord, normalizeToError } from "../../core/index.js";
34
+ import { CAMUNDA_PROJECT_FILE, decodeCamundaJson, parseCamundaJson, } from "./camunda-json.js";
35
+ import { matchesParsedPattern, parsePattern, } from "./ignore.js";
36
+ /** Name of the descriptor field. */
37
+ export const DEPLOY_RESOURCES_FIELD = "deployResources";
38
+ /**
39
+ * Default exclusions, applied as implicit leading negations before the
40
+ * user's patterns. The root descriptor is anchored; the directories match
41
+ * at any depth (same as the `.c8ignore` defaults).
42
+ */
43
+ export const DEPLOY_RESOURCES_DEFAULT_EXCLUSIONS = [
44
+ "node_modules/",
45
+ "target/",
46
+ ".git/",
47
+ "/camunda.json",
48
+ ];
49
+ /**
50
+ * Raised for an invalid `deployResources` configuration, an empty final
51
+ * selection, or a selected path that cannot be read (`read-error`). `code` matches the `error` value used by the shared parity
52
+ * fixtures.
53
+ */
54
+ export class DeployResourcesError extends Error {
55
+ code;
56
+ constructor(code, message) {
57
+ super(message);
58
+ this.name = "DeployResourcesError";
59
+ this.code = code;
60
+ }
61
+ }
62
+ /** Describe why a single pattern is invalid, or `null` when it is valid. */
63
+ function patternProblem(pattern) {
64
+ // Validate what the matcher sees: `parsePattern` trims trailing
65
+ // whitespace, so `resources/.. ` must be checked as `resources/..`.
66
+ const trimmed = pattern.trimEnd();
67
+ const body = trimmed.startsWith("!") ? trimmed.slice(1) : trimmed;
68
+ if (body.trim() === "") {
69
+ return "patterns must not be empty";
70
+ }
71
+ if (trimmed.startsWith("#")) {
72
+ return "comments are not supported in deployResources";
73
+ }
74
+ // A single leading `/` is the gitignore root anchor (same as .c8ignore),
75
+ // not an absolute path. Absolute paths that cannot be anchors are
76
+ // invalid: a Windows drive letter, a UNC root (`//server`, `\\server`)
77
+ // or any leading backslash.
78
+ if (/^[A-Za-z]:/.test(body) ||
79
+ body.startsWith("//") ||
80
+ body.startsWith("\\")) {
81
+ return "patterns are relative to the project root; drive-letter, UNC and backslash-rooted paths are not allowed (a leading / anchors the pattern to the project root)";
82
+ }
83
+ if (body.split(/[/\\]/).includes("..")) {
84
+ return "patterns must stay inside the project; '..' is not allowed";
85
+ }
86
+ if (parsePattern(pattern) === null) {
87
+ return "pattern does not select anything";
88
+ }
89
+ return null;
90
+ }
91
+ /**
92
+ * Validate the raw `deployResources` value read from `camunda.json`.
93
+ *
94
+ * @param value - The raw field value (`CamundaProject.deployResources`).
95
+ * @param source - Descriptor path used in error messages.
96
+ * @returns The validated pattern list (possibly empty).
97
+ * @throws {DeployResourcesError} `invalid-config` when the value is not an
98
+ * array of valid pattern strings.
99
+ */
100
+ export function parseDeployResources(value, source = "camunda.json") {
101
+ if (!Array.isArray(value)) {
102
+ throw new DeployResourcesError("invalid-config", `Invalid "${DEPLOY_RESOURCES_FIELD}" in ${source}: expected an array of glob strings, ` +
103
+ `got ${value === null ? "null" : typeof value}. ` +
104
+ `Example: "${DEPLOY_RESOURCES_FIELD}": ["resources/**"]`);
105
+ }
106
+ return value.map((entry, index) => {
107
+ if (typeof entry !== "string") {
108
+ throw new DeployResourcesError("invalid-config", `Invalid "${DEPLOY_RESOURCES_FIELD}" in ${source}: entry ${index} must be a string, ` +
109
+ `got ${entry === null ? "null" : typeof entry}`);
110
+ }
111
+ const problem = patternProblem(entry);
112
+ if (problem) {
113
+ throw new DeployResourcesError("invalid-config", `Invalid "${DEPLOY_RESOURCES_FIELD}" pattern ${JSON.stringify(entry)} in ${source}: ${problem}`);
114
+ }
115
+ return entry;
116
+ });
117
+ }
118
+ /**
119
+ * Strictly read the `camunda.json` descriptor of a directory that is being
120
+ * resolved for deployment or watching.
121
+ *
122
+ * Unlike `readCamundaProject` (lenient marker detection), a descriptor
123
+ * that exists but cannot be read — a directory named `camunda.json`, no
124
+ * permission, an I/O error — is an `invalid-config` error. Degrading to
125
+ * "no descriptor" would silently fall back to the default scan and
126
+ * bypass a `deployResources` allowlist.
127
+ *
128
+ * @returns The parsed descriptor, or `null` only when no `camunda.json`
129
+ * exists.
130
+ * @throws {DeployResourcesError} `invalid-config` when the file exists but
131
+ * cannot be read.
132
+ * @throws {Error} When `camunda.json` is not valid JSON.
133
+ */
134
+ export function readProjectDescriptor(dirPath) {
135
+ const file = join(dirPath, CAMUNDA_PROJECT_FILE);
136
+ let buffer;
137
+ try {
138
+ buffer = readFileSync(file);
139
+ }
140
+ catch (error) {
141
+ const code = isRecord(error) ? error.code : undefined;
142
+ if (code === "ENOENT" || code === "ENOTDIR") {
143
+ // No entry at all: not a project. An entry that exists but can't
144
+ // be followed (a dangling symlink) is a broken descriptor.
145
+ let dangling = false;
146
+ try {
147
+ dangling = lstatSync(file).isSymbolicLink();
148
+ }
149
+ catch {
150
+ // Genuinely absent.
151
+ }
152
+ if (!dangling)
153
+ return null;
154
+ throw new DeployResourcesError("invalid-config", `Failed to read ${file}: it is a dangling symlink (its target does not exist)`);
155
+ }
156
+ throw new DeployResourcesError("invalid-config", `Failed to read ${file}: ${normalizeToError(error).message}`);
157
+ }
158
+ return parseCamundaJson(decodeCamundaJson(buffer), file);
159
+ }
160
+ /**
161
+ * Read a project's `deployResources` state, distinguishing a missing
162
+ * descriptor from a descriptor without the field.
163
+ *
164
+ * @throws {DeployResourcesError} `invalid-config` when the descriptor
165
+ * cannot be read or the field is invalid.
166
+ * @throws {Error} When `camunda.json` is not valid JSON.
167
+ */
168
+ export function readDeployResourcesState(projectRoot) {
169
+ return deployResourcesStateOf(readProjectDescriptor(projectRoot), projectRoot);
170
+ }
171
+ /**
172
+ * The `deployResources` state of an already-read descriptor (`null` when
173
+ * there is none), so a caller can decide from a single read.
174
+ *
175
+ * @throws {DeployResourcesError} `invalid-config` when the field is invalid.
176
+ */
177
+ export function deployResourcesStateOf(project, projectRoot) {
178
+ if (!project)
179
+ return { kind: "no-descriptor" };
180
+ if (!Object.hasOwn(project, DEPLOY_RESOURCES_FIELD)) {
181
+ return { kind: "no-field" };
182
+ }
183
+ return {
184
+ kind: "patterns",
185
+ patterns: parseDeployResources(project.deployResources, join(projectRoot, CAMUNDA_PROJECT_FILE)),
186
+ };
187
+ }
188
+ /**
189
+ * Read the validated `deployResources` patterns of the project rooted at
190
+ * `projectRoot`.
191
+ *
192
+ * @returns The patterns, or `null` when there is no descriptor or the
193
+ * descriptor has no `deployResources` key (default scan applies).
194
+ * @throws {Error} When `camunda.json` is not valid JSON.
195
+ * @throws {DeployResourcesError} `invalid-config` when the descriptor
196
+ * cannot be read or the field is invalid.
197
+ */
198
+ export function readDeployResources(projectRoot) {
199
+ const state = readDeployResourcesState(projectRoot);
200
+ return state.kind === "patterns" ? state.patterns : null;
201
+ }
202
+ /**
203
+ * Whether glob `segments` could match some path strictly below the
204
+ * directory `dirSegments`. Mirrors the engine's segment semantics: `**`
205
+ * spans zero or more segments but never a dot-prefixed one.
206
+ */
207
+ function globCouldMatchBelow(dirSegments, globSegments) {
208
+ const step = (d, g) => {
209
+ if (d === dirSegments.length)
210
+ return g < globSegments.length;
211
+ if (g === globSegments.length)
212
+ return false;
213
+ const seg = globSegments[g];
214
+ if (seg === "**") {
215
+ return (step(d, g + 1) || (!dirSegments[d].startsWith(".") && step(d + 1, g)));
216
+ }
217
+ return matchesGlob(dirSegments[d], seg) && step(d + 1, g + 1);
218
+ };
219
+ return step(0, 0);
220
+ }
221
+ /**
222
+ * Expand comma brace groups (`{a,b}`, nesting allowed) into alternative
223
+ * globs. Braces without a top-level comma (`{1..3}`, a literal `{x}`) are
224
+ * left to the matcher.
225
+ */
226
+ function expandBraces(glob) {
227
+ let depth = 0;
228
+ let start = -1;
229
+ for (let i = 0; i < glob.length; i++) {
230
+ const ch = glob[i];
231
+ if (ch === "\\") {
232
+ i++;
233
+ }
234
+ else if (ch === "{") {
235
+ if (depth === 0)
236
+ start = i;
237
+ depth++;
238
+ }
239
+ else if (ch === "}" && depth > 0) {
240
+ depth--;
241
+ if (depth === 0) {
242
+ const options = splitTopLevel(glob.slice(start + 1, i));
243
+ if (options.length > 1) {
244
+ const prefix = glob.slice(0, start);
245
+ const suffix = glob.slice(i + 1);
246
+ return options.flatMap((option) => expandBraces(`${prefix}${option}${suffix}`));
247
+ }
248
+ }
249
+ }
250
+ }
251
+ return [glob];
252
+ }
253
+ /** Split a brace body on its top-level commas. */
254
+ function splitTopLevel(body) {
255
+ const parts = [];
256
+ let depth = 0;
257
+ let current = "";
258
+ for (let i = 0; i < body.length; i++) {
259
+ const ch = body[i];
260
+ if (ch === "\\") {
261
+ current += ch + (body[i + 1] ?? "");
262
+ i++;
263
+ continue;
264
+ }
265
+ if (ch === "{" || ch === "(")
266
+ depth++;
267
+ if ((ch === "}" || ch === ")") && depth > 0)
268
+ depth--;
269
+ if (ch === "," && depth === 0) {
270
+ parts.push(current);
271
+ current = "";
272
+ }
273
+ else {
274
+ current += ch;
275
+ }
276
+ }
277
+ parts.push(current);
278
+ return parts;
279
+ }
280
+ /** Whether some `/`-separated segment has an unbalanced group. */
281
+ function hasSplitGroup(glob) {
282
+ return glob.split("/").some((segment) => {
283
+ let depth = 0;
284
+ for (const ch of segment) {
285
+ if (ch === "(" || ch === "{")
286
+ depth++;
287
+ else if (ch === ")" || ch === "}")
288
+ depth--;
289
+ }
290
+ return depth !== 0;
291
+ });
292
+ }
293
+ /**
294
+ * Whether a brace-expanded glob could match a path strictly below the
295
+ * folder `dirSegments`.
296
+ */
297
+ function globReachesBelow(dirSegments, glob) {
298
+ return (
299
+ // A group that still spans a `/` (an extglob such as `@(a/b|c)`)
300
+ // can't be checked segment by segment: assume it can reach.
301
+ hasSplitGroup(glob) ||
302
+ // Empty (`a//b`) and `.` (`a/./b`) segments are dropped, as the
303
+ // native matcher collapses them. Dropping more than the matcher
304
+ // does only makes the answer more conservative.
305
+ globCouldMatchBelow(dirSegments, glob.split("/").filter((seg) => seg !== "" && seg !== ".")));
306
+ }
307
+ /**
308
+ * Compile validated `deployResources` patterns into a selector.
309
+ * Call {@link parseDeployResources} first to validate raw input.
310
+ */
311
+ export function compileDeployResources(patterns) {
312
+ const defaults = DEPLOY_RESOURCES_DEFAULT_EXCLUSIONS.map((p) => parsePattern(`!${p}`)).filter((p) => p !== null);
313
+ const user = patterns
314
+ .map(parsePattern)
315
+ .filter((p) => p !== null);
316
+ const ordered = [...defaults, ...user];
317
+ // Brace groups are expanded so reachability is checked per alternative.
318
+ const positiveAlternatives = user
319
+ .filter((p) => !p.negate)
320
+ .flatMap((p) => p.globs)
321
+ .flatMap(expandBraces);
322
+ return {
323
+ patterns: [...patterns],
324
+ excludesFolder: (relDir) => {
325
+ // In pattern order: a `!` pattern matching the folder excludes it;
326
+ // a later positive pattern that matches the folder or can reach
327
+ // below it cancels that, since it may select files inside.
328
+ const dirSegments = relDir.split("/").filter(Boolean);
329
+ return ordered.reduce((excluded, p) => {
330
+ if (p.negate) {
331
+ return matchesParsedPattern(`${relDir}/`, p) ? true : excluded;
332
+ }
333
+ const reaches = matchesParsedPattern(`${relDir}/`, p) ||
334
+ p.globs
335
+ .flatMap(expandBraces)
336
+ .some((glob) => globReachesBelow(dirSegments, glob));
337
+ return reaches ? false : excluded;
338
+ }, false);
339
+ },
340
+ selects: (relPath) => ordered.reduce((selected, p) => matchesParsedPattern(relPath, p) ? !p.negate : selected, false),
341
+ couldSelectUnder: (relDir) => {
342
+ const dirSegments = relDir.split("/").filter(Boolean);
343
+ return positiveAlternatives.some((glob) => globReachesBelow(dirSegments, glob));
344
+ },
345
+ };
346
+ }
347
+ /**
348
+ * Walk `projectRoot` and return the project-relative (`/`-separated)
349
+ * paths of every file the selector selects, sorted.
350
+ *
351
+ * - Symlinks are followed (same as the default deploy discovery). A
352
+ * directory reachable under several project-relative paths (a symlink
353
+ * alias and its real path) is walked under each of them, because
354
+ * patterns are evaluated against the project-relative path. Cycles are
355
+ * cut by skipping a directory whose real path is already on the
356
+ * current descent (an active ancestor). Files that resolve to the same
357
+ * real path are kept once (first path in sorted order wins).
358
+ * - Hidden files and directories are not skipped by the walker — the
359
+ * pattern engine decides (see module docs).
360
+ * - Nested `camunda.json` folders are ordinary folders here: nested
361
+ * projects are unsupported and are not excluded from the selection.
362
+ */
363
+ export function selectProjectFiles(projectRoot, selector) {
364
+ const selected = [];
365
+ // Real paths of the directories on the current descent.
366
+ const activeAncestors = new Set();
367
+ const visit = (dirAbs, relDir) => {
368
+ let real;
369
+ let entries;
370
+ try {
371
+ real = realpathSync(dirAbs);
372
+ entries = readdirSync(dirAbs).sort();
373
+ }
374
+ catch (error) {
375
+ // A folder the user excluded explicitly (`!folder/`) is skipped
376
+ // even if a broad pattern could reach into it.
377
+ if (relDir !== "" && selector.excludesFolder(relDir))
378
+ return;
379
+ throw unreadablePath(dirAbs, error, relDir);
380
+ }
381
+ if (activeAncestors.has(real))
382
+ return;
383
+ activeAncestors.add(real);
384
+ for (const entry of entries) {
385
+ const abs = join(dirAbs, entry);
386
+ const rel = relDir ? `${relDir}/${entry}` : entry;
387
+ let stat;
388
+ try {
389
+ stat = statSync(abs);
390
+ }
391
+ catch (error) {
392
+ // An entry no pattern can select (as a file or as a folder) is
393
+ // irrelevant. One a pattern can select must never be skipped
394
+ // silently: the deployment would succeed without it.
395
+ // The root camunda.json is the descriptor, already read for
396
+ // this run: it only matters if a pattern selects it as a file
397
+ // (it may be mid-replacement, e.g. briefly a dangling link).
398
+ const isDescriptor = relDir === "" && entry === CAMUNDA_PROJECT_FILE;
399
+ if (!selector.selects(rel) &&
400
+ (isDescriptor ||
401
+ !selector.couldSelectUnder(rel) ||
402
+ selector.excludesFolder(rel))) {
403
+ continue;
404
+ }
405
+ throw unreadablePath(abs, error, rel);
406
+ }
407
+ if (stat.isDirectory()) {
408
+ if (selector.couldSelectUnder(rel))
409
+ visit(abs, rel);
410
+ }
411
+ else if (stat.isFile() && selector.selects(rel)) {
412
+ selected.push(rel);
413
+ }
414
+ }
415
+ activeAncestors.delete(real);
416
+ };
417
+ visit(projectRoot, "");
418
+ const seenReal = new Set();
419
+ return selected.sort().filter((rel) => {
420
+ let key = rel;
421
+ try {
422
+ key = realpathSync(join(projectRoot, rel));
423
+ }
424
+ catch {
425
+ // Best effort: fall back to the relative path.
426
+ }
427
+ if (seenReal.has(key))
428
+ return false;
429
+ seenReal.add(key);
430
+ return true;
431
+ });
432
+ }
433
+ /**
434
+ * The `read-error` raised when a path a `deployResources` pattern can
435
+ * select cannot be read. Names the path and, for a dangling symlink,
436
+ * says so.
437
+ */
438
+ export function unreadablePath(path, error,
439
+ /** Project-relative path, used to suggest an exclusion pattern. */
440
+ rel) {
441
+ const code = isRecord(error) ? error.code : undefined;
442
+ let reason = normalizeToError(error).message;
443
+ if (code === "ENOENT") {
444
+ let dangling = false;
445
+ try {
446
+ dangling = lstatSync(path).isSymbolicLink();
447
+ }
448
+ catch {
449
+ // The path itself is gone (removed while deploying).
450
+ }
451
+ reason = dangling
452
+ ? "it is a dangling symlink (its target does not exist)"
453
+ : "it was removed while the selection was being read";
454
+ }
455
+ return new DeployResourcesError("read-error", `Cannot read ${path}, which a "${DEPLOY_RESOURCES_FIELD}" pattern can select: ${reason}. ` +
456
+ "Nothing was deployed. Fix the file permissions or the path, or exclude it " +
457
+ (rel
458
+ ? `with a ! pattern placed after the patterns that reach it, such as "!${rel}/" for a folder or "!${rel}" for a file.`
459
+ : "with a ! pattern."));
460
+ }
461
+ /**
462
+ * Resolve the deployed resource set of a project from its validated
463
+ * `deployResources` patterns.
464
+ *
465
+ * @throws {DeployResourcesError} `empty-selection` when nothing is
466
+ * selected (an unmatched pattern alone is silently ignored).
467
+ */
468
+ export function resolveDeployResources(projectRoot, patterns) {
469
+ const files = selectProjectFiles(projectRoot, compileDeployResources(patterns));
470
+ if (files.length === 0) {
471
+ throw new DeployResourcesError("empty-selection", `No deployable files found: "${DEPLOY_RESOURCES_FIELD}" in ${join(projectRoot, CAMUNDA_PROJECT_FILE)} ` +
472
+ "selects no files. Adjust the patterns so they match at least one project file.");
473
+ }
474
+ return files;
475
+ }
476
+ //# sourceMappingURL=deploy-resource-selection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deploy-resource-selection.js","sourceRoot":"","sources":["../../../src/utils/shared/deploy-resource-selection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EACN,SAAS,EACT,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,QAAQ,GACR,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,EACN,oBAAoB,EAEpB,iBAAiB,EACjB,gBAAgB,GAChB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACN,oBAAoB,EAEpB,YAAY,GACZ,MAAM,aAAa,CAAC;AAErB,oCAAoC;AACpC,MAAM,CAAC,MAAM,sBAAsB,GAAG,iBAAiB,CAAC;AAExD;;;;GAIG;AACH,MAAM,CAAC,MAAM,mCAAmC,GAAsB;IACrE,eAAe;IACf,SAAS;IACT,OAAO;IACP,eAAe;CACf,CAAC;AAQF;;;;GAIG;AACH,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IACrC,IAAI,CAA2B;IACxC,YAAY,IAA8B,EAAE,OAAe;QAC1D,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;QACnC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IAClB,CAAC;CACD;AAED,4EAA4E;AAC5E,SAAS,cAAc,CAAC,OAAe;IACtC,gEAAgE;IAChE,oEAAoE;IACpE,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,EAAE,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