mirror of
				https://gitcode.com/github-mirrors/react-native-update-cli.git
				synced 2025-10-29 05:43:11 +08:00 
			
		
		
		
	maxSize
This commit is contained in:
		| @@ -34,6 +34,7 @@ | ||||
|   "dependencies": { | ||||
|     "app-info-parser": "^0.3.9", | ||||
|     "cli-arguments": "^0.2.1", | ||||
|     "filesize-parser": "^1.5.0", | ||||
|     "fs-extra": "^8.1.0", | ||||
|     "gradle-to-js": "^2.0.0", | ||||
|     "node-fetch": "^2.6.0", | ||||
|   | ||||
| @@ -11,6 +11,8 @@ const packageJson = require('../package.json'); | ||||
| const tcpp = require('tcp-ping'); | ||||
| const util = require('util'); | ||||
| const path = require('path'); | ||||
| import filesizeParser from 'filesize-parser'; | ||||
| import { pricingPageUrl } from './utils'; | ||||
|  | ||||
| const tcpPing = util.promisify(tcpp.ping); | ||||
|  | ||||
| @@ -103,7 +105,7 @@ exports.put = queryWithBody('PUT'); | ||||
| exports.doDelete = queryWithBody('DELETE'); | ||||
|  | ||||
| async function uploadFile(fn, key) { | ||||
|   const { url, backupUrl, formData } = await exports.post('/upload', { | ||||
|   const { url, backupUrl, formData, maxSize } = await exports.post('/upload', { | ||||
|     ext: path.extname(fn) | ||||
|   }); | ||||
|   let realUrl = url; | ||||
| @@ -122,6 +124,9 @@ async function uploadFile(fn, key) { | ||||
|   } | ||||
|  | ||||
|   const fileSize = fs.statSync(fn).size; | ||||
|   if (maxSize && fileSize > filesizeParser(maxSize)) { | ||||
|     throw new Error(`此文件大小超出上限${maxSize}。您可以考虑购买付费业务以提升此限制。详情请访问:${pricingPageUrl}`) | ||||
|   } | ||||
|  | ||||
|   const bar = new ProgressBar('  Uploading [:bar] :percent :etas', { | ||||
|     complete: '=', | ||||
|   | ||||
| @@ -128,3 +128,5 @@ export function printVersionCommand() { | ||||
|     console.log('react-native-update: 无法获取版本号,请在项目目录中运行命令') | ||||
|   } | ||||
| } | ||||
|  | ||||
| export const pricingPageUrl = 'https://pushy.reactnative.cn/pricing' | ||||
|   | ||||
| @@ -1104,6 +1104,11 @@ filename-regex@^2.0.0: | ||||
|   resolved "https://registry.yarnpkg.com/filename-regex/-/filename-regex-2.0.1.tgz#c1c4b9bee3e09725ddb106b75c1e301fe2f18b26" | ||||
|   integrity sha1-wcS5vuPglyXdsQa3XB4wH+LxiyY= | ||||
|  | ||||
| filesize-parser@^1.5.0: | ||||
|   version "1.5.0" | ||||
|   resolved "https://registry.yarnpkg.com/filesize-parser/-/filesize-parser-1.5.0.tgz#97ad66d5b0d7154b2e8b1b4e83f526aed33c62f3" | ||||
|   integrity sha512-UTDpJB22VvozK7t31slU9WCAPSdcUWuwD7P7S6LBXswdgzUz+YhoziLOohknFcx0Kq5LWCAj4MEKY9q3zGq47Q== | ||||
|  | ||||
| fill-range@^2.1.0: | ||||
|   version "2.2.4" | ||||
|   resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-2.2.4.tgz#eb1e773abb056dcd8df2bfdf6af59b8b3a936565" | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 sunnylqm
					sunnylqm