@pmate/cli 0.24.21 → 0.24.23
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 +145 -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,56 @@ 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 profileIds = input.profiles.map((profile) => profile.id).join(", ");
|
|
10149
|
+
throw new Error(
|
|
10150
|
+
`Multiple profiles found for app ${input.appId}. Run "pmate login --app ${input.appId} --profile-id <id>" with one of: ${profileIds}`
|
|
10151
|
+
);
|
|
10152
|
+
}
|
|
10153
|
+
ui.info(`Multiple profiles found for ${input.appId}. Select one:`);
|
|
10154
|
+
input.profiles.forEach((profile, index) => {
|
|
10155
|
+
ui.plain(`${index + 1}. ${this.formatProfileLabel(profile)}`);
|
|
10156
|
+
});
|
|
10157
|
+
const rl = (0, import_promises.createInterface)({
|
|
10158
|
+
input: process.stdin,
|
|
10159
|
+
output: process.stdout
|
|
10160
|
+
});
|
|
10161
|
+
try {
|
|
10162
|
+
while (true) {
|
|
10163
|
+
const answer = (await rl.question("Profile number: ")).trim();
|
|
10164
|
+
const index = Number.parseInt(answer, 10);
|
|
10165
|
+
if (Number.isInteger(index) && index >= 1 && index <= input.profiles.length) {
|
|
10166
|
+
return input.profiles[index - 1].id;
|
|
10167
|
+
}
|
|
10168
|
+
ui.warn(`Enter a number from 1 to ${input.profiles.length}.`);
|
|
10169
|
+
}
|
|
10170
|
+
} finally {
|
|
10171
|
+
rl.close();
|
|
10172
|
+
}
|
|
10173
|
+
}
|
|
10174
|
+
formatProfileLabel(profile) {
|
|
10175
|
+
const parts = [
|
|
10176
|
+
profile.nickName?.trim(),
|
|
10177
|
+
profile.userName?.trim(),
|
|
10178
|
+
profile.role?.trim()
|
|
10179
|
+
].filter(Boolean);
|
|
10180
|
+
return parts.length > 0 ? `${parts.join(" / ")} (${profile.id})` : profile.id;
|
|
10181
|
+
}
|
|
10122
10182
|
async startCallbackServer() {
|
|
10123
10183
|
let resolveToken;
|
|
10124
10184
|
let rejectToken;
|
|
@@ -11272,7 +11332,7 @@ var import_node_path5 = __toESM(require("path"));
|
|
|
11272
11332
|
var import_node_child_process2 = require("child_process");
|
|
11273
11333
|
|
|
11274
11334
|
// src/serverAddress.ts
|
|
11275
|
-
var
|
|
11335
|
+
var import_promises2 = require("dns/promises");
|
|
11276
11336
|
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
11337
|
function isIpv4Address(value) {
|
|
11278
11338
|
return IPV4_PATTERN.test(value.trim());
|
|
@@ -11285,7 +11345,7 @@ async function resolveServerAddress(server) {
|
|
|
11285
11345
|
if (isIpv4Address(normalized)) {
|
|
11286
11346
|
return normalized;
|
|
11287
11347
|
}
|
|
11288
|
-
const resolved = await (0,
|
|
11348
|
+
const resolved = await (0, import_promises2.lookup)(normalized, { family: 4 });
|
|
11289
11349
|
return resolved.address;
|
|
11290
11350
|
}
|
|
11291
11351
|
|
|
@@ -11947,7 +12007,7 @@ function formatEnvValue(value) {
|
|
|
11947
12007
|
|
|
11948
12008
|
// src/commands/PrepareDevCommandHandler.ts
|
|
11949
12009
|
var import_node_fs6 = require("fs");
|
|
11950
|
-
var
|
|
12010
|
+
var import_promises3 = require("fs/promises");
|
|
11951
12011
|
var import_node_os3 = __toESM(require("os"));
|
|
11952
12012
|
var import_node_path10 = __toESM(require("path"));
|
|
11953
12013
|
var import_node_child_process5 = require("child_process");
|
|
@@ -11971,7 +12031,7 @@ var PrepareDevCommandHandler = class {
|
|
|
11971
12031
|
return result;
|
|
11972
12032
|
}
|
|
11973
12033
|
async openEnvironment(repo, note, envRoot, baseRoot) {
|
|
11974
|
-
await (0,
|
|
12034
|
+
await (0, import_promises3.mkdir)(envRoot, { recursive: true });
|
|
11975
12035
|
const baseRepoPath = import_node_path10.default.join(baseRoot, repo);
|
|
11976
12036
|
if (!await this.pathExists(baseRepoPath)) {
|
|
11977
12037
|
throw new Error(`Base repo not found: ${baseRepoPath}`);
|
|
@@ -12130,7 +12190,7 @@ var PrepareDevCommandHandler = class {
|
|
|
12130
12190
|
}
|
|
12131
12191
|
async pathExists(targetPath) {
|
|
12132
12192
|
try {
|
|
12133
|
-
await (0,
|
|
12193
|
+
await (0, import_promises3.access)(targetPath, import_node_fs6.constants.F_OK);
|
|
12134
12194
|
return true;
|
|
12135
12195
|
} catch {
|
|
12136
12196
|
return false;
|
|
@@ -12145,7 +12205,7 @@ var PrepareDevCommandHandler = class {
|
|
|
12145
12205
|
note,
|
|
12146
12206
|
openedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
12147
12207
|
};
|
|
12148
|
-
await (0,
|
|
12208
|
+
await (0, import_promises3.writeFile)(lockPath, `${JSON.stringify(payload, null, 2)}
|
|
12149
12209
|
`, {
|
|
12150
12210
|
encoding: "utf8",
|
|
12151
12211
|
flag: "wx"
|
|
@@ -12155,7 +12215,7 @@ var PrepareDevCommandHandler = class {
|
|
|
12155
12215
|
if (!await this.pathExists(lockPath)) {
|
|
12156
12216
|
return false;
|
|
12157
12217
|
}
|
|
12158
|
-
await (0,
|
|
12218
|
+
await (0, import_promises3.rm)(lockPath, { force: true });
|
|
12159
12219
|
return true;
|
|
12160
12220
|
}
|
|
12161
12221
|
isLocalOrigin(origin) {
|
|
@@ -13076,7 +13136,7 @@ var import_node_child_process8 = require("child_process");
|
|
|
13076
13136
|
var import_node_fs8 = require("fs");
|
|
13077
13137
|
var import_node_os4 = __toESM(require("os"));
|
|
13078
13138
|
var import_node_path13 = __toESM(require("path"));
|
|
13079
|
-
var
|
|
13139
|
+
var import_promises4 = require("readline/promises");
|
|
13080
13140
|
var import_openai = __toESM(require("openai"));
|
|
13081
13141
|
var import_sdk = require("@linear/sdk");
|
|
13082
13142
|
var ISSUE_SUMMARY_FIELDS = `
|
|
@@ -13927,7 +13987,7 @@ var LinearCommandHandler = class {
|
|
|
13927
13987
|
return accounts[index];
|
|
13928
13988
|
}
|
|
13929
13989
|
}
|
|
13930
|
-
const rl = (0,
|
|
13990
|
+
const rl = (0, import_promises4.createInterface)({
|
|
13931
13991
|
input: process.stdin,
|
|
13932
13992
|
output: process.stdout
|
|
13933
13993
|
});
|
|
@@ -14093,7 +14153,7 @@ var LinearCommandHandler = class {
|
|
|
14093
14153
|
ui.info(issue.description?.trim() ? issue.description : " (no description)");
|
|
14094
14154
|
}
|
|
14095
14155
|
async collectReplInput() {
|
|
14096
|
-
const rl = (0,
|
|
14156
|
+
const rl = (0, import_promises4.createInterface)({
|
|
14097
14157
|
input: process.stdin,
|
|
14098
14158
|
output: process.stdout
|
|
14099
14159
|
});
|
|
@@ -14153,7 +14213,7 @@ var LinearCommandHandler = class {
|
|
|
14153
14213
|
} else {
|
|
14154
14214
|
ui.info("Copy a screenshot to your clipboard, then press Enter.");
|
|
14155
14215
|
}
|
|
14156
|
-
const rl = (0,
|
|
14216
|
+
const rl = (0, import_promises4.createInterface)({
|
|
14157
14217
|
input: process.stdin,
|
|
14158
14218
|
output: process.stdout
|
|
14159
14219
|
});
|
|
@@ -15047,7 +15107,7 @@ var import_node_child_process9 = require("child_process");
|
|
|
15047
15107
|
var import_node_fs10 = require("fs");
|
|
15048
15108
|
var import_node_os5 = __toESM(require("os"));
|
|
15049
15109
|
var import_node_path15 = __toESM(require("path"));
|
|
15050
|
-
var
|
|
15110
|
+
var import_promises5 = require("readline/promises");
|
|
15051
15111
|
var import_jsqr = __toESM(require("jsqr"));
|
|
15052
15112
|
var import_pngjs = require("pngjs");
|
|
15053
15113
|
var QrcodeCommandHandler = class {
|
|
@@ -15079,7 +15139,7 @@ var QrcodeCommandHandler = class {
|
|
|
15079
15139
|
}
|
|
15080
15140
|
async captureScreenshot() {
|
|
15081
15141
|
ui.info("Capture a QR code screenshot now (macOS screencapture).");
|
|
15082
|
-
const rl = (0,
|
|
15142
|
+
const rl = (0, import_promises5.createInterface)({
|
|
15083
15143
|
input: process.stdin,
|
|
15084
15144
|
output: process.stdout
|
|
15085
15145
|
});
|
|
@@ -15130,7 +15190,7 @@ var QrcodeCommandHandler = class {
|
|
|
15130
15190
|
return value ? value : null;
|
|
15131
15191
|
}
|
|
15132
15192
|
async promptValue(detected) {
|
|
15133
|
-
const rl = (0,
|
|
15193
|
+
const rl = (0, import_promises5.createInterface)({
|
|
15134
15194
|
input: process.stdin,
|
|
15135
15195
|
output: process.stdout
|
|
15136
15196
|
});
|
|
@@ -18464,9 +18524,9 @@ function readNamespaceFromPayload(payload) {
|
|
|
18464
18524
|
|
|
18465
18525
|
// src/commands/ServiceCommandHandler.ts
|
|
18466
18526
|
var import_node_fs20 = require("fs");
|
|
18467
|
-
var
|
|
18527
|
+
var import_promises6 = require("fs/promises");
|
|
18468
18528
|
var import_node_path24 = __toESM(require("path"));
|
|
18469
|
-
var
|
|
18529
|
+
var import_promises7 = require("readline/promises");
|
|
18470
18530
|
|
|
18471
18531
|
// src/services/ServiceRuntimeRunner.ts
|
|
18472
18532
|
var import_node_fs19 = require("fs");
|
|
@@ -20195,7 +20255,7 @@ var ServiceCommandHandler = class {
|
|
|
20195
20255
|
}
|
|
20196
20256
|
);
|
|
20197
20257
|
const outputPath = import_node_path24.default.resolve(process.cwd(), args.output);
|
|
20198
|
-
await (0,
|
|
20258
|
+
await (0, import_promises6.writeFile)(outputPath, payload.content, "utf8");
|
|
20199
20259
|
ui.success(`Wrote env file for ${args.appId} to ${outputPath}`);
|
|
20200
20260
|
this.renderJson({ ...payload, output: outputPath }, args.json);
|
|
20201
20261
|
return;
|
|
@@ -20283,7 +20343,7 @@ var ServiceCommandHandler = class {
|
|
|
20283
20343
|
if (!process.stdin.isTTY || !process.stdout.isTTY) {
|
|
20284
20344
|
throw new Error("Prompt input requires an interactive terminal.");
|
|
20285
20345
|
}
|
|
20286
|
-
const rl = (0,
|
|
20346
|
+
const rl = (0, import_promises7.createInterface)({
|
|
20287
20347
|
input: process.stdin,
|
|
20288
20348
|
output: process.stdout
|
|
20289
20349
|
});
|
|
@@ -20861,7 +20921,13 @@ var AccountCommandHandler = class {
|
|
|
20861
20921
|
signature: this.signBotChallenge(challenge, privateKey)
|
|
20862
20922
|
}
|
|
20863
20923
|
);
|
|
20864
|
-
const
|
|
20924
|
+
const profileId = await fetchDefaultProfileId({
|
|
20925
|
+
token: login.token,
|
|
20926
|
+
app: args.app,
|
|
20927
|
+
accountId: login.session.identity.accountId,
|
|
20928
|
+
authApiBaseUrl: baseUrl
|
|
20929
|
+
});
|
|
20930
|
+
const saved = saveLoginSession({ ...login, profileId }, args.app);
|
|
20865
20931
|
if (!args.json) {
|
|
20866
20932
|
ui.success(`Logged in bot ${args.name} to ${saved.app}`);
|
|
20867
20933
|
}
|
|
@@ -24268,7 +24334,7 @@ var HELP_TEXT = [
|
|
|
24268
24334
|
import_chalk4.default.bold("Commands:"),
|
|
24269
24335
|
` ${import_chalk4.default.cyan("list [path]")} List apps from .pmate.yaml in the target folder`,
|
|
24270
24336
|
` ${import_chalk4.default.cyan("login")} Log in and store a session in ~/.pmate/session.json`,
|
|
24271
|
-
` ${import_chalk4.default.gray(" [--app <app-id>]")}`,
|
|
24337
|
+
` ${import_chalk4.default.gray(" [--app <app-id>] [--profile-id <id>]")}`,
|
|
24272
24338
|
` ${import_chalk4.default.cyan("add-dns")} Add a DNS record via Aliyun DNS`,
|
|
24273
24339
|
` ${import_chalk4.default.gray(" --type <t> --value <v> --rr <rr> [--ttl <n>] [--domain <name>]")}`,
|
|
24274
24340
|
` ${import_chalk4.default.cyan("sts")} Request an OSS STS token from the CI server`,
|
|
@@ -24491,17 +24557,21 @@ function parseCommandArgs(args) {
|
|
|
24491
24557
|
if (args.rest[0] === "login") {
|
|
24492
24558
|
const rest = args.rest.slice(1);
|
|
24493
24559
|
let app;
|
|
24560
|
+
let profileId;
|
|
24494
24561
|
while (rest.length > 0) {
|
|
24495
24562
|
const token = rest.shift();
|
|
24496
24563
|
switch (token) {
|
|
24497
24564
|
case "--app":
|
|
24498
24565
|
app = requireValue13(rest, token);
|
|
24499
24566
|
break;
|
|
24567
|
+
case "--profile-id":
|
|
24568
|
+
profileId = requireValue13(rest, token);
|
|
24569
|
+
break;
|
|
24500
24570
|
default:
|
|
24501
24571
|
throw new Error(`Unknown login option: ${token}`);
|
|
24502
24572
|
}
|
|
24503
24573
|
}
|
|
24504
|
-
return { type: "login" /* Login */, app };
|
|
24574
|
+
return { type: "login" /* Login */, app, profileId };
|
|
24505
24575
|
}
|
|
24506
24576
|
if (args.rest[0] === "add-dns") {
|
|
24507
24577
|
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.23",
|
|
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
|
+
}
|