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