mirror of
https://gitcode.com/gh_mirrors/re/react-native-pushy.git
synced 2025-12-19 12:15:08 +08:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aee9345e3d | ||
|
|
6c07aa7518 | ||
|
|
536b5487a2 | ||
|
|
cc1e5776b5 | ||
|
|
8ac7b83e5b | ||
|
|
6ab80be42f |
16
.github/workflows/publish.yml
vendored
16
.github/workflows/publish.yml
vendored
@@ -2,6 +2,11 @@ name: Publish Package to npmjs
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
|
||||
permissions:
|
||||
id-token: write # Required for OIDC
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
@@ -9,14 +14,15 @@ jobs:
|
||||
contents: read
|
||||
id-token: write
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
- uses: oven-sh/setup-bun@v2
|
||||
# Setup .npmrc file to publish to npm
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: '20.x'
|
||||
node-version: 24
|
||||
registry-url: 'https://registry.npmjs.org'
|
||||
- run: bun install --frozen-lockfile
|
||||
# Ensure npm 11.5.1 or later is installed
|
||||
- name: Update npm
|
||||
run: npm install -g npm@latest
|
||||
- run: npm publish --provenance --access public
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
|
||||
@@ -46,20 +46,9 @@ public class UpdateContext {
|
||||
|
||||
|
||||
SharedPreferences.Editor editor = this.sp.edit();
|
||||
if (storedPackageVersion == null) {
|
||||
editor.putString("packageVersion", packageVersion);
|
||||
editor.apply();
|
||||
storedPackageVersion = packageVersion;
|
||||
}
|
||||
|
||||
if (storedBuildTime == null) {
|
||||
editor.putString("buildTime", buildTime);
|
||||
editor.apply();
|
||||
storedBuildTime = buildTime;
|
||||
}
|
||||
|
||||
boolean packageVersionChanged = !packageVersion.equals(storedPackageVersion);
|
||||
boolean buildTimeChanged = !buildTime.equals(storedBuildTime);
|
||||
boolean packageVersionChanged = storedPackageVersion == null || !packageVersion.equals(storedPackageVersion);
|
||||
boolean buildTimeChanged = storedBuildTime == null || !buildTime.equals(storedBuildTime);
|
||||
|
||||
if (packageVersionChanged || buildTimeChanged) {
|
||||
// Execute cleanUp before clearing SharedPreferences to avoid race condition
|
||||
|
||||
@@ -77,41 +77,16 @@ RCT_EXPORT_MODULE(RCTPushy);
|
||||
NSString *storedPackageVersion = [defaults stringForKey:paramPackageVersion];
|
||||
NSString *storedBuildTime = [defaults stringForKey:paramBuildTime];
|
||||
|
||||
RCTLogInfo(@"RCTPushy -- Version check: curPackageVersion=%@, curBuildTime=%@, storedPackageVersion=%@, storedBuildTime=%@",
|
||||
curPackageVersion ?: @"nil",
|
||||
curBuildTime ?: @"nil",
|
||||
storedPackageVersion ?: @"nil",
|
||||
storedBuildTime ?: @"nil");
|
||||
|
||||
// If stored versions don't exist, write current versions first
|
||||
if (!storedPackageVersion) {
|
||||
RCTLogInfo(@"RCTPushy -- No stored package version found, writing current version: %@", curPackageVersion);
|
||||
[defaults setObject:curPackageVersion forKey:paramPackageVersion];
|
||||
storedPackageVersion = curPackageVersion;
|
||||
}
|
||||
|
||||
if (!storedBuildTime) {
|
||||
RCTLogInfo(@"RCTPushy -- No stored build time found, writing current build time: %@", curBuildTime);
|
||||
[defaults setObject:curBuildTime forKey:paramBuildTime];
|
||||
storedBuildTime = curBuildTime;
|
||||
}
|
||||
|
||||
BOOL packageVersionChanged = ![curPackageVersion isEqualToString:storedPackageVersion];
|
||||
BOOL buildTimeChanged = curBuildTime && ![curBuildTime isEqualToString:storedBuildTime];
|
||||
|
||||
RCTLogInfo(@"RCTPushy -- Version change check: packageVersionChanged=%d, buildTimeChanged=%d",
|
||||
packageVersionChanged, buildTimeChanged);
|
||||
BOOL packageVersionChanged = !storedPackageVersion || ![curPackageVersion isEqualToString:storedPackageVersion];
|
||||
BOOL buildTimeChanged = !storedBuildTime || ![curBuildTime isEqualToString:storedBuildTime];
|
||||
|
||||
if (packageVersionChanged || buildTimeChanged) {
|
||||
RCTLogInfo(@"RCTPushy -- Version or build time changed, clearing update data. packageVersionChanged=%d, buildTimeChanged=%d",
|
||||
packageVersionChanged, buildTimeChanged);
|
||||
// Clear all update data and store new versions
|
||||
[defaults setObject:nil forKey:keyPushyInfo];
|
||||
[defaults setObject:nil forKey:keyHashInfo];
|
||||
[defaults setObject:@(YES) forKey:KeyPackageUpdatedMarked];
|
||||
[defaults setObject:curPackageVersion forKey:paramPackageVersion];
|
||||
[defaults setObject:curBuildTime forKey:paramBuildTime];
|
||||
|
||||
}
|
||||
|
||||
NSDictionary *pushyInfo = [defaults dictionaryForKey:keyPushyInfo];
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "react-native-update",
|
||||
"version": "10.36.4",
|
||||
"version": "10.37.0",
|
||||
"description": "react-native hot update",
|
||||
"main": "src/index",
|
||||
"scripts": {
|
||||
|
||||
@@ -65,6 +65,7 @@ const defaultClientOptions: ClientOptions = {
|
||||
export const sharedState: {
|
||||
progressHandlers: Record<string, EmitterSubscription>;
|
||||
downloadedHash?: string;
|
||||
toHash?: string;
|
||||
apkStatus: 'downloading' | 'downloaded' | null;
|
||||
marked: boolean;
|
||||
applyingUpdate: boolean;
|
||||
@@ -509,11 +510,15 @@ export class Pushy {
|
||||
});
|
||||
}
|
||||
log(`downloaded ${succeeded} hash:`, hash);
|
||||
setLocalHashInfo(hash, {
|
||||
const hashInfo: Record<string, any> = {
|
||||
name,
|
||||
description,
|
||||
metaInfo,
|
||||
});
|
||||
};
|
||||
if (sharedState.toHash === hash) {
|
||||
hashInfo.debugChannel = true;
|
||||
}
|
||||
setLocalHashInfo(hash, hashInfo);
|
||||
sharedState.downloadedHash = hash;
|
||||
return hash;
|
||||
};
|
||||
|
||||
16
src/core.ts
16
src/core.ts
@@ -31,11 +31,21 @@ export const downloadRootDir: string = PushyConstants.downloadRootDir;
|
||||
export const packageVersion: string = PushyConstants.packageVersion;
|
||||
export const currentVersion: string = PushyConstants.currentVersion;
|
||||
|
||||
export function setLocalHashInfo(hash: string, info: Record<string, any>) {
|
||||
PushyModule.setLocalHashInfo(hash, JSON.stringify(info));
|
||||
}
|
||||
|
||||
const currentVersionInfoString: string = PushyConstants.currentVersionInfo;
|
||||
let _currentVersionInfo = {};
|
||||
let _currentVersionInfo: Record<string, any> = {};
|
||||
let isDebugChannel = false;
|
||||
if (currentVersionInfoString) {
|
||||
try {
|
||||
_currentVersionInfo = JSON.parse(currentVersionInfoString);
|
||||
if (_currentVersionInfo.debugChannel) {
|
||||
isDebugChannel = true;
|
||||
delete _currentVersionInfo.debugChannel;
|
||||
setLocalHashInfo(currentVersion, _currentVersionInfo);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(
|
||||
'Failed to parse currentVersionInfo:',
|
||||
@@ -46,15 +56,13 @@ if (currentVersionInfoString) {
|
||||
export const currentVersionInfo = _currentVersionInfo;
|
||||
|
||||
export const isFirstTime: boolean = PushyConstants.isFirstTime;
|
||||
export const isFirstTimeDebug: boolean = isFirstTime && isDebugChannel;
|
||||
export const rolledBackVersion: string = PushyConstants.rolledBackVersion;
|
||||
export const isRolledBack: boolean = !!rolledBackVersion;
|
||||
|
||||
export const buildTime: string = PushyConstants.buildTime;
|
||||
let uuid = PushyConstants.uuid;
|
||||
|
||||
export function setLocalHashInfo(hash: string, info: Record<string, any>) {
|
||||
PushyModule.setLocalHashInfo(hash, JSON.stringify(info));
|
||||
}
|
||||
|
||||
async function getLocalHashInfo(hash: string) {
|
||||
return JSON.parse(await PushyModule.getLocalHashInfo(hash));
|
||||
|
||||
@@ -327,7 +327,9 @@ export const UpdateProvider = ({
|
||||
Alert.alert(type, JSON.stringify(data));
|
||||
};
|
||||
if (payload.type === '__rnPushyVersionHash') {
|
||||
checkUpdate({ extra: { toHash: payload.data } }).then(() => {
|
||||
const toHash = payload.data;
|
||||
sharedState.toHash = toHash;
|
||||
checkUpdate({ extra: { toHash } }).then(() => {
|
||||
if (updateInfoRef.current && updateInfoRef.current.upToDate) {
|
||||
Alert.alert(
|
||||
client.t('alert_info'),
|
||||
|
||||
Reference in New Issue
Block a user