@pmate/cli 0.24.21 → 0.24.22
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 -0
- package/dist/index.js +147 -75
- package/package.json +10 -17
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -111,13 +111,13 @@ function saveLoginSession(session, requestedApp = DEFAULT_APP_ID) {
|
|
|
111
111
|
const token = session.token?.trim();
|
|
112
112
|
const issuedAt = session.session.issuedAt?.trim();
|
|
113
113
|
const expiresAt = session.session.expiresAt?.trim();
|
|
114
|
-
if (!accountId || !token || !issuedAt || !expiresAt) {
|
|
114
|
+
if (!accountId || !profileId || !token || !issuedAt || !expiresAt) {
|
|
115
115
|
throw new Error("Invalid login session payload.");
|
|
116
116
|
}
|
|
117
117
|
const nextSession = {
|
|
118
118
|
token,
|
|
119
119
|
accountId,
|
|
120
|
-
|
|
120
|
+
profileId,
|
|
121
121
|
issuedAt,
|
|
122
122
|
expiresAt,
|
|
123
123
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -181,6 +181,11 @@ function loadSessionStoreWithPath() {
|
|
|
181
181
|
return { sessionPath, store };
|
|
182
182
|
}
|
|
183
183
|
function normalizeStore(value) {
|
|
184
|
+
if (isLegacySessionStoreVersion(value)) {
|
|
185
|
+
throw new Error(
|
|
186
|
+
`Unsupported session store version in ${buildSessionStorePath()}. Run "pmate login" again.`
|
|
187
|
+
);
|
|
188
|
+
}
|
|
184
189
|
if (!isSessionStore(value)) {
|
|
185
190
|
throw new Error(
|
|
186
191
|
`Invalid session store format in ${buildSessionStorePath()}. Run "pmate login" again.`
|
|
@@ -188,6 +193,9 @@ function normalizeStore(value) {
|
|
|
188
193
|
}
|
|
189
194
|
return value;
|
|
190
195
|
}
|
|
196
|
+
function isLegacySessionStoreVersion(value) {
|
|
197
|
+
return !!value && typeof value === "object" && "version" in value && value.version !== SESSION_STORE_VERSION;
|
|
198
|
+
}
|
|
191
199
|
function isSessionStore(value) {
|
|
192
200
|
if (!value || typeof value !== "object") {
|
|
193
201
|
return false;
|
|
@@ -233,7 +241,7 @@ function isStoredSession(value) {
|
|
|
233
241
|
return false;
|
|
234
242
|
}
|
|
235
243
|
const session = value;
|
|
236
|
-
return typeof session.token === "string" && !!session.token.trim() && typeof session.accountId === "string" && !!session.accountId.trim() &&
|
|
244
|
+
return typeof session.token === "string" && !!session.token.trim() && typeof session.accountId === "string" && !!session.accountId.trim() && typeof session.profileId === "string" && !!session.profileId.trim() && typeof session.issuedAt === "string" && !!session.issuedAt.trim() && typeof session.expiresAt === "string" && !!session.expiresAt.trim() && typeof session.updatedAt === "string" && !!session.updatedAt.trim();
|
|
237
245
|
}
|
|
238
246
|
function resolveReadApp(store, options) {
|
|
239
247
|
const requestedApp = options?.app?.trim();
|
|
@@ -281,47 +289,7 @@ var init_sessionStore = __esm({
|
|
|
281
289
|
import_node_path3 = __toESM(require("path"));
|
|
282
290
|
init_namespacedRef();
|
|
283
291
|
DEFAULT_APP_ID = "pmate:factory";
|
|
284
|
-
SESSION_STORE_VERSION =
|
|
285
|
-
}
|
|
286
|
-
});
|
|
287
|
-
|
|
288
|
-
// src/profileClient.ts
|
|
289
|
-
async function fetchDefaultProfileId(options) {
|
|
290
|
-
const token = options.token.trim();
|
|
291
|
-
const app = options.app.trim();
|
|
292
|
-
const accountId = options.accountId.trim();
|
|
293
|
-
if (!token || !app || !accountId) {
|
|
294
|
-
throw new Error("Missing token, app, or accountId for profile lookup.");
|
|
295
|
-
}
|
|
296
|
-
const url = new URL(`${resolveAuthApiBaseUrl(options.authApiBaseUrl)}/profiles`);
|
|
297
|
-
url.searchParams.set("app", app);
|
|
298
|
-
url.searchParams.set("account", accountId);
|
|
299
|
-
const response = await fetch(url, {
|
|
300
|
-
headers: {
|
|
301
|
-
Authorization: `Bearer ${token}`
|
|
302
|
-
}
|
|
303
|
-
});
|
|
304
|
-
if (!response.ok) {
|
|
305
|
-
const detail = await response.text();
|
|
306
|
-
throw new Error(
|
|
307
|
-
`Failed to resolve default profile (${response.status}): ${detail || response.statusText}`
|
|
308
|
-
);
|
|
309
|
-
}
|
|
310
|
-
const envelope = await response.json();
|
|
311
|
-
const profileId = envelope.data?.[0]?.id?.trim();
|
|
312
|
-
if (!profileId) {
|
|
313
|
-
throw new Error(`No profile found for app ${app} and account ${accountId}.`);
|
|
314
|
-
}
|
|
315
|
-
return profileId;
|
|
316
|
-
}
|
|
317
|
-
function resolveAuthApiBaseUrl(value) {
|
|
318
|
-
return (value || process.env.PMATE_AUTH_API_BASE_URL || process.env.AUTH_API_BASE_URL || DEFAULT_AUTH_API_BASE_URL).replace(/\/+$/, "");
|
|
319
|
-
}
|
|
320
|
-
var DEFAULT_AUTH_API_BASE_URL;
|
|
321
|
-
var init_profileClient = __esm({
|
|
322
|
-
"src/profileClient.ts"() {
|
|
323
|
-
"use strict";
|
|
324
|
-
DEFAULT_AUTH_API_BASE_URL = "https://auth-api-v2.pmate.chat";
|
|
292
|
+
SESSION_STORE_VERSION = 4;
|
|
325
293
|
}
|
|
326
294
|
});
|
|
327
295
|
|
|
@@ -9514,7 +9482,6 @@ var init_AgentLlmClient = __esm({
|
|
|
9514
9482
|
import_node_path11 = __toESM(require("path"));
|
|
9515
9483
|
init_dist2();
|
|
9516
9484
|
init_sessionStore();
|
|
9517
|
-
init_profileClient();
|
|
9518
9485
|
DEFAULT_AGENT_API_BASE_URL = "https://agent-api.pmate.chat";
|
|
9519
9486
|
DEFAULT_AGENT_HUB_BASE_URL = "https://hub.pmate.chat";
|
|
9520
9487
|
DEFAULT_NAMESPACE = "pmate-cli";
|
|
@@ -9527,7 +9494,6 @@ var init_AgentLlmClient = __esm({
|
|
|
9527
9494
|
this.token = options?.token ?? this.session.token;
|
|
9528
9495
|
this.profileId = options?.profileId?.trim() || process.env.PMATE_PROFILE_ID || this.session.profileId;
|
|
9529
9496
|
this.agentApiBaseUrl = resolveAgentApiBaseUrl(options?.agentApiBaseUrl);
|
|
9530
|
-
this.authApiBaseUrl = resolveAuthApiBaseUrl(options?.authApiBaseUrl);
|
|
9531
9497
|
this.hubBaseUrl = resolveHubBaseUrl(options?.hubBaseUrl);
|
|
9532
9498
|
this.from = options?.from?.trim() || void 0;
|
|
9533
9499
|
this.agentService = new AgentService({
|
|
@@ -9594,12 +9560,7 @@ var init_AgentLlmClient = __esm({
|
|
|
9594
9560
|
if (profileId) {
|
|
9595
9561
|
return profileId;
|
|
9596
9562
|
}
|
|
9597
|
-
|
|
9598
|
-
token: this.token,
|
|
9599
|
-
app: DEFAULT_APP_ID,
|
|
9600
|
-
accountId: this.session.accountId,
|
|
9601
|
-
authApiBaseUrl: this.authApiBaseUrl
|
|
9602
|
-
});
|
|
9563
|
+
throw new Error(`Missing profileId in session. Run "pmate login --app ${DEFAULT_APP_ID}" again.`);
|
|
9603
9564
|
}
|
|
9604
9565
|
resolveFrom(value, profileId) {
|
|
9605
9566
|
return value?.trim() || this.from || profileId;
|
|
@@ -10048,8 +10009,52 @@ var ListCommandHandler = class {
|
|
|
10048
10009
|
// src/commands/LoginCommandHandler.ts
|
|
10049
10010
|
var import_node_child_process = require("child_process");
|
|
10050
10011
|
var import_node_http = require("http");
|
|
10012
|
+
var import_promises = require("readline/promises");
|
|
10051
10013
|
init_sessionStore();
|
|
10052
|
-
|
|
10014
|
+
|
|
10015
|
+
// src/profileClient.ts
|
|
10016
|
+
var DEFAULT_AUTH_API_BASE_URL = "https://auth-api-v2.pmate.chat";
|
|
10017
|
+
async function fetchDefaultProfileId(options) {
|
|
10018
|
+
const profiles = await fetchProfiles(options);
|
|
10019
|
+
const profileId = profiles[0]?.id?.trim();
|
|
10020
|
+
if (!profileId) {
|
|
10021
|
+
throw new Error(
|
|
10022
|
+
`No profile found for app ${options.app.trim()} and account ${options.accountId.trim()}.`
|
|
10023
|
+
);
|
|
10024
|
+
}
|
|
10025
|
+
return profileId;
|
|
10026
|
+
}
|
|
10027
|
+
async function fetchProfiles(options) {
|
|
10028
|
+
const token = options.token.trim();
|
|
10029
|
+
const app = options.app.trim();
|
|
10030
|
+
const accountId = options.accountId.trim();
|
|
10031
|
+
if (!token || !app || !accountId) {
|
|
10032
|
+
throw new Error("Missing token, app, or accountId for profile lookup.");
|
|
10033
|
+
}
|
|
10034
|
+
const url = new URL(`${resolveAuthApiBaseUrl(options.authApiBaseUrl)}/profiles`);
|
|
10035
|
+
url.searchParams.set("app", app);
|
|
10036
|
+
url.searchParams.set("account", accountId);
|
|
10037
|
+
const response = await fetch(url, {
|
|
10038
|
+
headers: {
|
|
10039
|
+
Authorization: `Bearer ${token}`
|
|
10040
|
+
}
|
|
10041
|
+
});
|
|
10042
|
+
if (!response.ok) {
|
|
10043
|
+
const detail = await response.text();
|
|
10044
|
+
throw new Error(
|
|
10045
|
+
`Failed to resolve default profile (${response.status}): ${detail || response.statusText}`
|
|
10046
|
+
);
|
|
10047
|
+
}
|
|
10048
|
+
const envelope = await response.json();
|
|
10049
|
+
return (envelope.data ?? []).filter(
|
|
10050
|
+
(profile) => !!profile?.id && typeof profile.id === "string"
|
|
10051
|
+
);
|
|
10052
|
+
}
|
|
10053
|
+
function resolveAuthApiBaseUrl(value) {
|
|
10054
|
+
return (value || process.env.PMATE_AUTH_API_BASE_URL || process.env.AUTH_API_BASE_URL || DEFAULT_AUTH_API_BASE_URL).replace(/\/+$/, "");
|
|
10055
|
+
}
|
|
10056
|
+
|
|
10057
|
+
// src/commands/LoginCommandHandler.ts
|
|
10053
10058
|
var AUTH_UI_BASE_URL = "https://auth.pmate.chat";
|
|
10054
10059
|
var AUTH_API_BASE_URL = DEFAULT_AUTH_API_BASE_URL;
|
|
10055
10060
|
var CALLBACK_PATH = "/pmate-login-callback";
|
|
@@ -10082,11 +10087,16 @@ var LoginCommandHandler = class {
|
|
|
10082
10087
|
try {
|
|
10083
10088
|
const token = await callback.waitForToken;
|
|
10084
10089
|
const loginResponse = await this.exchangeSession(token, appId);
|
|
10085
|
-
const
|
|
10090
|
+
const profiles = await fetchProfiles({
|
|
10086
10091
|
token: loginResponse.token,
|
|
10087
10092
|
app: appId,
|
|
10088
10093
|
accountId: loginResponse.session.identity.accountId
|
|
10089
10094
|
});
|
|
10095
|
+
const profileId = await this.resolveProfileId({
|
|
10096
|
+
appId,
|
|
10097
|
+
requestedProfileId: args.profileId,
|
|
10098
|
+
profiles
|
|
10099
|
+
});
|
|
10090
10100
|
savedSession = saveLoginSession({ ...loginResponse, profileId }, appId);
|
|
10091
10101
|
} finally {
|
|
10092
10102
|
await callback.close();
|
|
@@ -10119,6 +10129,58 @@ var LoginCommandHandler = class {
|
|
|
10119
10129
|
}
|
|
10120
10130
|
return resp.data;
|
|
10121
10131
|
}
|
|
10132
|
+
async resolveProfileId(input) {
|
|
10133
|
+
const requestedProfileId = input.requestedProfileId?.trim();
|
|
10134
|
+
if (requestedProfileId) {
|
|
10135
|
+
const exists = input.profiles.some((profile) => profile.id === requestedProfileId);
|
|
10136
|
+
if (!exists) {
|
|
10137
|
+
throw new Error(`Profile ${requestedProfileId} was not found for app ${input.appId}.`);
|
|
10138
|
+
}
|
|
10139
|
+
return requestedProfileId;
|
|
10140
|
+
}
|
|
10141
|
+
if (input.profiles.length === 0) {
|
|
10142
|
+
throw new Error(`No profile found for app ${input.appId}.`);
|
|
10143
|
+
}
|
|
10144
|
+
if (input.profiles.length === 1) {
|
|
10145
|
+
return input.profiles[0].id;
|
|
10146
|
+
}
|
|
10147
|
+
if (!process.stdin.isTTY || !process.stdout.isTTY) {
|
|
10148
|
+
const selected = input.profiles[0];
|
|
10149
|
+
ui.warn("Multiple profiles found; non-interactive login selected the first profile.", {
|
|
10150
|
+
app: input.appId,
|
|
10151
|
+
profileId: selected.id
|
|
10152
|
+
});
|
|
10153
|
+
return selected.id;
|
|
10154
|
+
}
|
|
10155
|
+
ui.info(`Multiple profiles found for ${input.appId}. Select one:`);
|
|
10156
|
+
input.profiles.forEach((profile, index) => {
|
|
10157
|
+
ui.plain(`${index + 1}. ${this.formatProfileLabel(profile)}`);
|
|
10158
|
+
});
|
|
10159
|
+
const rl = (0, import_promises.createInterface)({
|
|
10160
|
+
input: process.stdin,
|
|
10161
|
+
output: process.stdout
|
|
10162
|
+
});
|
|
10163
|
+
try {
|
|
10164
|
+
while (true) {
|
|
10165
|
+
const answer = (await rl.question("Profile number: ")).trim();
|
|
10166
|
+
const index = Number.parseInt(answer, 10);
|
|
10167
|
+
if (Number.isInteger(index) && index >= 1 && index <= input.profiles.length) {
|
|
10168
|
+
return input.profiles[index - 1].id;
|
|
10169
|
+
}
|
|
10170
|
+
ui.warn(`Enter a number from 1 to ${input.profiles.length}.`);
|
|
10171
|
+
}
|
|
10172
|
+
} finally {
|
|
10173
|
+
rl.close();
|
|
10174
|
+
}
|
|
10175
|
+
}
|
|
10176
|
+
formatProfileLabel(profile) {
|
|
10177
|
+
const parts = [
|
|
10178
|
+
profile.nickName?.trim(),
|
|
10179
|
+
profile.userName?.trim(),
|
|
10180
|
+
profile.role?.trim()
|
|
10181
|
+
].filter(Boolean);
|
|
10182
|
+
return parts.length > 0 ? `${parts.join(" / ")} (${profile.id})` : profile.id;
|
|
10183
|
+
}
|
|
10122
10184
|
async startCallbackServer() {
|
|
10123
10185
|
let resolveToken;
|
|
10124
10186
|
let rejectToken;
|
|
@@ -11272,7 +11334,7 @@ var import_node_path5 = __toESM(require("path"));
|
|
|
11272
11334
|
var import_node_child_process2 = require("child_process");
|
|
11273
11335
|
|
|
11274
11336
|
// src/serverAddress.ts
|
|
11275
|
-
var
|
|
11337
|
+
var import_promises2 = require("dns/promises");
|
|
11276
11338
|
var IPV4_PATTERN = /^(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}$/;
|
|
11277
11339
|
function isIpv4Address(value) {
|
|
11278
11340
|
return IPV4_PATTERN.test(value.trim());
|
|
@@ -11285,7 +11347,7 @@ async function resolveServerAddress(server) {
|
|
|
11285
11347
|
if (isIpv4Address(normalized)) {
|
|
11286
11348
|
return normalized;
|
|
11287
11349
|
}
|
|
11288
|
-
const resolved = await (0,
|
|
11350
|
+
const resolved = await (0, import_promises2.lookup)(normalized, { family: 4 });
|
|
11289
11351
|
return resolved.address;
|
|
11290
11352
|
}
|
|
11291
11353
|
|
|
@@ -11947,7 +12009,7 @@ function formatEnvValue(value) {
|
|
|
11947
12009
|
|
|
11948
12010
|
// src/commands/PrepareDevCommandHandler.ts
|
|
11949
12011
|
var import_node_fs6 = require("fs");
|
|
11950
|
-
var
|
|
12012
|
+
var import_promises3 = require("fs/promises");
|
|
11951
12013
|
var import_node_os3 = __toESM(require("os"));
|
|
11952
12014
|
var import_node_path10 = __toESM(require("path"));
|
|
11953
12015
|
var import_node_child_process5 = require("child_process");
|
|
@@ -11971,7 +12033,7 @@ var PrepareDevCommandHandler = class {
|
|
|
11971
12033
|
return result;
|
|
11972
12034
|
}
|
|
11973
12035
|
async openEnvironment(repo, note, envRoot, baseRoot) {
|
|
11974
|
-
await (0,
|
|
12036
|
+
await (0, import_promises3.mkdir)(envRoot, { recursive: true });
|
|
11975
12037
|
const baseRepoPath = import_node_path10.default.join(baseRoot, repo);
|
|
11976
12038
|
if (!await this.pathExists(baseRepoPath)) {
|
|
11977
12039
|
throw new Error(`Base repo not found: ${baseRepoPath}`);
|
|
@@ -12130,7 +12192,7 @@ var PrepareDevCommandHandler = class {
|
|
|
12130
12192
|
}
|
|
12131
12193
|
async pathExists(targetPath) {
|
|
12132
12194
|
try {
|
|
12133
|
-
await (0,
|
|
12195
|
+
await (0, import_promises3.access)(targetPath, import_node_fs6.constants.F_OK);
|
|
12134
12196
|
return true;
|
|
12135
12197
|
} catch {
|
|
12136
12198
|
return false;
|
|
@@ -12145,7 +12207,7 @@ var PrepareDevCommandHandler = class {
|
|
|
12145
12207
|
note,
|
|
12146
12208
|
openedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
12147
12209
|
};
|
|
12148
|
-
await (0,
|
|
12210
|
+
await (0, import_promises3.writeFile)(lockPath, `${JSON.stringify(payload, null, 2)}
|
|
12149
12211
|
`, {
|
|
12150
12212
|
encoding: "utf8",
|
|
12151
12213
|
flag: "wx"
|
|
@@ -12155,7 +12217,7 @@ var PrepareDevCommandHandler = class {
|
|
|
12155
12217
|
if (!await this.pathExists(lockPath)) {
|
|
12156
12218
|
return false;
|
|
12157
12219
|
}
|
|
12158
|
-
await (0,
|
|
12220
|
+
await (0, import_promises3.rm)(lockPath, { force: true });
|
|
12159
12221
|
return true;
|
|
12160
12222
|
}
|
|
12161
12223
|
isLocalOrigin(origin) {
|
|
@@ -13076,7 +13138,7 @@ var import_node_child_process8 = require("child_process");
|
|
|
13076
13138
|
var import_node_fs8 = require("fs");
|
|
13077
13139
|
var import_node_os4 = __toESM(require("os"));
|
|
13078
13140
|
var import_node_path13 = __toESM(require("path"));
|
|
13079
|
-
var
|
|
13141
|
+
var import_promises4 = require("readline/promises");
|
|
13080
13142
|
var import_openai = __toESM(require("openai"));
|
|
13081
13143
|
var import_sdk = require("@linear/sdk");
|
|
13082
13144
|
var ISSUE_SUMMARY_FIELDS = `
|
|
@@ -13927,7 +13989,7 @@ var LinearCommandHandler = class {
|
|
|
13927
13989
|
return accounts[index];
|
|
13928
13990
|
}
|
|
13929
13991
|
}
|
|
13930
|
-
const rl = (0,
|
|
13992
|
+
const rl = (0, import_promises4.createInterface)({
|
|
13931
13993
|
input: process.stdin,
|
|
13932
13994
|
output: process.stdout
|
|
13933
13995
|
});
|
|
@@ -14093,7 +14155,7 @@ var LinearCommandHandler = class {
|
|
|
14093
14155
|
ui.info(issue.description?.trim() ? issue.description : " (no description)");
|
|
14094
14156
|
}
|
|
14095
14157
|
async collectReplInput() {
|
|
14096
|
-
const rl = (0,
|
|
14158
|
+
const rl = (0, import_promises4.createInterface)({
|
|
14097
14159
|
input: process.stdin,
|
|
14098
14160
|
output: process.stdout
|
|
14099
14161
|
});
|
|
@@ -14153,7 +14215,7 @@ var LinearCommandHandler = class {
|
|
|
14153
14215
|
} else {
|
|
14154
14216
|
ui.info("Copy a screenshot to your clipboard, then press Enter.");
|
|
14155
14217
|
}
|
|
14156
|
-
const rl = (0,
|
|
14218
|
+
const rl = (0, import_promises4.createInterface)({
|
|
14157
14219
|
input: process.stdin,
|
|
14158
14220
|
output: process.stdout
|
|
14159
14221
|
});
|
|
@@ -15047,7 +15109,7 @@ var import_node_child_process9 = require("child_process");
|
|
|
15047
15109
|
var import_node_fs10 = require("fs");
|
|
15048
15110
|
var import_node_os5 = __toESM(require("os"));
|
|
15049
15111
|
var import_node_path15 = __toESM(require("path"));
|
|
15050
|
-
var
|
|
15112
|
+
var import_promises5 = require("readline/promises");
|
|
15051
15113
|
var import_jsqr = __toESM(require("jsqr"));
|
|
15052
15114
|
var import_pngjs = require("pngjs");
|
|
15053
15115
|
var QrcodeCommandHandler = class {
|
|
@@ -15079,7 +15141,7 @@ var QrcodeCommandHandler = class {
|
|
|
15079
15141
|
}
|
|
15080
15142
|
async captureScreenshot() {
|
|
15081
15143
|
ui.info("Capture a QR code screenshot now (macOS screencapture).");
|
|
15082
|
-
const rl = (0,
|
|
15144
|
+
const rl = (0, import_promises5.createInterface)({
|
|
15083
15145
|
input: process.stdin,
|
|
15084
15146
|
output: process.stdout
|
|
15085
15147
|
});
|
|
@@ -15130,7 +15192,7 @@ var QrcodeCommandHandler = class {
|
|
|
15130
15192
|
return value ? value : null;
|
|
15131
15193
|
}
|
|
15132
15194
|
async promptValue(detected) {
|
|
15133
|
-
const rl = (0,
|
|
15195
|
+
const rl = (0, import_promises5.createInterface)({
|
|
15134
15196
|
input: process.stdin,
|
|
15135
15197
|
output: process.stdout
|
|
15136
15198
|
});
|
|
@@ -18464,9 +18526,9 @@ function readNamespaceFromPayload(payload) {
|
|
|
18464
18526
|
|
|
18465
18527
|
// src/commands/ServiceCommandHandler.ts
|
|
18466
18528
|
var import_node_fs20 = require("fs");
|
|
18467
|
-
var
|
|
18529
|
+
var import_promises6 = require("fs/promises");
|
|
18468
18530
|
var import_node_path24 = __toESM(require("path"));
|
|
18469
|
-
var
|
|
18531
|
+
var import_promises7 = require("readline/promises");
|
|
18470
18532
|
|
|
18471
18533
|
// src/services/ServiceRuntimeRunner.ts
|
|
18472
18534
|
var import_node_fs19 = require("fs");
|
|
@@ -20195,7 +20257,7 @@ var ServiceCommandHandler = class {
|
|
|
20195
20257
|
}
|
|
20196
20258
|
);
|
|
20197
20259
|
const outputPath = import_node_path24.default.resolve(process.cwd(), args.output);
|
|
20198
|
-
await (0,
|
|
20260
|
+
await (0, import_promises6.writeFile)(outputPath, payload.content, "utf8");
|
|
20199
20261
|
ui.success(`Wrote env file for ${args.appId} to ${outputPath}`);
|
|
20200
20262
|
this.renderJson({ ...payload, output: outputPath }, args.json);
|
|
20201
20263
|
return;
|
|
@@ -20283,7 +20345,7 @@ var ServiceCommandHandler = class {
|
|
|
20283
20345
|
if (!process.stdin.isTTY || !process.stdout.isTTY) {
|
|
20284
20346
|
throw new Error("Prompt input requires an interactive terminal.");
|
|
20285
20347
|
}
|
|
20286
|
-
const rl = (0,
|
|
20348
|
+
const rl = (0, import_promises7.createInterface)({
|
|
20287
20349
|
input: process.stdin,
|
|
20288
20350
|
output: process.stdout
|
|
20289
20351
|
});
|
|
@@ -20861,7 +20923,13 @@ var AccountCommandHandler = class {
|
|
|
20861
20923
|
signature: this.signBotChallenge(challenge, privateKey)
|
|
20862
20924
|
}
|
|
20863
20925
|
);
|
|
20864
|
-
const
|
|
20926
|
+
const profileId = await fetchDefaultProfileId({
|
|
20927
|
+
token: login.token,
|
|
20928
|
+
app: args.app,
|
|
20929
|
+
accountId: login.session.identity.accountId,
|
|
20930
|
+
authApiBaseUrl: baseUrl
|
|
20931
|
+
});
|
|
20932
|
+
const saved = saveLoginSession({ ...login, profileId }, args.app);
|
|
20865
20933
|
if (!args.json) {
|
|
20866
20934
|
ui.success(`Logged in bot ${args.name} to ${saved.app}`);
|
|
20867
20935
|
}
|
|
@@ -24268,7 +24336,7 @@ var HELP_TEXT = [
|
|
|
24268
24336
|
import_chalk4.default.bold("Commands:"),
|
|
24269
24337
|
` ${import_chalk4.default.cyan("list [path]")} List apps from .pmate.yaml in the target folder`,
|
|
24270
24338
|
` ${import_chalk4.default.cyan("login")} Log in and store a session in ~/.pmate/session.json`,
|
|
24271
|
-
` ${import_chalk4.default.gray(" [--app <app-id>]")}`,
|
|
24339
|
+
` ${import_chalk4.default.gray(" [--app <app-id>] [--profile-id <id>]")}`,
|
|
24272
24340
|
` ${import_chalk4.default.cyan("add-dns")} Add a DNS record via Aliyun DNS`,
|
|
24273
24341
|
` ${import_chalk4.default.gray(" --type <t> --value <v> --rr <rr> [--ttl <n>] [--domain <name>]")}`,
|
|
24274
24342
|
` ${import_chalk4.default.cyan("sts")} Request an OSS STS token from the CI server`,
|
|
@@ -24491,17 +24559,21 @@ function parseCommandArgs(args) {
|
|
|
24491
24559
|
if (args.rest[0] === "login") {
|
|
24492
24560
|
const rest = args.rest.slice(1);
|
|
24493
24561
|
let app;
|
|
24562
|
+
let profileId;
|
|
24494
24563
|
while (rest.length > 0) {
|
|
24495
24564
|
const token = rest.shift();
|
|
24496
24565
|
switch (token) {
|
|
24497
24566
|
case "--app":
|
|
24498
24567
|
app = requireValue13(rest, token);
|
|
24499
24568
|
break;
|
|
24569
|
+
case "--profile-id":
|
|
24570
|
+
profileId = requireValue13(rest, token);
|
|
24571
|
+
break;
|
|
24500
24572
|
default:
|
|
24501
24573
|
throw new Error(`Unknown login option: ${token}`);
|
|
24502
24574
|
}
|
|
24503
24575
|
}
|
|
24504
|
-
return { type: "login" /* Login */, app };
|
|
24576
|
+
return { type: "login" /* Login */, app, profileId };
|
|
24505
24577
|
}
|
|
24506
24578
|
if (args.rest[0] === "add-dns") {
|
|
24507
24579
|
return parseAddDnsArgs(args.rest.slice(1));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pmate/cli",
|
|
3
|
-
"version": "0.24.
|
|
3
|
+
"version": "0.24.22",
|
|
4
4
|
"description": "CLI utilities for the pMate project",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
@@ -11,16 +11,6 @@
|
|
|
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": "npm publish",
|
|
19
|
-
"start": "node dist/index.js",
|
|
20
|
-
"test": "vitest run src/tests",
|
|
21
|
-
"typecheck": "tsc --noEmit",
|
|
22
|
-
"prepare": "npm run build"
|
|
23
|
-
},
|
|
24
14
|
"keywords": [
|
|
25
15
|
"cli",
|
|
26
16
|
"typescript",
|
|
@@ -67,10 +57,13 @@
|
|
|
67
57
|
"typescript": "^5.9.3",
|
|
68
58
|
"vitest": "^4.0.17"
|
|
69
59
|
},
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
60
|
+
"scripts": {
|
|
61
|
+
"build": "npm run clean && tsup --config tsup.config.ts && node scripts/copy-templates.js",
|
|
62
|
+
"clean": "rimraf dist",
|
|
63
|
+
"dev": "ts-node src/index.ts",
|
|
64
|
+
"release": "npm publish",
|
|
65
|
+
"start": "node dist/index.js",
|
|
66
|
+
"test": "vitest run src/tests",
|
|
67
|
+
"typecheck": "tsc --noEmit"
|
|
75
68
|
}
|
|
76
|
-
}
|
|
69
|
+
}
|