mirror of
				https://gitcode.com/github-mirrors/react-native-update-cli.git
				synced 2025-10-31 14:53:11 +08:00 
			
		
		
		
	Support oss
This commit is contained in:
		
							
								
								
									
										8
									
								
								.babelrc
									
									
									
									
									
								
							
							
						
						
									
										8
									
								
								.babelrc
									
									
									
									
									
								
							| @@ -1,14 +1,8 @@ | ||||
| { | ||||
|   "plugins": [ | ||||
|     "syntax-object-rest-spread", | ||||
|     "syntax-async-functions", | ||||
|     "transform-es2015-arrow-functions", | ||||
|     "transform-async-to-generator", | ||||
|     "transform-es2015-modules-commonjs", | ||||
|     "transform-es2015-destructuring", | ||||
|     "transform-es2015-spread", | ||||
|     "transform-object-rest-spread", | ||||
|     "transform-es2015-parameters", | ||||
|     "transform-strict-mode" | ||||
|     "transform-object-rest-spread" | ||||
|   ] | ||||
| } | ||||
|   | ||||
							
								
								
									
										30
									
								
								package.json
									
									
									
									
									
								
							
							
						
						
									
										30
									
								
								package.json
									
									
									
									
									
								
							| @@ -32,31 +32,25 @@ | ||||
|   }, | ||||
|   "homepage": "https://github.com/reactnativecn/react-native-pushy/tree/master/react-native-pushy-cli", | ||||
|   "dependencies": { | ||||
|     "app-info-parser": "^0.3.8", | ||||
|     "app-info-parser": "^0.3.9", | ||||
|     "cli-arguments": "^0.2.1", | ||||
|     "fs-extra": "^8.1.0", | ||||
|     "gradle-to-js": "^2.0.0", | ||||
|     "isomorphic-fetch": "^2.2.1", | ||||
|     "progress": "^1.1.8", | ||||
|     "node-fetch": "^2.6.0", | ||||
|     "progress": "^2.0.3", | ||||
|     "read": "^1.0.7", | ||||
|     "request": "^2.69.0", | ||||
|     "tty-table": "^2.7.0", | ||||
|     "request": "^2.88.2", | ||||
|     "tty-table": "^3.2.0", | ||||
|     "update-notifier": "^4.1.0", | ||||
|     "yauzl": "^2.10.0", | ||||
|     "yazl": "2.3.0" | ||||
|     "yazl": "2.5.1" | ||||
|   }, | ||||
|   "devDependencies": { | ||||
|     "babel-cli": "^6.5.1", | ||||
|     "babel-eslint": "^4.1.6", | ||||
|     "babel-plugin-syntax-async-functions": "^6.5.0", | ||||
|     "babel-plugin-syntax-object-rest-spread": "^6.5.0", | ||||
|     "babel-plugin-transform-async-to-generator": "^6.3.13", | ||||
|     "babel-plugin-transform-es2015-arrow-functions": "^6.5.2", | ||||
|     "babel-plugin-transform-es2015-destructuring": "^6.3.15", | ||||
|     "babel-plugin-transform-es2015-modules-commonjs": "^6.3.16", | ||||
|     "babel-plugin-transform-es2015-parameters": "^6.5.0", | ||||
|     "babel-plugin-transform-es2015-spread": "^6.5.2", | ||||
|     "babel-plugin-transform-object-rest-spread": "^6.5.0", | ||||
|     "babel-plugin-transform-strict-mode": "^6.5.2" | ||||
|     "babel-cli": "^6.26.0", | ||||
|     "babel-eslint": "^10.1.0", | ||||
|     "babel-plugin-syntax-object-rest-spread": "^6.13.0", | ||||
|     "babel-plugin-transform-es2015-modules-commonjs": "^6.26.2", | ||||
|     "babel-plugin-transform-es2015-spread": "^6.22.0", | ||||
|     "babel-plugin-transform-object-rest-spread": "^6.26.0" | ||||
|   } | ||||
| } | ||||
|   | ||||
							
								
								
									
										24
									
								
								src/api.js
									
									
									
									
									
								
							
							
						
						
									
										24
									
								
								src/api.js
									
									
									
									
									
								
							| @@ -2,7 +2,7 @@ | ||||
|  * Created by tdzl2003 on 2/13/16. | ||||
|  */ | ||||
|  | ||||
| const fetch = require('isomorphic-fetch'); | ||||
| const fetch = require('node-fetch'); | ||||
| let host = process.env.PUSHY_REGISTRY || 'https://update.reactnative.cn/api'; | ||||
| const fs = require('fs-extra'); | ||||
| import request from 'request'; | ||||
| @@ -17,7 +17,9 @@ exports.loadSession = async function() { | ||||
|       exports.replaceSession(JSON.parse(fs.readFileSync('.update', 'utf8'))); | ||||
|       savedSession = session; | ||||
|     } catch (e) { | ||||
|       console.error('Failed to parse file `.update`. Try to remove it manually.'); | ||||
|       console.error( | ||||
|         'Failed to parse file `.update`. Try to remove it manually.', | ||||
|       ); | ||||
|       throw e; | ||||
|     } | ||||
|   } | ||||
| @@ -54,7 +56,9 @@ async function query(url, options) { | ||||
|   const resp = await fetch(url, options); | ||||
|   const json = await resp.json(); | ||||
|   if (resp.status !== 200) { | ||||
|     throw Object.assign(new Error(json.message || json.error), { status: resp.status }); | ||||
|     throw Object.assign(new Error(json.message || json.error), { | ||||
|       status: resp.status, | ||||
|     }); | ||||
|   } | ||||
|   return json; | ||||
| } | ||||
| @@ -89,7 +93,7 @@ exports.put = queryWithBody('PUT'); | ||||
| exports.doDelete = queryWithBody('DELETE'); | ||||
|  | ||||
| async function uploadFile(fn) { | ||||
|   const { url, fieldName, formData } = await exports.post('/upload', {}); | ||||
|   const { url, formData } = await exports.post('/upload', {}); | ||||
|   let realUrl = url; | ||||
|  | ||||
|   if (!/^https?\:\/\//.test(url)) { | ||||
| @@ -120,9 +124,17 @@ async function uploadFile(fn) { | ||||
|           return reject(err); | ||||
|         } | ||||
|         if (resp.statusCode > 299) { | ||||
|           return reject(Object.assign(new Error(body), { status: resp.statusCode })); | ||||
|           return reject( | ||||
|             Object.assign(new Error(body), { status: resp.statusCode }), | ||||
|           ); | ||||
|         } | ||||
|         resolve(JSON.parse(body)); | ||||
|         resolve( | ||||
|           body | ||||
|             ? // qiniu | ||||
|               JSON.parse(body) | ||||
|             : // aliyun oss | ||||
|               { hash: formData.key }, | ||||
|         ); | ||||
|       }, | ||||
|     ); | ||||
|   }); | ||||
|   | ||||
| @@ -47,7 +47,7 @@ export async function choosePackage(appId) { | ||||
| export const commands = { | ||||
|   uploadIpa: async function({ args }) { | ||||
|     const fn = args[0]; | ||||
|     if (!fn) { | ||||
|     if (!fn || !fn.endsWith('.ipa')) { | ||||
|       throw new Error('Usage: pushy uploadIpa <ipaFile>'); | ||||
|     } | ||||
|     const { versionName, buildTime } = await getIpaInfo(fn); | ||||
| @@ -60,12 +60,12 @@ export const commands = { | ||||
|       hash, | ||||
|       buildTime, | ||||
|     }); | ||||
|     saveToLocal(fn, `${appId}/${id}.ipa`); | ||||
|     saveToLocal(fn, `${appId}/package/${id}.ipa`); | ||||
|     console.log(`Ipa uploaded: ${id}`); | ||||
|   }, | ||||
|   uploadApk: async function({ args }) { | ||||
|     const fn = args[0]; | ||||
|     if (!fn) { | ||||
|     if (!fn || !fn.endsWith('.apk')) { | ||||
|       throw new Error('Usage: pushy uploadApk <apkFile>'); | ||||
|     } | ||||
|     const { versionName, buildTime } = await getApkInfo(fn); | ||||
| @@ -78,7 +78,7 @@ export const commands = { | ||||
|       hash, | ||||
|       buildTime, | ||||
|     }); | ||||
|     saveToLocal(fn, `${appId}/${id}.apk`); | ||||
|     saveToLocal(fn, `${appId}/package/${id}.apk`); | ||||
|     console.log(`Apk uploaded: ${id}`); | ||||
|   }, | ||||
|   packages: async function({ options }) { | ||||
|   | ||||
| @@ -95,7 +95,8 @@ export async function getIpaInfo(fn) { | ||||
| const localDir = path.resolve(os.homedir(), '.pushy'); | ||||
| fs.ensureDirSync(localDir); | ||||
| export function saveToLocal(originPath, destName) { | ||||
|   const destPath = path.join(localDir, destName); | ||||
|   fs.ensureDirSync(path.dirname(destPath)); | ||||
|   fs.copyFileSync(originPath, destPath); | ||||
|   // TODO | ||||
|   // const destPath = path.join(localDir, destName); | ||||
|   // fs.ensureDirSync(path.dirname(destPath)); | ||||
|   // fs.copyFileSync(originPath, destPath); | ||||
| } | ||||
|   | ||||
| @@ -8,7 +8,7 @@ const { | ||||
|   put, | ||||
|   uploadFile, | ||||
| } = require('./api'); | ||||
| import { question } from './utils'; | ||||
| import { question, saveToLocal } from './utils'; | ||||
|  | ||||
| import { checkPlatform, getSelectedApp } from './app'; | ||||
| import { choosePackage } from './package'; | ||||
| @@ -86,6 +86,8 @@ export const commands = { | ||||
|       description: description || await question('Enter description:'), | ||||
|       metaInfo: metaInfo || await question('Enter meta info:'), | ||||
|     }); | ||||
|     // TODO local diff | ||||
|     saveToLocal(fn, `${appId}/ppk/${id}.ppk`); | ||||
|     console.log(`Version published: ${id}`); | ||||
|  | ||||
|     const v = await question('Would you like to bind packages to this version?(Y/N)'); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 sunnylqm
					sunnylqm