@pmate/cli 0.30.1 → 0.30.2
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.js +201 -180
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -88,7 +88,7 @@ var init_namespacedRef = __esm({
|
|
|
88
88
|
|
|
89
89
|
// src/sessionStore.ts
|
|
90
90
|
function buildSessionStorePath() {
|
|
91
|
-
return process.env.PMATE_SESSION_FILE?.trim() ||
|
|
91
|
+
return process.env.PMATE_SESSION_FILE?.trim() || import_node_path5.default.join(import_node_os4.default.homedir(), ".pmate", "session.json");
|
|
92
92
|
}
|
|
93
93
|
function assertValidAppRef(appRef2) {
|
|
94
94
|
return parseNamespacedRef(appRef2, { entityLabel: "app ref" }).fullId;
|
|
@@ -265,7 +265,7 @@ function resolveReadApp(store, options) {
|
|
|
265
265
|
}
|
|
266
266
|
function writeSessionStore(store) {
|
|
267
267
|
const sessionPath = buildSessionStorePath();
|
|
268
|
-
(0, import_node_fs4.mkdirSync)(
|
|
268
|
+
(0, import_node_fs4.mkdirSync)(import_node_path5.default.dirname(sessionPath), { recursive: true });
|
|
269
269
|
(0, import_node_fs4.writeFileSync)(sessionPath, JSON.stringify(store, null, 2), {
|
|
270
270
|
mode: 384
|
|
271
271
|
});
|
|
@@ -280,13 +280,13 @@ function buildMissingSessionMessage(sessionPath, app) {
|
|
|
280
280
|
}
|
|
281
281
|
return `Missing session for app ${app} in ${sessionPath}. Run "pmate login --app ${app}" first.`;
|
|
282
282
|
}
|
|
283
|
-
var import_node_fs4,
|
|
283
|
+
var import_node_fs4, import_node_os4, import_node_path5, DEFAULT_APP_ID, SESSION_STORE_VERSION;
|
|
284
284
|
var init_sessionStore = __esm({
|
|
285
285
|
"src/sessionStore.ts"() {
|
|
286
286
|
"use strict";
|
|
287
287
|
import_node_fs4 = require("fs");
|
|
288
|
-
|
|
289
|
-
|
|
288
|
+
import_node_os4 = __toESM(require("os"));
|
|
289
|
+
import_node_path5 = __toESM(require("path"));
|
|
290
290
|
init_namespacedRef();
|
|
291
291
|
DEFAULT_APP_ID = "pmate:factory";
|
|
292
292
|
SESSION_STORE_VERSION = 4;
|
|
@@ -8819,11 +8819,32 @@ __export(index_exports, {
|
|
|
8819
8819
|
});
|
|
8820
8820
|
module.exports = __toCommonJS(index_exports);
|
|
8821
8821
|
var import_node_fs26 = require("fs");
|
|
8822
|
-
var
|
|
8822
|
+
var import_node_path31 = __toESM(require("path"));
|
|
8823
8823
|
|
|
8824
8824
|
// src/managedSession.ts
|
|
8825
8825
|
var import_node_fs = require("fs");
|
|
8826
|
+
var import_node_os = require("os");
|
|
8827
|
+
var import_node_path = require("path");
|
|
8826
8828
|
async function ensureManagedSession(env = process.env, fetcher = fetch) {
|
|
8829
|
+
if (env.HEBO_MEMORY_TOKEN?.trim()) {
|
|
8830
|
+
const token = env.HEBO_MEMORY_TOKEN.trim(), app = "pmate:factory";
|
|
8831
|
+
const base = (env.AUTH_API_BASE_URL ?? "https://auth-api-v2.pmate.chat").replace(/\/+$/, "");
|
|
8832
|
+
const headers = { authorization: `Bearer ${token}` };
|
|
8833
|
+
const r2 = await fetcher(`${base}/session?app=${encodeURIComponent(app)}`, { headers, signal: AbortSignal.timeout(15e3) });
|
|
8834
|
+
const body = await r2.json(), session = body.data;
|
|
8835
|
+
if (!r2.ok || !body.success || session?.identity?.app !== app || !session.identity.accountId || !session.issuedAt || !Number.isFinite(Date.parse(session.expiresAt)) || Date.parse(session.expiresAt) <= Date.now()) throw Error("Delegated user session is invalid or expired");
|
|
8836
|
+
const pr = await fetcher(`${base}/profiles?app=${encodeURIComponent(app)}&account=${encodeURIComponent(session.identity.accountId)}`, { headers, signal: AbortSignal.timeout(15e3) });
|
|
8837
|
+
const profiles = await pr.json(), profileId = profiles.data?.[0]?.id;
|
|
8838
|
+
if (!pr.ok || !profiles.success || !profileId) throw Error("Delegated user profile unavailable");
|
|
8839
|
+
const dir = (0, import_node_fs.mkdtempSync)((0, import_node_path.join)((0, import_node_os.tmpdir)(), "pmate-delegated-")), file = (0, import_node_path.join)(dir, "session.json");
|
|
8840
|
+
(0, import_node_fs.writeFileSync)(file, JSON.stringify({ version: 4, activeAppRef: app, sessions: { [app]: { token, accountId: session.identity.accountId, profileId, issuedAt: session.issuedAt, expiresAt: session.expiresAt, updatedAt: (/* @__PURE__ */ new Date()).toISOString() } } }), { mode: 384 });
|
|
8841
|
+
env.PMATE_SESSION_FILE = file;
|
|
8842
|
+
env.PCS_AGENT_SESSION_MANAGED = "0";
|
|
8843
|
+
process.once("exit", () => {
|
|
8844
|
+
(0, import_node_fs.rmSync)(dir, { recursive: true, force: true });
|
|
8845
|
+
});
|
|
8846
|
+
return;
|
|
8847
|
+
}
|
|
8827
8848
|
if (env.PCS_AGENT_SESSION_MANAGED !== "1") return;
|
|
8828
8849
|
if (!env.PMATE_SESSION_FILE) throw Error("Managed session file is required");
|
|
8829
8850
|
const state = JSON.parse((0, import_node_fs.readFileSync)(env.PMATE_SESSION_FILE, "utf8"));
|
|
@@ -8881,12 +8902,12 @@ var ui = {
|
|
|
8881
8902
|
};
|
|
8882
8903
|
|
|
8883
8904
|
// src/commands/ListCommandHandler.ts
|
|
8884
|
-
var
|
|
8905
|
+
var import_node_path3 = __toESM(require("path"));
|
|
8885
8906
|
|
|
8886
8907
|
// src/config.ts
|
|
8887
8908
|
var import_node_fs2 = require("fs");
|
|
8888
|
-
var
|
|
8889
|
-
var
|
|
8909
|
+
var import_node_os2 = __toESM(require("os"));
|
|
8910
|
+
var import_node_path2 = __toESM(require("path"));
|
|
8890
8911
|
var import_ajv = __toESM(require("ajv"));
|
|
8891
8912
|
var import_yaml = __toESM(require("yaml"));
|
|
8892
8913
|
var cachedConfig;
|
|
@@ -9010,8 +9031,8 @@ function loadPmateConfig() {
|
|
|
9010
9031
|
if (cachedConfig !== void 0) {
|
|
9011
9032
|
return cachedConfig ?? {};
|
|
9012
9033
|
}
|
|
9013
|
-
const pmateDir =
|
|
9014
|
-
const yamlPath =
|
|
9034
|
+
const pmateDir = import_node_path2.default.join(import_node_os2.default.homedir(), ".pmate");
|
|
9035
|
+
const yamlPath = import_node_path2.default.join(pmateDir, "config.yaml");
|
|
9015
9036
|
let yamlConfig = null;
|
|
9016
9037
|
if ((0, import_node_fs2.existsSync)(yamlPath)) {
|
|
9017
9038
|
const raw = (0, import_node_fs2.readFileSync)(yamlPath, "utf8");
|
|
@@ -9076,11 +9097,11 @@ ${detail}`);
|
|
|
9076
9097
|
return value;
|
|
9077
9098
|
}
|
|
9078
9099
|
function findRepoConfigPaths(cwd, searchParents) {
|
|
9079
|
-
let current =
|
|
9100
|
+
let current = import_node_path2.default.resolve(cwd);
|
|
9080
9101
|
while (true) {
|
|
9081
|
-
const candidate =
|
|
9102
|
+
const candidate = import_node_path2.default.join(current, ".pmate.yaml");
|
|
9082
9103
|
if ((0, import_node_fs2.existsSync)(candidate)) {
|
|
9083
|
-
const localCandidate =
|
|
9104
|
+
const localCandidate = import_node_path2.default.join(current, ".pmate.local.yaml");
|
|
9084
9105
|
return {
|
|
9085
9106
|
rootDir: current,
|
|
9086
9107
|
configPath: candidate,
|
|
@@ -9090,7 +9111,7 @@ function findRepoConfigPaths(cwd, searchParents) {
|
|
|
9090
9111
|
if (!searchParents) {
|
|
9091
9112
|
return null;
|
|
9092
9113
|
}
|
|
9093
|
-
const parent =
|
|
9114
|
+
const parent = import_node_path2.default.dirname(current);
|
|
9094
9115
|
if (parent === current) {
|
|
9095
9116
|
return null;
|
|
9096
9117
|
}
|
|
@@ -9261,7 +9282,7 @@ var ListCommandHandler = class {
|
|
|
9261
9282
|
}
|
|
9262
9283
|
}
|
|
9263
9284
|
resolveTargetDir(targetPath) {
|
|
9264
|
-
return targetPath ?
|
|
9285
|
+
return targetPath ? import_node_path3.default.resolve(process.cwd(), targetPath) : process.cwd();
|
|
9265
9286
|
}
|
|
9266
9287
|
loadConfig(targetDir) {
|
|
9267
9288
|
return loadAppConfig(targetDir).config;
|
|
@@ -9270,14 +9291,14 @@ var ListCommandHandler = class {
|
|
|
9270
9291
|
|
|
9271
9292
|
// src/commands/LoginCommandHandler.ts
|
|
9272
9293
|
var import_node_child_process = require("child_process");
|
|
9273
|
-
var
|
|
9294
|
+
var import_node_path6 = __toESM(require("path"));
|
|
9274
9295
|
var import_node_http = require("http");
|
|
9275
9296
|
var import_promises = require("readline/promises");
|
|
9276
9297
|
|
|
9277
9298
|
// src/accessKeyFile.ts
|
|
9278
9299
|
var import_node_fs3 = require("fs");
|
|
9279
|
-
var
|
|
9280
|
-
var
|
|
9300
|
+
var import_node_os3 = __toESM(require("os"));
|
|
9301
|
+
var import_node_path4 = __toESM(require("path"));
|
|
9281
9302
|
function readAccessKeyFile(filePath, options = {}) {
|
|
9282
9303
|
const absolutePath = resolveFilePath(filePath, options.cwd);
|
|
9283
9304
|
if (!(0, import_node_fs3.existsSync)(absolutePath)) {
|
|
@@ -9305,7 +9326,7 @@ function scanAccessKeyFiles(app) {
|
|
|
9305
9326
|
if (!(0, import_node_fs3.existsSync)(dir)) {
|
|
9306
9327
|
return [];
|
|
9307
9328
|
}
|
|
9308
|
-
return (0, import_node_fs3.readdirSync)(dir, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".access-key.json")).map((entry) =>
|
|
9329
|
+
return (0, import_node_fs3.readdirSync)(dir, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".access-key.json")).map((entry) => import_node_path4.default.join(dir, entry.name)).flatMap((filePath) => {
|
|
9309
9330
|
try {
|
|
9310
9331
|
return [{ filePath, key: readAccessKeyFile(filePath, { expectedApp: app }) }];
|
|
9311
9332
|
} catch {
|
|
@@ -9314,13 +9335,13 @@ function scanAccessKeyFiles(app) {
|
|
|
9314
9335
|
}).sort((a, b) => a.key.name.localeCompare(b.key.name) || a.filePath.localeCompare(b.filePath));
|
|
9315
9336
|
}
|
|
9316
9337
|
function resolveAccessKeyDir(app) {
|
|
9317
|
-
return
|
|
9338
|
+
return import_node_path4.default.join(homeDir(), ".pmate", "access-keys", app);
|
|
9318
9339
|
}
|
|
9319
9340
|
function resolveFilePath(filePath, cwd = process.cwd()) {
|
|
9320
|
-
return
|
|
9341
|
+
return import_node_path4.default.isAbsolute(filePath) ? filePath : import_node_path4.default.resolve(cwd, filePath);
|
|
9321
9342
|
}
|
|
9322
9343
|
function homeDir() {
|
|
9323
|
-
return process.env.HOME || process.env.USERPROFILE ||
|
|
9344
|
+
return process.env.HOME || process.env.USERPROFILE || import_node_os3.default.homedir() || process.cwd();
|
|
9324
9345
|
}
|
|
9325
9346
|
function isAccessKeyFile(value) {
|
|
9326
9347
|
if (!value || typeof value !== "object") {
|
|
@@ -9608,7 +9629,7 @@ var LoginCommandHandler = class {
|
|
|
9608
9629
|
key.id?.trim(),
|
|
9609
9630
|
key.namespace?.trim(),
|
|
9610
9631
|
`expires ${key.expiresAt}`,
|
|
9611
|
-
|
|
9632
|
+
import_node_path6.default.relative(process.cwd(), candidate.filePath)
|
|
9612
9633
|
].filter(Boolean);
|
|
9613
9634
|
return parts.join(" / ");
|
|
9614
9635
|
}
|
|
@@ -9828,7 +9849,7 @@ var import_sts20150401 = __toESM(require("@alicloud/sts20150401"));
|
|
|
9828
9849
|
var import_ali_oss = __toESM(require("ali-oss"));
|
|
9829
9850
|
var import_node_crypto = require("crypto");
|
|
9830
9851
|
var import_node_fs5 = require("fs");
|
|
9831
|
-
var
|
|
9852
|
+
var import_node_path7 = __toESM(require("path"));
|
|
9832
9853
|
|
|
9833
9854
|
// src/certs.ts
|
|
9834
9855
|
var DEFAULT_SSL_CERT_KEY = "pmate-01";
|
|
@@ -10121,7 +10142,7 @@ var AliyunService = class {
|
|
|
10121
10142
|
])
|
|
10122
10143
|
);
|
|
10123
10144
|
for (const filePath of files) {
|
|
10124
|
-
const relativePath =
|
|
10145
|
+
const relativePath = import_node_path7.default.relative(localDir, filePath);
|
|
10125
10146
|
const objectKey = this.toObjectKey(normalizedPrefix, relativePath);
|
|
10126
10147
|
const contentType = this.getContentType(filePath);
|
|
10127
10148
|
const cacheControl = this.getStaticAssetCacheControl(relativePath);
|
|
@@ -10506,7 +10527,7 @@ var AliyunService = class {
|
|
|
10506
10527
|
const entries = await import_node_fs5.promises.readdir(dir, { withFileTypes: true });
|
|
10507
10528
|
const files = [];
|
|
10508
10529
|
for (const entry of entries) {
|
|
10509
|
-
const fullPath =
|
|
10530
|
+
const fullPath = import_node_path7.default.join(dir, entry.name);
|
|
10510
10531
|
if (entry.isDirectory()) {
|
|
10511
10532
|
files.push(...await this.collectFiles(fullPath));
|
|
10512
10533
|
} else if (entry.isFile()) {
|
|
@@ -10568,17 +10589,17 @@ var AliyunService = class {
|
|
|
10568
10589
|
});
|
|
10569
10590
|
}
|
|
10570
10591
|
static toObjectKey(prefix, relativePath) {
|
|
10571
|
-
const normalizedPath = relativePath.split(
|
|
10592
|
+
const normalizedPath = relativePath.split(import_node_path7.default.sep).join("/");
|
|
10572
10593
|
if (!prefix) {
|
|
10573
10594
|
return normalizedPath;
|
|
10574
10595
|
}
|
|
10575
10596
|
return `${prefix}/${normalizedPath}`;
|
|
10576
10597
|
}
|
|
10577
10598
|
static getContentType(filePath) {
|
|
10578
|
-
if (
|
|
10599
|
+
if (import_node_path7.default.basename(filePath).toLowerCase() === "apple-app-site-association") {
|
|
10579
10600
|
return "application/json";
|
|
10580
10601
|
}
|
|
10581
|
-
const ext =
|
|
10602
|
+
const ext = import_node_path7.default.extname(filePath).toLowerCase();
|
|
10582
10603
|
switch (ext) {
|
|
10583
10604
|
case ".html":
|
|
10584
10605
|
return "text/html";
|
|
@@ -10621,7 +10642,7 @@ var AliyunService = class {
|
|
|
10621
10642
|
}
|
|
10622
10643
|
static getStaticAssetCacheControl(filePath) {
|
|
10623
10644
|
const normalized = filePath.replace(/\\/g, "/");
|
|
10624
|
-
const base =
|
|
10645
|
+
const base = import_node_path7.default.posix.basename(normalized).toLowerCase();
|
|
10625
10646
|
if (base === "index.html" || base === "200.html" || base === "404.html" || base === "latest.json" || base === "apple-app-site-association") {
|
|
10626
10647
|
return "no-cache, no-store, must-revalidate";
|
|
10627
10648
|
}
|
|
@@ -10838,7 +10859,7 @@ var BucketCommandHandler = class {
|
|
|
10838
10859
|
};
|
|
10839
10860
|
|
|
10840
10861
|
// src/commands/DeleteCommandHandler.ts
|
|
10841
|
-
var
|
|
10862
|
+
var import_node_path8 = __toESM(require("path"));
|
|
10842
10863
|
var import_node_child_process2 = require("child_process");
|
|
10843
10864
|
|
|
10844
10865
|
// src/serverAddress.ts
|
|
@@ -10996,17 +11017,17 @@ var DeleteCommandHandler = class {
|
|
|
10996
11017
|
});
|
|
10997
11018
|
}
|
|
10998
11019
|
resolveCwd(target) {
|
|
10999
|
-
return target ?
|
|
11020
|
+
return target ? import_node_path8.default.resolve(process.cwd(), target) : process.cwd();
|
|
11000
11021
|
}
|
|
11001
11022
|
};
|
|
11002
11023
|
|
|
11003
11024
|
// src/commands/DevCommandHandler.ts
|
|
11004
11025
|
var import_node_fs6 = require("fs");
|
|
11005
|
-
var
|
|
11026
|
+
var import_node_path10 = __toESM(require("path"));
|
|
11006
11027
|
var import_node_child_process3 = require("child_process");
|
|
11007
11028
|
|
|
11008
11029
|
// src/appDir.ts
|
|
11009
|
-
var
|
|
11030
|
+
var import_node_path9 = __toESM(require("path"));
|
|
11010
11031
|
function normalizeRelativeDir(input, appName) {
|
|
11011
11032
|
if (typeof input !== "string") {
|
|
11012
11033
|
throw new Error(`Missing dir for ${appName} in .pmate.yaml`);
|
|
@@ -11019,7 +11040,7 @@ function normalizeRelativeDir(input, appName) {
|
|
|
11019
11040
|
if (unixLike.startsWith("/")) {
|
|
11020
11041
|
throw new Error(`Invalid dir for ${appName} in .pmate.yaml: must be relative`);
|
|
11021
11042
|
}
|
|
11022
|
-
const normalized =
|
|
11043
|
+
const normalized = import_node_path9.default.posix.normalize(unixLike);
|
|
11023
11044
|
if (normalized.startsWith("../") || normalized === "..") {
|
|
11024
11045
|
throw new Error(
|
|
11025
11046
|
`Invalid dir for ${appName} in .pmate.yaml: must stay within repo`
|
|
@@ -11029,7 +11050,7 @@ function normalizeRelativeDir(input, appName) {
|
|
|
11029
11050
|
}
|
|
11030
11051
|
function resolveLocalAppDir(repoRoot, appName, dir) {
|
|
11031
11052
|
const relative = normalizeRelativeDir(dir, appName);
|
|
11032
|
-
return
|
|
11053
|
+
return import_node_path9.default.resolve(repoRoot, relative);
|
|
11033
11054
|
}
|
|
11034
11055
|
function resolveRemoteAppDir(appName, dir) {
|
|
11035
11056
|
return normalizeRelativeDir(dir, appName);
|
|
@@ -11052,7 +11073,7 @@ var DevCommandHandler = class {
|
|
|
11052
11073
|
);
|
|
11053
11074
|
}
|
|
11054
11075
|
const appDir = resolveLocalAppDir(cwd, appName, appConfig.dir);
|
|
11055
|
-
const packageJsonPath =
|
|
11076
|
+
const packageJsonPath = import_node_path10.default.join(appDir, "package.json");
|
|
11056
11077
|
if (!(0, import_node_fs6.existsSync)(packageJsonPath)) {
|
|
11057
11078
|
throw new Error(`No package.json found at ${packageJsonPath}`);
|
|
11058
11079
|
}
|
|
@@ -11067,7 +11088,7 @@ var DevCommandHandler = class {
|
|
|
11067
11088
|
await this.runCommand("pnpm", ["--filter", pkgName, "run", "dev"], cwd);
|
|
11068
11089
|
}
|
|
11069
11090
|
resolveCwd(target) {
|
|
11070
|
-
return target ?
|
|
11091
|
+
return target ? import_node_path10.default.resolve(process.cwd(), target) : process.cwd();
|
|
11071
11092
|
}
|
|
11072
11093
|
loadConfig(cwd) {
|
|
11073
11094
|
return loadAppConfig(cwd);
|
|
@@ -11102,7 +11123,7 @@ var DevCommandHandler = class {
|
|
|
11102
11123
|
|
|
11103
11124
|
// src/commands/OssCommandHandler.ts
|
|
11104
11125
|
var import_node_fs7 = require("fs");
|
|
11105
|
-
var
|
|
11126
|
+
var import_node_path11 = __toESM(require("path"));
|
|
11106
11127
|
var PARROT_STATIC_PUBLIC_BASE_URL = "https://parrot-static.pmate.chat";
|
|
11107
11128
|
var OssCommandHandler = class _OssCommandHandler {
|
|
11108
11129
|
static {
|
|
@@ -11120,7 +11141,7 @@ var OssCommandHandler = class _OssCommandHandler {
|
|
|
11120
11141
|
}
|
|
11121
11142
|
return;
|
|
11122
11143
|
}
|
|
11123
|
-
const resolvedFile =
|
|
11144
|
+
const resolvedFile = import_node_path11.default.resolve(process.cwd(), args.filePath);
|
|
11124
11145
|
this.assertFile(resolvedFile);
|
|
11125
11146
|
const objectKey = this.normalizeObjectKey(args.objectKey);
|
|
11126
11147
|
const bucket = this.resolveBucket(args.bucket);
|
|
@@ -11161,7 +11182,7 @@ function buildOssPublicUrl(bucket, objectKey) {
|
|
|
11161
11182
|
}
|
|
11162
11183
|
|
|
11163
11184
|
// src/commands/EnvCommandHandler.ts
|
|
11164
|
-
var
|
|
11185
|
+
var import_node_path12 = __toESM(require("path"));
|
|
11165
11186
|
var import_node_child_process4 = require("child_process");
|
|
11166
11187
|
|
|
11167
11188
|
// src/shell.ts
|
|
@@ -11245,8 +11266,8 @@ var EnvCommandHandler = class {
|
|
|
11245
11266
|
ui.success(`Set ${envKey} in .env.local`, appName);
|
|
11246
11267
|
}
|
|
11247
11268
|
async listEnvKeys(server, repoDir, appDir, verbose) {
|
|
11248
|
-
const envLocalPath =
|
|
11249
|
-
const envPath =
|
|
11269
|
+
const envLocalPath = import_node_path12.default.posix.join(appDir, ".env.local");
|
|
11270
|
+
const envPath = import_node_path12.default.posix.join(appDir, ".env");
|
|
11250
11271
|
if (verbose) {
|
|
11251
11272
|
const repoPath = `$HOME/${repoDir}`;
|
|
11252
11273
|
ui.info("Env list target", {
|
|
@@ -11339,8 +11360,8 @@ var EnvCommandHandler = class {
|
|
|
11339
11360
|
}
|
|
11340
11361
|
}
|
|
11341
11362
|
async appendEnvLine(server, repoDir, appDir, envKey, envLine, verbose) {
|
|
11342
|
-
const envLocalPath =
|
|
11343
|
-
const envPath =
|
|
11363
|
+
const envLocalPath = import_node_path12.default.posix.join(appDir, ".env.local");
|
|
11364
|
+
const envPath = import_node_path12.default.posix.join(appDir, ".env");
|
|
11344
11365
|
if (verbose) {
|
|
11345
11366
|
const repoPath = `$HOME/${repoDir}`;
|
|
11346
11367
|
ui.info("Env add target", {
|
|
@@ -11388,8 +11409,8 @@ var EnvCommandHandler = class {
|
|
|
11388
11409
|
await this.runRemoteCommand(server, command);
|
|
11389
11410
|
}
|
|
11390
11411
|
async deleteEnvKey(server, repoDir, appDir, envKey, verbose) {
|
|
11391
|
-
const envLocalPath =
|
|
11392
|
-
const envPath =
|
|
11412
|
+
const envLocalPath = import_node_path12.default.posix.join(appDir, ".env.local");
|
|
11413
|
+
const envPath = import_node_path12.default.posix.join(appDir, ".env");
|
|
11393
11414
|
if (verbose) {
|
|
11394
11415
|
const repoPath = `$HOME/${repoDir}`;
|
|
11395
11416
|
ui.info("Env delete target", {
|
|
@@ -12157,7 +12178,7 @@ var CommitCommandHandler = class {
|
|
|
12157
12178
|
|
|
12158
12179
|
// src/commands/SummaryCommandHandler.ts
|
|
12159
12180
|
var import_node_child_process6 = require("child_process");
|
|
12160
|
-
var
|
|
12181
|
+
var import_node_path13 = __toESM(require("path"));
|
|
12161
12182
|
var SummaryCommandHandler = class {
|
|
12162
12183
|
async handle(args) {
|
|
12163
12184
|
const cwd = this.resolveCwd(args.cwd);
|
|
@@ -12342,7 +12363,7 @@ var SummaryCommandHandler = class {
|
|
|
12342
12363
|
return this.runCapture("gh", args, allowFailure, await this.getGhEnv(cwd), cwd);
|
|
12343
12364
|
}
|
|
12344
12365
|
resolveCwd(value) {
|
|
12345
|
-
return value ?
|
|
12366
|
+
return value ? import_node_path13.default.resolve(process.cwd(), value) : process.cwd();
|
|
12346
12367
|
}
|
|
12347
12368
|
};
|
|
12348
12369
|
function truncate2(value, limit) {
|
|
@@ -12356,8 +12377,8 @@ function truncate2(value, limit) {
|
|
|
12356
12377
|
// src/commands/LinearCommandHandler.ts
|
|
12357
12378
|
var import_node_child_process7 = require("child_process");
|
|
12358
12379
|
var import_node_fs8 = require("fs");
|
|
12359
|
-
var
|
|
12360
|
-
var
|
|
12380
|
+
var import_node_os5 = __toESM(require("os"));
|
|
12381
|
+
var import_node_path14 = __toESM(require("path"));
|
|
12361
12382
|
var import_promises3 = require("readline/promises");
|
|
12362
12383
|
var import_openai = __toESM(require("openai"));
|
|
12363
12384
|
var import_sdk = require("@linear/sdk");
|
|
@@ -13241,7 +13262,7 @@ var LinearCommandHandler = class {
|
|
|
13241
13262
|
}
|
|
13242
13263
|
}
|
|
13243
13264
|
getLinearSelectionPath() {
|
|
13244
|
-
return
|
|
13265
|
+
return import_node_path14.default.join(import_node_os5.default.homedir(), ".pmate", "linear-selection.json");
|
|
13245
13266
|
}
|
|
13246
13267
|
readCachedLinearSelection(cwd) {
|
|
13247
13268
|
const selectionPath = this.getLinearSelectionPath();
|
|
@@ -13260,7 +13281,7 @@ var LinearCommandHandler = class {
|
|
|
13260
13281
|
}
|
|
13261
13282
|
writeCachedLinearSelection(cwd, title) {
|
|
13262
13283
|
const selectionPath = this.getLinearSelectionPath();
|
|
13263
|
-
const dir =
|
|
13284
|
+
const dir = import_node_path14.default.dirname(selectionPath);
|
|
13264
13285
|
(0, import_node_fs8.mkdirSync)(dir, { recursive: true });
|
|
13265
13286
|
let data = {};
|
|
13266
13287
|
if ((0, import_node_fs8.existsSync)(selectionPath)) {
|
|
@@ -13451,8 +13472,8 @@ var LinearCommandHandler = class {
|
|
|
13451
13472
|
if (process.platform !== "darwin") {
|
|
13452
13473
|
throw new Error("Screenshot capture only supports macOS.");
|
|
13453
13474
|
}
|
|
13454
|
-
const dir = await import_node_fs8.promises.mkdtemp(
|
|
13455
|
-
const filePath =
|
|
13475
|
+
const dir = await import_node_fs8.promises.mkdtemp(import_node_path14.default.join(import_node_os5.default.tmpdir(), "pmate-screenshot-"));
|
|
13476
|
+
const filePath = import_node_path14.default.join(dir, `screenshot-${index}.png`);
|
|
13456
13477
|
try {
|
|
13457
13478
|
const code = await this.run("screencapture", ["-i", "-x", filePath], true);
|
|
13458
13479
|
if (code !== 0) {
|
|
@@ -13614,9 +13635,9 @@ var LinearCommandHandler = class {
|
|
|
13614
13635
|
return compact.length > limit ? `${compact.slice(0, limit)}...` : compact;
|
|
13615
13636
|
}
|
|
13616
13637
|
async convertToPng(buffer, ext) {
|
|
13617
|
-
const dir = await import_node_fs8.promises.mkdtemp(
|
|
13618
|
-
const inputPath =
|
|
13619
|
-
const outputPath =
|
|
13638
|
+
const dir = await import_node_fs8.promises.mkdtemp(import_node_path14.default.join(import_node_os5.default.tmpdir(), "pmate-"));
|
|
13639
|
+
const inputPath = import_node_path14.default.join(dir, `clipboard.${ext}`);
|
|
13640
|
+
const outputPath = import_node_path14.default.join(dir, "clipboard.png");
|
|
13620
13641
|
try {
|
|
13621
13642
|
await import_node_fs8.promises.writeFile(inputPath, buffer);
|
|
13622
13643
|
const stderr = await this.runCapture(
|
|
@@ -13927,7 +13948,7 @@ var LinearCommandHandler = class {
|
|
|
13927
13948
|
return this.runCapture("gh", args, allowFailure, await this.getGhEnv(cwd), cwd);
|
|
13928
13949
|
}
|
|
13929
13950
|
resolveCwd(value) {
|
|
13930
|
-
return value ?
|
|
13951
|
+
return value ? import_node_path14.default.resolve(process.cwd(), value) : process.cwd();
|
|
13931
13952
|
}
|
|
13932
13953
|
createOpenAiClient() {
|
|
13933
13954
|
const config = loadPmateConfig();
|
|
@@ -13980,7 +14001,7 @@ function sleep2(ms) {
|
|
|
13980
14001
|
|
|
13981
14002
|
// src/commands/NotionCommandHandler.ts
|
|
13982
14003
|
var import_node_fs9 = require("fs");
|
|
13983
|
-
var
|
|
14004
|
+
var import_node_path15 = __toESM(require("path"));
|
|
13984
14005
|
|
|
13985
14006
|
// src/services/NotionService.ts
|
|
13986
14007
|
var NotionService = class {
|
|
@@ -14319,7 +14340,7 @@ var NotionCommandHandler = class {
|
|
|
14319
14340
|
if (!args.filePath) {
|
|
14320
14341
|
return "";
|
|
14321
14342
|
}
|
|
14322
|
-
const resolved =
|
|
14343
|
+
const resolved = import_node_path15.default.resolve(process.cwd(), args.filePath);
|
|
14323
14344
|
return (0, import_node_fs9.readFileSync)(resolved, "utf8");
|
|
14324
14345
|
}
|
|
14325
14346
|
};
|
|
@@ -14327,8 +14348,8 @@ var NotionCommandHandler = class {
|
|
|
14327
14348
|
// src/commands/QrcodeCommandHandler.ts
|
|
14328
14349
|
var import_node_child_process8 = require("child_process");
|
|
14329
14350
|
var import_node_fs10 = require("fs");
|
|
14330
|
-
var
|
|
14331
|
-
var
|
|
14351
|
+
var import_node_os6 = __toESM(require("os"));
|
|
14352
|
+
var import_node_path16 = __toESM(require("path"));
|
|
14332
14353
|
var import_promises4 = require("readline/promises");
|
|
14333
14354
|
var import_jsqr = __toESM(require("jsqr"));
|
|
14334
14355
|
var import_pngjs = require("pngjs");
|
|
@@ -14370,8 +14391,8 @@ var QrcodeCommandHandler = class {
|
|
|
14370
14391
|
} finally {
|
|
14371
14392
|
rl.close();
|
|
14372
14393
|
}
|
|
14373
|
-
const dir = await import_node_fs10.promises.mkdtemp(
|
|
14374
|
-
const filePath =
|
|
14394
|
+
const dir = await import_node_fs10.promises.mkdtemp(import_node_path16.default.join(import_node_os6.default.tmpdir(), "pmate-qrcode-"));
|
|
14395
|
+
const filePath = import_node_path16.default.join(dir, "qrcode.png");
|
|
14375
14396
|
const code = await this.run("screencapture", ["-i", "-x", filePath], true);
|
|
14376
14397
|
if (code !== 0) {
|
|
14377
14398
|
throw new Error("Screenshot capture canceled or failed.");
|
|
@@ -14651,7 +14672,7 @@ function clampNumber(value, min, max, fallback) {
|
|
|
14651
14672
|
|
|
14652
14673
|
// src/commands/QuizCommandHandler.ts
|
|
14653
14674
|
var import_node_fs11 = require("fs");
|
|
14654
|
-
var
|
|
14675
|
+
var import_node_path17 = __toESM(require("path"));
|
|
14655
14676
|
init_sessionStore();
|
|
14656
14677
|
|
|
14657
14678
|
// src/services/QuizService.ts
|
|
@@ -15196,7 +15217,7 @@ var QuizCommandHandler = class {
|
|
|
15196
15217
|
return;
|
|
15197
15218
|
}
|
|
15198
15219
|
if (args.action === "update-meta") {
|
|
15199
|
-
const resolvedFilePath =
|
|
15220
|
+
const resolvedFilePath = import_node_path17.default.resolve(process.cwd(), args.filePath);
|
|
15200
15221
|
const metadata = JSON.parse((0, import_node_fs11.readFileSync)(resolvedFilePath, "utf8"));
|
|
15201
15222
|
const result = await updateQuizPaperMetadata({
|
|
15202
15223
|
apiBaseUrl,
|
|
@@ -15209,7 +15230,7 @@ var QuizCommandHandler = class {
|
|
|
15209
15230
|
return;
|
|
15210
15231
|
}
|
|
15211
15232
|
if (args.action === "append-step") {
|
|
15212
|
-
const resolvedFilePath =
|
|
15233
|
+
const resolvedFilePath = import_node_path17.default.resolve(process.cwd(), args.filePath);
|
|
15213
15234
|
const step = JSON.parse((0, import_node_fs11.readFileSync)(resolvedFilePath, "utf8"));
|
|
15214
15235
|
const result = await appendQuizPaperStep({
|
|
15215
15236
|
apiBaseUrl,
|
|
@@ -15223,7 +15244,7 @@ var QuizCommandHandler = class {
|
|
|
15223
15244
|
return;
|
|
15224
15245
|
}
|
|
15225
15246
|
if (args.action === "update-step") {
|
|
15226
|
-
const resolvedFilePath =
|
|
15247
|
+
const resolvedFilePath = import_node_path17.default.resolve(process.cwd(), args.filePath);
|
|
15227
15248
|
const step = JSON.parse((0, import_node_fs11.readFileSync)(resolvedFilePath, "utf8"));
|
|
15228
15249
|
step.stepId = args.stepId;
|
|
15229
15250
|
const result = await updateQuizPaperStep({
|
|
@@ -15287,7 +15308,7 @@ var QuizCommandHandler = class {
|
|
|
15287
15308
|
if (targetIndex < 0) {
|
|
15288
15309
|
throw new Error(`\u672A\u627E\u5230 stepId=${args.stepId}\uFF0C\u65E0\u6CD5\u66F4\u65B0\u8BE5\u9898\u76EE\u3002`);
|
|
15289
15310
|
}
|
|
15290
|
-
const resolvedFilePath =
|
|
15311
|
+
const resolvedFilePath = import_node_path17.default.resolve(process.cwd(), args.filePath);
|
|
15291
15312
|
const nextStep = JSON.parse((0, import_node_fs11.readFileSync)(resolvedFilePath, "utf8"));
|
|
15292
15313
|
nextStep.stepId = args.stepId;
|
|
15293
15314
|
const nextSteps = [...basePaper.steps];
|
|
@@ -15339,8 +15360,8 @@ var QuizCommandHandler = class {
|
|
|
15339
15360
|
|
|
15340
15361
|
// src/commands/CollectCommandHandler.ts
|
|
15341
15362
|
var import_node_fs13 = require("fs");
|
|
15342
|
-
var
|
|
15343
|
-
var
|
|
15363
|
+
var import_node_os8 = __toESM(require("os"));
|
|
15364
|
+
var import_node_path19 = __toESM(require("path"));
|
|
15344
15365
|
var import_playwright = require("playwright");
|
|
15345
15366
|
|
|
15346
15367
|
// src/im1BotClient.ts
|
|
@@ -15425,12 +15446,12 @@ var Im1BotClient = class {
|
|
|
15425
15446
|
// src/collectStore.ts
|
|
15426
15447
|
var import_node_crypto3 = require("crypto");
|
|
15427
15448
|
var import_node_fs12 = require("fs");
|
|
15428
|
-
var
|
|
15429
|
-
var
|
|
15449
|
+
var import_node_os7 = __toESM(require("os"));
|
|
15450
|
+
var import_node_path18 = __toESM(require("path"));
|
|
15430
15451
|
function resolveCollectTarget(input) {
|
|
15431
15452
|
const endpoint = input.endpoint ?? (input.source === "cc" ? "http://localhost:9223" : "http://localhost:9222");
|
|
15432
15453
|
const sourceKey = input.source ?? `endpoint-${(0, import_node_crypto3.createHash)("sha1").update(endpoint).digest("hex").slice(0, 8)}`;
|
|
15433
|
-
const rootDir =
|
|
15454
|
+
const rootDir = import_node_path18.default.join(import_node_os7.default.homedir(), ".pmate", "collect", sourceKey);
|
|
15434
15455
|
return { sourceKey, endpoint, rootDir };
|
|
15435
15456
|
}
|
|
15436
15457
|
function toThreadKey(name) {
|
|
@@ -15460,14 +15481,14 @@ async function writeStoredThread(rootDir, thread) {
|
|
|
15460
15481
|
const metaPath = getThreadMetaFilePath(rootDir, thread.threadKey);
|
|
15461
15482
|
const messagePath = getThreadMessagesFilePath(rootDir, thread.threadKey);
|
|
15462
15483
|
const { messages: messages2, ...meta } = thread;
|
|
15463
|
-
await import_node_fs12.promises.mkdir(
|
|
15484
|
+
await import_node_fs12.promises.mkdir(import_node_path18.default.dirname(metaPath), { recursive: true });
|
|
15464
15485
|
await import_node_fs12.promises.writeFile(metaPath, JSON.stringify(meta, null, 2) + "\n", "utf8");
|
|
15465
15486
|
const body = messages2.map((message) => JSON.stringify(message)).join("\n");
|
|
15466
15487
|
await import_node_fs12.promises.writeFile(messagePath, `${body}${body ? "\n" : ""}`, "utf8");
|
|
15467
15488
|
}
|
|
15468
15489
|
async function writeStoredIndex(rootDir, index) {
|
|
15469
15490
|
await import_node_fs12.promises.mkdir(rootDir, { recursive: true });
|
|
15470
|
-
const filePath =
|
|
15491
|
+
const filePath = import_node_path18.default.join(rootDir, "index.json");
|
|
15471
15492
|
await import_node_fs12.promises.writeFile(filePath, JSON.stringify(index, null, 2) + "\n", "utf8");
|
|
15472
15493
|
}
|
|
15473
15494
|
function diffMessages(existing, incoming) {
|
|
@@ -15558,13 +15579,13 @@ async function readLegacyStoredThread(rootDir, threadKey) {
|
|
|
15558
15579
|
}
|
|
15559
15580
|
}
|
|
15560
15581
|
function getThreadMetaFilePath(rootDir, threadKey) {
|
|
15561
|
-
return
|
|
15582
|
+
return import_node_path18.default.join(rootDir, "threads", `${threadKey}.json`);
|
|
15562
15583
|
}
|
|
15563
15584
|
function getThreadMessagesFilePath(rootDir, threadKey) {
|
|
15564
|
-
return
|
|
15585
|
+
return import_node_path18.default.join(rootDir, "threads", `${threadKey}.jsonl`);
|
|
15565
15586
|
}
|
|
15566
15587
|
function getLegacyThreadFilePath(rootDir, threadKey) {
|
|
15567
|
-
return
|
|
15588
|
+
return import_node_path18.default.join(rootDir, "threads", `${threadKey}.json`);
|
|
15568
15589
|
}
|
|
15569
15590
|
function normalizeStoredMessage(message) {
|
|
15570
15591
|
return {
|
|
@@ -15580,9 +15601,9 @@ function normalizeStoredMessage(message) {
|
|
|
15580
15601
|
|
|
15581
15602
|
// src/commands/CollectCommandHandler.ts
|
|
15582
15603
|
async function readOutgoingAttachment(filePath) {
|
|
15583
|
-
const resolved =
|
|
15604
|
+
const resolved = import_node_path19.default.resolve(filePath);
|
|
15584
15605
|
const data = await import_node_fs13.promises.readFile(resolved);
|
|
15585
|
-
const extension =
|
|
15606
|
+
const extension = import_node_path19.default.extname(resolved).toLowerCase();
|
|
15586
15607
|
const contentTypes = {
|
|
15587
15608
|
".png": "image/png",
|
|
15588
15609
|
".jpg": "image/jpeg",
|
|
@@ -15597,7 +15618,7 @@ async function readOutgoingAttachment(filePath) {
|
|
|
15597
15618
|
};
|
|
15598
15619
|
return {
|
|
15599
15620
|
base64: data.toString("base64"),
|
|
15600
|
-
fileName:
|
|
15621
|
+
fileName: import_node_path19.default.basename(resolved),
|
|
15601
15622
|
contentType: contentTypes[extension] ?? "application/octet-stream",
|
|
15602
15623
|
size: data.byteLength
|
|
15603
15624
|
};
|
|
@@ -15867,7 +15888,7 @@ var CollectCommandHandler = class {
|
|
|
15867
15888
|
}
|
|
15868
15889
|
async writeSyncReport(rootDir, target, results, failures, syncedAt) {
|
|
15869
15890
|
const syncId = toSyncId(syncedAt);
|
|
15870
|
-
const reportPath =
|
|
15891
|
+
const reportPath = import_node_path19.default.join(rootDir, "syncs", `${syncId}.json`);
|
|
15871
15892
|
const threadReports = results.map((result) => ({
|
|
15872
15893
|
threadKey: result.thread.threadKey,
|
|
15873
15894
|
threadName: result.thread.threadName,
|
|
@@ -15876,7 +15897,7 @@ var CollectCommandHandler = class {
|
|
|
15876
15897
|
addedMessages: result.diff.added,
|
|
15877
15898
|
upgradedMessages: result.diff.upgraded
|
|
15878
15899
|
})).filter((thread) => thread.addedCount > 0 || thread.upgradedCount > 0);
|
|
15879
|
-
await import_node_fs13.promises.mkdir(
|
|
15900
|
+
await import_node_fs13.promises.mkdir(import_node_path19.default.dirname(reportPath), { recursive: true });
|
|
15880
15901
|
await import_node_fs13.promises.writeFile(
|
|
15881
15902
|
reportPath,
|
|
15882
15903
|
JSON.stringify(
|
|
@@ -16055,18 +16076,18 @@ async function archiveMessageImage(rootDir, attachmentRoot, threadKey, imagePath
|
|
|
16055
16076
|
if (!imagePath || isExternalImageRef(imagePath)) {
|
|
16056
16077
|
return imagePath;
|
|
16057
16078
|
}
|
|
16058
|
-
const normalized =
|
|
16079
|
+
const normalized = import_node_path19.default.posix.normalize(imagePath.replace(/\\/g, "/"));
|
|
16059
16080
|
if (normalized.startsWith("attachments/")) {
|
|
16060
|
-
return
|
|
16081
|
+
return import_node_path19.default.join(rootDir, ...normalized.split("/"));
|
|
16061
16082
|
}
|
|
16062
|
-
if (normalized.startsWith("../") ||
|
|
16083
|
+
if (normalized.startsWith("../") || import_node_path19.default.posix.isAbsolute(normalized)) {
|
|
16063
16084
|
return imagePath;
|
|
16064
16085
|
}
|
|
16065
|
-
const sourcePath =
|
|
16066
|
-
const destinationRelativePath =
|
|
16067
|
-
const destinationPath =
|
|
16086
|
+
const sourcePath = import_node_path19.default.join(attachmentRoot, ...normalized.split("/"));
|
|
16087
|
+
const destinationRelativePath = import_node_path19.default.posix.join("attachments", threadKey, normalized);
|
|
16088
|
+
const destinationPath = import_node_path19.default.join(rootDir, ...destinationRelativePath.split("/"));
|
|
16068
16089
|
try {
|
|
16069
|
-
await import_node_fs13.promises.mkdir(
|
|
16090
|
+
await import_node_fs13.promises.mkdir(import_node_path19.default.dirname(destinationPath), { recursive: true });
|
|
16070
16091
|
await import_node_fs13.promises.copyFile(sourcePath, destinationPath);
|
|
16071
16092
|
return destinationPath;
|
|
16072
16093
|
} catch {
|
|
@@ -16077,7 +16098,7 @@ function resolveLocalAttachmentRoot(sourceKey) {
|
|
|
16077
16098
|
if (sourceKey !== "cc" && sourceKey !== "yelling") {
|
|
16078
16099
|
return null;
|
|
16079
16100
|
}
|
|
16080
|
-
return
|
|
16101
|
+
return import_node_path19.default.join(import_node_os8.default.homedir(), "Library", "Application Support", sourceKey, "attachments.noindex");
|
|
16081
16102
|
}
|
|
16082
16103
|
function isExternalImageRef(imagePath) {
|
|
16083
16104
|
return /^[a-z][a-z0-9+.-]*:/i.test(imagePath);
|
|
@@ -16784,7 +16805,7 @@ async function loadChatSdk() {
|
|
|
16784
16805
|
|
|
16785
16806
|
// src/commands/RegistryResourceCommandHandler.ts
|
|
16786
16807
|
var import_node_fs15 = require("fs");
|
|
16787
|
-
var
|
|
16808
|
+
var import_node_path20 = __toESM(require("path"));
|
|
16788
16809
|
init_sessionStore();
|
|
16789
16810
|
var RegistryResourceCommandHandler = class {
|
|
16790
16811
|
async handle(args) {
|
|
@@ -16819,7 +16840,7 @@ var RegistryResourceCommandHandler = class {
|
|
|
16819
16840
|
}
|
|
16820
16841
|
};
|
|
16821
16842
|
function readJson(filePath) {
|
|
16822
|
-
const absolutePath =
|
|
16843
|
+
const absolutePath = import_node_path20.default.resolve(process.cwd(), filePath);
|
|
16823
16844
|
if (!(0, import_node_fs15.existsSync)(absolutePath)) throw new Error(`JSON file not found: ${absolutePath}`);
|
|
16824
16845
|
return JSON.parse((0, import_node_fs15.readFileSync)(absolutePath, "utf8"));
|
|
16825
16846
|
}
|
|
@@ -16836,7 +16857,7 @@ async function request(baseUrl, token, method, pathname, body) {
|
|
|
16836
16857
|
|
|
16837
16858
|
// src/commands/CallCommandHandler.ts
|
|
16838
16859
|
var import_node_fs16 = require("fs");
|
|
16839
|
-
var
|
|
16860
|
+
var import_node_path21 = __toESM(require("path"));
|
|
16840
16861
|
init_dist2();
|
|
16841
16862
|
init_sessionStore();
|
|
16842
16863
|
var CallCommandHandler = class {
|
|
@@ -16859,7 +16880,7 @@ var CallCommandHandler = class {
|
|
|
16859
16880
|
}
|
|
16860
16881
|
};
|
|
16861
16882
|
async function callWithBinaryFile(hub, functionId, filePath, contentType, timeoutMs) {
|
|
16862
|
-
const absolutePath =
|
|
16883
|
+
const absolutePath = import_node_path21.default.resolve(process.cwd(), filePath);
|
|
16863
16884
|
if (!(0, import_node_fs16.existsSync)(absolutePath)) throw new Error(`Binary file not found: ${absolutePath}`);
|
|
16864
16885
|
const mimeType = contentType || inferContentType(absolutePath);
|
|
16865
16886
|
const result = hub.stream({
|
|
@@ -16885,10 +16906,10 @@ function inferContentType(filePath) {
|
|
|
16885
16906
|
".wav": "audio/wav",
|
|
16886
16907
|
".webm": "audio/webm"
|
|
16887
16908
|
};
|
|
16888
|
-
return contentTypes[
|
|
16909
|
+
return contentTypes[import_node_path21.default.extname(filePath).toLowerCase()] || "application/octet-stream";
|
|
16889
16910
|
}
|
|
16890
16911
|
function readJson2(filePath) {
|
|
16891
|
-
const absolutePath =
|
|
16912
|
+
const absolutePath = import_node_path21.default.resolve(process.cwd(), filePath);
|
|
16892
16913
|
if (!(0, import_node_fs16.existsSync)(absolutePath)) throw new Error(`JSON file not found: ${absolutePath}`);
|
|
16893
16914
|
const decoded = JSON.parse((0, import_node_fs16.readFileSync)(absolutePath, "utf8"));
|
|
16894
16915
|
if (!decoded || typeof decoded !== "object" || Array.isArray(decoded)) {
|
|
@@ -17278,7 +17299,7 @@ var NsCommandHandler = class {
|
|
|
17278
17299
|
|
|
17279
17300
|
// src/commands/StoreCommandHandler.ts
|
|
17280
17301
|
var import_node_fs17 = require("fs");
|
|
17281
|
-
var
|
|
17302
|
+
var import_node_path22 = __toESM(require("path"));
|
|
17282
17303
|
init_sessionStore();
|
|
17283
17304
|
var StoreCommandHandler = class {
|
|
17284
17305
|
async handle(args) {
|
|
@@ -17432,7 +17453,7 @@ var StoreCommandHandler = class {
|
|
|
17432
17453
|
return payload.data ?? [];
|
|
17433
17454
|
}
|
|
17434
17455
|
readJsonFile(filePath) {
|
|
17435
|
-
const absolutePath =
|
|
17456
|
+
const absolutePath = import_node_path22.default.resolve(process.cwd(), filePath);
|
|
17436
17457
|
if (!(0, import_node_fs17.existsSync)(absolutePath)) {
|
|
17437
17458
|
throw new Error(`JSON file not found: ${absolutePath}`);
|
|
17438
17459
|
}
|
|
@@ -17489,13 +17510,13 @@ var StoreCommandHandler = class {
|
|
|
17489
17510
|
|
|
17490
17511
|
// src/commands/AppCommandHandler.ts
|
|
17491
17512
|
var import_node_fs19 = require("fs");
|
|
17492
|
-
var
|
|
17513
|
+
var import_node_path24 = __toESM(require("path"));
|
|
17493
17514
|
init_sessionStore();
|
|
17494
17515
|
|
|
17495
17516
|
// src/appIcon.ts
|
|
17496
17517
|
var import_node_fs18 = require("fs");
|
|
17497
|
-
var
|
|
17498
|
-
var
|
|
17518
|
+
var import_node_os9 = __toESM(require("os"));
|
|
17519
|
+
var import_node_path23 = __toESM(require("path"));
|
|
17499
17520
|
var import_sharp = __toESM(require("sharp"));
|
|
17500
17521
|
init_namespacedRef();
|
|
17501
17522
|
var ANDROID_ICON_SPECS = [
|
|
@@ -17600,13 +17621,13 @@ function createAppIconExportPlans(input) {
|
|
|
17600
17621
|
if (!input.outDir) {
|
|
17601
17622
|
throw new Error("App icon preset export requires --out-dir.");
|
|
17602
17623
|
}
|
|
17603
|
-
const outDir =
|
|
17624
|
+
const outDir = import_node_path23.default.resolve(input.cwd, input.outDir);
|
|
17604
17625
|
(0, import_node_fs18.mkdirSync)(outDir, { recursive: true });
|
|
17605
17626
|
return specs.map((spec) => ({
|
|
17606
17627
|
width: spec.width,
|
|
17607
17628
|
height: spec.height,
|
|
17608
17629
|
format: "png",
|
|
17609
|
-
outputPath:
|
|
17630
|
+
outputPath: import_node_path23.default.join(
|
|
17610
17631
|
outDir,
|
|
17611
17632
|
`${namespace}-${objectId}-${spec.name}-${spec.width}x${spec.height}.png`
|
|
17612
17633
|
)
|
|
@@ -17619,8 +17640,8 @@ function createAppIconExportPlans(input) {
|
|
|
17619
17640
|
if (!input.output) {
|
|
17620
17641
|
throw new Error("Single-size app icon export requires --output.");
|
|
17621
17642
|
}
|
|
17622
|
-
const resolvedOutput =
|
|
17623
|
-
(0, import_node_fs18.mkdirSync)(
|
|
17643
|
+
const resolvedOutput = import_node_path23.default.resolve(input.cwd, input.output);
|
|
17644
|
+
(0, import_node_fs18.mkdirSync)(import_node_path23.default.dirname(resolvedOutput), { recursive: true });
|
|
17624
17645
|
return [
|
|
17625
17646
|
{
|
|
17626
17647
|
width: input.width,
|
|
@@ -17642,8 +17663,8 @@ async function renderAppIconVariant(input) {
|
|
|
17642
17663
|
const bytes = await renderAppIcon(svg, input.width, input.height, input.format);
|
|
17643
17664
|
let outputPath;
|
|
17644
17665
|
if (input.output) {
|
|
17645
|
-
outputPath =
|
|
17646
|
-
(0, import_node_fs18.mkdirSync)(
|
|
17666
|
+
outputPath = import_node_path23.default.resolve(input.cwd, input.output);
|
|
17667
|
+
(0, import_node_fs18.mkdirSync)(import_node_path23.default.dirname(outputPath), { recursive: true });
|
|
17647
17668
|
(0, import_node_fs18.writeFileSync)(outputPath, bytes);
|
|
17648
17669
|
}
|
|
17649
17670
|
if (input.name) {
|
|
@@ -17665,7 +17686,7 @@ async function renderAppIconVariant(input) {
|
|
|
17665
17686
|
};
|
|
17666
17687
|
}
|
|
17667
17688
|
async function loadAppIconVariantFile(input) {
|
|
17668
|
-
const absolutePath =
|
|
17689
|
+
const absolutePath = import_node_path23.default.resolve(input.cwd, input.filePath);
|
|
17669
17690
|
const format = inferVariantFormatFromPath(absolutePath);
|
|
17670
17691
|
return {
|
|
17671
17692
|
value: input.name ? await uploadAppIconVariantAsset({
|
|
@@ -17733,7 +17754,7 @@ function shouldAutoGenerateDefaultVariant(icon) {
|
|
|
17733
17754
|
return looksLikeSvgMarkup(icon) || looksLikeSvgUrl(icon);
|
|
17734
17755
|
}
|
|
17735
17756
|
function inferVariantFormatFromPath(filePath) {
|
|
17736
|
-
const ext =
|
|
17757
|
+
const ext = import_node_path23.default.extname(filePath).toLowerCase();
|
|
17737
17758
|
switch (ext) {
|
|
17738
17759
|
case ".png":
|
|
17739
17760
|
return "png";
|
|
@@ -17804,13 +17825,13 @@ async function uploadAppIconVariantAsset(input) {
|
|
|
17804
17825
|
await AliyunService.uploadFile(sourcePath, DEFAULT_APP_ICON_VARIANT_BUCKET, objectKey);
|
|
17805
17826
|
} finally {
|
|
17806
17827
|
if (shouldCleanup) {
|
|
17807
|
-
(0, import_node_fs18.rmSync)(
|
|
17828
|
+
(0, import_node_fs18.rmSync)(import_node_path23.default.dirname(sourcePath), { recursive: true, force: true });
|
|
17808
17829
|
}
|
|
17809
17830
|
}
|
|
17810
17831
|
return `${DEFAULT_APP_ICON_VARIANT_PUBLIC_BASE_URL}/${objectKey}`;
|
|
17811
17832
|
}
|
|
17812
17833
|
function buildAppIconVariantObjectKey(input) {
|
|
17813
|
-
return
|
|
17834
|
+
return import_node_path23.default.posix.join(
|
|
17814
17835
|
"apps",
|
|
17815
17836
|
`${resolveAppIconAssetStem(input.icon, input.appRef)}-${input.name}.${extensionForIconFormat(input.format)}`
|
|
17816
17837
|
);
|
|
@@ -17819,8 +17840,8 @@ function resolveAppIconAssetStem(icon, appRef2) {
|
|
|
17819
17840
|
if (icon) {
|
|
17820
17841
|
try {
|
|
17821
17842
|
const url = new URL(icon);
|
|
17822
|
-
const ext =
|
|
17823
|
-
const basename =
|
|
17843
|
+
const ext = import_node_path23.default.posix.extname(url.pathname);
|
|
17844
|
+
const basename = import_node_path23.default.posix.basename(url.pathname, ext);
|
|
17824
17845
|
const normalized = sanitizeAppIconAssetStem(basename);
|
|
17825
17846
|
if (normalized) {
|
|
17826
17847
|
return normalized;
|
|
@@ -17849,8 +17870,8 @@ function writeTempAppIconVariantFile(objectKey, format, bytes) {
|
|
|
17849
17870
|
if (!bytes) {
|
|
17850
17871
|
throw new Error("App icon variant upload requires bytes or a source file.");
|
|
17851
17872
|
}
|
|
17852
|
-
const tempDir = (0, import_node_fs18.mkdtempSync)(
|
|
17853
|
-
const tempPath =
|
|
17873
|
+
const tempDir = (0, import_node_fs18.mkdtempSync)(import_node_path23.default.join(import_node_os9.default.tmpdir(), "pmate-app-icon-"));
|
|
17874
|
+
const tempPath = import_node_path23.default.join(tempDir, import_node_path23.default.basename(objectKey) || `variant.${extensionForIconFormat(format)}`);
|
|
17854
17875
|
(0, import_node_fs18.writeFileSync)(tempPath, bytes);
|
|
17855
17876
|
return tempPath;
|
|
17856
17877
|
}
|
|
@@ -18073,10 +18094,10 @@ var AppCommandHandler = class {
|
|
|
18073
18094
|
}
|
|
18074
18095
|
async preparePayload(filePath, appRef2) {
|
|
18075
18096
|
const absolutePath = this.resolveFilePath(filePath);
|
|
18076
|
-
return prepareAppPayload(this.readJsonFile(filePath),
|
|
18097
|
+
return prepareAppPayload(this.readJsonFile(filePath), import_node_path24.default.dirname(absolutePath), { appRef: appRef2 });
|
|
18077
18098
|
}
|
|
18078
18099
|
resolveFilePath(filePath) {
|
|
18079
|
-
return
|
|
18100
|
+
return import_node_path24.default.resolve(process.cwd(), filePath);
|
|
18080
18101
|
}
|
|
18081
18102
|
async request(baseUrl, token, method, pathname, body) {
|
|
18082
18103
|
const response = await fetch(`${baseUrl}${pathname}`, {
|
|
@@ -18198,7 +18219,7 @@ function readNamespaceFromPayload(payload) {
|
|
|
18198
18219
|
// src/commands/ServiceCommandHandler.ts
|
|
18199
18220
|
var import_node_fs22 = require("fs");
|
|
18200
18221
|
var import_promises5 = require("fs/promises");
|
|
18201
|
-
var
|
|
18222
|
+
var import_node_path27 = __toESM(require("path"));
|
|
18202
18223
|
var import_node_child_process11 = require("child_process");
|
|
18203
18224
|
var import_promises6 = require("readline/promises");
|
|
18204
18225
|
|
|
@@ -18206,8 +18227,8 @@ var import_promises6 = require("readline/promises");
|
|
|
18206
18227
|
var import_node_child_process9 = require("child_process");
|
|
18207
18228
|
var import_node_crypto4 = require("crypto");
|
|
18208
18229
|
var import_node_fs20 = require("fs");
|
|
18209
|
-
var
|
|
18210
|
-
var
|
|
18230
|
+
var import_node_os10 = __toESM(require("os"));
|
|
18231
|
+
var import_node_path25 = __toESM(require("path"));
|
|
18211
18232
|
var ANDROID_APK_BUCKET = "parrot-static";
|
|
18212
18233
|
var ANDROID_APK_PUBLIC_BASE_URL = "https://parrot-static.pmate.chat";
|
|
18213
18234
|
var AndroidApkReleaseService = class {
|
|
@@ -18275,8 +18296,8 @@ var AndroidApkReleaseService = class {
|
|
|
18275
18296
|
minimumVersionCode: options.minimumVersionCode
|
|
18276
18297
|
});
|
|
18277
18298
|
const objectKey = buildAndroidLatestManifestObjectKey(service.namespace, service.name);
|
|
18278
|
-
const tempDir = (0, import_node_fs20.mkdtempSync)(
|
|
18279
|
-
const manifestPath =
|
|
18299
|
+
const tempDir = (0, import_node_fs20.mkdtempSync)(import_node_path25.default.join(import_node_os10.default.tmpdir(), "pmate-apk-latest-"));
|
|
18300
|
+
const manifestPath = import_node_path25.default.join(tempDir, "latest.json");
|
|
18280
18301
|
try {
|
|
18281
18302
|
(0, import_node_fs20.writeFileSync)(manifestPath, `${JSON.stringify(manifest, null, 2)}
|
|
18282
18303
|
`);
|
|
@@ -18299,7 +18320,7 @@ var AndroidApkReleaseService = class {
|
|
|
18299
18320
|
const prefix = `apks/${service.namespace}/${service.name}`;
|
|
18300
18321
|
const objects = await AliyunService.listObjects(ANDROID_APK_BUCKET, prefix);
|
|
18301
18322
|
return objects.filter((item) => item.name.endsWith(".apk")).map((item) => {
|
|
18302
|
-
const versionName =
|
|
18323
|
+
const versionName = import_node_path25.default.basename(item.name, ".apk");
|
|
18303
18324
|
return {
|
|
18304
18325
|
serviceId,
|
|
18305
18326
|
env: options.env ?? "unknown",
|
|
@@ -18322,7 +18343,7 @@ var AndroidApkReleaseService = class {
|
|
|
18322
18343
|
}
|
|
18323
18344
|
}
|
|
18324
18345
|
resolveRepoRoot(service, cwd) {
|
|
18325
|
-
if (cwd) return
|
|
18346
|
+
if (cwd) return import_node_path25.default.resolve(process.cwd(), cwd);
|
|
18326
18347
|
const repository = this.getRepository(service);
|
|
18327
18348
|
if (repository) {
|
|
18328
18349
|
return resolveRepositoryLocalRoot(repository);
|
|
@@ -18334,7 +18355,7 @@ var AndroidApkReleaseService = class {
|
|
|
18334
18355
|
if (!dir) {
|
|
18335
18356
|
throw new Error(`Missing dir for android service ${service.id}`);
|
|
18336
18357
|
}
|
|
18337
|
-
const appDir =
|
|
18358
|
+
const appDir = import_node_path25.default.resolve(repoRoot, dir);
|
|
18338
18359
|
if (!(0, import_node_fs20.existsSync)(appDir)) {
|
|
18339
18360
|
throw new Error(`Android app dir not found: ${appDir}`);
|
|
18340
18361
|
}
|
|
@@ -18351,11 +18372,11 @@ var AndroidApkReleaseService = class {
|
|
|
18351
18372
|
return void 0;
|
|
18352
18373
|
}
|
|
18353
18374
|
async runGradleAssembleAndFindApk(repoRoot, appDir, variant) {
|
|
18354
|
-
const gradlew = [
|
|
18375
|
+
const gradlew = [import_node_path25.default.join(appDir, "gradlew"), import_node_path25.default.join(repoRoot, "gradlew")].find((candidate) => (0, import_node_fs20.existsSync)(candidate));
|
|
18355
18376
|
if (!gradlew) {
|
|
18356
18377
|
throw new Error(`Gradle wrapper not found in ${appDir} or ${repoRoot}`);
|
|
18357
18378
|
}
|
|
18358
|
-
const gradleCwd =
|
|
18379
|
+
const gradleCwd = import_node_path25.default.dirname(gradlew);
|
|
18359
18380
|
const normalizedVariant = variant.toLowerCase();
|
|
18360
18381
|
const taskSuffix = `assemble${capitalize(normalizedVariant)}`;
|
|
18361
18382
|
const tasks = [`:app:${taskSuffix}`, taskSuffix];
|
|
@@ -18443,7 +18464,7 @@ function resolveRepositoryLocalRoot(repository) {
|
|
|
18443
18464
|
if (!repoName) {
|
|
18444
18465
|
throw new Error(`Invalid repository: ${repository}`);
|
|
18445
18466
|
}
|
|
18446
|
-
return
|
|
18467
|
+
return import_node_path25.default.join(import_node_os10.default.homedir(), "dev", "pmate", repoName);
|
|
18447
18468
|
}
|
|
18448
18469
|
function bumpAndroidGradleVersionText(source, bump) {
|
|
18449
18470
|
const versionNameMatch = source.match(/(^\s*versionName\s+["'])([^"']+)(["']\s*$)/m) ?? source.match(/(^\s*versionName\s*=\s*["'])([^"']+)(["']\s*$)/m);
|
|
@@ -18499,10 +18520,10 @@ function parseGradleOutputMetadata(source, apkFileName) {
|
|
|
18499
18520
|
}
|
|
18500
18521
|
function bumpAndroidProjectVersion(appDir, bump) {
|
|
18501
18522
|
const candidates = [
|
|
18502
|
-
|
|
18503
|
-
|
|
18504
|
-
|
|
18505
|
-
|
|
18523
|
+
import_node_path25.default.join(appDir, "app", "build.gradle.kts"),
|
|
18524
|
+
import_node_path25.default.join(appDir, "app", "build.gradle"),
|
|
18525
|
+
import_node_path25.default.join(appDir, "build.gradle.kts"),
|
|
18526
|
+
import_node_path25.default.join(appDir, "build.gradle")
|
|
18506
18527
|
];
|
|
18507
18528
|
for (const candidate of candidates) {
|
|
18508
18529
|
if (!(0, import_node_fs20.existsSync)(candidate)) continue;
|
|
@@ -18514,9 +18535,9 @@ function bumpAndroidProjectVersion(appDir, bump) {
|
|
|
18514
18535
|
}
|
|
18515
18536
|
function findLatestApk(repoRoot, appDir, variant) {
|
|
18516
18537
|
const dirs = [
|
|
18517
|
-
|
|
18518
|
-
|
|
18519
|
-
|
|
18538
|
+
import_node_path25.default.join(appDir, "app", "build", "outputs", "apk", variant),
|
|
18539
|
+
import_node_path25.default.join(appDir, "build", "outputs", "apk", variant),
|
|
18540
|
+
import_node_path25.default.join(repoRoot, "app", "build", "outputs", "apk", variant)
|
|
18520
18541
|
];
|
|
18521
18542
|
const files = dirs.flatMap((dir) => listApks(dir));
|
|
18522
18543
|
if (files.length === 0) {
|
|
@@ -18526,15 +18547,15 @@ function findLatestApk(repoRoot, appDir, variant) {
|
|
|
18526
18547
|
return files[0];
|
|
18527
18548
|
}
|
|
18528
18549
|
function readGradleOutputMetadata(apkPath) {
|
|
18529
|
-
const metadataPath =
|
|
18550
|
+
const metadataPath = import_node_path25.default.join(import_node_path25.default.dirname(apkPath), "output-metadata.json");
|
|
18530
18551
|
if (!(0, import_node_fs20.existsSync)(metadataPath)) {
|
|
18531
18552
|
throw new Error(`Gradle output metadata not found: ${metadataPath}`);
|
|
18532
18553
|
}
|
|
18533
|
-
return parseGradleOutputMetadata((0, import_node_fs20.readFileSync)(metadataPath, "utf8"),
|
|
18554
|
+
return parseGradleOutputMetadata((0, import_node_fs20.readFileSync)(metadataPath, "utf8"), import_node_path25.default.basename(apkPath));
|
|
18534
18555
|
}
|
|
18535
18556
|
function listApks(dir) {
|
|
18536
18557
|
if (!(0, import_node_fs20.existsSync)(dir)) return [];
|
|
18537
|
-
return (0, import_node_fs20.readdirSync)(dir).filter((entry) => entry.endsWith(".apk")).map((entry) =>
|
|
18558
|
+
return (0, import_node_fs20.readdirSync)(dir).filter((entry) => entry.endsWith(".apk")).map((entry) => import_node_path25.default.join(dir, entry)).filter((entry) => (0, import_node_fs20.statSync)(entry).isFile());
|
|
18538
18559
|
}
|
|
18539
18560
|
function runCommand(command, args, cwd) {
|
|
18540
18561
|
return new Promise((resolve, reject) => {
|
|
@@ -18568,12 +18589,12 @@ async function runAndroidSdkToolCapture(toolName, args) {
|
|
|
18568
18589
|
return runCommandCapture(toolPath, args);
|
|
18569
18590
|
}
|
|
18570
18591
|
function findAndroidSdkTool(toolName) {
|
|
18571
|
-
const sdkRoots = [process.env.ANDROID_HOME, process.env.ANDROID_SDK_ROOT].filter((item) => Boolean(item)).map((item) =>
|
|
18592
|
+
const sdkRoots = [process.env.ANDROID_HOME, process.env.ANDROID_SDK_ROOT].filter((item) => Boolean(item)).map((item) => import_node_path25.default.resolve(item));
|
|
18572
18593
|
for (const sdkRoot of sdkRoots) {
|
|
18573
|
-
const candidates = toolName === "aapt" ? listVersionedToolCandidates(
|
|
18574
|
-
|
|
18575
|
-
...listVersionedToolCandidates(
|
|
18576
|
-
|
|
18594
|
+
const candidates = toolName === "aapt" ? listVersionedToolCandidates(import_node_path25.default.join(sdkRoot, "build-tools"), toolName) : [
|
|
18595
|
+
import_node_path25.default.join(sdkRoot, "cmdline-tools", "latest", "bin", toolName),
|
|
18596
|
+
...listVersionedToolCandidates(import_node_path25.default.join(sdkRoot, "cmdline-tools"), import_node_path25.default.join("bin", toolName)),
|
|
18597
|
+
import_node_path25.default.join(sdkRoot, "tools", "bin", toolName)
|
|
18577
18598
|
];
|
|
18578
18599
|
const match = candidates.find((candidate) => (0, import_node_fs20.existsSync)(candidate));
|
|
18579
18600
|
if (match) return match;
|
|
@@ -18582,7 +18603,7 @@ function findAndroidSdkTool(toolName) {
|
|
|
18582
18603
|
}
|
|
18583
18604
|
function listVersionedToolCandidates(parentDir, relativeToolPath) {
|
|
18584
18605
|
if (!(0, import_node_fs20.existsSync)(parentDir)) return [];
|
|
18585
|
-
return (0, import_node_fs20.readdirSync)(parentDir).map((entry) =>
|
|
18606
|
+
return (0, import_node_fs20.readdirSync)(parentDir).map((entry) => import_node_path25.default.join(parentDir, entry)).filter((entry) => (0, import_node_fs20.statSync)(entry).isDirectory()).sort((a, b) => import_node_path25.default.basename(b).localeCompare(import_node_path25.default.basename(a), void 0, { numeric: true })).map((entry) => import_node_path25.default.join(entry, relativeToolPath));
|
|
18586
18607
|
}
|
|
18587
18608
|
function sha256File(filePath) {
|
|
18588
18609
|
return new Promise((resolve, reject) => {
|
|
@@ -18605,8 +18626,8 @@ function capitalize(value) {
|
|
|
18605
18626
|
|
|
18606
18627
|
// src/services/ServiceRuntimeRunner.ts
|
|
18607
18628
|
var import_node_fs21 = require("fs");
|
|
18608
|
-
var
|
|
18609
|
-
var
|
|
18629
|
+
var import_node_os11 = __toESM(require("os"));
|
|
18630
|
+
var import_node_path26 = __toESM(require("path"));
|
|
18610
18631
|
var import_node_child_process10 = require("child_process");
|
|
18611
18632
|
var import_node_readline = require("readline");
|
|
18612
18633
|
var import_chalk3 = __toESM(require("chalk"));
|
|
@@ -19099,13 +19120,13 @@ var ServiceRuntimeRunner = class {
|
|
|
19099
19120
|
}
|
|
19100
19121
|
resolveRepoRoot(service, cwd) {
|
|
19101
19122
|
if (cwd) {
|
|
19102
|
-
return
|
|
19123
|
+
return import_node_path26.default.resolve(process.cwd(), cwd);
|
|
19103
19124
|
}
|
|
19104
19125
|
const repository = this.getType(service) === "vite" || this.getType(service) === "static" ? this.getRepoStaticSite(service).repository.trim() : this.getType(service) === "fc" ? this.getFc(service).repository?.trim() : this.getType(service) === "ios" || this.getType(service) === "android" ? void 0 : this.getNetwork(service).repository?.trim();
|
|
19105
19126
|
if (repository) {
|
|
19106
19127
|
const repoName = repository.replace(/\/+$/, "").split("/").pop()?.replace(/\.git$/i, "");
|
|
19107
19128
|
if (repoName) {
|
|
19108
|
-
const candidate =
|
|
19129
|
+
const candidate = import_node_path26.default.join(import_node_os11.default.homedir(), "dev", "pmate", repoName);
|
|
19109
19130
|
if ((0, import_node_fs21.existsSync)(candidate)) {
|
|
19110
19131
|
return candidate;
|
|
19111
19132
|
}
|
|
@@ -19119,12 +19140,12 @@ var ServiceRuntimeRunner = class {
|
|
|
19119
19140
|
if (!dir) {
|
|
19120
19141
|
throw new Error(`Missing service dir for ${service.id}`);
|
|
19121
19142
|
}
|
|
19122
|
-
return
|
|
19143
|
+
return import_node_path26.default.resolve(repoRoot, dir);
|
|
19123
19144
|
}
|
|
19124
19145
|
async deployVite(service, options) {
|
|
19125
19146
|
this.assertDeployableStaticSite(service);
|
|
19126
19147
|
const appDir = this.resolveLocalDir(service, options.cwd);
|
|
19127
|
-
const packageJsonPath =
|
|
19148
|
+
const packageJsonPath = import_node_path26.default.join(appDir, "package.json");
|
|
19128
19149
|
if (!(0, import_node_fs21.existsSync)(packageJsonPath)) {
|
|
19129
19150
|
throw new Error(`No package.json found at ${packageJsonPath}`);
|
|
19130
19151
|
}
|
|
@@ -19140,7 +19161,7 @@ var ServiceRuntimeRunner = class {
|
|
|
19140
19161
|
this.resolveRepoRoot(service, options.cwd),
|
|
19141
19162
|
buildEnv
|
|
19142
19163
|
);
|
|
19143
|
-
const distDir =
|
|
19164
|
+
const distDir = import_node_path26.default.join(appDir, "dist");
|
|
19144
19165
|
if (!(0, import_node_fs21.existsSync)(distDir)) {
|
|
19145
19166
|
throw new Error(`No dist directory found at ${distDir}`);
|
|
19146
19167
|
}
|
|
@@ -19154,7 +19175,7 @@ var ServiceRuntimeRunner = class {
|
|
|
19154
19175
|
async deployStatic(service, options) {
|
|
19155
19176
|
this.assertDeployableStaticSite(service);
|
|
19156
19177
|
const appDir = this.resolveLocalDir(service, options.cwd);
|
|
19157
|
-
const srcDir =
|
|
19178
|
+
const srcDir = import_node_path26.default.join(appDir, "src");
|
|
19158
19179
|
if (!(0, import_node_fs21.existsSync)(srcDir)) {
|
|
19159
19180
|
throw new Error(`No src directory found at ${srcDir}`);
|
|
19160
19181
|
}
|
|
@@ -19189,7 +19210,7 @@ var ServiceRuntimeRunner = class {
|
|
|
19189
19210
|
this.validateFcConfig(service, fc);
|
|
19190
19211
|
const repoRoot = this.resolveRepoRoot(service, options.cwd);
|
|
19191
19212
|
const appDir = this.resolveLocalDir(service, options.cwd);
|
|
19192
|
-
const packageJsonPath =
|
|
19213
|
+
const packageJsonPath = import_node_path26.default.join(appDir, "package.json");
|
|
19193
19214
|
if (!(0, import_node_fs21.existsSync)(packageJsonPath)) {
|
|
19194
19215
|
throw new Error(`No package.json found at ${packageJsonPath}`);
|
|
19195
19216
|
}
|
|
@@ -19243,11 +19264,11 @@ var ServiceRuntimeRunner = class {
|
|
|
19243
19264
|
const repoRoot = this.resolveRepoRoot(service, options.cwd);
|
|
19244
19265
|
const appDir = this.resolveLocalDir(service, options.cwd);
|
|
19245
19266
|
await this.ensurePnpmWorkspaceRoot(repoRoot);
|
|
19246
|
-
const configPath =
|
|
19267
|
+
const configPath = import_node_path26.default.join(appDir, fc.configFile ?? "s.yaml");
|
|
19247
19268
|
if (!(0, import_node_fs21.existsSync)(configPath)) {
|
|
19248
19269
|
throw new Error(`Missing FC config file at ${configPath}`);
|
|
19249
19270
|
}
|
|
19250
|
-
const packageJsonPath =
|
|
19271
|
+
const packageJsonPath = import_node_path26.default.join(appDir, "package.json");
|
|
19251
19272
|
if (!(0, import_node_fs21.existsSync)(packageJsonPath)) {
|
|
19252
19273
|
throw new Error(`No package.json found at ${packageJsonPath}`);
|
|
19253
19274
|
}
|
|
@@ -19564,7 +19585,7 @@ var ServiceRuntimeRunner = class {
|
|
|
19564
19585
|
}
|
|
19565
19586
|
if (config.ensurePackageJson) {
|
|
19566
19587
|
const appDir = this.resolveLocalDir(service, options.cwd);
|
|
19567
|
-
const packageJsonPath =
|
|
19588
|
+
const packageJsonPath = import_node_path26.default.join(appDir, "package.json");
|
|
19568
19589
|
if (!(0, import_node_fs21.existsSync)(packageJsonPath)) {
|
|
19569
19590
|
throw new Error(`Missing package.json at ${packageJsonPath}`);
|
|
19570
19591
|
}
|
|
@@ -20042,9 +20063,9 @@ var ServiceRuntimeRunner = class {
|
|
|
20042
20063
|
}
|
|
20043
20064
|
resolveTemplatePath(templateName) {
|
|
20044
20065
|
const candidates = [
|
|
20045
|
-
|
|
20046
|
-
|
|
20047
|
-
|
|
20066
|
+
import_node_path26.default.join(__dirname, "..", "templates", templateName),
|
|
20067
|
+
import_node_path26.default.join(__dirname, "..", "src", "templates", templateName),
|
|
20068
|
+
import_node_path26.default.join(__dirname, "templates", templateName)
|
|
20048
20069
|
];
|
|
20049
20070
|
for (const candidate of candidates) {
|
|
20050
20071
|
if ((0, import_node_fs21.existsSync)(candidate)) {
|
|
@@ -20115,7 +20136,7 @@ var ServiceRuntimeRunner = class {
|
|
|
20115
20136
|
}
|
|
20116
20137
|
}
|
|
20117
20138
|
async ensurePnpmWorkspaceRoot(repoRoot) {
|
|
20118
|
-
const workspacePath =
|
|
20139
|
+
const workspacePath = import_node_path26.default.join(repoRoot, "pnpm-workspace.yaml");
|
|
20119
20140
|
if (!(0, import_node_fs21.existsSync)(workspacePath)) {
|
|
20120
20141
|
throw new Error(`Missing pnpm-workspace.yaml at ${workspacePath}`);
|
|
20121
20142
|
}
|
|
@@ -20280,7 +20301,7 @@ var ServiceRuntimeRunner = class {
|
|
|
20280
20301
|
});
|
|
20281
20302
|
}
|
|
20282
20303
|
runRemoteCommand(server, command) {
|
|
20283
|
-
if (server === "local") return this.runCommandWithEnv("bash", ["-c", command],
|
|
20304
|
+
if (server === "local") return this.runCommandWithEnv("bash", ["-c", command], import_node_os11.default.homedir());
|
|
20284
20305
|
return new Promise((resolve, reject) => {
|
|
20285
20306
|
const target = `pmate@${server}`;
|
|
20286
20307
|
const child = (0, import_node_child_process10.spawn)("ssh", buildSshBashArgs(target, command), { stdio: "inherit" });
|
|
@@ -20712,7 +20733,7 @@ var ServiceCommandHandler = class {
|
|
|
20712
20733
|
format: "dotenv"
|
|
20713
20734
|
}
|
|
20714
20735
|
);
|
|
20715
|
-
const outputPath =
|
|
20736
|
+
const outputPath = import_node_path27.default.resolve(process.cwd(), args.output);
|
|
20716
20737
|
await (0, import_promises5.writeFile)(outputPath, payload.content, "utf8");
|
|
20717
20738
|
ui.success(`Wrote env file for ${args.appId} to ${outputPath}`);
|
|
20718
20739
|
this.renderJson({ ...payload, output: outputPath }, args.json);
|
|
@@ -20938,7 +20959,7 @@ var ServiceCommandHandler = class {
|
|
|
20938
20959
|
return (baseUrl || process.env.PMATE_APPS_API_BASE_URL || "https://apps-api.pmate.chat").replace(/\/+$/, "");
|
|
20939
20960
|
}
|
|
20940
20961
|
readJsonFile(filePath) {
|
|
20941
|
-
const absolutePath =
|
|
20962
|
+
const absolutePath = import_node_path27.default.resolve(process.cwd(), filePath);
|
|
20942
20963
|
if (!(0, import_node_fs22.existsSync)(absolutePath)) {
|
|
20943
20964
|
throw new Error(`JSON file not found: ${absolutePath}`);
|
|
20944
20965
|
}
|
|
@@ -21752,7 +21773,7 @@ var RoleCommandHandler = class {
|
|
|
21752
21773
|
// src/commands/AccountCommandHandler.ts
|
|
21753
21774
|
var import_node_fs23 = require("fs");
|
|
21754
21775
|
var import_node_crypto5 = require("crypto");
|
|
21755
|
-
var
|
|
21776
|
+
var import_node_path28 = __toESM(require("path"));
|
|
21756
21777
|
init_sessionStore();
|
|
21757
21778
|
var AccountCommandHandler = class {
|
|
21758
21779
|
async handle(args) {
|
|
@@ -21760,7 +21781,7 @@ var AccountCommandHandler = class {
|
|
|
21760
21781
|
case "bot-keygen": {
|
|
21761
21782
|
const keyFile = this.generateBotKeyFile(args.app, args.name);
|
|
21762
21783
|
const outPath = args.out ? this.resolveFilePath(args.out) : this.resolveDefaultBotKeyPath(args.app, args.name);
|
|
21763
|
-
(0, import_node_fs23.mkdirSync)(
|
|
21784
|
+
(0, import_node_fs23.mkdirSync)(import_node_path28.default.dirname(outPath), { recursive: true });
|
|
21764
21785
|
(0, import_node_fs23.writeFileSync)(outPath, JSON.stringify(keyFile, null, 2), { mode: 384 });
|
|
21765
21786
|
(0, import_node_fs23.chmodSync)(outPath, 384);
|
|
21766
21787
|
if (!args.json) {
|
|
@@ -22339,13 +22360,13 @@ var AccountCommandHandler = class {
|
|
|
22339
22360
|
return parsed;
|
|
22340
22361
|
}
|
|
22341
22362
|
resolveFilePath(filePath) {
|
|
22342
|
-
return
|
|
22363
|
+
return import_node_path28.default.resolve(process.cwd(), filePath);
|
|
22343
22364
|
}
|
|
22344
22365
|
resolveDefaultBotKeyPath(app, name) {
|
|
22345
|
-
return
|
|
22366
|
+
return import_node_path28.default.join(this.homeDir(), ".pmate", "bots", app, `${name}.bot-key.json`);
|
|
22346
22367
|
}
|
|
22347
22368
|
resolveDefaultAccessKeyPath(app, name) {
|
|
22348
|
-
return
|
|
22369
|
+
return import_node_path28.default.join(this.homeDir(), ".pmate", "access-keys", app, `${name}.access-key.json`);
|
|
22349
22370
|
}
|
|
22350
22371
|
homeDir() {
|
|
22351
22372
|
return process.env.HOME || process.env.USERPROFILE || process.cwd();
|
|
@@ -22370,7 +22391,7 @@ var AccountCommandHandler = class {
|
|
|
22370
22391
|
}
|
|
22371
22392
|
const keyFile = this.readBotKeyFile(oldPath, app, name);
|
|
22372
22393
|
const newPath = this.resolveDefaultBotKeyPath(app, newName);
|
|
22373
|
-
(0, import_node_fs23.mkdirSync)(
|
|
22394
|
+
(0, import_node_fs23.mkdirSync)(import_node_path28.default.dirname(newPath), { recursive: true, mode: 448 });
|
|
22374
22395
|
(0, import_node_fs23.writeFileSync)(newPath, JSON.stringify({ ...keyFile, name: newName }, null, 2));
|
|
22375
22396
|
(0, import_node_fs23.chmodSync)(newPath, 384);
|
|
22376
22397
|
return newPath;
|
|
@@ -22425,7 +22446,7 @@ var AccountCommandHandler = class {
|
|
|
22425
22446
|
createdAt: result.key.createdAt
|
|
22426
22447
|
};
|
|
22427
22448
|
const outPath = out ? this.resolveFilePath(out) : this.resolveDefaultAccessKeyPath(result.key.app, result.key.name);
|
|
22428
|
-
(0, import_node_fs23.mkdirSync)(
|
|
22449
|
+
(0, import_node_fs23.mkdirSync)(import_node_path28.default.dirname(outPath), { recursive: true });
|
|
22429
22450
|
(0, import_node_fs23.writeFileSync)(outPath, JSON.stringify(keyFile, null, 2), { mode: 384 });
|
|
22430
22451
|
(0, import_node_fs23.chmodSync)(outPath, 384);
|
|
22431
22452
|
}
|
|
@@ -22513,7 +22534,7 @@ function encodePathSegment2(value) {
|
|
|
22513
22534
|
|
|
22514
22535
|
// src/commands/OrgCommandHandler.ts
|
|
22515
22536
|
var import_node_fs24 = require("fs");
|
|
22516
|
-
var
|
|
22537
|
+
var import_node_path29 = __toESM(require("path"));
|
|
22517
22538
|
init_sessionStore();
|
|
22518
22539
|
var OrgCommandHandler = class {
|
|
22519
22540
|
async handle(args) {
|
|
@@ -22683,7 +22704,7 @@ var OrgCommandHandler = class {
|
|
|
22683
22704
|
if (!filePath) {
|
|
22684
22705
|
throw new Error(`Missing ${itemLabel} input`);
|
|
22685
22706
|
}
|
|
22686
|
-
const absolutePath =
|
|
22707
|
+
const absolutePath = import_node_path29.default.resolve(process.cwd(), filePath);
|
|
22687
22708
|
if (!(0, import_node_fs24.existsSync)(absolutePath)) {
|
|
22688
22709
|
throw new Error(`JSON file not found: ${absolutePath}`);
|
|
22689
22710
|
}
|
|
@@ -22759,8 +22780,8 @@ function encodePathSegment3(value) {
|
|
|
22759
22780
|
|
|
22760
22781
|
// src/commands/HostCommandHandler.ts
|
|
22761
22782
|
var import_node_fs25 = require("fs");
|
|
22762
|
-
var
|
|
22763
|
-
var
|
|
22783
|
+
var import_node_os12 = require("os");
|
|
22784
|
+
var import_node_path30 = __toESM(require("path"));
|
|
22764
22785
|
var import_node_child_process13 = require("child_process");
|
|
22765
22786
|
var BLOCK_START = "# >>> pmate host env >>>";
|
|
22766
22787
|
var BLOCK_END = "# <<< pmate host env <<<";
|
|
@@ -22773,7 +22794,7 @@ fi
|
|
|
22773
22794
|
${BLOCK_END}`;
|
|
22774
22795
|
var HostCommandHandler = class {
|
|
22775
22796
|
async handle(args) {
|
|
22776
|
-
const hostId = normalizeHostId(args.host ?? process.env.PMATE_HOST_ID ?? (0,
|
|
22797
|
+
const hostId = normalizeHostId(args.host ?? process.env.PMATE_HOST_ID ?? (0, import_node_os12.hostname)());
|
|
22777
22798
|
const client = new ServiceRegistryClient(args.baseUrl);
|
|
22778
22799
|
if (args.action === "env-list") {
|
|
22779
22800
|
const items = await client.listHostEnv(hostId);
|
|
@@ -25969,7 +25990,7 @@ function requireValue11(tokens, option) {
|
|
|
25969
25990
|
|
|
25970
25991
|
// src/index.ts
|
|
25971
25992
|
var pkg = JSON.parse(
|
|
25972
|
-
(0, import_node_fs26.readFileSync)(
|
|
25993
|
+
(0, import_node_fs26.readFileSync)(import_node_path31.default.resolve(__dirname, "..", "package.json"), "utf8")
|
|
25973
25994
|
);
|
|
25974
25995
|
var HELP_TEXT = [
|
|
25975
25996
|
import_chalk4.default.bold(`pmate v${pkg.version}`),
|