@pmate/cli 0.29.7 → 0.29.9
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 +1 -7
- package/dist/index.js +6 -83
- package/package.json +17 -10
package/dist/index.d.ts
CHANGED
|
@@ -12,7 +12,6 @@ declare enum Command {
|
|
|
12
12
|
Delete = "delete",
|
|
13
13
|
Dev = "dev",
|
|
14
14
|
Env = "env",
|
|
15
|
-
Pr = "pr",
|
|
16
15
|
Commit = "commit",
|
|
17
16
|
Summary = "summary",
|
|
18
17
|
Linear = "linear",
|
|
@@ -124,11 +123,6 @@ type EnvCommandArgs = {
|
|
|
124
123
|
envVerbose?: boolean;
|
|
125
124
|
envCwd: string;
|
|
126
125
|
};
|
|
127
|
-
type PrCommandArgs = {
|
|
128
|
-
type: Command.Pr;
|
|
129
|
-
action: "create" | "merge";
|
|
130
|
-
prRef?: string;
|
|
131
|
-
};
|
|
132
126
|
type CommitCommandArgs = {
|
|
133
127
|
type: Command.Commit;
|
|
134
128
|
push: boolean;
|
|
@@ -1131,7 +1125,7 @@ type VercelDeploysCommandArgs = {
|
|
|
1131
1125
|
lastWeek: boolean;
|
|
1132
1126
|
};
|
|
1133
1127
|
type VercelCommandArgs = VercelProjectsCommandArgs | VercelDeploysCommandArgs;
|
|
1134
|
-
type CommandArgs = NoneCommandArgs | ListCommandArgs | LoginCommandArgs | AddDnsCommandArgs | StsCommandArgs | BucketCommandArgs | DeployCommandArgs | LogCommandArgs | InitCommandArgs | DeleteCommandArgs | DevCommandArgs | EnvCommandArgs |
|
|
1128
|
+
type CommandArgs = NoneCommandArgs | ListCommandArgs | LoginCommandArgs | AddDnsCommandArgs | StsCommandArgs | BucketCommandArgs | DeployCommandArgs | LogCommandArgs | InitCommandArgs | DeleteCommandArgs | DevCommandArgs | EnvCommandArgs | CommitCommandArgs | SummaryCommandArgs | QuizCommandArgs | ServiceCommandArgs | LinearCommandArgs | NotionCommandArgs | OssCommandArgs | QrcodeCommandArgs | RandomCommandArgs | CollectCommandArgs | ChatRoomCommandArgs | FunctionCommandArgs | WorkerCommandArgs | CallCommandArgs | NsCommandArgs | RoleCommandArgs | AccountCommandArgs | OrgCommandArgs | StoreCommandArgs | AppCommandArgs | VercelCommandArgs | HostCommandArgs;
|
|
1135
1129
|
|
|
1136
1130
|
interface ParsedArgs {
|
|
1137
1131
|
help: boolean;
|
package/dist/index.js
CHANGED
|
@@ -11512,54 +11512,6 @@ var PrCommandHandler = class {
|
|
|
11512
11512
|
constructor(cwd = process.cwd()) {
|
|
11513
11513
|
this.cwd = cwd;
|
|
11514
11514
|
}
|
|
11515
|
-
async handle(args) {
|
|
11516
|
-
if (args.action === "merge") {
|
|
11517
|
-
await this.handleMerge(args.prRef);
|
|
11518
|
-
return;
|
|
11519
|
-
}
|
|
11520
|
-
await this.ensureGitRepo();
|
|
11521
|
-
await this.ensureGhCli();
|
|
11522
|
-
await this.ensureGhAuth();
|
|
11523
|
-
const context = await this.getRepoContext();
|
|
11524
|
-
let existingPrUrl = await this.findExistingPrUrl(context.currentBranch);
|
|
11525
|
-
if (!this.hasLocalChanges(context)) {
|
|
11526
|
-
await this.handleNoLocalChanges(context, existingPrUrl);
|
|
11527
|
-
return;
|
|
11528
|
-
}
|
|
11529
|
-
const recentLog = await this.runCapture("git", [
|
|
11530
|
-
"log",
|
|
11531
|
-
"--oneline",
|
|
11532
|
-
"-n",
|
|
11533
|
-
"20"
|
|
11534
|
-
]);
|
|
11535
|
-
console.log("Generating PR metadata using a PMate Function...");
|
|
11536
|
-
const suggestion = await this.getAiSuggestion({
|
|
11537
|
-
status: context.status,
|
|
11538
|
-
diff: truncate(context.diff, 6e3),
|
|
11539
|
-
diffCached: truncate(context.diffCached, 6e3),
|
|
11540
|
-
recentLog: truncate(recentLog, 2e3),
|
|
11541
|
-
baseBranch: context.baseBranch
|
|
11542
|
-
});
|
|
11543
|
-
this.assertNonEmpty("PR title", suggestion.prTitle);
|
|
11544
|
-
this.assertNonEmpty("Commit message", suggestion.commitMessage);
|
|
11545
|
-
const prTitle = normalizePrTitle(suggestion.prTitle);
|
|
11546
|
-
if (prTitle !== suggestion.prTitle.trim()) {
|
|
11547
|
-
ui.info("Normalized PR title", prTitle);
|
|
11548
|
-
}
|
|
11549
|
-
const headBranch = await this.ensureWorkBranch(context, suggestion);
|
|
11550
|
-
if (headBranch !== context.currentBranch) {
|
|
11551
|
-
existingPrUrl = await this.findExistingPrUrl(headBranch);
|
|
11552
|
-
}
|
|
11553
|
-
await this.commitIfNeeded(suggestion.commitMessage);
|
|
11554
|
-
await this.rebaseOntoBase(context.baseBranch);
|
|
11555
|
-
await this.pushBranchIfNeeded(headBranch, context.baseBranch);
|
|
11556
|
-
await this.ensurePr(
|
|
11557
|
-
existingPrUrl,
|
|
11558
|
-
context.baseBranch,
|
|
11559
|
-
headBranch,
|
|
11560
|
-
prTitle
|
|
11561
|
-
);
|
|
11562
|
-
}
|
|
11563
11515
|
async handleCommit(push = false) {
|
|
11564
11516
|
await this.ensureGitRepo();
|
|
11565
11517
|
const context = await this.getRepoContext();
|
|
@@ -19429,8 +19381,11 @@ var ServiceRuntimeRunner = class {
|
|
|
19429
19381
|
`cd "${repoDir}"`,
|
|
19430
19382
|
`if [ -f ~/.profile ]; then . ~/.profile; fi`,
|
|
19431
19383
|
`if [ -f ~/.bashrc ]; then . ~/.bashrc; fi`,
|
|
19432
|
-
|
|
19433
|
-
|
|
19384
|
+
...server === "local" ? [
|
|
19385
|
+
`test "$(git branch --show-current)" = main || { echo 'Local service checkout must be on main' >&2; exit 1; }`,
|
|
19386
|
+
`test -z "$(git status --porcelain)" || { echo 'Local service checkout has uncommitted changes; refusing to discard them' >&2; exit 1; }`,
|
|
19387
|
+
`git pull --ff-only origin main`
|
|
19388
|
+
] : [`if [ -n "$(git status --porcelain)" ]; then git reset --hard HEAD; git clean -fd; fi`, `git pull --rebase`],
|
|
19434
19389
|
...envSyncCommand ? [envSyncCommand] : [],
|
|
19435
19390
|
`"${scriptPath}" restart --env ${shellQuote2(envName)}`
|
|
19436
19391
|
].join(" && ");
|
|
@@ -20303,6 +20258,7 @@ var ServiceRuntimeRunner = class {
|
|
|
20303
20258
|
});
|
|
20304
20259
|
}
|
|
20305
20260
|
runRemoteCommand(server, command) {
|
|
20261
|
+
if (server === "local") return this.runCommandWithEnv("bash", ["-c", command], import_node_os10.default.homedir());
|
|
20306
20262
|
return new Promise((resolve, reject) => {
|
|
20307
20263
|
const target = `pmate@${server}`;
|
|
20308
20264
|
const child = (0, import_node_child_process10.spawn)("ssh", buildSshBashArgs(target, command), { stdio: "inherit" });
|
|
@@ -25956,8 +25912,6 @@ var HELP_TEXT = [
|
|
|
25956
25912
|
` ${import_chalk4.default.gray(" <app-name> [--cwd <dir>]")}`,
|
|
25957
25913
|
` ${import_chalk4.default.cyan("env")} Manage app env vars on the server`,
|
|
25958
25914
|
` ${import_chalk4.default.gray(" <app-name> --list|--set <key> --value <value> [--delete <key>] [--cwd <dir>] [--verbose|-v]")}`,
|
|
25959
|
-
` ${import_chalk4.default.cyan("pr")} Create or update GitHub PRs with AI assistance`,
|
|
25960
|
-
` ${import_chalk4.default.gray(" merge [<pr>] (defaults: --squash --delete-branch)")}`,
|
|
25961
25915
|
` ${import_chalk4.default.cyan("commit")} Create an AI-generated commit from local changes`,
|
|
25962
25916
|
` ${import_chalk4.default.gray(" [--push] [--cwd <dir>]")}`,
|
|
25963
25917
|
` ${import_chalk4.default.cyan("summary")} Summarize a GitHub PR with AI`,
|
|
@@ -26231,9 +26185,6 @@ function parseCommandArgs(args) {
|
|
|
26231
26185
|
if (args.rest[0] === "env") {
|
|
26232
26186
|
return parseEnvArgs(args.rest.slice(1));
|
|
26233
26187
|
}
|
|
26234
|
-
if (args.rest[0] === "pr") {
|
|
26235
|
-
return parsePrArgs(args.rest.slice(1));
|
|
26236
|
-
}
|
|
26237
26188
|
if (args.rest[0] === "commit") {
|
|
26238
26189
|
return parseCommitArgs(args.rest.slice(1));
|
|
26239
26190
|
}
|
|
@@ -26597,29 +26548,6 @@ function parseEnvArgs(tokens) {
|
|
|
26597
26548
|
envCwd: cwd
|
|
26598
26549
|
};
|
|
26599
26550
|
}
|
|
26600
|
-
function parsePrArgs(tokens) {
|
|
26601
|
-
const rest = [...tokens];
|
|
26602
|
-
if (rest[0] === "merge") {
|
|
26603
|
-
rest.shift();
|
|
26604
|
-
let prRef;
|
|
26605
|
-
while (rest.length > 0) {
|
|
26606
|
-
const token = rest.shift();
|
|
26607
|
-
if (token.startsWith("-")) {
|
|
26608
|
-
throw new Error(`Unknown pr merge option: ${token}`);
|
|
26609
|
-
}
|
|
26610
|
-
if (prRef) {
|
|
26611
|
-
throw new Error(`Unexpected extra argument for pr merge: ${token}`);
|
|
26612
|
-
}
|
|
26613
|
-
prRef = token;
|
|
26614
|
-
}
|
|
26615
|
-
return { type: "pr" /* Pr */, action: "merge", prRef };
|
|
26616
|
-
}
|
|
26617
|
-
while (rest.length > 0) {
|
|
26618
|
-
const token = rest.shift();
|
|
26619
|
-
throw new Error(`Unknown pr option: ${token}`);
|
|
26620
|
-
}
|
|
26621
|
-
return { type: "pr" /* Pr */, action: "create" };
|
|
26622
|
-
}
|
|
26623
26551
|
function parseCommitArgs(tokens) {
|
|
26624
26552
|
const rest = [...tokens];
|
|
26625
26553
|
let push = false;
|
|
@@ -27917,11 +27845,6 @@ async function main() {
|
|
|
27917
27845
|
await handler.handle(commandArgs);
|
|
27918
27846
|
return;
|
|
27919
27847
|
}
|
|
27920
|
-
case "pr" /* Pr */: {
|
|
27921
|
-
const handler = new PrCommandHandler();
|
|
27922
|
-
await handler.handle(commandArgs);
|
|
27923
|
-
return;
|
|
27924
|
-
}
|
|
27925
27848
|
case "commit" /* Commit */: {
|
|
27926
27849
|
const handler = new CommitCommandHandler();
|
|
27927
27850
|
await handler.handle(commandArgs);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pmate/cli",
|
|
3
|
-
"version": "0.29.
|
|
3
|
+
"version": "0.29.9",
|
|
4
4
|
"description": "CLI utilities for the pMate project",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
@@ -11,6 +11,16 @@
|
|
|
11
11
|
"files": [
|
|
12
12
|
"dist"
|
|
13
13
|
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "npm run clean && tsup --config tsup.config.ts && node scripts/copy-templates.js",
|
|
16
|
+
"clean": "rimraf dist",
|
|
17
|
+
"dev": "ts-node src/index.ts",
|
|
18
|
+
"release": "pnpm publish",
|
|
19
|
+
"start": "node dist/index.js",
|
|
20
|
+
"test": "vitest run src/tests",
|
|
21
|
+
"typecheck": "tsc --noEmit",
|
|
22
|
+
"prepare": "npm run build"
|
|
23
|
+
},
|
|
14
24
|
"keywords": [
|
|
15
25
|
"cli",
|
|
16
26
|
"typescript",
|
|
@@ -57,13 +67,10 @@
|
|
|
57
67
|
"typescript": "^5.9.3",
|
|
58
68
|
"vitest": "^4.0.17"
|
|
59
69
|
},
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
"start": "node dist/index.js",
|
|
66
|
-
"test": "vitest run src/tests",
|
|
67
|
-
"typecheck": "tsc --noEmit"
|
|
70
|
+
"pnpm": {
|
|
71
|
+
"overrides": {
|
|
72
|
+
"@pmate/meta": "^1.3.1",
|
|
73
|
+
"@pmate/utils": "^1.1.4"
|
|
74
|
+
}
|
|
68
75
|
}
|
|
69
|
-
}
|
|
76
|
+
}
|