1
0
mirror of https://gitcode.com/github-mirrors/react-native-update-cli.git synced 2025-09-16 09:41:38 +08:00
Code Issues Packages Projects Releases Wiki Activity GitHub Gitee

Remove fs-extra

This commit is contained in:
sunnylqm
2020-05-29 10:24:09 +08:00
parent b76a2eb989
commit 37353222ef
6 changed files with 50 additions and 70 deletions

View File

@@ -35,7 +35,6 @@
"app-info-parser": "^0.3.9",
"cli-arguments": "^0.2.1",
"filesize-parser": "^1.5.0",
"fs-extra": "^9.0.0",
"gradle-to-js": "^2.0.0",
"node-fetch": "^2.6.0",
"progress": "^2.0.3",
@@ -49,7 +48,6 @@
},
"devDependencies": {
"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",

View File

@@ -4,7 +4,7 @@
const fetch = require('node-fetch');
let host = process.env.PUSHY_REGISTRY || 'https://update.react-native.cn/api';
const fs = require('fs-extra');
const fs = require('fs');
import request from 'request';
import ProgressBar from 'progress';
const packageJson = require('../package.json');

View File

@@ -3,7 +3,7 @@
*/
import {question} from './utils';
import * as fs from 'fs-extra';
import fs from 'fs';
const {
post,

View File

@@ -4,7 +4,7 @@
const path = require('path');
import { getRNVersion, translateOptions } from './utils';
import * as fs from 'fs-extra';
import fs from 'fs';
import { ZipFile } from 'yazl';
import { open as openZipFile } from 'yauzl';
import { question, printVersionCommand } from './utils';
@@ -47,6 +47,11 @@ async function runReactNativeBundleCommand(
sourcemapOutput,
config,
) {
// empty output folder
fs.unlink(outputFolder, () => {
fs.mkdir(outputFolder, () => {});
});
let reactNativeBundleArgs = [];
let envArgs = process.env.PUSHY_ENV_ARGS;
@@ -58,8 +63,6 @@ async function runReactNativeBundleCommand(
);
}
fs.emptyDirSync(outputFolder);
Array.prototype.push.apply(reactNativeBundleArgs, [
path.join('node_modules', 'react-native', 'local-cli', 'cli.js'),
'bundle',
@@ -90,15 +93,15 @@ async function runReactNativeBundleCommand(
);
return new Promise((resolve, reject) => {
reactNativeBundleProcess.stdout.on('data', data => {
reactNativeBundleProcess.stdout.on('data', (data) => {
console.log(data.toString().trim());
});
reactNativeBundleProcess.stderr.on('data', data => {
reactNativeBundleProcess.stderr.on('data', (data) => {
console.error(data.toString().trim());
});
reactNativeBundleProcess.on('close', async exitCode => {
reactNativeBundleProcess.on('close', async (exitCode) => {
if (exitCode) {
reject(
new Error(
@@ -183,7 +186,7 @@ async function pack(dir, output) {
addDirectory(dir, '');
zipfile.outputStream.on('error', err => reject(err));
zipfile.outputStream.on('error', (err) => reject(err));
zipfile.outputStream
.pipe(fs.createWriteStream(output))
.on('close', function () {
@@ -235,7 +238,7 @@ async function diffFromPPK(origin, next, output) {
if (entry.fileName === 'index.bundlejs') {
// This is source.
return readEntire(entry, zipFile).then(v => (originSource = v));
return readEntire(entry, zipFile).then((v) => (originSource = v));
}
}
});
@@ -251,7 +254,7 @@ async function diffFromPPK(origin, next, output) {
var zipfile = new ZipFile();
const writePromise = new Promise((resolve, reject) => {
zipfile.outputStream.on('error', err => {
zipfile.outputStream.on('error', (err) => {
throw err;
});
zipfile.outputStream
@@ -287,7 +290,7 @@ async function diffFromPPK(origin, next, output) {
}
} else if (entry.fileName === 'index.bundlejs') {
//console.log('Found bundle');
return readEntire(entry, nextZipfile).then(newSource => {
return readEntire(entry, nextZipfile).then((newSource) => {
//console.log('Begin diff');
zipfile.addBuffer(
diff(originSource, newSource),
@@ -354,7 +357,7 @@ async function diffFromPackage(
next,
output,
originBundleName,
transformPackagePath = v => v,
transformPackagePath = (v) => v,
) {
fs.ensureDirSync(path.dirname(output));
@@ -377,7 +380,7 @@ async function diffFromPackage(
if (fn === originBundleName) {
// This is source.
return readEntire(entry, zipFile).then(v => (originSource = v));
return readEntire(entry, zipFile).then((v) => (originSource = v));
}
}
});
@@ -393,7 +396,7 @@ async function diffFromPackage(
var zipfile = new ZipFile();
const writePromise = new Promise((resolve, reject) => {
zipfile.outputStream.on('error', err => {
zipfile.outputStream.on('error', (err) => {
throw err;
});
zipfile.outputStream
@@ -409,7 +412,7 @@ async function diffFromPackage(
zipfile.addEmptyDirectory(entry.fileName);
} else if (entry.fileName === 'index.bundlejs') {
//console.log('Found bundle');
return readEntire(entry, nextZipfile).then(newSource => {
return readEntire(entry, nextZipfile).then((newSource) => {
//console.log('Begin diff');
zipfile.addBuffer(
diff(originSource, newSource),
@@ -457,7 +460,7 @@ function enumZipEntries(zipFn, callback) {
}
zipfile.on('end', resolve);
zipfile.on('error', reject);
zipfile.on('entry', entry => {
zipfile.on('entry', (entry) => {
const result = callback(entry, zipfile);
if (result && typeof result.then === 'function') {
result.then(() => zipfile.readEntry());
@@ -568,7 +571,7 @@ export const commands = {
process.exit(1);
}
await diffFromPackage(origin, next, realOutput, 'main.jsbundle', v => {
await diffFromPackage(origin, next, realOutput, 'main.jsbundle', (v) => {
const m = /^Payload\/[^/]+\/(.+)$/.exec(v);
return m && m[1];
});

View File

@@ -2,7 +2,7 @@
* Created by tdzl2003 on 2/13/16.
*/
import * as fs from 'fs-extra';
import fs from 'fs';
import os from 'os';
import path from 'path';
const pkg = require('../../package.json');
@@ -61,7 +61,9 @@ export async function getApkInfo(fn) {
/assets\/index.android.bundle/,
);
if (!bundleFile) {
throw new Error('找不到bundle文件。请确保此apk为release版本且bundle文件名为默认的index.android.bundle');
throw new Error(
'找不到bundle文件。请确保此apk为release版本且bundle文件名为默认的index.android.bundle',
);
}
const { versionName, application } = await appInfoParser.parse();
let buildTime = 0;
@@ -73,7 +75,9 @@ export async function getApkInfo(fn) {
}
}
if (buildTime == 0) {
throw new Error('无法获取此包的编译时间戳。请更新react-native-update到最新版本后重新打包上传。');
throw new Error(
'无法获取此包的编译时间戳。请更新react-native-update到最新版本后重新打包上传。',
);
}
return { versionName, buildTime };
}
@@ -84,7 +88,9 @@ export async function getIpaInfo(fn) {
/payload\/.+?\.app\/main.jsbundle/,
);
if (!bundleFile) {
throw new Error('找不到bundle文件。请确保此ipa为release版本且bundle文件名为默认的main.jsbundle');
throw new Error(
'找不到bundle文件。请确保此ipa为release版本且bundle文件名为默认的main.jsbundle',
);
}
const {
CFBundleShortVersionString: versionName,
@@ -99,14 +105,16 @@ export async function getIpaInfo(fn) {
);
}
if (!buildTimeTxtBuffer) {
throw new Error('无法获取此包的编译时间戳。请更新react-native-update到最新版本后重新打包上传。');
throw new Error(
'无法获取此包的编译时间戳。请更新react-native-update到最新版本后重新打包上传。',
);
}
const buildTime = buildTimeTxtBuffer.toString().replace('\n', '');
return { versionName, buildTime };
}
const localDir = path.resolve(os.homedir(), '.pushy');
fs.ensureDirSync(localDir);
fs.mkdir(localDir, () => {});
export function saveToLocal(originPath, destName) {
// TODO
// const destPath = path.join(localDir, destName);
@@ -121,12 +129,12 @@ export function printVersionCommand() {
process.cwd(),
'node_modules',
'react-native-update',
'package.json'
'package.json',
);
console.log('react-native-update: ' + require(PACKAGE_JSON_PATH).version);
} catch (e) {
console.log('react-native-update: 无法获取版本号,请在项目目录中运行命令')
console.log('react-native-update: 无法获取版本号,请在项目目录中运行命令');
}
}
export const pricingPageUrl = 'https://pushy.reactnative.cn/pricing'
export const pricingPageUrl = 'https://pushy.reactnative.cn/pricing';

View File

@@ -244,11 +244,6 @@ asynckit@^0.4.0:
resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79"
integrity sha1-x57Zf380y48robyXkLzDZkdLS3k=
at-least-node@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/at-least-node/-/at-least-node-1.0.0.tgz#602cd4b46e844ad4effc92a8011a3c46e0238dc2"
integrity sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==
atob@^2.1.2:
version "2.1.2"
resolved "https://registry.yarnpkg.com/atob/-/atob-2.1.2.tgz#6d9517eb9e030d2436666651e86bd9f6f13533c9"
@@ -1217,16 +1212,6 @@ fragment-cache@^0.2.1:
dependencies:
map-cache "^0.2.2"
fs-extra@^9.0.0:
version "9.0.0"
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-9.0.0.tgz#b6afc31036e247b2466dc99c29ae797d5d4580a3"
integrity sha512-pmEYSk3vYsG/bF651KPUXZ+hvjpgWYw/Gc7W9NFUe3ZVLczKKWIij3IKpOrQcdw4TILtibFslZ0UmR8Vvzig4g==
dependencies:
at-least-node "^1.0.0"
graceful-fs "^4.2.0"
jsonfile "^6.0.1"
universalify "^1.0.0"
fs-readdir-recursive@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/fs-readdir-recursive/-/fs-readdir-recursive-1.1.0.tgz#e32fc030a2ccee44a6b5371308da54be0b397d27"
@@ -1342,7 +1327,7 @@ got@^9.6.0:
to-readable-stream "^1.0.0"
url-parse-lax "^3.0.0"
graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.4, graceful-fs@^4.1.6, graceful-fs@^4.2.0:
graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.4:
version "4.2.3"
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.3.tgz#4a12ff1b60376ef09862c2093edd908328be8423"
integrity sha512-a30VEBm4PEdx1dRB7MFK7BejejvCvBronbLjht+sHuGYj8PHs7M/5Z+rt5lw551vZ7yfTCj4Vuyy3mSJytDWRQ==
@@ -1793,15 +1778,6 @@ json5@^0.5.1:
resolved "https://registry.yarnpkg.com/json5/-/json5-0.5.1.tgz#1eade7acc012034ad84e2396767ead9fa5495821"
integrity sha1-Hq3nrMASA0rYTiOWdn6tn6VJWCE=
jsonfile@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-6.0.1.tgz#98966cba214378c8c84b82e085907b40bf614179"
integrity sha512-jR2b5v7d2vIOust+w3wtFKZIfpC2pnRmFAhAC/BuweZFQR8qZzxH1OyrQ10HmdVYiXWkYUqPVsz91cG7EL2FBg==
dependencies:
universalify "^1.0.0"
optionalDependencies:
graceful-fs "^4.1.6"
jsprim@^1.2.2:
version "1.4.1"
resolved "https://registry.yarnpkg.com/jsprim/-/jsprim-1.4.1.tgz#313e66bc1e5cc06e438bc1b7499c2e5c56acb6a2"
@@ -2867,11 +2843,6 @@ unique-string@^2.0.0:
dependencies:
crypto-random-string "^2.0.0"
universalify@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/universalify/-/universalify-1.0.0.tgz#b61a1da173e8435b2fe3c67d29b9adf8594bd16d"
integrity sha512-rb6X1W158d7pRQBg5gkR8uPaSfiids68LTJQYOtEUhoJUWBdaQHsuT/EUduxXYxcrt4r5PJ4fuHW1MHT6p0qug==
unset-value@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/unset-value/-/unset-value-1.0.0.tgz#8376873f7d2335179ffb1e6fc3a8ed0dfc8ab559"