1
0
mirror of https://gitcode.com/github-mirrors/react-native-update-cli.git synced 2025-09-16 09:41:38 +08:00
Code Issues Packages Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
sunnylqm
2025-01-11 20:23:25 +08:00
parent 4f0784172f
commit b24b27d100
4 changed files with 18 additions and 17 deletions

View File

@@ -8,7 +8,8 @@
"recommended": true,
"suspicious": {
"noExplicitAny": "off",
"noAssignInExpressions": "off"
"noAssignInExpressions": "off",
"noDoubleEquals": "off"
},
"style": {
"noNonNullAssertion": "off"

View File

@@ -6,7 +6,7 @@ import { checkPlatform, getSelectedApp } from './app';
import { getApkInfo, getIpaInfo, getAppInfo } from './utils';
import Table from 'tty-table';
export async function listPackage(appId) {
export async function listPackage(appId: string) {
const { data } = await get(`/app/${appId}/package/list?limit=1000`);
const header = [{ value: '原生包 Id' }, { value: '原生版本' }];
@@ -35,12 +35,12 @@ export async function listPackage(appId) {
return data;
}
export async function choosePackage(appId) {
export async function choosePackage(appId: string) {
const list = await listPackage(appId);
while (true) {
const id = await question('输入原生包 id:');
const app = list.find((v) => v.id === (id | 0));
const app = list.find((v) => v.id === Number(id));
if (app) {
return app;
}
@@ -48,7 +48,7 @@ export async function choosePackage(appId) {
}
export const commands = {
uploadIpa: async function ({ args }) {
uploadIpa: async ({ args }: { args: string[] }) => {
const fn = args[0];
if (!fn || !fn.endsWith('.ipa')) {
throw new Error('使用方法: pushy uploadIpa ipa后缀文件');
@@ -85,7 +85,7 @@ export const commands = {
`已成功上传ipa原生包id: ${id}, version: ${versionName}, buildTime: ${buildTime}`,
);
},
uploadApk: async function ({ args }) {
uploadApk: async ({ args }) => {
const fn = args[0];
if (!fn || !fn.endsWith('.apk')) {
throw new Error('使用方法: pushy uploadApk apk后缀文件');
@@ -122,7 +122,7 @@ export const commands = {
`已成功上传apk原生包id: ${id}, version: ${versionName}, buildTime: ${buildTime}`,
);
},
uploadApp: async function ({ args }) {
uploadApp: async ({ args }) => {
const fn = args[0];
if (!fn || !fn.endsWith('.app')) {
throw new Error('使用方法: pushy uploadApp app后缀文件');
@@ -135,7 +135,6 @@ export const commands = {
} = await getAppInfo(fn);
const { appId, appKey } = await getSelectedApp('harmony');
if (appIdInPkg && appIdInPkg != appId) {
throw new Error(
`appId不匹配当前app: ${appIdInPkg}, 当前update.json: ${appId}`,
@@ -160,28 +159,28 @@ export const commands = {
`已成功上传app原生包id: ${id}, version: ${versionName}, buildTime: ${buildTime}`,
);
},
parseApp: async function ({ args }) {
parseApp: async ({ args }) => {
const fn = args[0];
if (!fn || !fn.endsWith('.app')) {
throw new Error('使用方法: pushy parseApp app后缀文件');
}
console.log(await getAppInfo(fn));
},
parseIpa: async function ({ args }) {
parseIpa: async ({ args }) => {
const fn = args[0];
if (!fn || !fn.endsWith('.ipa')) {
throw new Error('使用方法: pushy parseIpa ipa后缀文件');
}
console.log(await getIpaInfo(fn));
},
parseApk: async function ({ args }) {
parseApk: async ({ args }) => {
const fn = args[0];
if (!fn || !fn.endsWith('.apk')) {
throw new Error('使用方法: pushy parseApk apk后缀文件');
}
console.log(await getApkInfo(fn));
},
packages: async function ({ options }) {
packages: async ({ options }) => {
const platform = checkPlatform(
options.platform || (await question('平台(ios/android/harmony):')),
);

View File

@@ -2,12 +2,12 @@ import { question } from './utils';
import { post, get, replaceSession, saveSession, closeSession } from './api';
import crypto from 'node:crypto';
function md5(str) {
function md5(str: string) {
return crypto.createHash('md5').update(str).digest('hex');
}
export const commands = {
login: async ({ args }) => {
login: async ({ args }: { args: string[] }) => {
const email = args[0] || (await question('email:'));
const pwd = args[1] || (await question('password:', true));
const { token, info } = await post('/user/login', {

View File

@@ -25,8 +25,9 @@ export function translateOptions(options) {
for (const key in options) {
const v = options[key];
if (typeof v === 'string') {
ret[key] = v.replace(/\$\{(\w+)\}/g, (v, n) =>
options[n] || process.env[n] || v,
ret[key] = v.replace(
/\$\{(\w+)\}/g,
(v, n) => options[n] || process.env[n] || v,
);
} else {
ret[key] = v;
@@ -124,7 +125,7 @@ export async function getAppInfo(fn) {
return { versionName, buildTime, ...appCredential };
}
export async function getIpaInfo(fn) {
export async function getIpaInfo(fn: string) {
const appInfoParser = new AppInfoParser(fn);
const bundleFile = await appInfoParser.parser.getEntry(
/payload\/.+?\.app\/main.jsbundle/,