@pmate/cli 0.21.3 → 0.21.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/dist/index.d.ts +19 -1
- package/dist/index.js +590 -277
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9435,8 +9435,8 @@ __export(index_exports, {
|
|
|
9435
9435
|
parseCommandArgs: () => parseCommandArgs
|
|
9436
9436
|
});
|
|
9437
9437
|
module.exports = __toCommonJS(index_exports);
|
|
9438
|
-
var
|
|
9439
|
-
var
|
|
9438
|
+
var import_node_fs19 = require("fs");
|
|
9439
|
+
var import_node_path24 = __toESM(require("path"));
|
|
9440
9440
|
var import_chalk4 = __toESM(require("chalk"));
|
|
9441
9441
|
|
|
9442
9442
|
// src/cli.ts
|
|
@@ -11639,8 +11639,224 @@ function formatEnvValue(value) {
|
|
|
11639
11639
|
return value;
|
|
11640
11640
|
}
|
|
11641
11641
|
|
|
11642
|
-
// src/commands/
|
|
11642
|
+
// src/commands/PrepareDevCommandHandler.ts
|
|
11643
|
+
var import_node_fs6 = require("fs");
|
|
11644
|
+
var import_promises2 = require("fs/promises");
|
|
11645
|
+
var import_node_os3 = __toESM(require("os"));
|
|
11646
|
+
var import_node_path10 = __toESM(require("path"));
|
|
11643
11647
|
var import_node_child_process5 = require("child_process");
|
|
11648
|
+
var import_node_util = require("util");
|
|
11649
|
+
var execFileAsync = (0, import_node_util.promisify)(import_node_child_process5.execFile);
|
|
11650
|
+
var LOCK_FILE_NAME = ".pmate.lock";
|
|
11651
|
+
var PrepareDevCommandHandler = class {
|
|
11652
|
+
async handle(args) {
|
|
11653
|
+
if (args.type !== "prepare-dev" /* PrepareDev */) {
|
|
11654
|
+
throw new Error("Unsupported command for PrepareDevCommandHandler");
|
|
11655
|
+
}
|
|
11656
|
+
const envRoot = this.resolveRoot(args.envRoot, ["dev", "pmate-envs"]);
|
|
11657
|
+
const baseRoot = this.resolveRoot(args.baseRoot, ["dev", "pmate"]);
|
|
11658
|
+
if (args.action === "open") {
|
|
11659
|
+
const result2 = await this.openEnvironment(args.repo, args.note, envRoot, baseRoot);
|
|
11660
|
+
this.renderOpen(result2, args.json);
|
|
11661
|
+
return result2;
|
|
11662
|
+
}
|
|
11663
|
+
const result = await this.closeEnvironment(args.repo, args.envIndex, envRoot);
|
|
11664
|
+
this.renderClose(result, args.json);
|
|
11665
|
+
return result;
|
|
11666
|
+
}
|
|
11667
|
+
async openEnvironment(repo, note, envRoot, baseRoot) {
|
|
11668
|
+
await (0, import_promises2.mkdir)(envRoot, { recursive: true });
|
|
11669
|
+
const baseRepoPath = import_node_path10.default.join(baseRoot, repo);
|
|
11670
|
+
if (!await this.pathExists(baseRepoPath)) {
|
|
11671
|
+
throw new Error(`Base repo not found: ${baseRepoPath}`);
|
|
11672
|
+
}
|
|
11673
|
+
const baseOrigin = await this.getGitOutput(baseRepoPath, ["remote", "get-url", "origin"]);
|
|
11674
|
+
if (this.isLocalOrigin(baseOrigin)) {
|
|
11675
|
+
throw new Error(
|
|
11676
|
+
`Base repo origin must be a remote origin, got local origin: ${baseOrigin}`
|
|
11677
|
+
);
|
|
11678
|
+
}
|
|
11679
|
+
for (let envIndex = 0; envIndex < 1e3; envIndex += 1) {
|
|
11680
|
+
const envPath = import_node_path10.default.join(envRoot, `${repo}-${envIndex}`);
|
|
11681
|
+
const lockPath = import_node_path10.default.join(envPath, LOCK_FILE_NAME);
|
|
11682
|
+
if (!await this.pathExists(envPath)) {
|
|
11683
|
+
await this.runGit(["clone", baseOrigin, envPath], envRoot);
|
|
11684
|
+
await this.ensureMainBranch(envPath);
|
|
11685
|
+
await this.writeLock(lockPath, repo, envIndex, envPath, baseOrigin, note);
|
|
11686
|
+
return {
|
|
11687
|
+
action: "open",
|
|
11688
|
+
repo,
|
|
11689
|
+
envIndex,
|
|
11690
|
+
envPath,
|
|
11691
|
+
lockPath,
|
|
11692
|
+
origin: baseOrigin,
|
|
11693
|
+
note,
|
|
11694
|
+
created: true
|
|
11695
|
+
};
|
|
11696
|
+
}
|
|
11697
|
+
if (!await this.pathExists(import_node_path10.default.join(envPath, ".git"))) {
|
|
11698
|
+
continue;
|
|
11699
|
+
}
|
|
11700
|
+
if (await this.pathExists(lockPath)) {
|
|
11701
|
+
continue;
|
|
11702
|
+
}
|
|
11703
|
+
const envOrigin = await this.safeGitOutput(envPath, ["remote", "get-url", "origin"]);
|
|
11704
|
+
if (!envOrigin || envOrigin !== baseOrigin || this.isLocalOrigin(envOrigin)) {
|
|
11705
|
+
continue;
|
|
11706
|
+
}
|
|
11707
|
+
const branch = await this.safeGitOutput(envPath, ["branch", "--show-current"]);
|
|
11708
|
+
if (branch !== "main") {
|
|
11709
|
+
continue;
|
|
11710
|
+
}
|
|
11711
|
+
if (await this.hasUncommittedChanges(envPath)) {
|
|
11712
|
+
continue;
|
|
11713
|
+
}
|
|
11714
|
+
try {
|
|
11715
|
+
await this.writeLock(lockPath, repo, envIndex, envPath, envOrigin, note);
|
|
11716
|
+
} catch (error) {
|
|
11717
|
+
if (this.isAlreadyExistsError(error)) {
|
|
11718
|
+
continue;
|
|
11719
|
+
}
|
|
11720
|
+
throw error;
|
|
11721
|
+
}
|
|
11722
|
+
return {
|
|
11723
|
+
action: "open",
|
|
11724
|
+
repo,
|
|
11725
|
+
envIndex,
|
|
11726
|
+
envPath,
|
|
11727
|
+
lockPath,
|
|
11728
|
+
origin: envOrigin,
|
|
11729
|
+
note,
|
|
11730
|
+
created: false
|
|
11731
|
+
};
|
|
11732
|
+
}
|
|
11733
|
+
throw new Error(`No available dev environment found for ${repo} under ${envRoot}`);
|
|
11734
|
+
}
|
|
11735
|
+
async closeEnvironment(repo, envIndex, envRoot) {
|
|
11736
|
+
const envPath = import_node_path10.default.join(envRoot, `${repo}-${envIndex}`);
|
|
11737
|
+
const lockPath = import_node_path10.default.join(envPath, LOCK_FILE_NAME);
|
|
11738
|
+
if (!await this.pathExists(envPath) || !await this.pathExists(import_node_path10.default.join(envPath, ".git"))) {
|
|
11739
|
+
throw new Error(`Dev environment not found: ${envPath}`);
|
|
11740
|
+
}
|
|
11741
|
+
const hasChanges = await this.hasUncommittedChanges(envPath);
|
|
11742
|
+
if (hasChanges) {
|
|
11743
|
+
throw new Error(
|
|
11744
|
+
`Cannot close ${repo}-${envIndex}: local changes detected. Commit or clean the worktree first.`
|
|
11745
|
+
);
|
|
11746
|
+
}
|
|
11747
|
+
const removedLock = await this.removeLock(lockPath);
|
|
11748
|
+
return {
|
|
11749
|
+
action: "close",
|
|
11750
|
+
repo,
|
|
11751
|
+
envIndex,
|
|
11752
|
+
envPath,
|
|
11753
|
+
lockPath,
|
|
11754
|
+
removedLock
|
|
11755
|
+
};
|
|
11756
|
+
}
|
|
11757
|
+
resolveRoot(input, fallbackSegments) {
|
|
11758
|
+
if (input) {
|
|
11759
|
+
return import_node_path10.default.resolve(input);
|
|
11760
|
+
}
|
|
11761
|
+
return import_node_path10.default.join(import_node_os3.default.homedir(), ...fallbackSegments);
|
|
11762
|
+
}
|
|
11763
|
+
async ensureMainBranch(cwd) {
|
|
11764
|
+
const branch = await this.getGitOutput(cwd, ["branch", "--show-current"]);
|
|
11765
|
+
if (branch !== "main") {
|
|
11766
|
+
throw new Error(`Expected ${cwd} to be on main, got ${branch || "(detached)"}`);
|
|
11767
|
+
}
|
|
11768
|
+
}
|
|
11769
|
+
async hasUncommittedChanges(cwd) {
|
|
11770
|
+
const status = await this.getGitOutput(cwd, ["status", "--porcelain"]);
|
|
11771
|
+
if (!status) {
|
|
11772
|
+
return false;
|
|
11773
|
+
}
|
|
11774
|
+
const meaningfulLines = status.split("\n").map((line) => line.trimEnd()).filter(Boolean).filter((line) => {
|
|
11775
|
+
const relativePath = line.slice(3).trim();
|
|
11776
|
+
return relativePath !== LOCK_FILE_NAME;
|
|
11777
|
+
});
|
|
11778
|
+
return meaningfulLines.length > 0;
|
|
11779
|
+
}
|
|
11780
|
+
async getGitOutput(cwd, args) {
|
|
11781
|
+
const { stdout } = await execFileAsync("git", args, { cwd });
|
|
11782
|
+
return stdout.trim();
|
|
11783
|
+
}
|
|
11784
|
+
async safeGitOutput(cwd, args) {
|
|
11785
|
+
try {
|
|
11786
|
+
return await this.getGitOutput(cwd, args);
|
|
11787
|
+
} catch {
|
|
11788
|
+
return "";
|
|
11789
|
+
}
|
|
11790
|
+
}
|
|
11791
|
+
async runGit(args, cwd) {
|
|
11792
|
+
await execFileAsync("git", args, { cwd });
|
|
11793
|
+
}
|
|
11794
|
+
async pathExists(targetPath) {
|
|
11795
|
+
try {
|
|
11796
|
+
await (0, import_promises2.access)(targetPath, import_node_fs6.constants.F_OK);
|
|
11797
|
+
return true;
|
|
11798
|
+
} catch {
|
|
11799
|
+
return false;
|
|
11800
|
+
}
|
|
11801
|
+
}
|
|
11802
|
+
async writeLock(lockPath, repo, envIndex, envPath, origin, note) {
|
|
11803
|
+
const payload = {
|
|
11804
|
+
repo,
|
|
11805
|
+
envIndex,
|
|
11806
|
+
envPath,
|
|
11807
|
+
origin,
|
|
11808
|
+
note,
|
|
11809
|
+
openedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
11810
|
+
};
|
|
11811
|
+
await (0, import_promises2.writeFile)(lockPath, `${JSON.stringify(payload, null, 2)}
|
|
11812
|
+
`, {
|
|
11813
|
+
encoding: "utf8",
|
|
11814
|
+
flag: "wx"
|
|
11815
|
+
});
|
|
11816
|
+
}
|
|
11817
|
+
async removeLock(lockPath) {
|
|
11818
|
+
if (!await this.pathExists(lockPath)) {
|
|
11819
|
+
return false;
|
|
11820
|
+
}
|
|
11821
|
+
await (0, import_promises2.rm)(lockPath, { force: true });
|
|
11822
|
+
return true;
|
|
11823
|
+
}
|
|
11824
|
+
isLocalOrigin(origin) {
|
|
11825
|
+
return origin.startsWith("/") || origin.startsWith("./") || origin.startsWith("../") || origin.startsWith("file://");
|
|
11826
|
+
}
|
|
11827
|
+
isAlreadyExistsError(error) {
|
|
11828
|
+
return Boolean(
|
|
11829
|
+
error && typeof error === "object" && "code" in error && error.code === "EEXIST"
|
|
11830
|
+
);
|
|
11831
|
+
}
|
|
11832
|
+
renderOpen(result, asJson) {
|
|
11833
|
+
if (asJson) {
|
|
11834
|
+
ui.plain(JSON.stringify(result, null, 2));
|
|
11835
|
+
return;
|
|
11836
|
+
}
|
|
11837
|
+
ui.success(
|
|
11838
|
+
`Prepared ${result.repo}-${result.envIndex}${result.created ? " (cloned)" : ""}`,
|
|
11839
|
+
{
|
|
11840
|
+
path: result.envPath,
|
|
11841
|
+
origin: result.origin,
|
|
11842
|
+
lock: result.lockPath
|
|
11843
|
+
}
|
|
11844
|
+
);
|
|
11845
|
+
}
|
|
11846
|
+
renderClose(result, asJson) {
|
|
11847
|
+
if (asJson) {
|
|
11848
|
+
ui.plain(JSON.stringify(result, null, 2));
|
|
11849
|
+
return;
|
|
11850
|
+
}
|
|
11851
|
+
ui.success(`Closed ${result.repo}-${result.envIndex}`, {
|
|
11852
|
+
path: result.envPath,
|
|
11853
|
+
lockRemoved: result.removedLock
|
|
11854
|
+
});
|
|
11855
|
+
}
|
|
11856
|
+
};
|
|
11857
|
+
|
|
11858
|
+
// src/commands/PrCommandHandler.ts
|
|
11859
|
+
var import_node_child_process6 = require("child_process");
|
|
11644
11860
|
var PrCommandHandler = class {
|
|
11645
11861
|
constructor(cwd = process.cwd()) {
|
|
11646
11862
|
this.cwd = cwd;
|
|
@@ -12112,7 +12328,7 @@ ${lines}`;
|
|
|
12112
12328
|
}
|
|
12113
12329
|
run(command, args, quietError = false, env, cwd) {
|
|
12114
12330
|
return new Promise((resolve, reject) => {
|
|
12115
|
-
const child = (0,
|
|
12331
|
+
const child = (0, import_node_child_process6.spawn)(command, args, {
|
|
12116
12332
|
stdio: quietError ? "ignore" : "inherit",
|
|
12117
12333
|
env: env ?? process.env,
|
|
12118
12334
|
cwd: cwd ?? this.cwd
|
|
@@ -12131,7 +12347,7 @@ ${lines}`;
|
|
|
12131
12347
|
}
|
|
12132
12348
|
runCapture(command, args, allowFailure = false, env, cwd) {
|
|
12133
12349
|
return new Promise((resolve, reject) => {
|
|
12134
|
-
const child = (0,
|
|
12350
|
+
const child = (0, import_node_child_process6.spawn)(command, args, {
|
|
12135
12351
|
stdio: ["ignore", "pipe", "pipe"],
|
|
12136
12352
|
env: env ?? process.env,
|
|
12137
12353
|
cwd: cwd ?? this.cwd
|
|
@@ -12272,8 +12488,8 @@ var CommitCommandHandler = class {
|
|
|
12272
12488
|
};
|
|
12273
12489
|
|
|
12274
12490
|
// src/commands/SummaryCommandHandler.ts
|
|
12275
|
-
var
|
|
12276
|
-
var
|
|
12491
|
+
var import_node_child_process7 = require("child_process");
|
|
12492
|
+
var import_node_path11 = __toESM(require("path"));
|
|
12277
12493
|
var SummaryCommandHandler = class {
|
|
12278
12494
|
async handle(args) {
|
|
12279
12495
|
const cwd = this.resolveCwd(args.cwd);
|
|
@@ -12381,7 +12597,7 @@ var SummaryCommandHandler = class {
|
|
|
12381
12597
|
}
|
|
12382
12598
|
run(command, args, quietError = false, env, cwd) {
|
|
12383
12599
|
return new Promise((resolve, reject) => {
|
|
12384
|
-
const child = (0,
|
|
12600
|
+
const child = (0, import_node_child_process7.spawn)(command, args, {
|
|
12385
12601
|
stdio: quietError ? "ignore" : "inherit",
|
|
12386
12602
|
env: env ?? process.env,
|
|
12387
12603
|
cwd
|
|
@@ -12400,7 +12616,7 @@ var SummaryCommandHandler = class {
|
|
|
12400
12616
|
}
|
|
12401
12617
|
runCapture(command, args, allowFailure = false, env, cwd) {
|
|
12402
12618
|
return new Promise((resolve, reject) => {
|
|
12403
|
-
const child = (0,
|
|
12619
|
+
const child = (0, import_node_child_process7.spawn)(command, args, {
|
|
12404
12620
|
stdio: ["ignore", "pipe", "pipe"],
|
|
12405
12621
|
env: env ?? process.env,
|
|
12406
12622
|
cwd
|
|
@@ -12458,7 +12674,7 @@ var SummaryCommandHandler = class {
|
|
|
12458
12674
|
return this.runCapture("gh", args, allowFailure, await this.getGhEnv(cwd), cwd);
|
|
12459
12675
|
}
|
|
12460
12676
|
resolveCwd(value) {
|
|
12461
|
-
return value ?
|
|
12677
|
+
return value ? import_node_path11.default.resolve(process.cwd(), value) : process.cwd();
|
|
12462
12678
|
}
|
|
12463
12679
|
};
|
|
12464
12680
|
function truncate2(value, limit) {
|
|
@@ -12470,11 +12686,11 @@ function truncate2(value, limit) {
|
|
|
12470
12686
|
}
|
|
12471
12687
|
|
|
12472
12688
|
// src/commands/LinearCommandHandler.ts
|
|
12473
|
-
var
|
|
12474
|
-
var
|
|
12475
|
-
var
|
|
12476
|
-
var
|
|
12477
|
-
var
|
|
12689
|
+
var import_node_child_process8 = require("child_process");
|
|
12690
|
+
var import_node_fs7 = require("fs");
|
|
12691
|
+
var import_node_os4 = __toESM(require("os"));
|
|
12692
|
+
var import_node_path12 = __toESM(require("path"));
|
|
12693
|
+
var import_promises3 = require("readline/promises");
|
|
12478
12694
|
var import_openai = __toESM(require("openai"));
|
|
12479
12695
|
var import_sdk = require("@linear/sdk");
|
|
12480
12696
|
var ISSUE_SUMMARY_FIELDS = `
|
|
@@ -13325,7 +13541,7 @@ var LinearCommandHandler = class {
|
|
|
13325
13541
|
return accounts[index];
|
|
13326
13542
|
}
|
|
13327
13543
|
}
|
|
13328
|
-
const rl = (0,
|
|
13544
|
+
const rl = (0, import_promises3.createInterface)({
|
|
13329
13545
|
input: process.stdin,
|
|
13330
13546
|
output: process.stdout
|
|
13331
13547
|
});
|
|
@@ -13357,15 +13573,15 @@ var LinearCommandHandler = class {
|
|
|
13357
13573
|
}
|
|
13358
13574
|
}
|
|
13359
13575
|
getLinearSelectionPath() {
|
|
13360
|
-
return
|
|
13576
|
+
return import_node_path12.default.join(import_node_os4.default.homedir(), ".pmate", "linear-selection.json");
|
|
13361
13577
|
}
|
|
13362
13578
|
readCachedLinearSelection(cwd) {
|
|
13363
13579
|
const selectionPath = this.getLinearSelectionPath();
|
|
13364
|
-
if (!(0,
|
|
13580
|
+
if (!(0, import_node_fs7.existsSync)(selectionPath)) {
|
|
13365
13581
|
return void 0;
|
|
13366
13582
|
}
|
|
13367
13583
|
try {
|
|
13368
|
-
const raw = (0,
|
|
13584
|
+
const raw = (0, import_node_fs7.readFileSync)(selectionPath, "utf8").trim();
|
|
13369
13585
|
if (!raw) return void 0;
|
|
13370
13586
|
const parsed = JSON.parse(raw);
|
|
13371
13587
|
const value = parsed[cwd];
|
|
@@ -13376,12 +13592,12 @@ var LinearCommandHandler = class {
|
|
|
13376
13592
|
}
|
|
13377
13593
|
writeCachedLinearSelection(cwd, title) {
|
|
13378
13594
|
const selectionPath = this.getLinearSelectionPath();
|
|
13379
|
-
const dir =
|
|
13380
|
-
(0,
|
|
13595
|
+
const dir = import_node_path12.default.dirname(selectionPath);
|
|
13596
|
+
(0, import_node_fs7.mkdirSync)(dir, { recursive: true });
|
|
13381
13597
|
let data = {};
|
|
13382
|
-
if ((0,
|
|
13598
|
+
if ((0, import_node_fs7.existsSync)(selectionPath)) {
|
|
13383
13599
|
try {
|
|
13384
|
-
const raw = (0,
|
|
13600
|
+
const raw = (0, import_node_fs7.readFileSync)(selectionPath, "utf8").trim();
|
|
13385
13601
|
if (raw) {
|
|
13386
13602
|
data = JSON.parse(raw);
|
|
13387
13603
|
}
|
|
@@ -13390,7 +13606,7 @@ var LinearCommandHandler = class {
|
|
|
13390
13606
|
}
|
|
13391
13607
|
}
|
|
13392
13608
|
data[cwd] = title;
|
|
13393
|
-
(0,
|
|
13609
|
+
(0, import_node_fs7.writeFileSync)(selectionPath, `${JSON.stringify(data, null, 2)}
|
|
13394
13610
|
`, "utf8");
|
|
13395
13611
|
}
|
|
13396
13612
|
async lookupIssue(client, issueRef) {
|
|
@@ -13491,7 +13707,7 @@ var LinearCommandHandler = class {
|
|
|
13491
13707
|
ui.info(issue.description?.trim() ? issue.description : " (no description)");
|
|
13492
13708
|
}
|
|
13493
13709
|
async collectReplInput() {
|
|
13494
|
-
const rl = (0,
|
|
13710
|
+
const rl = (0, import_promises3.createInterface)({
|
|
13495
13711
|
input: process.stdin,
|
|
13496
13712
|
output: process.stdout
|
|
13497
13713
|
});
|
|
@@ -13551,7 +13767,7 @@ var LinearCommandHandler = class {
|
|
|
13551
13767
|
} else {
|
|
13552
13768
|
ui.info("Copy a screenshot to your clipboard, then press Enter.");
|
|
13553
13769
|
}
|
|
13554
|
-
const rl = (0,
|
|
13770
|
+
const rl = (0, import_promises3.createInterface)({
|
|
13555
13771
|
input: process.stdin,
|
|
13556
13772
|
output: process.stdout
|
|
13557
13773
|
});
|
|
@@ -13567,14 +13783,14 @@ var LinearCommandHandler = class {
|
|
|
13567
13783
|
if (process.platform !== "darwin") {
|
|
13568
13784
|
throw new Error("Screenshot capture only supports macOS.");
|
|
13569
13785
|
}
|
|
13570
|
-
const dir = await
|
|
13571
|
-
const filePath =
|
|
13786
|
+
const dir = await import_node_fs7.promises.mkdtemp(import_node_path12.default.join(import_node_os4.default.tmpdir(), "pmate-screenshot-"));
|
|
13787
|
+
const filePath = import_node_path12.default.join(dir, `screenshot-${index}.png`);
|
|
13572
13788
|
try {
|
|
13573
13789
|
const code = await this.run("screencapture", ["-i", "-x", filePath], true);
|
|
13574
13790
|
if (code !== 0) {
|
|
13575
13791
|
throw new Error("Screenshot capture canceled or failed.");
|
|
13576
13792
|
}
|
|
13577
|
-
const buffer = await
|
|
13793
|
+
const buffer = await import_node_fs7.promises.readFile(filePath);
|
|
13578
13794
|
if (buffer.length === 0) {
|
|
13579
13795
|
throw new Error("Screenshot capture produced an empty file.");
|
|
13580
13796
|
}
|
|
@@ -13586,7 +13802,7 @@ var LinearCommandHandler = class {
|
|
|
13586
13802
|
return { buffer, mime, filename: `screenshot-${index}.${extension}` };
|
|
13587
13803
|
} finally {
|
|
13588
13804
|
try {
|
|
13589
|
-
await
|
|
13805
|
+
await import_node_fs7.promises.rm(dir, { recursive: true, force: true });
|
|
13590
13806
|
} catch {
|
|
13591
13807
|
}
|
|
13592
13808
|
}
|
|
@@ -13730,17 +13946,17 @@ var LinearCommandHandler = class {
|
|
|
13730
13946
|
return compact.length > limit ? `${compact.slice(0, limit)}...` : compact;
|
|
13731
13947
|
}
|
|
13732
13948
|
async convertToPng(buffer, ext) {
|
|
13733
|
-
const dir = await
|
|
13734
|
-
const inputPath =
|
|
13735
|
-
const outputPath =
|
|
13949
|
+
const dir = await import_node_fs7.promises.mkdtemp(import_node_path12.default.join(import_node_os4.default.tmpdir(), "pmate-"));
|
|
13950
|
+
const inputPath = import_node_path12.default.join(dir, `clipboard.${ext}`);
|
|
13951
|
+
const outputPath = import_node_path12.default.join(dir, "clipboard.png");
|
|
13736
13952
|
try {
|
|
13737
|
-
await
|
|
13953
|
+
await import_node_fs7.promises.writeFile(inputPath, buffer);
|
|
13738
13954
|
const stderr = await this.runCapture(
|
|
13739
13955
|
"sips",
|
|
13740
13956
|
["-s", "format", "png", inputPath, "--out", outputPath],
|
|
13741
13957
|
true
|
|
13742
13958
|
);
|
|
13743
|
-
const out = await
|
|
13959
|
+
const out = await import_node_fs7.promises.readFile(outputPath);
|
|
13744
13960
|
if (this.detectImageMime(out) !== "image/png") {
|
|
13745
13961
|
throw new Error(
|
|
13746
13962
|
stderr?.trim() ? `Failed to convert clipboard ${ext} to PNG: ${stderr.trim()}` : `Failed to convert clipboard ${ext} to PNG.`
|
|
@@ -13749,14 +13965,14 @@ var LinearCommandHandler = class {
|
|
|
13749
13965
|
return out;
|
|
13750
13966
|
} finally {
|
|
13751
13967
|
try {
|
|
13752
|
-
await
|
|
13968
|
+
await import_node_fs7.promises.rm(dir, { recursive: true, force: true });
|
|
13753
13969
|
} catch {
|
|
13754
13970
|
}
|
|
13755
13971
|
}
|
|
13756
13972
|
}
|
|
13757
13973
|
captureClipboard(preferred) {
|
|
13758
13974
|
return new Promise((resolve, reject) => {
|
|
13759
|
-
const child = (0,
|
|
13975
|
+
const child = (0, import_node_child_process8.spawn)("pbpaste", ["-Prefer", preferred], {
|
|
13760
13976
|
stdio: ["ignore", "pipe", "pipe"]
|
|
13761
13977
|
});
|
|
13762
13978
|
const chunks = [];
|
|
@@ -13966,7 +14182,7 @@ var LinearCommandHandler = class {
|
|
|
13966
14182
|
}
|
|
13967
14183
|
run(command, args, quietError = false, env, cwd) {
|
|
13968
14184
|
return new Promise((resolve, reject) => {
|
|
13969
|
-
const child = (0,
|
|
14185
|
+
const child = (0, import_node_child_process8.spawn)(command, args, {
|
|
13970
14186
|
stdio: quietError ? "ignore" : "inherit",
|
|
13971
14187
|
env: env ?? process.env,
|
|
13972
14188
|
cwd
|
|
@@ -13985,7 +14201,7 @@ var LinearCommandHandler = class {
|
|
|
13985
14201
|
}
|
|
13986
14202
|
runCapture(command, args, allowFailure = false, env, cwd) {
|
|
13987
14203
|
return new Promise((resolve, reject) => {
|
|
13988
|
-
const child = (0,
|
|
14204
|
+
const child = (0, import_node_child_process8.spawn)(command, args, {
|
|
13989
14205
|
stdio: ["ignore", "pipe", "pipe"],
|
|
13990
14206
|
env: env ?? process.env,
|
|
13991
14207
|
cwd
|
|
@@ -14043,7 +14259,7 @@ var LinearCommandHandler = class {
|
|
|
14043
14259
|
return this.runCapture("gh", args, allowFailure, await this.getGhEnv(cwd), cwd);
|
|
14044
14260
|
}
|
|
14045
14261
|
resolveCwd(value) {
|
|
14046
|
-
return value ?
|
|
14262
|
+
return value ? import_node_path12.default.resolve(process.cwd(), value) : process.cwd();
|
|
14047
14263
|
}
|
|
14048
14264
|
createOpenAiClient() {
|
|
14049
14265
|
const config = loadPmateConfig();
|
|
@@ -14095,8 +14311,8 @@ function sleep2(ms) {
|
|
|
14095
14311
|
}
|
|
14096
14312
|
|
|
14097
14313
|
// src/commands/NotionCommandHandler.ts
|
|
14098
|
-
var
|
|
14099
|
-
var
|
|
14314
|
+
var import_node_fs8 = require("fs");
|
|
14315
|
+
var import_node_path13 = __toESM(require("path"));
|
|
14100
14316
|
|
|
14101
14317
|
// src/services/NotionService.ts
|
|
14102
14318
|
var NotionService = class {
|
|
@@ -14335,9 +14551,9 @@ ${indent}\`\`\``;
|
|
|
14335
14551
|
static richTextToPlain(richText) {
|
|
14336
14552
|
return richText.map((item) => item.plain_text ?? item.text?.content ?? "").join("").trim();
|
|
14337
14553
|
}
|
|
14338
|
-
static async requestJson(
|
|
14554
|
+
static async requestJson(path25, init) {
|
|
14339
14555
|
const token = this.getToken();
|
|
14340
|
-
const response = await fetch(`${this.baseUrl}${
|
|
14556
|
+
const response = await fetch(`${this.baseUrl}${path25}`, {
|
|
14341
14557
|
method: init.method,
|
|
14342
14558
|
headers: {
|
|
14343
14559
|
Authorization: `Bearer ${token}`,
|
|
@@ -14435,17 +14651,17 @@ var NotionCommandHandler = class {
|
|
|
14435
14651
|
if (!args.filePath) {
|
|
14436
14652
|
return "";
|
|
14437
14653
|
}
|
|
14438
|
-
const resolved =
|
|
14439
|
-
return (0,
|
|
14654
|
+
const resolved = import_node_path13.default.resolve(process.cwd(), args.filePath);
|
|
14655
|
+
return (0, import_node_fs8.readFileSync)(resolved, "utf8");
|
|
14440
14656
|
}
|
|
14441
14657
|
};
|
|
14442
14658
|
|
|
14443
14659
|
// src/commands/QrcodeCommandHandler.ts
|
|
14444
|
-
var
|
|
14445
|
-
var
|
|
14446
|
-
var
|
|
14447
|
-
var
|
|
14448
|
-
var
|
|
14660
|
+
var import_node_child_process9 = require("child_process");
|
|
14661
|
+
var import_node_fs9 = require("fs");
|
|
14662
|
+
var import_node_os5 = __toESM(require("os"));
|
|
14663
|
+
var import_node_path14 = __toESM(require("path"));
|
|
14664
|
+
var import_promises4 = require("readline/promises");
|
|
14449
14665
|
var import_jsqr = __toESM(require("jsqr"));
|
|
14450
14666
|
var import_pngjs = require("pngjs");
|
|
14451
14667
|
var QrcodeCommandHandler = class {
|
|
@@ -14470,14 +14686,14 @@ var QrcodeCommandHandler = class {
|
|
|
14470
14686
|
ui.success("QR code value:", value);
|
|
14471
14687
|
} finally {
|
|
14472
14688
|
try {
|
|
14473
|
-
await
|
|
14689
|
+
await import_node_fs9.promises.rm(dir, { recursive: true, force: true });
|
|
14474
14690
|
} catch {
|
|
14475
14691
|
}
|
|
14476
14692
|
}
|
|
14477
14693
|
}
|
|
14478
14694
|
async captureScreenshot() {
|
|
14479
14695
|
ui.info("Capture a QR code screenshot now (macOS screencapture).");
|
|
14480
|
-
const rl = (0,
|
|
14696
|
+
const rl = (0, import_promises4.createInterface)({
|
|
14481
14697
|
input: process.stdin,
|
|
14482
14698
|
output: process.stdout
|
|
14483
14699
|
});
|
|
@@ -14486,13 +14702,13 @@ var QrcodeCommandHandler = class {
|
|
|
14486
14702
|
} finally {
|
|
14487
14703
|
rl.close();
|
|
14488
14704
|
}
|
|
14489
|
-
const dir = await
|
|
14490
|
-
const filePath =
|
|
14705
|
+
const dir = await import_node_fs9.promises.mkdtemp(import_node_path14.default.join(import_node_os5.default.tmpdir(), "pmate-qrcode-"));
|
|
14706
|
+
const filePath = import_node_path14.default.join(dir, "qrcode.png");
|
|
14491
14707
|
const code = await this.run("screencapture", ["-i", "-x", filePath], true);
|
|
14492
14708
|
if (code !== 0) {
|
|
14493
14709
|
throw new Error("Screenshot capture canceled or failed.");
|
|
14494
14710
|
}
|
|
14495
|
-
const buffer = await
|
|
14711
|
+
const buffer = await import_node_fs9.promises.readFile(filePath);
|
|
14496
14712
|
if (buffer.length === 0) {
|
|
14497
14713
|
throw new Error("Screenshot capture produced an empty file.");
|
|
14498
14714
|
}
|
|
@@ -14508,7 +14724,7 @@ var QrcodeCommandHandler = class {
|
|
|
14508
14724
|
async decodeQr(filePath) {
|
|
14509
14725
|
let buffer;
|
|
14510
14726
|
try {
|
|
14511
|
-
buffer = await
|
|
14727
|
+
buffer = await import_node_fs9.promises.readFile(filePath);
|
|
14512
14728
|
} catch {
|
|
14513
14729
|
return null;
|
|
14514
14730
|
}
|
|
@@ -14528,7 +14744,7 @@ var QrcodeCommandHandler = class {
|
|
|
14528
14744
|
return value ? value : null;
|
|
14529
14745
|
}
|
|
14530
14746
|
async promptValue(detected) {
|
|
14531
|
-
const rl = (0,
|
|
14747
|
+
const rl = (0, import_promises4.createInterface)({
|
|
14532
14748
|
input: process.stdin,
|
|
14533
14749
|
output: process.stdout
|
|
14534
14750
|
});
|
|
@@ -14549,7 +14765,7 @@ var QrcodeCommandHandler = class {
|
|
|
14549
14765
|
}
|
|
14550
14766
|
run(command, args, quietError = false, env, cwd) {
|
|
14551
14767
|
return new Promise((resolve, reject) => {
|
|
14552
|
-
const child = (0,
|
|
14768
|
+
const child = (0, import_node_child_process9.spawn)(command, args, {
|
|
14553
14769
|
stdio: quietError ? "ignore" : "inherit",
|
|
14554
14770
|
env: env ?? process.env,
|
|
14555
14771
|
cwd
|
|
@@ -14766,8 +14982,8 @@ function clampNumber(value, min, max, fallback) {
|
|
|
14766
14982
|
}
|
|
14767
14983
|
|
|
14768
14984
|
// src/commands/QuizCommandHandler.ts
|
|
14769
|
-
var
|
|
14770
|
-
var
|
|
14985
|
+
var import_node_fs10 = require("fs");
|
|
14986
|
+
var import_node_path15 = __toESM(require("path"));
|
|
14771
14987
|
init_sessionStore();
|
|
14772
14988
|
|
|
14773
14989
|
// src/services/QuizService.ts
|
|
@@ -15243,8 +15459,8 @@ var QuizCommandHandler = class {
|
|
|
15243
15459
|
return;
|
|
15244
15460
|
}
|
|
15245
15461
|
if (args.action === "update-meta") {
|
|
15246
|
-
const resolvedFilePath =
|
|
15247
|
-
const metadata = JSON.parse((0,
|
|
15462
|
+
const resolvedFilePath = import_node_path15.default.resolve(process.cwd(), args.filePath);
|
|
15463
|
+
const metadata = JSON.parse((0, import_node_fs10.readFileSync)(resolvedFilePath, "utf8"));
|
|
15248
15464
|
const result = await updateQuizPaperMetadata({
|
|
15249
15465
|
apiBaseUrl,
|
|
15250
15466
|
linkBaseUrl,
|
|
@@ -15256,8 +15472,8 @@ var QuizCommandHandler = class {
|
|
|
15256
15472
|
return;
|
|
15257
15473
|
}
|
|
15258
15474
|
if (args.action === "append-step") {
|
|
15259
|
-
const resolvedFilePath =
|
|
15260
|
-
const step = JSON.parse((0,
|
|
15475
|
+
const resolvedFilePath = import_node_path15.default.resolve(process.cwd(), args.filePath);
|
|
15476
|
+
const step = JSON.parse((0, import_node_fs10.readFileSync)(resolvedFilePath, "utf8"));
|
|
15261
15477
|
const result = await appendQuizPaperStep({
|
|
15262
15478
|
apiBaseUrl,
|
|
15263
15479
|
linkBaseUrl,
|
|
@@ -15270,8 +15486,8 @@ var QuizCommandHandler = class {
|
|
|
15270
15486
|
return;
|
|
15271
15487
|
}
|
|
15272
15488
|
if (args.action === "update-step") {
|
|
15273
|
-
const resolvedFilePath =
|
|
15274
|
-
const step = JSON.parse((0,
|
|
15489
|
+
const resolvedFilePath = import_node_path15.default.resolve(process.cwd(), args.filePath);
|
|
15490
|
+
const step = JSON.parse((0, import_node_fs10.readFileSync)(resolvedFilePath, "utf8"));
|
|
15275
15491
|
step.stepId = args.stepId;
|
|
15276
15492
|
const result = await updateQuizPaperStep({
|
|
15277
15493
|
apiBaseUrl,
|
|
@@ -15322,8 +15538,8 @@ var QuizCommandHandler = class {
|
|
|
15322
15538
|
if (targetIndex < 0) {
|
|
15323
15539
|
throw new Error(`\u672A\u627E\u5230 stepId=${args.stepId}\uFF0C\u65E0\u6CD5\u66F4\u65B0\u8BE5\u9898\u76EE\u3002`);
|
|
15324
15540
|
}
|
|
15325
|
-
const resolvedFilePath =
|
|
15326
|
-
const nextStep = JSON.parse((0,
|
|
15541
|
+
const resolvedFilePath = import_node_path15.default.resolve(process.cwd(), args.filePath);
|
|
15542
|
+
const nextStep = JSON.parse((0, import_node_fs10.readFileSync)(resolvedFilePath, "utf8"));
|
|
15327
15543
|
nextStep.stepId = args.stepId;
|
|
15328
15544
|
const nextSteps = [...basePaper.steps];
|
|
15329
15545
|
nextSteps[targetIndex] = nextStep;
|
|
@@ -15375,19 +15591,19 @@ var QuizCommandHandler = class {
|
|
|
15375
15591
|
// src/commands/CollectCommandHandler.ts
|
|
15376
15592
|
var import_playwright = require("playwright");
|
|
15377
15593
|
var import_node_crypto4 = require("crypto");
|
|
15378
|
-
var
|
|
15379
|
-
var
|
|
15380
|
-
var
|
|
15594
|
+
var import_node_fs12 = require("fs");
|
|
15595
|
+
var import_node_os7 = __toESM(require("os"));
|
|
15596
|
+
var import_node_path17 = __toESM(require("path"));
|
|
15381
15597
|
|
|
15382
15598
|
// src/collectStore.ts
|
|
15383
15599
|
var import_node_crypto3 = require("crypto");
|
|
15384
|
-
var
|
|
15385
|
-
var
|
|
15386
|
-
var
|
|
15600
|
+
var import_node_fs11 = require("fs");
|
|
15601
|
+
var import_node_os6 = __toESM(require("os"));
|
|
15602
|
+
var import_node_path16 = __toESM(require("path"));
|
|
15387
15603
|
function resolveCollectTarget(input) {
|
|
15388
15604
|
const endpoint = input.endpoint ?? (input.source === "cc" ? "http://localhost:9223" : "http://localhost:9222");
|
|
15389
15605
|
const sourceKey = input.source ?? `endpoint-${(0, import_node_crypto3.createHash)("sha1").update(endpoint).digest("hex").slice(0, 8)}`;
|
|
15390
|
-
const rootDir =
|
|
15606
|
+
const rootDir = import_node_path16.default.join(import_node_os6.default.homedir(), ".pmate", "collect", sourceKey);
|
|
15391
15607
|
return { sourceKey, endpoint, rootDir };
|
|
15392
15608
|
}
|
|
15393
15609
|
function toThreadKey(name) {
|
|
@@ -15399,7 +15615,7 @@ function toThreadKey(name) {
|
|
|
15399
15615
|
async function readStoredThread(rootDir, threadKey) {
|
|
15400
15616
|
const filePath = getThreadFilePath(rootDir, threadKey);
|
|
15401
15617
|
try {
|
|
15402
|
-
const raw = await
|
|
15618
|
+
const raw = await import_node_fs11.promises.readFile(filePath, "utf8");
|
|
15403
15619
|
return JSON.parse(raw);
|
|
15404
15620
|
} catch {
|
|
15405
15621
|
return null;
|
|
@@ -15407,13 +15623,13 @@ async function readStoredThread(rootDir, threadKey) {
|
|
|
15407
15623
|
}
|
|
15408
15624
|
async function writeStoredThread(rootDir, thread) {
|
|
15409
15625
|
const filePath = getThreadFilePath(rootDir, thread.threadKey);
|
|
15410
|
-
await
|
|
15411
|
-
await
|
|
15626
|
+
await import_node_fs11.promises.mkdir(import_node_path16.default.dirname(filePath), { recursive: true });
|
|
15627
|
+
await import_node_fs11.promises.writeFile(filePath, JSON.stringify(thread, null, 2) + "\n", "utf8");
|
|
15412
15628
|
}
|
|
15413
15629
|
async function writeStoredIndex(rootDir, index) {
|
|
15414
|
-
await
|
|
15415
|
-
const filePath =
|
|
15416
|
-
await
|
|
15630
|
+
await import_node_fs11.promises.mkdir(rootDir, { recursive: true });
|
|
15631
|
+
const filePath = import_node_path16.default.join(rootDir, "index.json");
|
|
15632
|
+
await import_node_fs11.promises.writeFile(filePath, JSON.stringify(index, null, 2) + "\n", "utf8");
|
|
15417
15633
|
}
|
|
15418
15634
|
function mergeMessages(existing, incoming) {
|
|
15419
15635
|
const seen = new Set(existing.map((message) => message.hash));
|
|
@@ -15430,7 +15646,7 @@ function mergeMessages(existing, incoming) {
|
|
|
15430
15646
|
return { messages: merged, added };
|
|
15431
15647
|
}
|
|
15432
15648
|
function getThreadFilePath(rootDir, threadKey) {
|
|
15433
|
-
return
|
|
15649
|
+
return import_node_path16.default.join(rootDir, "threads", `${threadKey}.json`);
|
|
15434
15650
|
}
|
|
15435
15651
|
|
|
15436
15652
|
// src/commands/CollectCommandHandler.ts
|
|
@@ -15842,19 +16058,19 @@ function parseMessageText(rawText) {
|
|
|
15842
16058
|
};
|
|
15843
16059
|
}
|
|
15844
16060
|
async function toDisplayableImagePath(src) {
|
|
15845
|
-
if (!
|
|
16061
|
+
if (!import_node_path17.default.isAbsolute(src)) {
|
|
15846
16062
|
return src;
|
|
15847
16063
|
}
|
|
15848
|
-
const ext =
|
|
16064
|
+
const ext = import_node_path17.default.extname(src);
|
|
15849
16065
|
if (ext) {
|
|
15850
16066
|
return src;
|
|
15851
16067
|
}
|
|
15852
16068
|
try {
|
|
15853
|
-
const stat = await
|
|
16069
|
+
const stat = await import_node_fs12.promises.stat(src);
|
|
15854
16070
|
if (!stat.isFile()) {
|
|
15855
16071
|
return src;
|
|
15856
16072
|
}
|
|
15857
|
-
const fh = await
|
|
16073
|
+
const fh = await import_node_fs12.promises.open(src, "r");
|
|
15858
16074
|
try {
|
|
15859
16075
|
const buf = Buffer.alloc(32);
|
|
15860
16076
|
const { bytesRead } = await fh.read(buf, 0, 32, 0);
|
|
@@ -15863,17 +16079,17 @@ async function toDisplayableImagePath(src) {
|
|
|
15863
16079
|
if (!guessedExt) {
|
|
15864
16080
|
return src;
|
|
15865
16081
|
}
|
|
15866
|
-
const cacheDir =
|
|
15867
|
-
|
|
16082
|
+
const cacheDir = import_node_path17.default.join(
|
|
16083
|
+
import_node_os7.default.homedir(),
|
|
15868
16084
|
".pmate",
|
|
15869
16085
|
"messages",
|
|
15870
16086
|
"images"
|
|
15871
16087
|
);
|
|
15872
|
-
await
|
|
16088
|
+
await import_node_fs12.promises.mkdir(cacheDir, { recursive: true });
|
|
15873
16089
|
const base = (0, import_node_crypto4.createHash)("sha1").update(src).digest("hex");
|
|
15874
|
-
const displayPath =
|
|
15875
|
-
await
|
|
15876
|
-
await
|
|
16090
|
+
const displayPath = import_node_path17.default.join(cacheDir, `${base}.${guessedExt}`);
|
|
16091
|
+
await import_node_fs12.promises.rm(displayPath, { force: true }).catch(() => void 0);
|
|
16092
|
+
await import_node_fs12.promises.copyFile(src, displayPath);
|
|
15877
16093
|
return displayPath;
|
|
15878
16094
|
} finally {
|
|
15879
16095
|
await fh.close();
|
|
@@ -15899,8 +16115,8 @@ function guessImageExtension(header) {
|
|
|
15899
16115
|
}
|
|
15900
16116
|
|
|
15901
16117
|
// src/commands/AgentCommandHandler.ts
|
|
15902
|
-
var
|
|
15903
|
-
var
|
|
16118
|
+
var import_node_fs13 = require("fs");
|
|
16119
|
+
var import_node_path18 = __toESM(require("path"));
|
|
15904
16120
|
init_AgentLlmClient();
|
|
15905
16121
|
init_sessionStore();
|
|
15906
16122
|
|
|
@@ -15933,8 +16149,8 @@ function descriptorPathSegments(descriptor) {
|
|
|
15933
16149
|
return ["chains", normalized.chain, "namespaces", normalized.ns, normalized.kind, normalized.name];
|
|
15934
16150
|
}
|
|
15935
16151
|
function buildPathUrl(baseUrl, pathSegments, query) {
|
|
15936
|
-
const
|
|
15937
|
-
const url = new URL(
|
|
16152
|
+
const path25 = `/${pathSegments.map((segment) => encodeURIComponent(segment)).join("/")}`;
|
|
16153
|
+
const url = new URL(path25, baseUrl);
|
|
15938
16154
|
if (query) {
|
|
15939
16155
|
for (const [key, value] of Object.entries(query)) {
|
|
15940
16156
|
url.searchParams.set(key, String(value));
|
|
@@ -16366,11 +16582,11 @@ var AgentCommandHandler = class {
|
|
|
16366
16582
|
}).token;
|
|
16367
16583
|
}
|
|
16368
16584
|
readJsonFile(filePath) {
|
|
16369
|
-
const absolutePath =
|
|
16370
|
-
if (!(0,
|
|
16585
|
+
const absolutePath = import_node_path18.default.resolve(process.cwd(), filePath);
|
|
16586
|
+
if (!(0, import_node_fs13.existsSync)(absolutePath)) {
|
|
16371
16587
|
throw new Error(`JSON file not found: ${absolutePath}`);
|
|
16372
16588
|
}
|
|
16373
|
-
const raw = (0,
|
|
16589
|
+
const raw = (0, import_node_fs13.readFileSync)(absolutePath, "utf8");
|
|
16374
16590
|
try {
|
|
16375
16591
|
return JSON.parse(raw);
|
|
16376
16592
|
} catch (error) {
|
|
@@ -16381,7 +16597,7 @@ var AgentCommandHandler = class {
|
|
|
16381
16597
|
readJsonObjectFile(filePath) {
|
|
16382
16598
|
const parsed = this.readJsonFile(filePath);
|
|
16383
16599
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
16384
|
-
const absolutePath =
|
|
16600
|
+
const absolutePath = import_node_path18.default.resolve(process.cwd(), filePath);
|
|
16385
16601
|
throw new Error(`Invalid JSON in ${absolutePath}: expected an object`);
|
|
16386
16602
|
}
|
|
16387
16603
|
return parsed;
|
|
@@ -16465,8 +16681,8 @@ var AgentCommandHandler = class {
|
|
|
16465
16681
|
};
|
|
16466
16682
|
|
|
16467
16683
|
// src/commands/RunnerCommandHandler.ts
|
|
16468
|
-
var
|
|
16469
|
-
var
|
|
16684
|
+
var import_node_fs14 = require("fs");
|
|
16685
|
+
var import_node_path19 = __toESM(require("path"));
|
|
16470
16686
|
init_sessionStore();
|
|
16471
16687
|
init_namespacedRef();
|
|
16472
16688
|
var RunnerCommandHandler = class {
|
|
@@ -16561,11 +16777,11 @@ var RunnerCommandHandler = class {
|
|
|
16561
16777
|
}).token;
|
|
16562
16778
|
}
|
|
16563
16779
|
readJsonFile(filePath) {
|
|
16564
|
-
const absolutePath =
|
|
16565
|
-
if (!(0,
|
|
16780
|
+
const absolutePath = import_node_path19.default.resolve(process.cwd(), filePath);
|
|
16781
|
+
if (!(0, import_node_fs14.existsSync)(absolutePath)) {
|
|
16566
16782
|
throw new Error(`JSON file not found: ${absolutePath}`);
|
|
16567
16783
|
}
|
|
16568
|
-
const raw = (0,
|
|
16784
|
+
const raw = (0, import_node_fs14.readFileSync)(absolutePath, "utf8");
|
|
16569
16785
|
try {
|
|
16570
16786
|
return JSON.parse(raw);
|
|
16571
16787
|
} catch (error) {
|
|
@@ -16684,8 +16900,8 @@ var NsCommandHandler = class {
|
|
|
16684
16900
|
};
|
|
16685
16901
|
|
|
16686
16902
|
// src/commands/StoreCommandHandler.ts
|
|
16687
|
-
var
|
|
16688
|
-
var
|
|
16903
|
+
var import_node_fs15 = require("fs");
|
|
16904
|
+
var import_node_path20 = __toESM(require("path"));
|
|
16689
16905
|
var StoreCommandHandler = class {
|
|
16690
16906
|
async handle(args) {
|
|
16691
16907
|
if (args.scope === "namespace") {
|
|
@@ -16827,11 +17043,11 @@ var StoreCommandHandler = class {
|
|
|
16827
17043
|
return payload.data ?? [];
|
|
16828
17044
|
}
|
|
16829
17045
|
readJsonFile(filePath) {
|
|
16830
|
-
const absolutePath =
|
|
16831
|
-
if (!(0,
|
|
17046
|
+
const absolutePath = import_node_path20.default.resolve(process.cwd(), filePath);
|
|
17047
|
+
if (!(0, import_node_fs15.existsSync)(absolutePath)) {
|
|
16832
17048
|
throw new Error(`JSON file not found: ${absolutePath}`);
|
|
16833
17049
|
}
|
|
16834
|
-
const raw = (0,
|
|
17050
|
+
const raw = (0, import_node_fs15.readFileSync)(absolutePath, "utf8");
|
|
16835
17051
|
try {
|
|
16836
17052
|
return JSON.parse(raw);
|
|
16837
17053
|
} catch (error) {
|
|
@@ -16883,8 +17099,8 @@ var StoreCommandHandler = class {
|
|
|
16883
17099
|
};
|
|
16884
17100
|
|
|
16885
17101
|
// src/commands/AppCommandHandler.ts
|
|
16886
|
-
var
|
|
16887
|
-
var
|
|
17102
|
+
var import_node_fs16 = require("fs");
|
|
17103
|
+
var import_node_path21 = __toESM(require("path"));
|
|
16888
17104
|
init_sessionStore();
|
|
16889
17105
|
init_namespacedRef();
|
|
16890
17106
|
var AppCommandHandler = class {
|
|
@@ -17001,11 +17217,11 @@ var AppCommandHandler = class {
|
|
|
17001
17217
|
}).token;
|
|
17002
17218
|
}
|
|
17003
17219
|
readJsonFile(filePath) {
|
|
17004
|
-
const absolutePath =
|
|
17005
|
-
if (!(0,
|
|
17220
|
+
const absolutePath = import_node_path21.default.resolve(process.cwd(), filePath);
|
|
17221
|
+
if (!(0, import_node_fs16.existsSync)(absolutePath)) {
|
|
17006
17222
|
throw new Error(`JSON file not found: ${absolutePath}`);
|
|
17007
17223
|
}
|
|
17008
|
-
const raw = (0,
|
|
17224
|
+
const raw = (0, import_node_fs16.readFileSync)(absolutePath, "utf8");
|
|
17009
17225
|
try {
|
|
17010
17226
|
return JSON.parse(raw);
|
|
17011
17227
|
} catch (error) {
|
|
@@ -17085,14 +17301,14 @@ function readNamespaceFromPayload(payload) {
|
|
|
17085
17301
|
}
|
|
17086
17302
|
|
|
17087
17303
|
// src/commands/ServiceCommandHandler.ts
|
|
17088
|
-
var
|
|
17089
|
-
var
|
|
17304
|
+
var import_node_fs18 = require("fs");
|
|
17305
|
+
var import_node_path23 = __toESM(require("path"));
|
|
17090
17306
|
|
|
17091
17307
|
// src/services/ServiceRuntimeRunner.ts
|
|
17092
|
-
var
|
|
17093
|
-
var
|
|
17094
|
-
var
|
|
17095
|
-
var
|
|
17308
|
+
var import_node_fs17 = require("fs");
|
|
17309
|
+
var import_node_os8 = __toESM(require("os"));
|
|
17310
|
+
var import_node_path22 = __toESM(require("path"));
|
|
17311
|
+
var import_node_child_process10 = require("child_process");
|
|
17096
17312
|
var import_node_readline = require("readline");
|
|
17097
17313
|
var import_chalk3 = __toESM(require("chalk"));
|
|
17098
17314
|
var ServiceRuntimeRunner = class {
|
|
@@ -17204,14 +17420,14 @@ var ServiceRuntimeRunner = class {
|
|
|
17204
17420
|
}
|
|
17205
17421
|
resolveRepoRoot(service, cwd) {
|
|
17206
17422
|
if (cwd) {
|
|
17207
|
-
return
|
|
17423
|
+
return import_node_path22.default.resolve(process.cwd(), cwd);
|
|
17208
17424
|
}
|
|
17209
17425
|
const repository = this.getDeploy(service).repository?.trim();
|
|
17210
17426
|
if (repository) {
|
|
17211
17427
|
const repoName = repository.replace(/\/+$/, "").split("/").pop()?.replace(/\.git$/i, "");
|
|
17212
17428
|
if (repoName) {
|
|
17213
|
-
const candidate =
|
|
17214
|
-
if ((0,
|
|
17429
|
+
const candidate = import_node_path22.default.join(import_node_os8.default.homedir(), "dev", "pmate", repoName);
|
|
17430
|
+
if ((0, import_node_fs17.existsSync)(candidate)) {
|
|
17215
17431
|
return candidate;
|
|
17216
17432
|
}
|
|
17217
17433
|
}
|
|
@@ -17224,12 +17440,12 @@ var ServiceRuntimeRunner = class {
|
|
|
17224
17440
|
if (!dir) {
|
|
17225
17441
|
throw new Error(`Missing deploy.dir for ${service.id}`);
|
|
17226
17442
|
}
|
|
17227
|
-
return
|
|
17443
|
+
return import_node_path22.default.resolve(repoRoot, dir);
|
|
17228
17444
|
}
|
|
17229
17445
|
async deployVite(service, options) {
|
|
17230
17446
|
const appDir = this.resolveLocalDir(service, options.cwd);
|
|
17231
|
-
const packageJsonPath =
|
|
17232
|
-
if (!(0,
|
|
17447
|
+
const packageJsonPath = import_node_path22.default.join(appDir, "package.json");
|
|
17448
|
+
if (!(0, import_node_fs17.existsSync)(packageJsonPath)) {
|
|
17233
17449
|
throw new Error(`No package.json found at ${packageJsonPath}`);
|
|
17234
17450
|
}
|
|
17235
17451
|
const pkg2 = this.loadPackageJson(packageJsonPath);
|
|
@@ -17238,8 +17454,8 @@ var ServiceRuntimeRunner = class {
|
|
|
17238
17454
|
throw new Error(`Missing package name in ${packageJsonPath}`);
|
|
17239
17455
|
}
|
|
17240
17456
|
await this.runCommand("pnpm", ["--filter", pkgName, "build"], this.resolveRepoRoot(service, options.cwd));
|
|
17241
|
-
const distDir =
|
|
17242
|
-
if (!(0,
|
|
17457
|
+
const distDir = import_node_path22.default.join(appDir, "dist");
|
|
17458
|
+
if (!(0, import_node_fs17.existsSync)(distDir)) {
|
|
17243
17459
|
throw new Error(`No dist directory found at ${distDir}`);
|
|
17244
17460
|
}
|
|
17245
17461
|
const bucketName = this.getDeploy(service).bucket?.trim();
|
|
@@ -17250,8 +17466,8 @@ var ServiceRuntimeRunner = class {
|
|
|
17250
17466
|
}
|
|
17251
17467
|
async deployStatic(service, options) {
|
|
17252
17468
|
const appDir = this.resolveLocalDir(service, options.cwd);
|
|
17253
|
-
const srcDir =
|
|
17254
|
-
if (!(0,
|
|
17469
|
+
const srcDir = import_node_path22.default.join(appDir, "src");
|
|
17470
|
+
if (!(0, import_node_fs17.existsSync)(srcDir)) {
|
|
17255
17471
|
throw new Error(`No src directory found at ${srcDir}`);
|
|
17256
17472
|
}
|
|
17257
17473
|
const bucketName = this.getDeploy(service).bucket?.trim();
|
|
@@ -17369,7 +17585,7 @@ var ServiceRuntimeRunner = class {
|
|
|
17369
17585
|
const serverAddress = await resolveServerAddress(server);
|
|
17370
17586
|
const templateName = serviceType === "ws" ? "nginx.ws.template" : "nginx.rest.template";
|
|
17371
17587
|
const templatePath = this.resolveTemplatePath(templateName);
|
|
17372
|
-
const template = (0,
|
|
17588
|
+
const template = (0, import_node_fs17.readFileSync)(templatePath, "utf8");
|
|
17373
17589
|
const host = `${subdomain}.${deploy.domain?.trim() || "pmate.chat"}`;
|
|
17374
17590
|
const rendered = template.replace(/\$\{\{PORT\}\}/g, String(port)).replace(/\$\{\{HOSTS\}\}/g, host).replace(/\$\{\{HOST\}\}/g, host);
|
|
17375
17591
|
const remotePath = `/etc/nginx/sites-enabled/${subdomain}.conf`;
|
|
@@ -17401,11 +17617,11 @@ var ServiceRuntimeRunner = class {
|
|
|
17401
17617
|
}
|
|
17402
17618
|
if (config.ensurePackageJson) {
|
|
17403
17619
|
const appDir = this.resolveLocalDir(service, options.cwd);
|
|
17404
|
-
const packageJsonPath =
|
|
17405
|
-
if (!(0,
|
|
17620
|
+
const packageJsonPath = import_node_path22.default.join(appDir, "package.json");
|
|
17621
|
+
if (!(0, import_node_fs17.existsSync)(packageJsonPath)) {
|
|
17406
17622
|
throw new Error(`Missing package.json at ${packageJsonPath}`);
|
|
17407
17623
|
}
|
|
17408
|
-
const pkgStat = (0,
|
|
17624
|
+
const pkgStat = (0, import_node_fs17.statSync)(packageJsonPath);
|
|
17409
17625
|
if (!pkgStat.isFile()) {
|
|
17410
17626
|
throw new Error(`package.json is not a file at ${packageJsonPath}`);
|
|
17411
17627
|
}
|
|
@@ -17828,9 +18044,9 @@ var ServiceRuntimeRunner = class {
|
|
|
17828
18044
|
return tokens;
|
|
17829
18045
|
}
|
|
17830
18046
|
readPathValue(source, pathExpr) {
|
|
17831
|
-
const
|
|
18047
|
+
const path25 = pathExpr.split(".").map((segment) => segment.trim()).filter(Boolean);
|
|
17832
18048
|
let cursor = source;
|
|
17833
|
-
for (const segment of
|
|
18049
|
+
for (const segment of path25) {
|
|
17834
18050
|
if (!cursor || typeof cursor !== "object" || Array.isArray(cursor)) {
|
|
17835
18051
|
return void 0;
|
|
17836
18052
|
}
|
|
@@ -17873,12 +18089,12 @@ var ServiceRuntimeRunner = class {
|
|
|
17873
18089
|
}
|
|
17874
18090
|
resolveTemplatePath(templateName) {
|
|
17875
18091
|
const candidates = [
|
|
17876
|
-
|
|
17877
|
-
|
|
17878
|
-
|
|
18092
|
+
import_node_path22.default.join(__dirname, "..", "templates", templateName),
|
|
18093
|
+
import_node_path22.default.join(__dirname, "..", "src", "templates", templateName),
|
|
18094
|
+
import_node_path22.default.join(__dirname, "templates", templateName)
|
|
17879
18095
|
];
|
|
17880
18096
|
for (const candidate of candidates) {
|
|
17881
|
-
if ((0,
|
|
18097
|
+
if ((0, import_node_fs17.existsSync)(candidate)) {
|
|
17882
18098
|
return candidate;
|
|
17883
18099
|
}
|
|
17884
18100
|
}
|
|
@@ -17887,7 +18103,7 @@ var ServiceRuntimeRunner = class {
|
|
|
17887
18103
|
writeRemoteConfig(server, content, remotePath) {
|
|
17888
18104
|
return new Promise((resolve, reject) => {
|
|
17889
18105
|
const target = `pmate@${server}`;
|
|
17890
|
-
const child = (0,
|
|
18106
|
+
const child = (0, import_node_child_process10.spawn)("ssh", [target, "sudo", "tee", remotePath], {
|
|
17891
18107
|
stdio: ["pipe", "inherit", "inherit"]
|
|
17892
18108
|
});
|
|
17893
18109
|
child.on("error", reject);
|
|
@@ -17902,7 +18118,7 @@ var ServiceRuntimeRunner = class {
|
|
|
17902
18118
|
reloadNginx(server) {
|
|
17903
18119
|
return new Promise((resolve, reject) => {
|
|
17904
18120
|
const target = `pmate@${server}`;
|
|
17905
|
-
const child = (0,
|
|
18121
|
+
const child = (0, import_node_child_process10.spawn)("ssh", [target, "sudo", "nginx", "-s", "reload"], {
|
|
17906
18122
|
stdio: ["ignore", "inherit", "inherit"]
|
|
17907
18123
|
});
|
|
17908
18124
|
child.on("error", reject);
|
|
@@ -17910,7 +18126,7 @@ var ServiceRuntimeRunner = class {
|
|
|
17910
18126
|
});
|
|
17911
18127
|
}
|
|
17912
18128
|
loadPackageJson(packageJsonPath) {
|
|
17913
|
-
const raw = (0,
|
|
18129
|
+
const raw = (0, import_node_fs17.readFileSync)(packageJsonPath, "utf8");
|
|
17914
18130
|
const parsed = JSON.parse(raw);
|
|
17915
18131
|
if (!parsed || typeof parsed !== "object") {
|
|
17916
18132
|
throw new Error(`Invalid package.json at ${packageJsonPath}`);
|
|
@@ -17919,12 +18135,12 @@ var ServiceRuntimeRunner = class {
|
|
|
17919
18135
|
}
|
|
17920
18136
|
writePackageJson(packageJsonPath, data) {
|
|
17921
18137
|
const serialized = JSON.stringify(data, null, 2);
|
|
17922
|
-
(0,
|
|
18138
|
+
(0, import_node_fs17.writeFileSync)(packageJsonPath, `${serialized}
|
|
17923
18139
|
`, "utf8");
|
|
17924
18140
|
}
|
|
17925
18141
|
runCommand(command, args, cwd) {
|
|
17926
18142
|
return new Promise((resolve, reject) => {
|
|
17927
|
-
const child = (0,
|
|
18143
|
+
const child = (0, import_node_child_process10.spawn)(command, args, { cwd, stdio: "inherit" });
|
|
17928
18144
|
child.on("error", reject);
|
|
17929
18145
|
child.on("close", (code) => code === 0 ? resolve() : reject(new Error(`${command} exited with code ${code}`)));
|
|
17930
18146
|
});
|
|
@@ -17932,7 +18148,7 @@ var ServiceRuntimeRunner = class {
|
|
|
17932
18148
|
runRemoteCommand(server, command) {
|
|
17933
18149
|
return new Promise((resolve, reject) => {
|
|
17934
18150
|
const target = `pmate@${server}`;
|
|
17935
|
-
const child = (0,
|
|
18151
|
+
const child = (0, import_node_child_process10.spawn)("ssh", buildSshBashArgs(target, command), { stdio: "inherit" });
|
|
17936
18152
|
child.on("error", reject);
|
|
17937
18153
|
child.on("close", (code) => code === 0 ? resolve() : reject(new Error(`ssh to ${server} exited with code ${code}`)));
|
|
17938
18154
|
});
|
|
@@ -18187,11 +18403,11 @@ var ServiceCommandHandler = class {
|
|
|
18187
18403
|
return (baseUrl || process.env.PMATE_APPS_API_BASE_URL || "https://apps-api.pmate.chat").replace(/\/+$/, "");
|
|
18188
18404
|
}
|
|
18189
18405
|
readJsonFile(filePath) {
|
|
18190
|
-
const absolutePath =
|
|
18191
|
-
if (!(0,
|
|
18406
|
+
const absolutePath = import_node_path23.default.resolve(process.cwd(), filePath);
|
|
18407
|
+
if (!(0, import_node_fs18.existsSync)(absolutePath)) {
|
|
18192
18408
|
throw new Error(`JSON file not found: ${absolutePath}`);
|
|
18193
18409
|
}
|
|
18194
|
-
const raw = (0,
|
|
18410
|
+
const raw = (0, import_node_fs18.readFileSync)(absolutePath, "utf8");
|
|
18195
18411
|
try {
|
|
18196
18412
|
return JSON.parse(raw);
|
|
18197
18413
|
} catch (error) {
|
|
@@ -18290,9 +18506,9 @@ var ServiceCommandHandler = class {
|
|
|
18290
18506
|
};
|
|
18291
18507
|
|
|
18292
18508
|
// src/commands/VercelCommandHandler.ts
|
|
18293
|
-
var
|
|
18294
|
-
var
|
|
18295
|
-
var
|
|
18509
|
+
var import_node_child_process11 = require("child_process");
|
|
18510
|
+
var import_node_util2 = require("util");
|
|
18511
|
+
var execFileAsync2 = (0, import_node_util2.promisify)(import_node_child_process11.execFile);
|
|
18296
18512
|
function parseDeploymentTimestamp(deployment) {
|
|
18297
18513
|
const candidates = [deployment.createdAt, deployment.readyAt, deployment.ready];
|
|
18298
18514
|
for (const value of candidates) {
|
|
@@ -18320,7 +18536,7 @@ function filterDeploymentsFromLastWeek(deployments, now = Date.now()) {
|
|
|
18320
18536
|
});
|
|
18321
18537
|
}
|
|
18322
18538
|
var VercelCommandHandler = class {
|
|
18323
|
-
constructor(runCommand = async (command, args) =>
|
|
18539
|
+
constructor(runCommand = async (command, args) => execFileAsync2(command, args, { maxBuffer: 1024 * 1024 * 20 }), getConfig = loadPmateConfig) {
|
|
18324
18540
|
this.runCommand = runCommand;
|
|
18325
18541
|
this.getConfig = getConfig;
|
|
18326
18542
|
}
|
|
@@ -20220,9 +20436,95 @@ function requireValue9(tokens, optionName) {
|
|
|
20220
20436
|
return value;
|
|
20221
20437
|
}
|
|
20222
20438
|
|
|
20439
|
+
// src/prepareDevCommandParser.ts
|
|
20440
|
+
function parsePrepareDevArgs(tokens) {
|
|
20441
|
+
const rest = [...tokens];
|
|
20442
|
+
const repo = rest.shift();
|
|
20443
|
+
if (!repo || repo.startsWith("-")) {
|
|
20444
|
+
throw new Error("Missing repo name. Usage: prepare-dev <repo> --open|--close [options]");
|
|
20445
|
+
}
|
|
20446
|
+
if (repo.includes("/") || repo.includes("\\")) {
|
|
20447
|
+
throw new Error(`Invalid repo name: ${repo}`);
|
|
20448
|
+
}
|
|
20449
|
+
let open = false;
|
|
20450
|
+
let close = false;
|
|
20451
|
+
let envIndex;
|
|
20452
|
+
let note;
|
|
20453
|
+
let envRoot;
|
|
20454
|
+
let baseRoot;
|
|
20455
|
+
let json = false;
|
|
20456
|
+
while (rest.length > 0) {
|
|
20457
|
+
const token = rest.shift();
|
|
20458
|
+
switch (token) {
|
|
20459
|
+
case "--open":
|
|
20460
|
+
open = true;
|
|
20461
|
+
break;
|
|
20462
|
+
case "--close":
|
|
20463
|
+
close = true;
|
|
20464
|
+
break;
|
|
20465
|
+
case "--env": {
|
|
20466
|
+
const rawValue = requireValue10(rest, token);
|
|
20467
|
+
const parsed = Number.parseInt(rawValue, 10);
|
|
20468
|
+
if (!Number.isInteger(parsed) || parsed < 0) {
|
|
20469
|
+
throw new Error(`Invalid --env value: ${rawValue}`);
|
|
20470
|
+
}
|
|
20471
|
+
envIndex = parsed;
|
|
20472
|
+
break;
|
|
20473
|
+
}
|
|
20474
|
+
case "--env-root":
|
|
20475
|
+
envRoot = requireValue10(rest, token);
|
|
20476
|
+
break;
|
|
20477
|
+
case "--base-root":
|
|
20478
|
+
baseRoot = requireValue10(rest, token);
|
|
20479
|
+
break;
|
|
20480
|
+
case "--note":
|
|
20481
|
+
note = requireValue10(rest, token);
|
|
20482
|
+
break;
|
|
20483
|
+
case "--json":
|
|
20484
|
+
json = true;
|
|
20485
|
+
break;
|
|
20486
|
+
default:
|
|
20487
|
+
throw new Error(`Unknown prepare-dev option: ${token}`);
|
|
20488
|
+
}
|
|
20489
|
+
}
|
|
20490
|
+
if (open === close) {
|
|
20491
|
+
throw new Error("Use exactly one of --open or --close.");
|
|
20492
|
+
}
|
|
20493
|
+
if (open) {
|
|
20494
|
+
return {
|
|
20495
|
+
type: "prepare-dev" /* PrepareDev */,
|
|
20496
|
+
action: "open",
|
|
20497
|
+
repo,
|
|
20498
|
+
note,
|
|
20499
|
+
envRoot,
|
|
20500
|
+
baseRoot,
|
|
20501
|
+
json
|
|
20502
|
+
};
|
|
20503
|
+
}
|
|
20504
|
+
if (envIndex === void 0) {
|
|
20505
|
+
throw new Error("Missing required option --env for prepare-dev --close.");
|
|
20506
|
+
}
|
|
20507
|
+
return {
|
|
20508
|
+
type: "prepare-dev" /* PrepareDev */,
|
|
20509
|
+
action: "close",
|
|
20510
|
+
repo,
|
|
20511
|
+
envIndex,
|
|
20512
|
+
envRoot,
|
|
20513
|
+
baseRoot,
|
|
20514
|
+
json
|
|
20515
|
+
};
|
|
20516
|
+
}
|
|
20517
|
+
function requireValue10(tokens, option) {
|
|
20518
|
+
const value = tokens.shift();
|
|
20519
|
+
if (!value || value.startsWith("-")) {
|
|
20520
|
+
throw new Error(`Missing value for ${option}`);
|
|
20521
|
+
}
|
|
20522
|
+
return value;
|
|
20523
|
+
}
|
|
20524
|
+
|
|
20223
20525
|
// src/index.ts
|
|
20224
20526
|
var pkg = JSON.parse(
|
|
20225
|
-
(0,
|
|
20527
|
+
(0, import_node_fs19.readFileSync)(import_node_path24.default.resolve(__dirname, "..", "package.json"), "utf8")
|
|
20226
20528
|
);
|
|
20227
20529
|
var HELP_TEXT = [
|
|
20228
20530
|
import_chalk4.default.bold(`pmate v${pkg.version}`),
|
|
@@ -20248,6 +20550,9 @@ var HELP_TEXT = [
|
|
|
20248
20550
|
` ${import_chalk4.default.gray(" [app] <app-name> [--cwd <dir>]")}`,
|
|
20249
20551
|
` ${import_chalk4.default.cyan("dev")} Run the dev script for app dir from .pmate.yaml`,
|
|
20250
20552
|
` ${import_chalk4.default.gray(" <app-name> [--cwd <dir>]")}`,
|
|
20553
|
+
` ${import_chalk4.default.cyan("prepare-dev")} Open or close a local dev environment under ~/dev/pmate-envs`,
|
|
20554
|
+
` ${import_chalk4.default.gray(" <repo> --open [--note <text>] [--env-root <dir>] [--base-root <dir>] [--json]")}`,
|
|
20555
|
+
` ${import_chalk4.default.gray(" <repo> --close --env <n> [--env-root <dir>] [--base-root <dir>] [--json]")}`,
|
|
20251
20556
|
` ${import_chalk4.default.cyan("env")} Manage app env vars on the server`,
|
|
20252
20557
|
` ${import_chalk4.default.gray(" <app-name> --list|--set <key> --value <value> [--delete <key>] [--cwd <dir>] [--verbose|-v]")}`,
|
|
20253
20558
|
` ${import_chalk4.default.cyan("pr")} Create or update GitHub PRs with AI assistance`,
|
|
@@ -20424,7 +20729,7 @@ function parseCommandArgs(args) {
|
|
|
20424
20729
|
const token = rest.shift();
|
|
20425
20730
|
switch (token) {
|
|
20426
20731
|
case "--app":
|
|
20427
|
-
app =
|
|
20732
|
+
app = requireValue11(rest, token);
|
|
20428
20733
|
break;
|
|
20429
20734
|
default:
|
|
20430
20735
|
throw new Error(`Unknown login option: ${token}`);
|
|
@@ -20450,6 +20755,9 @@ function parseCommandArgs(args) {
|
|
|
20450
20755
|
if (args.rest[0] === "dev") {
|
|
20451
20756
|
return parseDevArgs(args.rest.slice(1));
|
|
20452
20757
|
}
|
|
20758
|
+
if (args.rest[0] === "prepare-dev") {
|
|
20759
|
+
return parsePrepareDevArgs(args.rest.slice(1));
|
|
20760
|
+
}
|
|
20453
20761
|
if (args.rest[0] === "oss") {
|
|
20454
20762
|
return parseOssArgs(args.rest.slice(1));
|
|
20455
20763
|
}
|
|
@@ -20524,7 +20832,7 @@ function parseVercelArgs(tokens) {
|
|
|
20524
20832
|
const token = rest.shift();
|
|
20525
20833
|
switch (token) {
|
|
20526
20834
|
case "--scope":
|
|
20527
|
-
scope =
|
|
20835
|
+
scope = requireValue11(rest, token);
|
|
20528
20836
|
break;
|
|
20529
20837
|
default:
|
|
20530
20838
|
throw new Error(`Unknown vercel option: ${token}`);
|
|
@@ -20544,10 +20852,10 @@ function parseVercelArgs(tokens) {
|
|
|
20544
20852
|
const token = rest.shift();
|
|
20545
20853
|
switch (token) {
|
|
20546
20854
|
case "--scope":
|
|
20547
|
-
scope =
|
|
20855
|
+
scope = requireValue11(rest, token);
|
|
20548
20856
|
break;
|
|
20549
20857
|
case "--project":
|
|
20550
|
-
project =
|
|
20858
|
+
project = requireValue11(rest, token);
|
|
20551
20859
|
break;
|
|
20552
20860
|
case "--last-week":
|
|
20553
20861
|
lastWeek = true;
|
|
@@ -20578,16 +20886,16 @@ function parseAddDnsArgs(tokens) {
|
|
|
20578
20886
|
const token = rest.shift();
|
|
20579
20887
|
switch (token) {
|
|
20580
20888
|
case "--type":
|
|
20581
|
-
options.dnsType =
|
|
20889
|
+
options.dnsType = requireValue11(rest, token);
|
|
20582
20890
|
break;
|
|
20583
20891
|
case "--value":
|
|
20584
|
-
options.dnsValue =
|
|
20892
|
+
options.dnsValue = requireValue11(rest, token);
|
|
20585
20893
|
break;
|
|
20586
20894
|
case "--rr":
|
|
20587
|
-
options.dnsRr =
|
|
20895
|
+
options.dnsRr = requireValue11(rest, token);
|
|
20588
20896
|
break;
|
|
20589
20897
|
case "--ttl": {
|
|
20590
|
-
const ttlValue =
|
|
20898
|
+
const ttlValue = requireValue11(rest, token);
|
|
20591
20899
|
const ttl = Number.parseInt(ttlValue, 10);
|
|
20592
20900
|
if (!Number.isFinite(ttl) || ttl <= 0) {
|
|
20593
20901
|
throw new Error(`Invalid --ttl value: ${ttlValue}`);
|
|
@@ -20596,7 +20904,7 @@ function parseAddDnsArgs(tokens) {
|
|
|
20596
20904
|
break;
|
|
20597
20905
|
}
|
|
20598
20906
|
case "--domain":
|
|
20599
|
-
options.dnsDomain =
|
|
20907
|
+
options.dnsDomain = requireValue11(rest, token);
|
|
20600
20908
|
break;
|
|
20601
20909
|
default:
|
|
20602
20910
|
throw new Error(`Unknown add-dns option: ${token}`);
|
|
@@ -20629,13 +20937,13 @@ function parseBucketArgs(tokens) {
|
|
|
20629
20937
|
options.bucketCreate = true;
|
|
20630
20938
|
break;
|
|
20631
20939
|
case "--name":
|
|
20632
|
-
options.bucketName =
|
|
20940
|
+
options.bucketName = requireValue11(rest, token);
|
|
20633
20941
|
break;
|
|
20634
20942
|
case "--subdomain":
|
|
20635
|
-
options.bucketSubdomain =
|
|
20943
|
+
options.bucketSubdomain = requireValue11(rest, token);
|
|
20636
20944
|
break;
|
|
20637
20945
|
case "--domain":
|
|
20638
|
-
options.bucketDomain =
|
|
20946
|
+
options.bucketDomain = requireValue11(rest, token);
|
|
20639
20947
|
break;
|
|
20640
20948
|
default:
|
|
20641
20949
|
throw new Error(`Unknown bucket option: ${token}`);
|
|
@@ -20667,7 +20975,7 @@ function parseDevArgs(tokens) {
|
|
|
20667
20975
|
const token = rest.shift();
|
|
20668
20976
|
switch (token) {
|
|
20669
20977
|
case "--cwd":
|
|
20670
|
-
options.devCwd =
|
|
20978
|
+
options.devCwd = requireValue11(rest, token);
|
|
20671
20979
|
break;
|
|
20672
20980
|
default:
|
|
20673
20981
|
throw new Error(`Unknown dev option: ${token}`);
|
|
@@ -20687,7 +20995,7 @@ function parseDeleteArgs(tokens) {
|
|
|
20687
20995
|
const token = rest.shift();
|
|
20688
20996
|
switch (token) {
|
|
20689
20997
|
case "--cwd":
|
|
20690
|
-
deleteCwd =
|
|
20998
|
+
deleteCwd = requireValue11(rest, token);
|
|
20691
20999
|
break;
|
|
20692
21000
|
default:
|
|
20693
21001
|
throw new Error(`Unknown delete option: ${token}`);
|
|
@@ -20721,13 +21029,13 @@ function parseOssArgs(tokens) {
|
|
|
20721
21029
|
const token = rest.shift();
|
|
20722
21030
|
switch (token) {
|
|
20723
21031
|
case "--bucket":
|
|
20724
|
-
bucket =
|
|
21032
|
+
bucket = requireValue11(rest, token);
|
|
20725
21033
|
break;
|
|
20726
21034
|
case "--file":
|
|
20727
|
-
filePath =
|
|
21035
|
+
filePath = requireValue11(rest, token);
|
|
20728
21036
|
break;
|
|
20729
21037
|
case "--key":
|
|
20730
|
-
objectKey =
|
|
21038
|
+
objectKey = requireValue11(rest, token);
|
|
20731
21039
|
break;
|
|
20732
21040
|
default:
|
|
20733
21041
|
throw new Error(`Unknown oss option: ${token}`);
|
|
@@ -20760,7 +21068,7 @@ function parseEnvArgs(tokens) {
|
|
|
20760
21068
|
throw new Error("Only one env action is allowed.");
|
|
20761
21069
|
}
|
|
20762
21070
|
action = "set";
|
|
20763
|
-
key =
|
|
21071
|
+
key = requireValue11(rest, token);
|
|
20764
21072
|
break;
|
|
20765
21073
|
case "--list":
|
|
20766
21074
|
if (action) {
|
|
@@ -20773,17 +21081,17 @@ function parseEnvArgs(tokens) {
|
|
|
20773
21081
|
throw new Error("Only one env action is allowed.");
|
|
20774
21082
|
}
|
|
20775
21083
|
action = "delete";
|
|
20776
|
-
key =
|
|
21084
|
+
key = requireValue11(rest, token);
|
|
20777
21085
|
break;
|
|
20778
21086
|
case "--value":
|
|
20779
|
-
value =
|
|
21087
|
+
value = requireValue11(rest, token);
|
|
20780
21088
|
break;
|
|
20781
21089
|
case "--verbose":
|
|
20782
21090
|
case "-v":
|
|
20783
21091
|
verbose = true;
|
|
20784
21092
|
break;
|
|
20785
21093
|
case "--cwd":
|
|
20786
|
-
cwd =
|
|
21094
|
+
cwd = requireValue11(rest, token);
|
|
20787
21095
|
break;
|
|
20788
21096
|
default:
|
|
20789
21097
|
throw new Error(`Unknown env option: ${token}`);
|
|
@@ -20841,7 +21149,7 @@ function parseCommitArgs(tokens) {
|
|
|
20841
21149
|
push = true;
|
|
20842
21150
|
break;
|
|
20843
21151
|
case "--cwd":
|
|
20844
|
-
cwd =
|
|
21152
|
+
cwd = requireValue11(rest, token);
|
|
20845
21153
|
break;
|
|
20846
21154
|
default:
|
|
20847
21155
|
throw new Error(`Unknown commit option: ${token}`);
|
|
@@ -20857,10 +21165,10 @@ function parseSummaryArgs(tokens) {
|
|
|
20857
21165
|
const token = rest.shift();
|
|
20858
21166
|
switch (token) {
|
|
20859
21167
|
case "--pr":
|
|
20860
|
-
prRef =
|
|
21168
|
+
prRef = requireValue11(rest, token);
|
|
20861
21169
|
break;
|
|
20862
21170
|
case "--cwd":
|
|
20863
|
-
cwd =
|
|
21171
|
+
cwd = requireValue11(rest, token);
|
|
20864
21172
|
break;
|
|
20865
21173
|
default:
|
|
20866
21174
|
throw new Error(`Unknown summary option: ${token}`);
|
|
@@ -20885,13 +21193,13 @@ function parseQuizArgs(tokens) {
|
|
|
20885
21193
|
const token = rest.shift();
|
|
20886
21194
|
switch (token) {
|
|
20887
21195
|
case "--paper-id":
|
|
20888
|
-
paperId =
|
|
21196
|
+
paperId = requireValue11(rest, token);
|
|
20889
21197
|
break;
|
|
20890
21198
|
case "--base-url":
|
|
20891
|
-
apiBaseUrl =
|
|
21199
|
+
apiBaseUrl = requireValue11(rest, token);
|
|
20892
21200
|
break;
|
|
20893
21201
|
case "--link-base":
|
|
20894
|
-
linkBaseUrl =
|
|
21202
|
+
linkBaseUrl = requireValue11(rest, token);
|
|
20895
21203
|
break;
|
|
20896
21204
|
default:
|
|
20897
21205
|
throw new Error(`Unknown quiz create-draft option: ${token}`);
|
|
@@ -20917,16 +21225,16 @@ function parseQuizArgs(tokens) {
|
|
|
20917
21225
|
const token = rest.shift();
|
|
20918
21226
|
switch (token) {
|
|
20919
21227
|
case "--paper-id":
|
|
20920
|
-
paperId =
|
|
21228
|
+
paperId = requireValue11(rest, token);
|
|
20921
21229
|
break;
|
|
20922
21230
|
case "--file":
|
|
20923
|
-
filePath =
|
|
21231
|
+
filePath = requireValue11(rest, token);
|
|
20924
21232
|
break;
|
|
20925
21233
|
case "--base-url":
|
|
20926
|
-
apiBaseUrl =
|
|
21234
|
+
apiBaseUrl = requireValue11(rest, token);
|
|
20927
21235
|
break;
|
|
20928
21236
|
case "--link-base":
|
|
20929
|
-
linkBaseUrl =
|
|
21237
|
+
linkBaseUrl = requireValue11(rest, token);
|
|
20930
21238
|
break;
|
|
20931
21239
|
default:
|
|
20932
21240
|
throw new Error(`Unknown quiz update-meta option: ${token}`);
|
|
@@ -20956,16 +21264,16 @@ function parseQuizArgs(tokens) {
|
|
|
20956
21264
|
const token = rest.shift();
|
|
20957
21265
|
switch (token) {
|
|
20958
21266
|
case "--paper-id":
|
|
20959
|
-
paperId =
|
|
21267
|
+
paperId = requireValue11(rest, token);
|
|
20960
21268
|
break;
|
|
20961
21269
|
case "--file":
|
|
20962
|
-
filePath =
|
|
21270
|
+
filePath = requireValue11(rest, token);
|
|
20963
21271
|
break;
|
|
20964
21272
|
case "--base-url":
|
|
20965
|
-
apiBaseUrl =
|
|
21273
|
+
apiBaseUrl = requireValue11(rest, token);
|
|
20966
21274
|
break;
|
|
20967
21275
|
case "--link-base":
|
|
20968
|
-
linkBaseUrl =
|
|
21276
|
+
linkBaseUrl = requireValue11(rest, token);
|
|
20969
21277
|
break;
|
|
20970
21278
|
default:
|
|
20971
21279
|
throw new Error(`Unknown quiz append-step option: ${token}`);
|
|
@@ -20996,19 +21304,19 @@ function parseQuizArgs(tokens) {
|
|
|
20996
21304
|
const token = rest.shift();
|
|
20997
21305
|
switch (token) {
|
|
20998
21306
|
case "--paper-id":
|
|
20999
|
-
paperId =
|
|
21307
|
+
paperId = requireValue11(rest, token);
|
|
21000
21308
|
break;
|
|
21001
21309
|
case "--step-id":
|
|
21002
|
-
stepId =
|
|
21310
|
+
stepId = requireValue11(rest, token);
|
|
21003
21311
|
break;
|
|
21004
21312
|
case "--file":
|
|
21005
|
-
filePath =
|
|
21313
|
+
filePath = requireValue11(rest, token);
|
|
21006
21314
|
break;
|
|
21007
21315
|
case "--base-url":
|
|
21008
|
-
apiBaseUrl =
|
|
21316
|
+
apiBaseUrl = requireValue11(rest, token);
|
|
21009
21317
|
break;
|
|
21010
21318
|
case "--link-base":
|
|
21011
|
-
linkBaseUrl =
|
|
21319
|
+
linkBaseUrl = requireValue11(rest, token);
|
|
21012
21320
|
break;
|
|
21013
21321
|
default:
|
|
21014
21322
|
throw new Error(`Unknown quiz update-step option: ${token}`);
|
|
@@ -21042,16 +21350,16 @@ function parseQuizArgs(tokens) {
|
|
|
21042
21350
|
const token = rest.shift();
|
|
21043
21351
|
switch (token) {
|
|
21044
21352
|
case "--paper-id":
|
|
21045
|
-
paperId =
|
|
21353
|
+
paperId = requireValue11(rest, token);
|
|
21046
21354
|
break;
|
|
21047
21355
|
case "--step-ids":
|
|
21048
|
-
stepIdsRaw =
|
|
21356
|
+
stepIdsRaw = requireValue11(rest, token);
|
|
21049
21357
|
break;
|
|
21050
21358
|
case "--base-url":
|
|
21051
|
-
apiBaseUrl =
|
|
21359
|
+
apiBaseUrl = requireValue11(rest, token);
|
|
21052
21360
|
break;
|
|
21053
21361
|
case "--link-base":
|
|
21054
|
-
linkBaseUrl =
|
|
21362
|
+
linkBaseUrl = requireValue11(rest, token);
|
|
21055
21363
|
break;
|
|
21056
21364
|
default:
|
|
21057
21365
|
throw new Error(`Unknown quiz reorder option: ${token}`);
|
|
@@ -21084,13 +21392,13 @@ function parseQuizArgs(tokens) {
|
|
|
21084
21392
|
const token = rest.shift();
|
|
21085
21393
|
switch (token) {
|
|
21086
21394
|
case "--paper-id":
|
|
21087
|
-
paperId =
|
|
21395
|
+
paperId = requireValue11(rest, token);
|
|
21088
21396
|
break;
|
|
21089
21397
|
case "--base-url":
|
|
21090
|
-
apiBaseUrl =
|
|
21398
|
+
apiBaseUrl = requireValue11(rest, token);
|
|
21091
21399
|
break;
|
|
21092
21400
|
case "--link-base":
|
|
21093
|
-
linkBaseUrl =
|
|
21401
|
+
linkBaseUrl = requireValue11(rest, token);
|
|
21094
21402
|
break;
|
|
21095
21403
|
default:
|
|
21096
21404
|
throw new Error(`Unknown quiz activate option: ${token}`);
|
|
@@ -21115,13 +21423,13 @@ function parseQuizArgs(tokens) {
|
|
|
21115
21423
|
const token = rest.shift();
|
|
21116
21424
|
switch (token) {
|
|
21117
21425
|
case "--paper-id":
|
|
21118
|
-
paperId =
|
|
21426
|
+
paperId = requireValue11(rest, token);
|
|
21119
21427
|
break;
|
|
21120
21428
|
case "--base-url":
|
|
21121
|
-
apiBaseUrl =
|
|
21429
|
+
apiBaseUrl = requireValue11(rest, token);
|
|
21122
21430
|
break;
|
|
21123
21431
|
case "--link-base":
|
|
21124
|
-
linkBaseUrl =
|
|
21432
|
+
linkBaseUrl = requireValue11(rest, token);
|
|
21125
21433
|
break;
|
|
21126
21434
|
default:
|
|
21127
21435
|
throw new Error(`Unknown quiz view option: ${token}`);
|
|
@@ -21150,22 +21458,22 @@ function parseQuizArgs(tokens) {
|
|
|
21150
21458
|
const token = rest.shift();
|
|
21151
21459
|
switch (token) {
|
|
21152
21460
|
case "--paper-id":
|
|
21153
|
-
paperId =
|
|
21461
|
+
paperId = requireValue11(rest, token);
|
|
21154
21462
|
break;
|
|
21155
21463
|
case "--step-id":
|
|
21156
|
-
stepId =
|
|
21464
|
+
stepId = requireValue11(rest, token);
|
|
21157
21465
|
break;
|
|
21158
21466
|
case "--file":
|
|
21159
|
-
filePath =
|
|
21467
|
+
filePath = requireValue11(rest, token);
|
|
21160
21468
|
break;
|
|
21161
21469
|
case "--new-paper-id":
|
|
21162
|
-
newPaperId =
|
|
21470
|
+
newPaperId = requireValue11(rest, token);
|
|
21163
21471
|
break;
|
|
21164
21472
|
case "--base-url":
|
|
21165
|
-
apiBaseUrl =
|
|
21473
|
+
apiBaseUrl = requireValue11(rest, token);
|
|
21166
21474
|
break;
|
|
21167
21475
|
case "--link-base":
|
|
21168
|
-
linkBaseUrl =
|
|
21476
|
+
linkBaseUrl = requireValue11(rest, token);
|
|
21169
21477
|
break;
|
|
21170
21478
|
case "--activate":
|
|
21171
21479
|
activate = true;
|
|
@@ -21255,10 +21563,10 @@ function parseLinearPrArgs(tokens) {
|
|
|
21255
21563
|
const token = rest.shift();
|
|
21256
21564
|
switch (token) {
|
|
21257
21565
|
case "--account":
|
|
21258
|
-
account =
|
|
21566
|
+
account = requireValue11(rest, token);
|
|
21259
21567
|
break;
|
|
21260
21568
|
case "--cwd":
|
|
21261
|
-
cwd =
|
|
21569
|
+
cwd = requireValue11(rest, token);
|
|
21262
21570
|
break;
|
|
21263
21571
|
default:
|
|
21264
21572
|
throw new Error(`Unknown linear option: ${token}`);
|
|
@@ -21287,35 +21595,35 @@ function parseLinearCreateArgs(tokens) {
|
|
|
21287
21595
|
const token = rest.shift();
|
|
21288
21596
|
switch (token) {
|
|
21289
21597
|
case "--account":
|
|
21290
|
-
account =
|
|
21598
|
+
account = requireValue11(rest, token);
|
|
21291
21599
|
break;
|
|
21292
21600
|
case "--repl":
|
|
21293
21601
|
useRepl = true;
|
|
21294
21602
|
break;
|
|
21295
21603
|
case "--title":
|
|
21296
|
-
title =
|
|
21604
|
+
title = requireValue11(rest, token);
|
|
21297
21605
|
break;
|
|
21298
21606
|
case "--desc":
|
|
21299
21607
|
case "--description":
|
|
21300
|
-
description = decodeEscapedNewlines(
|
|
21608
|
+
description = decodeEscapedNewlines(requireValue11(rest, token));
|
|
21301
21609
|
break;
|
|
21302
21610
|
case "--team-id":
|
|
21303
|
-
teamId =
|
|
21611
|
+
teamId = requireValue11(rest, token);
|
|
21304
21612
|
break;
|
|
21305
21613
|
case "--team-key":
|
|
21306
|
-
teamKey =
|
|
21614
|
+
teamKey = requireValue11(rest, token);
|
|
21307
21615
|
break;
|
|
21308
21616
|
case "--priority":
|
|
21309
|
-
priority = parseLinearPriority(
|
|
21617
|
+
priority = parseLinearPriority(requireValue11(rest, token));
|
|
21310
21618
|
break;
|
|
21311
21619
|
case "--parent-id":
|
|
21312
|
-
parentId =
|
|
21620
|
+
parentId = requireValue11(rest, token);
|
|
21313
21621
|
break;
|
|
21314
21622
|
case "--state-id":
|
|
21315
|
-
stateId =
|
|
21623
|
+
stateId = requireValue11(rest, token);
|
|
21316
21624
|
break;
|
|
21317
21625
|
case "--cwd":
|
|
21318
|
-
cwd =
|
|
21626
|
+
cwd = requireValue11(rest, token);
|
|
21319
21627
|
break;
|
|
21320
21628
|
default:
|
|
21321
21629
|
throw new Error(`Unknown linear option: ${token}`);
|
|
@@ -21350,10 +21658,10 @@ function parseLinearWhoamiArgs(tokens) {
|
|
|
21350
21658
|
const token = rest.shift();
|
|
21351
21659
|
switch (token) {
|
|
21352
21660
|
case "--account":
|
|
21353
|
-
account =
|
|
21661
|
+
account = requireValue11(rest, token);
|
|
21354
21662
|
break;
|
|
21355
21663
|
case "--cwd":
|
|
21356
|
-
cwd =
|
|
21664
|
+
cwd = requireValue11(rest, token);
|
|
21357
21665
|
break;
|
|
21358
21666
|
default:
|
|
21359
21667
|
throw new Error(`Unknown linear option: ${token}`);
|
|
@@ -21378,10 +21686,10 @@ function parseLinearViewArgs(tokens) {
|
|
|
21378
21686
|
const token = rest.shift();
|
|
21379
21687
|
switch (token) {
|
|
21380
21688
|
case "--account":
|
|
21381
|
-
account =
|
|
21689
|
+
account = requireValue11(rest, token);
|
|
21382
21690
|
break;
|
|
21383
21691
|
case "--cwd":
|
|
21384
|
-
cwd =
|
|
21692
|
+
cwd = requireValue11(rest, token);
|
|
21385
21693
|
break;
|
|
21386
21694
|
default:
|
|
21387
21695
|
throw new Error(`Unknown linear option: ${token}`);
|
|
@@ -21416,32 +21724,32 @@ function parseLinearUpdateArgs(tokens) {
|
|
|
21416
21724
|
const token = rest.shift();
|
|
21417
21725
|
switch (token) {
|
|
21418
21726
|
case "--account":
|
|
21419
|
-
account =
|
|
21727
|
+
account = requireValue11(rest, token);
|
|
21420
21728
|
break;
|
|
21421
21729
|
case "--title":
|
|
21422
|
-
title =
|
|
21730
|
+
title = requireValue11(rest, token);
|
|
21423
21731
|
break;
|
|
21424
21732
|
case "--desc":
|
|
21425
21733
|
case "--description":
|
|
21426
|
-
description = decodeEscapedNewlines(
|
|
21734
|
+
description = decodeEscapedNewlines(requireValue11(rest, token));
|
|
21427
21735
|
break;
|
|
21428
21736
|
case "--team-id":
|
|
21429
|
-
teamId =
|
|
21737
|
+
teamId = requireValue11(rest, token);
|
|
21430
21738
|
break;
|
|
21431
21739
|
case "--team-key":
|
|
21432
|
-
teamKey =
|
|
21740
|
+
teamKey = requireValue11(rest, token);
|
|
21433
21741
|
break;
|
|
21434
21742
|
case "--priority":
|
|
21435
|
-
priority = parseLinearPriority(
|
|
21743
|
+
priority = parseLinearPriority(requireValue11(rest, token));
|
|
21436
21744
|
break;
|
|
21437
21745
|
case "--parent-id":
|
|
21438
|
-
parentId =
|
|
21746
|
+
parentId = requireValue11(rest, token);
|
|
21439
21747
|
break;
|
|
21440
21748
|
case "--state-id":
|
|
21441
|
-
stateId =
|
|
21749
|
+
stateId = requireValue11(rest, token);
|
|
21442
21750
|
break;
|
|
21443
21751
|
case "--cwd":
|
|
21444
|
-
cwd =
|
|
21752
|
+
cwd = requireValue11(rest, token);
|
|
21445
21753
|
break;
|
|
21446
21754
|
default:
|
|
21447
21755
|
throw new Error(`Unknown linear option: ${token}`);
|
|
@@ -21479,10 +21787,10 @@ function parseLinearSubIssuesArgs(tokens) {
|
|
|
21479
21787
|
const token = rest.shift();
|
|
21480
21788
|
switch (token) {
|
|
21481
21789
|
case "--account":
|
|
21482
|
-
account =
|
|
21790
|
+
account = requireValue11(rest, token);
|
|
21483
21791
|
break;
|
|
21484
21792
|
case "--cwd":
|
|
21485
|
-
cwd =
|
|
21793
|
+
cwd = requireValue11(rest, token);
|
|
21486
21794
|
break;
|
|
21487
21795
|
default:
|
|
21488
21796
|
throw new Error(`Unknown linear option: ${token}`);
|
|
@@ -21509,15 +21817,15 @@ function parseLinearCommentArgs(tokens) {
|
|
|
21509
21817
|
const token = rest.shift();
|
|
21510
21818
|
switch (token) {
|
|
21511
21819
|
case "--account":
|
|
21512
|
-
account =
|
|
21820
|
+
account = requireValue11(rest, token);
|
|
21513
21821
|
break;
|
|
21514
21822
|
case "--body":
|
|
21515
21823
|
case "--desc":
|
|
21516
21824
|
case "--description":
|
|
21517
|
-
body = decodeEscapedNewlines(
|
|
21825
|
+
body = decodeEscapedNewlines(requireValue11(rest, token));
|
|
21518
21826
|
break;
|
|
21519
21827
|
case "--cwd":
|
|
21520
|
-
cwd =
|
|
21828
|
+
cwd = requireValue11(rest, token);
|
|
21521
21829
|
break;
|
|
21522
21830
|
default:
|
|
21523
21831
|
throw new Error(`Unknown linear option: ${token}`);
|
|
@@ -21547,10 +21855,10 @@ function parseLinearCommentsArgs(tokens) {
|
|
|
21547
21855
|
const token = rest.shift();
|
|
21548
21856
|
switch (token) {
|
|
21549
21857
|
case "--account":
|
|
21550
|
-
account =
|
|
21858
|
+
account = requireValue11(rest, token);
|
|
21551
21859
|
break;
|
|
21552
21860
|
case "--cwd":
|
|
21553
|
-
cwd =
|
|
21861
|
+
cwd = requireValue11(rest, token);
|
|
21554
21862
|
break;
|
|
21555
21863
|
default:
|
|
21556
21864
|
throw new Error(`Unknown linear option: ${token}`);
|
|
@@ -21574,16 +21882,16 @@ function parseLinearCycleArgs(tokens) {
|
|
|
21574
21882
|
const token = rest.shift();
|
|
21575
21883
|
switch (token) {
|
|
21576
21884
|
case "--account":
|
|
21577
|
-
account =
|
|
21885
|
+
account = requireValue11(rest, token);
|
|
21578
21886
|
break;
|
|
21579
21887
|
case "--team-id":
|
|
21580
|
-
teamId =
|
|
21888
|
+
teamId = requireValue11(rest, token);
|
|
21581
21889
|
break;
|
|
21582
21890
|
case "--team-key":
|
|
21583
|
-
teamKey =
|
|
21891
|
+
teamKey = requireValue11(rest, token);
|
|
21584
21892
|
break;
|
|
21585
21893
|
case "--cwd":
|
|
21586
|
-
cwd =
|
|
21894
|
+
cwd = requireValue11(rest, token);
|
|
21587
21895
|
break;
|
|
21588
21896
|
default:
|
|
21589
21897
|
throw new Error(`Unknown linear option: ${token}`);
|
|
@@ -21606,10 +21914,10 @@ function parseLinearTeamsArgs(tokens) {
|
|
|
21606
21914
|
const token = rest.shift();
|
|
21607
21915
|
switch (token) {
|
|
21608
21916
|
case "--account":
|
|
21609
|
-
account =
|
|
21917
|
+
account = requireValue11(rest, token);
|
|
21610
21918
|
break;
|
|
21611
21919
|
case "--cwd":
|
|
21612
|
-
cwd =
|
|
21920
|
+
cwd = requireValue11(rest, token);
|
|
21613
21921
|
break;
|
|
21614
21922
|
default:
|
|
21615
21923
|
throw new Error(`Unknown linear option: ${token}`);
|
|
@@ -21636,16 +21944,16 @@ function parseLinearUserIssuesArgs(tokens) {
|
|
|
21636
21944
|
const token = rest.shift();
|
|
21637
21945
|
switch (token) {
|
|
21638
21946
|
case "--account":
|
|
21639
|
-
account =
|
|
21947
|
+
account = requireValue11(rest, token);
|
|
21640
21948
|
break;
|
|
21641
21949
|
case "--cycle":
|
|
21642
|
-
cycle = parseLinearCycle(
|
|
21950
|
+
cycle = parseLinearCycle(requireValue11(rest, token));
|
|
21643
21951
|
break;
|
|
21644
21952
|
case "--status":
|
|
21645
|
-
status = parseLinearStatus(
|
|
21953
|
+
status = parseLinearStatus(requireValue11(rest, token));
|
|
21646
21954
|
break;
|
|
21647
21955
|
case "--cwd":
|
|
21648
|
-
cwd =
|
|
21956
|
+
cwd = requireValue11(rest, token);
|
|
21649
21957
|
break;
|
|
21650
21958
|
default:
|
|
21651
21959
|
throw new Error(`Unknown linear option: ${token}`);
|
|
@@ -21679,28 +21987,28 @@ function parseLinearIssuesArgs(tokens) {
|
|
|
21679
21987
|
const token = rest.shift();
|
|
21680
21988
|
switch (token) {
|
|
21681
21989
|
case "--account":
|
|
21682
|
-
account =
|
|
21990
|
+
account = requireValue11(rest, token);
|
|
21683
21991
|
break;
|
|
21684
21992
|
case "--team-id":
|
|
21685
|
-
teamId =
|
|
21993
|
+
teamId = requireValue11(rest, token);
|
|
21686
21994
|
break;
|
|
21687
21995
|
case "--team-key":
|
|
21688
|
-
teamKey =
|
|
21996
|
+
teamKey = requireValue11(rest, token);
|
|
21689
21997
|
break;
|
|
21690
21998
|
case "--user":
|
|
21691
|
-
user =
|
|
21999
|
+
user = requireValue11(rest, token);
|
|
21692
22000
|
break;
|
|
21693
22001
|
case "--cycle":
|
|
21694
|
-
cycle = parseLinearCycle(
|
|
22002
|
+
cycle = parseLinearCycle(requireValue11(rest, token));
|
|
21695
22003
|
break;
|
|
21696
22004
|
case "--status":
|
|
21697
|
-
status = parseLinearStatus(
|
|
22005
|
+
status = parseLinearStatus(requireValue11(rest, token));
|
|
21698
22006
|
break;
|
|
21699
22007
|
case "--query":
|
|
21700
|
-
query =
|
|
22008
|
+
query = requireValue11(rest, token).trim();
|
|
21701
22009
|
break;
|
|
21702
22010
|
case "--limit": {
|
|
21703
|
-
const value = Number.parseInt(
|
|
22011
|
+
const value = Number.parseInt(requireValue11(rest, token), 10);
|
|
21704
22012
|
if (!Number.isInteger(value) || value < 1 || value > 250) {
|
|
21705
22013
|
throw new Error("Invalid --limit. Expected an integer between 1 and 250.");
|
|
21706
22014
|
}
|
|
@@ -21708,7 +22016,7 @@ function parseLinearIssuesArgs(tokens) {
|
|
|
21708
22016
|
break;
|
|
21709
22017
|
}
|
|
21710
22018
|
case "--cwd":
|
|
21711
|
-
cwd =
|
|
22019
|
+
cwd = requireValue11(rest, token);
|
|
21712
22020
|
break;
|
|
21713
22021
|
default:
|
|
21714
22022
|
throw new Error(`Unknown linear option: ${token}`);
|
|
@@ -21749,10 +22057,10 @@ function parseLinearLegacyArgs(tokens) {
|
|
|
21749
22057
|
useScreenshot = true;
|
|
21750
22058
|
break;
|
|
21751
22059
|
case "--account":
|
|
21752
|
-
account =
|
|
22060
|
+
account = requireValue11(rest, token);
|
|
21753
22061
|
break;
|
|
21754
22062
|
case "--cwd":
|
|
21755
|
-
cwd =
|
|
22063
|
+
cwd = requireValue11(rest, token);
|
|
21756
22064
|
break;
|
|
21757
22065
|
default:
|
|
21758
22066
|
throw new Error(`Unknown linear option: ${token}`);
|
|
@@ -21846,19 +22154,19 @@ function parseNotionArgs(tokens) {
|
|
|
21846
22154
|
const token = rest.shift();
|
|
21847
22155
|
switch (token) {
|
|
21848
22156
|
case "--parent":
|
|
21849
|
-
parentPageId =
|
|
22157
|
+
parentPageId = requireValue11(rest, token);
|
|
21850
22158
|
break;
|
|
21851
22159
|
case "--title":
|
|
21852
|
-
title =
|
|
22160
|
+
title = requireValue11(rest, token);
|
|
21853
22161
|
break;
|
|
21854
22162
|
case "--private":
|
|
21855
22163
|
isPrivate = true;
|
|
21856
22164
|
break;
|
|
21857
22165
|
case "--content":
|
|
21858
|
-
content2 =
|
|
22166
|
+
content2 = requireValue11(rest, token);
|
|
21859
22167
|
break;
|
|
21860
22168
|
case "--file":
|
|
21861
|
-
filePath2 =
|
|
22169
|
+
filePath2 = requireValue11(rest, token);
|
|
21862
22170
|
break;
|
|
21863
22171
|
default:
|
|
21864
22172
|
throw new Error(`Unknown notion option: ${token}`);
|
|
@@ -21902,10 +22210,10 @@ function parseNotionArgs(tokens) {
|
|
|
21902
22210
|
const token = rest.shift();
|
|
21903
22211
|
switch (token) {
|
|
21904
22212
|
case "--content":
|
|
21905
|
-
content =
|
|
22213
|
+
content = requireValue11(rest, token);
|
|
21906
22214
|
break;
|
|
21907
22215
|
case "--file":
|
|
21908
|
-
filePath =
|
|
22216
|
+
filePath = requireValue11(rest, token);
|
|
21909
22217
|
break;
|
|
21910
22218
|
case "--append":
|
|
21911
22219
|
append = true;
|
|
@@ -21950,11 +22258,11 @@ function parseRandomArgs(tokens) {
|
|
|
21950
22258
|
mode = "easy";
|
|
21951
22259
|
break;
|
|
21952
22260
|
case "--length":
|
|
21953
|
-
length = parsePositiveInt(
|
|
22261
|
+
length = parsePositiveInt(requireValue11(rest, token), token);
|
|
21954
22262
|
seenLength = true;
|
|
21955
22263
|
break;
|
|
21956
22264
|
case "--charset": {
|
|
21957
|
-
const value =
|
|
22265
|
+
const value = requireValue11(rest, token);
|
|
21958
22266
|
if (!["base64url", "hex", "alnum", "ascii"].includes(value)) {
|
|
21959
22267
|
throw new Error(
|
|
21960
22268
|
`Invalid --charset value: ${value}. Use base64url|hex|alnum|ascii.`
|
|
@@ -21965,18 +22273,18 @@ function parseRandomArgs(tokens) {
|
|
|
21965
22273
|
break;
|
|
21966
22274
|
}
|
|
21967
22275
|
case "--count":
|
|
21968
|
-
count = parsePositiveInt(
|
|
22276
|
+
count = parsePositiveInt(requireValue11(rest, token), token);
|
|
21969
22277
|
break;
|
|
21970
22278
|
case "--words":
|
|
21971
|
-
words = parsePositiveInt(
|
|
22279
|
+
words = parsePositiveInt(requireValue11(rest, token), token);
|
|
21972
22280
|
seenWords = true;
|
|
21973
22281
|
break;
|
|
21974
22282
|
case "--digits":
|
|
21975
|
-
digits = parseNonNegativeInt(
|
|
22283
|
+
digits = parseNonNegativeInt(requireValue11(rest, token), token);
|
|
21976
22284
|
seenDigits = true;
|
|
21977
22285
|
break;
|
|
21978
22286
|
case "--separator":
|
|
21979
|
-
separator =
|
|
22287
|
+
separator = requireValue11(rest, token);
|
|
21980
22288
|
seenSeparator = true;
|
|
21981
22289
|
break;
|
|
21982
22290
|
default:
|
|
@@ -22007,7 +22315,7 @@ function parseRandomArgs(tokens) {
|
|
|
22007
22315
|
count
|
|
22008
22316
|
};
|
|
22009
22317
|
}
|
|
22010
|
-
function
|
|
22318
|
+
function requireValue11(tokens, optionName) {
|
|
22011
22319
|
const value = tokens.shift();
|
|
22012
22320
|
if (!value) {
|
|
22013
22321
|
throw new Error(`Missing value for ${optionName}`);
|
|
@@ -22083,6 +22391,11 @@ async function main() {
|
|
|
22083
22391
|
await handler.handle(commandArgs);
|
|
22084
22392
|
return;
|
|
22085
22393
|
}
|
|
22394
|
+
case "prepare-dev" /* PrepareDev */: {
|
|
22395
|
+
const handler = new PrepareDevCommandHandler();
|
|
22396
|
+
await handler.handle(commandArgs);
|
|
22397
|
+
return;
|
|
22398
|
+
}
|
|
22086
22399
|
case "env" /* Env */: {
|
|
22087
22400
|
const handler = new EnvCommandHandler();
|
|
22088
22401
|
await handler.handle(commandArgs);
|