mirror of
https://gitcode.com/gh_mirrors/re/react-native-pushy.git
synced 2025-11-02 06:13:11 +08:00
bugfixes
This commit is contained in:
@@ -124,6 +124,14 @@ public class UpdateContext {
|
|||||||
this.clearUp();
|
this.clearUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void clearRollbackMark() {
|
||||||
|
SharedPreferences.Editor editor = sp.edit();
|
||||||
|
editor.putBoolean("rolledBack", false);
|
||||||
|
editor.apply();
|
||||||
|
|
||||||
|
this.clearUp();
|
||||||
|
}
|
||||||
|
|
||||||
public static String getBundleUrl(Context context) {
|
public static String getBundleUrl(Context context) {
|
||||||
return new UpdateContext(context.getApplicationContext()).getBundleUrl();
|
return new UpdateContext(context.getApplicationContext()).getBundleUrl();
|
||||||
}
|
}
|
||||||
@@ -133,7 +141,7 @@ public class UpdateContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getBundleUrl() {
|
public String getBundleUrl() {
|
||||||
return this.getBundleUrl((String)null);
|
return this.getBundleUrl((String) null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getBundleUrl(String defaultAssetsUrl) {
|
public String getBundleUrl(String defaultAssetsUrl) {
|
||||||
@@ -150,7 +158,7 @@ public class UpdateContext {
|
|||||||
editor.putBoolean("shouldRollback", true);
|
editor.putBoolean("shouldRollback", true);
|
||||||
editor.apply();
|
editor.apply();
|
||||||
}
|
}
|
||||||
return new File(rootDir, currentVersion+"/index.bundlejs").toURI().toString();
|
return (new File(rootDir, currentVersion+"/index.bundlejs").toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void rollBack() {
|
private void rollBack() {
|
||||||
|
|||||||
@@ -34,8 +34,12 @@ public class UpdateModule extends ReactContextBaseJavaModule{
|
|||||||
constants.put("downloadRootDir", updateContext.getRootDir());
|
constants.put("downloadRootDir", updateContext.getRootDir());
|
||||||
constants.put("packageVersion", updateContext.getPackageVersion());
|
constants.put("packageVersion", updateContext.getPackageVersion());
|
||||||
constants.put("currentVersion", updateContext.getCurrentVersion());
|
constants.put("currentVersion", updateContext.getCurrentVersion());
|
||||||
constants.put("firstTime", updateContext.isFirstTime());
|
constants.put("isFirstTime", updateContext.isFirstTime());
|
||||||
constants.put("rolledBack", updateContext.isRolledBack());
|
boolean isRolledBack = updateContext.isRolledBack();
|
||||||
|
constants.put("isRolledBack", isRolledBack);
|
||||||
|
if (isRolledBack) {
|
||||||
|
updateContext.clearRollbackMark();
|
||||||
|
}
|
||||||
return constants;
|
return constants;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,10 @@ There is available update:
|
|||||||
export async function checkUpdate(APPKEY) {
|
export async function checkUpdate(APPKEY) {
|
||||||
const resp = await fetch(`${host}/checkUpdate/${APPKEY}`, {
|
const resp = await fetch(`${host}/checkUpdate/${APPKEY}`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Accept': 'application/json',
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
packageVersion: packageVersion,
|
packageVersion: packageVersion,
|
||||||
hash: currentVersion,
|
hash: currentVersion,
|
||||||
@@ -75,11 +79,11 @@ export async function downloadUpdate(options) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function switchVersion({hash}) {
|
export async function switchVersion(hash) {
|
||||||
HotUpdate.reloadUpdate({hashName:hash});
|
HotUpdate.reloadUpdate({hashName:hash});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function switchVersionLater({hash}) {
|
export async function switchVersionLater(hash) {
|
||||||
HotUpdate.setNeedUpdate({hashName:hash});
|
HotUpdate.setNeedUpdate({hashName:hash});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import * as fs from 'fs';
|
|||||||
import {ZipFile} from 'yazl';
|
import {ZipFile} from 'yazl';
|
||||||
import {open as openZipFile} from 'yauzl';
|
import {open as openZipFile} from 'yauzl';
|
||||||
import {diff} from 'node-bsdiff';
|
import {diff} from 'node-bsdiff';
|
||||||
|
import { question } from './utils';
|
||||||
|
|
||||||
import crypto from 'crypto';
|
import crypto from 'crypto';
|
||||||
|
|
||||||
@@ -28,8 +29,7 @@ function mkdir(dir){
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function pack(dir, output){
|
async function pack(dir, output){
|
||||||
const realOutput = output.replace(/\$\{time\}/g, '' + Date.now());
|
await mkdir(path.dirname(output));
|
||||||
await mkdir(path.dirname(realOutput));
|
|
||||||
await new Promise((resolve, reject) => {
|
await new Promise((resolve, reject) => {
|
||||||
var zipfile = new ZipFile();
|
var zipfile = new ZipFile();
|
||||||
|
|
||||||
@@ -57,13 +57,13 @@ async function pack(dir, output){
|
|||||||
addDirectory(dir, '');
|
addDirectory(dir, '');
|
||||||
|
|
||||||
zipfile.outputStream.on('error', err => reject(err));
|
zipfile.outputStream.on('error', err => reject(err));
|
||||||
zipfile.outputStream.pipe(fs.createWriteStream(realOutput))
|
zipfile.outputStream.pipe(fs.createWriteStream(output))
|
||||||
.on("close", function() {
|
.on("close", function() {
|
||||||
resolve();
|
resolve();
|
||||||
});
|
});
|
||||||
zipfile.end();
|
zipfile.end();
|
||||||
});
|
});
|
||||||
console.log('Bundled saved to: ' + realOutput);
|
console.log('Bundled saved to: ' + output);
|
||||||
}
|
}
|
||||||
|
|
||||||
function readEntire(entry, zipFile) {
|
function readEntire(entry, zipFile) {
|
||||||
@@ -94,6 +94,8 @@ function basename(fn) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function diffWithPPK(origin, next, output) {
|
async function diffWithPPK(origin, next, output) {
|
||||||
|
await mkdir(path.dirname(output));
|
||||||
|
|
||||||
const originEntries = {};
|
const originEntries = {};
|
||||||
const originMap = {};
|
const originMap = {};
|
||||||
|
|
||||||
@@ -208,6 +210,8 @@ async function diffWithPPK(origin, next, output) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function diffWithPackage(origin, next, output, originBundleName, transformPackagePath = v=>v) {
|
async function diffWithPackage(origin, next, output, originBundleName, transformPackagePath = v=>v) {
|
||||||
|
await mkdir(path.dirname(output));
|
||||||
|
|
||||||
const originEntries = {};
|
const originEntries = {};
|
||||||
const originMap = {};
|
const originMap = {};
|
||||||
|
|
||||||
@@ -320,6 +324,7 @@ export const commands = {
|
|||||||
dev,
|
dev,
|
||||||
verbose
|
verbose
|
||||||
} = translateOptions(options);
|
} = translateOptions(options);
|
||||||
|
const realOutput = output.replace(/\$\{time\}/g, '' + Date.now());
|
||||||
|
|
||||||
if (!platform) {
|
if (!platform) {
|
||||||
throw new Error('Platform must be specified.');
|
throw new Error('Platform must be specified.');
|
||||||
@@ -359,7 +364,14 @@ export const commands = {
|
|||||||
|
|
||||||
console.log('Packing');
|
console.log('Packing');
|
||||||
|
|
||||||
await pack(intermediaDir, output);
|
await pack(intermediaDir, realOutput);
|
||||||
|
|
||||||
|
const v = await question('Would you like to publish it?(Y/N)');
|
||||||
|
if (v.toLowerCase() === 'y') {
|
||||||
|
await this.publish({args: [realOutput], options: {
|
||||||
|
platform,
|
||||||
|
}})
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
async diff({args, options}) {
|
async diff({args, options}) {
|
||||||
@@ -374,6 +386,7 @@ export const commands = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
await diffWithPPK(origin, next, realOutput, 'index.bundlejs');
|
await diffWithPPK(origin, next, realOutput, 'index.bundlejs');
|
||||||
|
console.log(`${realOutput} generated.`);
|
||||||
},
|
},
|
||||||
|
|
||||||
async diffFromApk({args, options}) {
|
async diffFromApk({args, options}) {
|
||||||
|
|||||||
@@ -57,7 +57,6 @@ async function chooseVersion(appId) {
|
|||||||
case 'B': offset = 0; break;
|
case 'B': offset = 0; break;
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
console.log(data.find(v=>v.id === (cmd | 0)));
|
|
||||||
const v = data.find(v=>v.id === (cmd | 0));
|
const v = data.find(v=>v.id === (cmd | 0));
|
||||||
if (v) {
|
if (v) {
|
||||||
return v;
|
return v;
|
||||||
@@ -79,16 +78,16 @@ export const commands = {
|
|||||||
const { hash } = await uploadFile(fn);
|
const { hash } = await uploadFile(fn);
|
||||||
|
|
||||||
const { id } = await post(`/app/${appId}/version/create`, {
|
const { id } = await post(`/app/${appId}/version/create`, {
|
||||||
name,
|
name: name || await question('Enter version name:') || '(未命名)',
|
||||||
hash,
|
hash,
|
||||||
description,
|
description: description || await question('Enter description:'),
|
||||||
metaInfo,
|
metaInfo: metaInfo || await question('Enter meta info:'),
|
||||||
});
|
});
|
||||||
console.log('Ok.');
|
console.log('Ok.');
|
||||||
|
|
||||||
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)');
|
||||||
if (v.toLowerCase() === 'y') {
|
if (v.toLowerCase() === 'y') {
|
||||||
await this.update({args:[], options:{packageId: id, }});
|
await this.update({args:[], options:{packageId: id, platform}});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
versions: async function({options}) {
|
versions: async function({options}) {
|
||||||
|
|||||||
Reference in New Issue
Block a user