File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -78,7 +78,7 @@ async function run() {
7878 const handler = commandHandlers [ argv . command ] ;
7979 await handler ( argv ) ;
8080 } else {
81- throw new Error ( `Unknown command: ${ argv . command } ` ) ;
81+ throw new Error ( t ( 'unknownCommand' , { command : argv . command } ) ) ;
8282 }
8383 } catch ( err : any ) {
8484 if ( err . status === 401 ) {
Original file line number Diff line number Diff line change @@ -433,7 +433,9 @@ function normalizeString(value: string | undefined): string | undefined {
433433export function resolveHermesCommand ( projectRoot = process . cwd ( ) ) : string {
434434 const osBin = getHermesOSBin ( ) ;
435435 if ( ! osBin ) {
436- throw new Error ( `Unsupported platform for Hermes: ${ os . platform ( ) } ` ) ;
436+ throw new Error (
437+ t ( 'unsupportedPlatformForHermes' , { platform : os . platform ( ) } ) ,
438+ ) ;
437439 }
438440
439441 const executableName = getHermesExecutableName ( ) ;
Original file line number Diff line number Diff line change @@ -204,7 +204,7 @@ export const bundleCommands = {
204204 throw new Error ( t ( 'platformRequired' ) ) ;
205205 }
206206
207- console . log ( `Bundling with react-native: ${ depVersions [ 'react-native' ] } ` ) ;
207+ console . log ( t ( 'bundlingWithRN' , { version : depVersions [ 'react-native' ] } ) ) ;
208208
209209 await runReactNativeBundleCommand ( {
210210 bundleName : normalized . bundleName ,
Original file line number Diff line number Diff line change @@ -347,7 +347,7 @@ function diffArgsCheck(
347347 tempDir,
348348 } as DiffCommandOptions & { tempDir : string } ) ;
349349 if ( typeof output !== 'string' ) {
350- throw new Error ( 'Output path is required.' ) ;
350+ throw new Error ( t ( 'outputPathRequired' ) ) ;
351351 }
352352
353353 return {
Original file line number Diff line number Diff line change @@ -193,4 +193,13 @@ This can reduce the risk of inconsistent dependencies and supply chain attacks.
193193 'Network error — likely caused by a proxy/VPN. Please try disabling your proxy and retry.' ,
194194 proxyNetworkErrorTips :
195195 'Common fixes:\n1. Disable system proxy or VPN\n2. Check HTTP_PROXY / HTTPS_PROXY environment variables\n3. Check proxy settings in .npmrc' ,
196+ invalidId : 'Invalid id: {{id}}' ,
197+ outputPathRequired : 'Output path is required.' ,
198+ unsupportedFileType : 'Unsupported file type: {{fileType}}' ,
199+ failedToLoadSession : 'Failed to load session' ,
200+ appIdRequired : 'appId is required' ,
201+ unknownCommand : 'Unknown command: {{command}}' ,
202+ unsupportedPlatformForHermes : 'Unsupported platform for Hermes: {{platform}}' ,
203+ invalidManifest : 'Invalid manifest' ,
204+ failedToResolveResource : 'Failed to resolve resource: {{error}}' ,
196205} ;
Original file line number Diff line number Diff line change @@ -178,4 +178,13 @@ export default {
178178 '网络连接异常,可能是代理/VPN 导致。请尝试关闭代理后重试。' ,
179179 proxyNetworkErrorTips :
180180 '常见解决方法:\n1. 关闭系统代理或 VPN\n2. 检查 HTTP_PROXY / HTTPS_PROXY 环境变量\n3. 检查 .npmrc 中的 proxy 配置' ,
181+ invalidId : '无效的 id:{{id}}' ,
182+ outputPathRequired : '必须指定输出路径。' ,
183+ unsupportedFileType : '不支持的文件类型:{{fileType}}' ,
184+ failedToLoadSession : '加载登录状态失败' ,
185+ appIdRequired : '必须指定 appId' ,
186+ unknownCommand : '未知命令:{{command}}' ,
187+ unsupportedPlatformForHermes : 'Hermes 不支持当前系统平台:{{platform}}' ,
188+ invalidManifest : '无效的 manifest' ,
189+ failedToResolveResource : '资源解析失败:{{error}}' ,
181190} ;
Original file line number Diff line number Diff line change @@ -90,7 +90,7 @@ function toNumericIds(ids: string[]) {
9090 return ids . map ( ( id ) => {
9191 const numericId = Number ( id ) ;
9292 if ( ! Number . isInteger ( numericId ) || numericId <= 0 ) {
93- throw new Error ( `Invalid id: ${ id } ` ) ;
93+ throw new Error ( t ( 'invalidId' , { id } ) ) ;
9494 }
9595 return numericId ;
9696 } ) ;
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import type {
1212 UploadOptions ,
1313} from './types' ;
1414import { runAsCommandResult } from './utils/command-result' ;
15+ import { t } from './utils/i18n' ;
1516
1617const DEFAULT_BUNDLE_OUTPUT =
1718 '$' + '{tempDir}/output/$' + '{platform}.$' + '{time}.ppk' ;
@@ -164,7 +165,7 @@ export class CLIProviderImpl implements CLIProvider {
164165 : undefined ;
165166
166167 if ( ! uploadHandler ) {
167- throw new Error ( `Unsupported file type: ${ fileType } ` ) ;
168+ throw new Error ( t ( 'unsupportedFileType' , { fileType } ) ) ;
168169 }
169170 await uploadHandler ( context ) ;
170171 } ,
@@ -244,15 +245,15 @@ export class CLIProviderImpl implements CLIProvider {
244245 async loadSession ( ) : Promise < Session > {
245246 await this . ensureInitialized ( ) ;
246247 if ( ! this . session ) {
247- throw new Error ( 'Failed to load session' ) ;
248+ throw new Error ( t ( 'failedToLoadSession' ) ) ;
248249 }
249250 return this . session ;
250251 }
251252
252253 async listPackages ( appId ?: string ) : Promise < CommandResult > {
253254 return this . runDataCommand ( async ( ) => {
254255 if ( ! appId ) {
255- throw new Error ( 'appId is required to list packages' ) ;
256+ throw new Error ( t ( 'appIdRequired' ) ) ;
256257 }
257258 const { listPackage } = await import ( './package' ) ;
258259 return listPackage ( appId ) ;
Original file line number Diff line number Diff line change @@ -282,7 +282,7 @@ export async function getAabInfo(fn: string) {
282282
283283 const manifestElement = object . element ;
284284 if ( manifestElement . name !== 'manifest' ) {
285- throw new Error ( 'Invalid manifest' ) ;
285+ throw new Error ( t ( 'invalidManifest' ) ) ;
286286 }
287287
288288 let versionName = '' ;
@@ -429,7 +429,7 @@ async function resolveResource(
429429 }
430430 }
431431 } catch ( e ) {
432- console . warn ( 'Failed to resolve resource:' , e ) ;
432+ console . warn ( t ( 'failedToResolveResource' , { error : e } ) ) ;
433433 }
434434 return null ;
435435}
Original file line number Diff line number Diff line change @@ -133,7 +133,7 @@ function toNumericIds(ids: string[]) {
133133 return ids . map ( ( id ) => {
134134 const numericId = Number ( id ) ;
135135 if ( ! Number . isInteger ( numericId ) || numericId <= 0 ) {
136- throw new Error ( `Invalid id: ${ id } ` ) ;
136+ throw new Error ( t ( 'invalidId' , { id } ) ) ;
137137 }
138138 return numericId ;
139139 } ) ;
You can’t perform that action at this time.
0 commit comments