apify-test-tools 0.10.1-beta.2 → 0.10.1-beta.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.
- package/.github/actions/checkout-restore-dependencies/action.yaml +4 -3
- package/.github/workflows/public_platform-tests-claude-investigate-and-fix.yaml +7 -2
- package/.github/workflows/public_platform-tests.yaml +0 -1
- package/.github/workflows-package-version +1 -1
- package/CHANGELOG.md +6 -0
- package/CONTRIBUTING.md +13 -3
- package/README.md +2 -2
- package/bin/build-from-local.ts +8 -7
- package/bin/build.ts +22 -21
- package/bin/diff-changes.ts +11 -10
- package/bin/diff-json-schema.ts +14 -12
- package/bin/git.ts +89 -47
- package/bin/logger.ts +23 -0
- package/bin/main.ts +44 -38
- package/bin/output.ts +6 -0
- package/bin/slack.ts +8 -7
- package/bin/test-report.ts +22 -21
- package/bin/types.ts +0 -1
- package/bin/utils/config/actor-json.ts +84 -0
- package/bin/utils/config/load-config.ts +46 -46
- package/bin/utils/config/parser.ts +33 -28
- package/bin/utils/config/structures/base.ts +7 -0
- package/bin/utils/json-file.ts +11 -14
- package/bin/utils/path/repo-relative.ts +156 -0
- package/bin/utils/path/schema.ts +18 -0
- package/bin/utils.ts +63 -44
- package/dist/bin/build-from-local.d.ts +1 -1
- package/dist/bin/build-from-local.d.ts.map +1 -1
- package/dist/bin/build-from-local.js +8 -7
- package/dist/bin/build-from-local.js.map +1 -1
- package/dist/bin/build.d.ts.map +1 -1
- package/dist/bin/build.js +22 -21
- package/dist/bin/build.js.map +1 -1
- package/dist/bin/diff-changes.d.ts +1 -1
- package/dist/bin/diff-changes.d.ts.map +1 -1
- package/dist/bin/diff-changes.js +9 -8
- package/dist/bin/diff-changes.js.map +1 -1
- package/dist/bin/diff-json-schema.d.ts +1 -1
- package/dist/bin/diff-json-schema.d.ts.map +1 -1
- package/dist/bin/diff-json-schema.js +13 -12
- package/dist/bin/diff-json-schema.js.map +1 -1
- package/dist/bin/git.d.ts +10 -10
- package/dist/bin/git.d.ts.map +1 -1
- package/dist/bin/git.js +78 -37
- package/dist/bin/git.js.map +1 -1
- package/dist/bin/logger.d.ts +11 -0
- package/dist/bin/logger.d.ts.map +1 -0
- package/dist/bin/logger.js +20 -0
- package/dist/bin/logger.js.map +1 -0
- package/dist/bin/main.d.ts +1 -1
- package/dist/bin/main.js +44 -38
- package/dist/bin/main.js.map +1 -1
- package/dist/bin/output.d.ts +3 -0
- package/dist/bin/output.d.ts.map +1 -0
- package/dist/bin/output.js +6 -0
- package/dist/bin/output.js.map +1 -0
- package/dist/bin/slack.d.ts.map +1 -1
- package/dist/bin/slack.js +8 -7
- package/dist/bin/slack.js.map +1 -1
- package/dist/bin/test-report.d.ts.map +1 -1
- package/dist/bin/test-report.js +22 -21
- package/dist/bin/test-report.js.map +1 -1
- package/dist/bin/types.d.ts +0 -1
- package/dist/bin/types.d.ts.map +1 -1
- package/dist/bin/utils/config/actor-json.d.ts +14 -0
- package/dist/bin/utils/config/actor-json.d.ts.map +1 -0
- package/dist/bin/utils/config/actor-json.js +60 -0
- package/dist/bin/utils/config/actor-json.js.map +1 -0
- package/dist/bin/utils/config/load-config.d.ts +12 -2
- package/dist/bin/utils/config/load-config.d.ts.map +1 -1
- package/dist/bin/utils/config/load-config.js +32 -31
- package/dist/bin/utils/config/load-config.js.map +1 -1
- package/dist/bin/utils/config/parser.d.ts +4 -12
- package/dist/bin/utils/config/parser.d.ts.map +1 -1
- package/dist/bin/utils/config/parser.js +24 -23
- package/dist/bin/utils/config/parser.js.map +1 -1
- package/dist/bin/utils/config/structures/base.d.ts +5 -0
- package/dist/bin/utils/config/structures/base.d.ts.map +1 -1
- package/dist/bin/utils/config/structures/base.js.map +1 -1
- package/dist/bin/utils/json-file.d.ts +3 -2
- package/dist/bin/utils/json-file.d.ts.map +1 -1
- package/dist/bin/utils/json-file.js +8 -13
- package/dist/bin/utils/json-file.js.map +1 -1
- package/dist/bin/utils/path/repo-relative.d.ts +35 -0
- package/dist/bin/utils/path/repo-relative.d.ts.map +1 -0
- package/dist/bin/utils/path/repo-relative.js +137 -0
- package/dist/bin/utils/path/repo-relative.js.map +1 -0
- package/dist/bin/utils/path/schema.d.ts +7 -0
- package/dist/bin/utils/path/schema.d.ts.map +1 -0
- package/dist/bin/utils/path/schema.js +16 -0
- package/dist/bin/utils/path/schema.js.map +1 -0
- package/dist/bin/utils.d.ts +14 -6
- package/dist/bin/utils.d.ts.map +1 -1
- package/dist/bin/utils.js +52 -36
- package/dist/bin/utils.js.map +1 -1
- package/dist/test/unit/bin/build-from-local.test.js +4 -40
- package/dist/test/unit/bin/build-from-local.test.js.map +1 -1
- package/dist/test/unit/bin/diff-changes.test.js +97 -96
- package/dist/test/unit/bin/diff-changes.test.js.map +1 -1
- package/dist/test/unit/bin/diff.test.js +52 -48
- package/dist/test/unit/bin/diff.test.js.map +1 -1
- package/dist/test/unit/bin/git-command.test.d.ts +2 -0
- package/dist/test/unit/bin/git-command.test.d.ts.map +1 -0
- package/dist/test/unit/bin/git-command.test.js +54 -0
- package/dist/test/unit/bin/git-command.test.js.map +1 -0
- package/dist/test/unit/bin/git.test.js +211 -94
- package/dist/test/unit/bin/git.test.js.map +1 -1
- package/dist/test/unit/bin/logger.test.d.ts +2 -0
- package/dist/test/unit/bin/logger.test.d.ts.map +1 -0
- package/dist/test/unit/bin/logger.test.js +44 -0
- package/dist/test/unit/bin/logger.test.js.map +1 -0
- package/dist/test/unit/bin/logging.test.d.ts +2 -0
- package/dist/test/unit/bin/logging.test.d.ts.map +1 -0
- package/dist/test/unit/bin/logging.test.js +43 -0
- package/dist/test/unit/bin/logging.test.js.map +1 -0
- package/dist/test/unit/bin/utils/config/load-config.test.js +47 -25
- package/dist/test/unit/bin/utils/config/load-config.test.js.map +1 -1
- package/dist/test/unit/bin/utils/config/parser.test.js +64 -19
- package/dist/test/unit/bin/utils/config/parser.test.js.map +1 -1
- package/dist/test/unit/bin/utils/files.test.js +16 -27
- package/dist/test/unit/bin/utils/files.test.js.map +1 -1
- package/dist/test/unit/bin/utils/path/repo-relative.test.d.ts +2 -0
- package/dist/test/unit/bin/utils/path/repo-relative.test.d.ts.map +1 -0
- package/dist/test/unit/bin/utils/path/repo-relative.test.js +196 -0
- package/dist/test/unit/bin/utils/path/repo-relative.test.js.map +1 -0
- package/dist/test/unit/bin/utils/path/schema.test.d.ts +2 -0
- package/dist/test/unit/bin/utils/path/schema.test.d.ts.map +1 -0
- package/dist/test/unit/bin/utils/path/schema.test.js +52 -0
- package/dist/test/unit/bin/utils/path/schema.test.js.map +1 -0
- package/dist/test/unit/should-built-and-test.test.js +40 -38
- package/dist/test/unit/should-built-and-test.test.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/eslint.config.mjs +9 -1
- package/package.json +5 -5
- package/test/unit/bin/build-from-local.test.ts +4 -54
- package/test/unit/bin/diff-changes.test.ts +97 -96
- package/test/unit/bin/diff.test.ts +53 -48
- package/test/unit/bin/git-command.test.ts +71 -0
- package/test/unit/bin/git.test.ts +246 -91
- package/test/unit/bin/logger.test.ts +55 -0
- package/test/unit/bin/logging.test.ts +52 -0
- package/test/unit/bin/utils/config/load-config.test.ts +63 -26
- package/test/unit/bin/utils/config/parser.test.ts +81 -27
- package/test/unit/bin/utils/files.test.ts +19 -33
- package/test/unit/bin/utils/path/repo-relative.test.ts +250 -0
- package/test/unit/bin/utils/path/schema.test.ts +65 -0
- package/test/unit/should-built-and-test.test.ts +40 -38
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import z from 'zod';
|
|
2
|
-
import {
|
|
2
|
+
import { ExistingDirSchema, RelativeDirSchema } from '../path/schema.js';
|
|
3
|
+
import { CONFIG_FILE_STRATEGY, } from './structures/base.js';
|
|
3
4
|
import { GROUPED_PARSER } from './structures/grouped.js';
|
|
4
5
|
import { LEGACY_PARSER } from './structures/legacy.js';
|
|
5
6
|
const CONFIG_FILE_STRATEGIES = {
|
|
@@ -21,31 +22,32 @@ const normalizeFolder = (folder) => {
|
|
|
21
22
|
const stripped = stripTrailingSlash(folder);
|
|
22
23
|
return stripped === '.' ? '' : stripped;
|
|
23
24
|
};
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
* @throws Error listing every problem found.
|
|
32
|
-
*/
|
|
25
|
+
const ValidatedConfigSchema = z.array(z.object({
|
|
26
|
+
actorFullName: z.string(),
|
|
27
|
+
folder: ExistingDirSchema,
|
|
28
|
+
tokenEnvVar: z.string(),
|
|
29
|
+
overrideActorContext: z.array(RelativeDirSchema).optional(),
|
|
30
|
+
}));
|
|
31
|
+
/** Normalize and validate paths, then check collisions using their final spelling. */
|
|
33
32
|
function verifyConfiguration(body) {
|
|
34
|
-
const seenFolders = new Set();
|
|
35
|
-
const seenActorFullNames = new Set();
|
|
36
|
-
const errors = [];
|
|
37
33
|
const normalized = body.map((entry) => ({
|
|
38
34
|
...entry,
|
|
39
35
|
folder: normalizeFolder(entry.folder),
|
|
40
36
|
overrideActorContext: entry.overrideActorContext?.map(stripTrailingSlash),
|
|
41
37
|
}));
|
|
42
|
-
|
|
38
|
+
const parsed = ValidatedConfigSchema.safeParse(normalized);
|
|
39
|
+
if (!parsed.success)
|
|
40
|
+
throw new Error(z.prettifyError(parsed.error));
|
|
41
|
+
const seenFolders = new Set();
|
|
42
|
+
const seenActorFullNames = new Set();
|
|
43
|
+
const errors = [];
|
|
44
|
+
for (const [index, entry] of parsed.data.entries()) {
|
|
43
45
|
// TODO: drop folder uniqueness (this requires several changes on other places)
|
|
44
|
-
if (seenFolders.has(entry.folder)) {
|
|
46
|
+
if (seenFolders.has(entry.folder.path)) {
|
|
45
47
|
errors.push(`Duplicate folder "${body[index].folder}". Each actor must have a unique folder.`);
|
|
46
48
|
}
|
|
47
49
|
else {
|
|
48
|
-
seenFolders.add(entry.folder);
|
|
50
|
+
seenFolders.add(entry.folder.path);
|
|
49
51
|
}
|
|
50
52
|
if (seenActorFullNames.has(entry.actorFullName)) {
|
|
51
53
|
errors.push(`Duplicate actor "${entry.actorFullName}". Each entry must point at a different actor.`);
|
|
@@ -54,10 +56,9 @@ function verifyConfiguration(body) {
|
|
|
54
56
|
seenActorFullNames.add(entry.actorFullName);
|
|
55
57
|
}
|
|
56
58
|
}
|
|
57
|
-
if (errors.length > 0)
|
|
59
|
+
if (errors.length > 0)
|
|
58
60
|
throw new Error(errors.join('\n'));
|
|
59
|
-
|
|
60
|
-
return normalized;
|
|
61
|
+
return parsed.data;
|
|
61
62
|
}
|
|
62
63
|
// eslint-disable-next-line no-underscore-dangle
|
|
63
64
|
export const _privates = {
|
|
@@ -65,9 +66,9 @@ export const _privates = {
|
|
|
65
66
|
verifyConfiguration,
|
|
66
67
|
};
|
|
67
68
|
export function parseConfigFile(body) {
|
|
68
|
-
const
|
|
69
|
-
const
|
|
70
|
-
const
|
|
71
|
-
return
|
|
69
|
+
const { mode, ...rest } = body;
|
|
70
|
+
const strategy = selectStrategy({ mode });
|
|
71
|
+
const resolved = strategy.parse(rest);
|
|
72
|
+
return verifyConfiguration(resolved);
|
|
72
73
|
}
|
|
73
74
|
//# sourceMappingURL=parser.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../../../../bin/utils/config/parser.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AAEpB,OAAO,EAAE,oBAAoB,
|
|
1
|
+
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../../../../bin/utils/config/parser.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AAEpB,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EACH,oBAAoB,GAIvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC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,CAAC,CAAC;QACzG,CAAC;aAAM,CAAC;YACJ,kBAAkB,CAAC,GAAG,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;QAChD,CAAC;IACL,CAAC;IAED,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAC1D,OAAO,MAAM,CAAC,IAAI,CAAC;AACvB,CAAC;AAED,gDAAgD;AAChD,MAAM,CAAC,MAAM,SAAS,GAAG;IACrB,cAAc;IACd,mBAAmB;CACtB,CAAC;AAEF,MAAM,UAAU,eAAe,CAAC,IAA6B;IACzD,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC;IAC/B,MAAM,QAAQ,GAAG,cAAc,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;IAE1C,MAAM,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACtC,OAAO,mBAAmB,CAAC,QAAQ,CAAC,CAAC;AACzC,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type ZodType } from 'zod';
|
|
2
|
+
import type { ExistingDir, RelativeDir } from '../../path/repo-relative.js';
|
|
2
3
|
export declare const ACTOR_FULL_NAME_REGEX: RegExp;
|
|
3
4
|
export interface ResolvedActorConfig {
|
|
4
5
|
actorFullName: string;
|
|
@@ -6,6 +7,10 @@ export interface ResolvedActorConfig {
|
|
|
6
7
|
tokenEnvVar: string;
|
|
7
8
|
overrideActorContext: string[] | undefined;
|
|
8
9
|
}
|
|
10
|
+
export interface ValidatedActorConfig extends Omit<ResolvedActorConfig, 'folder' | 'overrideActorContext'> {
|
|
11
|
+
folder: ExistingDir;
|
|
12
|
+
overrideActorContext?: RelativeDir[];
|
|
13
|
+
}
|
|
9
14
|
export declare enum CONFIG_FILE_STRATEGY {
|
|
10
15
|
LEGACY = "legacy",
|
|
11
16
|
GROUPED = "grouped"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../../../bin/utils/config/structures/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,OAAO,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../../../bin/utils/config/structures/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,OAAO,EAAE,MAAM,KAAK,CAAC;AAIlD,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAM5E,eAAO,MAAM,qBAAqB,QAGjC,CAAC;AAKF,MAAM,WAAW,mBAAmB;IAChC,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,oBAAoB,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;CAC9C;AAED,MAAM,WAAW,oBAAqB,SAAQ,IAAI,CAAC,mBAAmB,EAAE,QAAQ,GAAG,sBAAsB,CAAC;IACtG,MAAM,EAAE,WAAW,CAAC;IACpB,oBAAoB,CAAC,EAAE,WAAW,EAAE,CAAC;CACxC;AAED,oBAAY,oBAAoB;IAC5B,MAAM,WAAW;IACjB,OAAO,YAAY;CACtB;AAED,MAAM,MAAM,cAAc,GAAG;IACzB,IAAI,EAAE,oBAAoB,CAAC;IAC3B,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,mBAAmB,EAAE,CAAC;CACnE,CAAC;AAEF,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,SAAS,oBAAoB,EAE/F,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,EAClB,OAAO,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,mBAAmB,EAAE;;IAIvC;;;;;;;;;;;;;;OAcG;kBACW,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;EAQ5C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../../../../bin/utils/config/structures/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAgB,MAAM,KAAK,CAAC;AAElD,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../../../../bin/utils/config/structures/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAgB,MAAM,KAAK,CAAC;AAElD,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAIrD,SAAS,gBAAgB,CAAC,KAAa;IACnC,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AACvD,CAAC;AAED,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,MAAM,CAC3C,IAAI,gBAAgB,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,gBAAgB,CAAC,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,EAC3F,QAAQ,CAAC,KAAK,CAAC,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,KAAK,CAChD,CAAC;AAiBF,MAAM,CAAN,IAAY,oBAGX;AAHD,WAAY,oBAAoB;IAC5B,yCAAiB,CAAA;IACjB,2CAAmB,CAAA;AACvB,CAAC,EAHW,oBAAoB,KAApB,oBAAoB,QAG/B;AAOD,MAAM,UAAU,cAAc;AAC1B,mEAAmE;AACnE,IAAU,EACV,MAAkB,EAClB,OAA2C;IAE3C,OAAO;QACH,IAAI;QACJ;;;;;;;;;;;;;;WAcG;QACH,KAAK,EAAE,CAAC,IAA6B,EAAE,EAAE;YACrC,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;YACtC,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;gBACjB,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YAChC,CAAC;YACD,MAAM,IAAI,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QACjD,CAAC;KACJ,CAAC;AACN,CAAC"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import type { ExistingFile } from './path/repo-relative.js';
|
|
1
2
|
/**
|
|
2
3
|
* Why a JSON object could not be produced from a path. Callers that already have their own
|
|
3
4
|
* user-facing wording (e.g. the config file reader) switch on this instead of re-deriving the
|
|
4
5
|
* cause from an error message.
|
|
5
6
|
*/
|
|
6
|
-
export type JsonObjectReadFailureReason = '
|
|
7
|
+
export type JsonObjectReadFailureReason = 'unreadable' | 'invalid-json' | 'not-an-object';
|
|
7
8
|
export type JsonObjectReadResult = {
|
|
8
9
|
success: true;
|
|
9
10
|
contents: Record<string, unknown>;
|
|
@@ -16,5 +17,5 @@ export type JsonObjectReadResult = {
|
|
|
16
17
|
* Reads a file and parses it as a JSON object, reporting every way that can go wrong as a value
|
|
17
18
|
* instead of a thrown error — the caller decides which failures are fatal and how to word them.
|
|
18
19
|
*/
|
|
19
|
-
export declare function safeReadJsonObjectFile(
|
|
20
|
+
export declare function safeReadJsonObjectFile(filePath: ExistingFile): JsonObjectReadResult;
|
|
20
21
|
//# sourceMappingURL=json-file.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-file.d.ts","sourceRoot":"","sources":["../../../bin/utils/json-file.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,MAAM,2BAA2B,GAAG,YAAY,GAAG,
|
|
1
|
+
{"version":3,"file":"json-file.d.ts","sourceRoot":"","sources":["../../../bin/utils/json-file.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAE5D;;;;GAIG;AACH,MAAM,MAAM,2BAA2B,GAAG,YAAY,GAAG,cAAc,GAAG,eAAe,CAAC;AAE1F,MAAM,MAAM,oBAAoB,GAC1B;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,GACpD;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,2BAA2B,CAAC;IAAC,OAAO,EAAE,KAAK,CAAA;CAAE,CAAC;AAQ9E;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,YAAY,GAAG,oBAAoB,CA0BnF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { readFileSync
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
2
|
const failed = (reason, message) => ({
|
|
3
3
|
success: false,
|
|
4
4
|
reason,
|
|
@@ -8,34 +8,29 @@ const failed = (reason, message) => ({
|
|
|
8
8
|
* Reads a file and parses it as a JSON object, reporting every way that can go wrong as a value
|
|
9
9
|
* instead of a thrown error — the caller decides which failures are fatal and how to word them.
|
|
10
10
|
*/
|
|
11
|
-
export function safeReadJsonObjectFile(
|
|
11
|
+
export function safeReadJsonObjectFile(filePath) {
|
|
12
12
|
let file;
|
|
13
13
|
try {
|
|
14
|
-
|
|
15
|
-
const stats = statSync(path);
|
|
16
|
-
if (!stats.isFile()) {
|
|
17
|
-
return failed('not-a-file', `Expected ${path} to be a file`);
|
|
18
|
-
}
|
|
19
|
-
file = readFileSync(path, 'utf8');
|
|
14
|
+
file = readFileSync(filePath.path, 'utf8');
|
|
20
15
|
}
|
|
21
16
|
catch {
|
|
22
|
-
return failed('unreadable', `Expected ${
|
|
17
|
+
return failed('unreadable', `Expected ${filePath} to exist or be readable`);
|
|
23
18
|
}
|
|
24
19
|
let parsed;
|
|
25
20
|
try {
|
|
26
21
|
parsed = JSON.parse(file);
|
|
27
22
|
}
|
|
28
23
|
catch (err) {
|
|
29
|
-
return failed('invalid-json', `Failed to parse ${
|
|
24
|
+
return failed('invalid-json', `Failed to parse ${filePath}: ${err}`);
|
|
30
25
|
}
|
|
31
26
|
if (parsed === null) {
|
|
32
|
-
return failed('not-an-object', `Expected ${
|
|
27
|
+
return failed('not-an-object', `Expected ${filePath} to be a JSON object, not null`);
|
|
33
28
|
}
|
|
34
29
|
if (Array.isArray(parsed)) {
|
|
35
|
-
return failed('not-an-object', `Expected ${
|
|
30
|
+
return failed('not-an-object', `Expected ${filePath} to be a JSON object, not an array`);
|
|
36
31
|
}
|
|
37
32
|
if (typeof parsed !== 'object') {
|
|
38
|
-
return failed('not-an-object', `Expected ${
|
|
33
|
+
return failed('not-an-object', `Expected ${filePath} to be a JSON object`);
|
|
39
34
|
}
|
|
40
35
|
return { success: true, contents: parsed };
|
|
41
36
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-file.js","sourceRoot":"","sources":["../../../bin/utils/json-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"json-file.js","sourceRoot":"","sources":["../../../bin/utils/json-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAevC,MAAM,MAAM,GAAG,CAAC,MAAmC,EAAE,OAAe,EAAwB,EAAE,CAAC,CAAC;IAC5F,OAAO,EAAE,KAAK;IACd,MAAM;IACN,OAAO,EAAE,IAAI,KAAK,CAAC,OAAO,CAAC;CAC9B,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CAAC,QAAsB;IACzD,IAAI,IAAY,CAAC;IACjB,IAAI,CAAC;QACD,IAAI,GAAG,YAAY,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAC/C,CAAC;IAAC,MAAM,CAAC;QACL,OAAO,MAAM,CAAC,YAAY,EAAE,YAAY,QAAQ,0BAA0B,CAAC,CAAC;IAChF,CAAC;IAED,IAAI,MAAe,CAAC;IACpB,IAAI,CAAC;QACD,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACX,OAAO,MAAM,CAAC,cAAc,EAAE,mBAAmB,QAAQ,KAAK,GAAG,EAAE,CAAC,CAAC;IACzE,CAAC;IAED,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QAClB,OAAO,MAAM,CAAC,eAAe,EAAE,YAAY,QAAQ,gCAAgC,CAAC,CAAC;IACzF,CAAC;IACD,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QACxB,OAAO,MAAM,CAAC,eAAe,EAAE,YAAY,QAAQ,oCAAoC,CAAC,CAAC;IAC7F,CAAC;IACD,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC7B,OAAO,MAAM,CAAC,eAAe,EAAE,YAAY,QAAQ,sBAAsB,CAAC,CAAC;IAC/E,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAiC,EAAE,CAAC;AAC1E,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export declare abstract class AbstractPath {
|
|
2
|
+
#private;
|
|
3
|
+
constructor(rawPath: string);
|
|
4
|
+
isEqualTo(other: AbstractPath): boolean;
|
|
5
|
+
get path(): string;
|
|
6
|
+
toString(): string;
|
|
7
|
+
toJSON(): string;
|
|
8
|
+
private assertNoEscape;
|
|
9
|
+
}
|
|
10
|
+
export declare class RelativeDir extends AbstractPath {
|
|
11
|
+
static readonly ROOT: RelativeDir;
|
|
12
|
+
joinDir(relativePath: string): RelativeDir;
|
|
13
|
+
joinFile(relativePath: string): RelativeFile;
|
|
14
|
+
contains(other: AbstractPath): boolean;
|
|
15
|
+
isStrictAncestorOf(other: AbstractPath): boolean;
|
|
16
|
+
assertIsDir(): this;
|
|
17
|
+
private join;
|
|
18
|
+
}
|
|
19
|
+
export declare class ExistingDir extends RelativeDir {
|
|
20
|
+
constructor(rawPath: string);
|
|
21
|
+
static initialize(dir: RelativeDir): ExistingDir;
|
|
22
|
+
}
|
|
23
|
+
export declare class RelativeFile extends AbstractPath {
|
|
24
|
+
constructor(rawPath: string);
|
|
25
|
+
get parent(): RelativeDir;
|
|
26
|
+
joinDir(relativePath: string): RelativeDir;
|
|
27
|
+
joinFile(relativePath: string): RelativeFile;
|
|
28
|
+
isWithin(scope: RelativeDir): boolean;
|
|
29
|
+
assertIsFile(): this;
|
|
30
|
+
}
|
|
31
|
+
export declare class ExistingFile extends RelativeFile {
|
|
32
|
+
constructor(rawPath: string);
|
|
33
|
+
static initialize(file: RelativeFile): ExistingFile;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=repo-relative.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repo-relative.d.ts","sourceRoot":"","sources":["../../../../bin/utils/path/repo-relative.ts"],"names":[],"mappings":"AAgBA,8BAAsB,YAAY;;gBAElB,OAAO,EAAE,MAAM;IAW3B,SAAS,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO;IAMvC,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,QAAQ,IAAI,MAAM;IAIlB,MAAM,IAAI,MAAM;IAIhB,OAAO,CAAC,cAAc;CAKzB;AAED,qBAAa,WAAY,SAAQ,YAAY;IACzC,MAAM,CAAC,QAAQ,CAAC,IAAI,cAAwB;IAE5C,OAAO,CAAC,YAAY,EAAE,MAAM,GAAG,WAAW;IAI1C,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,YAAY;IAO5C,QAAQ,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO;IAMtC,kBAAkB,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO;IAOhD,WAAW,IAAI,IAAI;IAQnB,OAAO,CAAC,IAAI;CAOf;AAED,qBAAa,WAAY,SAAQ,WAAW;gBAC5B,OAAO,EAAE,MAAM;IAK3B,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,WAAW,GAAG,WAAW;CAGnD;AAED,qBAAa,YAAa,SAAQ,YAAY;gBAC9B,OAAO,EAAE,MAAM;IAM3B,IAAI,MAAM,IAAI,WAAW,CAExB;IAID,OAAO,CAAC,YAAY,EAAE,MAAM,GAAG,WAAW;IAK1C,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,YAAY;IAI5C,QAAQ,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO;IAMrC,YAAY,IAAI,IAAI;CAOvB;AAED,qBAAa,YAAa,SAAQ,YAAY;gBAC9B,OAAO,EAAE,MAAM;IAK3B,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,YAAY,GAAG,YAAY;CAGtD"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/* eslint-disable max-classes-per-file */
|
|
2
|
+
import { statSync } from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
// Git and the config file always use "/", so paths are POSIX regardless of the host OS.
|
|
5
|
+
const { posix } = path;
|
|
6
|
+
// A file path cannot end in "/", ".", "..", or be empty: each of those names a directory.
|
|
7
|
+
const assertNamesFile = (rawPath) => {
|
|
8
|
+
const lastSegment = rawPath.slice(rawPath.lastIndexOf('/') + 1);
|
|
9
|
+
if (lastSegment === '' || lastSegment === '.' || lastSegment === '..') {
|
|
10
|
+
throw new Error(`Expected a file path, got directory path "${rawPath}".`);
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
// Shared by the file and directory paths. Use it as a parameter type where either kind is fine.
|
|
14
|
+
export class AbstractPath {
|
|
15
|
+
#path;
|
|
16
|
+
constructor(rawPath) {
|
|
17
|
+
if (posix.isAbsolute(rawPath)) {
|
|
18
|
+
throw new Error(`Expected a relative path, got absolute path "${rawPath}".`);
|
|
19
|
+
}
|
|
20
|
+
const normalized = posix.normalize(rawPath);
|
|
21
|
+
// normalize keeps a trailing slash ("actors/foo/"), which would make equal paths compare unequal.
|
|
22
|
+
this.#path = normalized.endsWith('/') ? normalized.slice(0, -1) : normalized;
|
|
23
|
+
this.assertNoEscape(rawPath);
|
|
24
|
+
}
|
|
25
|
+
// A file and a directory are never equal, even when spelled the same.
|
|
26
|
+
isEqualTo(other) {
|
|
27
|
+
// inheritance safe check, at least one of the two is a subclass of the other
|
|
28
|
+
const isRelativeOf = this instanceof other.constructor || other instanceof this.constructor;
|
|
29
|
+
return isRelativeOf && this.#path === other.#path;
|
|
30
|
+
}
|
|
31
|
+
get path() {
|
|
32
|
+
return this.#path;
|
|
33
|
+
}
|
|
34
|
+
toString() {
|
|
35
|
+
return this.path;
|
|
36
|
+
}
|
|
37
|
+
toJSON() {
|
|
38
|
+
return this.path;
|
|
39
|
+
}
|
|
40
|
+
assertNoEscape(raw) {
|
|
41
|
+
if (this.#path === '..' || this.#path.startsWith('../')) {
|
|
42
|
+
throw new Error(`Path "${raw}" escapes the repo root.`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
export class RelativeDir extends AbstractPath {
|
|
47
|
+
static ROOT = new RelativeDir('.');
|
|
48
|
+
joinDir(relativePath) {
|
|
49
|
+
return new RelativeDir(this.join(relativePath));
|
|
50
|
+
}
|
|
51
|
+
joinFile(relativePath) {
|
|
52
|
+
// Must be checked before joining: posix.join('actors/foo', '.') is "actors/foo", which looks like a file.
|
|
53
|
+
assertNamesFile(relativePath);
|
|
54
|
+
return new RelativeFile(this.join(relativePath));
|
|
55
|
+
}
|
|
56
|
+
// True when `other` is this directory itself or lies inside it.
|
|
57
|
+
contains(other) {
|
|
58
|
+
// the root contains every path
|
|
59
|
+
if (this.path === '.')
|
|
60
|
+
return true;
|
|
61
|
+
return this.isEqualTo(other) || other.path.startsWith(`${this.path}/`);
|
|
62
|
+
}
|
|
63
|
+
isStrictAncestorOf(other) {
|
|
64
|
+
// you are not an ancestor of yourself
|
|
65
|
+
return !this.isEqualTo(other) && this.contains(other);
|
|
66
|
+
}
|
|
67
|
+
// Throws unless this path exists and is a directory. Paths resolve against the process working
|
|
68
|
+
// directory, which is the repo root.
|
|
69
|
+
assertIsDir() {
|
|
70
|
+
// `stat`, not `lstat`: a symlink must resolve to its target, matching what reading it does.
|
|
71
|
+
const stats = statSync(this.path, { throwIfNoEntry: false });
|
|
72
|
+
if (!stats)
|
|
73
|
+
throw new Error(`Expected directory "${this}" to exist.`);
|
|
74
|
+
if (!stats.isDirectory())
|
|
75
|
+
throw new Error(`Expected "${this}" to be a directory.`);
|
|
76
|
+
return this;
|
|
77
|
+
}
|
|
78
|
+
join(relativePath) {
|
|
79
|
+
// Must be checked here: posix.join('.', '/etc') is "etc", so the constructor would not catch it.
|
|
80
|
+
if (posix.isAbsolute(relativePath)) {
|
|
81
|
+
throw new Error(`Expected a relative path to join with "${this}", got absolute path "${relativePath}".`);
|
|
82
|
+
}
|
|
83
|
+
return posix.join(this.path, relativePath);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
export class ExistingDir extends RelativeDir {
|
|
87
|
+
constructor(rawPath) {
|
|
88
|
+
super(rawPath);
|
|
89
|
+
this.assertIsDir();
|
|
90
|
+
}
|
|
91
|
+
static initialize(dir) {
|
|
92
|
+
return new ExistingDir(dir.path);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
export class RelativeFile extends AbstractPath {
|
|
96
|
+
constructor(rawPath) {
|
|
97
|
+
assertNamesFile(rawPath);
|
|
98
|
+
super(rawPath);
|
|
99
|
+
}
|
|
100
|
+
// The directory containing this file.
|
|
101
|
+
get parent() {
|
|
102
|
+
return new RelativeDir(posix.dirname(this.path));
|
|
103
|
+
}
|
|
104
|
+
// Resolves against the file's directory, the way a path written inside the file is meant
|
|
105
|
+
// (e.g. `dockerContextDir: ".."` in `.actor/actor.json` is the actor folder).
|
|
106
|
+
joinDir(relativePath) {
|
|
107
|
+
return this.parent.joinDir(relativePath);
|
|
108
|
+
}
|
|
109
|
+
// Resolves against the file's directory, e.g. a sibling file.
|
|
110
|
+
joinFile(relativePath) {
|
|
111
|
+
return this.parent.joinFile(relativePath);
|
|
112
|
+
}
|
|
113
|
+
isWithin(scope) {
|
|
114
|
+
return scope.contains(this);
|
|
115
|
+
}
|
|
116
|
+
// Throws unless this path exists and is a file. Paths resolve against the process working
|
|
117
|
+
// directory, which is the repo root.
|
|
118
|
+
assertIsFile() {
|
|
119
|
+
// `stat`, not `lstat`: a symlink must resolve to its target, matching what reading it does.
|
|
120
|
+
const stats = statSync(this.path, { throwIfNoEntry: false });
|
|
121
|
+
if (!stats)
|
|
122
|
+
throw new Error(`Expected file "${this}" to exist.`);
|
|
123
|
+
if (!stats.isFile())
|
|
124
|
+
throw new Error(`Expected "${this}" to be a file.`);
|
|
125
|
+
return this;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
export class ExistingFile extends RelativeFile {
|
|
129
|
+
constructor(rawPath) {
|
|
130
|
+
super(rawPath);
|
|
131
|
+
this.assertIsFile();
|
|
132
|
+
}
|
|
133
|
+
static initialize(file) {
|
|
134
|
+
return new ExistingFile(file.path);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=repo-relative.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repo-relative.js","sourceRoot":"","sources":["../../../../bin/utils/path/repo-relative.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,wFAAwF;AACxF,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;AAEvB,0FAA0F;AAC1F,MAAM,eAAe,GAAG,CAAC,OAAe,EAAQ,EAAE;IAC9C,MAAM,WAAW,GAAG,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAA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;IAChC,CAAC;IAED,0FAA0F;IAC1F,qCAAqC;IACrC,YAAY;QACR,4FAA4F;QAC5F,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC,CAAC;QAC7D,IAAI,CAAC,KAAK;YAAE,MAAM,IAAI,KAAK,CAAC,kBAAkB,IAAI,aAAa,CAAC,CAAC;QACjE,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;YAAE,MAAM,IAAI,KAAK,CAAC,aAAa,IAAI,iBAAiB,CAAC,CAAC;QACzE,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AAED,MAAM,OAAO,YAAa,SAAQ,YAAY;IAC1C,YAAY,OAAe;QACvB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,YAAY,EAAE,CAAC;IACxB,CAAC;IAED,MAAM,CAAC,UAAU,CAAC,IAAkB;QAChC,OAAO,IAAI,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACvC,CAAC;CACJ"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
import { ExistingDir, ExistingFile, RelativeDir, RelativeFile } from './repo-relative.js';
|
|
3
|
+
export declare const RelativeDirSchema: z.ZodPipe<z.ZodString, z.ZodTransform<RelativeDir, string>>;
|
|
4
|
+
export declare const ExistingDirSchema: z.ZodPipe<z.ZodString, z.ZodTransform<ExistingDir, string>>;
|
|
5
|
+
export declare const RelativeFileSchema: z.ZodPipe<z.ZodString, z.ZodTransform<RelativeFile, string>>;
|
|
6
|
+
export declare const ExistingFileSchema: z.ZodPipe<z.ZodString, z.ZodTransform<ExistingFile, string>>;
|
|
7
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../bin/utils/path/schema.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AAEpB,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAY1F,eAAO,MAAM,iBAAiB,6DAA+C,CAAC;AAC9E,eAAO,MAAM,iBAAiB,6DAA+C,CAAC;AAC9E,eAAO,MAAM,kBAAkB,8DAAgD,CAAC;AAChF,eAAO,MAAM,kBAAkB,8DAAgD,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
import { ExistingDir, ExistingFile, RelativeDir, RelativeFile } from './repo-relative.js';
|
|
3
|
+
const parsePath = (construct) => z.string().transform((value, ctx) => {
|
|
4
|
+
try {
|
|
5
|
+
return construct(value);
|
|
6
|
+
}
|
|
7
|
+
catch (error) {
|
|
8
|
+
ctx.addIssue({ code: 'custom', message: error instanceof Error ? error.message : String(error) });
|
|
9
|
+
return z.NEVER;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
export const RelativeDirSchema = parsePath((value) => new RelativeDir(value));
|
|
13
|
+
export const ExistingDirSchema = parsePath((value) => new ExistingDir(value));
|
|
14
|
+
export const RelativeFileSchema = parsePath((value) => new RelativeFile(value));
|
|
15
|
+
export const ExistingFileSchema = parsePath((value) => new ExistingFile(value));
|
|
16
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../../bin/utils/path/schema.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AAEpB,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAE1F,MAAM,SAAS,GAAG,CAAI,SAA+B,EAAE,EAAE,CACrD,CAAC,CAAC,MAAM,EAAE,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,GAAG,EAAsB,EAAE;IACpD,IAAI,CAAC;QACD,OAAO,SAAS,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,GAAG,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAClG,OAAO,CAAC,CAAC,KAAK,CAAC;IACnB,CAAC;AACL,CAAC,CAAC,CAAC;AAEP,MAAM,CAAC,MAAM,iBAAiB,GAAG,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC;AAC9E,MAAM,CAAC,MAAM,iBAAiB,GAAG,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC;AAC9E,MAAM,CAAC,MAAM,kBAAkB,GAAG,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC;AAChF,MAAM,CAAC,MAAM,kBAAkB,GAAG,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC"}
|
package/dist/bin/utils.d.ts
CHANGED
|
@@ -6,22 +6,30 @@ export declare const isOutsideDir: (childPath: string, parentPath: string) => bo
|
|
|
6
6
|
* to keep, e.g. because .actor/ must survive even if .gitignore would otherwise exclude it.
|
|
7
7
|
* This also means .git/ itself is never walked, since git never lists its own internals here.
|
|
8
8
|
*/
|
|
9
|
-
export declare const listRepoFilePaths: (repoRoot: string, subDir: string) => string[]
|
|
9
|
+
export declare const listRepoFilePaths: (repoRoot: string, subDir: string) => Promise<string[]>;
|
|
10
10
|
/**
|
|
11
11
|
* Given paths relative to the repo root, returns the subset that `git` would exclude because of
|
|
12
12
|
* .gitignore rules (including nested .gitignore files, `.git/info/exclude`, and global excludes —
|
|
13
13
|
* anything `git` itself respects). Delegating to `git check-ignore` avoids re-implementing gitignore
|
|
14
14
|
* pattern matching.
|
|
15
15
|
*/
|
|
16
|
-
export declare const getGitignoredPaths: (relativePaths: string[]) => Set<string
|
|
16
|
+
export declare const getGitignoredPaths: (relativePaths: string[], cwd?: string) => Promise<Set<string>>;
|
|
17
17
|
export type SourceFile = {
|
|
18
18
|
name: string;
|
|
19
19
|
content: Buffer;
|
|
20
20
|
};
|
|
21
21
|
export declare const readSourceFile: (absPath: string, rootDir: string) => Promise<SourceFile>;
|
|
22
|
-
export declare
|
|
22
|
+
export declare class GitCommandError extends Error {
|
|
23
|
+
readonly args: readonly string[];
|
|
24
|
+
readonly gitError: string;
|
|
25
|
+
readonly exitCode?: number;
|
|
26
|
+
readonly cause: unknown;
|
|
27
|
+
constructor(args: readonly string[], error: unknown, operation?: string);
|
|
28
|
+
}
|
|
29
|
+
/** Runs Git asynchronously, passing each argument directly to Git without a shell. */
|
|
30
|
+
export declare const runGitCommand: (args: string[], { cwd, operation }?: {
|
|
31
|
+
cwd?: string;
|
|
32
|
+
operation?: string;
|
|
33
|
+
}) => Promise<string>;
|
|
23
34
|
export declare const getEnvVar: (varName: string, defaultValue?: string) => string;
|
|
24
|
-
export declare const setCwd: ({ workspace }: {
|
|
25
|
-
workspace: string | undefined;
|
|
26
|
-
}) => void;
|
|
27
35
|
//# sourceMappingURL=utils.d.ts.map
|
package/dist/bin/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../bin/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../bin/utils.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,YAAY,GAAI,WAAW,MAAM,EAAE,YAAY,MAAM,KAAG,OACZ,CAAC;AAE1D;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,GAAU,UAAU,MAAM,EAAE,QAAQ,MAAM,KAAG,OAAO,CAAC,MAAM,EAAE,CAO1F,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,GAAU,eAAe,MAAM,EAAE,EAAE,MAAM,MAAM,KAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAiBnG,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAE3D,eAAO,MAAM,cAAc,GAAU,SAAS,MAAM,EAAE,SAAS,MAAM,KAAG,OAAO,CAAC,UAAU,CAGxF,CAAC;AAEH,qBAAa,eAAgB,SAAQ,KAAK;IACtC,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;gBAEZ,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,CAAC,EAAE,MAAM;CAmB1E;AAED,sFAAsF;AACtF,eAAO,MAAM,aAAa,GACtB,MAAM,MAAM,EAAE,EACd,qBAAoB;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAO,KAC9D,OAAO,CAAC,MAAM,CAUhB,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,SAAS,MAAM,EAAE,eAAe,MAAM,KAAG,MAMlE,CAAC"}
|
package/dist/bin/utils.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { execFile } from 'node:child_process';
|
|
2
2
|
import fs from 'node:fs/promises';
|
|
3
3
|
import path from 'node:path';
|
|
4
|
+
import { promisify } from 'node:util';
|
|
5
|
+
import { logger } from './logger.js';
|
|
6
|
+
const execFileAsync = promisify(execFile);
|
|
4
7
|
// Returns true when `childPath` is not inside `parentPath`.
|
|
5
8
|
// Used to detect monorepo actors whose dockerContextDir escapes the actor directory.
|
|
6
9
|
export const isOutsideDir = (childPath, parentPath) => path.relative(parentPath, childPath).startsWith('..');
|
|
@@ -11,16 +14,13 @@ export const isOutsideDir = (childPath, parentPath) => path.relative(parentPath,
|
|
|
11
14
|
* to keep, e.g. because .actor/ must survive even if .gitignore would otherwise exclude it.
|
|
12
15
|
* This also means .git/ itself is never walked, since git never lists its own internals here.
|
|
13
16
|
*/
|
|
14
|
-
export const listRepoFilePaths = (repoRoot, subDir) => {
|
|
17
|
+
export const listRepoFilePaths = async (repoRoot, subDir) => {
|
|
15
18
|
const relSubDir = path.relative(repoRoot, subDir).split(path.sep).join('/') || '.';
|
|
16
|
-
const
|
|
19
|
+
const output = await runGitCommand(['ls-files', '--cached', '--others', '-z', '--', relSubDir], {
|
|
17
20
|
cwd: repoRoot,
|
|
18
|
-
|
|
21
|
+
operation: 'list repository files for the local build',
|
|
19
22
|
});
|
|
20
|
-
|
|
21
|
-
throw new Error(`[Command failed]: git ls-files\n${result.stderr.toString()}`);
|
|
22
|
-
}
|
|
23
|
-
return result.stdout.toString().split('\0').filter(Boolean);
|
|
23
|
+
return output.split('\0').filter(Boolean);
|
|
24
24
|
};
|
|
25
25
|
/**
|
|
26
26
|
* Given paths relative to the repo root, returns the subset that `git` would exclude because of
|
|
@@ -28,37 +28,60 @@ export const listRepoFilePaths = (repoRoot, subDir) => {
|
|
|
28
28
|
* anything `git` itself respects). Delegating to `git check-ignore` avoids re-implementing gitignore
|
|
29
29
|
* pattern matching.
|
|
30
30
|
*/
|
|
31
|
-
export const getGitignoredPaths = (relativePaths) => {
|
|
31
|
+
export const getGitignoredPaths = async (relativePaths, cwd) => {
|
|
32
32
|
if (relativePaths.length === 0)
|
|
33
33
|
return new Set();
|
|
34
|
-
const result = spawnSync('git', ['check-ignore', '--stdin'], {
|
|
35
|
-
input: relativePaths.join('\n'),
|
|
36
|
-
maxBuffer: 100 * 1024 * 1024,
|
|
37
|
-
});
|
|
38
34
|
// Exit code 1 means none of the given paths are ignored - not an error. Anything else
|
|
39
35
|
// (e.g. 128 for "not a git repository") is a real failure.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
36
|
+
return runGitCommand(['check-ignore', '--', ...relativePaths], {
|
|
37
|
+
cwd,
|
|
38
|
+
operation: 'check which repository paths are ignored',
|
|
39
|
+
})
|
|
40
|
+
.then((output) => new Set(output.split('\n').filter(Boolean)))
|
|
41
|
+
.catch((error) => {
|
|
42
|
+
// exit code 1 means none of the given paths are ignored - not an error
|
|
43
|
+
if (error instanceof GitCommandError && error.exitCode === 1) {
|
|
44
|
+
return new Set();
|
|
45
|
+
}
|
|
46
|
+
throw error;
|
|
47
|
+
});
|
|
44
48
|
};
|
|
45
49
|
export const readSourceFile = async (absPath, rootDir) => ({
|
|
46
50
|
name: path.relative(rootDir, absPath).split(path.sep).join('/'),
|
|
47
51
|
content: await fs.readFile(absPath),
|
|
48
52
|
});
|
|
49
|
-
export
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
53
|
+
export class GitCommandError extends Error {
|
|
54
|
+
args;
|
|
55
|
+
gitError;
|
|
56
|
+
exitCode;
|
|
57
|
+
cause;
|
|
58
|
+
constructor(args, error, operation) {
|
|
59
|
+
const stderr = typeof error === 'object' && error !== null && 'stderr' in error && typeof error.stderr === 'string'
|
|
60
|
+
? error.stderr.trim()
|
|
61
|
+
: '';
|
|
62
|
+
const gitError = stderr || (error instanceof Error ? error.message : String(error));
|
|
63
|
+
const exitCode = typeof error === 'object' && error !== null && 'code' in error && typeof error.code === 'number'
|
|
64
|
+
? error.code
|
|
65
|
+
: undefined;
|
|
66
|
+
const command = `git ${args.map((arg) => JSON.stringify(arg)).join(' ')}`;
|
|
67
|
+
const operationContext = operation ? `Failed to ${operation}.\n` : '';
|
|
68
|
+
super(`${operationContext}Command: ${command}\nGit error: ${gitError}`);
|
|
69
|
+
this.name = 'GitCommandError';
|
|
70
|
+
this.args = [...args];
|
|
71
|
+
this.gitError = gitError;
|
|
72
|
+
this.exitCode = exitCode;
|
|
73
|
+
this.cause = error;
|
|
54
74
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
75
|
+
}
|
|
76
|
+
/** Runs Git asynchronously, passing each argument directly to Git without a shell. */
|
|
77
|
+
export const runGitCommand = async (args, { cwd, operation } = {}) => {
|
|
78
|
+
logger.debug('git', args);
|
|
79
|
+
const { stdout } = await execFileAsync('git', args, { cwd, encoding: 'utf8', maxBuffer: 100 * 1024 * 1024 }).catch((error) => {
|
|
80
|
+
const err = new GitCommandError(args, error, operation);
|
|
81
|
+
logger.debug('git command failed:\n', err);
|
|
82
|
+
throw err;
|
|
83
|
+
});
|
|
84
|
+
return stdout.trim();
|
|
62
85
|
};
|
|
63
86
|
export const getEnvVar = (varName, defaultValue) => {
|
|
64
87
|
const value = process.env[varName] ?? defaultValue;
|
|
@@ -67,11 +90,4 @@ export const getEnvVar = (varName, defaultValue) => {
|
|
|
67
90
|
}
|
|
68
91
|
return value;
|
|
69
92
|
};
|
|
70
|
-
// Commands expect to run from the repository root (config file and Actor folders are relative to it).
|
|
71
|
-
// That is the current directory by default, --workspace points elsewhere, e.g. for local development.
|
|
72
|
-
export const setCwd = ({ workspace }) => {
|
|
73
|
-
if (workspace) {
|
|
74
|
-
process.chdir(workspace);
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
93
|
//# sourceMappingURL=utils.js.map
|