@pmate/cli 0.28.5 → 0.28.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +2 -0
- package/dist/index.js +59 -2
- package/package.json +10 -17
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -12073,7 +12073,7 @@ var AliyunService = class {
|
|
|
12073
12073
|
static getStaticAssetCacheControl(filePath) {
|
|
12074
12074
|
const normalized = filePath.replace(/\\/g, "/");
|
|
12075
12075
|
const base = import_node_path6.default.posix.basename(normalized).toLowerCase();
|
|
12076
|
-
if (base === "index.html" || base === "200.html" || base === "404.html" || base === "apple-app-site-association") {
|
|
12076
|
+
if (base === "index.html" || base === "200.html" || base === "404.html" || base === "latest.json" || base === "apple-app-site-association") {
|
|
12077
12077
|
return "no-cache, no-store, must-revalidate";
|
|
12078
12078
|
}
|
|
12079
12079
|
if (/[.-][a-z0-9_-]{8,}\./i.test(base)) {
|
|
@@ -20074,9 +20074,29 @@ var AndroidApkReleaseService = class {
|
|
|
20074
20074
|
ui.warn("APK uploaded but registry artifact record failed", error instanceof Error ? error.message : String(error));
|
|
20075
20075
|
}
|
|
20076
20076
|
}
|
|
20077
|
+
if (options.env === "prod" && options.variant.toLowerCase() === "release") {
|
|
20078
|
+
await this.publishLatestManifest(service, artifact, options);
|
|
20079
|
+
}
|
|
20077
20080
|
ui.success(`Released APK ${artifact.downloadUrl}`);
|
|
20078
20081
|
return artifact;
|
|
20079
20082
|
}
|
|
20083
|
+
async publishLatestManifest(service, artifact, options) {
|
|
20084
|
+
const manifest = buildAndroidLatestManifest(artifact, {
|
|
20085
|
+
releaseNotes: options.releaseNotes,
|
|
20086
|
+
minimumVersionCode: options.minimumVersionCode
|
|
20087
|
+
});
|
|
20088
|
+
const objectKey = buildAndroidLatestManifestObjectKey(service.namespace, service.name);
|
|
20089
|
+
const tempDir = (0, import_node_fs20.mkdtempSync)(import_node_path25.default.join(import_node_os9.default.tmpdir(), "pmate-apk-latest-"));
|
|
20090
|
+
const manifestPath = import_node_path25.default.join(tempDir, "latest.json");
|
|
20091
|
+
try {
|
|
20092
|
+
(0, import_node_fs20.writeFileSync)(manifestPath, `${JSON.stringify(manifest, null, 2)}
|
|
20093
|
+
`);
|
|
20094
|
+
await AliyunService.uploadFile(manifestPath, ANDROID_APK_BUCKET, objectKey);
|
|
20095
|
+
ui.success(`Published Android update manifest ${ANDROID_APK_PUBLIC_BASE_URL}/${objectKey}`);
|
|
20096
|
+
} finally {
|
|
20097
|
+
(0, import_node_fs20.rmSync)(tempDir, { recursive: true, force: true });
|
|
20098
|
+
}
|
|
20099
|
+
}
|
|
20080
20100
|
async list(service, options) {
|
|
20081
20101
|
const serviceId = service.id;
|
|
20082
20102
|
if (this.registry) {
|
|
@@ -20209,6 +20229,26 @@ function bumpVersionName(versionName, bump) {
|
|
|
20209
20229
|
function buildAndroidApkObjectKey(namespace, serviceName, versionName) {
|
|
20210
20230
|
return `apks/${encodePathSegment(namespace)}/${encodePathSegment(serviceName)}/${encodePathSegment(versionName)}.apk`;
|
|
20211
20231
|
}
|
|
20232
|
+
function buildAndroidLatestManifestObjectKey(namespace, serviceName) {
|
|
20233
|
+
return `apks/${namespace}/${serviceName}/latest.json`;
|
|
20234
|
+
}
|
|
20235
|
+
function buildAndroidLatestManifest(artifact, options = {}) {
|
|
20236
|
+
const minimumVersionCode = options.minimumVersionCode ?? 0;
|
|
20237
|
+
if (!Number.isInteger(minimumVersionCode) || minimumVersionCode < 0 || minimumVersionCode > artifact.versionCode) {
|
|
20238
|
+
throw new Error(`minimumVersionCode must be between 0 and released versionCode ${artifact.versionCode}`);
|
|
20239
|
+
}
|
|
20240
|
+
return {
|
|
20241
|
+
applicationId: artifact.applicationId,
|
|
20242
|
+
versionName: artifact.versionName,
|
|
20243
|
+
versionCode: artifact.versionCode,
|
|
20244
|
+
downloadUrl: artifact.downloadUrl,
|
|
20245
|
+
sha256: artifact.sha256,
|
|
20246
|
+
size: artifact.size,
|
|
20247
|
+
releaseNotes: options.releaseNotes?.trim() ?? "",
|
|
20248
|
+
minimumVersionCode,
|
|
20249
|
+
publishedAt: options.publishedAt ?? (/* @__PURE__ */ new Date()).toISOString()
|
|
20250
|
+
};
|
|
20251
|
+
}
|
|
20212
20252
|
function resolveRepositoryLocalRoot(repository) {
|
|
20213
20253
|
const repoName = repository.replace(/\/+$/, "").split("/").pop()?.replace(/\.git$/i, "");
|
|
20214
20254
|
if (!repoName) {
|
|
@@ -22329,7 +22369,9 @@ var ServiceCommandHandler = class {
|
|
|
22329
22369
|
variant: args.variant,
|
|
22330
22370
|
bump: args.bump,
|
|
22331
22371
|
cwd: args.cwd,
|
|
22332
|
-
force: args.force
|
|
22372
|
+
force: args.force,
|
|
22373
|
+
releaseNotes: args.releaseNotes,
|
|
22374
|
+
minimumVersionCode: args.minimumVersionCode
|
|
22333
22375
|
});
|
|
22334
22376
|
this.renderApkArtifacts([artifact], args.json);
|
|
22335
22377
|
return;
|
|
@@ -26175,6 +26217,8 @@ function parseServiceApkArgs(tokens, defaults) {
|
|
|
26175
26217
|
let force = false;
|
|
26176
26218
|
let major = false;
|
|
26177
26219
|
let minor = false;
|
|
26220
|
+
let releaseNotes;
|
|
26221
|
+
let minimumVersionCode;
|
|
26178
26222
|
while (rest.length > 0) {
|
|
26179
26223
|
const token = rest.shift();
|
|
26180
26224
|
switch (token) {
|
|
@@ -26211,6 +26255,17 @@ function parseServiceApkArgs(tokens, defaults) {
|
|
|
26211
26255
|
}
|
|
26212
26256
|
minor = true;
|
|
26213
26257
|
break;
|
|
26258
|
+
case "--release-notes":
|
|
26259
|
+
if (apkAction !== "release") throw new Error(`Unknown service apk ${apkAction} option: ${token}`);
|
|
26260
|
+
releaseNotes = requireValue6(rest, token);
|
|
26261
|
+
break;
|
|
26262
|
+
case "--minimum-version-code": {
|
|
26263
|
+
if (apkAction !== "release") throw new Error(`Unknown service apk ${apkAction} option: ${token}`);
|
|
26264
|
+
const value = Number(requireValue6(rest, token));
|
|
26265
|
+
if (!Number.isInteger(value) || value < 0) throw new Error("--minimum-version-code must be a non-negative integer");
|
|
26266
|
+
minimumVersionCode = value;
|
|
26267
|
+
break;
|
|
26268
|
+
}
|
|
26214
26269
|
case "--base-url":
|
|
26215
26270
|
baseUrl = requireValue6(rest, token);
|
|
26216
26271
|
break;
|
|
@@ -26245,6 +26300,8 @@ function parseServiceApkArgs(tokens, defaults) {
|
|
|
26245
26300
|
bump: major ? "major" : minor ? "minor" : "patch",
|
|
26246
26301
|
cwd,
|
|
26247
26302
|
force,
|
|
26303
|
+
releaseNotes,
|
|
26304
|
+
minimumVersionCode,
|
|
26248
26305
|
baseUrl,
|
|
26249
26306
|
json
|
|
26250
26307
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pmate/cli",
|
|
3
|
-
"version": "0.28.
|
|
3
|
+
"version": "0.28.6",
|
|
4
4
|
"description": "CLI utilities for the pMate project",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
@@ -11,16 +11,6 @@
|
|
|
11
11
|
"files": [
|
|
12
12
|
"dist"
|
|
13
13
|
],
|
|
14
|
-
"scripts": {
|
|
15
|
-
"build": "npm run clean && tsup --config tsup.config.ts && node scripts/copy-templates.js",
|
|
16
|
-
"clean": "rimraf dist",
|
|
17
|
-
"dev": "ts-node src/index.ts",
|
|
18
|
-
"release": "npm publish",
|
|
19
|
-
"start": "node dist/index.js",
|
|
20
|
-
"test": "vitest run src/tests",
|
|
21
|
-
"typecheck": "tsc --noEmit",
|
|
22
|
-
"prepare": "npm run build"
|
|
23
|
-
},
|
|
24
14
|
"keywords": [
|
|
25
15
|
"cli",
|
|
26
16
|
"typescript",
|
|
@@ -67,10 +57,13 @@
|
|
|
67
57
|
"typescript": "^5.9.3",
|
|
68
58
|
"vitest": "^4.0.17"
|
|
69
59
|
},
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
60
|
+
"scripts": {
|
|
61
|
+
"build": "npm run clean && tsup --config tsup.config.ts && node scripts/copy-templates.js",
|
|
62
|
+
"clean": "rimraf dist",
|
|
63
|
+
"dev": "ts-node src/index.ts",
|
|
64
|
+
"release": "pnpm publish",
|
|
65
|
+
"start": "node dist/index.js",
|
|
66
|
+
"test": "vitest run src/tests",
|
|
67
|
+
"typecheck": "tsc --noEmit"
|
|
75
68
|
}
|
|
76
|
-
}
|
|
69
|
+
}
|