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