@brainervirus/workit-pi 8.1.0 → 8.1.1
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/dist/worker.js +1 -0
- package/dist/workit.js +78 -49
- package/package.json +1 -1
package/dist/worker.js
CHANGED
|
@@ -8542,6 +8542,7 @@ var workspacesFileSchema = object({ workspaces: array(workspaceConfigSchema).opt
|
|
|
8542
8542
|
names.add(workspace.name);
|
|
8543
8543
|
}
|
|
8544
8544
|
});
|
|
8545
|
+
var mainCheckouts = new Map;
|
|
8545
8546
|
var runtimeWorkspaceIndexSchema = object({
|
|
8546
8547
|
workspaces: array(object({ name: nonBlank, glob: nonBlank }).passthrough()).optional()
|
|
8547
8548
|
}).passthrough();
|
package/dist/workit.js
CHANGED
|
@@ -3,7 +3,7 @@ import { randomUUID as randomUUID5 } from "node:crypto";
|
|
|
3
3
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
4
4
|
|
|
5
5
|
// packages/workit-core/src/core.ts
|
|
6
|
-
import { spawnSync as
|
|
6
|
+
import { spawnSync as spawnSync14 } from "node:child_process";
|
|
7
7
|
import { existsSync as existsSync7, realpathSync as realpathSync5 } from "node:fs";
|
|
8
8
|
import path19 from "node:path";
|
|
9
9
|
|
|
@@ -14263,6 +14263,7 @@ var gitContext = (workspaceRoot, paths = []) => {
|
|
|
14263
14263
|
};
|
|
14264
14264
|
|
|
14265
14265
|
// packages/workit-core/src/core/workspaces.ts
|
|
14266
|
+
import { spawnSync as spawnSync8 } from "node:child_process";
|
|
14266
14267
|
import { createHash as createHash8 } from "node:crypto";
|
|
14267
14268
|
import { readFileSync as readFileSync4, realpathSync as realpathSync3 } from "node:fs";
|
|
14268
14269
|
import path13 from "node:path";
|
|
@@ -14507,6 +14508,53 @@ var validateWorkspaceGlob = (glob) => {
|
|
|
14507
14508
|
}
|
|
14508
14509
|
return { ok: true };
|
|
14509
14510
|
};
|
|
14511
|
+
|
|
14512
|
+
class WorkspaceConfigError extends Error {
|
|
14513
|
+
name = "WorkspaceConfigError";
|
|
14514
|
+
}
|
|
14515
|
+
var mainCheckouts = new Map;
|
|
14516
|
+
var mainCheckoutOf = (cwd) => {
|
|
14517
|
+
const cached = mainCheckouts.get(cwd);
|
|
14518
|
+
if (cached !== undefined)
|
|
14519
|
+
return cached;
|
|
14520
|
+
const env = { ...process.env };
|
|
14521
|
+
for (const name of ["GIT_DIR", "GIT_WORK_TREE", "GIT_COMMON_DIR", "GIT_INDEX_FILE"])
|
|
14522
|
+
delete env[name];
|
|
14523
|
+
const git = (args) => {
|
|
14524
|
+
const run = spawnSync8("git", args, {
|
|
14525
|
+
cwd,
|
|
14526
|
+
env,
|
|
14527
|
+
encoding: "utf8",
|
|
14528
|
+
timeout: 5000,
|
|
14529
|
+
windowsHide: true
|
|
14530
|
+
});
|
|
14531
|
+
return run.status === 0 ? run.stdout : null;
|
|
14532
|
+
};
|
|
14533
|
+
let main = null;
|
|
14534
|
+
const dirs = git(["rev-parse", "--path-format=absolute", "--git-dir", "--git-common-dir"]);
|
|
14535
|
+
const [gitDir, common] = (dirs ?? "").trim().split(/\r?\n/u);
|
|
14536
|
+
if (gitDir && common && path13.resolve(gitDir) !== path13.resolve(common)) {
|
|
14537
|
+
const listed = /^worktree (.+)$/mu.exec(git(["worktree", "list", "--porcelain"]) ?? "")?.[1];
|
|
14538
|
+
main = listed?.trim() || (path13.basename(common) === ".git" ? path13.dirname(common) : common);
|
|
14539
|
+
}
|
|
14540
|
+
mainCheckouts.set(cwd, main);
|
|
14541
|
+
return main;
|
|
14542
|
+
};
|
|
14543
|
+
var matchingEntries = (cwd, entries) => {
|
|
14544
|
+
const match = (where) => {
|
|
14545
|
+
const targets = [where, realpathOf(where)].map((value) => value.replaceAll("\\", "/"));
|
|
14546
|
+
return entries.filter((entry) => {
|
|
14547
|
+
const glob = entry.glob.replaceAll("\\", "/");
|
|
14548
|
+
const canonical = canonicalGlob(glob);
|
|
14549
|
+
return targets.some((target) => matchWorkspace(glob, target) || canonical !== glob && matchWorkspace(canonical, target));
|
|
14550
|
+
});
|
|
14551
|
+
};
|
|
14552
|
+
const direct = match(cwd);
|
|
14553
|
+
if (direct.length)
|
|
14554
|
+
return direct;
|
|
14555
|
+
const main = mainCheckoutOf(cwd);
|
|
14556
|
+
return main ? match(main) : direct;
|
|
14557
|
+
};
|
|
14510
14558
|
var realpathOf = (p) => {
|
|
14511
14559
|
const real = realpathSync3.native ?? realpathSync3;
|
|
14512
14560
|
try {
|
|
@@ -14531,43 +14579,29 @@ var selectWorkspaceMatch = (matches, cwd, workspaceName) => {
|
|
|
14531
14579
|
if (named.length === 1)
|
|
14532
14580
|
return named[0];
|
|
14533
14581
|
if (named.length > 1)
|
|
14534
|
-
throw new
|
|
14582
|
+
throw new WorkspaceConfigError(`ambiguous workspace ${JSON.stringify(workspaceName)} for ${cwd}`);
|
|
14535
14583
|
if (matches.length > 0) {
|
|
14536
|
-
throw new
|
|
14584
|
+
throw new WorkspaceConfigError(`workspace ${JSON.stringify(workspaceName)} does not match ${cwd}; matching choices: ${matches.map((entry) => entry.name).join(", ")}`);
|
|
14537
14585
|
}
|
|
14538
|
-
throw new
|
|
14586
|
+
throw new WorkspaceConfigError(`workspace ${JSON.stringify(workspaceName)} does not match ${cwd}`);
|
|
14539
14587
|
}
|
|
14540
14588
|
if (matches.length < 2)
|
|
14541
14589
|
return matches[0];
|
|
14542
14590
|
const highestSpecificity = Math.max(...matches.map((entry) => globSpecificity(entry.glob)));
|
|
14543
14591
|
const mostSpecific = matches.filter((entry) => globSpecificity(entry.glob) === highestSpecificity);
|
|
14544
14592
|
if (mostSpecific.length > 1) {
|
|
14545
|
-
throw new
|
|
14593
|
+
throw new WorkspaceConfigError(`ambiguous workspace for ${cwd}; choose one of: ${mostSpecific.map((entry) => entry.name).join(", ")}`);
|
|
14546
14594
|
}
|
|
14547
14595
|
return mostSpecific[0];
|
|
14548
14596
|
};
|
|
14549
14597
|
var resolveWorkspaceFromEntries = (cwd, entries, workspaceName) => {
|
|
14550
|
-
const
|
|
14551
|
-
const matches = [];
|
|
14552
|
-
for (const ws of entries) {
|
|
14553
|
-
const glob = ws.glob.replaceAll("\\", "/");
|
|
14554
|
-
const canonical = canonicalGlob(glob);
|
|
14555
|
-
let matched = false;
|
|
14556
|
-
for (const target of targets) {
|
|
14557
|
-
if (matchWorkspace(glob, target) || canonical !== glob && matchWorkspace(canonical, target)) {
|
|
14558
|
-
matched = true;
|
|
14559
|
-
break;
|
|
14560
|
-
}
|
|
14561
|
-
}
|
|
14562
|
-
if (matched)
|
|
14563
|
-
matches.push(ws);
|
|
14564
|
-
}
|
|
14598
|
+
const matches = matchingEntries(cwd, entries);
|
|
14565
14599
|
return selectWorkspaceMatch(matches, cwd, workspaceName) ?? null;
|
|
14566
14600
|
};
|
|
14567
14601
|
var resolveWorkspaceFrom = (cwd, dir, workspaceName) => {
|
|
14568
14602
|
const result = readWorkspacesResult(dir);
|
|
14569
14603
|
if (result.status === "malformed" || result.status === "invalid")
|
|
14570
|
-
throw new
|
|
14604
|
+
throw new WorkspaceConfigError(result.error);
|
|
14571
14605
|
return resolveWorkspaceFromEntries(cwd, result.entries, workspaceName);
|
|
14572
14606
|
};
|
|
14573
14607
|
var runtimeWorkspacePolicySchema = (kind) => {
|
|
@@ -14599,31 +14633,26 @@ var matchRuntimeWorkspace = (cwd) => {
|
|
|
14599
14633
|
} catch (error) {
|
|
14600
14634
|
if (error.code === "ENOENT")
|
|
14601
14635
|
return null;
|
|
14602
|
-
throw new
|
|
14636
|
+
throw new WorkspaceConfigError(`${file} could not be read: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
|
|
14603
14637
|
}
|
|
14604
14638
|
let parsed;
|
|
14605
14639
|
try {
|
|
14606
14640
|
parsed = JSON.parse(raw);
|
|
14607
14641
|
} catch {
|
|
14608
|
-
throw new
|
|
14642
|
+
throw new WorkspaceConfigError(`${file} is not valid JSON`);
|
|
14609
14643
|
}
|
|
14610
14644
|
const validated = runtimeWorkspaceIndexSchema.safeParse(parsed);
|
|
14611
14645
|
if (!validated.success) {
|
|
14612
14646
|
const detail = validated.error.issues.map((issue) => `${issue.path.map(String).join(".") || "workspaces"}: ${issue.message}`).join("; ");
|
|
14613
|
-
throw new
|
|
14647
|
+
throw new WorkspaceConfigError(`${file} has invalid workspace matching data: ${detail}`);
|
|
14614
14648
|
}
|
|
14615
14649
|
const entries = validated.data.workspaces;
|
|
14616
14650
|
for (const entry of entries ?? []) {
|
|
14617
14651
|
const glob = validateWorkspaceGlob(entry.glob);
|
|
14618
14652
|
if (!glob.ok)
|
|
14619
|
-
throw new
|
|
14653
|
+
throw new WorkspaceConfigError(`${file} workspace ${entry.name}: ${glob.error}`);
|
|
14620
14654
|
}
|
|
14621
|
-
const
|
|
14622
|
-
const matches = (entries ?? []).filter((entry) => {
|
|
14623
|
-
const glob = entry.glob.replaceAll("\\", "/");
|
|
14624
|
-
const canonical = canonicalGlob(glob);
|
|
14625
|
-
return targets.some((target) => matchWorkspace(glob, target) || canonical !== glob && matchWorkspace(canonical, target));
|
|
14626
|
-
});
|
|
14655
|
+
const matches = matchingEntries(cwd, entries ?? []);
|
|
14627
14656
|
const workspaceName = process.env.WORKFLOW_WORKSPACE_NAME?.trim() || undefined;
|
|
14628
14657
|
const selected = selectWorkspaceMatch(matches, cwd, workspaceName);
|
|
14629
14658
|
return selected ? { file, selected } : null;
|
|
@@ -14640,7 +14669,7 @@ var resolveRuntimeWorkspaceCandidate = (cwd, kind) => {
|
|
|
14640
14669
|
const policy = runtimeWorkspacePolicySchema(kind).safeParse(selected);
|
|
14641
14670
|
if (!policy.success) {
|
|
14642
14671
|
const detail = policy.error.issues.map((issue) => `${issue.path.map(String).join(".") || "workspace"}: ${issue.message}`).join("; ");
|
|
14643
|
-
throw new
|
|
14672
|
+
throw new WorkspaceConfigError(`${file} has invalid ${kind} policy configuration: ${detail}`);
|
|
14644
14673
|
}
|
|
14645
14674
|
return policy.data;
|
|
14646
14675
|
};
|
|
@@ -14651,10 +14680,10 @@ var resolveRuntimeWorkspacePolicy = (cwd, kind, requestedProfile) => {
|
|
|
14651
14680
|
const key = kind === "branch" ? "branchPolicy" : "commitPolicy";
|
|
14652
14681
|
const profileName = requestedProfile?.trim() || candidate.defaultProfile;
|
|
14653
14682
|
if (candidate.defaultProfile && !Object.hasOwn(candidate.profiles ?? {}, candidate.defaultProfile))
|
|
14654
|
-
throw new
|
|
14683
|
+
throw new WorkspaceConfigError(`workspace ${JSON.stringify(candidate.name)} has no profile ${JSON.stringify(candidate.defaultProfile)}`);
|
|
14655
14684
|
const profile = profileName ? candidate.profiles?.[profileName] : undefined;
|
|
14656
14685
|
if (profileName && !profile)
|
|
14657
|
-
throw new
|
|
14686
|
+
throw new WorkspaceConfigError(`workspace ${JSON.stringify(candidate.name)} has no profile ${JSON.stringify(profileName)}`);
|
|
14658
14687
|
const profilePolicy = profile?.[key];
|
|
14659
14688
|
const workspacePolicy = candidate[key];
|
|
14660
14689
|
return {
|
|
@@ -14674,11 +14703,11 @@ function workspaceDefaultTarget(cwd, globalDefault) {
|
|
|
14674
14703
|
// packages/workit-core/src/core/vcs-config.ts
|
|
14675
14704
|
import fs12 from "node:fs";
|
|
14676
14705
|
import path14 from "node:path";
|
|
14677
|
-
import { spawnSync as
|
|
14706
|
+
import { spawnSync as spawnSync10 } from "node:child_process";
|
|
14678
14707
|
|
|
14679
14708
|
// packages/workit-core/src/core/release-tracks.ts
|
|
14680
14709
|
import { createHash as createHash9 } from "node:crypto";
|
|
14681
|
-
import { spawnSync as
|
|
14710
|
+
import { spawnSync as spawnSync9 } from "node:child_process";
|
|
14682
14711
|
class ReleaseTrackError extends Error {
|
|
14683
14712
|
}
|
|
14684
14713
|
var KNOWN_FIELDS = new Set([
|
|
@@ -14963,7 +14992,7 @@ function resolveReleaseTrack(input) {
|
|
|
14963
14992
|
return fallback(`${branch} has the same or unrelated fork points with ${[...new Set(newest.map((fork) => `${fork.ref} (${fork.track.name === IMPLICIT ? "workspace default" : fork.track.name})`))].join(" and ")}`);
|
|
14964
14993
|
}
|
|
14965
14994
|
var git4 = (cwd, args) => {
|
|
14966
|
-
const run =
|
|
14995
|
+
const run = spawnSync9("git", args, {
|
|
14967
14996
|
cwd,
|
|
14968
14997
|
encoding: "utf8",
|
|
14969
14998
|
timeout: 20000,
|
|
@@ -15078,7 +15107,7 @@ function resolveTrackFor(cwd, options) {
|
|
|
15078
15107
|
var workspacesPath = () => path14.join(configDir(), "workspaces.json");
|
|
15079
15108
|
var vcsCwd = (cwd) => cwd ?? process.env.WORKFLOW_WORKSPACE_ROOT ?? process.cwd();
|
|
15080
15109
|
var remoteProvider = (cwd) => {
|
|
15081
|
-
const r =
|
|
15110
|
+
const r = spawnSync10("git", ["remote", "get-url", "origin"], { cwd, encoding: "utf8" });
|
|
15082
15111
|
if (r.status !== 0)
|
|
15083
15112
|
return null;
|
|
15084
15113
|
const url = (r.stdout ?? "").trim();
|
|
@@ -15115,7 +15144,7 @@ var remoteEndpoint = (remote) => {
|
|
|
15115
15144
|
var configuredSshEndpoint = (host) => {
|
|
15116
15145
|
if (host.startsWith("-"))
|
|
15117
15146
|
return null;
|
|
15118
|
-
const resolved =
|
|
15147
|
+
const resolved = spawnSync10("ssh", ["-G", host], {
|
|
15119
15148
|
encoding: "utf8",
|
|
15120
15149
|
timeout: 5000,
|
|
15121
15150
|
maxBuffer: 1024 * 1024,
|
|
@@ -15288,7 +15317,7 @@ function mergedPrStyle(limit = 6, cwd) {
|
|
|
15288
15317
|
`).filter((l) => l.startsWith("## ")).map((l) => l.trim()),
|
|
15289
15318
|
descriptionPreview: desc.slice(0, 600)
|
|
15290
15319
|
});
|
|
15291
|
-
const remoteResult =
|
|
15320
|
+
const remoteResult = spawnSync10("git", ["remote", "get-url", "--push", "--all", "origin"], {
|
|
15292
15321
|
cwd,
|
|
15293
15322
|
encoding: "utf8"
|
|
15294
15323
|
});
|
|
@@ -15304,7 +15333,7 @@ function mergedPrStyle(limit = 6, cwd) {
|
|
|
15304
15333
|
if (!hostingApiHostMatches(remote, host))
|
|
15305
15334
|
return { ok: false, error: "PR style target does not match the provider host" };
|
|
15306
15335
|
if (provider === "gitlab") {
|
|
15307
|
-
const run = (args) =>
|
|
15336
|
+
const run = (args) => spawnSync10("glab", ["api", ...args], {
|
|
15308
15337
|
cwd,
|
|
15309
15338
|
encoding: "utf8",
|
|
15310
15339
|
env
|
|
@@ -15324,7 +15353,7 @@ function mergedPrStyle(limit = 6, cwd) {
|
|
|
15324
15353
|
});
|
|
15325
15354
|
}
|
|
15326
15355
|
} else if (provider === "github") {
|
|
15327
|
-
const r =
|
|
15356
|
+
const r = spawnSync10("gh", [
|
|
15328
15357
|
"pr",
|
|
15329
15358
|
"list",
|
|
15330
15359
|
"--repo",
|
|
@@ -17370,7 +17399,7 @@ class WorkitCore {
|
|
|
17370
17399
|
}
|
|
17371
17400
|
}
|
|
17372
17401
|
// packages/workit-core/src/core/repo-context.ts
|
|
17373
|
-
import { spawnSync as
|
|
17402
|
+
import { spawnSync as spawnSync11 } from "node:child_process";
|
|
17374
17403
|
import { existsSync as existsSync6, readFileSync as readFileSync5, readdirSync as readdirSync4 } from "node:fs";
|
|
17375
17404
|
import path16 from "node:path";
|
|
17376
17405
|
var isSafeContextRange = (value) => value.length <= 4096 && (() => {
|
|
@@ -17399,7 +17428,7 @@ var invalidRange = (cwd) => ({
|
|
|
17399
17428
|
cwd
|
|
17400
17429
|
});
|
|
17401
17430
|
var runGit = (cwd, args) => {
|
|
17402
|
-
const result =
|
|
17431
|
+
const result = spawnSync11("git", args, { cwd, encoding: "utf8" });
|
|
17403
17432
|
return {
|
|
17404
17433
|
stdout: (result.stdout ?? "").trimEnd(),
|
|
17405
17434
|
stderr: (result.stderr ?? "").trimEnd(),
|
|
@@ -17840,12 +17869,12 @@ function releaseNotesContext(root, rangeOrTag) {
|
|
|
17840
17869
|
}
|
|
17841
17870
|
|
|
17842
17871
|
// packages/workit-core/src/core/tracker-issues.ts
|
|
17843
|
-
import { spawnSync as
|
|
17872
|
+
import { spawnSync as spawnSync13 } from "node:child_process";
|
|
17844
17873
|
|
|
17845
17874
|
// packages/workit-core/src/core/pr-create.ts
|
|
17846
17875
|
import fs13 from "node:fs";
|
|
17847
17876
|
import path17 from "node:path";
|
|
17848
|
-
import { spawnSync as
|
|
17877
|
+
import { spawnSync as spawnSync12 } from "node:child_process";
|
|
17849
17878
|
// packages/workit-core/src/forge/pr-body.ts
|
|
17850
17879
|
function parseGhIssue(value) {
|
|
17851
17880
|
const m = /issues\/(\d+)/.exec(value);
|
|
@@ -17870,7 +17899,7 @@ function whichOnPath(tool) {
|
|
|
17870
17899
|
}
|
|
17871
17900
|
var hostingCliAvailable = (provider) => whichOnPath(provider === "gitlab" ? "glab" : "gh") !== null;
|
|
17872
17901
|
var pushRemote = (cwd) => {
|
|
17873
|
-
const result =
|
|
17902
|
+
const result = spawnSync12("git", ["remote", "get-url", "--push", "--all", "origin"], {
|
|
17874
17903
|
cwd,
|
|
17875
17904
|
encoding: "utf8"
|
|
17876
17905
|
});
|
|
@@ -17901,7 +17930,7 @@ var defaultCli = (bin, available) => {
|
|
|
17901
17930
|
if (!available)
|
|
17902
17931
|
return null;
|
|
17903
17932
|
return (args, root) => {
|
|
17904
|
-
const out =
|
|
17933
|
+
const out = spawnSync13(bin, args, {
|
|
17905
17934
|
cwd: root,
|
|
17906
17935
|
encoding: "utf8",
|
|
17907
17936
|
env: { ...process.env, PATH: process.env.PATH ?? "" }
|
|
@@ -18434,7 +18463,7 @@ function resolveInside(root, candidate) {
|
|
|
18434
18463
|
}
|
|
18435
18464
|
function run2(root, executable, args, env = {}) {
|
|
18436
18465
|
const cwd = realpathSync5(root);
|
|
18437
|
-
const result =
|
|
18466
|
+
const result = spawnSync14(executable, args, {
|
|
18438
18467
|
cwd,
|
|
18439
18468
|
encoding: "utf8",
|
|
18440
18469
|
env: { ...process.env, ...env }
|