@@ -3,21 +3,22 @@ import fs from 'node:fs';
33import Table from 'tty-table' ;
44
55import { post , get , doDelete } from './api' ;
6+ import type { Platform } from './types' ;
67
78const validPlatforms = {
89 ios : 1 ,
910 android : 1 ,
1011 harmony : 1 ,
1112} ;
1213
13- export function checkPlatform ( platform ) {
14+ export function checkPlatform ( platform : Platform ) {
1415 if ( ! validPlatforms [ platform ] ) {
1516 throw new Error ( `无法识别的平台 '${ platform } '` ) ;
1617 }
1718 return platform ;
1819}
1920
20- export function getSelectedApp ( platform ) {
21+ export function getSelectedApp ( platform : Platform ) {
2122 checkPlatform ( platform ) ;
2223
2324 if ( ! fs . existsSync ( 'update.json' ) ) {
@@ -34,7 +35,7 @@ export function getSelectedApp(platform) {
3435 return updateInfo [ platform ] ;
3536}
3637
37- export async function listApp ( platform ) {
38+ export async function listApp ( platform : Platform ) {
3839 const { data } = await get ( '/app/list' ) ;
3940 const list = platform ? data . filter ( ( v ) => v . platform === platform ) : data ;
4041
@@ -58,12 +59,12 @@ export async function listApp(platform) {
5859 return list ;
5960}
6061
61- export async function chooseApp ( platform ) {
62+ export async function chooseApp ( platform : Platform ) {
6263 const list = await listApp ( platform ) ;
6364
6465 while ( true ) {
6566 const id = await question ( '输入应用 id:' ) ;
66- const app = list . find ( ( v ) => v . id === ( id | 0 ) ) ;
67+ const app = list . find ( ( v ) => v . id === Number ( id ) ) ;
6768 if ( app ) {
6869 return app ;
6970 }
0 commit comments