mirror of
				https://gitcode.com/github-mirrors/react-native-update-cli.git
				synced 2025-10-31 14:53:11 +08:00 
			
		
		
		
	Add deletePackage command with confirmation and error handling; update version to 2.1.0 and enhance localization for delete operations
This commit is contained in:
		
							
								
								
									
										7
									
								
								cli.json
									
									
									
									
									
								
							
							
						
						
									
										7
									
								
								cli.json
									
									
									
									
									
								
							| @@ -62,6 +62,13 @@ | |||||||
|         } |         } | ||||||
|       } |       } | ||||||
|     }, |     }, | ||||||
|  |     "deletePackage": { | ||||||
|  |       "options": { | ||||||
|  |         "appId": { | ||||||
|  |           "hasValue": true | ||||||
|  |         } | ||||||
|  |       } | ||||||
|  |     }, | ||||||
|     "publish": { |     "publish": { | ||||||
|       "options": { |       "options": { | ||||||
|         "platform": { |         "platform": { | ||||||
|   | |||||||
| @@ -1,6 +1,6 @@ | |||||||
| { | { | ||||||
|   "name": "react-native-update-cli", |   "name": "react-native-update-cli", | ||||||
|   "version": "2.0.1", |   "version": "2.1.0", | ||||||
|   "description": "command line tool for react-native-update (remote updates for react native)", |   "description": "command line tool for react-native-update (remote updates for react native)", | ||||||
|   "main": "index.js", |   "main": "index.js", | ||||||
|   "bin": { |   "bin": { | ||||||
|   | |||||||
| @@ -131,4 +131,10 @@ This can reduce the risk of inconsistent dependencies and supply chain attacks. | |||||||
|   unnamed: '(Unnamed)', |   unnamed: '(Unnamed)', | ||||||
|   dryRun: 'Below is the dry-run result, no actual operation will be performed:', |   dryRun: 'Below is the dry-run result, no actual operation will be performed:', | ||||||
|   usingCustomVersion: 'Using custom version: {{version}}', |   usingCustomVersion: 'Using custom version: {{version}}', | ||||||
|  |   confirmDeletePackage: | ||||||
|  |     'Confirm delete native package {{packageId}}? This operation cannot be undone (Y/N):', | ||||||
|  |   deletePackageSuccess: 'Native package {{packageId}} deleted successfully', | ||||||
|  |   deletePackageError: | ||||||
|  |     'Failed to delete native package {{packageId}}: {{error}}', | ||||||
|  |   usageDeletePackage: 'Usage: cresc deletePackage [packageId] --appId [appId]', | ||||||
| }; | }; | ||||||
|   | |||||||
| @@ -124,4 +124,9 @@ export default { | |||||||
|   unnamed: '(未命名)', |   unnamed: '(未命名)', | ||||||
|   dryRun: '以下是 dry-run 模拟运行结果,不会实际执行任何操作:', |   dryRun: '以下是 dry-run 模拟运行结果,不会实际执行任何操作:', | ||||||
|   usingCustomVersion: '使用自定义版本:{{version}}', |   usingCustomVersion: '使用自定义版本:{{version}}', | ||||||
|  |   confirmDeletePackage: '确认删除原生包 {{packageId}}? 此操作不可撤销 (Y/N):', | ||||||
|  |   deletePackageSuccess: '原生包 {{packageId}} 删除成功', | ||||||
|  |   deletePackageError: '删除原生包 {{packageId}} 失败: {{error}}', | ||||||
|  |   usageDeletePackage: | ||||||
|  |     '使用方法: pushy deletePackage [packageId] --appId [appId]', | ||||||
| }; | }; | ||||||
|   | |||||||
| @@ -1,4 +1,4 @@ | |||||||
| import { get, getAllPackages, post, uploadFile } from './api'; | import { get, getAllPackages, post, uploadFile, doDelete } from './api'; | ||||||
| import { question, saveToLocal } from './utils'; | import { question, saveToLocal } from './utils'; | ||||||
| import { t } from './utils/i18n'; | import { t } from './utils/i18n'; | ||||||
|  |  | ||||||
| @@ -212,4 +212,47 @@ export const packageCommands = { | |||||||
|     const { appId } = await getSelectedApp(platform); |     const { appId } = await getSelectedApp(platform); | ||||||
|     await listPackage(appId); |     await listPackage(appId); | ||||||
|   }, |   }, | ||||||
|  |   deletePackage: async ({ | ||||||
|  |     args, | ||||||
|  |     options, | ||||||
|  |   }: { | ||||||
|  |     args: string[]; | ||||||
|  |     options: { appId?: string }; | ||||||
|  |   }) => { | ||||||
|  |     let packageId = args[0]; | ||||||
|  |     let { appId } = options; | ||||||
|  |  | ||||||
|  |     if (!appId) { | ||||||
|  |       const platform = await getPlatform(); | ||||||
|  |       appId = (await getSelectedApp(platform)).appId as string; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     // If no packageId provided as argument, let user choose from list | ||||||
|  |     if (!packageId) { | ||||||
|  |       const selectedPackage = await choosePackage(appId); | ||||||
|  |       packageId = selectedPackage.id; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     // Confirm deletion | ||||||
|  |     // const confirmDelete = await question( | ||||||
|  |     //   t('confirmDeletePackage', { packageId }), | ||||||
|  |     // ); | ||||||
|  |  | ||||||
|  |     // if ( | ||||||
|  |     //   confirmDelete.toLowerCase() !== 'y' && | ||||||
|  |     //   confirmDelete.toLowerCase() !== 'yes' | ||||||
|  |     // ) { | ||||||
|  |     //   console.log(t('cancelled')); | ||||||
|  |     //   return; | ||||||
|  |     // } | ||||||
|  |  | ||||||
|  |     try { | ||||||
|  |       await doDelete(`/app/${appId}/package/${packageId}`); | ||||||
|  |       console.log(t('deletePackageSuccess', { packageId })); | ||||||
|  |     } catch (error: any) { | ||||||
|  |       throw new Error( | ||||||
|  |         t('deletePackageError', { packageId, error: error.message }), | ||||||
|  |       ); | ||||||
|  |     } | ||||||
|  |   }, | ||||||
| }; | }; | ||||||
|   | |||||||
| @@ -4,7 +4,8 @@ | |||||||
|     "target": "ESNext" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */, |     "target": "ESNext" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */, | ||||||
|     "module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */, |     "module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */, | ||||||
|     "lib": [ |     "lib": [ | ||||||
|       "ESNext" |       "ESNext", | ||||||
|  |       "DOM" | ||||||
|     ] /* Specify library files to be included in the compilation. */, |     ] /* Specify library files to be included in the compilation. */, | ||||||
|     "allowJs": true /* Allow javascript files to be compiled. */, |     "allowJs": true /* Allow javascript files to be compiled. */, | ||||||
|     // "checkJs": true /* Report errors in .js files. */, |     // "checkJs": true /* Report errors in .js files. */, | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 sunny.ll
					sunny.ll