@pmate/cli 0.41.1 → 0.42.0
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/README.md +11 -1
- package/dist/index.js +780 -478
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -8294,14 +8294,14 @@ function abortError(reason) {
|
|
|
8294
8294
|
return reason;
|
|
8295
8295
|
return new Error(typeof reason === "string" ? reason : "Function stream aborted");
|
|
8296
8296
|
}
|
|
8297
|
-
function ensureWsProtocol(
|
|
8298
|
-
if (/^wss?:\/\//i.test(
|
|
8299
|
-
return
|
|
8300
|
-
if (/^https:\/\//i.test(
|
|
8301
|
-
return
|
|
8302
|
-
if (/^http:\/\//i.test(
|
|
8303
|
-
return
|
|
8304
|
-
return `wss://${
|
|
8297
|
+
function ensureWsProtocol(baseUrl2) {
|
|
8298
|
+
if (/^wss?:\/\//i.test(baseUrl2))
|
|
8299
|
+
return baseUrl2;
|
|
8300
|
+
if (/^https:\/\//i.test(baseUrl2))
|
|
8301
|
+
return baseUrl2.replace(/^https:/i, "wss:");
|
|
8302
|
+
if (/^http:\/\//i.test(baseUrl2))
|
|
8303
|
+
return baseUrl2.replace(/^http:/i, "ws:");
|
|
8304
|
+
return `wss://${baseUrl2}`;
|
|
8305
8305
|
}
|
|
8306
8306
|
function deferred() {
|
|
8307
8307
|
let resolve;
|
|
@@ -8818,8 +8818,8 @@ __export(index_exports, {
|
|
|
8818
8818
|
parseCommandArgs: () => parseCommandArgs
|
|
8819
8819
|
});
|
|
8820
8820
|
module.exports = __toCommonJS(index_exports);
|
|
8821
|
-
var
|
|
8822
|
-
var
|
|
8821
|
+
var import_node_fs31 = require("fs");
|
|
8822
|
+
var import_node_path36 = __toESM(require("path"));
|
|
8823
8823
|
|
|
8824
8824
|
// src/managedSession.ts
|
|
8825
8825
|
var import_node_fs = require("fs");
|
|
@@ -10116,7 +10116,7 @@ var AliyunService = class {
|
|
|
10116
10116
|
ui.success(`Bucket created: ${bucketName}`);
|
|
10117
10117
|
}
|
|
10118
10118
|
/** Upload all files in a directory to OSS, skipping unchanged files. */
|
|
10119
|
-
static async uploadDirectory(localDir,
|
|
10119
|
+
static async uploadDirectory(localDir, bucket2, prefix) {
|
|
10120
10120
|
const cfg = loadPmateConfig();
|
|
10121
10121
|
const region = cfg.oss?.public?.region?.trim();
|
|
10122
10122
|
const accessKeyId = cfg.aliyun?.ak?.trim();
|
|
@@ -10124,7 +10124,7 @@ var AliyunService = class {
|
|
|
10124
10124
|
if (!region) throw new Error("Missing oss.public.region in ~/.pmate/config.yaml.");
|
|
10125
10125
|
if (!accessKeyId) throw new Error("Missing aliyun.ak in ~/.pmate/config.yaml.");
|
|
10126
10126
|
if (!accessKeySecret) throw new Error("Missing aliyun.sk in ~/.pmate/config.yaml.");
|
|
10127
|
-
const client = new import_ali_oss.default({ region, accessKeyId, accessKeySecret, bucket });
|
|
10127
|
+
const client = new import_ali_oss.default({ region, accessKeyId, accessKeySecret, bucket: bucket2 });
|
|
10128
10128
|
const files = await this.collectFiles(localDir);
|
|
10129
10129
|
if (files.length === 0) {
|
|
10130
10130
|
ui.warn(`No files to upload from ${localDir}`);
|
|
@@ -10169,7 +10169,7 @@ var AliyunService = class {
|
|
|
10169
10169
|
}
|
|
10170
10170
|
}
|
|
10171
10171
|
/** Upload a single file to OSS. */
|
|
10172
|
-
static async uploadFile(localFile,
|
|
10172
|
+
static async uploadFile(localFile, bucket2, objectKey, extraHeaders = {}) {
|
|
10173
10173
|
const cfg = loadPmateConfig();
|
|
10174
10174
|
const region = cfg.oss?.public?.region?.trim();
|
|
10175
10175
|
const accessKeyId = cfg.aliyun?.ak?.trim();
|
|
@@ -10180,24 +10180,25 @@ var AliyunService = class {
|
|
|
10180
10180
|
if (!(0, import_node_fs5.existsSync)(localFile)) {
|
|
10181
10181
|
throw new Error(`File not found: ${localFile}`);
|
|
10182
10182
|
}
|
|
10183
|
-
const client = new import_ali_oss.default({ region, accessKeyId, accessKeySecret, bucket });
|
|
10183
|
+
const client = new import_ali_oss.default({ region, accessKeyId, accessKeySecret, bucket: bucket2 });
|
|
10184
10184
|
const contentType = this.getContentType(localFile);
|
|
10185
10185
|
const cacheControl = this.getStaticAssetCacheControl(objectKey);
|
|
10186
10186
|
const headers = {};
|
|
10187
10187
|
if (contentType) headers["Content-Type"] = contentType;
|
|
10188
10188
|
if (cacheControl) headers["Cache-Control"] = cacheControl;
|
|
10189
|
+
Object.assign(headers, extraHeaders);
|
|
10189
10190
|
const options = Object.keys(headers).length > 0 ? { headers } : void 0;
|
|
10190
10191
|
await client.put(objectKey, localFile, options);
|
|
10191
10192
|
ui.success(`Uploaded ${objectKey}`);
|
|
10192
10193
|
}
|
|
10193
10194
|
/** List objects in a bucket (optionally under a prefix). */
|
|
10194
|
-
static async readJsonObject(
|
|
10195
|
+
static async readJsonObject(bucket2, objectKey) {
|
|
10195
10196
|
const cfg = loadPmateConfig();
|
|
10196
10197
|
const region = cfg.oss?.public?.region?.trim();
|
|
10197
10198
|
const accessKeyId = cfg.aliyun?.ak?.trim();
|
|
10198
10199
|
const accessKeySecret = cfg.aliyun?.sk?.trim();
|
|
10199
10200
|
if (!region || !accessKeyId || !accessKeySecret) throw new Error("Missing OSS credentials.");
|
|
10200
|
-
const client = new import_ali_oss.default({ region, accessKeyId, accessKeySecret, bucket });
|
|
10201
|
+
const client = new import_ali_oss.default({ region, accessKeyId, accessKeySecret, bucket: bucket2 });
|
|
10201
10202
|
try {
|
|
10202
10203
|
const result = await client.get(objectKey);
|
|
10203
10204
|
return JSON.parse(result.content.toString());
|
|
@@ -10206,19 +10207,34 @@ var AliyunService = class {
|
|
|
10206
10207
|
throw error;
|
|
10207
10208
|
}
|
|
10208
10209
|
}
|
|
10209
|
-
static async
|
|
10210
|
+
static async assertUnversionedBucket(bucket2) {
|
|
10211
|
+
const cfg = loadPmateConfig();
|
|
10212
|
+
const region = cfg.oss?.public?.region?.trim(), accessKeyId = cfg.aliyun?.ak?.trim(), accessKeySecret = cfg.aliyun?.sk?.trim();
|
|
10213
|
+
if (!region || !accessKeyId || !accessKeySecret) throw new Error("Missing OSS credentials.");
|
|
10214
|
+
const client = new import_ali_oss.default({ region, accessKeyId, accessKeySecret, bucket: bucket2 });
|
|
10215
|
+
const { versionStatus } = await client.getBucketVersioning(bucket2);
|
|
10216
|
+
if (versionStatus) throw new Error("HarmonyOS immutable publication requires an unversioned OSS bucket");
|
|
10217
|
+
}
|
|
10218
|
+
static async removePublicationLock(bucket2, objectKey) {
|
|
10219
|
+
if (!/^harmony\/[\w-]+\/[\w-]+\/\.publish-lock\.json$/.test(objectKey)) throw new Error("Invalid HarmonyOS publication lock key");
|
|
10220
|
+
const cfg = loadPmateConfig();
|
|
10221
|
+
const region = cfg.oss?.public?.region?.trim(), accessKeyId = cfg.aliyun?.ak?.trim(), accessKeySecret = cfg.aliyun?.sk?.trim();
|
|
10222
|
+
if (!region || !accessKeyId || !accessKeySecret) throw new Error("Missing OSS credentials.");
|
|
10223
|
+
await new import_ali_oss.default({ region, accessKeyId, accessKeySecret, bucket: bucket2 }).delete(objectKey);
|
|
10224
|
+
}
|
|
10225
|
+
static async uploadJsonObject(bucket2, objectKey, value, extraHeaders = {}) {
|
|
10210
10226
|
const cfg = loadPmateConfig();
|
|
10211
10227
|
const region = cfg.oss?.public?.region?.trim();
|
|
10212
10228
|
const accessKeyId = cfg.aliyun?.ak?.trim();
|
|
10213
10229
|
const accessKeySecret = cfg.aliyun?.sk?.trim();
|
|
10214
10230
|
if (!region || !accessKeyId || !accessKeySecret) throw new Error("Missing OSS credentials.");
|
|
10215
|
-
const client = new import_ali_oss.default({ region, accessKeyId, accessKeySecret, bucket });
|
|
10231
|
+
const client = new import_ali_oss.default({ region, accessKeyId, accessKeySecret, bucket: bucket2 });
|
|
10216
10232
|
await client.put(objectKey, Buffer.from(JSON.stringify(value)), {
|
|
10217
|
-
headers: { "Content-Type": "application/json", "Cache-Control": "no-cache, no-store, must-revalidate" }
|
|
10233
|
+
headers: { "Content-Type": "application/json", "Cache-Control": "no-cache, no-store, must-revalidate", ...extraHeaders }
|
|
10218
10234
|
});
|
|
10219
10235
|
}
|
|
10220
10236
|
/** List objects in a bucket (optionally under a prefix). */
|
|
10221
|
-
static async listObjects(
|
|
10237
|
+
static async listObjects(bucket2, prefix) {
|
|
10222
10238
|
const cfg = loadPmateConfig();
|
|
10223
10239
|
const region = cfg.oss?.public?.region?.trim();
|
|
10224
10240
|
const accessKeyId = cfg.aliyun?.ak?.trim();
|
|
@@ -10226,7 +10242,7 @@ var AliyunService = class {
|
|
|
10226
10242
|
if (!region) throw new Error("Missing oss.public.region in ~/.pmate/config.yaml.");
|
|
10227
10243
|
if (!accessKeyId) throw new Error("Missing aliyun.ak in ~/.pmate/config.yaml.");
|
|
10228
10244
|
if (!accessKeySecret) throw new Error("Missing aliyun.sk in ~/.pmate/config.yaml.");
|
|
10229
|
-
const client = new import_ali_oss.default({ region, accessKeyId, accessKeySecret, bucket });
|
|
10245
|
+
const client = new import_ali_oss.default({ region, accessKeyId, accessKeySecret, bucket: bucket2 });
|
|
10230
10246
|
const normalizedPrefix = prefix ? prefix.replace(/^\/+|\/+$/g, "") : "";
|
|
10231
10247
|
const objects = await this.listObjectsForClient(client, normalizedPrefix);
|
|
10232
10248
|
return objects.filter((item) => typeof item.name === "string" && item.name.length > 0).map((item) => ({
|
|
@@ -10248,7 +10264,7 @@ var AliyunService = class {
|
|
|
10248
10264
|
const result = await client.listBuckets({});
|
|
10249
10265
|
const buckets = Array.isArray(result) ? result : result?.buckets ?? [];
|
|
10250
10266
|
return buckets.map(
|
|
10251
|
-
(
|
|
10267
|
+
(bucket2) => typeof bucket2 === "string" ? bucket2 : bucket2.name
|
|
10252
10268
|
).filter(
|
|
10253
10269
|
(name) => typeof name === "string" && name.trim().length > 0
|
|
10254
10270
|
);
|
|
@@ -10756,8 +10772,8 @@ var StsCommandHandler = class {
|
|
|
10756
10772
|
if (!token) {
|
|
10757
10773
|
throw new Error("Missing session token. Run `pmate login` first.");
|
|
10758
10774
|
}
|
|
10759
|
-
const
|
|
10760
|
-
const response = await fetch(`${
|
|
10775
|
+
const baseUrl2 = "https://ci.pmate.chat";
|
|
10776
|
+
const response = await fetch(`${baseUrl2}/oss/sts`, {
|
|
10761
10777
|
method: "POST",
|
|
10762
10778
|
headers: {
|
|
10763
10779
|
"content-type": "application/json",
|
|
@@ -11163,17 +11179,17 @@ var OssCommandHandler = class _OssCommandHandler {
|
|
|
11163
11179
|
ui.warn("No buckets found for current access key.");
|
|
11164
11180
|
return;
|
|
11165
11181
|
}
|
|
11166
|
-
for (const
|
|
11167
|
-
ui.info(
|
|
11182
|
+
for (const bucket3 of buckets) {
|
|
11183
|
+
ui.info(bucket3);
|
|
11168
11184
|
}
|
|
11169
11185
|
return;
|
|
11170
11186
|
}
|
|
11171
11187
|
const resolvedFile = import_node_path11.default.resolve(process.cwd(), args.filePath);
|
|
11172
11188
|
this.assertFile(resolvedFile);
|
|
11173
11189
|
const objectKey = this.normalizeObjectKey(args.objectKey);
|
|
11174
|
-
const
|
|
11175
|
-
await AliyunService.uploadFile(resolvedFile,
|
|
11176
|
-
const publicUrl = buildOssPublicUrl(
|
|
11190
|
+
const bucket2 = this.resolveBucket(args.bucket);
|
|
11191
|
+
await AliyunService.uploadFile(resolvedFile, bucket2, objectKey);
|
|
11192
|
+
const publicUrl = buildOssPublicUrl(bucket2, objectKey);
|
|
11177
11193
|
if (publicUrl) {
|
|
11178
11194
|
ui.plain(publicUrl);
|
|
11179
11195
|
}
|
|
@@ -11202,8 +11218,8 @@ var OssCommandHandler = class _OssCommandHandler {
|
|
|
11202
11218
|
return _OssCommandHandler.DEFAULT_BUCKET;
|
|
11203
11219
|
}
|
|
11204
11220
|
};
|
|
11205
|
-
function buildOssPublicUrl(
|
|
11206
|
-
if (
|
|
11221
|
+
function buildOssPublicUrl(bucket2, objectKey) {
|
|
11222
|
+
if (bucket2 !== "parrot-static") return null;
|
|
11207
11223
|
const encodedKey = objectKey.split("/").map((segment) => encodeURIComponent(segment)).join("/");
|
|
11208
11224
|
return `${PARROT_STATIC_PUBLIC_BASE_URL}/${encodedKey}`;
|
|
11209
11225
|
}
|
|
@@ -11819,11 +11835,11 @@ var PrCommandHandler = class {
|
|
|
11819
11835
|
await this.run("git", ["rebase", `origin/${baseBranch}`]);
|
|
11820
11836
|
}
|
|
11821
11837
|
async ensureGitRepo() {
|
|
11822
|
-
const
|
|
11838
|
+
const inside2 = await this.runCapture("git", [
|
|
11823
11839
|
"rev-parse",
|
|
11824
11840
|
"--is-inside-work-tree"
|
|
11825
11841
|
]);
|
|
11826
|
-
if (
|
|
11842
|
+
if (inside2.trim() !== "true") {
|
|
11827
11843
|
throw new Error("This command must be run inside a git repository.");
|
|
11828
11844
|
}
|
|
11829
11845
|
}
|
|
@@ -12291,14 +12307,14 @@ var SummaryCommandHandler = class {
|
|
|
12291
12307
|
};
|
|
12292
12308
|
}
|
|
12293
12309
|
async ensureGitRepo(cwd) {
|
|
12294
|
-
const
|
|
12310
|
+
const inside2 = await this.runCapture(
|
|
12295
12311
|
"git",
|
|
12296
12312
|
["rev-parse", "--is-inside-work-tree"],
|
|
12297
12313
|
false,
|
|
12298
12314
|
void 0,
|
|
12299
12315
|
cwd
|
|
12300
12316
|
);
|
|
12301
|
-
if (
|
|
12317
|
+
if (inside2.trim() !== "true") {
|
|
12302
12318
|
throw new Error("This command must be run inside a git repository.");
|
|
12303
12319
|
}
|
|
12304
12320
|
}
|
|
@@ -13876,14 +13892,14 @@ var LinearCommandHandler = class {
|
|
|
13876
13892
|
}
|
|
13877
13893
|
}
|
|
13878
13894
|
async ensureGitRepo(cwd) {
|
|
13879
|
-
const
|
|
13895
|
+
const inside2 = await this.runCapture(
|
|
13880
13896
|
"git",
|
|
13881
13897
|
["rev-parse", "--is-inside-work-tree"],
|
|
13882
13898
|
false,
|
|
13883
13899
|
void 0,
|
|
13884
13900
|
cwd
|
|
13885
13901
|
);
|
|
13886
|
-
if (
|
|
13902
|
+
if (inside2.trim() !== "true") {
|
|
13887
13903
|
throw new Error("This command must be run inside a git repository.");
|
|
13888
13904
|
}
|
|
13889
13905
|
}
|
|
@@ -13983,10 +13999,10 @@ var LinearCommandHandler = class {
|
|
|
13983
13999
|
if (!apiKey) {
|
|
13984
14000
|
throw new Error("Missing openAI.apiKey in ~/.pmate/config.yaml.");
|
|
13985
14001
|
}
|
|
13986
|
-
const
|
|
14002
|
+
const baseUrl2 = config.openAI?.baseUrl?.trim();
|
|
13987
14003
|
return new import_openai.default({
|
|
13988
14004
|
apiKey,
|
|
13989
|
-
baseURL:
|
|
14005
|
+
baseURL: baseUrl2 ? `${baseUrl2}/v1` : void 0
|
|
13990
14006
|
});
|
|
13991
14007
|
}
|
|
13992
14008
|
getResponseText(response) {
|
|
@@ -14267,9 +14283,9 @@ ${indent}\`\`\``;
|
|
|
14267
14283
|
static richTextToPlain(richText) {
|
|
14268
14284
|
return richText.map((item) => item.plain_text ?? item.text?.content ?? "").join("").trim();
|
|
14269
14285
|
}
|
|
14270
|
-
static async requestJson(
|
|
14286
|
+
static async requestJson(path36, init) {
|
|
14271
14287
|
const token = this.getToken();
|
|
14272
|
-
const response = await fetch(`${this.baseUrl}${
|
|
14288
|
+
const response = await fetch(`${this.baseUrl}${path36}`, {
|
|
14273
14289
|
method: init.method,
|
|
14274
14290
|
headers: {
|
|
14275
14291
|
Authorization: `Bearer ${token}`,
|
|
@@ -15394,8 +15410,8 @@ var import_playwright = require("playwright");
|
|
|
15394
15410
|
// src/im1BotClient.ts
|
|
15395
15411
|
var DEFAULT_IM1_BASE_URL = "http://localhost:39223";
|
|
15396
15412
|
var Im1BotClient = class {
|
|
15397
|
-
constructor(
|
|
15398
|
-
this.baseUrl =
|
|
15413
|
+
constructor(baseUrl2 = process.env.PMATE_IM1_BASE_URL ?? DEFAULT_IM1_BASE_URL) {
|
|
15414
|
+
this.baseUrl = baseUrl2;
|
|
15399
15415
|
}
|
|
15400
15416
|
async health() {
|
|
15401
15417
|
return this.request("/health");
|
|
@@ -16838,11 +16854,11 @@ var RegistryResourceCommandHandler = class {
|
|
|
16838
16854
|
async handle(args) {
|
|
16839
16855
|
const resource = args.type === "function" ? "functions" : "workers";
|
|
16840
16856
|
const singular = args.type === "function" ? "Function" : "Worker";
|
|
16841
|
-
const
|
|
16857
|
+
const baseUrl2 = (args.baseUrl || process.env.PMATE_AGENT_API_BASE_URL || "https://agent-api.pmate.chat").replace(/\/+$/, "");
|
|
16842
16858
|
const token = readRequiredSession({ preferredApp: DEFAULT_APP_ID }).token;
|
|
16843
16859
|
if (args.action === "list") {
|
|
16844
16860
|
const query = args.namespace ? `?namespace=${encodeURIComponent(args.namespace)}` : "";
|
|
16845
|
-
const { items } = await request(
|
|
16861
|
+
const { items } = await request(baseUrl2, token, "GET", `/v1/${resource}${query}`);
|
|
16846
16862
|
if (args.json) ui.plain(JSON.stringify(items, null, 2));
|
|
16847
16863
|
else if (!items.length) ui.warn(`No ${resource} found.`);
|
|
16848
16864
|
else for (const item of items) ui.info(item.id, { status: item.status, ...item.payload });
|
|
@@ -16850,18 +16866,18 @@ var RegistryResourceCommandHandler = class {
|
|
|
16850
16866
|
}
|
|
16851
16867
|
const resourcePath = `/v1/${resource}/${encodeURIComponent(args.namespace)}${args.action === "create" ? "" : `/${encodeURIComponent(args.name)}`}`;
|
|
16852
16868
|
if (args.action === "get" || args.action === "view") {
|
|
16853
|
-
const record2 = await request(
|
|
16869
|
+
const record2 = await request(baseUrl2, token, "GET", resourcePath);
|
|
16854
16870
|
ui.plain(JSON.stringify(record2, null, 2));
|
|
16855
16871
|
return;
|
|
16856
16872
|
}
|
|
16857
16873
|
if (args.action === "create" || args.action === "update") {
|
|
16858
16874
|
const payload = readJson(args.filePath);
|
|
16859
|
-
const record2 = await request(
|
|
16875
|
+
const record2 = await request(baseUrl2, token, args.action === "create" ? "POST" : "PUT", resourcePath, payload);
|
|
16860
16876
|
ui.success(`${args.action === "create" ? "Created" : "Updated"} ${singular.toLowerCase()} ${record2.id}`);
|
|
16861
16877
|
if (args.json) ui.plain(JSON.stringify(record2, null, 2));
|
|
16862
16878
|
return;
|
|
16863
16879
|
}
|
|
16864
|
-
const record = await request(
|
|
16880
|
+
const record = await request(baseUrl2, token, "DELETE", resourcePath);
|
|
16865
16881
|
ui.success(`Disabled ${singular.toLowerCase()} ${record.id}`);
|
|
16866
16882
|
if (args.json) ui.plain(JSON.stringify(record, null, 2));
|
|
16867
16883
|
}
|
|
@@ -16871,8 +16887,8 @@ function readJson(filePath) {
|
|
|
16871
16887
|
if (!(0, import_node_fs15.existsSync)(absolutePath)) throw new Error(`JSON file not found: ${absolutePath}`);
|
|
16872
16888
|
return JSON.parse((0, import_node_fs15.readFileSync)(absolutePath, "utf8"));
|
|
16873
16889
|
}
|
|
16874
|
-
async function request(
|
|
16875
|
-
const response = await fetch(`${
|
|
16890
|
+
async function request(baseUrl2, token, method, pathname, body) {
|
|
16891
|
+
const response = await fetch(`${baseUrl2}${pathname}`, {
|
|
16876
16892
|
method,
|
|
16877
16893
|
headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json" },
|
|
16878
16894
|
...body === void 0 ? {} : { body: JSON.stringify(body) }
|
|
@@ -16973,9 +16989,9 @@ function descriptorPathSegments(descriptor) {
|
|
|
16973
16989
|
const normalized = createDescriptor(descriptor);
|
|
16974
16990
|
return ["chains", normalized.chain, "namespaces", normalized.ns, normalized.kind, normalized.name];
|
|
16975
16991
|
}
|
|
16976
|
-
function buildPathUrl(
|
|
16977
|
-
const
|
|
16978
|
-
const url = new URL(
|
|
16992
|
+
function buildPathUrl(baseUrl2, pathSegments, query) {
|
|
16993
|
+
const path36 = `/${pathSegments.map((segment) => encodeURIComponent(segment)).join("/")}`;
|
|
16994
|
+
const url = new URL(path36, baseUrl2);
|
|
16979
16995
|
if (query) {
|
|
16980
16996
|
for (const [key, value] of Object.entries(query)) {
|
|
16981
16997
|
url.searchParams.set(key, String(value));
|
|
@@ -16999,8 +17015,8 @@ function normalizeNamespace(value) {
|
|
|
16999
17015
|
return normalized;
|
|
17000
17016
|
}
|
|
17001
17017
|
var IndexerClient = class {
|
|
17002
|
-
constructor(
|
|
17003
|
-
this.baseUrl =
|
|
17018
|
+
constructor(baseUrl2, headers = {}) {
|
|
17019
|
+
this.baseUrl = baseUrl2;
|
|
17004
17020
|
this.headers = headers;
|
|
17005
17021
|
}
|
|
17006
17022
|
async requestByPath(pathSegments, options = {}) {
|
|
@@ -17023,9 +17039,9 @@ var IndexerClient = class {
|
|
|
17023
17039
|
}
|
|
17024
17040
|
};
|
|
17025
17041
|
var BlockLogAppender = class {
|
|
17026
|
-
constructor(chainId,
|
|
17042
|
+
constructor(chainId, baseUrl2, headers = {}) {
|
|
17027
17043
|
this.chainId = chainId;
|
|
17028
|
-
this.baseUrl =
|
|
17044
|
+
this.baseUrl = baseUrl2;
|
|
17029
17045
|
this.headers = headers;
|
|
17030
17046
|
}
|
|
17031
17047
|
async append(logs) {
|
|
@@ -17288,8 +17304,8 @@ var NsCommandHandler = class {
|
|
|
17288
17304
|
}
|
|
17289
17305
|
}
|
|
17290
17306
|
}
|
|
17291
|
-
resolveBaseUrl(
|
|
17292
|
-
return (
|
|
17307
|
+
resolveBaseUrl(baseUrl2) {
|
|
17308
|
+
return (baseUrl2 || process.env.PMATE_NAMESPACE_API_BASE_URL || process.env.PMATE_APPS_API_BASE_URL || "https://apps-api.pmate.chat").replace(/\/+$/, "");
|
|
17293
17309
|
}
|
|
17294
17310
|
resolveAuthHeaders() {
|
|
17295
17311
|
return {
|
|
@@ -17433,8 +17449,8 @@ var StoreCommandHandler = class {
|
|
|
17433
17449
|
const token = readRequiredSession({ preferredApp: DEFAULT_APP_ID }).token;
|
|
17434
17450
|
return { Authorization: `Bearer ${token}` };
|
|
17435
17451
|
}
|
|
17436
|
-
resolveBaseUrl(
|
|
17437
|
-
const resolved =
|
|
17452
|
+
resolveBaseUrl(baseUrl2) {
|
|
17453
|
+
const resolved = baseUrl2 || process.env.PMATE_STORE_BASE_URL || process.env.BLOCKCHAIN_BASE_URL;
|
|
17438
17454
|
if (!resolved) {
|
|
17439
17455
|
throw new Error(
|
|
17440
17456
|
"Missing store base URL. Provide --base-url or set PMATE_STORE_BASE_URL / BLOCKCHAIN_BASE_URL."
|
|
@@ -17465,8 +17481,8 @@ var StoreCommandHandler = class {
|
|
|
17465
17481
|
return args.action === "set" || args.action === "delete";
|
|
17466
17482
|
}
|
|
17467
17483
|
async listNamespaces(args) {
|
|
17468
|
-
const
|
|
17469
|
-
const url = new URL(`/chains/${encodeURIComponent(args.chain)}/namespaces`, `${
|
|
17484
|
+
const baseUrl2 = this.resolveIndexerBaseUrl(args.indexerBaseUrl);
|
|
17485
|
+
const url = new URL(`/chains/${encodeURIComponent(args.chain)}/namespaces`, `${baseUrl2}/`);
|
|
17470
17486
|
const response = await fetch(url.toString(), {
|
|
17471
17487
|
headers: {
|
|
17472
17488
|
Accept: "application/json",
|
|
@@ -17908,11 +17924,11 @@ init_namespacedRef();
|
|
|
17908
17924
|
var AppCommandHandler = class {
|
|
17909
17925
|
async handle(args) {
|
|
17910
17926
|
const token = this.readToken();
|
|
17911
|
-
const
|
|
17927
|
+
const baseUrl2 = this.resolveBaseUrl(args.baseUrl);
|
|
17912
17928
|
switch (args.action) {
|
|
17913
17929
|
case "list": {
|
|
17914
17930
|
const response = await this.request(
|
|
17915
|
-
|
|
17931
|
+
baseUrl2,
|
|
17916
17932
|
token,
|
|
17917
17933
|
"GET",
|
|
17918
17934
|
"/apps"
|
|
@@ -17930,7 +17946,7 @@ var AppCommandHandler = class {
|
|
|
17930
17946
|
case "view": {
|
|
17931
17947
|
const pathname = this.buildAppPath(args.id);
|
|
17932
17948
|
const record = await this.request(
|
|
17933
|
-
|
|
17949
|
+
baseUrl2,
|
|
17934
17950
|
token,
|
|
17935
17951
|
"GET",
|
|
17936
17952
|
pathname
|
|
@@ -17944,9 +17960,9 @@ var AppCommandHandler = class {
|
|
|
17944
17960
|
}
|
|
17945
17961
|
case "create": {
|
|
17946
17962
|
const payload = await this.preparePayload(args.filePath);
|
|
17947
|
-
await this.requireNamespace(payload,
|
|
17963
|
+
await this.requireNamespace(payload, baseUrl2);
|
|
17948
17964
|
const record = await this.request(
|
|
17949
|
-
|
|
17965
|
+
baseUrl2,
|
|
17950
17966
|
token,
|
|
17951
17967
|
"POST",
|
|
17952
17968
|
"/apps",
|
|
@@ -17960,7 +17976,7 @@ var AppCommandHandler = class {
|
|
|
17960
17976
|
const payload = await this.preparePayload(args.filePath, args.id);
|
|
17961
17977
|
const pathname = this.buildAppPath(args.id);
|
|
17962
17978
|
const record = await this.request(
|
|
17963
|
-
|
|
17979
|
+
baseUrl2,
|
|
17964
17980
|
token,
|
|
17965
17981
|
"PUT",
|
|
17966
17982
|
pathname,
|
|
@@ -17972,7 +17988,7 @@ var AppCommandHandler = class {
|
|
|
17972
17988
|
}
|
|
17973
17989
|
case "icon": {
|
|
17974
17990
|
const record = await this.request(
|
|
17975
|
-
|
|
17991
|
+
baseUrl2,
|
|
17976
17992
|
token,
|
|
17977
17993
|
"GET",
|
|
17978
17994
|
this.buildAppPath(args.id)
|
|
@@ -18006,7 +18022,7 @@ var AppCommandHandler = class {
|
|
|
18006
18022
|
case "icon-add": {
|
|
18007
18023
|
const pathname = this.buildAppPath(args.id);
|
|
18008
18024
|
const record = await this.request(
|
|
18009
|
-
|
|
18025
|
+
baseUrl2,
|
|
18010
18026
|
token,
|
|
18011
18027
|
"GET",
|
|
18012
18028
|
pathname
|
|
@@ -18028,7 +18044,7 @@ var AppCommandHandler = class {
|
|
|
18028
18044
|
[name]: source.value
|
|
18029
18045
|
};
|
|
18030
18046
|
const updatedRecord = await this.request(
|
|
18031
|
-
|
|
18047
|
+
baseUrl2,
|
|
18032
18048
|
token,
|
|
18033
18049
|
"PUT",
|
|
18034
18050
|
pathname,
|
|
@@ -18052,7 +18068,7 @@ var AppCommandHandler = class {
|
|
|
18052
18068
|
case "delete": {
|
|
18053
18069
|
const pathname = this.buildAppPath(args.id);
|
|
18054
18070
|
const record = await this.request(
|
|
18055
|
-
|
|
18071
|
+
baseUrl2,
|
|
18056
18072
|
token,
|
|
18057
18073
|
"DELETE",
|
|
18058
18074
|
pathname
|
|
@@ -18063,7 +18079,7 @@ var AppCommandHandler = class {
|
|
|
18063
18079
|
}
|
|
18064
18080
|
case "rename": {
|
|
18065
18081
|
const record = await this.request(
|
|
18066
|
-
|
|
18082
|
+
baseUrl2,
|
|
18067
18083
|
token,
|
|
18068
18084
|
"POST",
|
|
18069
18085
|
`/apps/${encodeURIComponent(args.namespace)}/rename`,
|
|
@@ -18080,7 +18096,7 @@ var AppCommandHandler = class {
|
|
|
18080
18096
|
}
|
|
18081
18097
|
case "move": {
|
|
18082
18098
|
const record = await this.request(
|
|
18083
|
-
|
|
18099
|
+
baseUrl2,
|
|
18084
18100
|
token,
|
|
18085
18101
|
"POST",
|
|
18086
18102
|
`/apps/${encodeURIComponent(args.namespace)}/move`,
|
|
@@ -18098,8 +18114,8 @@ var AppCommandHandler = class {
|
|
|
18098
18114
|
}
|
|
18099
18115
|
}
|
|
18100
18116
|
}
|
|
18101
|
-
resolveBaseUrl(
|
|
18102
|
-
return (
|
|
18117
|
+
resolveBaseUrl(baseUrl2) {
|
|
18118
|
+
return (baseUrl2 || process.env.PMATE_APPS_API_BASE_URL || "https://apps-api.pmate.chat").replace(/\/+$/, "");
|
|
18103
18119
|
}
|
|
18104
18120
|
readToken() {
|
|
18105
18121
|
return readRequiredSession({
|
|
@@ -18126,8 +18142,8 @@ var AppCommandHandler = class {
|
|
|
18126
18142
|
resolveFilePath(filePath) {
|
|
18127
18143
|
return import_node_path24.default.resolve(process.cwd(), filePath);
|
|
18128
18144
|
}
|
|
18129
|
-
async request(
|
|
18130
|
-
const response = await fetch(`${
|
|
18145
|
+
async request(baseUrl2, token, method, pathname, body) {
|
|
18146
|
+
const response = await fetch(`${baseUrl2}${pathname}`, {
|
|
18131
18147
|
method,
|
|
18132
18148
|
headers: {
|
|
18133
18149
|
Authorization: `Bearer ${token}`,
|
|
@@ -18146,11 +18162,11 @@ var AppCommandHandler = class {
|
|
|
18146
18162
|
}
|
|
18147
18163
|
return payload.data;
|
|
18148
18164
|
}
|
|
18149
|
-
async requireNamespace(payload,
|
|
18165
|
+
async requireNamespace(payload, baseUrl2) {
|
|
18150
18166
|
const namespace = readNamespaceFromPayload(payload);
|
|
18151
18167
|
const registry = new NamespaceRegistry({
|
|
18152
18168
|
chain: "pmate",
|
|
18153
|
-
registryBaseUrl:
|
|
18169
|
+
registryBaseUrl: baseUrl2
|
|
18154
18170
|
});
|
|
18155
18171
|
const exists = await registry.exists(namespace);
|
|
18156
18172
|
if (!exists) {
|
|
@@ -18244,15 +18260,15 @@ function readNamespaceFromPayload(payload) {
|
|
|
18244
18260
|
}
|
|
18245
18261
|
|
|
18246
18262
|
// src/commands/ServiceCommandHandler.ts
|
|
18247
|
-
var
|
|
18263
|
+
var import_node_fs27 = require("fs");
|
|
18248
18264
|
var import_promises5 = require("fs/promises");
|
|
18249
|
-
var
|
|
18250
|
-
var
|
|
18265
|
+
var import_node_path32 = __toESM(require("path"));
|
|
18266
|
+
var import_node_child_process14 = require("child_process");
|
|
18251
18267
|
var import_promises6 = require("readline/promises");
|
|
18252
18268
|
|
|
18253
18269
|
// src/services/NativeServiceDeploy.ts
|
|
18254
|
-
var
|
|
18255
|
-
var
|
|
18270
|
+
var import_node_path30 = __toESM(require("path"));
|
|
18271
|
+
var import_node_fs25 = require("fs");
|
|
18256
18272
|
|
|
18257
18273
|
// src/electronBuild.ts
|
|
18258
18274
|
var import_node_child_process9 = require("child_process");
|
|
@@ -18270,7 +18286,7 @@ async function uploadDesktopArtifacts(directory, app, version, platform, arch) {
|
|
|
18270
18286
|
if (app.split(":").length !== 2 || segments.some((s) => !/^[\w.-]+$/.test(s) || s === "." || s === "..")) throw new Error("Invalid desktop release identity");
|
|
18271
18287
|
if (!["mac", "win"].includes(platform) || !["arm64", "x64"].includes(arch) || !/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/.test(version)) throw new Error("Desktop publication requires a stable version and supported target");
|
|
18272
18288
|
const { token } = readRequiredSession({ preferredApp: DEFAULT_APP_ID });
|
|
18273
|
-
const
|
|
18289
|
+
const bucket2 = "parrot-static";
|
|
18274
18290
|
const prefix = `desktop/${segments.join("/")}/`;
|
|
18275
18291
|
const url = (key) => `https://parrot-static.pmate.chat/${key.split("/").map(encodeURIComponent).join("/")}`;
|
|
18276
18292
|
const artifacts = (0, import_node_fs20.readdirSync)(directory, { withFileTypes: true }).filter((entry) => entry.isFile() && (platform === "mac" ? /\.(dmg|zip)$/i : /\.(exe|zip)$/i).test(entry.name)).sort((a, b) => a.name.localeCompare(b.name)).map((entry) => {
|
|
@@ -18280,11 +18296,11 @@ async function uploadDesktopArtifacts(directory, app, version, platform, arch) {
|
|
|
18280
18296
|
});
|
|
18281
18297
|
if (!artifacts.length) throw new Error("No desktop installers found to publish");
|
|
18282
18298
|
const manifestKey = prefix + "release.json";
|
|
18283
|
-
const existing = await AliyunService.readJsonObject(
|
|
18299
|
+
const existing = await AliyunService.readJsonObject(bucket2, manifestKey);
|
|
18284
18300
|
const release = { schemaVersion: 1, app, version, platform, arch, artifacts };
|
|
18285
18301
|
if (existing !== null && JSON.stringify(existing) !== JSON.stringify(release)) throw new Error("Desktop release already exists with different artifacts; bump the app version");
|
|
18286
|
-
for (const artifact of artifacts) await AliyunService.uploadFile(import_node_path25.default.join(directory, artifact.name),
|
|
18287
|
-
await AliyunService.uploadJsonObject(
|
|
18302
|
+
for (const artifact of artifacts) await AliyunService.uploadFile(import_node_path25.default.join(directory, artifact.name), bucket2, artifact.objectKey);
|
|
18303
|
+
await AliyunService.uploadJsonObject(bucket2, manifestKey, release);
|
|
18288
18304
|
const base = (process.env.PMATE_APPS_API_BASE_URL || "https://apps-api.pmate.chat").replace(/\/+$/, "");
|
|
18289
18305
|
const response = await fetch(`${base}/versions/${encodeURIComponent(app)}`, {
|
|
18290
18306
|
method: "POST",
|
|
@@ -18295,7 +18311,7 @@ async function uploadDesktopArtifacts(directory, app, version, platform, arch) {
|
|
|
18295
18311
|
});
|
|
18296
18312
|
const result = await response.json();
|
|
18297
18313
|
if (!response.ok || result.success !== true) throw new Error(`Installers uploaded but version registration failed: ${result.message || response.status}. Retry this release before announcing it.`);
|
|
18298
|
-
return { bucket, manifestUrl: url(manifestKey), downloads: artifacts };
|
|
18314
|
+
return { bucket: bucket2, manifestUrl: url(manifestKey), downloads: artifacts };
|
|
18299
18315
|
}
|
|
18300
18316
|
|
|
18301
18317
|
// src/electronBuild.ts
|
|
@@ -18964,12 +18980,293 @@ function capitalize(value) {
|
|
|
18964
18980
|
return value.slice(0, 1).toUpperCase() + value.slice(1);
|
|
18965
18981
|
}
|
|
18966
18982
|
|
|
18967
|
-
// src/services/
|
|
18983
|
+
// src/services/HarmonyReleaseService.ts
|
|
18968
18984
|
var import_node_child_process11 = require("child_process");
|
|
18969
18985
|
var import_node_crypto6 = require("crypto");
|
|
18970
18986
|
var import_node_fs23 = require("fs");
|
|
18971
18987
|
var import_node_os12 = __toESM(require("os"));
|
|
18972
18988
|
var import_node_path28 = __toESM(require("path"));
|
|
18989
|
+
var import_json5 = __toESM(require("json5"));
|
|
18990
|
+
var HARMONY_SIGNING_KEYS = ["HARMONY_KEYSTORE_BASE64", "HARMONY_CERTIFICATE_BASE64", "HARMONY_PROFILE_BASE64", "HARMONY_STORE_PASSWORD", "HARMONY_KEY_ALIAS", "HARMONY_KEY_PASSWORD"];
|
|
18991
|
+
var bucket = "parrot-static";
|
|
18992
|
+
var baseUrl = "https://parrot-static.pmate.chat";
|
|
18993
|
+
var inside = (parent, child) => {
|
|
18994
|
+
const rel = import_node_path28.default.relative(parent, child);
|
|
18995
|
+
return !rel || !rel.startsWith(`..${import_node_path28.default.sep}`) && rel !== ".." && !import_node_path28.default.isAbsolute(rel);
|
|
18996
|
+
};
|
|
18997
|
+
var readJson5 = (file) => import_json5.default.parse((0, import_node_fs23.readFileSync)(file, "utf8"));
|
|
18998
|
+
function readHarmonyVersion(appDir, expected) {
|
|
18999
|
+
const app = readJson5(import_node_path28.default.join(appDir, "AppScope/app.json5")).app;
|
|
19000
|
+
if (!app || app.bundleName !== expected) throw new Error("HarmonyOS bundleName does not match service.mobile.bundleName");
|
|
19001
|
+
if (!/^\d+\.\d+\.\d+$/.test(app.versionName ?? "") || !Number.isSafeInteger(app.versionCode) || app.versionCode <= 0) throw new Error("HarmonyOS source requires a stable versionName and positive integer versionCode");
|
|
19002
|
+
return { bundleName: app.bundleName, versionName: app.versionName, versionCode: app.versionCode };
|
|
19003
|
+
}
|
|
19004
|
+
function stageHarmonySources(repoRoot, appDir, target) {
|
|
19005
|
+
const copied = [];
|
|
19006
|
+
const excluded = /* @__PURE__ */ new Set([".git", "node_modules", "oh_modules", ".hvigor", ".idea", "build", "dist", ".gradle", "local.properties"]);
|
|
19007
|
+
const copy = (source) => {
|
|
19008
|
+
if (!inside(repoRoot, source)) throw new Error("HarmonyOS local dependencies must stay inside the repository");
|
|
19009
|
+
if (copied.some((dir) => inside(dir, source))) return;
|
|
19010
|
+
if (!(0, import_node_fs23.existsSync)(source) || !(0, import_node_fs23.lstatSync)(source).isDirectory() || (0, import_node_fs23.lstatSync)(source).isSymbolicLink()) throw new Error("Invalid HarmonyOS source dependency");
|
|
19011
|
+
if (!inside((0, import_node_fs23.realpathSync)(repoRoot), (0, import_node_fs23.realpathSync)(source))) throw new Error("HarmonyOS local dependencies must stay inside the repository");
|
|
19012
|
+
const dest = import_node_path28.default.join(target, import_node_path28.default.relative(repoRoot, source));
|
|
19013
|
+
(0, import_node_fs23.cpSync)(source, dest, { recursive: true, filter: (file) => {
|
|
19014
|
+
if ((0, import_node_fs23.lstatSync)(file).isSymbolicLink()) throw new Error("HarmonyOS source symlinks are not supported");
|
|
19015
|
+
const name = import_node_path28.default.basename(file);
|
|
19016
|
+
return !excluded.has(name) && !name.startsWith(".env") && !/\.(p12|pfx|p7b|keystore|jks|key|pem|cer)$/i.test(name);
|
|
19017
|
+
} });
|
|
19018
|
+
copied.push(source);
|
|
19019
|
+
const inspect = (dir) => {
|
|
19020
|
+
for (const entry of (0, import_node_fs23.readdirSync)(dir, { withFileTypes: true })) {
|
|
19021
|
+
const file = import_node_path28.default.join(dir, entry.name);
|
|
19022
|
+
if (entry.isDirectory()) inspect(file);
|
|
19023
|
+
else if (entry.name === "oh-package.json5") {
|
|
19024
|
+
const manifest = readJson5(file);
|
|
19025
|
+
for (const value of Object.values({ ...manifest.dependencies, ...manifest.devDependencies })) {
|
|
19026
|
+
if (typeof value !== "string" || !value.startsWith("file:")) continue;
|
|
19027
|
+
const original = import_node_path28.default.join(repoRoot, import_node_path28.default.relative(target, import_node_path28.default.dirname(file)));
|
|
19028
|
+
copy(import_node_path28.default.resolve(original, value.slice(5)));
|
|
19029
|
+
}
|
|
19030
|
+
}
|
|
19031
|
+
}
|
|
19032
|
+
};
|
|
19033
|
+
inspect(dest);
|
|
19034
|
+
};
|
|
19035
|
+
copy(appDir);
|
|
19036
|
+
const profile = readJson5(import_node_path28.default.join(appDir, "build-profile.json5"));
|
|
19037
|
+
for (const module2 of profile.modules ?? []) {
|
|
19038
|
+
if (typeof module2.srcPath !== "string") throw new Error("Invalid HarmonyOS module srcPath");
|
|
19039
|
+
copy(import_node_path28.default.resolve(appDir, module2.srcPath));
|
|
19040
|
+
}
|
|
19041
|
+
return import_node_path28.default.join(target, import_node_path28.default.relative(repoRoot, appDir));
|
|
19042
|
+
}
|
|
19043
|
+
function executable(value) {
|
|
19044
|
+
const candidates = value.includes(import_node_path28.default.sep) ? [import_node_path28.default.resolve(value)] : (process.env.PATH ?? "").split(import_node_path28.default.delimiter).map((dir) => import_node_path28.default.join(dir, value));
|
|
19045
|
+
for (const file of candidates) {
|
|
19046
|
+
try {
|
|
19047
|
+
(0, import_node_fs23.accessSync)(file, import_node_fs23.constants.X_OK);
|
|
19048
|
+
if ((0, import_node_fs23.lstatSync)(file).isFile() || (0, import_node_fs23.lstatSync)(file).isSymbolicLink()) return file;
|
|
19049
|
+
} catch {
|
|
19050
|
+
}
|
|
19051
|
+
}
|
|
19052
|
+
throw new Error(`HarmonyOS tool is missing: ${value}; configure the DevEco build toolchain`);
|
|
19053
|
+
}
|
|
19054
|
+
function findHarmonyTools() {
|
|
19055
|
+
if (!["darwin", "linux"].includes(process.platform)) throw new Error("HarmonyOS release scripts require macOS or Linux");
|
|
19056
|
+
const home = "/Applications/DevEco-Studio.app/Contents";
|
|
19057
|
+
const sdk = import_node_path28.default.resolve(process.env.DEVECO_SDK_HOME ?? `${home}/sdk`);
|
|
19058
|
+
if (!(0, import_node_fs23.existsSync)(sdk)) throw new Error("HarmonyOS SDK not found; install DevEco Studio or set DEVECO_SDK_HOME");
|
|
19059
|
+
const tools = { sdk, ohpm: executable(process.env.OHPM_BIN ?? `${home}/tools/ohpm/bin/ohpm`), hvigor: executable(process.env.HVIGORW_BIN ?? `${home}/tools/hvigor/bin/hvigorw`), node: executable(process.env.NODE_BIN ?? process.execPath), java: executable(process.env.JAVA_BIN ?? "java"), signer: process.env.HAP_SIGN_TOOL ?? "" };
|
|
19060
|
+
if (!tools.signer) {
|
|
19061
|
+
const jars = [];
|
|
19062
|
+
const scan = (dir) => {
|
|
19063
|
+
for (const entry of (0, import_node_fs23.readdirSync)(dir, { withFileTypes: true })) {
|
|
19064
|
+
const file = import_node_path28.default.join(dir, entry.name);
|
|
19065
|
+
if (entry.isDirectory()) scan(file);
|
|
19066
|
+
else if (entry.isFile() && entry.name === "hap-sign-tool.jar") jars.push(file);
|
|
19067
|
+
}
|
|
19068
|
+
};
|
|
19069
|
+
scan(sdk);
|
|
19070
|
+
if (jars.length !== 1) throw new Error("Set HAP_SIGN_TOOL to the intended hap-sign-tool.jar");
|
|
19071
|
+
tools.signer = jars[0];
|
|
19072
|
+
}
|
|
19073
|
+
tools.signer = import_node_path28.default.resolve(tools.signer);
|
|
19074
|
+
if (!(0, import_node_fs23.existsSync)(tools.signer)) throw new Error("HAP_SIGN_TOOL does not exist");
|
|
19075
|
+
executable("bash");
|
|
19076
|
+
executable("unzip");
|
|
19077
|
+
return tools;
|
|
19078
|
+
}
|
|
19079
|
+
var runHarmonyCommand = async (command, args, options) => {
|
|
19080
|
+
const log = (0, import_node_fs23.openSync)(options.log, "a", 384);
|
|
19081
|
+
const output = options.output ? (0, import_node_fs23.openSync)(options.output, "w", 384) : void 0;
|
|
19082
|
+
try {
|
|
19083
|
+
return await new Promise((resolve, reject) => {
|
|
19084
|
+
const child = (0, import_node_child_process11.spawn)(command, args, { cwd: options.cwd, env: options.env, detached: process.platform !== "win32", stdio: ["ignore", output ?? (options.capture ? "pipe" : log), log] });
|
|
19085
|
+
let text = "", oversized = false;
|
|
19086
|
+
child.stdout?.on("data", (chunk) => {
|
|
19087
|
+
if (Buffer.byteLength(text) + chunk.length > 1024 * 1024) {
|
|
19088
|
+
oversized = true;
|
|
19089
|
+
child.kill();
|
|
19090
|
+
} else text += chunk.toString();
|
|
19091
|
+
});
|
|
19092
|
+
const interrupt = () => {
|
|
19093
|
+
try {
|
|
19094
|
+
if (process.platform !== "win32" && child.pid) process.kill(-child.pid, "SIGTERM");
|
|
19095
|
+
else child.kill("SIGTERM");
|
|
19096
|
+
} catch {
|
|
19097
|
+
}
|
|
19098
|
+
};
|
|
19099
|
+
process.once("SIGINT", interrupt);
|
|
19100
|
+
process.once("SIGTERM", interrupt);
|
|
19101
|
+
const clean = () => {
|
|
19102
|
+
process.removeListener("SIGINT", interrupt);
|
|
19103
|
+
process.removeListener("SIGTERM", interrupt);
|
|
19104
|
+
};
|
|
19105
|
+
child.once("error", () => {
|
|
19106
|
+
clean();
|
|
19107
|
+
reject(new Error(`Cannot run ${import_node_path28.default.basename(command)}; see ${options.log}`));
|
|
19108
|
+
});
|
|
19109
|
+
child.once("close", (code) => {
|
|
19110
|
+
clean();
|
|
19111
|
+
code === 0 && !oversized ? resolve(text) : reject(new Error(`HarmonyOS ${import_node_path28.default.basename(command)} failed (${code}); see ${options.log}`));
|
|
19112
|
+
});
|
|
19113
|
+
});
|
|
19114
|
+
} finally {
|
|
19115
|
+
(0, import_node_fs23.closeSync)(log);
|
|
19116
|
+
if (output !== void 0) (0, import_node_fs23.closeSync)(output);
|
|
19117
|
+
}
|
|
19118
|
+
};
|
|
19119
|
+
function signingMaterial(values) {
|
|
19120
|
+
for (const key of HARMONY_SIGNING_KEYS) if (!values[key]?.trim()) throw new Error(`Missing HarmonyOS service signing variable: ${key}`);
|
|
19121
|
+
const decode2 = (key) => {
|
|
19122
|
+
const text = values[key].replace(/\s/g, ""), bytes = Buffer.from(text, "base64");
|
|
19123
|
+
if (!bytes.length || bytes.length > 5 * 1024 * 1024 || bytes.toString("base64") !== text) throw new Error(`Invalid HarmonyOS signing material: ${key}`);
|
|
19124
|
+
return bytes;
|
|
19125
|
+
};
|
|
19126
|
+
const certificate = decode2("HARMONY_CERTIFICATE_BASE64");
|
|
19127
|
+
const fingerprint = new import_node_crypto6.X509Certificate(certificate).fingerprint256.replace(/:/g, "");
|
|
19128
|
+
return { keystore: decode2("HARMONY_KEYSTORE_BASE64"), certificate, profile: decode2("HARMONY_PROFILE_BASE64"), fingerprint };
|
|
19129
|
+
}
|
|
19130
|
+
function assertHarmonyMetadata(raw, version) {
|
|
19131
|
+
const data = raw;
|
|
19132
|
+
if (!data?.app || data.app.bundleName !== version.bundleName || data.app.versionName !== version.versionName || data.app.versionCode !== version.versionCode || data.app.debug !== void 0 && data.app.debug !== false || data.module?.debug !== void 0 && data.module.debug !== false) throw new Error("HarmonyOS package identity/version/debug metadata mismatch");
|
|
19133
|
+
}
|
|
19134
|
+
var withHarmonyPublicationLock = async (bucket2, key, publish) => {
|
|
19135
|
+
if (!/^harmony\/[\w-]+\/[\w-]+\/\.publish-lock\.json$/.test(key)) throw new Error("Invalid HarmonyOS publication lock key");
|
|
19136
|
+
await AliyunService.assertUnversionedBucket(bucket2);
|
|
19137
|
+
const owner = (0, import_node_crypto6.randomUUID)();
|
|
19138
|
+
try {
|
|
19139
|
+
await AliyunService.uploadJsonObject(bucket2, key, { owner, createdAt: (/* @__PURE__ */ new Date()).toISOString() }, { "x-oss-forbid-overwrite": "true" });
|
|
19140
|
+
} catch {
|
|
19141
|
+
throw new Error("HarmonyOS publication is locked or the lock cannot be created; verify the active publisher before clearing a stale lock");
|
|
19142
|
+
}
|
|
19143
|
+
try {
|
|
19144
|
+
return await publish();
|
|
19145
|
+
} finally {
|
|
19146
|
+
const lock = await AliyunService.readJsonObject(bucket2, key);
|
|
19147
|
+
if (lock?.owner !== owner) throw new Error("HarmonyOS publication lock ownership changed; refusing to delete another publisher's lock");
|
|
19148
|
+
await AliyunService.removePublicationLock(bucket2, key);
|
|
19149
|
+
}
|
|
19150
|
+
};
|
|
19151
|
+
var HarmonyReleaseService = class {
|
|
19152
|
+
constructor(registry, deps = {}) {
|
|
19153
|
+
this.registry = registry;
|
|
19154
|
+
this.deps = deps;
|
|
19155
|
+
}
|
|
19156
|
+
async release(service, options) {
|
|
19157
|
+
if (!("type" in service) || service.type !== "harmonyos" || !service.mobile || !("bundleName" in service.mobile)) throw new Error("HarmonyOS requires service.mobile.bundleName");
|
|
19158
|
+
if (service.appIds?.length !== 1) throw new Error("HarmonyOS service requires exactly one appIds application identity");
|
|
19159
|
+
const application = service.appIds[0];
|
|
19160
|
+
const root = options.cwd ? import_node_path28.default.resolve(options.cwd) : resolveRepositoryLocalRoot(service.repository ?? service.mobile.repository ?? "");
|
|
19161
|
+
const dir = service.dir ?? service.mobile.dir;
|
|
19162
|
+
if (!dir) throw new Error("HarmonyOS service requires a source directory");
|
|
19163
|
+
const appDir = import_node_path28.default.resolve(root, dir);
|
|
19164
|
+
if (!inside(root, appDir)) throw new Error("HarmonyOS source must stay inside the repository");
|
|
19165
|
+
const version = readHarmonyVersion(appDir, service.mobile.bundleName);
|
|
19166
|
+
const script = service.build?.script ?? "scripts/build-release.sh";
|
|
19167
|
+
if (import_node_path28.default.isAbsolute(script) || !inside(appDir, import_node_path28.default.resolve(appDir, script)) || (!(0, import_node_fs23.existsSync)(import_node_path28.default.resolve(appDir, script)) || !(0, import_node_fs23.lstatSync)(import_node_path28.default.resolve(appDir, script)).isFile())) throw new Error("HarmonyOS build.script must name an existing script inside the application");
|
|
19168
|
+
const prefix = `harmony/${service.namespace}/${service.name}`;
|
|
19169
|
+
if (![service.namespace, service.name].every((v) => /^[\w-]+$/.test(v))) throw new Error("Invalid HarmonyOS service identity");
|
|
19170
|
+
const releasePrefix = `${prefix}/${version.versionName}/${version.versionCode}/`;
|
|
19171
|
+
const manifestUrl = `${baseUrl}/${releasePrefix}release.json`, latestUrl = `${baseUrl}/${prefix}/latest.json`;
|
|
19172
|
+
const plan = { serviceId: service.id, app: application, type: "harmonyos", ...version, appDir, script, manifestUrl, latestUrl, distribution: "oss", appGallerySubmitted: false };
|
|
19173
|
+
if (options.dryRun) return { ...plan, status: "dry-run" };
|
|
19174
|
+
const tools = (this.deps.tools ?? findHarmonyTools)();
|
|
19175
|
+
const read = this.deps.readJson ?? AliyunService.readJsonObject;
|
|
19176
|
+
if (!options.local) {
|
|
19177
|
+
const latest = await read(bucket, `${prefix}/latest.json`);
|
|
19178
|
+
if (latest && (latest.serviceId !== service.id || latest.app !== application || latest.bundleName !== version.bundleName || latest.schemaVersion !== 1 || latest.platform !== "harmonyos" || latest.signature !== "verified" || !Number.isSafeInteger(latest.versionCode) || latest.versionCode <= 0)) throw new Error("Invalid existing HarmonyOS update manifest");
|
|
19179
|
+
if (latest && latest.versionCode >= version.versionCode) throw new Error("HarmonyOS versionCode is already published or behind the latest release; update AppScope/app.json5");
|
|
19180
|
+
if (await read(bucket, `${releasePrefix}release.json`) !== null || (await (this.deps.list ?? AliyunService.listObjects)(bucket, releasePrefix)).length) throw new Error("HarmonyOS release already exists; published objects are immutable");
|
|
19181
|
+
}
|
|
19182
|
+
if (!this.registry) throw new Error("HarmonyOS signing requires the service environment registry");
|
|
19183
|
+
const { values } = await this.registry.resolveEnv(service.id, { stage: "prod", includeSecretValue: true, includeHost: false });
|
|
19184
|
+
const material = signingMaterial(values);
|
|
19185
|
+
const outputBase = options.outDir ? import_node_path28.default.resolve(options.outDir) : import_node_path28.default.join(import_node_os12.default.homedir(), ".pmate/harmony-builds", service.namespace, service.name);
|
|
19186
|
+
if (inside(appDir, outputBase)) throw new Error("HarmonyOS output must be outside the application source directory");
|
|
19187
|
+
(0, import_node_fs23.mkdirSync)(outputBase, { recursive: true, mode: 448 });
|
|
19188
|
+
const output = (0, import_node_fs23.mkdtempSync)(import_node_path28.default.join(outputBase, `release-${version.versionCode}-`)), log = import_node_path28.default.join(output, "build.log");
|
|
19189
|
+
(0, import_node_fs23.writeFileSync)(log, "", { mode: 384 });
|
|
19190
|
+
const temp = (0, import_node_fs23.mkdtempSync)(import_node_path28.default.join(import_node_os12.default.tmpdir(), "pmate-harmony-")), run = this.deps.run ?? runHarmonyCommand;
|
|
19191
|
+
let artifacts = [];
|
|
19192
|
+
try {
|
|
19193
|
+
const staged = stageHarmonySources(root, appDir, import_node_path28.default.join(temp, "checkout"));
|
|
19194
|
+
for (const relative of ["build-profile.json5", "AppScope/app.json5"]) {
|
|
19195
|
+
const file = import_node_path28.default.join(staged, relative);
|
|
19196
|
+
(0, import_node_fs23.writeFileSync)(file, JSON.stringify(readJson5(file), null, 2));
|
|
19197
|
+
}
|
|
19198
|
+
const keys = import_node_path28.default.join(temp, "signing");
|
|
19199
|
+
(0, import_node_fs23.mkdirSync)(keys, { mode: 448 });
|
|
19200
|
+
for (const [name, bytes] of [["release.p12", material.keystore], ["release.cer", material.certificate], ["release.p7b", material.profile]]) (0, import_node_fs23.writeFileSync)(import_node_path28.default.join(keys, name), bytes, { mode: 384 });
|
|
19201
|
+
const env = Object.fromEntries(Object.entries(process.env).filter(([key]) => !key.startsWith("HARMONY_")));
|
|
19202
|
+
Object.assign(env, { DEVECO_SDK_HOME: tools.sdk, OHPM_BIN: tools.ohpm, HVIGORW_BIN: tools.hvigor, NODE_BIN: tools.node, JAVA_BIN: tools.java, HAP_SIGN_TOOL: tools.signer, HARMONY_KEYSTORE_FILE: import_node_path28.default.join(keys, "release.p12"), HARMONY_CERTIFICATE_FILE: import_node_path28.default.join(keys, "release.cer"), HARMONY_PROFILE_FILE: import_node_path28.default.join(keys, "release.p7b"), HARMONY_STORE_PASSWORD: values.HARMONY_STORE_PASSWORD, HARMONY_KEY_ALIAS: values.HARMONY_KEY_ALIAS, HARMONY_KEY_PASSWORD: values.HARMONY_KEY_PASSWORD, HARMONY_VERSION_NAME: version.versionName, HARMONY_VERSION_CODE: String(version.versionCode), HARMONY_RELEASE_DRY_RUN: "0" });
|
|
19203
|
+
const opts = { cwd: staged, env, log };
|
|
19204
|
+
await run("bash", [import_node_path28.default.resolve(staged, script)], opts);
|
|
19205
|
+
const dist = import_node_path28.default.join(staged, "dist");
|
|
19206
|
+
const files = (0, import_node_fs23.readdirSync)(dist, { withFileTypes: true }).filter((e) => e.isFile() && /\.(app|hap)$/.test(e.name)).map((e) => import_node_path28.default.join(dist, e.name));
|
|
19207
|
+
if (files.length !== 2 || files.filter((f) => f.endsWith(".app")).length !== 1 || files.filter((f) => f.endsWith(".hap")).length !== 1) throw new Error("HarmonyOS build must produce exactly one signed APP and one signed HAP");
|
|
19208
|
+
const check = async (file, inspectMetadata) => {
|
|
19209
|
+
const id = (0, import_node_crypto6.createHash)("sha256").update(file).digest("hex").slice(0, 16), cert = import_node_path28.default.join(temp, `${id}.cer`);
|
|
19210
|
+
await run(tools.java, ["-jar", tools.signer, "verify-app", "-inFile", file, "-outCertChain", cert, "-outProfile", import_node_path28.default.join(temp, `${id}.p7b`)], opts);
|
|
19211
|
+
if (new import_node_crypto6.X509Certificate((0, import_node_fs23.readFileSync)(cert)).fingerprint256.replace(/:/g, "") !== material.fingerprint) throw new Error("HarmonyOS signer certificate does not match service certificate");
|
|
19212
|
+
if (inspectMetadata) assertHarmonyMetadata(JSON.parse(await run("unzip", ["-p", file, "module.json"], { ...opts, capture: true })), version);
|
|
19213
|
+
};
|
|
19214
|
+
for (const file of files) {
|
|
19215
|
+
await check(file, file.endsWith(".hap"));
|
|
19216
|
+
if (file.endsWith(".app")) {
|
|
19217
|
+
const names = (await run("unzip", ["-Z1", file], { ...opts, capture: true })).split(/\r?\n/).filter((name) => /\.(hap|hsp)$/.test(name));
|
|
19218
|
+
if (!names.length) throw new Error("HarmonyOS APP contains no package modules");
|
|
19219
|
+
for (const [index, name] of names.entries()) {
|
|
19220
|
+
if (name.startsWith("/") || name.includes("\\") || name.split("/").includes("..")) throw new Error("Unsafe HarmonyOS archive member");
|
|
19221
|
+
const embedded = import_node_path28.default.join(temp, `module-${index}${import_node_path28.default.extname(name)}`);
|
|
19222
|
+
await run("unzip", ["-p", file, name], { ...opts, output: embedded });
|
|
19223
|
+
await check(embedded, true);
|
|
19224
|
+
}
|
|
19225
|
+
}
|
|
19226
|
+
}
|
|
19227
|
+
artifacts = [];
|
|
19228
|
+
for (const file of files) {
|
|
19229
|
+
const name = import_node_path28.default.basename(file);
|
|
19230
|
+
if (!/^[A-Za-z0-9._-]+\.(app|hap)$/.test(name)) throw new Error("Invalid HarmonyOS artifact filename");
|
|
19231
|
+
const size = (0, import_node_fs23.statSync)(file).size;
|
|
19232
|
+
if (!size) throw new Error("Empty HarmonyOS artifact");
|
|
19233
|
+
const target = import_node_path28.default.join(output, name);
|
|
19234
|
+
(0, import_node_fs23.cpSync)(file, target);
|
|
19235
|
+
const hash = (0, import_node_crypto6.createHash)("sha256");
|
|
19236
|
+
for await (const chunk of (0, import_node_fs23.createReadStream)(target)) hash.update(chunk);
|
|
19237
|
+
artifacts.push({ name, type: import_node_path28.default.extname(name).slice(1), objectKey: releasePrefix + name, downloadUrl: `${baseUrl}/${releasePrefix}${name}`, sha256: hash.digest("hex"), size });
|
|
19238
|
+
}
|
|
19239
|
+
} finally {
|
|
19240
|
+
(0, import_node_fs23.rmSync)(temp, { recursive: true, force: true });
|
|
19241
|
+
}
|
|
19242
|
+
if (options.local) return { ...plan, status: "local", output, log, artifacts };
|
|
19243
|
+
let revision;
|
|
19244
|
+
try {
|
|
19245
|
+
revision = (0, import_node_child_process11.execFileSync)("git", ["rev-parse", "HEAD"], { cwd: root, encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
|
|
19246
|
+
} catch {
|
|
19247
|
+
}
|
|
19248
|
+
const manifest = { schemaVersion: 1, serviceId: service.id, app: application, platform: "harmonyos", distribution: "oss", appGallerySubmitted: false, ...version, signature: "verified", certificateSha256: material.fingerprint, sourceRevision: revision, artifacts, publishedAt: (/* @__PURE__ */ new Date()).toISOString() };
|
|
19249
|
+
const upload = this.deps.upload ?? AliyunService.uploadFile, uploadJson = this.deps.uploadJson ?? AliyunService.uploadJsonObject;
|
|
19250
|
+
await (this.deps.lock ?? withHarmonyPublicationLock)(bucket, `${prefix}/.publish-lock.json`, async () => {
|
|
19251
|
+
const latest = await read(bucket, `${prefix}/latest.json`);
|
|
19252
|
+
if (latest && (latest.serviceId !== service.id || latest.app !== application || latest.bundleName !== version.bundleName || latest.schemaVersion !== 1 || latest.platform !== "harmonyos" || latest.signature !== "verified" || !Number.isSafeInteger(latest.versionCode) || latest.versionCode <= 0)) throw new Error("Invalid existing HarmonyOS update manifest");
|
|
19253
|
+
if (latest && latest.versionCode >= version.versionCode) throw new Error("A same or newer HarmonyOS release was published during the build; latest is unchanged");
|
|
19254
|
+
if (await read(bucket, `${releasePrefix}release.json`) !== null || (await (this.deps.list ?? AliyunService.listObjects)(bucket, releasePrefix)).length) throw new Error("HarmonyOS release already exists; published objects are immutable");
|
|
19255
|
+
for (const artifact of artifacts) await upload(import_node_path28.default.join(output, artifact.name), bucket, artifact.objectKey, { "x-oss-forbid-overwrite": "true" });
|
|
19256
|
+
await uploadJson(bucket, `${releasePrefix}release.json`, manifest, { "x-oss-forbid-overwrite": "true" });
|
|
19257
|
+
await uploadJson(bucket, `${prefix}/latest.json`, manifest);
|
|
19258
|
+
});
|
|
19259
|
+
(0, import_node_fs23.writeFileSync)(import_node_path28.default.join(output, "release.json"), JSON.stringify(manifest, null, 2));
|
|
19260
|
+
return { ...plan, status: "published", output, log, signature: "verified", artifacts };
|
|
19261
|
+
}
|
|
19262
|
+
};
|
|
19263
|
+
|
|
19264
|
+
// src/services/IosBuildService.ts
|
|
19265
|
+
var import_node_child_process12 = require("child_process");
|
|
19266
|
+
var import_node_crypto7 = require("crypto");
|
|
19267
|
+
var import_node_fs24 = require("fs");
|
|
19268
|
+
var import_node_os13 = __toESM(require("os"));
|
|
19269
|
+
var import_node_path29 = __toESM(require("path"));
|
|
18973
19270
|
function iosBuildInteger(value) {
|
|
18974
19271
|
if (!/^(0|[1-9]\d*)$/.test(String(value)) || !Number.isSafeInteger(Number(value))) {
|
|
18975
19272
|
throw new Error(`iOS Build must be a non-negative safe integer: ${String(value)}`);
|
|
@@ -18978,13 +19275,13 @@ function iosBuildInteger(value) {
|
|
|
18978
19275
|
}
|
|
18979
19276
|
async function runXcode(args, cwd, logPath) {
|
|
18980
19277
|
return new Promise((resolve, reject) => {
|
|
18981
|
-
const child = (0,
|
|
19278
|
+
const child = (0, import_node_child_process12.spawn)("xcodebuild", args, { cwd, stdio: ["ignore", "pipe", "pipe"] });
|
|
18982
19279
|
let output = "";
|
|
18983
19280
|
child.stdout.on("data", (chunk) => {
|
|
18984
19281
|
if (args.includes("-json") || args.includes("-version")) output += chunk.toString();
|
|
18985
|
-
(0,
|
|
19282
|
+
(0, import_node_fs24.appendFileSync)(logPath, chunk);
|
|
18986
19283
|
});
|
|
18987
|
-
child.stderr.on("data", (chunk) => (0,
|
|
19284
|
+
child.stderr.on("data", (chunk) => (0, import_node_fs24.appendFileSync)(logPath, chunk));
|
|
18988
19285
|
child.on("error", reject);
|
|
18989
19286
|
child.on("close", (code) => code === 0 ? resolve(output) : reject(new Error(`xcodebuild failed (${code}); see ${logPath}`)));
|
|
18990
19287
|
});
|
|
@@ -19003,18 +19300,18 @@ var IosBuildService = class {
|
|
|
19003
19300
|
const repository = service.repository ?? service.mobile?.repository;
|
|
19004
19301
|
const dir = service.dir ?? service.mobile?.dir;
|
|
19005
19302
|
if (!dir || !repository && !options.cwd) throw new Error("iOS service requires repository and dir, or --cwd and dir");
|
|
19006
|
-
const repoRoot = options.cwd ?
|
|
19007
|
-
const appDir =
|
|
19008
|
-
if (!(0,
|
|
19303
|
+
const repoRoot = options.cwd ? import_node_path29.default.resolve(options.cwd) : resolveRepositoryLocalRoot(repository);
|
|
19304
|
+
const appDir = import_node_path29.default.resolve(repoRoot, dir);
|
|
19305
|
+
if (!(0, import_node_fs24.existsSync)(appDir)) throw new Error(`iOS app dir not found: ${appDir}`);
|
|
19009
19306
|
const explicit = options.project ?? options.workspace;
|
|
19010
|
-
const candidates = explicit ? [
|
|
19011
|
-
if (candidates.length !== 1 || !(0,
|
|
19307
|
+
const candidates = explicit ? [import_node_path29.default.resolve(appDir, explicit)] : (0, import_node_fs24.readdirSync)(appDir).filter((name) => /\.(xcodeproj|xcworkspace)$/.test(name)).map((name) => import_node_path29.default.join(appDir, name));
|
|
19308
|
+
if (candidates.length !== 1 || !(0, import_node_fs24.existsSync)(candidates[0])) throw new Error("Specify exactly one existing --project or --workspace; project discovery is ambiguous or empty");
|
|
19012
19309
|
const project = candidates[0];
|
|
19013
|
-
const expectedExtension = options.workspace ? ".xcworkspace" : options.project ? ".xcodeproj" :
|
|
19014
|
-
if (![".xcodeproj", ".xcworkspace"].includes(expectedExtension) ||
|
|
19015
|
-
const root = this.deps.stateRoot ??
|
|
19016
|
-
(0,
|
|
19017
|
-
const preflightLog =
|
|
19310
|
+
const expectedExtension = options.workspace ? ".xcworkspace" : options.project ? ".xcodeproj" : import_node_path29.default.extname(project);
|
|
19311
|
+
if (![".xcodeproj", ".xcworkspace"].includes(expectedExtension) || import_node_path29.default.extname(project) !== expectedExtension) throw new Error("Invalid Xcode project/workspace extension");
|
|
19312
|
+
const root = this.deps.stateRoot ?? import_node_path29.default.join(import_node_os13.default.homedir(), ".pmate", "ios-builds");
|
|
19313
|
+
(0, import_node_fs24.mkdirSync)(root, { recursive: true, mode: 448 });
|
|
19314
|
+
const preflightLog = import_node_path29.default.join(root, `preflight-${process.pid}-${Date.now()}.log`);
|
|
19018
19315
|
const run = this.deps.run ?? runXcode;
|
|
19019
19316
|
await run(["-version"], appDir, preflightLog);
|
|
19020
19317
|
const common2 = [expectedExtension === ".xcworkspace" ? "-workspace" : "-project", project, "-scheme", options.scheme, "-configuration", "Release", "-destination", "generic/platform=iOS"];
|
|
@@ -19029,19 +19326,19 @@ var IosBuildService = class {
|
|
|
19029
19326
|
if (!bundleId || !/^\d+\.\d+(?:\.\d+)?$/.test(version ?? "") || !/^[A-Z0-9]{10}$/.test(team ?? "")) throw new Error("Missing or invalid bundle ID, MARKETING_VERSION or signing team; use --team if needed");
|
|
19030
19327
|
if (service.mobile && "bundleId" in service.mobile && service.mobile.bundleId !== bundleId) throw new Error("Service bundle ID does not match application target");
|
|
19031
19328
|
const currentBuild = iosBuildInteger(cfg.CURRENT_PROJECT_VERSION);
|
|
19032
|
-
const key = (0,
|
|
19033
|
-
const statePath =
|
|
19034
|
-
const lockPath =
|
|
19329
|
+
const key = (0, import_node_crypto7.createHash)("sha256").update(bundleId).digest("hex");
|
|
19330
|
+
const statePath = import_node_path29.default.join(root, `${key}.json`);
|
|
19331
|
+
const lockPath = import_node_path29.default.join(root, `${key}.lock`);
|
|
19035
19332
|
let lock;
|
|
19036
19333
|
try {
|
|
19037
|
-
lock = (0,
|
|
19334
|
+
lock = (0, import_node_fs24.openSync)(lockPath, "wx", 384);
|
|
19038
19335
|
} catch (error) {
|
|
19039
19336
|
if (error.code === "EEXIST") throw new Error(`iOS build already locked: ${lockPath}. Remove only after confirming no build is running.`);
|
|
19040
19337
|
throw error;
|
|
19041
19338
|
}
|
|
19042
19339
|
try {
|
|
19043
|
-
(0,
|
|
19044
|
-
const previous = (0,
|
|
19340
|
+
(0, import_node_fs24.writeFileSync)(lock, JSON.stringify({ pid: process.pid, bundleId }));
|
|
19341
|
+
const previous = (0, import_node_fs24.existsSync)(statePath) ? JSON.parse((0, import_node_fs24.readFileSync)(statePath, "utf8")) : void 0;
|
|
19045
19342
|
if (previous && previous.bundleId !== bundleId) throw new Error("iOS build state bundle ID mismatch");
|
|
19046
19343
|
const buildsByVersion = { ...previous?.buildsByVersion };
|
|
19047
19344
|
if (previous) buildsByVersion[previous.version] = Math.max(buildsByVersion[previous.version] ?? 0, iosBuildInteger(previous.build));
|
|
@@ -19049,52 +19346,52 @@ var IosBuildService = class {
|
|
|
19049
19346
|
if (priorBuild === void 0 && options.lastBuild === void 0) throw new Error("First build for this marketing version requires --last-build <highest Apple build for this version>; use 0 only for a new version. Import again after external uploads or changing machines.");
|
|
19050
19347
|
const build = Math.max(currentBuild, priorBuild ?? 0, options.lastBuild ?? 0) + 1;
|
|
19051
19348
|
iosBuildInteger(build);
|
|
19052
|
-
const buildDir =
|
|
19053
|
-
(0,
|
|
19054
|
-
const archivePath =
|
|
19055
|
-
const logPath =
|
|
19349
|
+
const buildDir = import_node_path29.default.join(root, key, `${version}-${build}`);
|
|
19350
|
+
(0, import_node_fs24.mkdirSync)(buildDir, { recursive: true, mode: 448 });
|
|
19351
|
+
const archivePath = import_node_path29.default.join(buildDir, "App.xcarchive");
|
|
19352
|
+
const logPath = import_node_path29.default.join(buildDir, "build.log");
|
|
19056
19353
|
buildsByVersion[version] = build;
|
|
19057
19354
|
const state = { bundleId, version, build, buildsByVersion, status: "reserved", archivePath, logPath };
|
|
19058
19355
|
const persist = () => {
|
|
19059
19356
|
const temp = `${statePath}.${process.pid}.tmp`;
|
|
19060
|
-
(0,
|
|
19061
|
-
(0,
|
|
19357
|
+
(0, import_node_fs24.writeFileSync)(temp, JSON.stringify(state, null, 2) + "\n", { mode: 384 });
|
|
19358
|
+
(0, import_node_fs24.renameSync)(temp, statePath);
|
|
19062
19359
|
};
|
|
19063
19360
|
persist();
|
|
19064
|
-
(0,
|
|
19361
|
+
(0, import_node_fs24.writeFileSync)(logPath, `Service ${service.id}: ${bundleId} ${version} (${build})
|
|
19065
19362
|
Preflight log: ${preflightLog}
|
|
19066
19363
|
`, { mode: 384 });
|
|
19067
19364
|
try {
|
|
19068
|
-
await run([...common2, `CURRENT_PROJECT_VERSION=${build}`, `MARKETING_VERSION=${version}`, "-archivePath", archivePath, "-derivedDataPath",
|
|
19069
|
-
const applications =
|
|
19070
|
-
const builtApps = (0,
|
|
19365
|
+
await run([...common2, `CURRENT_PROJECT_VERSION=${build}`, `MARKETING_VERSION=${version}`, "-archivePath", archivePath, "-derivedDataPath", import_node_path29.default.join(buildDir, "DerivedData"), "-allowProvisioningUpdates", "archive"], appDir, logPath);
|
|
19366
|
+
const applications = import_node_path29.default.join(archivePath, "Products", "Applications");
|
|
19367
|
+
const builtApps = (0, import_node_fs24.readdirSync)(applications).filter((name) => name.endsWith(".app"));
|
|
19071
19368
|
if (builtApps.length !== 1) throw new Error("Archive must contain exactly one application");
|
|
19072
|
-
const plist = (0,
|
|
19369
|
+
const plist = (0, import_node_fs24.readFileSync)(import_node_path29.default.join(applications, builtApps[0], "Info.plist"));
|
|
19073
19370
|
const info = await (this.deps.readPlist ?? readPlist)(plist);
|
|
19074
19371
|
if (info.CFBundleIdentifier !== bundleId || info.CFBundleShortVersionString !== version || String(info.CFBundleVersion) !== String(build)) throw new Error("Archive metadata does not match requested bundle, version and Build; upload stopped");
|
|
19075
|
-
const exportPlist =
|
|
19076
|
-
(0,
|
|
19077
|
-
await run(["-exportArchive", "-archivePath", archivePath, "-exportOptionsPlist", exportPlist, "-exportPath",
|
|
19372
|
+
const exportPlist = import_node_path29.default.join(buildDir, "ExportOptions.plist");
|
|
19373
|
+
(0, import_node_fs24.writeFileSync)(exportPlist, `<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"><plist version="1.0"><dict><key>method</key><string>app-store-connect</string><key>destination</key><string>upload</string><key>teamID</key><string>${team}</string><key>signingStyle</key><string>automatic</string><key>manageAppVersionAndBuildNumber</key><false/><key>uploadSymbols</key><true/></dict></plist>`);
|
|
19374
|
+
await run(["-exportArchive", "-archivePath", archivePath, "-exportOptionsPlist", exportPlist, "-exportPath", import_node_path29.default.join(buildDir, "export"), "-allowProvisioningUpdates"], appDir, logPath);
|
|
19078
19375
|
state.status = "uploaded-processing";
|
|
19079
19376
|
persist();
|
|
19080
19377
|
return { serviceId: service.id, bundleId, version, build, status: "uploaded-processing", archivePath, logPath };
|
|
19081
19378
|
} catch (error) {
|
|
19082
19379
|
state.status = "failed";
|
|
19083
19380
|
persist();
|
|
19084
|
-
(0,
|
|
19381
|
+
(0, import_node_fs24.appendFileSync)(logPath, `
|
|
19085
19382
|
${String(error)}
|
|
19086
19383
|
`);
|
|
19087
19384
|
throw new Error(`iOS Build ${build} failed; sequence reserved. See ${logPath}. ${String(error)}`);
|
|
19088
19385
|
}
|
|
19089
19386
|
} finally {
|
|
19090
|
-
(0,
|
|
19091
|
-
(0,
|
|
19387
|
+
(0, import_node_fs24.closeSync)(lock);
|
|
19388
|
+
(0, import_node_fs24.unlinkSync)(lockPath);
|
|
19092
19389
|
}
|
|
19093
19390
|
}
|
|
19094
19391
|
};
|
|
19095
19392
|
async function readPlist(input) {
|
|
19096
19393
|
return new Promise((resolve, reject) => {
|
|
19097
|
-
const child = (0,
|
|
19394
|
+
const child = (0, import_node_child_process12.spawn)("plutil", ["-convert", "json", "-o", "-", "--", "-"], { stdio: ["pipe", "pipe", "pipe"] });
|
|
19098
19395
|
let output = "";
|
|
19099
19396
|
let error = "";
|
|
19100
19397
|
child.stdout.on("data", (chunk) => {
|
|
@@ -19135,15 +19432,19 @@ var NativeServiceDeploy = class {
|
|
|
19135
19432
|
this.registry = registry;
|
|
19136
19433
|
}
|
|
19137
19434
|
async deploy(service, args) {
|
|
19138
|
-
if (!("type" in service) || !["electron", "ios", "android"].includes(service.type)) throw new Error("Native deployment requires
|
|
19435
|
+
if (!("type" in service) || !["electron", "ios", "android", "harmonyos"].includes(service.type)) throw new Error("Native deployment requires a supported native service");
|
|
19139
19436
|
if (service.type !== "android" && (args.env ?? "prod") !== "prod") throw new Error("Native deployment currently supports only --env prod");
|
|
19140
19437
|
const repository = service.repository ?? service.mobile?.repository;
|
|
19141
19438
|
const dir = service.dir ?? service.mobile?.dir;
|
|
19142
19439
|
if (!dir || !repository && !args.cwd) throw new Error("Native service requires repository and dir");
|
|
19143
|
-
const root = args.cwd ?
|
|
19144
|
-
const appDir =
|
|
19145
|
-
if (!(0,
|
|
19440
|
+
const root = args.cwd ? import_node_path30.default.resolve(args.cwd) : resolveRepositoryLocalRoot(repository);
|
|
19441
|
+
const appDir = import_node_path30.default.resolve(root, dir);
|
|
19442
|
+
if (!(0, import_node_fs25.existsSync)(appDir)) throw new Error(`Service source directory not found: ${appDir}`);
|
|
19146
19443
|
const settings = service.build ?? {};
|
|
19444
|
+
if (service.type === "harmonyos") {
|
|
19445
|
+
rejectNativeOverrides(args, ["dryRun", "local", "outDir"]);
|
|
19446
|
+
return (this.deps.harmony ?? new HarmonyReleaseService(this.registry)).release(service, { cwd: root, dryRun: args.dryRun, local: args.local, outDir: args.outDir });
|
|
19447
|
+
}
|
|
19147
19448
|
if (service.type === "android") {
|
|
19148
19449
|
rejectNativeOverrides(args, [...androidKeys, "dryRun"]);
|
|
19149
19450
|
const artifactIdentity = androidArtifactIdentity(service);
|
|
@@ -19172,10 +19473,10 @@ var NativeServiceDeploy = class {
|
|
|
19172
19473
|
const options2 = {
|
|
19173
19474
|
id: app,
|
|
19174
19475
|
target: "electron",
|
|
19175
|
-
config: args.config ?
|
|
19476
|
+
config: args.config ? import_node_path30.default.resolve(args.config) : import_node_path30.default.resolve(appDir, settings.config ?? "desktop.config.json"),
|
|
19176
19477
|
platform: args.platform ?? settings.platform ?? (process.platform === "darwin" ? "mac" : process.platform === "win32" ? "win" : process.platform),
|
|
19177
19478
|
arch: args.arch ?? settings.arch ?? process.arch,
|
|
19178
|
-
outDir: args.outDir ?
|
|
19479
|
+
outDir: args.outDir ? import_node_path30.default.resolve(args.outDir) : import_node_path30.default.join(root, "release", service.name),
|
|
19179
19480
|
signed: !args.unsigned,
|
|
19180
19481
|
dir: !!args.dir,
|
|
19181
19482
|
dryRun: !!args.dryRun,
|
|
@@ -19288,10 +19589,10 @@ async function requestDeveloperLogTool(tool, params, fetcher = fetch, delegate)
|
|
|
19288
19589
|
}
|
|
19289
19590
|
|
|
19290
19591
|
// src/services/ServiceRuntimeRunner.ts
|
|
19291
|
-
var
|
|
19292
|
-
var
|
|
19293
|
-
var
|
|
19294
|
-
var
|
|
19592
|
+
var import_node_fs26 = require("fs");
|
|
19593
|
+
var import_node_os14 = __toESM(require("os"));
|
|
19594
|
+
var import_node_path31 = __toESM(require("path"));
|
|
19595
|
+
var import_node_child_process13 = require("child_process");
|
|
19295
19596
|
var import_node_readline = require("readline");
|
|
19296
19597
|
var import_chalk3 = __toESM(require("chalk"));
|
|
19297
19598
|
var import_dotenv = require("dotenv");
|
|
@@ -19311,8 +19612,8 @@ var ServiceEnvNotFoundError = class extends Error {
|
|
|
19311
19612
|
}
|
|
19312
19613
|
};
|
|
19313
19614
|
var ServiceRegistryClient = class {
|
|
19314
|
-
constructor(
|
|
19315
|
-
this.baseUrl =
|
|
19615
|
+
constructor(baseUrl2) {
|
|
19616
|
+
this.baseUrl = baseUrl2;
|
|
19316
19617
|
}
|
|
19317
19618
|
async listHostEnv(hostId) {
|
|
19318
19619
|
const payload = await this.request(
|
|
@@ -19790,14 +20091,14 @@ var ServiceRuntimeRunner = class {
|
|
|
19790
20091
|
}
|
|
19791
20092
|
resolveRepoRoot(service, cwd) {
|
|
19792
20093
|
if (cwd) {
|
|
19793
|
-
return
|
|
20094
|
+
return import_node_path31.default.resolve(process.cwd(), cwd);
|
|
19794
20095
|
}
|
|
19795
20096
|
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();
|
|
19796
20097
|
if (repository) {
|
|
19797
20098
|
const repoName = repository.replace(/\/+$/, "").split("/").pop()?.replace(/\.git$/i, "");
|
|
19798
20099
|
if (repoName) {
|
|
19799
|
-
const candidate =
|
|
19800
|
-
if ((0,
|
|
20100
|
+
const candidate = import_node_path31.default.join(import_node_os14.default.homedir(), "dev", "pmate", repoName);
|
|
20101
|
+
if ((0, import_node_fs26.existsSync)(candidate)) {
|
|
19801
20102
|
return candidate;
|
|
19802
20103
|
}
|
|
19803
20104
|
}
|
|
@@ -19810,13 +20111,13 @@ var ServiceRuntimeRunner = class {
|
|
|
19810
20111
|
if (!dir) {
|
|
19811
20112
|
throw new Error(`Missing service dir for ${service.id}`);
|
|
19812
20113
|
}
|
|
19813
|
-
return
|
|
20114
|
+
return import_node_path31.default.resolve(repoRoot, dir);
|
|
19814
20115
|
}
|
|
19815
20116
|
async deployVite(service, options) {
|
|
19816
20117
|
this.assertDeployableStaticSite(service);
|
|
19817
20118
|
const appDir = this.resolveLocalDir(service, options.cwd);
|
|
19818
|
-
const packageJsonPath =
|
|
19819
|
-
if (!(0,
|
|
20119
|
+
const packageJsonPath = import_node_path31.default.join(appDir, "package.json");
|
|
20120
|
+
if (!(0, import_node_fs26.existsSync)(packageJsonPath)) {
|
|
19820
20121
|
throw new Error(`No package.json found at ${packageJsonPath}`);
|
|
19821
20122
|
}
|
|
19822
20123
|
const pkg2 = this.loadPackageJson(packageJsonPath);
|
|
@@ -19831,8 +20132,8 @@ var ServiceRuntimeRunner = class {
|
|
|
19831
20132
|
this.resolveRepoRoot(service, options.cwd),
|
|
19832
20133
|
buildEnv
|
|
19833
20134
|
);
|
|
19834
|
-
const distDir =
|
|
19835
|
-
if (!(0,
|
|
20135
|
+
const distDir = import_node_path31.default.join(appDir, "dist");
|
|
20136
|
+
if (!(0, import_node_fs26.existsSync)(distDir)) {
|
|
19836
20137
|
throw new Error(`No dist directory found at ${distDir}`);
|
|
19837
20138
|
}
|
|
19838
20139
|
const site = this.getSite(service);
|
|
@@ -19845,8 +20146,8 @@ var ServiceRuntimeRunner = class {
|
|
|
19845
20146
|
async deployStatic(service, options) {
|
|
19846
20147
|
this.assertDeployableStaticSite(service);
|
|
19847
20148
|
const appDir = this.resolveLocalDir(service, options.cwd);
|
|
19848
|
-
const srcDir =
|
|
19849
|
-
if (!(0,
|
|
20149
|
+
const srcDir = import_node_path31.default.join(appDir, "src");
|
|
20150
|
+
if (!(0, import_node_fs26.existsSync)(srcDir)) {
|
|
19850
20151
|
throw new Error(`No src directory found at ${srcDir}`);
|
|
19851
20152
|
}
|
|
19852
20153
|
const site = this.getSite(service);
|
|
@@ -19880,8 +20181,8 @@ var ServiceRuntimeRunner = class {
|
|
|
19880
20181
|
this.validateFcConfig(service, fc);
|
|
19881
20182
|
const repoRoot = this.resolveRepoRoot(service, options.cwd);
|
|
19882
20183
|
const appDir = this.resolveLocalDir(service, options.cwd);
|
|
19883
|
-
const packageJsonPath =
|
|
19884
|
-
if (!(0,
|
|
20184
|
+
const packageJsonPath = import_node_path31.default.join(appDir, "package.json");
|
|
20185
|
+
if (!(0, import_node_fs26.existsSync)(packageJsonPath)) {
|
|
19885
20186
|
throw new Error(`No package.json found at ${packageJsonPath}`);
|
|
19886
20187
|
}
|
|
19887
20188
|
const pkg2 = this.loadPackageJson(packageJsonPath);
|
|
@@ -19934,15 +20235,15 @@ var ServiceRuntimeRunner = class {
|
|
|
19934
20235
|
const repoRoot = this.resolveRepoRoot(service, options.cwd);
|
|
19935
20236
|
const appDir = this.resolveLocalDir(service, options.cwd);
|
|
19936
20237
|
await this.ensurePnpmWorkspaceRoot(repoRoot);
|
|
19937
|
-
const configPath =
|
|
19938
|
-
if (!(0,
|
|
20238
|
+
const configPath = import_node_path31.default.join(appDir, fc.configFile ?? "s.yaml");
|
|
20239
|
+
if (!(0, import_node_fs26.existsSync)(configPath)) {
|
|
19939
20240
|
throw new Error(`Missing FC config file at ${configPath}`);
|
|
19940
20241
|
}
|
|
19941
|
-
const packageJsonPath =
|
|
19942
|
-
if (!(0,
|
|
20242
|
+
const packageJsonPath = import_node_path31.default.join(appDir, "package.json");
|
|
20243
|
+
if (!(0, import_node_fs26.existsSync)(packageJsonPath)) {
|
|
19943
20244
|
throw new Error(`No package.json found at ${packageJsonPath}`);
|
|
19944
20245
|
}
|
|
19945
|
-
const rawConfig = (0,
|
|
20246
|
+
const rawConfig = (0, import_node_fs26.readFileSync)(configPath, "utf8");
|
|
19946
20247
|
if (!rawConfig.includes(fc.functionName)) {
|
|
19947
20248
|
throw new Error(`FC config ${configPath} does not mention functionName ${fc.functionName}`);
|
|
19948
20249
|
}
|
|
@@ -20232,7 +20533,7 @@ var ServiceRuntimeRunner = class {
|
|
|
20232
20533
|
const serverAddress = await resolveServerAddress(server);
|
|
20233
20534
|
const templateName = exposeType === "websocket" ? "nginx.ws.template" : exposeType === "mixed" ? "nginx.mixed.template" : "nginx.rest.template";
|
|
20234
20535
|
const templatePath = this.resolveTemplatePath(templateName);
|
|
20235
|
-
const template = (0,
|
|
20536
|
+
const template = (0, import_node_fs26.readFileSync)(templatePath, "utf8");
|
|
20236
20537
|
const host = `${subdomain}.${("domain" in network ? network.domain?.trim() : void 0) || "pmate.chat"}`;
|
|
20237
20538
|
const rendered = template.replace(/\$\{\{PORT\}\}/g, String(port)).replace(/\$\{\{HOSTS\}\}/g, host).replace(/\$\{\{HOST\}\}/g, host);
|
|
20238
20539
|
const remotePath = `/etc/nginx/sites-enabled/${subdomain}.conf`;
|
|
@@ -20264,11 +20565,11 @@ var ServiceRuntimeRunner = class {
|
|
|
20264
20565
|
}
|
|
20265
20566
|
if (config.ensurePackageJson) {
|
|
20266
20567
|
const appDir = this.resolveLocalDir(service, options.cwd);
|
|
20267
|
-
const packageJsonPath =
|
|
20268
|
-
if (!(0,
|
|
20568
|
+
const packageJsonPath = import_node_path31.default.join(appDir, "package.json");
|
|
20569
|
+
if (!(0, import_node_fs26.existsSync)(packageJsonPath)) {
|
|
20269
20570
|
throw new Error(`Missing package.json at ${packageJsonPath}`);
|
|
20270
20571
|
}
|
|
20271
|
-
const pkgStat = (0,
|
|
20572
|
+
const pkgStat = (0, import_node_fs26.statSync)(packageJsonPath);
|
|
20272
20573
|
if (!pkgStat.isFile()) {
|
|
20273
20574
|
throw new Error(`package.json is not a file at ${packageJsonPath}`);
|
|
20274
20575
|
}
|
|
@@ -20679,9 +20980,9 @@ var ServiceRuntimeRunner = class {
|
|
|
20679
20980
|
return tokens;
|
|
20680
20981
|
}
|
|
20681
20982
|
readPathValue(source, pathExpr) {
|
|
20682
|
-
const
|
|
20983
|
+
const path36 = pathExpr.split(".").map((segment) => segment.trim()).filter(Boolean);
|
|
20683
20984
|
let cursor = source;
|
|
20684
|
-
for (const segment of
|
|
20985
|
+
for (const segment of path36) {
|
|
20685
20986
|
if (!cursor || typeof cursor !== "object" || Array.isArray(cursor)) {
|
|
20686
20987
|
return void 0;
|
|
20687
20988
|
}
|
|
@@ -20724,12 +21025,12 @@ var ServiceRuntimeRunner = class {
|
|
|
20724
21025
|
}
|
|
20725
21026
|
resolveTemplatePath(templateName) {
|
|
20726
21027
|
const candidates = [
|
|
20727
|
-
|
|
20728
|
-
|
|
20729
|
-
|
|
21028
|
+
import_node_path31.default.join(__dirname, "..", "templates", templateName),
|
|
21029
|
+
import_node_path31.default.join(__dirname, "..", "src", "templates", templateName),
|
|
21030
|
+
import_node_path31.default.join(__dirname, "templates", templateName)
|
|
20730
21031
|
];
|
|
20731
21032
|
for (const candidate of candidates) {
|
|
20732
|
-
if ((0,
|
|
21033
|
+
if ((0, import_node_fs26.existsSync)(candidate)) {
|
|
20733
21034
|
return candidate;
|
|
20734
21035
|
}
|
|
20735
21036
|
}
|
|
@@ -20738,7 +21039,7 @@ var ServiceRuntimeRunner = class {
|
|
|
20738
21039
|
writeRemoteConfig(server, content, remotePath) {
|
|
20739
21040
|
return new Promise((resolve, reject) => {
|
|
20740
21041
|
const target = `pmate@${server}`;
|
|
20741
|
-
const child = (0,
|
|
21042
|
+
const child = (0, import_node_child_process13.spawn)("ssh", [target, "sudo", "tee", remotePath], {
|
|
20742
21043
|
stdio: ["pipe", "inherit", "inherit"]
|
|
20743
21044
|
});
|
|
20744
21045
|
child.on("error", reject);
|
|
@@ -20753,7 +21054,7 @@ var ServiceRuntimeRunner = class {
|
|
|
20753
21054
|
reloadNginx(server) {
|
|
20754
21055
|
return new Promise((resolve, reject) => {
|
|
20755
21056
|
const target = `pmate@${server}`;
|
|
20756
|
-
const child = (0,
|
|
21057
|
+
const child = (0, import_node_child_process13.spawn)("ssh", [target, "sudo", "nginx", "-s", "reload"], {
|
|
20757
21058
|
stdio: ["ignore", "inherit", "inherit"]
|
|
20758
21059
|
});
|
|
20759
21060
|
child.on("error", reject);
|
|
@@ -20761,7 +21062,7 @@ var ServiceRuntimeRunner = class {
|
|
|
20761
21062
|
});
|
|
20762
21063
|
}
|
|
20763
21064
|
loadPackageJson(packageJsonPath) {
|
|
20764
|
-
const raw = (0,
|
|
21065
|
+
const raw = (0, import_node_fs26.readFileSync)(packageJsonPath, "utf8");
|
|
20765
21066
|
const parsed = JSON.parse(raw);
|
|
20766
21067
|
if (!parsed || typeof parsed !== "object") {
|
|
20767
21068
|
throw new Error(`Invalid package.json at ${packageJsonPath}`);
|
|
@@ -20770,7 +21071,7 @@ var ServiceRuntimeRunner = class {
|
|
|
20770
21071
|
}
|
|
20771
21072
|
writePackageJson(packageJsonPath, data) {
|
|
20772
21073
|
const serialized = JSON.stringify(data, null, 2);
|
|
20773
|
-
(0,
|
|
21074
|
+
(0, import_node_fs26.writeFileSync)(packageJsonPath, `${serialized}
|
|
20774
21075
|
`, "utf8");
|
|
20775
21076
|
}
|
|
20776
21077
|
validateFcConfig(service, fc) {
|
|
@@ -20797,8 +21098,8 @@ var ServiceRuntimeRunner = class {
|
|
|
20797
21098
|
}
|
|
20798
21099
|
}
|
|
20799
21100
|
async ensurePnpmWorkspaceRoot(repoRoot) {
|
|
20800
|
-
const workspacePath =
|
|
20801
|
-
if (!(0,
|
|
21101
|
+
const workspacePath = import_node_path31.default.join(repoRoot, "pnpm-workspace.yaml");
|
|
21102
|
+
if (!(0, import_node_fs26.existsSync)(workspacePath)) {
|
|
20802
21103
|
throw new Error(`Missing pnpm-workspace.yaml at ${workspacePath}`);
|
|
20803
21104
|
}
|
|
20804
21105
|
}
|
|
@@ -20872,16 +21173,16 @@ var ServiceRuntimeRunner = class {
|
|
|
20872
21173
|
if (!privateKeyPath) {
|
|
20873
21174
|
throw new Error("Missing ssl.prv in ~/.pmate/config.yaml.");
|
|
20874
21175
|
}
|
|
20875
|
-
if (!(0,
|
|
21176
|
+
if (!(0, import_node_fs26.existsSync)(certificatePath)) {
|
|
20876
21177
|
throw new Error(`SSL certificate file not found: ${certificatePath}`);
|
|
20877
21178
|
}
|
|
20878
|
-
if (!(0,
|
|
21179
|
+
if (!(0, import_node_fs26.existsSync)(privateKeyPath)) {
|
|
20879
21180
|
throw new Error(`SSL private key file not found: ${privateKeyPath}`);
|
|
20880
21181
|
}
|
|
20881
21182
|
return {
|
|
20882
21183
|
certName: host,
|
|
20883
|
-
certificate: (0,
|
|
20884
|
-
privateKey: (0,
|
|
21184
|
+
certificate: (0, import_node_fs26.readFileSync)(certificatePath, "utf8"),
|
|
21185
|
+
privateKey: (0, import_node_fs26.readFileSync)(privateKeyPath, "utf8")
|
|
20885
21186
|
};
|
|
20886
21187
|
}
|
|
20887
21188
|
resolveFcProtocol(fc, certConfig) {
|
|
@@ -20940,7 +21241,7 @@ var ServiceRuntimeRunner = class {
|
|
|
20940
21241
|
}
|
|
20941
21242
|
runCommandWithEnv(command, args, cwd, env) {
|
|
20942
21243
|
return new Promise((resolve, reject) => {
|
|
20943
|
-
const child = (0,
|
|
21244
|
+
const child = (0, import_node_child_process13.spawn)(command, args, {
|
|
20944
21245
|
cwd,
|
|
20945
21246
|
stdio: "inherit",
|
|
20946
21247
|
env: { ...process.env, ...env ?? {} }
|
|
@@ -20951,7 +21252,7 @@ var ServiceRuntimeRunner = class {
|
|
|
20951
21252
|
}
|
|
20952
21253
|
runShellCommand(command, cwd, env) {
|
|
20953
21254
|
return new Promise((resolve, reject) => {
|
|
20954
|
-
const child = (0,
|
|
21255
|
+
const child = (0, import_node_child_process13.spawn)(command, [], {
|
|
20955
21256
|
cwd,
|
|
20956
21257
|
stdio: "inherit",
|
|
20957
21258
|
shell: true,
|
|
@@ -20962,10 +21263,10 @@ var ServiceRuntimeRunner = class {
|
|
|
20962
21263
|
});
|
|
20963
21264
|
}
|
|
20964
21265
|
runRemoteCommand(server, command) {
|
|
20965
|
-
if (server === "local") return this.runCommandWithEnv("bash", ["-c", command],
|
|
21266
|
+
if (server === "local") return this.runCommandWithEnv("bash", ["-c", command], import_node_os14.default.homedir());
|
|
20966
21267
|
return new Promise((resolve, reject) => {
|
|
20967
21268
|
const target = `pmate@${server}`;
|
|
20968
|
-
const child = (0,
|
|
21269
|
+
const child = (0, import_node_child_process13.spawn)("ssh", [target, "bash -ls"], { stdio: ["pipe", "inherit", "inherit"] });
|
|
20969
21270
|
child.stdin.on("error", reject);
|
|
20970
21271
|
child.stdin.end(`${command}
|
|
20971
21272
|
`);
|
|
@@ -21025,8 +21326,8 @@ function parseServiceRef(serviceId) {
|
|
|
21025
21326
|
init_namespacedRef();
|
|
21026
21327
|
var ServiceCommandHandler = class {
|
|
21027
21328
|
async handle(args) {
|
|
21028
|
-
const
|
|
21029
|
-
const registry = new ServiceRegistryClient(
|
|
21329
|
+
const baseUrl2 = this.resolveBaseUrl(args.baseUrl);
|
|
21330
|
+
const registry = new ServiceRegistryClient(baseUrl2);
|
|
21030
21331
|
const runtime = new ServiceRuntimeRunner(
|
|
21031
21332
|
(appId, options) => registry.pullEnv(appId, options)
|
|
21032
21333
|
);
|
|
@@ -21072,10 +21373,10 @@ var ServiceCommandHandler = class {
|
|
|
21072
21373
|
}
|
|
21073
21374
|
case "create": {
|
|
21074
21375
|
const payload = this.readJsonFile(args.filePath);
|
|
21075
|
-
await this.requireNamespace(payload,
|
|
21376
|
+
await this.requireNamespace(payload, baseUrl2);
|
|
21076
21377
|
await this.requireUniqueServerPort(payload, registry);
|
|
21077
21378
|
const record = await this.request(
|
|
21078
|
-
|
|
21379
|
+
baseUrl2,
|
|
21079
21380
|
"POST",
|
|
21080
21381
|
"/services",
|
|
21081
21382
|
payload
|
|
@@ -21091,7 +21392,7 @@ var ServiceCommandHandler = class {
|
|
|
21091
21392
|
name: args.name
|
|
21092
21393
|
});
|
|
21093
21394
|
const record = await this.request(
|
|
21094
|
-
|
|
21395
|
+
baseUrl2,
|
|
21095
21396
|
"PUT",
|
|
21096
21397
|
`/services/${encodeURIComponent(args.namespace)}/${encodeURIComponent(args.name)}`,
|
|
21097
21398
|
payload
|
|
@@ -21104,7 +21405,7 @@ var ServiceCommandHandler = class {
|
|
|
21104
21405
|
const service = await registry.getService(args.namespace, args.name);
|
|
21105
21406
|
await this.deleteServiceResources(service);
|
|
21106
21407
|
const record = await this.request(
|
|
21107
|
-
|
|
21408
|
+
baseUrl2,
|
|
21108
21409
|
"DELETE",
|
|
21109
21410
|
`/services/${encodeURIComponent(args.namespace)}/${encodeURIComponent(args.name)}`
|
|
21110
21411
|
);
|
|
@@ -21114,7 +21415,7 @@ var ServiceCommandHandler = class {
|
|
|
21114
21415
|
}
|
|
21115
21416
|
case "rename": {
|
|
21116
21417
|
const record = await this.request(
|
|
21117
|
-
|
|
21418
|
+
baseUrl2,
|
|
21118
21419
|
"POST",
|
|
21119
21420
|
`/services/${encodeURIComponent(args.namespace)}/rename`,
|
|
21120
21421
|
{
|
|
@@ -21130,7 +21431,7 @@ var ServiceCommandHandler = class {
|
|
|
21130
21431
|
}
|
|
21131
21432
|
case "move": {
|
|
21132
21433
|
const record = await this.request(
|
|
21133
|
-
|
|
21434
|
+
baseUrl2,
|
|
21134
21435
|
"POST",
|
|
21135
21436
|
`/services/${encodeURIComponent(args.namespace)}/move`,
|
|
21136
21437
|
{
|
|
@@ -21149,7 +21450,7 @@ var ServiceCommandHandler = class {
|
|
|
21149
21450
|
const certKey = args.sslCert ?? DEFAULT_SSL_CERT_KEY;
|
|
21150
21451
|
resolveSslCert(certKey);
|
|
21151
21452
|
const record = await this.request(
|
|
21152
|
-
|
|
21453
|
+
baseUrl2,
|
|
21153
21454
|
"PUT",
|
|
21154
21455
|
`/services/${encodeURIComponent(args.namespace)}/${encodeURIComponent(args.name)}`,
|
|
21155
21456
|
{ sslCert: certKey }
|
|
@@ -21186,10 +21487,10 @@ var ServiceCommandHandler = class {
|
|
|
21186
21487
|
}
|
|
21187
21488
|
case "deploy": {
|
|
21188
21489
|
const record = await registry.getService(args.namespace, args.name);
|
|
21189
|
-
if ("type" in record && (record.type === "electron" || record.type === "ios" || record.type === "android")) {
|
|
21490
|
+
if ("type" in record && (record.type === "electron" || record.type === "ios" || record.type === "android" || record.type === "harmonyos")) {
|
|
21190
21491
|
try {
|
|
21191
21492
|
const result = await new NativeServiceDeploy({}, registry).deploy(record, args);
|
|
21192
|
-
if (!args.dryRun && !args.local) await this.appendDeployHistory(registry, record.id, args.env ?? "prod", "success", String(result.status));
|
|
21493
|
+
if (!args.dryRun && !args.local) await this.appendDeployHistory(registry, record.id, args.env ?? "prod", "success", String(result.status), typeof result.manifestUrl === "string" ? { manifestUrl: result.manifestUrl, platform: result.type, distribution: result.distribution } : void 0);
|
|
21193
21494
|
this.renderJson(result, true);
|
|
21194
21495
|
} catch (error) {
|
|
21195
21496
|
if (!args.dryRun && !args.local) await this.appendDeployHistory(registry, record.id, args.env ?? "prod", "failed", error instanceof Error ? error.message : String(error));
|
|
@@ -21223,7 +21524,7 @@ var ServiceCommandHandler = class {
|
|
|
21223
21524
|
case "init": {
|
|
21224
21525
|
const record = await registry.getService(args.namespace, args.name);
|
|
21225
21526
|
const withDefaultCert = await this.ensureDefaultSslCertForStaticService(
|
|
21226
|
-
|
|
21527
|
+
baseUrl2,
|
|
21227
21528
|
record
|
|
21228
21529
|
);
|
|
21229
21530
|
const service = await this.materializeServiceEnv(registry, withDefaultCert, args.env);
|
|
@@ -21277,7 +21578,7 @@ var ServiceCommandHandler = class {
|
|
|
21277
21578
|
}
|
|
21278
21579
|
case "env-list": {
|
|
21279
21580
|
const payload = await this.request(
|
|
21280
|
-
|
|
21581
|
+
baseUrl2,
|
|
21281
21582
|
"GET",
|
|
21282
21583
|
this.buildEnvPath(args.appId, {
|
|
21283
21584
|
scope: args.scope,
|
|
@@ -21290,7 +21591,7 @@ var ServiceCommandHandler = class {
|
|
|
21290
21591
|
}
|
|
21291
21592
|
case "env-get": {
|
|
21292
21593
|
const payload = await this.request(
|
|
21293
|
-
|
|
21594
|
+
baseUrl2,
|
|
21294
21595
|
"GET",
|
|
21295
21596
|
`${this.buildEnvBasePath(args.appId)}/${encodeURIComponent(args.key)}?${new URLSearchParams({
|
|
21296
21597
|
scope: args.scope,
|
|
@@ -21303,7 +21604,7 @@ var ServiceCommandHandler = class {
|
|
|
21303
21604
|
case "env-set": {
|
|
21304
21605
|
const value = await this.resolveEnvValue(args);
|
|
21305
21606
|
const payload = await this.request(
|
|
21306
|
-
|
|
21607
|
+
baseUrl2,
|
|
21307
21608
|
"PUT",
|
|
21308
21609
|
`${this.buildEnvBasePath(args.appId)}/${encodeURIComponent(args.key)}`,
|
|
21309
21610
|
{
|
|
@@ -21319,7 +21620,7 @@ var ServiceCommandHandler = class {
|
|
|
21319
21620
|
}
|
|
21320
21621
|
case "env-unset": {
|
|
21321
21622
|
const payload = await this.request(
|
|
21322
|
-
|
|
21623
|
+
baseUrl2,
|
|
21323
21624
|
"DELETE",
|
|
21324
21625
|
`${this.buildEnvBasePath(args.appId)}/${encodeURIComponent(args.key)}?${new URLSearchParams({
|
|
21325
21626
|
scope: args.scope
|
|
@@ -21332,7 +21633,7 @@ var ServiceCommandHandler = class {
|
|
|
21332
21633
|
}
|
|
21333
21634
|
case "env-resolve": {
|
|
21334
21635
|
const payload = await this.request(
|
|
21335
|
-
|
|
21636
|
+
baseUrl2,
|
|
21336
21637
|
"POST",
|
|
21337
21638
|
`${this.buildEnvBasePath(args.appId)}/resolve`,
|
|
21338
21639
|
{
|
|
@@ -21346,7 +21647,7 @@ var ServiceCommandHandler = class {
|
|
|
21346
21647
|
}
|
|
21347
21648
|
case "env-pull": {
|
|
21348
21649
|
const payload = await this.request(
|
|
21349
|
-
|
|
21650
|
+
baseUrl2,
|
|
21350
21651
|
"POST",
|
|
21351
21652
|
`${this.buildEnvBasePath(args.appId)}/pull`,
|
|
21352
21653
|
{
|
|
@@ -21355,7 +21656,7 @@ var ServiceCommandHandler = class {
|
|
|
21355
21656
|
format: "dotenv"
|
|
21356
21657
|
}
|
|
21357
21658
|
);
|
|
21358
|
-
const outputPath =
|
|
21659
|
+
const outputPath = import_node_path32.default.resolve(process.cwd(), args.output);
|
|
21359
21660
|
await (0, import_promises5.writeFile)(outputPath, payload.content, "utf8");
|
|
21360
21661
|
ui.success(`Wrote env file for ${args.appId} to ${outputPath}`);
|
|
21361
21662
|
this.renderJson({ ...payload, output: outputPath }, args.json);
|
|
@@ -21363,7 +21664,7 @@ var ServiceCommandHandler = class {
|
|
|
21363
21664
|
}
|
|
21364
21665
|
case "env-copy-from": {
|
|
21365
21666
|
const payload = await this.request(
|
|
21366
|
-
|
|
21667
|
+
baseUrl2,
|
|
21367
21668
|
"POST",
|
|
21368
21669
|
`${this.buildEnvBasePath(args.targetAppId)}/copy-from`,
|
|
21369
21670
|
{
|
|
@@ -21380,7 +21681,7 @@ var ServiceCommandHandler = class {
|
|
|
21380
21681
|
}
|
|
21381
21682
|
case "env-update-scope": {
|
|
21382
21683
|
const payload = await this.request(
|
|
21383
|
-
|
|
21684
|
+
baseUrl2,
|
|
21384
21685
|
"POST",
|
|
21385
21686
|
`${this.buildEnvBasePath(args.appId)}/update-scope`,
|
|
21386
21687
|
{
|
|
@@ -21397,7 +21698,7 @@ var ServiceCommandHandler = class {
|
|
|
21397
21698
|
}
|
|
21398
21699
|
case "service-env-list": {
|
|
21399
21700
|
const payload = await this.request(
|
|
21400
|
-
|
|
21701
|
+
baseUrl2,
|
|
21401
21702
|
"GET",
|
|
21402
21703
|
this.buildServiceEnvBasePath(args.appId)
|
|
21403
21704
|
);
|
|
@@ -21406,7 +21707,7 @@ var ServiceCommandHandler = class {
|
|
|
21406
21707
|
}
|
|
21407
21708
|
case "service-env-get": {
|
|
21408
21709
|
const payload = await this.request(
|
|
21409
|
-
|
|
21710
|
+
baseUrl2,
|
|
21410
21711
|
"GET",
|
|
21411
21712
|
`${this.buildServiceEnvBasePath(args.appId)}/${encodeURIComponent(args.envName)}`
|
|
21412
21713
|
);
|
|
@@ -21415,7 +21716,7 @@ var ServiceCommandHandler = class {
|
|
|
21415
21716
|
}
|
|
21416
21717
|
case "service-env-add": {
|
|
21417
21718
|
const payload = await this.request(
|
|
21418
|
-
|
|
21719
|
+
baseUrl2,
|
|
21419
21720
|
"PUT",
|
|
21420
21721
|
`${this.buildServiceEnvBasePath(args.appId)}/${encodeURIComponent(args.envName)}`,
|
|
21421
21722
|
{
|
|
@@ -21428,7 +21729,7 @@ var ServiceCommandHandler = class {
|
|
|
21428
21729
|
}
|
|
21429
21730
|
case "service-env-expose": {
|
|
21430
21731
|
const payload = await this.request(
|
|
21431
|
-
|
|
21732
|
+
baseUrl2,
|
|
21432
21733
|
"POST",
|
|
21433
21734
|
`${this.buildServiceEnvBasePath(args.appId)}/${encodeURIComponent(args.envName)}/expose`,
|
|
21434
21735
|
{
|
|
@@ -21550,14 +21851,15 @@ var ServiceCommandHandler = class {
|
|
|
21550
21851
|
}
|
|
21551
21852
|
throw new Error(`Unsupported runtime ${runtime.type} for ${service.id} env ${env.name}`);
|
|
21552
21853
|
}
|
|
21553
|
-
async appendDeployHistory(registry, serviceId, environment, status, message) {
|
|
21854
|
+
async appendDeployHistory(registry, serviceId, environment, status, message, metadata) {
|
|
21554
21855
|
let lastError;
|
|
21555
21856
|
for (let attempt = 1; attempt <= 5; attempt += 1) {
|
|
21556
21857
|
try {
|
|
21557
21858
|
await registry.appendDeployHistory(serviceId, {
|
|
21558
21859
|
environment,
|
|
21559
21860
|
status,
|
|
21560
|
-
...message ? { message } : {}
|
|
21861
|
+
...message ? { message } : {},
|
|
21862
|
+
...metadata ? { metadata } : {}
|
|
21561
21863
|
});
|
|
21562
21864
|
return;
|
|
21563
21865
|
} catch (error2) {
|
|
@@ -21577,15 +21879,15 @@ var ServiceCommandHandler = class {
|
|
|
21577
21879
|
message: error instanceof Error ? error.message : String(error)
|
|
21578
21880
|
});
|
|
21579
21881
|
}
|
|
21580
|
-
resolveBaseUrl(
|
|
21581
|
-
return (
|
|
21882
|
+
resolveBaseUrl(baseUrl2) {
|
|
21883
|
+
return (baseUrl2 || process.env.PMATE_APPS_API_BASE_URL || "https://apps-api.pmate.chat").replace(/\/+$/, "");
|
|
21582
21884
|
}
|
|
21583
21885
|
readJsonFile(filePath) {
|
|
21584
|
-
const absolutePath =
|
|
21585
|
-
if (!(0,
|
|
21886
|
+
const absolutePath = import_node_path32.default.resolve(process.cwd(), filePath);
|
|
21887
|
+
if (!(0, import_node_fs27.existsSync)(absolutePath)) {
|
|
21586
21888
|
throw new Error(`JSON file not found: ${absolutePath}`);
|
|
21587
21889
|
}
|
|
21588
|
-
const raw = (0,
|
|
21890
|
+
const raw = (0, import_node_fs27.readFileSync)(absolutePath, "utf8");
|
|
21589
21891
|
try {
|
|
21590
21892
|
return JSON.parse(raw);
|
|
21591
21893
|
} catch (error) {
|
|
@@ -21593,9 +21895,9 @@ var ServiceCommandHandler = class {
|
|
|
21593
21895
|
throw new Error(`Invalid JSON in ${absolutePath}: ${message}`);
|
|
21594
21896
|
}
|
|
21595
21897
|
}
|
|
21596
|
-
async request(
|
|
21597
|
-
const token = new ServiceRegistryClient(
|
|
21598
|
-
const response = await fetch(`${
|
|
21898
|
+
async request(baseUrl2, method, pathname, body) {
|
|
21899
|
+
const token = new ServiceRegistryClient(baseUrl2).readToken();
|
|
21900
|
+
const response = await fetch(`${baseUrl2}${pathname}`, {
|
|
21599
21901
|
method,
|
|
21600
21902
|
headers: {
|
|
21601
21903
|
Authorization: `Bearer ${token}`,
|
|
@@ -21655,7 +21957,7 @@ var ServiceCommandHandler = class {
|
|
|
21655
21957
|
rl.close();
|
|
21656
21958
|
}
|
|
21657
21959
|
}
|
|
21658
|
-
async requireNamespace(payload,
|
|
21960
|
+
async requireNamespace(payload, baseUrl2) {
|
|
21659
21961
|
if (!payload || typeof payload !== "object") {
|
|
21660
21962
|
throw new Error("Service payload must be a JSON object.");
|
|
21661
21963
|
}
|
|
@@ -21665,7 +21967,7 @@ var ServiceCommandHandler = class {
|
|
|
21665
21967
|
}
|
|
21666
21968
|
const registry = new NamespaceRegistry({
|
|
21667
21969
|
chain: "pmate",
|
|
21668
|
-
registryBaseUrl:
|
|
21970
|
+
registryBaseUrl: baseUrl2
|
|
21669
21971
|
});
|
|
21670
21972
|
const exists = await registry.exists(namespace);
|
|
21671
21973
|
if (!exists) {
|
|
@@ -22065,13 +22367,13 @@ var ServiceCommandHandler = class {
|
|
|
22065
22367
|
}
|
|
22066
22368
|
return [...domains].sort();
|
|
22067
22369
|
}
|
|
22068
|
-
async ensureDefaultSslCertForStaticService(
|
|
22370
|
+
async ensureDefaultSslCertForStaticService(baseUrl2, service) {
|
|
22069
22371
|
const type = this.getServiceType(service);
|
|
22070
22372
|
if (type !== "vite" && type !== "static" || service.sslCert) {
|
|
22071
22373
|
return service;
|
|
22072
22374
|
}
|
|
22073
22375
|
const record = await this.request(
|
|
22074
|
-
|
|
22376
|
+
baseUrl2,
|
|
22075
22377
|
"PUT",
|
|
22076
22378
|
`/services/${encodeURIComponent(service.namespace)}/${encodeURIComponent(service.name)}`,
|
|
22077
22379
|
{ sslCert: DEFAULT_SSL_CERT_KEY }
|
|
@@ -22109,7 +22411,7 @@ var ServiceCommandHandler = class {
|
|
|
22109
22411
|
removeRemoteConfig(server, remotePath) {
|
|
22110
22412
|
return new Promise((resolve, reject) => {
|
|
22111
22413
|
const target = `pmate@${server}`;
|
|
22112
|
-
const child = (0,
|
|
22414
|
+
const child = (0, import_node_child_process14.spawn)("ssh", [target, "sudo", "rm", "-f", remotePath], {
|
|
22113
22415
|
stdio: ["ignore", "inherit", "inherit"]
|
|
22114
22416
|
});
|
|
22115
22417
|
child.on("error", (error) => {
|
|
@@ -22127,7 +22429,7 @@ var ServiceCommandHandler = class {
|
|
|
22127
22429
|
reloadNginx(server) {
|
|
22128
22430
|
return new Promise((resolve, reject) => {
|
|
22129
22431
|
const target = `pmate@${server}`;
|
|
22130
|
-
const child = (0,
|
|
22432
|
+
const child = (0, import_node_child_process14.spawn)("ssh", [target, "sudo", "nginx", "-s", "reload"], {
|
|
22131
22433
|
stdio: ["ignore", "inherit", "inherit"]
|
|
22132
22434
|
});
|
|
22133
22435
|
child.on("error", (error) => {
|
|
@@ -22200,9 +22502,9 @@ function sleep3(ms) {
|
|
|
22200
22502
|
}
|
|
22201
22503
|
|
|
22202
22504
|
// src/commands/VercelCommandHandler.ts
|
|
22203
|
-
var
|
|
22505
|
+
var import_node_child_process15 = require("child_process");
|
|
22204
22506
|
var import_node_util = require("util");
|
|
22205
|
-
var execFileAsync = (0, import_node_util.promisify)(
|
|
22507
|
+
var execFileAsync = (0, import_node_util.promisify)(import_node_child_process15.execFile);
|
|
22206
22508
|
function parseDeploymentTimestamp(deployment) {
|
|
22207
22509
|
const candidates = [deployment.createdAt, deployment.readyAt, deployment.ready];
|
|
22208
22510
|
for (const value of candidates) {
|
|
@@ -22310,11 +22612,11 @@ init_sessionStore();
|
|
|
22310
22612
|
var RoleCommandHandler = class {
|
|
22311
22613
|
async handle(args) {
|
|
22312
22614
|
const token = this.readToken();
|
|
22313
|
-
const
|
|
22615
|
+
const baseUrl2 = this.resolveBaseUrl(args.baseUrl);
|
|
22314
22616
|
switch (args.action) {
|
|
22315
22617
|
case "list": {
|
|
22316
22618
|
const items = await this.request(
|
|
22317
|
-
|
|
22619
|
+
baseUrl2,
|
|
22318
22620
|
token,
|
|
22319
22621
|
"GET",
|
|
22320
22622
|
"/role/definitions"
|
|
@@ -22324,7 +22626,7 @@ var RoleCommandHandler = class {
|
|
|
22324
22626
|
}
|
|
22325
22627
|
case "create": {
|
|
22326
22628
|
const item = await this.request(
|
|
22327
|
-
|
|
22629
|
+
baseUrl2,
|
|
22328
22630
|
token,
|
|
22329
22631
|
"POST",
|
|
22330
22632
|
"/role/definitions",
|
|
@@ -22340,16 +22642,16 @@ var RoleCommandHandler = class {
|
|
|
22340
22642
|
}
|
|
22341
22643
|
}
|
|
22342
22644
|
}
|
|
22343
|
-
resolveBaseUrl(
|
|
22344
|
-
return (
|
|
22645
|
+
resolveBaseUrl(baseUrl2) {
|
|
22646
|
+
return (baseUrl2 || process.env.PMATE_AUTH_API_BASE_URL || process.env.AUTH_API_BASE_URL || "https://auth-api-v2.pmate.chat").replace(/\/+$/, "");
|
|
22345
22647
|
}
|
|
22346
22648
|
readToken() {
|
|
22347
22649
|
return readRequiredSession({
|
|
22348
22650
|
preferredApp: DEFAULT_APP_ID
|
|
22349
22651
|
}).token;
|
|
22350
22652
|
}
|
|
22351
|
-
async request(
|
|
22352
|
-
const response = await fetch(`${
|
|
22653
|
+
async request(baseUrl2, token, method, pathname, body) {
|
|
22654
|
+
const response = await fetch(`${baseUrl2}${pathname}`, {
|
|
22353
22655
|
method,
|
|
22354
22656
|
headers: {
|
|
22355
22657
|
Authorization: `Bearer ${token}`,
|
|
@@ -22393,9 +22695,9 @@ var RoleCommandHandler = class {
|
|
|
22393
22695
|
};
|
|
22394
22696
|
|
|
22395
22697
|
// src/commands/AccountCommandHandler.ts
|
|
22396
|
-
var
|
|
22397
|
-
var
|
|
22398
|
-
var
|
|
22698
|
+
var import_node_fs28 = require("fs");
|
|
22699
|
+
var import_node_crypto8 = require("crypto");
|
|
22700
|
+
var import_node_path33 = __toESM(require("path"));
|
|
22399
22701
|
init_sessionStore();
|
|
22400
22702
|
var AccountCommandHandler = class {
|
|
22401
22703
|
async handle(args) {
|
|
@@ -22403,9 +22705,9 @@ var AccountCommandHandler = class {
|
|
|
22403
22705
|
case "bot-keygen": {
|
|
22404
22706
|
const keyFile = this.generateBotKeyFile(args.app, args.name);
|
|
22405
22707
|
const outPath = args.out ? this.resolveFilePath(args.out) : this.resolveDefaultBotKeyPath(args.app, args.name);
|
|
22406
|
-
(0,
|
|
22407
|
-
(0,
|
|
22408
|
-
(0,
|
|
22708
|
+
(0, import_node_fs28.mkdirSync)(import_node_path33.default.dirname(outPath), { recursive: true });
|
|
22709
|
+
(0, import_node_fs28.writeFileSync)(outPath, JSON.stringify(keyFile, null, 2), { mode: 384 });
|
|
22710
|
+
(0, import_node_fs28.chmodSync)(outPath, 384);
|
|
22409
22711
|
if (!args.json) {
|
|
22410
22712
|
ui.success(`Bot key saved to ${outPath}`);
|
|
22411
22713
|
}
|
|
@@ -22416,9 +22718,9 @@ var AccountCommandHandler = class {
|
|
|
22416
22718
|
}
|
|
22417
22719
|
case "list": {
|
|
22418
22720
|
const token = this.readToken();
|
|
22419
|
-
const
|
|
22721
|
+
const baseUrl2 = this.resolveAuthBaseUrl(args.baseUrl);
|
|
22420
22722
|
const result = await this.request(
|
|
22421
|
-
|
|
22723
|
+
baseUrl2,
|
|
22422
22724
|
token,
|
|
22423
22725
|
"GET",
|
|
22424
22726
|
`/accounts?${this.buildAccountListQuery(args)}`
|
|
@@ -22428,9 +22730,9 @@ var AccountCommandHandler = class {
|
|
|
22428
22730
|
}
|
|
22429
22731
|
case "app-users": {
|
|
22430
22732
|
const token = this.readToken();
|
|
22431
|
-
const
|
|
22733
|
+
const baseUrl2 = this.resolveAuthBaseUrl(args.baseUrl);
|
|
22432
22734
|
const result = await this.request(
|
|
22433
|
-
|
|
22735
|
+
baseUrl2,
|
|
22434
22736
|
token,
|
|
22435
22737
|
"GET",
|
|
22436
22738
|
`/accounts/app-users/${encodeURIComponent(args.app)}?${this.buildPagedQuery(args)}`
|
|
@@ -22440,9 +22742,9 @@ var AccountCommandHandler = class {
|
|
|
22440
22742
|
}
|
|
22441
22743
|
case "view": {
|
|
22442
22744
|
const token = this.readToken();
|
|
22443
|
-
const
|
|
22745
|
+
const baseUrl2 = this.resolveAuthBaseUrl(args.baseUrl);
|
|
22444
22746
|
const result = await this.request(
|
|
22445
|
-
|
|
22747
|
+
baseUrl2,
|
|
22446
22748
|
token,
|
|
22447
22749
|
"GET",
|
|
22448
22750
|
`/accounts/view?${this.buildAccountViewQuery(args)}`
|
|
@@ -22452,9 +22754,9 @@ var AccountCommandHandler = class {
|
|
|
22452
22754
|
}
|
|
22453
22755
|
case "role-list": {
|
|
22454
22756
|
const token = this.readToken();
|
|
22455
|
-
const
|
|
22757
|
+
const baseUrl2 = this.resolveAuthBaseUrl(args.baseUrl);
|
|
22456
22758
|
const items = await this.request(
|
|
22457
|
-
|
|
22759
|
+
baseUrl2,
|
|
22458
22760
|
token,
|
|
22459
22761
|
"GET",
|
|
22460
22762
|
`/role/bindings?${this.buildRoleBindingsQuery(args)}`
|
|
@@ -22464,9 +22766,9 @@ var AccountCommandHandler = class {
|
|
|
22464
22766
|
}
|
|
22465
22767
|
case "role-add": {
|
|
22466
22768
|
const token = this.readToken();
|
|
22467
|
-
const
|
|
22769
|
+
const baseUrl2 = this.resolveAuthBaseUrl(args.baseUrl);
|
|
22468
22770
|
const item = await this.request(
|
|
22469
|
-
|
|
22771
|
+
baseUrl2,
|
|
22470
22772
|
token,
|
|
22471
22773
|
"POST",
|
|
22472
22774
|
"/role/bindings",
|
|
@@ -22482,9 +22784,9 @@ var AccountCommandHandler = class {
|
|
|
22482
22784
|
}
|
|
22483
22785
|
case "role-remove": {
|
|
22484
22786
|
const token = this.readToken();
|
|
22485
|
-
const
|
|
22787
|
+
const baseUrl2 = this.resolveAuthBaseUrl(args.baseUrl);
|
|
22486
22788
|
await this.request(
|
|
22487
|
-
|
|
22789
|
+
baseUrl2,
|
|
22488
22790
|
token,
|
|
22489
22791
|
"DELETE",
|
|
22490
22792
|
"/role/bindings",
|
|
@@ -22499,9 +22801,9 @@ var AccountCommandHandler = class {
|
|
|
22499
22801
|
}
|
|
22500
22802
|
case "visible-app-list": {
|
|
22501
22803
|
const token = this.readToken();
|
|
22502
|
-
const
|
|
22804
|
+
const baseUrl2 = this.resolveAppsBaseUrl(args.baseUrl);
|
|
22503
22805
|
const result = await this.request(
|
|
22504
|
-
|
|
22806
|
+
baseUrl2,
|
|
22505
22807
|
token,
|
|
22506
22808
|
"GET",
|
|
22507
22809
|
`/accounts/${encodeURIComponent(args.account)}/visible-apps`
|
|
@@ -22511,9 +22813,9 @@ var AccountCommandHandler = class {
|
|
|
22511
22813
|
}
|
|
22512
22814
|
case "visible-app-add": {
|
|
22513
22815
|
const token = this.readToken();
|
|
22514
|
-
const
|
|
22816
|
+
const baseUrl2 = this.resolveAppsBaseUrl(args.baseUrl);
|
|
22515
22817
|
const item = await this.request(
|
|
22516
|
-
|
|
22818
|
+
baseUrl2,
|
|
22517
22819
|
token,
|
|
22518
22820
|
"PUT",
|
|
22519
22821
|
`/accounts/${encodeURIComponent(args.account)}/visible-apps/${encodePathSegment2(args.app)}`
|
|
@@ -22524,9 +22826,9 @@ var AccountCommandHandler = class {
|
|
|
22524
22826
|
}
|
|
22525
22827
|
case "visible-app-remove": {
|
|
22526
22828
|
const token = this.readToken();
|
|
22527
|
-
const
|
|
22829
|
+
const baseUrl2 = this.resolveAppsBaseUrl(args.baseUrl);
|
|
22528
22830
|
const result = await this.request(
|
|
22529
|
-
|
|
22831
|
+
baseUrl2,
|
|
22530
22832
|
token,
|
|
22531
22833
|
"DELETE",
|
|
22532
22834
|
`/accounts/${encodeURIComponent(args.account)}/visible-apps/${encodePathSegment2(args.app)}`
|
|
@@ -22539,10 +22841,10 @@ var AccountCommandHandler = class {
|
|
|
22539
22841
|
}
|
|
22540
22842
|
case "visible-app-set": {
|
|
22541
22843
|
const token = this.readToken();
|
|
22542
|
-
const
|
|
22844
|
+
const baseUrl2 = this.resolveAppsBaseUrl(args.baseUrl);
|
|
22543
22845
|
const items = this.resolveVisibleAppsInput(args);
|
|
22544
22846
|
const result = await this.request(
|
|
22545
|
-
|
|
22847
|
+
baseUrl2,
|
|
22546
22848
|
token,
|
|
22547
22849
|
"PUT",
|
|
22548
22850
|
`/accounts/${encodeURIComponent(args.account)}/visible-apps`,
|
|
@@ -22554,9 +22856,9 @@ var AccountCommandHandler = class {
|
|
|
22554
22856
|
}
|
|
22555
22857
|
case "visible-app-resolve": {
|
|
22556
22858
|
const token = this.readToken();
|
|
22557
|
-
const
|
|
22859
|
+
const baseUrl2 = this.resolveAppsBaseUrl(args.baseUrl);
|
|
22558
22860
|
const result = await this.request(
|
|
22559
|
-
|
|
22861
|
+
baseUrl2,
|
|
22560
22862
|
token,
|
|
22561
22863
|
"GET",
|
|
22562
22864
|
"/me/visible-apps"
|
|
@@ -22569,10 +22871,10 @@ var AccountCommandHandler = class {
|
|
|
22569
22871
|
}
|
|
22570
22872
|
case "bot-create": {
|
|
22571
22873
|
const token = this.readToken();
|
|
22572
|
-
const
|
|
22874
|
+
const baseUrl2 = this.resolveAuthBaseUrl(args.baseUrl);
|
|
22573
22875
|
const publicKey = args.publicKey ?? this.readBotKeyFile(args.keyFile, args.app, args.name).publicKey;
|
|
22574
22876
|
const bot = await this.request(
|
|
22575
|
-
|
|
22877
|
+
baseUrl2,
|
|
22576
22878
|
token,
|
|
22577
22879
|
"POST",
|
|
22578
22880
|
"/accounts/bots",
|
|
@@ -22590,9 +22892,9 @@ var AccountCommandHandler = class {
|
|
|
22590
22892
|
return;
|
|
22591
22893
|
}
|
|
22592
22894
|
case "bot-view": {
|
|
22593
|
-
const
|
|
22895
|
+
const baseUrl2 = this.resolveAuthBaseUrl(args.baseUrl);
|
|
22594
22896
|
const bot = await this.request(
|
|
22595
|
-
|
|
22897
|
+
baseUrl2,
|
|
22596
22898
|
void 0,
|
|
22597
22899
|
"GET",
|
|
22598
22900
|
`/accounts/bots/${encodeURIComponent(args.app)}/${encodeURIComponent(args.name)}`
|
|
@@ -22601,9 +22903,9 @@ var AccountCommandHandler = class {
|
|
|
22601
22903
|
return;
|
|
22602
22904
|
}
|
|
22603
22905
|
case "bot-list": {
|
|
22604
|
-
const
|
|
22906
|
+
const baseUrl2 = this.resolveAuthBaseUrl(args.baseUrl);
|
|
22605
22907
|
const result = await this.request(
|
|
22606
|
-
|
|
22908
|
+
baseUrl2,
|
|
22607
22909
|
void 0,
|
|
22608
22910
|
"GET",
|
|
22609
22911
|
`/accounts/bots?app=${encodeURIComponent(args.app)}`
|
|
@@ -22623,9 +22925,9 @@ var AccountCommandHandler = class {
|
|
|
22623
22925
|
}
|
|
22624
22926
|
case "bot-rename": {
|
|
22625
22927
|
const token = this.readToken();
|
|
22626
|
-
const
|
|
22928
|
+
const baseUrl2 = this.resolveAuthBaseUrl(args.baseUrl);
|
|
22627
22929
|
const bot = await this.request(
|
|
22628
|
-
|
|
22930
|
+
baseUrl2,
|
|
22629
22931
|
token,
|
|
22630
22932
|
"POST",
|
|
22631
22933
|
"/accounts/bots/rename",
|
|
@@ -22646,17 +22948,17 @@ var AccountCommandHandler = class {
|
|
|
22646
22948
|
return;
|
|
22647
22949
|
}
|
|
22648
22950
|
case "bot-login": {
|
|
22649
|
-
const
|
|
22951
|
+
const baseUrl2 = this.resolveAuthBaseUrl(args.baseUrl);
|
|
22650
22952
|
const privateKey = args.privateKey ?? this.readBotKeyFile(args.keyFile, args.app, args.name).privateKey;
|
|
22651
22953
|
const challenge = await this.request(
|
|
22652
|
-
|
|
22954
|
+
baseUrl2,
|
|
22653
22955
|
void 0,
|
|
22654
22956
|
"POST",
|
|
22655
22957
|
"/accounts/bots/session/challenge",
|
|
22656
22958
|
{ app: args.app, name: args.name }
|
|
22657
22959
|
);
|
|
22658
22960
|
const login = await this.request(
|
|
22659
|
-
|
|
22961
|
+
baseUrl2,
|
|
22660
22962
|
void 0,
|
|
22661
22963
|
"POST",
|
|
22662
22964
|
"/accounts/bots/session",
|
|
@@ -22673,7 +22975,7 @@ var AccountCommandHandler = class {
|
|
|
22673
22975
|
token: login.token,
|
|
22674
22976
|
app: args.app,
|
|
22675
22977
|
accountId: login.session.identity.accountId,
|
|
22676
|
-
authApiBaseUrl:
|
|
22978
|
+
authApiBaseUrl: baseUrl2
|
|
22677
22979
|
});
|
|
22678
22980
|
const saved = saveLoginSession({ ...login, profileId }, args.app);
|
|
22679
22981
|
if (!args.json) {
|
|
@@ -22684,9 +22986,9 @@ var AccountCommandHandler = class {
|
|
|
22684
22986
|
}
|
|
22685
22987
|
case "bot-profile-create": {
|
|
22686
22988
|
const token = this.readToken();
|
|
22687
|
-
const
|
|
22989
|
+
const baseUrl2 = this.resolveAuthBaseUrl(args.baseUrl);
|
|
22688
22990
|
const profile = await this.request(
|
|
22689
|
-
|
|
22991
|
+
baseUrl2,
|
|
22690
22992
|
token,
|
|
22691
22993
|
"POST",
|
|
22692
22994
|
"/accounts/bots/profile",
|
|
@@ -22705,9 +23007,9 @@ var AccountCommandHandler = class {
|
|
|
22705
23007
|
}
|
|
22706
23008
|
case "access-key-create": {
|
|
22707
23009
|
const token = this.readToken();
|
|
22708
|
-
const
|
|
23010
|
+
const baseUrl2 = this.resolveAuthBaseUrl(args.baseUrl);
|
|
22709
23011
|
const result = await this.request(
|
|
22710
|
-
|
|
23012
|
+
baseUrl2,
|
|
22711
23013
|
token,
|
|
22712
23014
|
"POST",
|
|
22713
23015
|
"/access-keys",
|
|
@@ -22724,9 +23026,9 @@ var AccountCommandHandler = class {
|
|
|
22724
23026
|
}
|
|
22725
23027
|
case "access-key-list": {
|
|
22726
23028
|
const token = this.readToken();
|
|
22727
|
-
const
|
|
23029
|
+
const baseUrl2 = this.resolveAuthBaseUrl(args.baseUrl);
|
|
22728
23030
|
const result = await this.request(
|
|
22729
|
-
|
|
23031
|
+
baseUrl2,
|
|
22730
23032
|
token,
|
|
22731
23033
|
"GET",
|
|
22732
23034
|
`/access-keys?${this.buildAccessKeyListQuery(args)}`
|
|
@@ -22736,9 +23038,9 @@ var AccountCommandHandler = class {
|
|
|
22736
23038
|
}
|
|
22737
23039
|
case "access-key-disable": {
|
|
22738
23040
|
const token = this.readToken();
|
|
22739
|
-
const
|
|
23041
|
+
const baseUrl2 = this.resolveAuthBaseUrl(args.baseUrl);
|
|
22740
23042
|
const item = await this.request(
|
|
22741
|
-
|
|
23043
|
+
baseUrl2,
|
|
22742
23044
|
token,
|
|
22743
23045
|
"DELETE",
|
|
22744
23046
|
`/access-keys/${encodeURIComponent(args.id)}`
|
|
@@ -22751,9 +23053,9 @@ var AccountCommandHandler = class {
|
|
|
22751
23053
|
}
|
|
22752
23054
|
case "access-key-rotate": {
|
|
22753
23055
|
const token = this.readToken();
|
|
22754
|
-
const
|
|
23056
|
+
const baseUrl2 = this.resolveAuthBaseUrl(args.baseUrl);
|
|
22755
23057
|
const result = await this.request(
|
|
22756
|
-
|
|
23058
|
+
baseUrl2,
|
|
22757
23059
|
token,
|
|
22758
23060
|
"POST",
|
|
22759
23061
|
`/access-keys/${encodeURIComponent(args.id)}/rotate`,
|
|
@@ -22767,16 +23069,16 @@ var AccountCommandHandler = class {
|
|
|
22767
23069
|
return;
|
|
22768
23070
|
}
|
|
22769
23071
|
case "access-key-login": {
|
|
22770
|
-
const
|
|
23072
|
+
const baseUrl2 = this.resolveAuthBaseUrl(args.baseUrl);
|
|
22771
23073
|
const secret = args.key ?? this.readAccessKeyFile(args.keyFile, args.app).secret;
|
|
22772
23074
|
const login = await this.request(
|
|
22773
|
-
|
|
23075
|
+
baseUrl2,
|
|
22774
23076
|
secret,
|
|
22775
23077
|
"POST",
|
|
22776
23078
|
"/access-keys/session",
|
|
22777
23079
|
{ app: args.app }
|
|
22778
23080
|
);
|
|
22779
|
-
const profileId = await this.resolveLoginProfileId(login, args.app,
|
|
23081
|
+
const profileId = await this.resolveLoginProfileId(login, args.app, baseUrl2);
|
|
22780
23082
|
const saved = saveLoginSession({ ...login, profileId }, args.app);
|
|
22781
23083
|
if (!args.json) {
|
|
22782
23084
|
ui.success(`Logged in access key ${login.session.identity.accessKeyId ?? "unknown"} to ${saved.app}`);
|
|
@@ -22786,11 +23088,11 @@ var AccountCommandHandler = class {
|
|
|
22786
23088
|
}
|
|
22787
23089
|
}
|
|
22788
23090
|
}
|
|
22789
|
-
resolveAuthBaseUrl(
|
|
22790
|
-
return (
|
|
23091
|
+
resolveAuthBaseUrl(baseUrl2) {
|
|
23092
|
+
return (baseUrl2 || process.env.PMATE_AUTH_API_BASE_URL || process.env.AUTH_API_BASE_URL || "https://auth-api-v2.pmate.chat").replace(/\/+$/, "");
|
|
22791
23093
|
}
|
|
22792
|
-
resolveAppsBaseUrl(
|
|
22793
|
-
return (
|
|
23094
|
+
resolveAppsBaseUrl(baseUrl2) {
|
|
23095
|
+
return (baseUrl2 || process.env.PMATE_APPS_API_BASE_URL || "https://apps-api.pmate.chat").replace(/\/+$/, "");
|
|
22794
23096
|
}
|
|
22795
23097
|
readToken() {
|
|
22796
23098
|
return readRequiredSession({
|
|
@@ -22830,8 +23132,8 @@ var AccountCommandHandler = class {
|
|
|
22830
23132
|
if (args.namespace) params.set("namespace", args.namespace);
|
|
22831
23133
|
return params.toString();
|
|
22832
23134
|
}
|
|
22833
|
-
async request(
|
|
22834
|
-
const response = await fetch(`${
|
|
23135
|
+
async request(baseUrl2, token, method, pathname, body) {
|
|
23136
|
+
const response = await fetch(`${baseUrl2}${pathname}`, {
|
|
22835
23137
|
method,
|
|
22836
23138
|
headers: {
|
|
22837
23139
|
...token ? { Authorization: `Bearer ${token}` } : {},
|
|
@@ -22965,10 +23267,10 @@ var AccountCommandHandler = class {
|
|
|
22965
23267
|
throw new Error("Missing visible apps input");
|
|
22966
23268
|
}
|
|
22967
23269
|
const absolutePath = this.resolveFilePath(args.filePath);
|
|
22968
|
-
if (!(0,
|
|
23270
|
+
if (!(0, import_node_fs28.existsSync)(absolutePath)) {
|
|
22969
23271
|
throw new Error(`JSON file not found: ${absolutePath}`);
|
|
22970
23272
|
}
|
|
22971
|
-
const raw = (0,
|
|
23273
|
+
const raw = (0, import_node_fs28.readFileSync)(absolutePath, "utf8");
|
|
22972
23274
|
let parsed;
|
|
22973
23275
|
try {
|
|
22974
23276
|
parsed = JSON.parse(raw);
|
|
@@ -22982,19 +23284,19 @@ var AccountCommandHandler = class {
|
|
|
22982
23284
|
return parsed;
|
|
22983
23285
|
}
|
|
22984
23286
|
resolveFilePath(filePath) {
|
|
22985
|
-
return
|
|
23287
|
+
return import_node_path33.default.resolve(process.cwd(), filePath);
|
|
22986
23288
|
}
|
|
22987
23289
|
resolveDefaultBotKeyPath(app, name) {
|
|
22988
|
-
return
|
|
23290
|
+
return import_node_path33.default.join(this.homeDir(), ".pmate", "bots", app, `${name}.bot-key.json`);
|
|
22989
23291
|
}
|
|
22990
23292
|
resolveDefaultAccessKeyPath(app, name) {
|
|
22991
|
-
return
|
|
23293
|
+
return import_node_path33.default.join(this.homeDir(), ".pmate", "access-keys", app, `${name}.access-key.json`);
|
|
22992
23294
|
}
|
|
22993
23295
|
homeDir() {
|
|
22994
23296
|
return process.env.HOME || process.env.USERPROFILE || process.cwd();
|
|
22995
23297
|
}
|
|
22996
23298
|
generateBotKeyFile(app, name) {
|
|
22997
|
-
const { publicKey, privateKey } = (0,
|
|
23299
|
+
const { publicKey, privateKey } = (0, import_node_crypto8.generateKeyPairSync)("ed25519");
|
|
22998
23300
|
return {
|
|
22999
23301
|
type: "pmate-bot-key",
|
|
23000
23302
|
version: 1,
|
|
@@ -23008,14 +23310,14 @@ var AccountCommandHandler = class {
|
|
|
23008
23310
|
}
|
|
23009
23311
|
renameDefaultBotKeyFile(app, name, newName) {
|
|
23010
23312
|
const oldPath = this.resolveDefaultBotKeyPath(app, name);
|
|
23011
|
-
if (!(0,
|
|
23313
|
+
if (!(0, import_node_fs28.existsSync)(oldPath)) {
|
|
23012
23314
|
return void 0;
|
|
23013
23315
|
}
|
|
23014
23316
|
const keyFile = this.readBotKeyFile(oldPath, app, name);
|
|
23015
23317
|
const newPath = this.resolveDefaultBotKeyPath(app, newName);
|
|
23016
|
-
(0,
|
|
23017
|
-
(0,
|
|
23018
|
-
(0,
|
|
23318
|
+
(0, import_node_fs28.mkdirSync)(import_node_path33.default.dirname(newPath), { recursive: true, mode: 448 });
|
|
23319
|
+
(0, import_node_fs28.writeFileSync)(newPath, JSON.stringify({ ...keyFile, name: newName }, null, 2));
|
|
23320
|
+
(0, import_node_fs28.chmodSync)(newPath, 384);
|
|
23019
23321
|
return newPath;
|
|
23020
23322
|
}
|
|
23021
23323
|
readBotKeyFile(filePath, expectedApp, expectedName) {
|
|
@@ -23023,10 +23325,10 @@ var AccountCommandHandler = class {
|
|
|
23023
23325
|
throw new Error("Missing bot key file");
|
|
23024
23326
|
}
|
|
23025
23327
|
const absolutePath = this.resolveFilePath(filePath);
|
|
23026
|
-
if (!(0,
|
|
23328
|
+
if (!(0, import_node_fs28.existsSync)(absolutePath)) {
|
|
23027
23329
|
throw new Error(`Bot key file not found: ${absolutePath}`);
|
|
23028
23330
|
}
|
|
23029
|
-
const parsed = JSON.parse((0,
|
|
23331
|
+
const parsed = JSON.parse((0, import_node_fs28.readFileSync)(absolutePath, "utf8"));
|
|
23030
23332
|
if (parsed.type !== "pmate-bot-key" || parsed.version !== 1 || parsed.algorithm !== "ed25519" || !parsed.publicKey || !parsed.privateKey) {
|
|
23031
23333
|
throw new Error(`Invalid PMate bot key file: ${absolutePath}`);
|
|
23032
23334
|
}
|
|
@@ -23043,10 +23345,10 @@ var AccountCommandHandler = class {
|
|
|
23043
23345
|
throw new Error("Missing access key file");
|
|
23044
23346
|
}
|
|
23045
23347
|
const absolutePath = this.resolveFilePath(filePath);
|
|
23046
|
-
if (!(0,
|
|
23348
|
+
if (!(0, import_node_fs28.existsSync)(absolutePath)) {
|
|
23047
23349
|
throw new Error(`Access key file not found: ${absolutePath}`);
|
|
23048
23350
|
}
|
|
23049
|
-
const parsed = JSON.parse((0,
|
|
23351
|
+
const parsed = JSON.parse((0, import_node_fs28.readFileSync)(absolutePath, "utf8"));
|
|
23050
23352
|
if (parsed.type !== "pmate-access-key" || parsed.version !== 1 || !parsed.id || !parsed.app || !parsed.secret || !parsed.expiresAt) {
|
|
23051
23353
|
throw new Error(`Invalid PMate access key file: ${absolutePath}`);
|
|
23052
23354
|
}
|
|
@@ -23068,9 +23370,9 @@ var AccountCommandHandler = class {
|
|
|
23068
23370
|
createdAt: result.key.createdAt
|
|
23069
23371
|
};
|
|
23070
23372
|
const outPath = out ? this.resolveFilePath(out) : this.resolveDefaultAccessKeyPath(result.key.app, result.key.name);
|
|
23071
|
-
(0,
|
|
23072
|
-
(0,
|
|
23073
|
-
(0,
|
|
23373
|
+
(0, import_node_fs28.mkdirSync)(import_node_path33.default.dirname(outPath), { recursive: true });
|
|
23374
|
+
(0, import_node_fs28.writeFileSync)(outPath, JSON.stringify(keyFile, null, 2), { mode: 384 });
|
|
23375
|
+
(0, import_node_fs28.chmodSync)(outPath, 384);
|
|
23074
23376
|
}
|
|
23075
23377
|
renderAccessKeyCreateResult(result, asJson, out) {
|
|
23076
23378
|
if (asJson) {
|
|
@@ -23116,12 +23418,12 @@ var AccountCommandHandler = class {
|
|
|
23116
23418
|
});
|
|
23117
23419
|
}
|
|
23118
23420
|
signBotChallenge(challenge, privateKey) {
|
|
23119
|
-
const key = (0,
|
|
23421
|
+
const key = (0, import_node_crypto8.createPrivateKey)({
|
|
23120
23422
|
key: Buffer.from(privateKey, "base64url"),
|
|
23121
23423
|
format: "der",
|
|
23122
23424
|
type: "pkcs8"
|
|
23123
23425
|
});
|
|
23124
|
-
return (0,
|
|
23426
|
+
return (0, import_node_crypto8.sign)(
|
|
23125
23427
|
null,
|
|
23126
23428
|
Buffer.from(JSON.stringify({
|
|
23127
23429
|
id: challenge.id,
|
|
@@ -23155,16 +23457,16 @@ function encodePathSegment2(value) {
|
|
|
23155
23457
|
}
|
|
23156
23458
|
|
|
23157
23459
|
// src/commands/OrgCommandHandler.ts
|
|
23158
|
-
var
|
|
23159
|
-
var
|
|
23460
|
+
var import_node_fs29 = require("fs");
|
|
23461
|
+
var import_node_path34 = __toESM(require("path"));
|
|
23160
23462
|
init_sessionStore();
|
|
23161
23463
|
var OrgCommandHandler = class {
|
|
23162
23464
|
async handle(args) {
|
|
23163
23465
|
const token = this.readToken();
|
|
23164
|
-
const
|
|
23466
|
+
const baseUrl2 = this.resolveBaseUrl(args.baseUrl);
|
|
23165
23467
|
switch (args.action) {
|
|
23166
23468
|
case "list": {
|
|
23167
|
-
const result = await this.request(
|
|
23469
|
+
const result = await this.request(baseUrl2, token, "GET", "/orgs");
|
|
23168
23470
|
this.renderJson(result.items, args.json);
|
|
23169
23471
|
if (!args.json) {
|
|
23170
23472
|
this.renderOrgList(result.items);
|
|
@@ -23174,7 +23476,7 @@ var OrgCommandHandler = class {
|
|
|
23174
23476
|
case "get":
|
|
23175
23477
|
case "view": {
|
|
23176
23478
|
const record = await this.request(
|
|
23177
|
-
|
|
23479
|
+
baseUrl2,
|
|
23178
23480
|
token,
|
|
23179
23481
|
"GET",
|
|
23180
23482
|
`/orgs/${encodeURIComponent(args.orgId)}`
|
|
@@ -23183,7 +23485,7 @@ var OrgCommandHandler = class {
|
|
|
23183
23485
|
return;
|
|
23184
23486
|
}
|
|
23185
23487
|
case "create": {
|
|
23186
|
-
const record = await this.request(
|
|
23488
|
+
const record = await this.request(baseUrl2, token, "POST", "/orgs", {
|
|
23187
23489
|
id: args.orgId,
|
|
23188
23490
|
displayName: args.displayName,
|
|
23189
23491
|
members: args.members
|
|
@@ -23194,7 +23496,7 @@ var OrgCommandHandler = class {
|
|
|
23194
23496
|
}
|
|
23195
23497
|
case "update": {
|
|
23196
23498
|
const record = await this.request(
|
|
23197
|
-
|
|
23499
|
+
baseUrl2,
|
|
23198
23500
|
token,
|
|
23199
23501
|
"PATCH",
|
|
23200
23502
|
`/orgs/${encodeURIComponent(args.orgId)}`,
|
|
@@ -23208,7 +23510,7 @@ var OrgCommandHandler = class {
|
|
|
23208
23510
|
}
|
|
23209
23511
|
case "disable": {
|
|
23210
23512
|
const record = await this.request(
|
|
23211
|
-
|
|
23513
|
+
baseUrl2,
|
|
23212
23514
|
token,
|
|
23213
23515
|
"DELETE",
|
|
23214
23516
|
`/orgs/${encodeURIComponent(args.orgId)}`
|
|
@@ -23219,7 +23521,7 @@ var OrgCommandHandler = class {
|
|
|
23219
23521
|
}
|
|
23220
23522
|
case "member-list": {
|
|
23221
23523
|
const result = await this.request(
|
|
23222
|
-
|
|
23524
|
+
baseUrl2,
|
|
23223
23525
|
token,
|
|
23224
23526
|
"GET",
|
|
23225
23527
|
`/orgs/${encodeURIComponent(args.orgId)}/members`
|
|
@@ -23229,7 +23531,7 @@ var OrgCommandHandler = class {
|
|
|
23229
23531
|
}
|
|
23230
23532
|
case "member-add": {
|
|
23231
23533
|
const record = await this.request(
|
|
23232
|
-
|
|
23534
|
+
baseUrl2,
|
|
23233
23535
|
token,
|
|
23234
23536
|
"PUT",
|
|
23235
23537
|
`/orgs/${encodeURIComponent(args.orgId)}/members/${encodeURIComponent(args.account)}`
|
|
@@ -23240,7 +23542,7 @@ var OrgCommandHandler = class {
|
|
|
23240
23542
|
}
|
|
23241
23543
|
case "member-remove": {
|
|
23242
23544
|
const record = await this.request(
|
|
23243
|
-
|
|
23545
|
+
baseUrl2,
|
|
23244
23546
|
token,
|
|
23245
23547
|
"DELETE",
|
|
23246
23548
|
`/orgs/${encodeURIComponent(args.orgId)}/members/${encodeURIComponent(args.account)}`
|
|
@@ -23252,7 +23554,7 @@ var OrgCommandHandler = class {
|
|
|
23252
23554
|
case "member-set": {
|
|
23253
23555
|
const accounts = this.resolveStringArrayInput(args.accounts, args.filePath, "account");
|
|
23254
23556
|
const record = await this.request(
|
|
23255
|
-
|
|
23557
|
+
baseUrl2,
|
|
23256
23558
|
token,
|
|
23257
23559
|
"PUT",
|
|
23258
23560
|
`/orgs/${encodeURIComponent(args.orgId)}/members`,
|
|
@@ -23264,7 +23566,7 @@ var OrgCommandHandler = class {
|
|
|
23264
23566
|
}
|
|
23265
23567
|
case "visible-app-list": {
|
|
23266
23568
|
const result = await this.request(
|
|
23267
|
-
|
|
23569
|
+
baseUrl2,
|
|
23268
23570
|
token,
|
|
23269
23571
|
"GET",
|
|
23270
23572
|
`/orgs/${encodeURIComponent(args.orgId)}/visible-apps`
|
|
@@ -23274,7 +23576,7 @@ var OrgCommandHandler = class {
|
|
|
23274
23576
|
}
|
|
23275
23577
|
case "visible-app-add": {
|
|
23276
23578
|
const record = await this.request(
|
|
23277
|
-
|
|
23579
|
+
baseUrl2,
|
|
23278
23580
|
token,
|
|
23279
23581
|
"PUT",
|
|
23280
23582
|
`/orgs/${encodeURIComponent(args.orgId)}/visible-apps/${encodePathSegment3(args.app)}`
|
|
@@ -23285,7 +23587,7 @@ var OrgCommandHandler = class {
|
|
|
23285
23587
|
}
|
|
23286
23588
|
case "visible-app-remove": {
|
|
23287
23589
|
const result = await this.request(
|
|
23288
|
-
|
|
23590
|
+
baseUrl2,
|
|
23289
23591
|
token,
|
|
23290
23592
|
"DELETE",
|
|
23291
23593
|
`/orgs/${encodeURIComponent(args.orgId)}/visible-apps/${encodePathSegment3(args.app)}`
|
|
@@ -23299,7 +23601,7 @@ var OrgCommandHandler = class {
|
|
|
23299
23601
|
case "visible-app-set": {
|
|
23300
23602
|
const apps = this.resolveStringArrayInput(args.apps, args.filePath, "app ref");
|
|
23301
23603
|
const result = await this.request(
|
|
23302
|
-
|
|
23604
|
+
baseUrl2,
|
|
23303
23605
|
token,
|
|
23304
23606
|
"PUT",
|
|
23305
23607
|
`/orgs/${encodeURIComponent(args.orgId)}/visible-apps`,
|
|
@@ -23311,8 +23613,8 @@ var OrgCommandHandler = class {
|
|
|
23311
23613
|
}
|
|
23312
23614
|
}
|
|
23313
23615
|
}
|
|
23314
|
-
resolveBaseUrl(
|
|
23315
|
-
return (
|
|
23616
|
+
resolveBaseUrl(baseUrl2) {
|
|
23617
|
+
return (baseUrl2 || process.env.PMATE_APPS_API_BASE_URL || "https://apps-api.pmate.chat").replace(/\/+$/, "");
|
|
23316
23618
|
}
|
|
23317
23619
|
readToken() {
|
|
23318
23620
|
return readRequiredSession({
|
|
@@ -23326,11 +23628,11 @@ var OrgCommandHandler = class {
|
|
|
23326
23628
|
if (!filePath) {
|
|
23327
23629
|
throw new Error(`Missing ${itemLabel} input`);
|
|
23328
23630
|
}
|
|
23329
|
-
const absolutePath =
|
|
23330
|
-
if (!(0,
|
|
23631
|
+
const absolutePath = import_node_path34.default.resolve(process.cwd(), filePath);
|
|
23632
|
+
if (!(0, import_node_fs29.existsSync)(absolutePath)) {
|
|
23331
23633
|
throw new Error(`JSON file not found: ${absolutePath}`);
|
|
23332
23634
|
}
|
|
23333
|
-
const raw = (0,
|
|
23635
|
+
const raw = (0, import_node_fs29.readFileSync)(absolutePath, "utf8");
|
|
23334
23636
|
let parsed;
|
|
23335
23637
|
try {
|
|
23336
23638
|
parsed = JSON.parse(raw);
|
|
@@ -23343,8 +23645,8 @@ var OrgCommandHandler = class {
|
|
|
23343
23645
|
}
|
|
23344
23646
|
return parsed;
|
|
23345
23647
|
}
|
|
23346
|
-
async request(
|
|
23347
|
-
const response = await fetch(`${
|
|
23648
|
+
async request(baseUrl2, token, method, pathname, body) {
|
|
23649
|
+
const response = await fetch(`${baseUrl2}${pathname}`, {
|
|
23348
23650
|
method,
|
|
23349
23651
|
headers: {
|
|
23350
23652
|
Authorization: `Bearer ${token}`,
|
|
@@ -23401,10 +23703,10 @@ function encodePathSegment3(value) {
|
|
|
23401
23703
|
}
|
|
23402
23704
|
|
|
23403
23705
|
// src/commands/HostCommandHandler.ts
|
|
23404
|
-
var
|
|
23405
|
-
var
|
|
23406
|
-
var
|
|
23407
|
-
var
|
|
23706
|
+
var import_node_fs30 = require("fs");
|
|
23707
|
+
var import_node_os15 = require("os");
|
|
23708
|
+
var import_node_path35 = __toESM(require("path"));
|
|
23709
|
+
var import_node_child_process16 = require("child_process");
|
|
23408
23710
|
var BLOCK_START = "# >>> pmate host env >>>";
|
|
23409
23711
|
var BLOCK_END = "# <<< pmate host env <<<";
|
|
23410
23712
|
var PROFILE_BLOCK = `${BLOCK_START}
|
|
@@ -23416,7 +23718,7 @@ fi
|
|
|
23416
23718
|
${BLOCK_END}`;
|
|
23417
23719
|
var HostCommandHandler = class {
|
|
23418
23720
|
async handle(args) {
|
|
23419
|
-
const hostId = normalizeHostId(args.host ?? process.env.PMATE_HOST_ID ?? (0,
|
|
23721
|
+
const hostId = normalizeHostId(args.host ?? process.env.PMATE_HOST_ID ?? (0, import_node_os15.hostname)());
|
|
23420
23722
|
const client = new ServiceRegistryClient(args.baseUrl);
|
|
23421
23723
|
if (args.action === "env-list") {
|
|
23422
23724
|
const items = await client.listHostEnv(hostId);
|
|
@@ -23447,7 +23749,7 @@ async function applyHostEnvRemote(host, values) {
|
|
|
23447
23749
|
const content = serializeHostEnv(values);
|
|
23448
23750
|
const script = buildRemoteApplyScript(Buffer.from(content, "utf8").toString("base64"));
|
|
23449
23751
|
await new Promise((resolve, reject) => {
|
|
23450
|
-
const child = (0,
|
|
23752
|
+
const child = (0, import_node_child_process16.spawn)("ssh", [target, "bash -s"], { stdio: ["pipe", "pipe", "pipe"] });
|
|
23451
23753
|
let stdout = "";
|
|
23452
23754
|
let stderr = "";
|
|
23453
23755
|
child.stdout.on("data", (chunk) => {
|
|
@@ -23533,7 +23835,7 @@ function parseRegistryArgs(tokens, type, label) {
|
|
|
23533
23835
|
if (!action || !["list", "get", "view", "create", "update", "delete"].includes(action)) {
|
|
23534
23836
|
throw new Error(`Use: ${label} list|get|view|create|update|delete`);
|
|
23535
23837
|
}
|
|
23536
|
-
let
|
|
23838
|
+
let baseUrl2;
|
|
23537
23839
|
let json = false;
|
|
23538
23840
|
let namespace;
|
|
23539
23841
|
let name;
|
|
@@ -23556,7 +23858,7 @@ function parseRegistryArgs(tokens, type, label) {
|
|
|
23556
23858
|
return next;
|
|
23557
23859
|
};
|
|
23558
23860
|
if (option === "--namespace" || option === "--ns") namespace = value();
|
|
23559
|
-
else if (option === "--base-url")
|
|
23861
|
+
else if (option === "--base-url") baseUrl2 = value();
|
|
23560
23862
|
else if (option === "--file") filePath = value();
|
|
23561
23863
|
else if (option === "--json") json = true;
|
|
23562
23864
|
else throw new Error(`Unknown ${label} option: ${option}`);
|
|
@@ -23564,7 +23866,7 @@ function parseRegistryArgs(tokens, type, label) {
|
|
|
23564
23866
|
if ((action === "create" || action === "update") && !filePath) {
|
|
23565
23867
|
throw new Error(`Missing required option --file for ${label} ${action}`);
|
|
23566
23868
|
}
|
|
23567
|
-
return { type, action, namespace, name, filePath, baseUrl, json };
|
|
23869
|
+
return { type, action, namespace, name, filePath, baseUrl: baseUrl2, json };
|
|
23568
23870
|
}
|
|
23569
23871
|
|
|
23570
23872
|
// src/callCommandParser.ts
|
|
@@ -23632,7 +23934,7 @@ function parseNsArgs(tokens) {
|
|
|
23632
23934
|
throw new Error("Missing ns action. Use: ns list|get|create");
|
|
23633
23935
|
}
|
|
23634
23936
|
let chain = DEFAULT_CHAIN;
|
|
23635
|
-
let
|
|
23937
|
+
let baseUrl2;
|
|
23636
23938
|
let json = false;
|
|
23637
23939
|
if (action === "list") {
|
|
23638
23940
|
takeSharedOptions(rest, {
|
|
@@ -23640,13 +23942,13 @@ function parseNsArgs(tokens) {
|
|
|
23640
23942
|
chain = value;
|
|
23641
23943
|
},
|
|
23642
23944
|
onBaseUrl: (value) => {
|
|
23643
|
-
|
|
23945
|
+
baseUrl2 = value;
|
|
23644
23946
|
},
|
|
23645
23947
|
onJson: () => {
|
|
23646
23948
|
json = true;
|
|
23647
23949
|
}
|
|
23648
23950
|
});
|
|
23649
|
-
return { type: "ns" /* Ns */, action, chain, baseUrl, json };
|
|
23951
|
+
return { type: "ns" /* Ns */, action, chain, baseUrl: baseUrl2, json };
|
|
23650
23952
|
}
|
|
23651
23953
|
if (action === "get" || action === "create") {
|
|
23652
23954
|
const namespace = rest.shift();
|
|
@@ -23658,13 +23960,13 @@ function parseNsArgs(tokens) {
|
|
|
23658
23960
|
chain = value;
|
|
23659
23961
|
},
|
|
23660
23962
|
onBaseUrl: (value) => {
|
|
23661
|
-
|
|
23963
|
+
baseUrl2 = value;
|
|
23662
23964
|
},
|
|
23663
23965
|
onJson: () => {
|
|
23664
23966
|
json = true;
|
|
23665
23967
|
}
|
|
23666
23968
|
});
|
|
23667
|
-
return { type: "ns" /* Ns */, action, namespace, chain, baseUrl, json };
|
|
23969
|
+
return { type: "ns" /* Ns */, action, namespace, chain, baseUrl: baseUrl2, json };
|
|
23668
23970
|
}
|
|
23669
23971
|
throw new Error(`Unknown ns action: ${action}`);
|
|
23670
23972
|
}
|
|
@@ -23911,14 +24213,14 @@ function parseAppArgs(tokens) {
|
|
|
23911
24213
|
throw new Error("Missing app action. Use: app list|get|view|create|update|rename|move|icon|delete");
|
|
23912
24214
|
}
|
|
23913
24215
|
if (action === "build") throw new Error("app build was removed; register an electron service and use pmate service deploy <ns:service>");
|
|
23914
|
-
let
|
|
24216
|
+
let baseUrl2;
|
|
23915
24217
|
let json = false;
|
|
23916
24218
|
const takeSharedOptions4 = () => {
|
|
23917
24219
|
while (rest.length > 0) {
|
|
23918
24220
|
const token = rest[0];
|
|
23919
24221
|
if (token === "--base-url") {
|
|
23920
24222
|
rest.shift();
|
|
23921
|
-
|
|
24223
|
+
baseUrl2 = requireValue3(rest, token);
|
|
23922
24224
|
continue;
|
|
23923
24225
|
}
|
|
23924
24226
|
if (token === "--json") {
|
|
@@ -23943,7 +24245,7 @@ function parseAppArgs(tokens) {
|
|
|
23943
24245
|
all = true;
|
|
23944
24246
|
break;
|
|
23945
24247
|
case "--base-url":
|
|
23946
|
-
|
|
24248
|
+
baseUrl2 = requireValue3(rest, token);
|
|
23947
24249
|
break;
|
|
23948
24250
|
case "--json":
|
|
23949
24251
|
json = true;
|
|
@@ -23952,7 +24254,7 @@ function parseAppArgs(tokens) {
|
|
|
23952
24254
|
throw new Error(`Unknown app list option: ${token}`);
|
|
23953
24255
|
}
|
|
23954
24256
|
}
|
|
23955
|
-
return { type: "app" /* App */, action, namespace, all, baseUrl, json };
|
|
24257
|
+
return { type: "app" /* App */, action, namespace, all, baseUrl: baseUrl2, json };
|
|
23956
24258
|
}
|
|
23957
24259
|
if (action === "view") {
|
|
23958
24260
|
const rawRef = rest.shift();
|
|
@@ -23968,13 +24270,13 @@ function parseAppArgs(tokens) {
|
|
|
23968
24270
|
const token = rest.shift();
|
|
23969
24271
|
switch (token) {
|
|
23970
24272
|
case "--base-url":
|
|
23971
|
-
|
|
24273
|
+
baseUrl2 = requireValue3(rest, token);
|
|
23972
24274
|
break;
|
|
23973
24275
|
default:
|
|
23974
24276
|
throw new Error(`Unknown app view option: ${token}`);
|
|
23975
24277
|
}
|
|
23976
24278
|
}
|
|
23977
|
-
return { type: "app" /* App */, action, id, baseUrl, json };
|
|
24279
|
+
return { type: "app" /* App */, action, id, baseUrl: baseUrl2, json };
|
|
23978
24280
|
}
|
|
23979
24281
|
if (action === "get" || action === "delete") {
|
|
23980
24282
|
const rawRef = rest.shift();
|
|
@@ -23990,7 +24292,7 @@ function parseAppArgs(tokens) {
|
|
|
23990
24292
|
if (rest.length > 0) {
|
|
23991
24293
|
throw new Error(`Unknown app ${action} option: ${rest[0]}`);
|
|
23992
24294
|
}
|
|
23993
|
-
return { type: "app" /* App */, action, id, baseUrl, json };
|
|
24295
|
+
return { type: "app" /* App */, action, id, baseUrl: baseUrl2, json };
|
|
23994
24296
|
}
|
|
23995
24297
|
if (action === "icon") {
|
|
23996
24298
|
const nextToken = rest[0];
|
|
@@ -24054,7 +24356,7 @@ function parseAppArgs(tokens) {
|
|
|
24054
24356
|
force = true;
|
|
24055
24357
|
break;
|
|
24056
24358
|
case "--base-url":
|
|
24057
|
-
|
|
24359
|
+
baseUrl2 = requireValue3(rest, token);
|
|
24058
24360
|
break;
|
|
24059
24361
|
case "--json":
|
|
24060
24362
|
json = true;
|
|
@@ -24080,7 +24382,7 @@ function parseAppArgs(tokens) {
|
|
|
24080
24382
|
format: format2,
|
|
24081
24383
|
output: output2,
|
|
24082
24384
|
force,
|
|
24083
|
-
baseUrl,
|
|
24385
|
+
baseUrl: baseUrl2,
|
|
24084
24386
|
json
|
|
24085
24387
|
};
|
|
24086
24388
|
}
|
|
@@ -24147,7 +24449,7 @@ function parseAppArgs(tokens) {
|
|
|
24147
24449
|
outDir = requireValue3(rest, token);
|
|
24148
24450
|
break;
|
|
24149
24451
|
case "--base-url":
|
|
24150
|
-
|
|
24452
|
+
baseUrl2 = requireValue3(rest, token);
|
|
24151
24453
|
break;
|
|
24152
24454
|
case "--json":
|
|
24153
24455
|
json = true;
|
|
@@ -24182,7 +24484,7 @@ function parseAppArgs(tokens) {
|
|
|
24182
24484
|
format,
|
|
24183
24485
|
output,
|
|
24184
24486
|
outDir,
|
|
24185
|
-
baseUrl,
|
|
24487
|
+
baseUrl: baseUrl2,
|
|
24186
24488
|
json
|
|
24187
24489
|
};
|
|
24188
24490
|
}
|
|
@@ -24195,7 +24497,7 @@ function parseAppArgs(tokens) {
|
|
|
24195
24497
|
filePath = requireValue3(rest, token);
|
|
24196
24498
|
break;
|
|
24197
24499
|
case "--base-url":
|
|
24198
|
-
|
|
24500
|
+
baseUrl2 = requireValue3(rest, token);
|
|
24199
24501
|
break;
|
|
24200
24502
|
case "--json":
|
|
24201
24503
|
json = true;
|
|
@@ -24207,7 +24509,7 @@ function parseAppArgs(tokens) {
|
|
|
24207
24509
|
if (!filePath) {
|
|
24208
24510
|
throw new Error("Missing required option --file for app create");
|
|
24209
24511
|
}
|
|
24210
|
-
return { type: "app" /* App */, action, filePath, baseUrl, json };
|
|
24512
|
+
return { type: "app" /* App */, action, filePath, baseUrl: baseUrl2, json };
|
|
24211
24513
|
}
|
|
24212
24514
|
if (action === "update") {
|
|
24213
24515
|
const rawRef = rest.shift();
|
|
@@ -24225,7 +24527,7 @@ function parseAppArgs(tokens) {
|
|
|
24225
24527
|
filePath = requireValue3(rest, token);
|
|
24226
24528
|
break;
|
|
24227
24529
|
case "--base-url":
|
|
24228
|
-
|
|
24530
|
+
baseUrl2 = requireValue3(rest, token);
|
|
24229
24531
|
break;
|
|
24230
24532
|
case "--json":
|
|
24231
24533
|
json = true;
|
|
@@ -24237,7 +24539,7 @@ function parseAppArgs(tokens) {
|
|
|
24237
24539
|
if (!filePath) {
|
|
24238
24540
|
throw new Error("Missing required option --file for app update");
|
|
24239
24541
|
}
|
|
24240
|
-
return { type: "app" /* App */, action, id, filePath, baseUrl, json };
|
|
24542
|
+
return { type: "app" /* App */, action, id, filePath, baseUrl: baseUrl2, json };
|
|
24241
24543
|
}
|
|
24242
24544
|
if (action === "rename") {
|
|
24243
24545
|
let namespace;
|
|
@@ -24257,7 +24559,7 @@ function parseAppArgs(tokens) {
|
|
|
24257
24559
|
toId = parseBareRenameId(requireValue3(rest, token), "app");
|
|
24258
24560
|
break;
|
|
24259
24561
|
case "--base-url":
|
|
24260
|
-
|
|
24562
|
+
baseUrl2 = requireValue3(rest, token);
|
|
24261
24563
|
break;
|
|
24262
24564
|
case "--json":
|
|
24263
24565
|
json = true;
|
|
@@ -24271,7 +24573,7 @@ function parseAppArgs(tokens) {
|
|
|
24271
24573
|
"Usage: app rename --from <id> --to <id> --ns <namespace> [--base-url <url>] [--json]"
|
|
24272
24574
|
);
|
|
24273
24575
|
}
|
|
24274
|
-
return { type: "app" /* App */, action, namespace, fromId, toId, baseUrl, json };
|
|
24576
|
+
return { type: "app" /* App */, action, namespace, fromId, toId, baseUrl: baseUrl2, json };
|
|
24275
24577
|
}
|
|
24276
24578
|
if (action === "move") {
|
|
24277
24579
|
let namespace;
|
|
@@ -24296,7 +24598,7 @@ function parseAppArgs(tokens) {
|
|
|
24296
24598
|
toId = parseBareRenameId(requireValue3(rest, token), "app");
|
|
24297
24599
|
break;
|
|
24298
24600
|
case "--base-url":
|
|
24299
|
-
|
|
24601
|
+
baseUrl2 = requireValue3(rest, token);
|
|
24300
24602
|
break;
|
|
24301
24603
|
case "--json":
|
|
24302
24604
|
json = true;
|
|
@@ -24310,7 +24612,7 @@ function parseAppArgs(tokens) {
|
|
|
24310
24612
|
"Usage: app move --from <id> --ns <namespace> --to-ns <namespace> [--to <id>] [--base-url <url>] [--json]"
|
|
24311
24613
|
);
|
|
24312
24614
|
}
|
|
24313
|
-
return { type: "app" /* App */, action, namespace, fromId, targetNamespace, toId, baseUrl, json };
|
|
24615
|
+
return { type: "app" /* App */, action, namespace, fromId, targetNamespace, toId, baseUrl: baseUrl2, json };
|
|
24314
24616
|
}
|
|
24315
24617
|
throw new Error(`Unknown app action: ${action}`);
|
|
24316
24618
|
}
|
|
@@ -24366,7 +24668,7 @@ function parseServiceArgs(tokens) {
|
|
|
24366
24668
|
if (!action) {
|
|
24367
24669
|
throw new Error("Missing service action. Use: service list|get|view|create|update|rename|delete|deploy|stop|init|log");
|
|
24368
24670
|
}
|
|
24369
|
-
let
|
|
24671
|
+
let baseUrl2;
|
|
24370
24672
|
let json = false;
|
|
24371
24673
|
if (action === "list") {
|
|
24372
24674
|
let namespace;
|
|
@@ -24385,7 +24687,7 @@ function parseServiceArgs(tokens) {
|
|
|
24385
24687
|
server = requireValue4(rest, token);
|
|
24386
24688
|
break;
|
|
24387
24689
|
case "--base-url":
|
|
24388
|
-
|
|
24690
|
+
baseUrl2 = requireValue4(rest, token);
|
|
24389
24691
|
break;
|
|
24390
24692
|
case "--json":
|
|
24391
24693
|
json = true;
|
|
@@ -24394,7 +24696,7 @@ function parseServiceArgs(tokens) {
|
|
|
24394
24696
|
throw new Error(`Unknown service list option: ${token}`);
|
|
24395
24697
|
}
|
|
24396
24698
|
}
|
|
24397
|
-
return { type: "service" /* Service */, action, namespace, repository, server, baseUrl, json };
|
|
24699
|
+
return { type: "service" /* Service */, action, namespace, repository, server, baseUrl: baseUrl2, json };
|
|
24398
24700
|
}
|
|
24399
24701
|
if (action === "view") {
|
|
24400
24702
|
const ref = rest.shift();
|
|
@@ -24405,7 +24707,7 @@ function parseServiceArgs(tokens) {
|
|
|
24405
24707
|
const token = rest.shift();
|
|
24406
24708
|
switch (token) {
|
|
24407
24709
|
case "--base-url":
|
|
24408
|
-
|
|
24710
|
+
baseUrl2 = requireValue4(rest, token);
|
|
24409
24711
|
break;
|
|
24410
24712
|
case "--json":
|
|
24411
24713
|
json = true;
|
|
@@ -24420,7 +24722,7 @@ function parseServiceArgs(tokens) {
|
|
|
24420
24722
|
action,
|
|
24421
24723
|
namespace: parsedRef.namespace,
|
|
24422
24724
|
name: parsedRef.objectId,
|
|
24423
|
-
baseUrl,
|
|
24725
|
+
baseUrl: baseUrl2,
|
|
24424
24726
|
json
|
|
24425
24727
|
};
|
|
24426
24728
|
}
|
|
@@ -24450,7 +24752,7 @@ function parseServiceArgs(tokens) {
|
|
|
24450
24752
|
dryRun = true;
|
|
24451
24753
|
break;
|
|
24452
24754
|
case "--base-url":
|
|
24453
|
-
|
|
24755
|
+
baseUrl2 = requireValue4(rest, token);
|
|
24454
24756
|
break;
|
|
24455
24757
|
case "--json":
|
|
24456
24758
|
json = true;
|
|
@@ -24469,13 +24771,13 @@ function parseServiceArgs(tokens) {
|
|
|
24469
24771
|
name: parsedRef.objectId,
|
|
24470
24772
|
sslCert,
|
|
24471
24773
|
dryRun,
|
|
24472
|
-
baseUrl,
|
|
24774
|
+
baseUrl: baseUrl2,
|
|
24473
24775
|
json
|
|
24474
24776
|
};
|
|
24475
24777
|
}
|
|
24476
24778
|
if (action === "ios") throw new Error("service ios build was removed; use pmate service deploy <ns:ios-service>");
|
|
24477
24779
|
if (action === "apk") {
|
|
24478
|
-
return parseServiceApkArgs(rest, { baseUrl, json });
|
|
24780
|
+
return parseServiceApkArgs(rest, { baseUrl: baseUrl2, json });
|
|
24479
24781
|
}
|
|
24480
24782
|
if (action === "get" || action === "delete" || action === "deploy" || action === "stop" || action === "init" || action === "log" || action === "deploy-logs" || action === "deploy-history") {
|
|
24481
24783
|
const ref = rest.shift();
|
|
@@ -24543,7 +24845,7 @@ function parseServiceArgs(tokens) {
|
|
|
24543
24845
|
if (!Number.isSafeInteger(sinceMs) || sinceMs < 0) throw new Error("Invalid --since-ms");
|
|
24544
24846
|
break;
|
|
24545
24847
|
case "--base-url":
|
|
24546
|
-
|
|
24848
|
+
baseUrl2 = requireValue4(rest, token);
|
|
24547
24849
|
break;
|
|
24548
24850
|
case "--cwd":
|
|
24549
24851
|
if (action !== "init" && action !== "deploy") {
|
|
@@ -24582,11 +24884,11 @@ function parseServiceArgs(tokens) {
|
|
|
24582
24884
|
const namespace = parsedRef.namespace;
|
|
24583
24885
|
const name = parsedRef.objectId;
|
|
24584
24886
|
if (action === "log") {
|
|
24585
|
-
if (app && (history || follow || env ||
|
|
24586
|
-
return { type: "service" /* Service */, action, namespace, name, baseUrl, json, page, history, search, follow, env, ...logFilters, ...app ? { app } : {}, ...sinceMs !== void 0 ? { sinceMs } : {} };
|
|
24887
|
+
if (app && (history || follow || env || baseUrl2)) throw new Error("App logs do not support --history, --follow, --env or --base-url; use --page, --search and --since-ms");
|
|
24888
|
+
return { type: "service" /* Service */, action, namespace, name, baseUrl: baseUrl2, json, page, history, search, follow, env, ...logFilters, ...app ? { app } : {}, ...sinceMs !== void 0 ? { sinceMs } : {} };
|
|
24587
24889
|
}
|
|
24588
24890
|
if (action === "deploy-logs" || action === "deploy-history") {
|
|
24589
|
-
return { type: "service" /* Service */, action, namespace, name, env, page, baseUrl, json };
|
|
24891
|
+
return { type: "service" /* Service */, action, namespace, name, env, page, baseUrl: baseUrl2, json };
|
|
24590
24892
|
}
|
|
24591
24893
|
if (action === "deploy" || action === "stop") {
|
|
24592
24894
|
if (native.signed && native.unsigned) throw new Error("--signed and --unsigned cannot be combined");
|
|
@@ -24604,15 +24906,15 @@ function parseServiceArgs(tokens) {
|
|
|
24604
24906
|
native.lastBuild = Number(native.lastBuild);
|
|
24605
24907
|
}
|
|
24606
24908
|
if (action === "deploy") env ??= "prod";
|
|
24607
|
-
return { type: "service" /* Service */, action, namespace, name, env, ...cwd ? { cwd } : {}, ...native, baseUrl, json };
|
|
24909
|
+
return { type: "service" /* Service */, action, namespace, name, env, ...cwd ? { cwd } : {}, ...native, baseUrl: baseUrl2, json };
|
|
24608
24910
|
}
|
|
24609
24911
|
if (action === "init") {
|
|
24610
24912
|
if (!env) {
|
|
24611
24913
|
throw new Error("Missing required option --env for service init");
|
|
24612
24914
|
}
|
|
24613
|
-
return { type: "service" /* Service */, action, namespace, name, env, cwd, baseUrl, json };
|
|
24915
|
+
return { type: "service" /* Service */, action, namespace, name, env, cwd, baseUrl: baseUrl2, json };
|
|
24614
24916
|
}
|
|
24615
|
-
return { type: "service" /* Service */, action, namespace, name, baseUrl, json };
|
|
24917
|
+
return { type: "service" /* Service */, action, namespace, name, baseUrl: baseUrl2, json };
|
|
24616
24918
|
}
|
|
24617
24919
|
if (action === "create") {
|
|
24618
24920
|
let filePath;
|
|
@@ -24623,7 +24925,7 @@ function parseServiceArgs(tokens) {
|
|
|
24623
24925
|
filePath = requireValue4(rest, token);
|
|
24624
24926
|
break;
|
|
24625
24927
|
case "--base-url":
|
|
24626
|
-
|
|
24928
|
+
baseUrl2 = requireValue4(rest, token);
|
|
24627
24929
|
break;
|
|
24628
24930
|
case "--json":
|
|
24629
24931
|
json = true;
|
|
@@ -24635,7 +24937,7 @@ function parseServiceArgs(tokens) {
|
|
|
24635
24937
|
if (!filePath) {
|
|
24636
24938
|
throw new Error("Missing required option --file for service create");
|
|
24637
24939
|
}
|
|
24638
|
-
return { type: "service" /* Service */, action, filePath, baseUrl, json };
|
|
24940
|
+
return { type: "service" /* Service */, action, filePath, baseUrl: baseUrl2, json };
|
|
24639
24941
|
}
|
|
24640
24942
|
if (action === "update") {
|
|
24641
24943
|
const ref = rest.shift();
|
|
@@ -24655,7 +24957,7 @@ function parseServiceArgs(tokens) {
|
|
|
24655
24957
|
filePath = requireValue4(rest, token);
|
|
24656
24958
|
break;
|
|
24657
24959
|
case "--base-url":
|
|
24658
|
-
|
|
24960
|
+
baseUrl2 = requireValue4(rest, token);
|
|
24659
24961
|
break;
|
|
24660
24962
|
case "--json":
|
|
24661
24963
|
json = true;
|
|
@@ -24667,7 +24969,7 @@ function parseServiceArgs(tokens) {
|
|
|
24667
24969
|
if (!filePath) {
|
|
24668
24970
|
throw new Error("Missing required option --file for service update");
|
|
24669
24971
|
}
|
|
24670
|
-
return { type: "service" /* Service */, action, namespace, name, filePath, baseUrl, json };
|
|
24972
|
+
return { type: "service" /* Service */, action, namespace, name, filePath, baseUrl: baseUrl2, json };
|
|
24671
24973
|
}
|
|
24672
24974
|
if (action === "rename") {
|
|
24673
24975
|
let namespace;
|
|
@@ -24687,7 +24989,7 @@ function parseServiceArgs(tokens) {
|
|
|
24687
24989
|
to = parseBareRenameId2(requireValue4(rest, token), "service");
|
|
24688
24990
|
break;
|
|
24689
24991
|
case "--base-url":
|
|
24690
|
-
|
|
24992
|
+
baseUrl2 = requireValue4(rest, token);
|
|
24691
24993
|
break;
|
|
24692
24994
|
case "--json":
|
|
24693
24995
|
json = true;
|
|
@@ -24707,7 +25009,7 @@ function parseServiceArgs(tokens) {
|
|
|
24707
25009
|
namespace,
|
|
24708
25010
|
fromName: from,
|
|
24709
25011
|
toName: to,
|
|
24710
|
-
baseUrl,
|
|
25012
|
+
baseUrl: baseUrl2,
|
|
24711
25013
|
json
|
|
24712
25014
|
};
|
|
24713
25015
|
}
|
|
@@ -24734,7 +25036,7 @@ function parseServiceArgs(tokens) {
|
|
|
24734
25036
|
to = parseBareRenameId2(requireValue4(rest, token), "service");
|
|
24735
25037
|
break;
|
|
24736
25038
|
case "--base-url":
|
|
24737
|
-
|
|
25039
|
+
baseUrl2 = requireValue4(rest, token);
|
|
24738
25040
|
break;
|
|
24739
25041
|
case "--json":
|
|
24740
25042
|
json = true;
|
|
@@ -24755,7 +25057,7 @@ function parseServiceArgs(tokens) {
|
|
|
24755
25057
|
fromName: from,
|
|
24756
25058
|
targetNamespace,
|
|
24757
25059
|
toName: to,
|
|
24758
|
-
baseUrl,
|
|
25060
|
+
baseUrl: baseUrl2,
|
|
24759
25061
|
json
|
|
24760
25062
|
};
|
|
24761
25063
|
}
|
|
@@ -24785,16 +25087,16 @@ function parseServiceApkArgs(tokens, defaults) {
|
|
|
24785
25087
|
if (action !== "list") throw new Error("Usage: service apk list <ns:service> [--env <env>] [--json]");
|
|
24786
25088
|
const parsed = parseNamespacedRef(rest.shift() ?? "", { entityLabel: "service ref" });
|
|
24787
25089
|
let env;
|
|
24788
|
-
let
|
|
25090
|
+
let baseUrl2 = defaults.baseUrl;
|
|
24789
25091
|
let json = defaults.json;
|
|
24790
25092
|
while (rest.length) {
|
|
24791
25093
|
const flag = rest.shift();
|
|
24792
25094
|
if (flag === "--env") env = requireValue4(rest, flag);
|
|
24793
|
-
else if (flag === "--base-url")
|
|
25095
|
+
else if (flag === "--base-url") baseUrl2 = requireValue4(rest, flag);
|
|
24794
25096
|
else if (flag === "--json") json = true;
|
|
24795
25097
|
else throw new Error(`Unknown service apk list option: ${flag}`);
|
|
24796
25098
|
}
|
|
24797
|
-
return { type: "service" /* Service */, action: "apk-list", namespace: parsed.namespace, name: parsed.objectId, env, baseUrl, json };
|
|
25099
|
+
return { type: "service" /* Service */, action: "apk-list", namespace: parsed.namespace, name: parsed.objectId, env, baseUrl: baseUrl2, json };
|
|
24798
25100
|
}
|
|
24799
25101
|
function parseServiceEnvDefinitionArgs(appId, tokens) {
|
|
24800
25102
|
const rest = [...tokens];
|
|
@@ -24802,14 +25104,14 @@ function parseServiceEnvDefinitionArgs(appId, tokens) {
|
|
|
24802
25104
|
if (!action) {
|
|
24803
25105
|
throw new Error("Usage: service <ns:service> env list|get|add|expose");
|
|
24804
25106
|
}
|
|
24805
|
-
let
|
|
25107
|
+
let baseUrl2;
|
|
24806
25108
|
let json = false;
|
|
24807
25109
|
if (action === "list") {
|
|
24808
25110
|
while (rest.length > 0) {
|
|
24809
25111
|
const token = rest.shift();
|
|
24810
25112
|
switch (token) {
|
|
24811
25113
|
case "--base-url":
|
|
24812
|
-
|
|
25114
|
+
baseUrl2 = requireValue4(rest, token);
|
|
24813
25115
|
break;
|
|
24814
25116
|
case "--json":
|
|
24815
25117
|
json = true;
|
|
@@ -24818,7 +25120,7 @@ function parseServiceEnvDefinitionArgs(appId, tokens) {
|
|
|
24818
25120
|
throw new Error(`Unknown service env list option: ${token}`);
|
|
24819
25121
|
}
|
|
24820
25122
|
}
|
|
24821
|
-
return { type: "service" /* Service */, action: "service-env-list", appId, baseUrl, json };
|
|
25123
|
+
return { type: "service" /* Service */, action: "service-env-list", appId, baseUrl: baseUrl2, json };
|
|
24822
25124
|
}
|
|
24823
25125
|
if (action === "get" || action === "add") {
|
|
24824
25126
|
const envName = rest.shift();
|
|
@@ -24829,7 +25131,7 @@ function parseServiceEnvDefinitionArgs(appId, tokens) {
|
|
|
24829
25131
|
const token = rest.shift();
|
|
24830
25132
|
switch (token) {
|
|
24831
25133
|
case "--base-url":
|
|
24832
|
-
|
|
25134
|
+
baseUrl2 = requireValue4(rest, token);
|
|
24833
25135
|
break;
|
|
24834
25136
|
case "--json":
|
|
24835
25137
|
json = true;
|
|
@@ -24843,7 +25145,7 @@ function parseServiceEnvDefinitionArgs(appId, tokens) {
|
|
|
24843
25145
|
action: action === "get" ? "service-env-get" : "service-env-add",
|
|
24844
25146
|
appId,
|
|
24845
25147
|
envName,
|
|
24846
|
-
baseUrl,
|
|
25148
|
+
baseUrl: baseUrl2,
|
|
24847
25149
|
json
|
|
24848
25150
|
};
|
|
24849
25151
|
}
|
|
@@ -24873,7 +25175,7 @@ function parseServiceEnvDefinitionArgs(appId, tokens) {
|
|
|
24873
25175
|
off = true;
|
|
24874
25176
|
break;
|
|
24875
25177
|
case "--base-url":
|
|
24876
|
-
|
|
25178
|
+
baseUrl2 = requireValue4(rest, token);
|
|
24877
25179
|
break;
|
|
24878
25180
|
case "--json":
|
|
24879
25181
|
json = true;
|
|
@@ -24890,7 +25192,7 @@ function parseServiceEnvDefinitionArgs(appId, tokens) {
|
|
|
24890
25192
|
exposeType,
|
|
24891
25193
|
domain,
|
|
24892
25194
|
off,
|
|
24893
|
-
baseUrl,
|
|
25195
|
+
baseUrl: baseUrl2,
|
|
24894
25196
|
json
|
|
24895
25197
|
};
|
|
24896
25198
|
}
|
|
@@ -24902,7 +25204,7 @@ function parseServiceEnvArgs(appId, tokens) {
|
|
|
24902
25204
|
if (!action) {
|
|
24903
25205
|
throw new Error("Usage: service <ns:app> env list|get|set|unset|resolve|pull|copy-from|update-scope");
|
|
24904
25206
|
}
|
|
24905
|
-
let
|
|
25207
|
+
let baseUrl2;
|
|
24906
25208
|
let json = false;
|
|
24907
25209
|
if (action === "list") {
|
|
24908
25210
|
let scope;
|
|
@@ -24922,7 +25224,7 @@ function parseServiceEnvArgs(appId, tokens) {
|
|
|
24922
25224
|
includeSecretValue = true;
|
|
24923
25225
|
break;
|
|
24924
25226
|
case "--base-url":
|
|
24925
|
-
|
|
25227
|
+
baseUrl2 = requireValue4(rest, token);
|
|
24926
25228
|
break;
|
|
24927
25229
|
case "--json":
|
|
24928
25230
|
json = true;
|
|
@@ -24931,7 +25233,7 @@ function parseServiceEnvArgs(appId, tokens) {
|
|
|
24931
25233
|
throw new Error(`Unknown service env list option: ${token}`);
|
|
24932
25234
|
}
|
|
24933
25235
|
}
|
|
24934
|
-
return { type: "service" /* Service */, action: "env-list", appId, scope, includeSecretMeta, includeSecretValue, baseUrl, json };
|
|
25236
|
+
return { type: "service" /* Service */, action: "env-list", appId, scope, includeSecretMeta, includeSecretValue, baseUrl: baseUrl2, json };
|
|
24935
25237
|
}
|
|
24936
25238
|
if (action === "get") {
|
|
24937
25239
|
const key = rest.shift();
|
|
@@ -24951,7 +25253,7 @@ function parseServiceEnvArgs(appId, tokens) {
|
|
|
24951
25253
|
includeSecretValue = true;
|
|
24952
25254
|
break;
|
|
24953
25255
|
case "--base-url":
|
|
24954
|
-
|
|
25256
|
+
baseUrl2 = requireValue4(rest, token);
|
|
24955
25257
|
break;
|
|
24956
25258
|
case "--json":
|
|
24957
25259
|
json = true;
|
|
@@ -24961,7 +25263,7 @@ function parseServiceEnvArgs(appId, tokens) {
|
|
|
24961
25263
|
}
|
|
24962
25264
|
}
|
|
24963
25265
|
scope = scope ?? "all";
|
|
24964
|
-
return { type: "service" /* Service */, action: "env-get", appId, key, scope, includeSecretValue, baseUrl, json };
|
|
25266
|
+
return { type: "service" /* Service */, action: "env-get", appId, key, scope, includeSecretValue, baseUrl: baseUrl2, json };
|
|
24965
25267
|
}
|
|
24966
25268
|
if (action === "set") {
|
|
24967
25269
|
const key = rest.shift();
|
|
@@ -24989,7 +25291,7 @@ function parseServiceEnvArgs(appId, tokens) {
|
|
|
24989
25291
|
prompt = true;
|
|
24990
25292
|
break;
|
|
24991
25293
|
case "--base-url":
|
|
24992
|
-
|
|
25294
|
+
baseUrl2 = requireValue4(rest, token);
|
|
24993
25295
|
break;
|
|
24994
25296
|
case "--json":
|
|
24995
25297
|
json = true;
|
|
@@ -25002,7 +25304,7 @@ function parseServiceEnvArgs(appId, tokens) {
|
|
|
25002
25304
|
if (!value && !secret && !prompt) {
|
|
25003
25305
|
throw new Error("Missing env value. Pass a value or use --prompt.");
|
|
25004
25306
|
}
|
|
25005
|
-
return { type: "service" /* Service */, action: "env-set", appId, key, value, scope, secret, prompt, baseUrl, json };
|
|
25307
|
+
return { type: "service" /* Service */, action: "env-set", appId, key, value, scope, secret, prompt, baseUrl: baseUrl2, json };
|
|
25006
25308
|
}
|
|
25007
25309
|
if (action === "unset") {
|
|
25008
25310
|
const key = rest.shift();
|
|
@@ -25018,7 +25320,7 @@ function parseServiceEnvArgs(appId, tokens) {
|
|
|
25018
25320
|
scope = requireValue4(rest, token);
|
|
25019
25321
|
break;
|
|
25020
25322
|
case "--base-url":
|
|
25021
|
-
|
|
25323
|
+
baseUrl2 = requireValue4(rest, token);
|
|
25022
25324
|
break;
|
|
25023
25325
|
case "--json":
|
|
25024
25326
|
json = true;
|
|
@@ -25028,7 +25330,7 @@ function parseServiceEnvArgs(appId, tokens) {
|
|
|
25028
25330
|
}
|
|
25029
25331
|
}
|
|
25030
25332
|
scope = scope ?? "all";
|
|
25031
|
-
return { type: "service" /* Service */, action: "env-unset", appId, key, scope, baseUrl, json };
|
|
25333
|
+
return { type: "service" /* Service */, action: "env-unset", appId, key, scope, baseUrl: baseUrl2, json };
|
|
25032
25334
|
}
|
|
25033
25335
|
if (action === "resolve") {
|
|
25034
25336
|
let stage;
|
|
@@ -25047,7 +25349,7 @@ function parseServiceEnvArgs(appId, tokens) {
|
|
|
25047
25349
|
includeSecretValue = true;
|
|
25048
25350
|
break;
|
|
25049
25351
|
case "--base-url":
|
|
25050
|
-
|
|
25352
|
+
baseUrl2 = requireValue4(rest, token);
|
|
25051
25353
|
break;
|
|
25052
25354
|
case "--json":
|
|
25053
25355
|
json = true;
|
|
@@ -25059,7 +25361,7 @@ function parseServiceEnvArgs(appId, tokens) {
|
|
|
25059
25361
|
if (!stage) {
|
|
25060
25362
|
throw new Error("Usage: service <ns:app> env resolve --stage <dev|preview|prod> [--branch <name>]");
|
|
25061
25363
|
}
|
|
25062
|
-
return { type: "service" /* Service */, action: "env-resolve", appId, stage, branch, includeSecretValue, baseUrl, json };
|
|
25364
|
+
return { type: "service" /* Service */, action: "env-resolve", appId, stage, branch, includeSecretValue, baseUrl: baseUrl2, json };
|
|
25063
25365
|
}
|
|
25064
25366
|
if (action === "pull") {
|
|
25065
25367
|
let stage;
|
|
@@ -25078,7 +25380,7 @@ function parseServiceEnvArgs(appId, tokens) {
|
|
|
25078
25380
|
output = requireValue4(rest, token);
|
|
25079
25381
|
break;
|
|
25080
25382
|
case "--base-url":
|
|
25081
|
-
|
|
25383
|
+
baseUrl2 = requireValue4(rest, token);
|
|
25082
25384
|
break;
|
|
25083
25385
|
case "--json":
|
|
25084
25386
|
json = true;
|
|
@@ -25090,7 +25392,7 @@ function parseServiceEnvArgs(appId, tokens) {
|
|
|
25090
25392
|
if (!stage) {
|
|
25091
25393
|
throw new Error("Usage: service <ns:app> env pull --stage <dev|preview|prod> [--branch <name>] [--output <path>]");
|
|
25092
25394
|
}
|
|
25093
|
-
return { type: "service" /* Service */, action: "env-pull", appId, stage, branch, output, baseUrl, json };
|
|
25395
|
+
return { type: "service" /* Service */, action: "env-pull", appId, stage, branch, output, baseUrl: baseUrl2, json };
|
|
25094
25396
|
}
|
|
25095
25397
|
if (action === "copy-from") {
|
|
25096
25398
|
const sourceAppId = rest.shift();
|
|
@@ -25117,7 +25419,7 @@ function parseServiceEnvArgs(appId, tokens) {
|
|
|
25117
25419
|
onlyKeys = requireValue4(rest, token).split(",").map((item) => item.trim()).filter(Boolean);
|
|
25118
25420
|
break;
|
|
25119
25421
|
case "--base-url":
|
|
25120
|
-
|
|
25422
|
+
baseUrl2 = requireValue4(rest, token);
|
|
25121
25423
|
break;
|
|
25122
25424
|
case "--json":
|
|
25123
25425
|
json = true;
|
|
@@ -25126,7 +25428,7 @@ function parseServiceEnvArgs(appId, tokens) {
|
|
|
25126
25428
|
throw new Error(`Unknown service env copy-from option: ${token}`);
|
|
25127
25429
|
}
|
|
25128
25430
|
}
|
|
25129
|
-
return { type: "service" /* Service */, action: "env-copy-from", targetAppId: appId, sourceAppId, scope, includeSecret, overwrite, onlyKeys, baseUrl, json };
|
|
25431
|
+
return { type: "service" /* Service */, action: "env-copy-from", targetAppId: appId, sourceAppId, scope, includeSecret, overwrite, onlyKeys, baseUrl: baseUrl2, json };
|
|
25130
25432
|
}
|
|
25131
25433
|
if (action === "update-scope") {
|
|
25132
25434
|
let fromScope;
|
|
@@ -25151,7 +25453,7 @@ function parseServiceEnvArgs(appId, tokens) {
|
|
|
25151
25453
|
onlyKeys = requireValue4(rest, token).split(",").map((item) => item.trim()).filter(Boolean);
|
|
25152
25454
|
break;
|
|
25153
25455
|
case "--base-url":
|
|
25154
|
-
|
|
25456
|
+
baseUrl2 = requireValue4(rest, token);
|
|
25155
25457
|
break;
|
|
25156
25458
|
case "--json":
|
|
25157
25459
|
json = true;
|
|
@@ -25171,7 +25473,7 @@ function parseServiceEnvArgs(appId, tokens) {
|
|
|
25171
25473
|
toScope,
|
|
25172
25474
|
overwrite,
|
|
25173
25475
|
onlyKeys,
|
|
25174
|
-
baseUrl,
|
|
25476
|
+
baseUrl: baseUrl2,
|
|
25175
25477
|
json
|
|
25176
25478
|
};
|
|
25177
25479
|
}
|
|
@@ -25259,12 +25561,12 @@ function parseRoleArgs(tokens) {
|
|
|
25259
25561
|
if (!action) {
|
|
25260
25562
|
throw new Error("Missing role action. Use: role definition list|create");
|
|
25261
25563
|
}
|
|
25262
|
-
let
|
|
25564
|
+
let baseUrl2;
|
|
25263
25565
|
let json = false;
|
|
25264
25566
|
if (action === "list") {
|
|
25265
25567
|
takeSharedOptions3(rest, {
|
|
25266
25568
|
onBaseUrl: (value) => {
|
|
25267
|
-
|
|
25569
|
+
baseUrl2 = value;
|
|
25268
25570
|
},
|
|
25269
25571
|
onJson: () => {
|
|
25270
25572
|
json = true;
|
|
@@ -25274,7 +25576,7 @@ function parseRoleArgs(tokens) {
|
|
|
25274
25576
|
type: "role" /* Role */,
|
|
25275
25577
|
resource,
|
|
25276
25578
|
action,
|
|
25277
|
-
baseUrl,
|
|
25579
|
+
baseUrl: baseUrl2,
|
|
25278
25580
|
json
|
|
25279
25581
|
};
|
|
25280
25582
|
}
|
|
@@ -25297,7 +25599,7 @@ function parseRoleArgs(tokens) {
|
|
|
25297
25599
|
description = requireValue5(rest, token);
|
|
25298
25600
|
break;
|
|
25299
25601
|
case "--base-url":
|
|
25300
|
-
|
|
25602
|
+
baseUrl2 = requireValue5(rest, token);
|
|
25301
25603
|
break;
|
|
25302
25604
|
case "--json":
|
|
25303
25605
|
json = true;
|
|
@@ -25313,7 +25615,7 @@ function parseRoleArgs(tokens) {
|
|
|
25313
25615
|
role,
|
|
25314
25616
|
displayName,
|
|
25315
25617
|
description,
|
|
25316
|
-
baseUrl,
|
|
25618
|
+
baseUrl: baseUrl2,
|
|
25317
25619
|
json
|
|
25318
25620
|
};
|
|
25319
25621
|
}
|
|
@@ -25355,7 +25657,7 @@ function parseAccountArgs(tokens) {
|
|
|
25355
25657
|
let nickName;
|
|
25356
25658
|
let page;
|
|
25357
25659
|
let pageSize;
|
|
25358
|
-
let
|
|
25660
|
+
let baseUrl3;
|
|
25359
25661
|
let json2 = false;
|
|
25360
25662
|
while (rest.length > 0) {
|
|
25361
25663
|
const token = rest.shift();
|
|
@@ -25374,7 +25676,7 @@ function parseAccountArgs(tokens) {
|
|
|
25374
25676
|
pageSize = parsePositiveInt(requireValue6(rest, token), token);
|
|
25375
25677
|
break;
|
|
25376
25678
|
case "--base-url":
|
|
25377
|
-
|
|
25679
|
+
baseUrl3 = requireValue6(rest, token);
|
|
25378
25680
|
break;
|
|
25379
25681
|
case "--json":
|
|
25380
25682
|
json2 = true;
|
|
@@ -25395,7 +25697,7 @@ function parseAccountArgs(tokens) {
|
|
|
25395
25697
|
pageSize,
|
|
25396
25698
|
mobile,
|
|
25397
25699
|
nickName,
|
|
25398
|
-
baseUrl:
|
|
25700
|
+
baseUrl: baseUrl3,
|
|
25399
25701
|
json: json2
|
|
25400
25702
|
};
|
|
25401
25703
|
}
|
|
@@ -25405,7 +25707,7 @@ function parseAccountArgs(tokens) {
|
|
|
25405
25707
|
}).fullId;
|
|
25406
25708
|
let page;
|
|
25407
25709
|
let pageSize;
|
|
25408
|
-
let
|
|
25710
|
+
let baseUrl3;
|
|
25409
25711
|
let json2 = false;
|
|
25410
25712
|
while (rest.length > 0) {
|
|
25411
25713
|
const token = rest.shift();
|
|
@@ -25417,7 +25719,7 @@ function parseAccountArgs(tokens) {
|
|
|
25417
25719
|
pageSize = parsePositiveInt(requireValue6(rest, token), token);
|
|
25418
25720
|
break;
|
|
25419
25721
|
case "--base-url":
|
|
25420
|
-
|
|
25722
|
+
baseUrl3 = requireValue6(rest, token);
|
|
25421
25723
|
break;
|
|
25422
25724
|
case "--json":
|
|
25423
25725
|
json2 = true;
|
|
@@ -25432,7 +25734,7 @@ function parseAccountArgs(tokens) {
|
|
|
25432
25734
|
app,
|
|
25433
25735
|
page,
|
|
25434
25736
|
pageSize,
|
|
25435
|
-
baseUrl:
|
|
25737
|
+
baseUrl: baseUrl3,
|
|
25436
25738
|
json: json2
|
|
25437
25739
|
};
|
|
25438
25740
|
}
|
|
@@ -25440,7 +25742,7 @@ function parseAccountArgs(tokens) {
|
|
|
25440
25742
|
let account2;
|
|
25441
25743
|
let mobile;
|
|
25442
25744
|
let nickName;
|
|
25443
|
-
let
|
|
25745
|
+
let baseUrl3;
|
|
25444
25746
|
let json2 = false;
|
|
25445
25747
|
while (rest.length > 0) {
|
|
25446
25748
|
const token = rest.shift();
|
|
@@ -25458,7 +25760,7 @@ function parseAccountArgs(tokens) {
|
|
|
25458
25760
|
nickName = requireValue6(rest, token);
|
|
25459
25761
|
break;
|
|
25460
25762
|
case "--base-url":
|
|
25461
|
-
|
|
25763
|
+
baseUrl3 = requireValue6(rest, token);
|
|
25462
25764
|
break;
|
|
25463
25765
|
case "--json":
|
|
25464
25766
|
json2 = true;
|
|
@@ -25483,7 +25785,7 @@ function parseAccountArgs(tokens) {
|
|
|
25483
25785
|
account: account2,
|
|
25484
25786
|
mobile,
|
|
25485
25787
|
nickName,
|
|
25486
|
-
baseUrl:
|
|
25788
|
+
baseUrl: baseUrl3,
|
|
25487
25789
|
json: json2
|
|
25488
25790
|
};
|
|
25489
25791
|
}
|
|
@@ -25496,7 +25798,7 @@ function parseAccountArgs(tokens) {
|
|
|
25496
25798
|
let app;
|
|
25497
25799
|
const apps = [];
|
|
25498
25800
|
let filePath;
|
|
25499
|
-
let
|
|
25801
|
+
let baseUrl3;
|
|
25500
25802
|
let json2 = false;
|
|
25501
25803
|
while (rest.length > 0) {
|
|
25502
25804
|
const token = rest.shift();
|
|
@@ -25514,7 +25816,7 @@ function parseAccountArgs(tokens) {
|
|
|
25514
25816
|
filePath = requireValue6(rest, token);
|
|
25515
25817
|
break;
|
|
25516
25818
|
case "--base-url":
|
|
25517
|
-
|
|
25819
|
+
baseUrl3 = requireValue6(rest, token);
|
|
25518
25820
|
break;
|
|
25519
25821
|
case "--json":
|
|
25520
25822
|
json2 = true;
|
|
@@ -25532,7 +25834,7 @@ function parseAccountArgs(tokens) {
|
|
|
25532
25834
|
return {
|
|
25533
25835
|
type: "account" /* Account */,
|
|
25534
25836
|
action: "visible-app-resolve",
|
|
25535
|
-
baseUrl:
|
|
25837
|
+
baseUrl: baseUrl3,
|
|
25536
25838
|
json: json2
|
|
25537
25839
|
};
|
|
25538
25840
|
}
|
|
@@ -25546,7 +25848,7 @@ function parseAccountArgs(tokens) {
|
|
|
25546
25848
|
type: "account" /* Account */,
|
|
25547
25849
|
action: "visible-app-list",
|
|
25548
25850
|
account: account2,
|
|
25549
|
-
baseUrl:
|
|
25851
|
+
baseUrl: baseUrl3,
|
|
25550
25852
|
json: json2
|
|
25551
25853
|
};
|
|
25552
25854
|
}
|
|
@@ -25561,7 +25863,7 @@ function parseAccountArgs(tokens) {
|
|
|
25561
25863
|
action: visibleAction === "add" ? "visible-app-add" : "visible-app-remove",
|
|
25562
25864
|
account: account2,
|
|
25563
25865
|
app,
|
|
25564
|
-
baseUrl:
|
|
25866
|
+
baseUrl: baseUrl3,
|
|
25565
25867
|
json: json2
|
|
25566
25868
|
};
|
|
25567
25869
|
}
|
|
@@ -25577,7 +25879,7 @@ function parseAccountArgs(tokens) {
|
|
|
25577
25879
|
account: account2,
|
|
25578
25880
|
apps: apps.length > 0 ? apps : void 0,
|
|
25579
25881
|
filePath,
|
|
25580
|
-
baseUrl:
|
|
25882
|
+
baseUrl: baseUrl3,
|
|
25581
25883
|
json: json2
|
|
25582
25884
|
};
|
|
25583
25885
|
}
|
|
@@ -25598,7 +25900,7 @@ function parseAccountArgs(tokens) {
|
|
|
25598
25900
|
let newName;
|
|
25599
25901
|
let nickName;
|
|
25600
25902
|
let role2;
|
|
25601
|
-
let
|
|
25903
|
+
let baseUrl3;
|
|
25602
25904
|
let json2 = false;
|
|
25603
25905
|
while (rest.length > 0) {
|
|
25604
25906
|
const token = rest.shift();
|
|
@@ -25640,7 +25942,7 @@ function parseAccountArgs(tokens) {
|
|
|
25640
25942
|
break;
|
|
25641
25943
|
}
|
|
25642
25944
|
case "--base-url":
|
|
25643
|
-
|
|
25945
|
+
baseUrl3 = requireValue6(rest, token);
|
|
25644
25946
|
break;
|
|
25645
25947
|
case "--json":
|
|
25646
25948
|
json2 = true;
|
|
@@ -25659,31 +25961,31 @@ function parseAccountArgs(tokens) {
|
|
|
25659
25961
|
if (!app || !name || !keyFile && !publicKey) {
|
|
25660
25962
|
throw new Error("Usage: account bot create --app <ns:app> --name <name> (--key-file <path> | --public-key <key>) [--base-url <url>] [--json]");
|
|
25661
25963
|
}
|
|
25662
|
-
return { type: "account" /* Account */, action: "bot-create", app, name, keyFile, publicKey, baseUrl:
|
|
25964
|
+
return { type: "account" /* Account */, action: "bot-create", app, name, keyFile, publicKey, baseUrl: baseUrl3, json: json2 };
|
|
25663
25965
|
}
|
|
25664
25966
|
if (botAction === "view") {
|
|
25665
25967
|
if (!app || !name) {
|
|
25666
25968
|
throw new Error("Usage: account bot view --app <ns:app> --name <name> [--base-url <url>] [--json]");
|
|
25667
25969
|
}
|
|
25668
|
-
return { type: "account" /* Account */, action: "bot-view", app, name, baseUrl:
|
|
25970
|
+
return { type: "account" /* Account */, action: "bot-view", app, name, baseUrl: baseUrl3, json: json2 };
|
|
25669
25971
|
}
|
|
25670
25972
|
if (botAction === "list") {
|
|
25671
25973
|
if (!app) {
|
|
25672
25974
|
throw new Error("Usage: account bot list --app <ns:app> [--base-url <url>] [--json]");
|
|
25673
25975
|
}
|
|
25674
|
-
return { type: "account" /* Account */, action: "bot-list", app, baseUrl:
|
|
25976
|
+
return { type: "account" /* Account */, action: "bot-list", app, baseUrl: baseUrl3, json: json2 };
|
|
25675
25977
|
}
|
|
25676
25978
|
if (botAction === "rename") {
|
|
25677
25979
|
if (!app || !name || !newName) {
|
|
25678
25980
|
throw new Error("Usage: account bot rename --app <ns:app> --name <name> --new-name <new-name> [--base-url <url>] [--json]");
|
|
25679
25981
|
}
|
|
25680
|
-
return { type: "account" /* Account */, action: "bot-rename", app, name, newName, baseUrl:
|
|
25982
|
+
return { type: "account" /* Account */, action: "bot-rename", app, name, newName, baseUrl: baseUrl3, json: json2 };
|
|
25681
25983
|
}
|
|
25682
25984
|
if (botAction === "login") {
|
|
25683
25985
|
if (!app || !name || !keyFile && !privateKey) {
|
|
25684
25986
|
throw new Error("Usage: account bot login --app <ns:app> --name <name> (--key-file <path> | --private-key <key>) [--base-url <url>] [--json]");
|
|
25685
25987
|
}
|
|
25686
|
-
return { type: "account" /* Account */, action: "bot-login", app, name, keyFile, privateKey, baseUrl:
|
|
25988
|
+
return { type: "account" /* Account */, action: "bot-login", app, name, keyFile, privateKey, baseUrl: baseUrl3, json: json2 };
|
|
25687
25989
|
}
|
|
25688
25990
|
if (botAction === "profile") {
|
|
25689
25991
|
if (botProfileAction !== "create") {
|
|
@@ -25692,7 +25994,7 @@ function parseAccountArgs(tokens) {
|
|
|
25692
25994
|
if (!app || !name || !nickName) {
|
|
25693
25995
|
throw new Error("Usage: account bot profile create --app <ns:app> --name <name> --nickname <nickname> [--role <role>] [--base-url <url>] [--json]");
|
|
25694
25996
|
}
|
|
25695
|
-
return { type: "account" /* Account */, action: "bot-profile-create", app, name, nickName, role: role2, baseUrl:
|
|
25997
|
+
return { type: "account" /* Account */, action: "bot-profile-create", app, name, nickName, role: role2, baseUrl: baseUrl3, json: json2 };
|
|
25696
25998
|
}
|
|
25697
25999
|
throw new Error(`Unknown account bot action: ${botAction}`);
|
|
25698
26000
|
}
|
|
@@ -25710,7 +26012,7 @@ function parseAccountArgs(tokens) {
|
|
|
25710
26012
|
let key;
|
|
25711
26013
|
let keyFile;
|
|
25712
26014
|
let gracePeriodSeconds;
|
|
25713
|
-
let
|
|
26015
|
+
let baseUrl3;
|
|
25714
26016
|
let json2 = false;
|
|
25715
26017
|
while (rest.length > 0) {
|
|
25716
26018
|
const token = rest.shift();
|
|
@@ -25745,7 +26047,7 @@ function parseAccountArgs(tokens) {
|
|
|
25745
26047
|
keyFile = requireValue6(rest, token);
|
|
25746
26048
|
break;
|
|
25747
26049
|
case "--base-url":
|
|
25748
|
-
|
|
26050
|
+
baseUrl3 = requireValue6(rest, token);
|
|
25749
26051
|
break;
|
|
25750
26052
|
case "--json":
|
|
25751
26053
|
json2 = true;
|
|
@@ -25765,28 +26067,28 @@ function parseAccountArgs(tokens) {
|
|
|
25765
26067
|
if (!app || !name) {
|
|
25766
26068
|
throw new Error("Usage: account access-key create --app <ns:app> --name <name> [--expires-at <iso> | --expires-in <duration>] [--namespace <ns>] [--out <path>] [--base-url <url>] [--json]");
|
|
25767
26069
|
}
|
|
25768
|
-
return { type: "account" /* Account */, action: "access-key-create", app, name, namespace: namespace2, expiresAt, out, baseUrl:
|
|
26070
|
+
return { type: "account" /* Account */, action: "access-key-create", app, name, namespace: namespace2, expiresAt, out, baseUrl: baseUrl3, json: json2 };
|
|
25769
26071
|
}
|
|
25770
26072
|
if (keyAction === "list") {
|
|
25771
|
-
return { type: "account" /* Account */, action: "access-key-list", app, namespace: namespace2, baseUrl:
|
|
26073
|
+
return { type: "account" /* Account */, action: "access-key-list", app, namespace: namespace2, baseUrl: baseUrl3, json: json2 };
|
|
25772
26074
|
}
|
|
25773
26075
|
if (keyAction === "disable") {
|
|
25774
26076
|
if (!id) {
|
|
25775
26077
|
throw new Error("Usage: account access-key disable <id> [--base-url <url>] [--json]");
|
|
25776
26078
|
}
|
|
25777
|
-
return { type: "account" /* Account */, action: "access-key-disable", id, baseUrl:
|
|
26079
|
+
return { type: "account" /* Account */, action: "access-key-disable", id, baseUrl: baseUrl3, json: json2 };
|
|
25778
26080
|
}
|
|
25779
26081
|
if (keyAction === "rotate") {
|
|
25780
26082
|
if (!id) {
|
|
25781
26083
|
throw new Error("Usage: account access-key rotate <id> [--expires-at <iso> | --expires-in <duration>] [--grace-period <duration>] [--out <path>] [--base-url <url>] [--json]");
|
|
25782
26084
|
}
|
|
25783
|
-
return { type: "account" /* Account */, action: "access-key-rotate", id, expiresAt, gracePeriodSeconds, out, baseUrl:
|
|
26085
|
+
return { type: "account" /* Account */, action: "access-key-rotate", id, expiresAt, gracePeriodSeconds, out, baseUrl: baseUrl3, json: json2 };
|
|
25784
26086
|
}
|
|
25785
26087
|
if (keyAction === "login") {
|
|
25786
26088
|
if (!app || !key && !keyFile || key && keyFile) {
|
|
25787
26089
|
throw new Error("Usage: account access-key login --app <ns:app> (--key <secret> | --key-file <path>) [--base-url <url>] [--json]");
|
|
25788
26090
|
}
|
|
25789
|
-
return { type: "account" /* Account */, action: "access-key-login", app, key, keyFile, baseUrl:
|
|
26091
|
+
return { type: "account" /* Account */, action: "access-key-login", app, key, keyFile, baseUrl: baseUrl3, json: json2 };
|
|
25790
26092
|
}
|
|
25791
26093
|
throw new Error(`Unknown account access-key action: ${keyAction}`);
|
|
25792
26094
|
}
|
|
@@ -25800,7 +26102,7 @@ function parseAccountArgs(tokens) {
|
|
|
25800
26102
|
let account;
|
|
25801
26103
|
let namespace;
|
|
25802
26104
|
let role;
|
|
25803
|
-
let
|
|
26105
|
+
let baseUrl2;
|
|
25804
26106
|
let json = false;
|
|
25805
26107
|
while (rest.length > 0) {
|
|
25806
26108
|
const token = rest.shift();
|
|
@@ -25815,7 +26117,7 @@ function parseAccountArgs(tokens) {
|
|
|
25815
26117
|
role = requireValue6(rest, token);
|
|
25816
26118
|
break;
|
|
25817
26119
|
case "--base-url":
|
|
25818
|
-
|
|
26120
|
+
baseUrl2 = requireValue6(rest, token);
|
|
25819
26121
|
break;
|
|
25820
26122
|
case "--json":
|
|
25821
26123
|
json = true;
|
|
@@ -25835,7 +26137,7 @@ function parseAccountArgs(tokens) {
|
|
|
25835
26137
|
action: "role-list",
|
|
25836
26138
|
account,
|
|
25837
26139
|
namespace,
|
|
25838
|
-
baseUrl,
|
|
26140
|
+
baseUrl: baseUrl2,
|
|
25839
26141
|
json
|
|
25840
26142
|
};
|
|
25841
26143
|
}
|
|
@@ -25851,7 +26153,7 @@ function parseAccountArgs(tokens) {
|
|
|
25851
26153
|
account,
|
|
25852
26154
|
namespace,
|
|
25853
26155
|
role,
|
|
25854
|
-
baseUrl,
|
|
26156
|
+
baseUrl: baseUrl2,
|
|
25855
26157
|
json
|
|
25856
26158
|
};
|
|
25857
26159
|
}
|
|
@@ -25896,14 +26198,14 @@ function parseOrgArgs(tokens) {
|
|
|
25896
26198
|
"Missing org action. Use: org list|get|view|create|update|disable|member|visible-app"
|
|
25897
26199
|
);
|
|
25898
26200
|
}
|
|
25899
|
-
let
|
|
26201
|
+
let baseUrl2;
|
|
25900
26202
|
let json = false;
|
|
25901
26203
|
const takeSharedOptions4 = () => {
|
|
25902
26204
|
while (rest.length > 0) {
|
|
25903
26205
|
const token = rest[0];
|
|
25904
26206
|
if (token === "--base-url") {
|
|
25905
26207
|
rest.shift();
|
|
25906
|
-
|
|
26208
|
+
baseUrl2 = requireValue7(rest, token);
|
|
25907
26209
|
continue;
|
|
25908
26210
|
}
|
|
25909
26211
|
if (token === "--json") {
|
|
@@ -25919,7 +26221,7 @@ function parseOrgArgs(tokens) {
|
|
|
25919
26221
|
if (rest.length > 0) {
|
|
25920
26222
|
throw new Error(`Unknown org list option: ${rest[0]}`);
|
|
25921
26223
|
}
|
|
25922
|
-
return { type: "org" /* Org */, action, baseUrl, json };
|
|
26224
|
+
return { type: "org" /* Org */, action, baseUrl: baseUrl2, json };
|
|
25923
26225
|
}
|
|
25924
26226
|
if (action === "get" || action === "view" || action === "disable") {
|
|
25925
26227
|
const orgId = parseRequiredOrgRef(rest.shift(), action);
|
|
@@ -25927,7 +26229,7 @@ function parseOrgArgs(tokens) {
|
|
|
25927
26229
|
if (rest.length > 0) {
|
|
25928
26230
|
throw new Error(`Unknown org ${action} option: ${rest[0]}`);
|
|
25929
26231
|
}
|
|
25930
|
-
return { type: "org" /* Org */, action, orgId, baseUrl, json };
|
|
26232
|
+
return { type: "org" /* Org */, action, orgId, baseUrl: baseUrl2, json };
|
|
25931
26233
|
}
|
|
25932
26234
|
if (action === "create") {
|
|
25933
26235
|
const orgId = parseRequiredOrgRef(rest.shift(), action);
|
|
@@ -25943,7 +26245,7 @@ function parseOrgArgs(tokens) {
|
|
|
25943
26245
|
members.push(requireValue7(rest, token));
|
|
25944
26246
|
break;
|
|
25945
26247
|
case "--base-url":
|
|
25946
|
-
|
|
26248
|
+
baseUrl2 = requireValue7(rest, token);
|
|
25947
26249
|
break;
|
|
25948
26250
|
case "--json":
|
|
25949
26251
|
json = true;
|
|
@@ -25963,7 +26265,7 @@ function parseOrgArgs(tokens) {
|
|
|
25963
26265
|
orgId,
|
|
25964
26266
|
displayName,
|
|
25965
26267
|
members,
|
|
25966
|
-
baseUrl,
|
|
26268
|
+
baseUrl: baseUrl2,
|
|
25967
26269
|
json
|
|
25968
26270
|
};
|
|
25969
26271
|
}
|
|
@@ -25977,7 +26279,7 @@ function parseOrgArgs(tokens) {
|
|
|
25977
26279
|
displayName = requireValue7(rest, token);
|
|
25978
26280
|
break;
|
|
25979
26281
|
case "--base-url":
|
|
25980
|
-
|
|
26282
|
+
baseUrl2 = requireValue7(rest, token);
|
|
25981
26283
|
break;
|
|
25982
26284
|
case "--json":
|
|
25983
26285
|
json = true;
|
|
@@ -25996,7 +26298,7 @@ function parseOrgArgs(tokens) {
|
|
|
25996
26298
|
action,
|
|
25997
26299
|
orgId,
|
|
25998
26300
|
displayName,
|
|
25999
|
-
baseUrl,
|
|
26301
|
+
baseUrl: baseUrl2,
|
|
26000
26302
|
json
|
|
26001
26303
|
};
|
|
26002
26304
|
}
|
|
@@ -26029,7 +26331,7 @@ function parseOrgArgs(tokens) {
|
|
|
26029
26331
|
filePath = requireValue7(memberTokens, token);
|
|
26030
26332
|
break;
|
|
26031
26333
|
case "--base-url":
|
|
26032
|
-
|
|
26334
|
+
baseUrl2 = requireValue7(memberTokens, token);
|
|
26033
26335
|
break;
|
|
26034
26336
|
case "--json":
|
|
26035
26337
|
json = true;
|
|
@@ -26039,7 +26341,7 @@ function parseOrgArgs(tokens) {
|
|
|
26039
26341
|
}
|
|
26040
26342
|
}
|
|
26041
26343
|
if (subAction === "list") {
|
|
26042
|
-
return { type: "org" /* Org */, action: "member-list", orgId, baseUrl, json };
|
|
26344
|
+
return { type: "org" /* Org */, action: "member-list", orgId, baseUrl: baseUrl2, json };
|
|
26043
26345
|
}
|
|
26044
26346
|
if (subAction === "add" || subAction === "remove") {
|
|
26045
26347
|
if (!account) {
|
|
@@ -26052,7 +26354,7 @@ function parseOrgArgs(tokens) {
|
|
|
26052
26354
|
action: subAction === "add" ? "member-add" : "member-remove",
|
|
26053
26355
|
orgId,
|
|
26054
26356
|
account,
|
|
26055
|
-
baseUrl,
|
|
26357
|
+
baseUrl: baseUrl2,
|
|
26056
26358
|
json
|
|
26057
26359
|
};
|
|
26058
26360
|
}
|
|
@@ -26068,7 +26370,7 @@ function parseOrgArgs(tokens) {
|
|
|
26068
26370
|
orgId,
|
|
26069
26371
|
accounts: accounts.length > 0 ? accounts : void 0,
|
|
26070
26372
|
filePath,
|
|
26071
|
-
baseUrl,
|
|
26373
|
+
baseUrl: baseUrl2,
|
|
26072
26374
|
json
|
|
26073
26375
|
};
|
|
26074
26376
|
}
|
|
@@ -26100,7 +26402,7 @@ function parseOrgArgs(tokens) {
|
|
|
26100
26402
|
filePath = requireValue7(visibleTokens, token);
|
|
26101
26403
|
break;
|
|
26102
26404
|
case "--base-url":
|
|
26103
|
-
|
|
26405
|
+
baseUrl2 = requireValue7(visibleTokens, token);
|
|
26104
26406
|
break;
|
|
26105
26407
|
case "--json":
|
|
26106
26408
|
json = true;
|
|
@@ -26110,7 +26412,7 @@ function parseOrgArgs(tokens) {
|
|
|
26110
26412
|
}
|
|
26111
26413
|
}
|
|
26112
26414
|
if (subAction === "list") {
|
|
26113
|
-
return { type: "org" /* Org */, action: "visible-app-list", orgId, baseUrl, json };
|
|
26415
|
+
return { type: "org" /* Org */, action: "visible-app-list", orgId, baseUrl: baseUrl2, json };
|
|
26114
26416
|
}
|
|
26115
26417
|
if (subAction === "add" || subAction === "remove") {
|
|
26116
26418
|
if (!app) {
|
|
@@ -26123,7 +26425,7 @@ function parseOrgArgs(tokens) {
|
|
|
26123
26425
|
action: subAction === "add" ? "visible-app-add" : "visible-app-remove",
|
|
26124
26426
|
orgId,
|
|
26125
26427
|
app,
|
|
26126
|
-
baseUrl,
|
|
26428
|
+
baseUrl: baseUrl2,
|
|
26127
26429
|
json
|
|
26128
26430
|
};
|
|
26129
26431
|
}
|
|
@@ -26139,7 +26441,7 @@ function parseOrgArgs(tokens) {
|
|
|
26139
26441
|
orgId,
|
|
26140
26442
|
apps: apps.length > 0 ? apps : void 0,
|
|
26141
26443
|
filePath,
|
|
26142
|
-
baseUrl,
|
|
26444
|
+
baseUrl: baseUrl2,
|
|
26143
26445
|
json
|
|
26144
26446
|
};
|
|
26145
26447
|
}
|
|
@@ -26184,18 +26486,18 @@ function parseHostArgs(tokens) {
|
|
|
26184
26486
|
} else throw new Error("Usage: host env list|set|unset ... | host apply");
|
|
26185
26487
|
let host;
|
|
26186
26488
|
let secret = false;
|
|
26187
|
-
let
|
|
26489
|
+
let baseUrl2;
|
|
26188
26490
|
let json = false;
|
|
26189
26491
|
while (rest.length > 0) {
|
|
26190
26492
|
const token = rest.shift();
|
|
26191
26493
|
if (token === "--host") host = requireValue8(rest, token);
|
|
26192
26494
|
else if (token === "--secret") secret = true;
|
|
26193
|
-
else if (token === "--base-url")
|
|
26495
|
+
else if (token === "--base-url") baseUrl2 = requireValue8(rest, token);
|
|
26194
26496
|
else if (token === "--json") json = true;
|
|
26195
26497
|
else throw new Error(`Unknown host option: ${token}`);
|
|
26196
26498
|
}
|
|
26197
26499
|
if (secret && action !== "env-set") throw new Error("--secret is only valid for host env set");
|
|
26198
|
-
return { type: "host" /* Host */, action, host, key, value, secret, baseUrl, json };
|
|
26500
|
+
return { type: "host" /* Host */, action, host, key, value, secret, baseUrl: baseUrl2, json };
|
|
26199
26501
|
}
|
|
26200
26502
|
function requireValue8(tokens, label) {
|
|
26201
26503
|
const value = tokens.shift();
|
|
@@ -26645,7 +26947,7 @@ function requireValue11(tokens, option) {
|
|
|
26645
26947
|
|
|
26646
26948
|
// src/index.ts
|
|
26647
26949
|
var pkg = JSON.parse(
|
|
26648
|
-
(0,
|
|
26950
|
+
(0, import_node_fs31.readFileSync)(import_node_path36.default.resolve(__dirname, "..", "package.json"), "utf8")
|
|
26649
26951
|
);
|
|
26650
26952
|
var HELP_TEXT = [
|
|
26651
26953
|
import_chalk4.default.bold(`pmate v${pkg.version}`),
|
|
@@ -27220,14 +27522,14 @@ function parseOssArgs(tokens) {
|
|
|
27220
27522
|
if (action !== "upload") {
|
|
27221
27523
|
throw new Error(`Unknown oss action: ${action}`);
|
|
27222
27524
|
}
|
|
27223
|
-
let
|
|
27525
|
+
let bucket2;
|
|
27224
27526
|
let filePath;
|
|
27225
27527
|
let objectKey;
|
|
27226
27528
|
while (rest.length > 0) {
|
|
27227
27529
|
const token = rest.shift();
|
|
27228
27530
|
switch (token) {
|
|
27229
27531
|
case "--bucket":
|
|
27230
|
-
|
|
27532
|
+
bucket2 = requireValue12(rest, token);
|
|
27231
27533
|
break;
|
|
27232
27534
|
case "--file":
|
|
27233
27535
|
filePath = requireValue12(rest, token);
|
|
@@ -27245,7 +27547,7 @@ function parseOssArgs(tokens) {
|
|
|
27245
27547
|
if (!objectKey) {
|
|
27246
27548
|
throw new Error("Missing required option --key for oss upload");
|
|
27247
27549
|
}
|
|
27248
|
-
return { type: "oss" /* Oss */, action, bucket, filePath, objectKey };
|
|
27550
|
+
return { type: "oss" /* Oss */, action, bucket: bucket2, filePath, objectKey };
|
|
27249
27551
|
}
|
|
27250
27552
|
function parseEnvArgs(tokens) {
|
|
27251
27553
|
const rest = [...tokens];
|