@moldea.ai/cli 12.0.0 → 13.0.0
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 +4 -4
- package/dist/chunks/{composition-8VLm2c-X.js → composition-C2m6SpCI.js} +1 -1
- package/dist/chunks/{composition-DX66KnuP.js → composition-cVui-wF_.js} +121 -453
- package/dist/chunks/composition-cVui-wF_.js.map +1 -0
- package/dist/chunks/{core-composition-Bbpu62TT.js → core-composition-ZEZSTBMA.js} +2 -2
- package/dist/chunks/{core-composition-Bbpu62TT.js.map → core-composition-ZEZSTBMA.js.map} +1 -1
- package/dist/moldea.js +204 -418
- package/dist/moldea.js.map +1 -1
- package/package.json +9 -4
- package/dist/chunks/composition-DX66KnuP.js.map +0 -1
package/dist/moldea.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { A as
|
|
2
|
+
import { A as createMoldeaCliOutputPage, C as formatMoldeaCliJsonInspectResult, D as MOLDEA_CLI_GIT_WORKING_TREE_SOURCE, E as createMoldeaCliOwnedError, F as MOLDEA_CLI_COMMANDS, M as decodeMoldeaCliCursor, N as encodeMoldeaCliCursor, O as parseMoldeaCliArguments, P as MoldeaCliOutputPageException, S as formatMoldeaCliJsonError, T as formatMoldeaCliJsonValidateResult, _ as formatMoldeaCliHumanInspectResult, a as require_semver, b as formatMoldeaCliJsonCompositionResult, c as runGitCommand, d as createMoldeaCliInspectProjection, f as createMoldeaCliValidateProjection, g as formatMoldeaCliHumanError, h as formatMoldeaCliHumanContentResult, j as calculateMoldeaCliJsonDigest, k as isRepositoryDirectoryInputValid, l as readGit, m as formatMoldeaCliHumanCompositionResult, o as MoldeaCliCompositionException, p as formatMoldeaCliHelp, s as createGitVersionPreflight, u as createMoldeaCliDiagnosticRecord, v as formatMoldeaCliHumanScopeResult, w as formatMoldeaCliJsonScopeResult, x as formatMoldeaCliJsonContentResult, y as formatMoldeaCliHumanValidateResult } from "./chunks/composition-cVui-wF_.js";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import process from "node:process";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
|
+
import { hasErrorCode } from "jg-exception";
|
|
7
|
+
import { ERRORS, createShutdownSignal, readStdin } from "jg-process";
|
|
8
|
+
import { countUtf8Bytes } from "jg-utilities";
|
|
6
9
|
import { REPOSITORY_LINK_TEXT_MAX_BYTES, REPOSITORY_ROOT, RepositorySourceException, createRepositoryComparison, isRepositoryPath, parseRepositoryPath } from "@moldea.ai/repository";
|
|
7
10
|
import { lstat, readFile, readdir, stat } from "node:fs/promises";
|
|
11
|
+
import { listUntrackedFiles, readConfigBoolean, readIndexEntries, readTopLevel } from "jg-git-commands";
|
|
8
12
|
import { CoreConfigurationException, CoreOperationException, createCore } from "@moldea.ai/core";
|
|
9
13
|
import { Buffer as Buffer$1 } from "node:buffer";
|
|
10
14
|
import { createFilesystemRepositoryReader } from "@moldea.ai/repository-fs";
|
|
@@ -67,21 +71,10 @@ var decodeGitOutput = (output) => {
|
|
|
67
71
|
} catch {
|
|
68
72
|
return null;
|
|
69
73
|
}
|
|
70
|
-
if (decodedOutput.includes("\0") || !
|
|
74
|
+
if (decodedOutput.includes("\0") || !decodedOutput.isWellFormed()) return null;
|
|
71
75
|
return decodedOutput;
|
|
72
76
|
};
|
|
73
77
|
/**
|
|
74
|
-
* Parses Git's canonical boolean output.
|
|
75
|
-
* @param output The raw bounded Git stdout bytes.
|
|
76
|
-
* @returns The parsed boolean, or null when the output is not canonical.
|
|
77
|
-
*/
|
|
78
|
-
var parseGitBooleanOutput = (output) => {
|
|
79
|
-
const decodedOutput = decodeGitOutput(output);
|
|
80
|
-
if (decodedOutput === "true\n" || decodedOutput === "true\r\n") return true;
|
|
81
|
-
if (decodedOutput === "false\n" || decodedOutput === "false\r\n") return false;
|
|
82
|
-
return null;
|
|
83
|
-
};
|
|
84
|
-
/**
|
|
85
78
|
* Parses one nonempty path returned by Git.
|
|
86
79
|
* @param output The raw bounded Git stdout bytes.
|
|
87
80
|
* @returns The exact relative or absolute path, or null when the output is invalid.
|
|
@@ -130,7 +123,7 @@ var mapFilesystemFailure$3 = (error) => {
|
|
|
130
123
|
* @returns A safe inspector that resolves and verifies the selected directory.
|
|
131
124
|
*/
|
|
132
125
|
var createGitStartingDirectoryInspector = (inspectPath = stat) => async (input) => {
|
|
133
|
-
if (!path.isAbsolute(input.invocationDirectory) || input.invocationDirectory.includes("\0") || !
|
|
126
|
+
if (!path.isAbsolute(input.invocationDirectory) || input.invocationDirectory.includes("\0") || !input.invocationDirectory.isWellFormed() || input.repositoryDirectory !== null && !isRepositoryDirectoryInputValid(input.repositoryDirectory)) return Object.freeze({
|
|
134
127
|
errorCode: "GIT_REPOSITORY_NOT_FOUND",
|
|
135
128
|
kind: "failed"
|
|
136
129
|
});
|
|
@@ -151,14 +144,19 @@ var createGitStartingDirectoryInspector = (inspectPath = stat) => async (input)
|
|
|
151
144
|
var inspectGitStartingDirectory = createGitStartingDirectoryInspector();
|
|
152
145
|
//#endregion
|
|
153
146
|
//#region src/git-working-tree/discovery.ts
|
|
154
|
-
|
|
155
|
-
|
|
147
|
+
var GIT_DISCOVERY_READS = Object.freeze({
|
|
148
|
+
readConfigBoolean,
|
|
149
|
+
readTopLevel
|
|
150
|
+
});
|
|
151
|
+
/** Maps a normalized Git failure to a safe discovery error. */
|
|
152
|
+
var mapGitFailure$5 = (reason) => {
|
|
156
153
|
switch (reason) {
|
|
157
154
|
case "aborted": return "GIT_OPERATION_ABORTED";
|
|
158
155
|
case "not-found": return "GIT_NOT_FOUND";
|
|
159
156
|
case "repository-not-found": return "GIT_REPOSITORY_NOT_FOUND";
|
|
160
157
|
case "access-denied": return "GIT_ACCESS_DENIED";
|
|
161
|
-
case "output-limit-exceeded":
|
|
158
|
+
case "output-limit-exceeded":
|
|
159
|
+
case "output-invalid": return "GIT_OUTPUT_INVALID";
|
|
162
160
|
case "command-failed": return "GIT_COMMAND_FAILED";
|
|
163
161
|
}
|
|
164
162
|
};
|
|
@@ -168,69 +166,35 @@ var createDiscoveryFailure = (errorCode) => Object.freeze({
|
|
|
168
166
|
kind: "failed"
|
|
169
167
|
});
|
|
170
168
|
/**
|
|
171
|
-
* Creates Git working-tree discovery around injectable
|
|
172
|
-
* @param
|
|
169
|
+
* Creates Git working-tree discovery around injectable Git and filesystem boundaries.
|
|
170
|
+
* @param git The typed Git reads.
|
|
173
171
|
* @param startingDirectoryInspector The safe directory inspection boundary.
|
|
174
172
|
* @param gitVersionPreflight The Git version prerequisite check.
|
|
175
173
|
* @returns A working-tree discovery operation.
|
|
176
174
|
*/
|
|
177
|
-
var createGitWorkingTreeDiscovery = (
|
|
175
|
+
var createGitWorkingTreeDiscovery = (git = GIT_DISCOVERY_READS, startingDirectoryInspector = inspectGitStartingDirectory, gitVersionPreflight = createGitVersionPreflight()) => async (input) => {
|
|
178
176
|
const startingDirectoryResult = await startingDirectoryInspector(input);
|
|
179
177
|
if (startingDirectoryResult.kind === "failed") return createDiscoveryFailure(startingDirectoryResult.errorCode);
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
startingDirectoryResult.directory,
|
|
184
|
-
"rev-parse",
|
|
185
|
-
"--is-inside-work-tree"
|
|
186
|
-
],
|
|
187
|
-
maxBufferBytes: MAX_GIT_DISCOVERY_OUTPUT_BYTES,
|
|
178
|
+
const gitOptions = {
|
|
179
|
+
maxOutputBytes: MAX_GIT_DISCOVERY_OUTPUT_BYTES,
|
|
180
|
+
timeoutSeconds: 300,
|
|
188
181
|
...input.signal === void 0 ? {} : { signal: input.signal }
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
if (
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
if (!
|
|
195
|
-
const rootResult = await processExecutor({
|
|
196
|
-
arguments: [
|
|
197
|
-
"-C",
|
|
198
|
-
startingDirectoryResult.directory,
|
|
199
|
-
"rev-parse",
|
|
200
|
-
"--show-toplevel"
|
|
201
|
-
],
|
|
202
|
-
maxBufferBytes: MAX_GIT_DISCOVERY_OUTPUT_BYTES,
|
|
203
|
-
...input.signal === void 0 ? {} : { signal: input.signal }
|
|
204
|
-
});
|
|
205
|
-
if (rootResult.kind === "failed") return createDiscoveryFailure(mapGitProcessFailure$5(rootResult.reason));
|
|
206
|
-
if (rootResult.stderr.byteLength > 0) return createDiscoveryFailure("GIT_OUTPUT_INVALID");
|
|
207
|
-
const repositoryRoot = parseGitAbsolutePathOutput(rootResult.stdout);
|
|
208
|
-
if (repositoryRoot === null) return createDiscoveryFailure("GIT_OUTPUT_INVALID");
|
|
182
|
+
};
|
|
183
|
+
const rootResult = await readGit(() => git.readTopLevel(startingDirectoryResult.directory, gitOptions), input.signal);
|
|
184
|
+
if (rootResult.kind === "failed") return createDiscoveryFailure(mapGitFailure$5(rootResult.reason));
|
|
185
|
+
if (rootResult.value === null) return createDiscoveryFailure("GIT_WORK_TREE_REQUIRED");
|
|
186
|
+
const repositoryRoot = rootResult.value;
|
|
187
|
+
if (!path.isAbsolute(repositoryRoot)) return createDiscoveryFailure("GIT_OUTPUT_INVALID");
|
|
209
188
|
const rootDirectoryResult = await startingDirectoryInspector({
|
|
210
189
|
invocationDirectory: startingDirectoryResult.directory,
|
|
211
190
|
repositoryDirectory: repositoryRoot
|
|
212
191
|
});
|
|
213
192
|
if (rootDirectoryResult.kind === "failed") return createDiscoveryFailure(rootDirectoryResult.errorCode);
|
|
214
|
-
const versionResult = await gitVersionPreflight(input.signal);
|
|
193
|
+
const versionResult = await gitVersionPreflight(rootDirectoryResult.directory, input.signal);
|
|
215
194
|
if (versionResult.kind === "failed") return createDiscoveryFailure(versionResult.errorCode);
|
|
216
|
-
const sparseCheckoutResult = await
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
rootDirectoryResult.directory,
|
|
220
|
-
"config",
|
|
221
|
-
"--type=bool",
|
|
222
|
-
"--default=false",
|
|
223
|
-
"--get",
|
|
224
|
-
"core.sparseCheckout"
|
|
225
|
-
],
|
|
226
|
-
maxBufferBytes: MAX_GIT_DISCOVERY_OUTPUT_BYTES,
|
|
227
|
-
...input.signal === void 0 ? {} : { signal: input.signal }
|
|
228
|
-
});
|
|
229
|
-
if (sparseCheckoutResult.kind === "failed") return createDiscoveryFailure(mapGitProcessFailure$5(sparseCheckoutResult.reason));
|
|
230
|
-
if (sparseCheckoutResult.stderr.byteLength > 0) return createDiscoveryFailure("GIT_OUTPUT_INVALID");
|
|
231
|
-
const isSparseCheckout = parseGitBooleanOutput(sparseCheckoutResult.stdout);
|
|
232
|
-
if (isSparseCheckout === null) return createDiscoveryFailure("GIT_OUTPUT_INVALID");
|
|
233
|
-
if (isSparseCheckout) return createDiscoveryFailure("GIT_SPARSE_CHECKOUT_UNSUPPORTED");
|
|
195
|
+
const sparseCheckoutResult = await readGit(() => git.readConfigBoolean(rootDirectoryResult.directory, "core.sparseCheckout", false, gitOptions), input.signal);
|
|
196
|
+
if (sparseCheckoutResult.kind === "failed") return createDiscoveryFailure(mapGitFailure$5(sparseCheckoutResult.reason));
|
|
197
|
+
if (sparseCheckoutResult.value) return createDiscoveryFailure("GIT_SPARSE_CHECKOUT_UNSUPPORTED");
|
|
234
198
|
return Object.freeze({
|
|
235
199
|
kind: "discovered",
|
|
236
200
|
repositoryRoot
|
|
@@ -281,14 +245,15 @@ var createInspectionFailure$2 = (errorCode) => Object.freeze({
|
|
|
281
245
|
errorCode,
|
|
282
246
|
kind: "failed"
|
|
283
247
|
});
|
|
284
|
-
/** Maps one normalized Git
|
|
285
|
-
var
|
|
248
|
+
/** Maps one normalized Git failure to the discovery error contract. */
|
|
249
|
+
var mapGitFailure$4 = (reason) => {
|
|
286
250
|
switch (reason) {
|
|
287
251
|
case "aborted": return "GIT_OPERATION_ABORTED";
|
|
288
252
|
case "not-found": return "GIT_NOT_FOUND";
|
|
289
253
|
case "repository-not-found": return "GIT_REPOSITORY_NOT_FOUND";
|
|
290
254
|
case "access-denied": return "GIT_ACCESS_DENIED";
|
|
291
|
-
case "output-limit-exceeded":
|
|
255
|
+
case "output-limit-exceeded":
|
|
256
|
+
case "output-invalid": return "GIT_OUTPUT_INVALID";
|
|
292
257
|
case "command-failed": return "GIT_COMMAND_FAILED";
|
|
293
258
|
}
|
|
294
259
|
};
|
|
@@ -308,19 +273,14 @@ var mapFilesystemFailure$2 = (error) => {
|
|
|
308
273
|
return "GIT_COMMAND_FAILED";
|
|
309
274
|
};
|
|
310
275
|
/** Executes one bounded Git identity-path query. */
|
|
311
|
-
var queryGitPath = async (
|
|
312
|
-
const result = await
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
repositoryRoot,
|
|
316
|
-
...arguments_
|
|
317
|
-
],
|
|
318
|
-
maxBufferBytes: MAX_GIT_DISCOVERY_OUTPUT_BYTES,
|
|
276
|
+
var queryGitPath = async (runGit, repositoryRoot, arguments_, isAbsoluteRequired, signal) => {
|
|
277
|
+
const result = await runGit(arguments_, {
|
|
278
|
+
cwd: repositoryRoot,
|
|
279
|
+
maxOutputBytes: MAX_GIT_DISCOVERY_OUTPUT_BYTES,
|
|
319
280
|
...signal === void 0 ? {} : { signal }
|
|
320
281
|
});
|
|
321
|
-
if (result.kind === "failed") return createInspectionFailure$2(
|
|
322
|
-
|
|
323
|
-
return (isAbsoluteRequired ? parseGitAbsolutePathOutput(result.stdout) : parseGitPathOutput(result.stdout)) ?? createInspectionFailure$2("GIT_OUTPUT_INVALID");
|
|
282
|
+
if (result.kind === "failed") return createInspectionFailure$2(mapGitFailure$4(result.reason));
|
|
283
|
+
return (isAbsoluteRequired ? parseGitAbsolutePathOutput(result.value) : parseGitPathOutput(result.value)) ?? createInspectionFailure$2("GIT_OUTPUT_INVALID");
|
|
324
284
|
};
|
|
325
285
|
/** Captures one directory path and stable filesystem identity. */
|
|
326
286
|
var captureLocation = async (inspectPath, hostPath, invalidTypeCode) => {
|
|
@@ -340,14 +300,14 @@ var captureLocation = async (inspectPath, hostPath, invalidTypeCode) => {
|
|
|
340
300
|
var isInspectionFailure$1 = (result) => typeof result === "object" && "kind" in result && result.kind === "failed";
|
|
341
301
|
/**
|
|
342
302
|
* Creates a bounded working-tree identity inspector around Git and filesystem boundaries.
|
|
343
|
-
* @param
|
|
303
|
+
* @param runGit The bounded Git command boundary.
|
|
344
304
|
* @param inspectPath The followed directory identity operation.
|
|
345
305
|
* @returns An inspector that captures one private immutable identity.
|
|
346
306
|
*/
|
|
347
|
-
var createGitWorkingTreeIdentityInspector = (
|
|
307
|
+
var createGitWorkingTreeIdentityInspector = (runGit = runGitCommand, inspectPath = inspectDirectoryIdentity) => {
|
|
348
308
|
return async (input) => {
|
|
349
|
-
if (!path.isAbsolute(input.repositoryRoot) || input.repositoryRoot.includes("\0") || !
|
|
350
|
-
const discoveredRoot = await queryGitPath(
|
|
309
|
+
if (!path.isAbsolute(input.repositoryRoot) || input.repositoryRoot.includes("\0") || !input.repositoryRoot.isWellFormed()) return createInspectionFailure$2("GIT_OUTPUT_INVALID");
|
|
310
|
+
const discoveredRoot = await queryGitPath(runGit, input.repositoryRoot, GIT_WORKING_TREE_IDENTITY_ARGUMENTS.RepositoryRoot, true, input.signal);
|
|
351
311
|
if (isInspectionFailure$1(discoveredRoot)) return discoveredRoot;
|
|
352
312
|
const repositoryRoot = await captureLocation(inspectPath, discoveredRoot, "GIT_WORK_TREE_REQUIRED");
|
|
353
313
|
if (input.signal?.aborted) return createInspectionFailure$2("GIT_OPERATION_ABORTED");
|
|
@@ -358,9 +318,9 @@ var createGitWorkingTreeIdentityInspector = (processExecutor = executeGitProcess
|
|
|
358
318
|
if (isInspectionFailure$1(selectedRepositoryRoot)) return selectedRepositoryRoot;
|
|
359
319
|
if (!haveSameHostPathIdentity(repositoryRoot, selectedRepositoryRoot)) return Object.freeze({ kind: "mismatched" });
|
|
360
320
|
}
|
|
361
|
-
const gitDirectoryPath = await queryGitPath(
|
|
321
|
+
const gitDirectoryPath = await queryGitPath(runGit, input.repositoryRoot, GIT_WORKING_TREE_IDENTITY_ARGUMENTS.GitDirectory, true, input.signal);
|
|
362
322
|
if (isInspectionFailure$1(gitDirectoryPath)) return gitDirectoryPath;
|
|
363
|
-
const commonDirectoryOutput = await queryGitPath(
|
|
323
|
+
const commonDirectoryOutput = await queryGitPath(runGit, input.repositoryRoot, GIT_WORKING_TREE_IDENTITY_ARGUMENTS.CommonDirectory, false, input.signal);
|
|
364
324
|
if (isInspectionFailure$1(commonDirectoryOutput)) return commonDirectoryOutput;
|
|
365
325
|
const commonDirectoryPath = path.isAbsolute(commonDirectoryOutput) ? commonDirectoryOutput : path.resolve(input.repositoryRoot, commonDirectoryOutput);
|
|
366
326
|
const gitDirectory = await captureLocation(inspectPath, gitDirectoryPath, "GIT_OUTPUT_INVALID");
|
|
@@ -906,25 +866,6 @@ var mapMoldeaCliOperationalError = (error) => {
|
|
|
906
866
|
};
|
|
907
867
|
//#endregion
|
|
908
868
|
//#region src/git-inventory/constants.ts
|
|
909
|
-
var GIT_TRACKED_INVENTORY_ARGUMENTS = [
|
|
910
|
-
"ls-files",
|
|
911
|
-
"--cached",
|
|
912
|
-
"--stage",
|
|
913
|
-
"--full-name",
|
|
914
|
-
"--no-abbrev",
|
|
915
|
-
"--no-recurse-submodules",
|
|
916
|
-
"-z",
|
|
917
|
-
"--"
|
|
918
|
-
];
|
|
919
|
-
var GIT_UNTRACKED_INVENTORY_ARGUMENTS = [
|
|
920
|
-
"ls-files",
|
|
921
|
-
"--others",
|
|
922
|
-
"--exclude-standard",
|
|
923
|
-
"--full-name",
|
|
924
|
-
"--no-recurse-submodules",
|
|
925
|
-
"-z",
|
|
926
|
-
"--"
|
|
927
|
-
];
|
|
928
869
|
var GIT_IGNORED_INVENTORY_ARGUMENTS = [
|
|
929
870
|
"ls-files",
|
|
930
871
|
"--others",
|
|
@@ -941,6 +882,12 @@ var INSTRUCTION_PATHS = Object.freeze([
|
|
|
941
882
|
"/.claude/CLAUDE.md",
|
|
942
883
|
"/CLAUDE.local.md"
|
|
943
884
|
].map((path) => parseRepositoryPath(path)));
|
|
885
|
+
var GIT_TRACKED_ENTRY_MODES = [
|
|
886
|
+
"100644",
|
|
887
|
+
"100755",
|
|
888
|
+
"120000",
|
|
889
|
+
"160000"
|
|
890
|
+
];
|
|
944
891
|
//#endregion
|
|
945
892
|
//#region src/git-inventory/content-transformation/constants.ts
|
|
946
893
|
var GIT_CONTENT_TRANSFORMATION_ATTRIBUTES = [
|
|
@@ -1077,15 +1024,14 @@ var createClassificationFailure = (errorCode) => Object.freeze({
|
|
|
1077
1024
|
kind: "failed"
|
|
1078
1025
|
});
|
|
1079
1026
|
/** Maps one bounded Git attribute failure to the existing safe inventory contract. */
|
|
1080
|
-
var
|
|
1027
|
+
var mapGitFailure$3 = (reason) => {
|
|
1081
1028
|
switch (reason) {
|
|
1082
1029
|
case "aborted": return "GIT_OPERATION_ABORTED";
|
|
1083
1030
|
case "not-found": return "GIT_NOT_FOUND";
|
|
1084
1031
|
case "access-denied": return "GIT_ACCESS_DENIED";
|
|
1085
1032
|
case "repository-not-found": return "GIT_REPOSITORY_NOT_FOUND";
|
|
1086
|
-
case "output-limit-exceeded":
|
|
1087
|
-
case "
|
|
1088
|
-
case "stderr-limit-exceeded": return "GIT_OUTPUT_INVALID";
|
|
1033
|
+
case "output-limit-exceeded": return "RESOURCE_LIMIT_EXCEEDED";
|
|
1034
|
+
case "output-invalid": return "GIT_OUTPUT_INVALID";
|
|
1089
1035
|
case "command-failed": return "GIT_COMMAND_FAILED";
|
|
1090
1036
|
}
|
|
1091
1037
|
};
|
|
@@ -1119,11 +1065,11 @@ var createClassification = (filter, ident, workingTreeEncoding) => Object.freeze
|
|
|
1119
1065
|
workingTreeEncoding
|
|
1120
1066
|
});
|
|
1121
1067
|
/**
|
|
1122
|
-
* Creates the effective Git content-transformation classifier around a
|
|
1123
|
-
* @param
|
|
1068
|
+
* Creates the effective Git content-transformation classifier around a Git command boundary.
|
|
1069
|
+
* @param runGit The bounded Git command boundary.
|
|
1124
1070
|
* @returns An all-or-nothing bounded classifier for effective inventory entries.
|
|
1125
1071
|
*/
|
|
1126
|
-
var createGitContentTransformationClassifier = (
|
|
1072
|
+
var createGitContentTransformationClassifier = (runGit = runGitCommand) => {
|
|
1127
1073
|
return async (input) => {
|
|
1128
1074
|
if (input.signal?.aborted) return createClassificationFailure("GIT_OPERATION_ABORTED");
|
|
1129
1075
|
if (!Number.isSafeInteger(input.maxMetadataBytes) || input.maxMetadataBytes < 0) return createClassificationFailure("RESOURCE_LIMIT_EXCEEDED");
|
|
@@ -1135,25 +1081,16 @@ var createGitContentTransformationClassifier = (processExecutor = executeGitStre
|
|
|
1135
1081
|
const paths = input.entries.map((entry) => entry.path);
|
|
1136
1082
|
const stdin = encodePaths(paths);
|
|
1137
1083
|
if (stdin === null) return createClassificationFailure("GIT_OUTPUT_INVALID");
|
|
1138
|
-
const
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
input.repositoryRoot,
|
|
1144
|
-
...GIT_CONTENT_TRANSFORMATION_ARGUMENTS
|
|
1145
|
-
],
|
|
1146
|
-
consumeStdout: (chunk) => {
|
|
1147
|
-
consumedStdoutBytes += chunk.byteLength;
|
|
1148
|
-
parser.consume(chunk);
|
|
1149
|
-
},
|
|
1150
|
-
maxStderrBytes: MAX_GIT_PROCESS_DIAGNOSTIC_BYTES,
|
|
1151
|
-
maxStdoutBytes: input.maxMetadataBytes,
|
|
1152
|
-
...input.signal === void 0 ? {} : { signal: input.signal },
|
|
1153
|
-
stdin
|
|
1084
|
+
const result = await runGit(GIT_CONTENT_TRANSFORMATION_ARGUMENTS, {
|
|
1085
|
+
cwd: input.repositoryRoot,
|
|
1086
|
+
input: stdin,
|
|
1087
|
+
maxOutputBytes: Math.max(input.maxMetadataBytes, 1),
|
|
1088
|
+
...input.signal === void 0 ? {} : { signal: input.signal }
|
|
1154
1089
|
});
|
|
1155
|
-
if (
|
|
1156
|
-
if (
|
|
1090
|
+
if (result.kind === "failed") return createClassificationFailure(mapGitFailure$3(result.reason));
|
|
1091
|
+
if (result.value.byteLength > input.maxMetadataBytes) return createClassificationFailure("RESOURCE_LIMIT_EXCEEDED");
|
|
1092
|
+
const parser = createGitContentTransformationParser({ paths });
|
|
1093
|
+
parser.consume(result.value);
|
|
1157
1094
|
const parserResult = parser.finish();
|
|
1158
1095
|
if (parserResult.kind === "failed" || parserResult.attributes.length !== input.entries.length) return createClassificationFailure("GIT_OUTPUT_INVALID");
|
|
1159
1096
|
const entries = input.entries.map((entry, index) => {
|
|
@@ -1167,7 +1104,7 @@ var createGitContentTransformationClassifier = (processExecutor = executeGitStre
|
|
|
1167
1104
|
if (entries.some((entry) => entry === null)) return createClassificationFailure("GIT_OUTPUT_INVALID");
|
|
1168
1105
|
return Object.freeze({
|
|
1169
1106
|
entries: Object.freeze(entries.filter((entry) => entry !== null)),
|
|
1170
|
-
gitMetadataBytes:
|
|
1107
|
+
gitMetadataBytes: result.value.byteLength,
|
|
1171
1108
|
kind: "classified"
|
|
1172
1109
|
});
|
|
1173
1110
|
};
|
|
@@ -1272,15 +1209,6 @@ var createGitInventoryEntryInspector = (inspectEntry = inspectHostEntry) => {
|
|
|
1272
1209
|
};
|
|
1273
1210
|
var inspectGitInventoryEntry = createGitInventoryEntryInspector();
|
|
1274
1211
|
//#endregion
|
|
1275
|
-
//#region src/git-inventory/entry-type/constants.ts
|
|
1276
|
-
var GIT_SYMLINK_CONFIGURATION_ARGUMENTS = [
|
|
1277
|
-
"config",
|
|
1278
|
-
"--type=bool",
|
|
1279
|
-
"--default=true",
|
|
1280
|
-
"--get",
|
|
1281
|
-
"core.symlinks"
|
|
1282
|
-
];
|
|
1283
|
-
//#endregion
|
|
1284
1212
|
//#region src/git-inventory/entry-type/symlink-configuration.ts
|
|
1285
1213
|
/** Creates one immutable effective symlink configuration failure. */
|
|
1286
1214
|
var createConfigurationFailure = (errorCode) => Object.freeze({
|
|
@@ -1288,60 +1216,37 @@ var createConfigurationFailure = (errorCode) => Object.freeze({
|
|
|
1288
1216
|
kind: "failed"
|
|
1289
1217
|
});
|
|
1290
1218
|
/** Maps one bounded Git configuration failure to the existing safe CLI contract. */
|
|
1291
|
-
var
|
|
1219
|
+
var mapGitFailure$2 = (reason) => {
|
|
1292
1220
|
switch (reason) {
|
|
1293
1221
|
case "aborted": return "GIT_OPERATION_ABORTED";
|
|
1294
1222
|
case "not-found": return "GIT_NOT_FOUND";
|
|
1295
1223
|
case "access-denied": return "GIT_ACCESS_DENIED";
|
|
1296
|
-
case "output-limit-exceeded":
|
|
1297
|
-
case "stdout-limit-exceeded": return "RESOURCE_LIMIT_EXCEEDED";
|
|
1224
|
+
case "output-limit-exceeded": return "RESOURCE_LIMIT_EXCEEDED";
|
|
1298
1225
|
case "repository-not-found":
|
|
1299
|
-
case "
|
|
1226
|
+
case "output-invalid": return "GIT_OUTPUT_INVALID";
|
|
1300
1227
|
case "command-failed": return "GIT_COMMAND_FAILED";
|
|
1301
1228
|
}
|
|
1302
1229
|
};
|
|
1303
|
-
/** Concatenates already bounded Git stdout chunks for strict boolean parsing. */
|
|
1304
|
-
var concatenateChunks$1 = (chunks, byteLength) => {
|
|
1305
|
-
const output = new Uint8Array(byteLength);
|
|
1306
|
-
let offset = 0;
|
|
1307
|
-
for (const chunk of chunks) {
|
|
1308
|
-
output.set(chunk, offset);
|
|
1309
|
-
offset += chunk.byteLength;
|
|
1310
|
-
}
|
|
1311
|
-
return output;
|
|
1312
|
-
};
|
|
1313
1230
|
/**
|
|
1314
|
-
* Creates the bounded effective core.symlinks resolver around a Git
|
|
1315
|
-
* @param
|
|
1231
|
+
* Creates the bounded effective core.symlinks resolver around a typed Git config read.
|
|
1232
|
+
* @param readBoolean The typed Git boolean config read.
|
|
1316
1233
|
* @returns A resolver for the selected repository's effective symlink behavior.
|
|
1317
1234
|
*/
|
|
1318
|
-
var createGitSymlinkConfigurationResolver = (
|
|
1235
|
+
var createGitSymlinkConfigurationResolver = (readBoolean = readConfigBoolean) => {
|
|
1319
1236
|
return async (input) => {
|
|
1320
1237
|
if (input.signal?.aborted) return createConfigurationFailure("GIT_OPERATION_ABORTED");
|
|
1321
1238
|
if (!Number.isSafeInteger(input.maxMetadataBytes) || input.maxMetadataBytes < 0) return createConfigurationFailure("RESOURCE_LIMIT_EXCEEDED");
|
|
1322
|
-
const
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
arguments: [
|
|
1326
|
-
"-C",
|
|
1327
|
-
input.repositoryRoot,
|
|
1328
|
-
...GIT_SYMLINK_CONFIGURATION_ARGUMENTS
|
|
1329
|
-
],
|
|
1330
|
-
consumeStdout: (chunk) => {
|
|
1331
|
-
stdoutChunks.push(Uint8Array.from(chunk));
|
|
1332
|
-
consumedStdoutBytes += chunk.byteLength;
|
|
1333
|
-
},
|
|
1334
|
-
maxStderrBytes: MAX_GIT_PROCESS_DIAGNOSTIC_BYTES,
|
|
1335
|
-
maxStdoutBytes: input.maxMetadataBytes,
|
|
1239
|
+
const result = await readGit(() => readBoolean(input.repositoryRoot, "core.symlinks", true, {
|
|
1240
|
+
maxOutputBytes: Math.max(input.maxMetadataBytes, 1),
|
|
1241
|
+
timeoutSeconds: 300,
|
|
1336
1242
|
...input.signal === void 0 ? {} : { signal: input.signal }
|
|
1337
|
-
});
|
|
1338
|
-
if (
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
if (isEnabled === null) return createConfigurationFailure("GIT_OUTPUT_INVALID");
|
|
1243
|
+
}), input.signal);
|
|
1244
|
+
if (result.kind === "failed") return createConfigurationFailure(mapGitFailure$2(result.reason));
|
|
1245
|
+
const gitMetadataBytes = result.value ? 5 : 6;
|
|
1246
|
+
if (gitMetadataBytes > input.maxMetadataBytes) return createConfigurationFailure("RESOURCE_LIMIT_EXCEEDED");
|
|
1342
1247
|
return Object.freeze({
|
|
1343
|
-
gitMetadataBytes
|
|
1344
|
-
isEnabled,
|
|
1248
|
+
gitMetadataBytes,
|
|
1249
|
+
isEnabled: result.value,
|
|
1345
1250
|
kind: "resolved"
|
|
1346
1251
|
});
|
|
1347
1252
|
};
|
|
@@ -1496,7 +1401,6 @@ var normalizeGitInventoryLogicalPaths = (input) => {
|
|
|
1496
1401
|
};
|
|
1497
1402
|
//#endregion
|
|
1498
1403
|
//#region src/git-inventory/parser.ts
|
|
1499
|
-
var TRACKED_ENTRY_HEADER_PATTERN = /^(100644|100755|120000|160000) (?:[0-9a-f]{40}|[0-9a-f]{64}) ([0-3])$/u;
|
|
1500
1404
|
/** Decodes one complete Git path as strict UTF-8 while preserving an initial BOM scalar. */
|
|
1501
1405
|
var decodeGitPath = (pathBytes) => {
|
|
1502
1406
|
if (pathBytes.byteLength === 0) return null;
|
|
@@ -1509,20 +1413,6 @@ var decodeGitPath = (pathBytes) => {
|
|
|
1509
1413
|
return null;
|
|
1510
1414
|
}
|
|
1511
1415
|
};
|
|
1512
|
-
/** Confirms that one decoded path contains only complete Unicode scalar values. */
|
|
1513
|
-
var hasOnlyUnicodeScalarValues = (path) => {
|
|
1514
|
-
for (let index = 0; index < path.length; index += 1) {
|
|
1515
|
-
const codeUnit = path.charCodeAt(index);
|
|
1516
|
-
if (codeUnit >= 55296 && codeUnit <= 56319) {
|
|
1517
|
-
const trailingCodeUnit = path.charCodeAt(index + 1);
|
|
1518
|
-
if (trailingCodeUnit < 56320 || trailingCodeUnit > 57343) return false;
|
|
1519
|
-
index += 1;
|
|
1520
|
-
continue;
|
|
1521
|
-
}
|
|
1522
|
-
if (codeUnit >= 56320 && codeUnit <= 57343) return false;
|
|
1523
|
-
}
|
|
1524
|
-
return true;
|
|
1525
|
-
};
|
|
1526
1416
|
/** Concatenates one complete record assembled across arbitrary process chunks. */
|
|
1527
1417
|
var concatenateRecord = (fragments, byteLength) => {
|
|
1528
1418
|
const record = new Uint8Array(byteLength);
|
|
@@ -1533,30 +1423,10 @@ var concatenateRecord = (fragments, byteLength) => {
|
|
|
1533
1423
|
}
|
|
1534
1424
|
return record;
|
|
1535
1425
|
};
|
|
1536
|
-
/** Parses one tracked `ls-files --stage` record without normalizing its path. */
|
|
1537
|
-
var parseTrackedCandidate = (record) => {
|
|
1538
|
-
const separatorIndex = record.indexOf(9);
|
|
1539
|
-
if (separatorIndex <= 0 || separatorIndex === record.byteLength - 1) return null;
|
|
1540
|
-
let header;
|
|
1541
|
-
try {
|
|
1542
|
-
header = new TextDecoder("utf-8", { fatal: true }).decode(record.subarray(0, separatorIndex));
|
|
1543
|
-
} catch {
|
|
1544
|
-
return null;
|
|
1545
|
-
}
|
|
1546
|
-
const headerMatch = TRACKED_ENTRY_HEADER_PATTERN.exec(header);
|
|
1547
|
-
const path = decodeGitPath(record.subarray(separatorIndex + 1));
|
|
1548
|
-
if (headerMatch === null || path === null || !hasOnlyUnicodeScalarValues(path)) return null;
|
|
1549
|
-
return Object.freeze({
|
|
1550
|
-
kind: "tracked",
|
|
1551
|
-
mode: headerMatch[1],
|
|
1552
|
-
path,
|
|
1553
|
-
stage: Number(headerMatch[2])
|
|
1554
|
-
});
|
|
1555
|
-
};
|
|
1556
1426
|
/** Parses one untracked `ls-files --others` record without normalizing its path. */
|
|
1557
1427
|
var parseUntrackedCandidate = (record) => {
|
|
1558
1428
|
const path = decodeGitPath(record);
|
|
1559
|
-
if (path === null || !
|
|
1429
|
+
if (path === null || !path.isWellFormed()) return null;
|
|
1560
1430
|
return Object.freeze({
|
|
1561
1431
|
kind: "untracked",
|
|
1562
1432
|
path
|
|
@@ -1617,14 +1487,12 @@ var createGitInventoryParser = (maxEntries, parseCandidate) => {
|
|
|
1617
1487
|
}
|
|
1618
1488
|
};
|
|
1619
1489
|
};
|
|
1620
|
-
/** Creates a strict incremental parser for tracked Git inventory output. */
|
|
1621
|
-
var createTrackedGitInventoryParser = (maxEntries) => createGitInventoryParser(maxEntries, parseTrackedCandidate);
|
|
1622
1490
|
/** Creates a strict incremental parser for untracked Git inventory output. */
|
|
1623
1491
|
var createUntrackedGitInventoryParser = (maxEntries) => createGitInventoryParser(maxEntries, parseUntrackedCandidate);
|
|
1624
1492
|
//#endregion
|
|
1625
1493
|
//#region src/git-inventory/repository-ownership/boundary-inspector.ts
|
|
1626
1494
|
var GIT_CONTROL_SEGMENT = ".git";
|
|
1627
|
-
var
|
|
1495
|
+
var TOP_LEVEL_OUTPUT_OVERHEAD_BYTES = 6;
|
|
1628
1496
|
/** Identifies one safe inspection failure in a filesystem result union. */
|
|
1629
1497
|
var isInspectionFailure = (result) => "kind" in result;
|
|
1630
1498
|
/** Creates one immutable ownership-inspection failure. */
|
|
@@ -1639,16 +1507,15 @@ var mapFilesystemFailure = (error) => {
|
|
|
1639
1507
|
if (errorCode === "ENOENT" || errorCode === "ENOTDIR" || errorCode === "ELOOP") return "GIT_OUTPUT_INVALID";
|
|
1640
1508
|
return "GIT_COMMAND_FAILED";
|
|
1641
1509
|
};
|
|
1642
|
-
/** Maps a
|
|
1643
|
-
var
|
|
1510
|
+
/** Maps a nested-root check failure into the existing safe CLI contract. */
|
|
1511
|
+
var mapGitFailure$1 = (reason) => {
|
|
1644
1512
|
switch (reason) {
|
|
1645
1513
|
case "aborted": return "GIT_OPERATION_ABORTED";
|
|
1646
1514
|
case "not-found": return "GIT_NOT_FOUND";
|
|
1647
1515
|
case "access-denied": return "GIT_ACCESS_DENIED";
|
|
1648
|
-
case "output-limit-exceeded":
|
|
1649
|
-
case "stdout-limit-exceeded": return "RESOURCE_LIMIT_EXCEEDED";
|
|
1516
|
+
case "output-limit-exceeded": return "RESOURCE_LIMIT_EXCEEDED";
|
|
1650
1517
|
case "repository-not-found":
|
|
1651
|
-
case "
|
|
1518
|
+
case "output-invalid": return "GIT_OUTPUT_INVALID";
|
|
1652
1519
|
case "command-failed": return "GIT_COMMAND_FAILED";
|
|
1653
1520
|
}
|
|
1654
1521
|
};
|
|
@@ -1679,56 +1546,37 @@ var inspectPath = async (hostPath, inspectHostPath) => {
|
|
|
1679
1546
|
var hasExactDirectoryName = (encodedNameKeys, segment) => encodedNameKeys.has(Buffer$1.from(segment, "utf8").toString("hex"));
|
|
1680
1547
|
/** Confirms that one directory observation retained its no-follow identity. */
|
|
1681
1548
|
var hasStableDirectoryIdentity = (initialStatistics, revalidatedStatistics) => initialStatistics.isDirectory() && !initialStatistics.isSymbolicLink() && revalidatedStatistics.isDirectory() && !revalidatedStatistics.isSymbolicLink() && initialStatistics.dev === revalidatedStatistics.dev && initialStatistics.ino === revalidatedStatistics.ino;
|
|
1682
|
-
/** Concatenates already bounded Git stdout chunks for strict root parsing. */
|
|
1683
|
-
var concatenateChunks = (chunks, byteLength) => {
|
|
1684
|
-
const output = new Uint8Array(byteLength);
|
|
1685
|
-
let offset = 0;
|
|
1686
|
-
for (const chunk of chunks) {
|
|
1687
|
-
output.set(chunk, offset);
|
|
1688
|
-
offset += chunk.byteLength;
|
|
1689
|
-
}
|
|
1690
|
-
return output;
|
|
1691
|
-
};
|
|
1692
1549
|
/**
|
|
1693
1550
|
* Confirms whether a directory with an exact `.git` marker owns another working tree.
|
|
1694
1551
|
* @param directory The exact no-follow directory being classified.
|
|
1695
1552
|
* @param repositoryRoot The selected repository root.
|
|
1696
1553
|
* @param directoryStatistics The stable no-follow boundary observation.
|
|
1697
|
-
* @param maxMetadataBytes The remaining bounded Git
|
|
1698
|
-
* @param
|
|
1554
|
+
* @param maxMetadataBytes The remaining bounded Git output budget.
|
|
1555
|
+
* @param readRoot The typed Git working-tree root read.
|
|
1699
1556
|
* @param inspectHostPath The no-follow filesystem stat operation.
|
|
1700
1557
|
* @returns A safe ownership classification and the consumed Git metadata bytes.
|
|
1701
1558
|
*/
|
|
1702
|
-
var validateGitBoundary = async (directory, repositoryRoot, directoryStatistics, maxMetadataBytes,
|
|
1559
|
+
var validateGitBoundary = async (directory, repositoryRoot, directoryStatistics, maxMetadataBytes, readRoot, inspectHostPath, signal) => {
|
|
1703
1560
|
if (signal?.aborted) return createInspectionFailure("GIT_OPERATION_ABORTED");
|
|
1704
1561
|
if (!Number.isSafeInteger(maxMetadataBytes) || maxMetadataBytes < 0) return createInspectionFailure("RESOURCE_LIMIT_EXCEEDED");
|
|
1705
|
-
const
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
arguments: [
|
|
1709
|
-
"-C",
|
|
1710
|
-
directory,
|
|
1711
|
-
...GIT_REPOSITORY_ROOT_ARGUMENTS
|
|
1712
|
-
],
|
|
1713
|
-
consumeStdout: (chunk) => {
|
|
1714
|
-
stdoutChunks.push(Uint8Array.from(chunk));
|
|
1715
|
-
consumedStdoutBytes += chunk.byteLength;
|
|
1716
|
-
},
|
|
1717
|
-
maxStderrBytes: MAX_GIT_PROCESS_DIAGNOSTIC_BYTES,
|
|
1718
|
-
maxStdoutBytes: maxMetadataBytes,
|
|
1562
|
+
const rootResult = await readGit(() => readRoot(directory, {
|
|
1563
|
+
maxOutputBytes: Math.max(maxMetadataBytes, 1),
|
|
1564
|
+
timeoutSeconds: 300,
|
|
1719
1565
|
...signal === void 0 ? {} : { signal }
|
|
1720
|
-
});
|
|
1721
|
-
if (
|
|
1722
|
-
if (
|
|
1723
|
-
const discoveredRoot =
|
|
1724
|
-
|
|
1566
|
+
}), signal);
|
|
1567
|
+
if (rootResult.kind === "failed") return createInspectionFailure(mapGitFailure$1(rootResult.reason));
|
|
1568
|
+
if (rootResult.value === null) return createInspectionFailure("GIT_COMMAND_FAILED");
|
|
1569
|
+
const discoveredRoot = rootResult.value;
|
|
1570
|
+
const gitMetadataBytes = TOP_LEVEL_OUTPUT_OVERHEAD_BYTES + countUtf8Bytes(discoveredRoot);
|
|
1571
|
+
if (gitMetadataBytes > maxMetadataBytes) return createInspectionFailure("RESOURCE_LIMIT_EXCEEDED");
|
|
1572
|
+
if (!path.isAbsolute(discoveredRoot)) return createInspectionFailure("GIT_OUTPUT_INVALID");
|
|
1725
1573
|
if (areHostPathsEquivalent(discoveredRoot, directory)) return Object.freeze({
|
|
1726
|
-
gitMetadataBytes
|
|
1574
|
+
gitMetadataBytes,
|
|
1727
1575
|
kind: "validated",
|
|
1728
1576
|
ownership: "nested-repository"
|
|
1729
1577
|
});
|
|
1730
1578
|
if (areHostPathsEquivalent(discoveredRoot, repositoryRoot)) return Object.freeze({
|
|
1731
|
-
gitMetadataBytes
|
|
1579
|
+
gitMetadataBytes,
|
|
1732
1580
|
kind: "validated",
|
|
1733
1581
|
ownership: "selected-repository"
|
|
1734
1582
|
});
|
|
@@ -1737,7 +1585,7 @@ var validateGitBoundary = async (directory, repositoryRoot, directoryStatistics,
|
|
|
1737
1585
|
if (discoveredRootInspection.kind === "failed") return discoveredRootInspection;
|
|
1738
1586
|
if (!discoveredRootInspection.statistics.isDirectory() || discoveredRootInspection.statistics.isSymbolicLink()) return createInspectionFailure("GIT_OUTPUT_INVALID");
|
|
1739
1587
|
if (haveSameHostPathIdentity(discoveredRootInspection.statistics, directoryStatistics)) return Object.freeze({
|
|
1740
|
-
gitMetadataBytes
|
|
1588
|
+
gitMetadataBytes,
|
|
1741
1589
|
kind: "validated",
|
|
1742
1590
|
ownership: "nested-repository"
|
|
1743
1591
|
});
|
|
@@ -1745,7 +1593,7 @@ var validateGitBoundary = async (directory, repositoryRoot, directoryStatistics,
|
|
|
1745
1593
|
if (signal?.aborted) return createInspectionFailure("GIT_OPERATION_ABORTED");
|
|
1746
1594
|
if (repositoryRootInspection.kind === "failed") return repositoryRootInspection;
|
|
1747
1595
|
if (repositoryRootInspection.statistics.isDirectory() && !repositoryRootInspection.statistics.isSymbolicLink() && haveSameHostPathIdentity(discoveredRootInspection.statistics, repositoryRootInspection.statistics)) return Object.freeze({
|
|
1748
|
-
gitMetadataBytes
|
|
1596
|
+
gitMetadataBytes,
|
|
1749
1597
|
kind: "validated",
|
|
1750
1598
|
ownership: "selected-repository"
|
|
1751
1599
|
});
|
|
@@ -1757,12 +1605,12 @@ var inspectOwnershipPath = async (hostPath) => lstat(hostPath, { bigint: true })
|
|
|
1757
1605
|
var readOwnershipDirectory = async (hostPath) => readdir(hostPath, { encoding: "buffer" });
|
|
1758
1606
|
/**
|
|
1759
1607
|
* Creates nested-repository inspection around injectable filesystem and Git boundaries.
|
|
1760
|
-
* @param
|
|
1608
|
+
* @param readRoot The typed Git working-tree root read.
|
|
1761
1609
|
* @param inspectHostPath The no-follow filesystem stat operation.
|
|
1762
1610
|
* @param readDirectory The raw native-name directory operation.
|
|
1763
1611
|
* @returns An all-or-nothing ownership inspector for untracked candidate paths.
|
|
1764
1612
|
*/
|
|
1765
|
-
var createGitInventoryBoundaryInspector = (
|
|
1613
|
+
var createGitInventoryBoundaryInspector = (readRoot = readTopLevel, inspectHostPath = inspectOwnershipPath, readDirectory = readOwnershipDirectory) => {
|
|
1766
1614
|
return async (input) => {
|
|
1767
1615
|
if (input.signal?.aborted) return createInspectionFailure("GIT_OPERATION_ABORTED");
|
|
1768
1616
|
const directoryObservations = /* @__PURE__ */ new Map();
|
|
@@ -1820,7 +1668,7 @@ var createGitInventoryBoundaryInspector = (processExecutor = executeGitStreaming
|
|
|
1820
1668
|
if (input.signal?.aborted) return createInspectionFailure("GIT_OPERATION_ABORTED");
|
|
1821
1669
|
if (gitControlInspection.kind === "failed") return gitControlInspection;
|
|
1822
1670
|
if (gitControlInspection.statistics.isSymbolicLink() || !gitControlInspection.statistics.isDirectory() && !gitControlInspection.statistics.isFile()) return createInspectionFailure("GIT_OUTPUT_INVALID");
|
|
1823
|
-
const boundaryValidation = await validateGitBoundary(hostPath, input.repositoryRoot, revalidatedInspection.statistics, input.maxMetadataBytes - gitMetadataBytes,
|
|
1671
|
+
const boundaryValidation = await validateGitBoundary(hostPath, input.repositoryRoot, revalidatedInspection.statistics, input.maxMetadataBytes - gitMetadataBytes, readRoot, inspectHostPath, input.signal);
|
|
1824
1672
|
if (boundaryValidation.kind === "failed") return boundaryValidation;
|
|
1825
1673
|
gitMetadataBytes += boundaryValidation.gitMetadataBytes;
|
|
1826
1674
|
directoryOwnership = boundaryValidation.ownership;
|
|
@@ -1982,19 +1830,43 @@ var createGitInventoryOwnershipFilter = (boundaryInspector = inspectGitInventory
|
|
|
1982
1830
|
};
|
|
1983
1831
|
//#endregion
|
|
1984
1832
|
//#region src/git-inventory/probe.ts
|
|
1985
|
-
|
|
1986
|
-
|
|
1833
|
+
var GIT_INVENTORY_LISTING_READS = Object.freeze({
|
|
1834
|
+
listUntrackedFiles,
|
|
1835
|
+
readIndexEntries,
|
|
1836
|
+
runGit: runGitCommand
|
|
1837
|
+
});
|
|
1838
|
+
/** Maps one normalized Git failure to a safe inventory error. */
|
|
1839
|
+
var mapGitFailure = (reason) => {
|
|
1987
1840
|
switch (reason) {
|
|
1988
1841
|
case "aborted": return "GIT_OPERATION_ABORTED";
|
|
1989
1842
|
case "not-found": return "GIT_NOT_FOUND";
|
|
1990
1843
|
case "repository-not-found": return "GIT_REPOSITORY_NOT_FOUND";
|
|
1991
1844
|
case "access-denied": return "GIT_ACCESS_DENIED";
|
|
1992
|
-
case "
|
|
1993
|
-
case "output-limit-exceeded":
|
|
1994
|
-
case "stdout-limit-exceeded": return "RESOURCE_LIMIT_EXCEEDED";
|
|
1845
|
+
case "output-invalid": return "GIT_OUTPUT_INVALID";
|
|
1846
|
+
case "output-limit-exceeded": return "RESOURCE_LIMIT_EXCEEDED";
|
|
1995
1847
|
case "command-failed": return "GIT_COMMAND_FAILED";
|
|
1996
1848
|
}
|
|
1997
1849
|
};
|
|
1850
|
+
/** Determines whether one index mode belongs to the version 1 inventory grammar. */
|
|
1851
|
+
var isTrackedEntryMode = (mode) => GIT_TRACKED_ENTRY_MODES.includes(mode);
|
|
1852
|
+
/** Converts index entries into tracked candidates, or null when one has an unsupported mode. */
|
|
1853
|
+
var toTrackedCandidates = (entries) => {
|
|
1854
|
+
const candidates = [];
|
|
1855
|
+
for (const { mode, path, stage } of entries) {
|
|
1856
|
+
if (!isTrackedEntryMode(mode)) return null;
|
|
1857
|
+
candidates.push(Object.freeze({
|
|
1858
|
+
kind: "tracked",
|
|
1859
|
+
mode,
|
|
1860
|
+
path,
|
|
1861
|
+
stage
|
|
1862
|
+
}));
|
|
1863
|
+
}
|
|
1864
|
+
return Object.freeze(candidates);
|
|
1865
|
+
};
|
|
1866
|
+
/** Measures the stdout `ls-files --stage -z` wrote for the index entries. */
|
|
1867
|
+
var measureTrackedOutput = (entries) => entries.reduce((bytes, { path }) => bytes + 75 + countUtf8Bytes(path), 0);
|
|
1868
|
+
/** Measures the stdout `ls-files --others -z` wrote for the untracked paths. */
|
|
1869
|
+
var measureUntrackedOutput = (paths) => paths.reduce((bytes, path) => bytes + countUtf8Bytes(path) + 1, 0);
|
|
1998
1870
|
/** Creates one immutable inventory-probe failure. */
|
|
1999
1871
|
var createProbeFailure = (errorCode) => Object.freeze({
|
|
2000
1872
|
errorCode,
|
|
@@ -2009,99 +1881,78 @@ var resolveParserResult = (parserResult) => {
|
|
|
2009
1881
|
var isProbeFailure = (result) => !Array.isArray(result);
|
|
2010
1882
|
/**
|
|
2011
1883
|
* Creates the strict normalized Git inventory probe around injectable boundaries.
|
|
2012
|
-
* @param
|
|
1884
|
+
* @param git The typed Git reads and command that list raw candidates.
|
|
2013
1885
|
* @param ownershipFilter The submodule and nested-repository ownership filter.
|
|
2014
1886
|
* @param entryTypeNormalizer The current filesystem and Git mode entry-type normalizer.
|
|
2015
1887
|
* @param contentTransformationClassifier The bounded effective Git attribute classifier.
|
|
2016
1888
|
* @param logicalPathNormalizer The portable repository logical-path normalizer.
|
|
2017
1889
|
* @returns An all-or-nothing selected-repository entry probe.
|
|
2018
1890
|
*/
|
|
2019
|
-
var createGitInventoryProbe = (
|
|
1891
|
+
var createGitInventoryProbe = (git = GIT_INVENTORY_LISTING_READS, ownershipFilter = createGitInventoryOwnershipFilter(createGitInventoryBoundaryInspector()), entryTypeNormalizer = createGitInventoryEntryTypeNormalizer(inspectGitInventoryEntry, createGitSymlinkConfigurationResolver()), contentTransformationClassifier = createGitContentTransformationClassifier(), logicalPathNormalizer = normalizeGitInventoryLogicalPaths) => async (input) => {
|
|
2020
1892
|
if (input.signal?.aborted) return createProbeFailure("GIT_OPERATION_ABORTED");
|
|
2021
|
-
const
|
|
2022
|
-
|
|
2023
|
-
const
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
...GIT_TRACKED_INVENTORY_ARGUMENTS,
|
|
2028
|
-
...selectionPathspecs
|
|
2029
|
-
],
|
|
2030
|
-
consumeStdout: (chunk) => trackedParser.consume(chunk),
|
|
2031
|
-
maxStderrBytes: MAX_GIT_PROCESS_DIAGNOSTIC_BYTES,
|
|
2032
|
-
maxStdoutBytes: input.maxMetadataBytes,
|
|
2033
|
-
...input.signal === void 0 ? {} : { signal: input.signal }
|
|
2034
|
-
});
|
|
2035
|
-
if (trackedProcessResult.kind === "failed") return createProbeFailure(mapGitProcessFailure(trackedProcessResult.reason));
|
|
2036
|
-
if (trackedProcessResult.stderr.byteLength > 0) return createProbeFailure("GIT_OUTPUT_INVALID");
|
|
2037
|
-
const trackedCandidates = resolveParserResult(trackedParser.finish());
|
|
2038
|
-
if (isProbeFailure(trackedCandidates)) return trackedCandidates;
|
|
2039
|
-
const untrackedParser = createUntrackedGitInventoryParser(input.maxEntries - trackedCandidates.length);
|
|
2040
|
-
const untrackedProcessResult = await processExecutor({
|
|
2041
|
-
arguments: [
|
|
2042
|
-
"-C",
|
|
2043
|
-
input.repositoryRoot,
|
|
2044
|
-
...GIT_UNTRACKED_INVENTORY_ARGUMENTS,
|
|
2045
|
-
...selectionPathspecs
|
|
2046
|
-
],
|
|
2047
|
-
consumeStdout: (chunk) => untrackedParser.consume(chunk),
|
|
2048
|
-
maxStderrBytes: MAX_GIT_PROCESS_DIAGNOSTIC_BYTES,
|
|
2049
|
-
maxStdoutBytes: input.maxMetadataBytes - trackedProcessResult.stdoutBytes,
|
|
1893
|
+
const selectionPaths = (input.selectionPaths ?? []).map((selectionPath) => selectionPath.slice(1));
|
|
1894
|
+
let remainingMetadataBytes = input.maxMetadataBytes;
|
|
1895
|
+
const createReadOptions = () => ({
|
|
1896
|
+
maxOutputBytes: Math.max(remainingMetadataBytes, 1),
|
|
1897
|
+
timeoutSeconds: 300,
|
|
1898
|
+
...selectionPaths.length === 0 ? {} : { paths: selectionPaths },
|
|
2050
1899
|
...input.signal === void 0 ? {} : { signal: input.signal }
|
|
2051
1900
|
});
|
|
2052
|
-
|
|
2053
|
-
if (
|
|
2054
|
-
|
|
2055
|
-
if (
|
|
1901
|
+
const trackedResult = await readGit(() => git.readIndexEntries(input.repositoryRoot, createReadOptions()), input.signal);
|
|
1902
|
+
if (trackedResult.kind === "failed") return createProbeFailure(mapGitFailure(trackedResult.reason));
|
|
1903
|
+
remainingMetadataBytes -= measureTrackedOutput(trackedResult.value);
|
|
1904
|
+
if (trackedResult.value.length > input.maxEntries || remainingMetadataBytes < 0) return createProbeFailure("RESOURCE_LIMIT_EXCEEDED");
|
|
1905
|
+
const trackedCandidates = toTrackedCandidates(trackedResult.value);
|
|
1906
|
+
if (trackedCandidates === null) return createProbeFailure("GIT_OUTPUT_INVALID");
|
|
1907
|
+
const untrackedResult = await readGit(() => git.listUntrackedFiles(input.repositoryRoot, createReadOptions()), input.signal);
|
|
1908
|
+
if (untrackedResult.kind === "failed") return createProbeFailure(mapGitFailure(untrackedResult.reason));
|
|
1909
|
+
remainingMetadataBytes -= measureUntrackedOutput(untrackedResult.value);
|
|
1910
|
+
if (trackedCandidates.length + untrackedResult.value.length > input.maxEntries || remainingMetadataBytes < 0) return createProbeFailure("RESOURCE_LIMIT_EXCEEDED");
|
|
1911
|
+
if (untrackedResult.value.some((path) => path.length === 0)) return createProbeFailure("GIT_OUTPUT_INVALID");
|
|
1912
|
+
const untrackedCandidates = Object.freeze(untrackedResult.value.map((path) => Object.freeze({
|
|
1913
|
+
kind: "untracked",
|
|
1914
|
+
path
|
|
1915
|
+
})));
|
|
2056
1916
|
let ignoredCandidates = [];
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
arguments: [
|
|
2062
|
-
"-C",
|
|
2063
|
-
input.repositoryRoot,
|
|
2064
|
-
...GIT_IGNORED_INVENTORY_ARGUMENTS,
|
|
2065
|
-
...selectionPathspecs
|
|
2066
|
-
],
|
|
2067
|
-
consumeStdout: (chunk) => ignoredParser.consume(chunk),
|
|
2068
|
-
maxStderrBytes: MAX_GIT_PROCESS_DIAGNOSTIC_BYTES,
|
|
2069
|
-
maxStdoutBytes: input.maxMetadataBytes - trackedProcessResult.stdoutBytes - untrackedProcessResult.stdoutBytes,
|
|
1917
|
+
if (input.includeIgnored === true && selectionPaths.length > 0) {
|
|
1918
|
+
const ignoredResult = await git.runGit([...GIT_IGNORED_INVENTORY_ARGUMENTS, ...selectionPaths], {
|
|
1919
|
+
cwd: input.repositoryRoot,
|
|
1920
|
+
maxOutputBytes: Math.max(remainingMetadataBytes, 1),
|
|
2070
1921
|
...input.signal === void 0 ? {} : { signal: input.signal }
|
|
2071
1922
|
});
|
|
2072
|
-
if (
|
|
2073
|
-
|
|
1923
|
+
if (ignoredResult.kind === "failed") return createProbeFailure(mapGitFailure(ignoredResult.reason));
|
|
1924
|
+
remainingMetadataBytes -= ignoredResult.value.byteLength;
|
|
1925
|
+
if (remainingMetadataBytes < 0) return createProbeFailure("RESOURCE_LIMIT_EXCEEDED");
|
|
1926
|
+
const ignoredParser = createUntrackedGitInventoryParser(input.maxEntries - trackedCandidates.length - untrackedCandidates.length);
|
|
1927
|
+
ignoredParser.consume(ignoredResult.value);
|
|
2074
1928
|
const parsedIgnoredCandidates = resolveParserResult(ignoredParser.finish());
|
|
2075
1929
|
if (isProbeFailure(parsedIgnoredCandidates)) return parsedIgnoredCandidates;
|
|
2076
1930
|
const untrackedPaths = new Set(untrackedCandidates.map((candidate) => candidate.path));
|
|
2077
1931
|
ignoredCandidates = parsedIgnoredCandidates.filter((candidate) => !untrackedPaths.has(candidate.path));
|
|
2078
|
-
ignoredStdoutBytes = ignoredProcessResult.stdoutBytes;
|
|
2079
1932
|
}
|
|
2080
|
-
const
|
|
1933
|
+
const logicalPathFilterResult = filterGitInventoryCandidateLogicalPaths({ candidates: Object.freeze([
|
|
2081
1934
|
...trackedCandidates,
|
|
2082
1935
|
...untrackedCandidates,
|
|
2083
1936
|
...ignoredCandidates
|
|
2084
|
-
]);
|
|
2085
|
-
const metadataBytesAfterListing = input.maxMetadataBytes - trackedProcessResult.stdoutBytes - untrackedProcessResult.stdoutBytes - ignoredStdoutBytes;
|
|
2086
|
-
const logicalPathFilterResult = filterGitInventoryCandidateLogicalPaths({ candidates });
|
|
1937
|
+
]) });
|
|
2087
1938
|
if (logicalPathFilterResult.kind === "failed") return logicalPathFilterResult;
|
|
2088
1939
|
const ownershipResult = await ownershipFilter({
|
|
2089
1940
|
candidates: logicalPathFilterResult.candidates,
|
|
2090
|
-
maxMetadataBytes:
|
|
1941
|
+
maxMetadataBytes: remainingMetadataBytes,
|
|
2091
1942
|
repositoryRoot: input.repositoryRoot,
|
|
2092
1943
|
...input.signal === void 0 ? {} : { signal: input.signal }
|
|
2093
1944
|
});
|
|
2094
1945
|
if (ownershipResult.kind === "failed") return ownershipResult;
|
|
2095
1946
|
const entryTypeResult = await entryTypeNormalizer({
|
|
2096
1947
|
candidates: ownershipResult.candidates,
|
|
2097
|
-
maxMetadataBytes:
|
|
1948
|
+
maxMetadataBytes: remainingMetadataBytes - ownershipResult.gitMetadataBytes,
|
|
2098
1949
|
repositoryRoot: input.repositoryRoot,
|
|
2099
1950
|
...input.signal === void 0 ? {} : { signal: input.signal }
|
|
2100
1951
|
});
|
|
2101
1952
|
if (entryTypeResult.kind === "failed") return entryTypeResult;
|
|
2102
1953
|
const contentTransformationResult = await contentTransformationClassifier({
|
|
2103
1954
|
entries: entryTypeResult.entries,
|
|
2104
|
-
maxMetadataBytes:
|
|
1955
|
+
maxMetadataBytes: remainingMetadataBytes - ownershipResult.gitMetadataBytes - entryTypeResult.gitMetadataBytes,
|
|
2105
1956
|
repositoryRoot: input.repositoryRoot,
|
|
2106
1957
|
...input.signal === void 0 ? {} : { signal: input.signal }
|
|
2107
1958
|
});
|
|
@@ -2675,11 +2526,11 @@ var createMoldeaCliContentExecutionResult = (pageResult, cliVersion, isJson, cur
|
|
|
2675
2526
|
//#region src/cli-execution/command-executor.ts
|
|
2676
2527
|
/** Loads isolated Core inspection only for commands that need it. */
|
|
2677
2528
|
var executeLazyCoreInspection = async (input) => {
|
|
2678
|
-
const { executeMoldeaCliCoreInspection } = await import("./chunks/core-composition-
|
|
2529
|
+
const { executeMoldeaCliCoreInspection } = await import("./chunks/core-composition-ZEZSTBMA.js");
|
|
2679
2530
|
return executeMoldeaCliCoreInspection(input);
|
|
2680
2531
|
};
|
|
2681
2532
|
var loadInstalledComposition = async (input) => {
|
|
2682
|
-
const { resolveInstalledMoldeaCliComposition } = await import("./chunks/composition-
|
|
2533
|
+
const { resolveInstalledMoldeaCliComposition } = await import("./chunks/composition-C2m6SpCI.js");
|
|
2683
2534
|
return resolveInstalledMoldeaCliComposition(input);
|
|
2684
2535
|
};
|
|
2685
2536
|
/** Creates one operational error result without exposing caught failure details. */
|
|
@@ -2909,92 +2760,31 @@ var loadMoldeaCliPackageMetadata = async (packageManifestPath, packageEntryResol
|
|
|
2909
2760
|
});
|
|
2910
2761
|
};
|
|
2911
2762
|
//#endregion
|
|
2912
|
-
//#region src/process-signal/session.ts
|
|
2913
|
-
var SIGNAL_EXIT_CODES = Object.freeze({
|
|
2914
|
-
SIGINT: MOLDEA_CLI_EXIT_CODES.Interrupted,
|
|
2915
|
-
SIGTERM: MOLDEA_CLI_EXIT_CODES.Terminated
|
|
2916
|
-
});
|
|
2917
|
-
var PROCESS_SIGNAL_SOURCE = Object.freeze({
|
|
2918
|
-
addListener: (signal, listener) => {
|
|
2919
|
-
process.on(signal, listener);
|
|
2920
|
-
},
|
|
2921
|
-
removeListener: (signal, listener) => {
|
|
2922
|
-
process.off(signal, listener);
|
|
2923
|
-
},
|
|
2924
|
-
closeIpc: () => {
|
|
2925
|
-
if (process.connected) process.disconnect();
|
|
2926
|
-
},
|
|
2927
|
-
hasDisconnectedLauncher: () => typeof process.send === "function" && !process.connected
|
|
2928
|
-
});
|
|
2929
|
-
/**
|
|
2930
|
-
* Creates one process-signal session around an operation-scoped abort controller.
|
|
2931
|
-
* @param signalSource The process-listener boundary.
|
|
2932
|
-
* @returns A session that records the first signal until output completes.
|
|
2933
|
-
*/
|
|
2934
|
-
var createMoldeaCliProcessSignalSession = (signalSource = PROCESS_SIGNAL_SOURCE) => {
|
|
2935
|
-
const controller = new AbortController();
|
|
2936
|
-
let exitCode = null;
|
|
2937
|
-
let isDisposed = false;
|
|
2938
|
-
let isOutputComplete = false;
|
|
2939
|
-
const handleSignal = (signal) => {
|
|
2940
|
-
if (exitCode !== null || isDisposed || isOutputComplete) return;
|
|
2941
|
-
exitCode = SIGNAL_EXIT_CODES[signal];
|
|
2942
|
-
controller.abort();
|
|
2943
|
-
};
|
|
2944
|
-
const handleSigint = () => handleSignal("SIGINT");
|
|
2945
|
-
const handleSigterm = () => handleSignal("SIGTERM");
|
|
2946
|
-
const handleDisconnect = () => handleSignal("SIGTERM");
|
|
2947
|
-
signalSource.addListener("SIGINT", handleSigint);
|
|
2948
|
-
signalSource.addListener("SIGTERM", handleSigterm);
|
|
2949
|
-
signalSource.addListener("disconnect", handleDisconnect);
|
|
2950
|
-
if (signalSource.hasDisconnectedLauncher()) handleDisconnect();
|
|
2951
|
-
return Object.freeze({
|
|
2952
|
-
completeOutput: () => {
|
|
2953
|
-
isOutputComplete = true;
|
|
2954
|
-
},
|
|
2955
|
-
dispose: () => {
|
|
2956
|
-
if (isDisposed) return;
|
|
2957
|
-
isDisposed = true;
|
|
2958
|
-
signalSource.removeListener("SIGINT", handleSigint);
|
|
2959
|
-
signalSource.removeListener("SIGTERM", handleSigterm);
|
|
2960
|
-
signalSource.removeListener("disconnect", handleDisconnect);
|
|
2961
|
-
signalSource.closeIpc();
|
|
2962
|
-
},
|
|
2963
|
-
get exitCode() {
|
|
2964
|
-
return exitCode;
|
|
2965
|
-
},
|
|
2966
|
-
get hasReceivedSignal() {
|
|
2967
|
-
return exitCode !== null;
|
|
2968
|
-
},
|
|
2969
|
-
signal: controller.signal
|
|
2970
|
-
});
|
|
2971
|
-
};
|
|
2972
|
-
//#endregion
|
|
2973
2763
|
//#region src/bin/index.ts
|
|
2974
2764
|
var executableDirectory = path.dirname(fileURLToPath(import.meta.url));
|
|
2975
2765
|
var packageManifestPath = path.resolve(executableDirectory, "..", "package.json");
|
|
2976
|
-
var
|
|
2977
|
-
|
|
2766
|
+
var shutdown = createShutdownSignal({
|
|
2767
|
+
disconnect: true,
|
|
2768
|
+
setExitCode: false
|
|
2769
|
+
});
|
|
2770
|
+
/** Reads process stdin without retaining bytes above the requested limit. */
|
|
2978
2771
|
var readProcessStdin = async (maxBytes, signal) => {
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2772
|
+
try {
|
|
2773
|
+
return {
|
|
2774
|
+
bytes: await readStdin({
|
|
2775
|
+
maxBytes,
|
|
2776
|
+
signal
|
|
2777
|
+
}),
|
|
2778
|
+
kind: "completed"
|
|
2779
|
+
};
|
|
2780
|
+
} catch (error) {
|
|
2781
|
+
if (hasErrorCode(error, ERRORS.STDIN_TOO_LARGE)) return { kind: "limit-exceeded" };
|
|
2782
|
+
if (signal?.aborted === true) return {
|
|
2983
2783
|
bytes: /* @__PURE__ */ new Uint8Array(),
|
|
2984
2784
|
kind: "completed"
|
|
2985
2785
|
};
|
|
2986
|
-
|
|
2987
|
-
totalBytes += bytes.byteLength;
|
|
2988
|
-
if (totalBytes > maxBytes) {
|
|
2989
|
-
process.stdin.pause();
|
|
2990
|
-
return { kind: "limit-exceeded" };
|
|
2991
|
-
}
|
|
2992
|
-
chunks.push(bytes);
|
|
2786
|
+
throw error;
|
|
2993
2787
|
}
|
|
2994
|
-
return {
|
|
2995
|
-
bytes: Buffer.concat(chunks, totalBytes),
|
|
2996
|
-
kind: "completed"
|
|
2997
|
-
};
|
|
2998
2788
|
};
|
|
2999
2789
|
/**
|
|
3000
2790
|
* Writes one complete process output string.
|
|
@@ -3022,24 +2812,20 @@ try {
|
|
|
3022
2812
|
invocationDirectory,
|
|
3023
2813
|
packageMetadata,
|
|
3024
2814
|
readStdin: readProcessStdin,
|
|
3025
|
-
signal:
|
|
2815
|
+
signal: shutdown.signal
|
|
3026
2816
|
});
|
|
3027
|
-
if (
|
|
3028
|
-
else {
|
|
2817
|
+
if (shutdown.receivedSignal() === null) {
|
|
3029
2818
|
await writeProcessOutput(process.stdout, executionResult.stdout);
|
|
3030
|
-
if (
|
|
3031
|
-
if (!signalSession.hasReceivedSignal) signalSession.completeOutput();
|
|
3032
|
-
process.exitCode = signalSession.exitCode ?? executionResult.exitCode;
|
|
2819
|
+
if (shutdown.receivedSignal() === null) await writeProcessOutput(process.stderr, executionResult.stderr);
|
|
3033
2820
|
}
|
|
2821
|
+
process.exitCode = shutdown.exitCode() ?? executionResult.exitCode;
|
|
3034
2822
|
} catch {
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
signalSession.completeOutput();
|
|
3039
|
-
process.exitCode = 3;
|
|
3040
|
-
}
|
|
2823
|
+
const signalExitCode = shutdown.exitCode();
|
|
2824
|
+
if (signalExitCode === null) await writeProcessOutput(process.stderr, formatMoldeaCliHumanError(createMoldeaCliOwnedError("INTERNAL_ERROR"))).catch(() => void 0);
|
|
2825
|
+
process.exitCode = signalExitCode ?? 3;
|
|
3041
2826
|
} finally {
|
|
3042
|
-
|
|
2827
|
+
shutdown.dispose();
|
|
2828
|
+
if (process.connected) process.disconnect();
|
|
3043
2829
|
}
|
|
3044
2830
|
//#endregion
|
|
3045
2831
|
|