fs-extra
This commit is contained in:
parent
a7f3d23439
commit
5ab361ed54
1
.npmrc
Normal file
1
.npmrc
Normal file
@ -0,0 +1 @@
|
||||
registry=https://registry.npm.taobao.org/
|
@ -4,8 +4,7 @@
|
||||
|
||||
const fetch = require('isomorphic-fetch');
|
||||
let host = process.env.PUSHY_REGISTRY || 'https://update.reactnative.cn/api';
|
||||
const fs = require('fs-promise');
|
||||
import * as fsOrigin from 'fs';
|
||||
const fs = require('fs-extra');
|
||||
import request from 'request';
|
||||
import ProgressBar from 'progress';
|
||||
|
||||
@ -13,9 +12,9 @@ let session = undefined;
|
||||
let savedSession = undefined;
|
||||
|
||||
exports.loadSession = async function() {
|
||||
if (await fs.exists('.update')) {
|
||||
if (fs.existsSync('.update')) {
|
||||
try {
|
||||
exports.replaceSession(JSON.parse(await fs.readFile('.update', 'utf8')));
|
||||
exports.replaceSession(JSON.parse(fs.readFileSync('.update', 'utf8')));
|
||||
savedSession = session;
|
||||
} catch (e) {
|
||||
console.error('Failed to parse file `.update`. Try to remove it manually.');
|
||||
@ -32,19 +31,19 @@ exports.replaceSession = function(newSession) {
|
||||
session = newSession;
|
||||
};
|
||||
|
||||
exports.saveSession = async function() {
|
||||
exports.saveSession = function() {
|
||||
// Only save on change.
|
||||
if (session !== savedSession) {
|
||||
const current = session;
|
||||
const data = JSON.stringify(current, null, 4);
|
||||
await fs.writeFile('.update', data, 'utf8');
|
||||
fs.writeFileSync('.update', data, 'utf8');
|
||||
savedSession = current;
|
||||
}
|
||||
};
|
||||
|
||||
exports.closeSession = async function() {
|
||||
if (await fs.exists('.update')) {
|
||||
await fs.unlink('.update');
|
||||
exports.closeSession = function() {
|
||||
if (fs.existsSync('.update')) {
|
||||
fs.unlinkSync('.update');
|
||||
savedSession = undefined;
|
||||
}
|
||||
session = undefined;
|
||||
@ -97,7 +96,7 @@ async function uploadFile(fn) {
|
||||
realUrl = host + url;
|
||||
}
|
||||
|
||||
const fileSize = (await fs.stat(fn)).size;
|
||||
const fileSize = fs.statSync(fn).size;
|
||||
|
||||
const bar = new ProgressBar(' Uploading [:bar] :percent :etas', {
|
||||
complete: '=',
|
||||
@ -106,7 +105,7 @@ async function uploadFile(fn) {
|
||||
});
|
||||
|
||||
const info = await new Promise((resolve, reject) => {
|
||||
formData.file = fsOrigin.createReadStream(fn);
|
||||
formData.file = fs.createReadStream(fn);
|
||||
|
||||
formData.file.on('data', function(data) {
|
||||
bar.tick(data.length);
|
||||
|
@ -3,7 +3,7 @@
|
||||
*/
|
||||
|
||||
import {question} from './utils';
|
||||
import * as fs from 'fs-promise';
|
||||
import * as fs from 'fs-extra';
|
||||
|
||||
const {
|
||||
post,
|
||||
@ -23,13 +23,13 @@ export function checkPlatform(platform) {
|
||||
return platform
|
||||
}
|
||||
|
||||
export async function getSelectedApp(platform) {
|
||||
export function getSelectedApp(platform) {
|
||||
checkPlatform(platform);
|
||||
|
||||
if (!await fs.exists('update.json')){
|
||||
if (!fs.existsSync('update.json')){
|
||||
throw new Error(`App not selected. run 'pushy selectApp --platform ${platform}' first!`);
|
||||
}
|
||||
const updateInfo = JSON.parse(await fs.readFile('update.json', 'utf8'));
|
||||
const updateInfo = JSON.parse(fs.readFileSync('update.json', 'utf8'));
|
||||
if (!updateInfo[platform]) {
|
||||
throw new Error(`App not selected. run 'pushy selectApp --platform ${platform}' first!`);
|
||||
}
|
||||
@ -92,9 +92,9 @@ export const commands = {
|
||||
const id = args[0] || (await chooseApp(platform)).id;
|
||||
|
||||
let updateInfo = {};
|
||||
if (await fs.exists('update.json')) {
|
||||
if (fs.existsSync('update.json')) {
|
||||
try {
|
||||
updateInfo = JSON.parse(await fs.readFile('update.json', 'utf8'));
|
||||
updateInfo = JSON.parse(fs.readFileSync('update.json', 'utf8'));
|
||||
} catch (e) {
|
||||
console.error('Failed to parse file `update.json`. Try to remove it manually.');
|
||||
throw e;
|
||||
@ -105,6 +105,6 @@ export const commands = {
|
||||
appId: id,
|
||||
appKey,
|
||||
};
|
||||
await fs.writeFile('update.json', JSON.stringify(updateInfo, null, 4), 'utf8');
|
||||
fs.writeFileSync('update.json', JSON.stringify(updateInfo, null, 4), 'utf8');
|
||||
},
|
||||
}
|
||||
|
@ -3,16 +3,13 @@
|
||||
*/
|
||||
|
||||
import * as path from 'path';
|
||||
import { mkdir as mkdirRecurisve } from 'mkdir-recursive';
|
||||
import rmdirRecursive from 'rimraf';
|
||||
import { getRNVersion, translateOptions } from './utils';
|
||||
import * as fs from 'fs';
|
||||
import * as fs from 'fs-extra';
|
||||
import { ZipFile } from 'yazl';
|
||||
import { open as openZipFile } from 'yauzl';
|
||||
// import {diff} from 'node-bsdiff';
|
||||
import { question } from './utils';
|
||||
import { checkPlatform } from './app';
|
||||
import crypto from 'crypto';
|
||||
import minimist from 'minimist';
|
||||
|
||||
var diff;
|
||||
@ -28,30 +25,6 @@ try {
|
||||
};
|
||||
}
|
||||
|
||||
function mkdir(dir) {
|
||||
return new Promise((resolve, reject) => {
|
||||
mkdirRecurisve(dir, err => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function rmdir(dir) {
|
||||
return new Promise((resolve, reject) => {
|
||||
rmdirRecursive(dir, err => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async function pack(dir, output) {
|
||||
await mkdir(path.dirname(output));
|
||||
await new Promise((resolve, reject) => {
|
||||
@ -359,8 +332,7 @@ export const commands = {
|
||||
|
||||
console.log('Bundling with React Native version: ', version);
|
||||
|
||||
await rmdir(realIntermedia);
|
||||
await mkdir(realIntermedia);
|
||||
fs.emptyDirSync(realIntermedia);
|
||||
|
||||
if (major === 0) {
|
||||
if (minor >= 56) {
|
||||
|
@ -3,7 +3,7 @@
|
||||
*/
|
||||
|
||||
import * as path from 'path';
|
||||
import * as fs from 'fs';
|
||||
import * as fs from 'fs-extra';
|
||||
import ApkReader from 'node-apk-parser';
|
||||
import ipaReader from './ipaReader';
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "react-native-update",
|
||||
"version": "5.1.7",
|
||||
"version": "5.1.8",
|
||||
"description": "react-native hot update",
|
||||
"main": "lib/index.js",
|
||||
"scripts": {
|
||||
@ -30,15 +30,13 @@
|
||||
"dependencies": {
|
||||
"cli-arguments": "^0.2.1",
|
||||
"decompress-zip": "^0.3.1",
|
||||
"fs-promise": "^0.4.1",
|
||||
"fs-extra": "^8.1.0",
|
||||
"glob": "^7.1.2",
|
||||
"isomorphic-fetch": "^2.2.1",
|
||||
"mkdir-recursive": "^0.2.1",
|
||||
"node-apk-parser": "^0.2.3",
|
||||
"progress": "^1.1.8",
|
||||
"read": "^1.0.7",
|
||||
"request": "^2.69.0",
|
||||
"rimraf": "^2.6.2",
|
||||
"simple-plist": "^0.3.0",
|
||||
"temporary": "^0.0.8",
|
||||
"yauzl": "2.4.1",
|
||||
|
2
react-native-pushy-cli/src/cli.js
vendored
2
react-native-pushy-cli/src/cli.js
vendored
@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
import * as path from 'path';
|
||||
import * as fs from 'fs-promise';
|
||||
import * as fs from 'fs-extra';
|
||||
|
||||
const CLI_MODULE_PATH = function() {
|
||||
return path.resolve(
|
||||
|
42
yarn.lock
42
yarn.lock
@ -44,10 +44,6 @@ ansi-styles@^2.2.1:
|
||||
version "2.2.1"
|
||||
resolved "http://registry.npm.taobao.org/ansi-styles/download/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe"
|
||||
|
||||
any-promise@^1.0.0:
|
||||
version "1.3.0"
|
||||
resolved "http://registry.npm.taobao.org/any-promise/download/any-promise-1.3.0.tgz#abc6afeedcea52e809cdc0376aed3ce39635d17f"
|
||||
|
||||
anymatch@^1.3.0:
|
||||
version "1.3.0"
|
||||
resolved "http://registry.npm.taobao.org/anymatch/download/anymatch-1.3.0.tgz#a3e52fa39168c825ff57b0248126ce5a8ff95507"
|
||||
@ -913,11 +909,14 @@ form-data@~2.1.1:
|
||||
combined-stream "^1.0.5"
|
||||
mime-types "^2.1.12"
|
||||
|
||||
fs-promise@^0.4.1:
|
||||
version "0.4.1"
|
||||
resolved "http://registry.npm.taobao.org/fs-promise/download/fs-promise-0.4.1.tgz#9d57aed89dbcea0fdb6d4cb9c2044aedd9722efd"
|
||||
fs-extra@^8.1.0:
|
||||
version "8.1.0"
|
||||
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-8.1.0.tgz#49d43c45a88cd9677668cb7be1b46efdb8d2e1c0"
|
||||
integrity sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==
|
||||
dependencies:
|
||||
any-promise "^1.0.0"
|
||||
graceful-fs "^4.2.0"
|
||||
jsonfile "^4.0.0"
|
||||
universalify "^0.1.0"
|
||||
|
||||
fs-readdir-recursive@^0.1.0:
|
||||
version "0.1.2"
|
||||
@ -1045,6 +1044,11 @@ graceful-fs@^4.1.2, graceful-fs@^4.1.3, graceful-fs@^4.1.4:
|
||||
version "4.1.11"
|
||||
resolved "http://registry.npm.taobao.org/graceful-fs/download/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658"
|
||||
|
||||
graceful-fs@^4.1.6, graceful-fs@^4.2.0:
|
||||
version "4.2.0"
|
||||
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.0.tgz#8d8fdc73977cb04104721cb53666c1ca64cd328b"
|
||||
integrity sha512-jpSvDPV4Cq/bgtpndIWbI5hmYxhQGHPC4d4cqBPb4DLniCfhJokdXhwhaDuLBGLQdvvRum/UiX6ECVIPvDXqdg==
|
||||
|
||||
"graceful-readlink@>= 1.0.0":
|
||||
version "1.0.1"
|
||||
resolved "http://registry.npm.taobao.org/graceful-readlink/download/graceful-readlink-1.0.1.tgz#4cafad76bc62f02fa039b2f94e9a3dd3a391a725"
|
||||
@ -1286,6 +1290,13 @@ json5@^0.5.0:
|
||||
version "0.5.1"
|
||||
resolved "http://registry.npm.taobao.org/json5/download/json5-0.5.1.tgz#1eade7acc012034ad84e2396767ead9fa5495821"
|
||||
|
||||
jsonfile@^4.0.0:
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb"
|
||||
integrity sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=
|
||||
optionalDependencies:
|
||||
graceful-fs "^4.1.6"
|
||||
|
||||
jsonpointer@^4.0.0:
|
||||
version "4.0.1"
|
||||
resolved "http://registry.npm.taobao.org/jsonpointer/download/jsonpointer-4.0.1.tgz#4fd92cb34e0e9db3c89c8622ecf51f9b978c6cb9"
|
||||
@ -1488,10 +1499,6 @@ minimist@^1.1.0, minimist@^1.2.0:
|
||||
version "1.2.0"
|
||||
resolved "http://registry.npm.taobao.org/minimist/download/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284"
|
||||
|
||||
mkdir-recursive@^0.2.1:
|
||||
version "0.2.3"
|
||||
resolved "http://registry.npm.taobao.org/mkdir-recursive/download/mkdir-recursive-0.2.3.tgz#056327ff2c973b46e7cbc42376ff0648ccc48a4a"
|
||||
|
||||
"mkdirp@>=0.5 0", mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.1:
|
||||
version "0.5.1"
|
||||
resolved "http://registry.npm.taobao.org/mkdirp/download/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903"
|
||||
@ -1890,12 +1897,6 @@ rimraf@2:
|
||||
dependencies:
|
||||
glob "^7.0.5"
|
||||
|
||||
rimraf@^2.6.2:
|
||||
version "2.6.2"
|
||||
resolved "http://registry.npm.taobao.org/rimraf/download/rimraf-2.6.2.tgz#2ed8150d24a16ea8651e6d6ef0f47c4158ce7a36"
|
||||
dependencies:
|
||||
glob "^7.0.5"
|
||||
|
||||
rimraf@~2.5.1, rimraf@~2.5.4:
|
||||
version "2.5.4"
|
||||
resolved "http://registry.npm.taobao.org/rimraf/download/rimraf-2.5.4.tgz#96800093cbf1a0c86bd95b4625467535c29dfa04"
|
||||
@ -2106,6 +2107,11 @@ uid-number@~0.0.6:
|
||||
version "0.0.6"
|
||||
resolved "http://registry.npm.taobao.org/uid-number/download/uid-number-0.0.6.tgz#0ea10e8035e8eb5b8e4449f06da1c730663baa81"
|
||||
|
||||
universalify@^0.1.0:
|
||||
version "0.1.2"
|
||||
resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66"
|
||||
integrity sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==
|
||||
|
||||
user-home@^1.1.1:
|
||||
version "1.1.1"
|
||||
resolved "http://registry.npm.taobao.org/user-home/download/user-home-1.1.1.tgz#2b5be23a32b63a7c9deb8d0f28d485724a3df190"
|
||||
|
Loading…
x
Reference in New Issue
Block a user