fix: 周尚安装包改传到 zhoushang 空间
This commit is contained in:
@@ -104,7 +104,7 @@ pack.json内容如下:详情可访问 [CLI uni-app发行 - Android/iOS云打
|
|||||||
|
|
||||||
### 上传 PDA 安装包
|
### 上传 PDA 安装包
|
||||||
|
|
||||||
云打包得到 APK 后,用命令行上传,等价于 ERP「开发者资源上传」里的安装包上传。登录和签名走本分支接口 `https://hcscmtest.zzfzyc.com/hcscm`。
|
云打包得到 APK 后,用命令行上传,等价于 ERP「开发者资源上传」里的安装包上传。周尚环境的登录和签名走 `https://zsfz.yushangfangzhi.com/hcscm`,安装包进入 `zhoushang` 空间。
|
||||||
|
|
||||||
先把 `src/manifest.json` 的 `versionName`、`versionCode` 改成新版本,再打包。安装包里的版本号必须和上传文件名一致,否则 PDA 会反复提示升级。
|
先把 `src/manifest.json` 的 `versionName`、`versionCode` 改成新版本,再打包。安装包里的版本号必须和上传文件名一致,否则 PDA 会反复提示升级。
|
||||||
|
|
||||||
@@ -125,8 +125,8 @@ node scripts/upload-apk.js --file D:\path\你的.apk --target test
|
|||||||
|
|
||||||
| 参数 | 说明 |
|
| 参数 | 说明 |
|
||||||
|---|---|
|
|---|---|
|
||||||
| `--target test` | 测试 CDN:`https://zsfzcdn.yushangfangzhi.com` |
|
| `--target test` | 周尚环境固定上传到 `https://zsfzcdn.yushangfangzhi.com` |
|
||||||
| `--target prod` | 正式 CDN:`https://zsfzcdn.yushangfangzhi.com` |
|
| `--target prod` | 其他环境的正式 CDN:`https://hcscm.cdn.zzfzyc.com` |
|
||||||
| `--mode` | 默认 `zhoushang`。可选 `zhoushang`、`zhisheng`、`mes`、`cjt` |
|
| `--mode` | 默认 `zhoushang`。可选 `zhoushang`、`zhisheng`、`mes`、`cjt` |
|
||||||
| `--version` | 可选。不传则用 `src/manifest.json` 的 `versionName` |
|
| `--version` | 可选。不传则用 `src/manifest.json` 的 `versionName` |
|
||||||
|
|
||||||
|
|||||||
+24
-12
@@ -21,11 +21,20 @@ const path = require('path');
|
|||||||
const readline = require('readline');
|
const readline = require('readline');
|
||||||
|
|
||||||
const ROOT = path.resolve(__dirname, '..');
|
const ROOT = path.resolve(__dirname, '..');
|
||||||
const API_BASE = 'https://hcscmtest.zzfzyc.com/hcscm';
|
|
||||||
const UPYUN_API = 'https://v0.api.upyun.com';
|
const UPYUN_API = 'https://v0.api.upyun.com';
|
||||||
const CDN_HOST = {
|
const DEFAULT_API_BASE = 'https://hcscmtest.zzfzyc.com/hcscm';
|
||||||
test: 'https://zsfzcdn.yushangfangzhi.com',
|
const DEFAULT_CDN_HOST = {
|
||||||
prod: 'https://zsfzcdn.yushangfangzhi.com',
|
test: 'https://testhcscm.cdn.zzfzyc.com',
|
||||||
|
prod: 'https://hcscm.cdn.zzfzyc.com',
|
||||||
|
};
|
||||||
|
/** 周尚环境的安装包签到 zhoushang 空间,下载域名是 zsfzcdn */
|
||||||
|
const MODE_UPLOAD = {
|
||||||
|
zhoushang: {
|
||||||
|
apiBase: 'https://zsfz.yushangfangzhi.com/hcscm',
|
||||||
|
cdnHost: 'https://zsfzcdn.yushangfangzhi.com',
|
||||||
|
/** 该环境只有 status=1 返回了 zhoushang 空间,正式状态没有可用 bucket */
|
||||||
|
status: 1,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const MODE_ENV = {
|
const MODE_ENV = {
|
||||||
@@ -218,9 +227,9 @@ async function uploadToUpyun({ bucket, authorization, policy, filePath, fileName
|
|||||||
return body;
|
return body;
|
||||||
}
|
}
|
||||||
|
|
||||||
function toPublicUrl(target, saveKey, uploaded) {
|
function toPublicUrl(cdnHost, saveKey, uploaded) {
|
||||||
if (uploaded.url && String(uploaded.url).startsWith('http')) return uploaded.url;
|
if (uploaded.url && String(uploaded.url).startsWith('http')) return uploaded.url;
|
||||||
return `${CDN_HOST[target]}${saveKey}`;
|
return `${cdnHost}${saveKey}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function uploadApkFile({ apiBase, token, apkPath, saveKey, fileName, status }) {
|
async function uploadApkFile({ apiBase, token, apkPath, saveKey, fileName, status }) {
|
||||||
@@ -235,6 +244,7 @@ async function uploadApkFile({ apiBase, token, apkPath, saveKey, fileName, statu
|
|||||||
if (!sign.bucket || !sign.authorization || !sign.policy) {
|
if (!sign.bucket || !sign.authorization || !sign.policy) {
|
||||||
throw new Error('签名返回缺少 bucket、authorization 或 policy');
|
throw new Error('签名返回缺少 bucket、authorization 或 policy');
|
||||||
}
|
}
|
||||||
|
console.log(`空间: ${sign.bucket}`);
|
||||||
console.log(`正在上传 ${fileName}...`);
|
console.log(`正在上传 ${fileName}...`);
|
||||||
const uploaded = await uploadToUpyun({
|
const uploaded = await uploadToUpyun({
|
||||||
bucket: sign.bucket,
|
bucket: sign.bucket,
|
||||||
@@ -280,12 +290,14 @@ async function main() {
|
|||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
const status = args.target === 'prod' ? 2 : 1;
|
const modeUpload = MODE_UPLOAD[args.mode];
|
||||||
|
const status = modeUpload ? modeUpload.status : (args.target === 'prod' ? 2 : 1);
|
||||||
const fileName = `${version}.apk`;
|
const fileName = `${version}.apk`;
|
||||||
const saveKey = `/version/${upgradeName}/${fileName}`;
|
const saveKey = `/version/${upgradeName}/${fileName}`;
|
||||||
const latestFileName = 'latest.apk';
|
const latestFileName = 'latest.apk';
|
||||||
const latestSaveKey = `/version/${upgradeName}/${latestFileName}`;
|
const latestSaveKey = `/version/${upgradeName}/${latestFileName}`;
|
||||||
const apiBase = API_BASE;
|
const apiBase = modeUpload ? modeUpload.apiBase : DEFAULT_API_BASE;
|
||||||
|
const cdnHost = modeUpload ? modeUpload.cdnHost : DEFAULT_CDN_HOST[args.target];
|
||||||
const token = await login(apiBase, {
|
const token = await login(apiBase, {
|
||||||
phone: args.phone,
|
phone: args.phone,
|
||||||
password: args.password,
|
password: args.password,
|
||||||
@@ -293,8 +305,8 @@ async function main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
console.log(`版本号: ${version}`);
|
console.log(`版本号: ${version}`);
|
||||||
const cdnLabel = args.target === 'prod' ? '正式 CDN' : '测试 CDN';
|
console.log(`签名接口: ${apiBase}`);
|
||||||
console.log(`CDN: ${cdnLabel}(只影响下载地址,生产环境也可以从测试 CDN 安装)`);
|
console.log(`CDN: ${cdnHost}`);
|
||||||
const uploaded = await uploadApkFile({
|
const uploaded = await uploadApkFile({
|
||||||
apiBase,
|
apiBase,
|
||||||
token,
|
token,
|
||||||
@@ -303,7 +315,7 @@ async function main() {
|
|||||||
fileName,
|
fileName,
|
||||||
status,
|
status,
|
||||||
});
|
});
|
||||||
console.log(toPublicUrl(args.target, saveKey, uploaded));
|
console.log(toPublicUrl(cdnHost, saveKey, uploaded));
|
||||||
|
|
||||||
const latestUploaded = await uploadApkFile({
|
const latestUploaded = await uploadApkFile({
|
||||||
apiBase,
|
apiBase,
|
||||||
@@ -313,7 +325,7 @@ async function main() {
|
|||||||
fileName: latestFileName,
|
fileName: latestFileName,
|
||||||
status,
|
status,
|
||||||
});
|
});
|
||||||
console.log(toPublicUrl(args.target, latestSaveKey, latestUploaded));
|
console.log(toPublicUrl(cdnHost, latestSaveKey, latestUploaded));
|
||||||
}
|
}
|
||||||
|
|
||||||
main().catch((error) => {
|
main().catch((error) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user