@gfean/react-native-bundle-drop 0.1.48 → 0.1.85
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLIENT_README.md +254 -84
- package/README.md +145 -14
- package/android/src/main/java/com/bundledrop/BundleDropModule.kt +94 -21
- package/ios/BundleDropBridge.m +29 -1
- package/ios/BundleDropLocator.swift +0 -6
- package/ios/BundleDropModule.swift +132 -4
- package/lib/CLI/cli.js +48 -39
- package/lib/CLI/scripts/init-config.d.ts +1 -0
- package/lib/CLI/scripts/init-config.js +42 -2
- package/lib/CLI/scripts/init-native-config.js +428 -45
- package/lib/CLI/scripts/login-cli.js +6 -2
- package/lib/CLI/scripts/post-init.d.ts +1 -0
- package/lib/CLI/scripts/post-init.js +42 -0
- package/lib/CLI/scripts/upload-cli.d.ts +2 -0
- package/lib/CLI/scripts/upload-cli.js +11 -5
- package/lib/api/client.d.ts +1 -1
- package/lib/api/client.js +2 -2
- package/lib/api/clientApi.d.ts +3 -6
- package/lib/api/clientApi.js +7 -18
- package/lib/api/types.d.ts +33 -18
- package/lib/bundleInfo.js +5 -5
- package/lib/context.js +3 -3
- package/lib/errors.d.ts +2 -2
- package/lib/fs/bundlePointer.d.ts +14 -0
- package/lib/fs/bundlePointer.js +77 -0
- package/lib/fs/fsUtils.js +13 -13
- package/lib/fs/installId.d.ts +1 -0
- package/lib/fs/installId.js +29 -0
- package/lib/fs/userProperties.d.ts +6 -0
- package/lib/fs/userProperties.js +100 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +8 -3
- package/lib/injectImageResolver.js +2 -2
- package/lib/install/installFromZip.js +9 -20
- package/lib/loadConfig.d.ts +5 -0
- package/lib/manager/downloadAndInstall.d.ts +10 -0
- package/lib/manager/downloadAndInstall.js +50 -42
- package/lib/manager/initUpdateManager.js +46 -10
- package/lib/manager/reporting.js +5 -3
- package/lib/manager/rollbackState.d.ts +30 -0
- package/lib/manager/rollbackState.js +186 -0
- package/lib/manager/updateCheck.js +57 -18
- package/lib/native/fs.d.ts +17 -0
- package/lib/native/fs.js +33 -0
- package/lib/scripts/download-bundle.js +19 -8
- package/lib/useBundleDrop.js +14 -2
- package/package.json +3 -4
- package/lib/api/utils.d.ts +0 -1
- package/lib/api/utils.js +0 -8
- package/lib/fs/iosPointer.d.ts +0 -1
- package/lib/fs/iosPointer.js +0 -20
package/lib/useBundleDrop.js
CHANGED
|
@@ -5,6 +5,7 @@ const react_1 = require("react");
|
|
|
5
5
|
const updateCheck_1 = require("./manager/updateCheck");
|
|
6
6
|
const downloadAndInstall_1 = require("./manager/downloadAndInstall");
|
|
7
7
|
const updateState_1 = require("./manager/updateState");
|
|
8
|
+
const rollbackState_1 = require("./manager/rollbackState");
|
|
8
9
|
function useBundleDrop(options) {
|
|
9
10
|
const channelName = options?.channelName || 'General';
|
|
10
11
|
const [status, setStatus] = (0, react_1.useState)('Click the button to check for updates');
|
|
@@ -38,8 +39,8 @@ function useBundleDrop(options) {
|
|
|
38
39
|
setStatus(nextStatus);
|
|
39
40
|
return { response: null, status: nextStatus };
|
|
40
41
|
}
|
|
41
|
-
if (res.
|
|
42
|
-
const nextStatus =
|
|
42
|
+
if (res.action === 'ROLLBACK') {
|
|
43
|
+
const nextStatus = res.reason ? `↩️ Rollback requested: ${res.reason}` : '↩️ Rollback requested';
|
|
43
44
|
setStatus(nextStatus);
|
|
44
45
|
return { response: res, status: nextStatus };
|
|
45
46
|
}
|
|
@@ -48,6 +49,11 @@ function useBundleDrop(options) {
|
|
|
48
49
|
setStatus(nextStatus);
|
|
49
50
|
return { response: res, status: nextStatus };
|
|
50
51
|
}
|
|
52
|
+
if (res.action === 'NOOP') {
|
|
53
|
+
const nextStatus = '✅ You have the latest version';
|
|
54
|
+
setStatus(nextStatus);
|
|
55
|
+
return { response: res, status: nextStatus };
|
|
56
|
+
}
|
|
51
57
|
const nextLabel = res.bundleVersion
|
|
52
58
|
? `⬇️ Update available${res.bundleVersion ? ` (v${res.bundleVersion})` : ''}`
|
|
53
59
|
: '⬇️ Update available';
|
|
@@ -63,6 +69,11 @@ function useBundleDrop(options) {
|
|
|
63
69
|
setStatus(nextStatus);
|
|
64
70
|
return { result, status: nextStatus };
|
|
65
71
|
}
|
|
72
|
+
if (result.status === 'rollback') {
|
|
73
|
+
const nextStatus = result.reason ? `↩️ Rollback requested: ${result.reason}` : '↩️ Rollback requested';
|
|
74
|
+
setStatus(nextStatus);
|
|
75
|
+
return { result, status: nextStatus };
|
|
76
|
+
}
|
|
66
77
|
if (result.status === 'incompatible') {
|
|
67
78
|
const nextStatus = '⛔️ No compatible update for this binary';
|
|
68
79
|
setStatus(nextStatus);
|
|
@@ -109,6 +120,7 @@ function useBundleDrop(options) {
|
|
|
109
120
|
}, [setAvailableChannels, setStatus]);
|
|
110
121
|
(0, react_1.useEffect)(() => {
|
|
111
122
|
refresh();
|
|
123
|
+
(0, rollbackState_1.commitActiveBundle)();
|
|
112
124
|
}, [refresh]);
|
|
113
125
|
return {
|
|
114
126
|
status,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gfean/react-native-bundle-drop",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.85",
|
|
4
4
|
"description": "react native ota by gFean",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
"clean": "rimraf lib dist",
|
|
23
23
|
"build": "tsc -p tsconfig.json && node scripts/make-cli-executable.js",
|
|
24
24
|
"prepublishOnly": "yarn clean && yarn build",
|
|
25
|
-
"build-and-publish": "yarn clean && yarn build && npm publish --access=restricted"
|
|
25
|
+
"build-and-publish": "yarn clean && yarn build && npm publish --access=restricted",
|
|
26
|
+
"publish:local": "yalc publish --private"
|
|
26
27
|
},
|
|
27
28
|
"create-react-native-library": {
|
|
28
29
|
"type": "legacy-module",
|
|
@@ -67,8 +68,6 @@
|
|
|
67
68
|
"fs-extra": "^11.2.0",
|
|
68
69
|
"plist": "^3.1.0",
|
|
69
70
|
"prompts": "^2.4.2",
|
|
70
|
-
"react-native-fs": "^2.20.0",
|
|
71
|
-
"react-native-zip-archive": "^7.0.1",
|
|
72
71
|
"undici": "^7.8.0"
|
|
73
72
|
},
|
|
74
73
|
"publishConfig": {
|
package/lib/api/utils.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const buildQuery: (params: Record<string, string | number | undefined | null>) => string;
|
package/lib/api/utils.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.buildQuery = void 0;
|
|
4
|
-
const buildQuery = (params) => Object.entries(params)
|
|
5
|
-
.filter(([, v]) => v !== undefined && v !== null)
|
|
6
|
-
.map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(String(v))}`)
|
|
7
|
-
.join('&');
|
|
8
|
-
exports.buildQuery = buildQuery;
|
package/lib/fs/iosPointer.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function setCurrentBundlePointer(bundlePath: string, hash: string): Promise<void>;
|
package/lib/fs/iosPointer.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.setCurrentBundlePointer = setCurrentBundlePointer;
|
|
7
|
-
const react_native_fs_1 = __importDefault(require("react-native-fs"));
|
|
8
|
-
const context_1 = require("../context");
|
|
9
|
-
const fsUtils_1 = require("./fsUtils");
|
|
10
|
-
async function setCurrentBundlePointer(bundlePath, hash) {
|
|
11
|
-
if (!context_1.isIOS)
|
|
12
|
-
return;
|
|
13
|
-
const root = `${react_native_fs_1.default.LibraryDirectoryPath}/bundle-drop`;
|
|
14
|
-
await (0, fsUtils_1.ensureDir)(root);
|
|
15
|
-
await (0, fsUtils_1.atomicWriteJson)(`${root}/current.json`, {
|
|
16
|
-
hash,
|
|
17
|
-
bundlePath,
|
|
18
|
-
updatedAt: new Date().toISOString(),
|
|
19
|
-
});
|
|
20
|
-
}
|