Skip to content

Commit b24b27d

Browse files
committedJan 11, 2025
ts
1 parent 4f07841 commit b24b27d

File tree

4 files changed

+18
-17
lines changed

4 files changed

+18
-17
lines changed
 

‎biome.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"recommended": true,
99
"suspicious": {
1010
"noExplicitAny": "off",
11-
"noAssignInExpressions": "off"
11+
"noAssignInExpressions": "off",
12+
"noDoubleEquals": "off"
1213
},
1314
"style": {
1415
"noNonNullAssertion": "off"

‎src/package.js renamed to ‎src/package.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { checkPlatform, getSelectedApp } from './app';
66
import { getApkInfo, getIpaInfo, getAppInfo } from './utils';
77
import Table from 'tty-table';
88

9-
export async function listPackage(appId) {
9+
export async function listPackage(appId: string) {
1010
const { data } = await get(`/app/${appId}/package/list?limit=1000`);
1111

1212
const header = [{ value: '原生包 Id' }, { value: '原生版本' }];
@@ -35,20 +35,20 @@ export async function listPackage(appId) {
3535
return data;
3636
}
3737

38-
export async function choosePackage(appId) {
38+
export async function choosePackage(appId: string) {
3939
const list = await listPackage(appId);
4040

4141
while (true) {
4242
const id = await question('输入原生包 id:');
43-
const app = list.find((v) => v.id === (id | 0));
43+
const app = list.find((v) => v.id === Number(id));
4444
if (app) {
4545
return app;
4646
}
4747
}
4848
}
4949

5050
export const commands = {
51-
uploadIpa: async function ({ args }) {
51+
uploadIpa: async ({ args }: { args: string[] }) => {
5252
const fn = args[0];
5353
if (!fn || !fn.endsWith('.ipa')) {
5454
throw new Error('使用方法: pushy uploadIpa ipa后缀文件');
@@ -85,7 +85,7 @@ export const commands = {
8585
`已成功上传ipa原生包(id: ${id}, version: ${versionName}, buildTime: ${buildTime})`,
8686
);
8787
},
88-
uploadApk: async function ({ args }) {
88+
uploadApk: async ({ args }) => {
8989
const fn = args[0];
9090
if (!fn || !fn.endsWith('.apk')) {
9191
throw new Error('使用方法: pushy uploadApk apk后缀文件');
@@ -122,7 +122,7 @@ export const commands = {
122122
`已成功上传apk原生包(id: ${id}, version: ${versionName}, buildTime: ${buildTime})`,
123123
);
124124
},
125-
uploadApp: async function ({ args }) {
125+
uploadApp: async ({ args }) => {
126126
const fn = args[0];
127127
if (!fn || !fn.endsWith('.app')) {
128128
throw new Error('使用方法: pushy uploadApp app后缀文件');
@@ -134,7 +134,6 @@ export const commands = {
134134
appKey: appKeyInPkg,
135135
} = await getAppInfo(fn);
136136
const { appId, appKey } = await getSelectedApp('harmony');
137-
138137

139138
if (appIdInPkg && appIdInPkg != appId) {
140139
throw new Error(
@@ -160,28 +159,28 @@ export const commands = {
160159
`已成功上传app原生包(id: ${id}, version: ${versionName}, buildTime: ${buildTime})`,
161160
);
162161
},
163-
parseApp: async function ({ args }) {
162+
parseApp: async ({ args }) => {
164163
const fn = args[0];
165164
if (!fn || !fn.endsWith('.app')) {
166165
throw new Error('使用方法: pushy parseApp app后缀文件');
167166
}
168167
console.log(await getAppInfo(fn));
169168
},
170-
parseIpa: async function ({ args }) {
169+
parseIpa: async ({ args }) => {
171170
const fn = args[0];
172171
if (!fn || !fn.endsWith('.ipa')) {
173172
throw new Error('使用方法: pushy parseIpa ipa后缀文件');
174173
}
175174
console.log(await getIpaInfo(fn));
176175
},
177-
parseApk: async function ({ args }) {
176+
parseApk: async ({ args }) => {
178177
const fn = args[0];
179178
if (!fn || !fn.endsWith('.apk')) {
180179
throw new Error('使用方法: pushy parseApk apk后缀文件');
181180
}
182181
console.log(await getApkInfo(fn));
183182
},
184-
packages: async function ({ options }) {
183+
packages: async ({ options }) => {
185184
const platform = checkPlatform(
186185
options.platform || (await question('平台(ios/android/harmony):')),
187186
);

‎src/user.js renamed to ‎src/user.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ import { question } from './utils';
22
import { post, get, replaceSession, saveSession, closeSession } from './api';
33
import crypto from 'node:crypto';
44

5-
function md5(str) {
5+
function md5(str: string) {
66
return crypto.createHash('md5').update(str).digest('hex');
77
}
88

99
export const commands = {
10-
login: async ({ args }) => {
10+
login: async ({ args }: { args: string[] }) => {
1111
const email = args[0] || (await question('email:'));
1212
const pwd = args[1] || (await question('password:', true));
1313
const { token, info } = await post('/user/login', {

‎src/utils/index.js renamed to ‎src/utils/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ export function translateOptions(options) {
2525
for (const key in options) {
2626
const v = options[key];
2727
if (typeof v === 'string') {
28-
ret[key] = v.replace(/\$\{(\w+)\}/g, (v, n) =>
29-
options[n] || process.env[n] || v,
28+
ret[key] = v.replace(
29+
/\$\{(\w+)\}/g,
30+
(v, n) => options[n] || process.env[n] || v,
3031
);
3132
} else {
3233
ret[key] = v;
@@ -124,7 +125,7 @@ export async function getAppInfo(fn) {
124125
return { versionName, buildTime, ...appCredential };
125126
}
126127

127-
export async function getIpaInfo(fn) {
128+
export async function getIpaInfo(fn: string) {
128129
const appInfoParser = new AppInfoParser(fn);
129130
const bundleFile = await appInfoParser.parser.getEntry(
130131
/payload\/.+?\.app\/main.jsbundle/,

0 commit comments

Comments
 (0)