@gfean/react-native-bundle-drop 0.3.5 โ 0.3.6
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/ios/BundleDropLocator.h +11 -0
- package/ios/BundleDropLocator.swift +1 -1
- package/lib/CLI/cli.js +56 -6
- package/lib/CLI/scripts/aipowered/apply-plan.d.ts +10 -0
- package/lib/CLI/scripts/aipowered/apply-plan.js +50 -0
- package/lib/CLI/scripts/aipowered/backend-client.d.ts +6 -0
- package/lib/CLI/scripts/aipowered/backend-client.js +34 -0
- package/lib/CLI/scripts/aipowered/diff-preview.d.ts +7 -0
- package/lib/CLI/scripts/aipowered/diff-preview.js +33 -0
- package/lib/CLI/scripts/aipowered/init-native-config.d.ts +2 -0
- package/lib/CLI/scripts/aipowered/init-native-config.js +131 -0
- package/lib/CLI/scripts/aipowered/scanner.d.ts +5 -0
- package/lib/CLI/scripts/aipowered/scanner.js +349 -0
- package/lib/CLI/scripts/aipowered/types.d.ts +53 -0
- package/lib/CLI/scripts/aipowered/types.js +2 -0
- package/lib/CLI/scripts/aipowered/validate-plan.d.ts +8 -0
- package/lib/CLI/scripts/aipowered/validate-plan.js +164 -0
- package/lib/CLI/scripts/init-config.js +10 -5
- package/lib/CLI/scripts/init-native-config.js +1 -1
- package/lib/CLI/scripts/post-init.js +7 -18
- package/lib/CLI/scripts/upload-cli.d.ts +2 -0
- package/lib/CLI/scripts/upload-cli.js +53 -25
- package/lib/CLI/utils/ui.d.ts +3 -0
- package/lib/CLI/utils/ui.js +26 -0
- package/lib/api/clientApi.d.ts +2 -1
- package/lib/api/clientApi.js +9 -0
- package/lib/api/types.d.ts +17 -0
- package/lib/context.d.ts +4 -4
- package/lib/context.js +2 -2
- package/lib/fs/bundlePointer.d.ts +2 -0
- package/lib/fs/bundlePointer.js +14 -4
- package/lib/index.d.ts +6 -3
- package/lib/index.js +5 -1
- package/lib/injectImageResolver.js +6 -15
- package/lib/loadConfig.d.ts +4 -4
- package/lib/manager/downloadAndInstall.d.ts +3 -0
- package/lib/manager/downloadAndInstall.js +23 -3
- package/lib/manager/reporting.d.ts +2 -0
- package/lib/manager/reporting.js +25 -0
- package/lib/manager/rollbackState.d.ts +25 -8
- package/lib/manager/rollbackState.js +87 -22
- package/lib/manager/updateCheck.js +15 -1
- package/lib/manager/updateState.d.ts +5 -1
- package/lib/manager/updateState.js +20 -11
- package/lib/runtime/service.d.ts +28 -0
- package/lib/runtime/service.js +134 -10
- package/lib/scripts/bundle.d.ts +4 -1
- package/lib/scripts/bundle.js +41 -28
- package/lib/scripts/projectRoot.d.ts +1 -0
- package/lib/scripts/projectRoot.js +54 -0
- package/lib/scripts/upload-bundle.d.ts +2 -1
- package/lib/scripts/upload-bundle.js +46 -37
- package/lib/useBundleDrop.d.ts +2 -0
- package/lib/useBundleDrop.js +1 -0
- package/package.json +3 -2
package/lib/scripts/bundle.js
CHANGED
|
@@ -37,30 +37,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
37
37
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
38
|
};
|
|
39
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
-
exports.findProjectRoot =
|
|
40
|
+
exports.findProjectRoot = void 0;
|
|
41
41
|
exports.runBundleScript = runBundleScript;
|
|
42
42
|
const adm_zip_1 = __importDefault(require("adm-zip"));
|
|
43
43
|
const child_process_1 = require("child_process");
|
|
44
44
|
const crypto_1 = require("crypto");
|
|
45
45
|
const fs = __importStar(require("fs"));
|
|
46
46
|
const path = __importStar(require("path"));
|
|
47
|
+
const projectRoot_1 = require("./projectRoot");
|
|
48
|
+
Object.defineProperty(exports, "findProjectRoot", { enumerable: true, get: function () { return projectRoot_1.findProjectRoot; } });
|
|
47
49
|
const getPackageRoot = () => process.env.BUNDLE_DROP_PACKAGE_ROOT_OVERRIDE || path.resolve(__dirname, '..', '..');
|
|
48
|
-
function findProjectRoot(startDir) {
|
|
49
|
-
let dir = path.resolve(startDir);
|
|
50
|
-
const MAX_UP = 12;
|
|
51
|
-
for (let i = 0; i < MAX_UP; i++) {
|
|
52
|
-
const iosDir = path.join(dir, 'ios');
|
|
53
|
-
const androidDir = path.join(dir, 'android');
|
|
54
|
-
if (fs.existsSync(iosDir) && fs.existsSync(androidDir)) {
|
|
55
|
-
return dir;
|
|
56
|
-
}
|
|
57
|
-
const parent = path.dirname(dir);
|
|
58
|
-
if (parent === dir)
|
|
59
|
-
break;
|
|
60
|
-
dir = parent;
|
|
61
|
-
}
|
|
62
|
-
return startDir;
|
|
63
|
-
}
|
|
64
50
|
function runBundleScript(options) {
|
|
65
51
|
const packageRoot = getPackageRoot();
|
|
66
52
|
const platform = options?.platform || process.argv[2] || 'ios';
|
|
@@ -74,9 +60,11 @@ function runBundleScript(options) {
|
|
|
74
60
|
const assetsDir = path.join(outputDir, 'assets');
|
|
75
61
|
const bundlePath = path.join(outputDir, 'main.jsbundle');
|
|
76
62
|
const metadataPath = path.join(outputDir, `metadata-${fileSuffix}.json`);
|
|
63
|
+
const sourceMapPath = path.join(outputDir, 'main.jsbundle.map');
|
|
77
64
|
const zipPath = path.join(outputDir, `bundle-${platform}.zip`);
|
|
78
65
|
const imageManifest = {};
|
|
79
|
-
const projectRoot = findProjectRoot(options?.cwd || process.cwd());
|
|
66
|
+
const projectRoot = (0, projectRoot_1.findProjectRoot)(options?.cwd || process.cwd());
|
|
67
|
+
const generateSourceMap = options?.sourcemap ?? process.argv.includes('--sourcemap');
|
|
80
68
|
let runtimeVersion;
|
|
81
69
|
const configPath = path.resolve(projectRoot, 'bundle.drop.config.js');
|
|
82
70
|
if (fs.existsSync(configPath)) {
|
|
@@ -90,7 +78,7 @@ function runBundleScript(options) {
|
|
|
90
78
|
else {
|
|
91
79
|
console.warn('โ ๏ธ bundle.drop.config.js not found in project root; runtimeVersion will be omitted.');
|
|
92
80
|
}
|
|
93
|
-
[bundlePath, zipPath, metadataPath].forEach(file => {
|
|
81
|
+
[bundlePath, zipPath, metadataPath, sourceMapPath].forEach(file => {
|
|
94
82
|
if (fs.existsSync(file))
|
|
95
83
|
fs.unlinkSync(file);
|
|
96
84
|
});
|
|
@@ -99,13 +87,14 @@ function runBundleScript(options) {
|
|
|
99
87
|
fs.mkdirSync(outputDir, { recursive: true });
|
|
100
88
|
fs.mkdirSync(assetsDir, { recursive: true });
|
|
101
89
|
console.log(`๐ฆ Bundling React Native code for platform: ${platform}...`);
|
|
90
|
+
const sourcemapFlag = generateSourceMap ? ` \\\n --sourcemap-output "${sourceMapPath}"` : '';
|
|
102
91
|
(0, child_process_1.execSync)(`npx react-native bundle \
|
|
103
92
|
--platform ${platform} \
|
|
104
93
|
--dev false \
|
|
105
94
|
--entry-file index.js \
|
|
106
95
|
--bundle-output "${bundlePath}" \
|
|
107
|
-
--assets-dest "${assetsDir}"`, { stdio: 'inherit' });
|
|
108
|
-
console.log('โ
Bundle created
|
|
96
|
+
--assets-dest "${assetsDir}"${sourcemapFlag}`, { stdio: 'inherit' });
|
|
97
|
+
console.log('โ
Bundle created');
|
|
109
98
|
const osBin = process.platform === 'darwin'
|
|
110
99
|
? 'osx-bin'
|
|
111
100
|
: process.platform === 'win32'
|
|
@@ -117,19 +106,42 @@ function runBundleScript(options) {
|
|
|
117
106
|
];
|
|
118
107
|
const hermescPath = hermesLocations.find(p => fs.existsSync(p));
|
|
119
108
|
if (hermescPath) {
|
|
120
|
-
console.log(`๐ฅ Compiling to Hermes bytecode (${platform})...`);
|
|
121
109
|
const hbcPath = bundlePath + '.hbc';
|
|
110
|
+
const hermesMapFlag = generateSourceMap ? ` -output-source-map` : '';
|
|
122
111
|
try {
|
|
123
|
-
|
|
112
|
+
console.log(`๐ฅ Compiling to Hermes bytecode (${platform})...`);
|
|
113
|
+
(0, child_process_1.execSync)(`"${hermescPath}" -emit-binary -out "${hbcPath}" "${bundlePath}"${hermesMapFlag}`, { stdio: ['ignore', 'ignore', 'ignore'] });
|
|
124
114
|
fs.renameSync(hbcPath, bundlePath);
|
|
125
|
-
console.log('โ
Hermes bytecode compiled
|
|
115
|
+
console.log('โ
Hermes bytecode compiled');
|
|
126
116
|
}
|
|
127
117
|
catch (e) {
|
|
128
118
|
console.warn('โ ๏ธ Hermes compilation failed, falling back to plain JS bundle:', e.message);
|
|
129
119
|
}
|
|
120
|
+
if (generateSourceMap) {
|
|
121
|
+
const hermesMapPath = bundlePath + '.hbc.map';
|
|
122
|
+
if (fs.existsSync(hermesMapPath) && fs.existsSync(sourceMapPath)) {
|
|
123
|
+
const composeScript = path.join(projectRoot, 'node_modules', 'react-native', 'scripts', 'compose-source-maps.js');
|
|
124
|
+
if (fs.existsSync(composeScript)) {
|
|
125
|
+
try {
|
|
126
|
+
const composedPath = sourceMapPath + '.composed';
|
|
127
|
+
(0, child_process_1.execSync)(`node "${composeScript}" "${sourceMapPath}" "${hermesMapPath}" -o "${composedPath}"`, { stdio: ['ignore', 'ignore', 'ignore'] });
|
|
128
|
+
fs.renameSync(composedPath, sourceMapPath);
|
|
129
|
+
console.log('โ
Source maps composed');
|
|
130
|
+
}
|
|
131
|
+
catch (composeErr) {
|
|
132
|
+
console.warn('โ ๏ธ Source map composition failed; keeping Metro source map:', composeErr.message);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
console.warn('โ ๏ธ compose-source-maps.js not found; keeping Metro source map as-is');
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
if (fs.existsSync(hermesMapPath))
|
|
140
|
+
fs.unlinkSync(hermesMapPath);
|
|
141
|
+
}
|
|
130
142
|
}
|
|
131
143
|
else {
|
|
132
|
-
console.log('โน๏ธ
|
|
144
|
+
console.log('โน๏ธ Hermes not found โ bundling plain JS');
|
|
133
145
|
}
|
|
134
146
|
const bundleBuffer = fs.readFileSync(bundlePath);
|
|
135
147
|
const hash = (0, crypto_1.createHash)('sha256').update(bundleBuffer).digest('hex');
|
|
@@ -144,9 +156,8 @@ function runBundleScript(options) {
|
|
|
144
156
|
metadata.runtimeVersion = runtimeVersion;
|
|
145
157
|
}
|
|
146
158
|
fs.writeFileSync(metadataPath, JSON.stringify(metadata, null, 2));
|
|
147
|
-
console.log('๐ง Metadata saved
|
|
159
|
+
console.log('๐ง Metadata saved');
|
|
148
160
|
console.log('๐ Hash:', hash);
|
|
149
|
-
console.log('๐ฆ Zipping bundle...');
|
|
150
161
|
const zip = new adm_zip_1.default();
|
|
151
162
|
zip.addFile('main.jsbundle', bundleBuffer);
|
|
152
163
|
zip.addFile(`metadata-${fileSuffix}.json`, Buffer.from(JSON.stringify(metadata, null, 2)));
|
|
@@ -182,12 +193,14 @@ function runBundleScript(options) {
|
|
|
182
193
|
zip.addFile('image-manifest.json', Buffer.from(JSON.stringify(imageManifest, null, 2)));
|
|
183
194
|
console.log(`๐งฉ Injected image-manifest.json with ${Object.keys(imageManifest).length} entries`);
|
|
184
195
|
}
|
|
196
|
+
console.log('๐ฆ Zipping bundle...');
|
|
185
197
|
zip.writeZip(zipPath);
|
|
186
|
-
console.log(
|
|
198
|
+
console.log('โ
OTA bundle zipped');
|
|
187
199
|
return {
|
|
188
200
|
projectRoot,
|
|
189
201
|
outputDir,
|
|
190
202
|
bundlePath,
|
|
203
|
+
sourceMapPath: generateSourceMap ? sourceMapPath : undefined,
|
|
191
204
|
metadataPath,
|
|
192
205
|
zipPath,
|
|
193
206
|
runtimeVersion,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function findProjectRoot(startDir: string): string;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.findProjectRoot = findProjectRoot;
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
function findProjectRoot(startDir) {
|
|
40
|
+
let dir = path.resolve(startDir);
|
|
41
|
+
const MAX_UP = 12;
|
|
42
|
+
for (let i = 0; i < MAX_UP; i++) {
|
|
43
|
+
const iosDir = path.join(dir, 'ios');
|
|
44
|
+
const androidDir = path.join(dir, 'android');
|
|
45
|
+
if (fs.existsSync(iosDir) && fs.existsSync(androidDir)) {
|
|
46
|
+
return dir;
|
|
47
|
+
}
|
|
48
|
+
const parent = path.dirname(dir);
|
|
49
|
+
if (parent === dir)
|
|
50
|
+
break;
|
|
51
|
+
dir = parent;
|
|
52
|
+
}
|
|
53
|
+
return startDir;
|
|
54
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
import { findProjectRoot } from './projectRoot';
|
|
3
|
+
export { findProjectRoot };
|
|
3
4
|
export declare function parseAndroidVersionFromGradle(filePath: string): string;
|
|
4
5
|
export declare const cleanupArtifacts: (platform: string, zipPath: string) => void;
|
|
5
6
|
export declare function runUploadBundle(options?: {
|
|
@@ -37,8 +37,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
37
37
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
38
|
};
|
|
39
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
-
exports.cleanupArtifacts = void 0;
|
|
41
|
-
exports.findProjectRoot = findProjectRoot;
|
|
40
|
+
exports.cleanupArtifacts = exports.findProjectRoot = void 0;
|
|
42
41
|
exports.parseAndroidVersionFromGradle = parseAndroidVersionFromGradle;
|
|
43
42
|
exports.runUploadBundle = runUploadBundle;
|
|
44
43
|
const axios_1 = __importDefault(require("axios"));
|
|
@@ -48,24 +47,10 @@ const fs = __importStar(require("fs"));
|
|
|
48
47
|
const os_1 = __importDefault(require("os"));
|
|
49
48
|
const path = __importStar(require("path"));
|
|
50
49
|
const plist = __importStar(require("plist"));
|
|
50
|
+
const projectRoot_1 = require("./projectRoot");
|
|
51
|
+
Object.defineProperty(exports, "findProjectRoot", { enumerable: true, get: function () { return projectRoot_1.findProjectRoot; } });
|
|
51
52
|
const resolve_ios_version_1 = require("./resolve-ios-version");
|
|
52
53
|
const getPackageRoot = () => process.env.BUNDLE_DROP_PACKAGE_ROOT_OVERRIDE || path.resolve(__dirname, '..', '..');
|
|
53
|
-
function findProjectRoot(startDir) {
|
|
54
|
-
let dir = path.resolve(startDir);
|
|
55
|
-
const MAX_UP = 12;
|
|
56
|
-
for (let i = 0; i < MAX_UP; i++) {
|
|
57
|
-
const iosDir = path.join(dir, 'ios');
|
|
58
|
-
const androidDir = path.join(dir, 'android');
|
|
59
|
-
if (fs.existsSync(iosDir) && fs.existsSync(androidDir)) {
|
|
60
|
-
return dir;
|
|
61
|
-
}
|
|
62
|
-
const parent = path.dirname(dir);
|
|
63
|
-
if (parent === dir)
|
|
64
|
-
break;
|
|
65
|
-
dir = parent;
|
|
66
|
-
}
|
|
67
|
-
return startDir;
|
|
68
|
-
}
|
|
69
54
|
function parseAndroidVersionFromGradle(filePath) {
|
|
70
55
|
if (!fs.existsSync(filePath)) {
|
|
71
56
|
console.error(`โ build.gradle not found at ${filePath}`);
|
|
@@ -82,25 +67,20 @@ function parseAndroidVersionFromGradle(filePath) {
|
|
|
82
67
|
const cleanupArtifacts = (platform, zipPath) => {
|
|
83
68
|
const outputDir = path.join(getPackageRoot(), 'dist');
|
|
84
69
|
try {
|
|
85
|
-
if (fs.existsSync(zipPath)) {
|
|
86
|
-
fs.unlinkSync(zipPath);
|
|
87
|
-
console.log(`๐งน Deleted: ${zipPath}`);
|
|
88
|
-
}
|
|
89
70
|
const suffix = platform === 'ios' ? 'ios' : 'android';
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
71
|
+
const filesToDelete = [
|
|
72
|
+
zipPath,
|
|
73
|
+
path.join(outputDir, `metadata-${suffix}.json`),
|
|
74
|
+
path.join(outputDir, 'main.jsbundle'),
|
|
75
|
+
path.join(outputDir, 'main.jsbundle.map'),
|
|
76
|
+
];
|
|
77
|
+
for (const file of filesToDelete) {
|
|
78
|
+
if (fs.existsSync(file))
|
|
79
|
+
fs.unlinkSync(file);
|
|
95
80
|
}
|
|
81
|
+
const assetsPath = path.join(outputDir, 'assets');
|
|
96
82
|
if (fs.existsSync(assetsPath)) {
|
|
97
83
|
fs.rmSync(assetsPath, { recursive: true, force: true });
|
|
98
|
-
console.log(`๐งน Deleted: ${assetsPath}`);
|
|
99
|
-
}
|
|
100
|
-
const bundlePath = path.join(outputDir, 'main.jsbundle');
|
|
101
|
-
if (fs.existsSync(bundlePath)) {
|
|
102
|
-
fs.unlinkSync(bundlePath);
|
|
103
|
-
console.log(`๐งน Deleted: ${bundlePath}`);
|
|
104
84
|
}
|
|
105
85
|
}
|
|
106
86
|
catch (err) {
|
|
@@ -112,7 +92,7 @@ async function runUploadBundle(options) {
|
|
|
112
92
|
const packageRoot = getPackageRoot();
|
|
113
93
|
const outputDir = path.join(packageRoot, 'dist');
|
|
114
94
|
const argv = options?.argv || process.argv;
|
|
115
|
-
const projectRoot = findProjectRoot(options?.cwd || process.cwd());
|
|
95
|
+
const projectRoot = (0, projectRoot_1.findProjectRoot)(options?.cwd || process.cwd());
|
|
116
96
|
const configPath = path.resolve(projectRoot, 'bundle.drop.config.js');
|
|
117
97
|
if (!fs.existsSync(configPath)) {
|
|
118
98
|
console.error('โ bundle.drop.config.js not found in project root');
|
|
@@ -167,6 +147,9 @@ async function runUploadBundle(options) {
|
|
|
167
147
|
const runtimeVersionOverride = runtimeVersionArg?.split('=')[1];
|
|
168
148
|
const releaseNotesArg = args.find(arg => arg.startsWith('--release-notes='));
|
|
169
149
|
let releaseNotes = releaseNotesArg ? releaseNotesArg.split('=')[1] : undefined;
|
|
150
|
+
const generateSourceMap = args.includes('--sourcemap');
|
|
151
|
+
const artifactDirArg = args.find(arg => arg.startsWith('--artifact-dir='));
|
|
152
|
+
const artifactDir = artifactDirArg ? path.resolve(artifactDirArg.split('=')[1]) : undefined;
|
|
170
153
|
const MAX_NOTES = 2000;
|
|
171
154
|
if (releaseNotes && releaseNotes.length > MAX_NOTES) {
|
|
172
155
|
console.warn(`โ ๏ธ Release notes too long (${releaseNotes.length}); truncating to ${MAX_NOTES} chars.`);
|
|
@@ -233,8 +216,9 @@ async function runUploadBundle(options) {
|
|
|
233
216
|
? `node "${compiledBundleScript}"`
|
|
234
217
|
: `ts-node "${tsBundleScript}"`;
|
|
235
218
|
try {
|
|
219
|
+
const sourcemapArg = generateSourceMap ? ' --sourcemap' : '';
|
|
236
220
|
console.log(`๐ฆ Running bundler for ${platform}...`);
|
|
237
|
-
(0, child_process_1.execSync)(`${bundleCommand} ${platform}`, {
|
|
221
|
+
(0, child_process_1.execSync)(`${bundleCommand} ${platform}${sourcemapArg}`, {
|
|
238
222
|
stdio: 'inherit',
|
|
239
223
|
});
|
|
240
224
|
const suffix = platform === 'ios' ? 'ios' : 'android';
|
|
@@ -285,7 +269,7 @@ async function runUploadBundle(options) {
|
|
|
285
269
|
form.append('releaseNotes', releaseNotes);
|
|
286
270
|
}
|
|
287
271
|
form.append('file', fs.createReadStream(zipPath));
|
|
288
|
-
console.log(
|
|
272
|
+
console.log(`โ Uploading bundle to server...`);
|
|
289
273
|
try {
|
|
290
274
|
const res = await axios_1.default.post(`${serverUrl}/bundle/upload`, form, {
|
|
291
275
|
headers: {
|
|
@@ -295,7 +279,32 @@ async function runUploadBundle(options) {
|
|
|
295
279
|
maxContentLength: Infinity,
|
|
296
280
|
maxBodyLength: Infinity,
|
|
297
281
|
});
|
|
298
|
-
|
|
282
|
+
if (artifactDir) {
|
|
283
|
+
try {
|
|
284
|
+
fs.mkdirSync(artifactDir, { recursive: true });
|
|
285
|
+
const bundleFile = path.join(outputDir, 'main.jsbundle');
|
|
286
|
+
const sourceMapFile = path.join(outputDir, 'main.jsbundle.map');
|
|
287
|
+
const result = { ...res.data };
|
|
288
|
+
if (fs.existsSync(bundleFile)) {
|
|
289
|
+
fs.copyFileSync(bundleFile, path.join(artifactDir, 'main.jsbundle'));
|
|
290
|
+
result.bundlePath = path.join(artifactDir, 'main.jsbundle');
|
|
291
|
+
}
|
|
292
|
+
if (generateSourceMap && fs.existsSync(sourceMapFile)) {
|
|
293
|
+
fs.copyFileSync(sourceMapFile, path.join(artifactDir, 'main.jsbundle.map'));
|
|
294
|
+
result.sourceMapPath = path.join(artifactDir, 'main.jsbundle.map');
|
|
295
|
+
}
|
|
296
|
+
fs.writeFileSync(path.join(artifactDir, 'bundle-drop-result.json'), JSON.stringify(result, null, 2));
|
|
297
|
+
console.log('๐ Artifacts saved to:', artifactDir);
|
|
298
|
+
}
|
|
299
|
+
catch (copyErr) {
|
|
300
|
+
console.warn('โ ๏ธ Upload succeeded but artifact copy failed:', copyErr.message);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
console.log('โ
Upload complete');
|
|
304
|
+
if (res.data?.bundleVersion != null)
|
|
305
|
+
console.log(`Bundle Version: ${res.data.bundleVersion}`);
|
|
306
|
+
if (res.data?.hash)
|
|
307
|
+
console.log(`Hash: ${res.data.hash}`);
|
|
299
308
|
return res.data;
|
|
300
309
|
}
|
|
301
310
|
catch (err) {
|
package/lib/useBundleDrop.d.ts
CHANGED
|
@@ -36,6 +36,8 @@ export type UseBundleDropReturn = {
|
|
|
36
36
|
result: ApplyUpdateResult;
|
|
37
37
|
status?: string;
|
|
38
38
|
}>;
|
|
39
|
+
/** Mark the current OTA candidate healthy for this device. */
|
|
40
|
+
reportHealthy: () => Promise<void>;
|
|
39
41
|
/** Fetch available channel names from the server (API key auth). */
|
|
40
42
|
fetchAvailableChannels: () => Promise<string[]>;
|
|
41
43
|
/** Last fetched list of channel names. */
|
package/lib/useBundleDrop.js
CHANGED
|
@@ -24,6 +24,7 @@ function useBundleDrop() {
|
|
|
24
24
|
checkLatest: service_1.checkLatest,
|
|
25
25
|
downloadUpdate: service_1.downloadAndStage,
|
|
26
26
|
applyUpdate: service_1.applyDownloadedUpdate,
|
|
27
|
+
reportHealthy: service_1.reportHealthy,
|
|
27
28
|
fetchAvailableChannels: service_1.fetchAvailableChannels,
|
|
28
29
|
availableChannels: state.availableChannels,
|
|
29
30
|
setChannel: service_1.setChannel,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gfean/react-native-bundle-drop",
|
|
3
|
-
"version": "0.3.
|
|
4
|
-
"nativeVersion": "0.3.
|
|
3
|
+
"version": "0.3.6",
|
|
4
|
+
"nativeVersion": "0.3.6",
|
|
5
5
|
"description": "Over-the-air (OTA) updates for React Native โ ship fixes instantly, no App Store or Play Store delays",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"types": "lib/index.d.ts",
|
|
@@ -112,6 +112,7 @@
|
|
|
112
112
|
"axios": "^1.8.4",
|
|
113
113
|
"chalk": "4",
|
|
114
114
|
"commander": "^13.1.0",
|
|
115
|
+
"diff": "^9.0.0",
|
|
115
116
|
"figures": "3",
|
|
116
117
|
"form-data": "^4.0.2",
|
|
117
118
|
"fs-extra": "^11.2.0",
|