feat: 上传脚本支持手机号密码参数

This commit is contained in:
2026-10-31 19:01:16 +08:00
parent 2764b27118
commit 7b11fc60c8
+23 -13
View File
@@ -39,7 +39,7 @@ function parseArgs(argv) {
for (let i = 0; i < argv.length; i += 1) {
const key = argv[i];
const value = argv[i + 1];
if (key === '--file' || key === '--target' || key === '--mode' || key === '--version') {
if (key === '--file' || key === '--target' || key === '--mode' || key === '--version' || key === '--phone' || key === '--password' || key === '--tenant') {
args[key.slice(2)] = value;
i += 1;
}
@@ -126,9 +126,9 @@ async function apiJson(apiBase, urlPath, { method = 'GET', token, body } = {}) {
return data.data || {};
}
async function login(apiBase) {
const phone = await ask('手机号: ');
const password = await askPassword('密码: ');
async function login(apiBase, { phone: phoneArg, password: passwordArg, tenant: tenantArg } = {}) {
const phone = phoneArg || await ask('手机号: ');
const password = passwordArg || await askPassword('密码: ');
if (!phone || !password) {
throw new Error('请输入手机号和密码');
}
@@ -148,14 +148,20 @@ async function login(apiBase) {
let tenant = tenants[0];
if (tenants.length > 1) {
console.log('请选择账套:');
tenants.forEach((item, index) => {
const name = item.company_name || item.database_name || item.tenant_contacts || item.tenant_management_id;
console.log(` ${index + 1}. ${name}`);
});
const picked = Number(await ask('序号: '));
tenant = tenants[picked - 1];
if (!tenant) throw new Error('账套序号无效');
if (tenantArg) {
const picked = Number(tenantArg);
tenant = tenants[picked - 1];
if (!tenant) throw new Error('账套序号无效');
} else {
console.log('请选择账套:');
tenants.forEach((item, index) => {
const name = item.company_name || item.database_name || item.tenant_contacts || item.tenant_management_id;
console.log(` ${index + 1}. ${name}`);
});
const picked = Number(await ask('序号: '));
tenant = tenants[picked - 1];
if (!tenant) throw new Error('账套序号无效');
}
}
const second = await apiJson(apiBase, '/admin/v1/login', {
@@ -248,7 +254,11 @@ async function main() {
const fileName = `${version}.apk`;
const saveKey = `/version/${upgradeName}/${fileName}`;
const apiBase = API_BASE;
const token = await login(apiBase);
const token = await login(apiBase, {
phone: args.phone,
password: args.password,
tenant: args.tenant,
});
console.log(`版本号: ${version}`);
console.log(`场景路径: ${saveKey}`);