@gfean/react-native-bundle-drop 0.1.36 → 0.1.37

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/lib/CLI/cli.js CHANGED
@@ -99,6 +99,13 @@ program
99
99
  //eslint-disable-next-line
100
100
  require('../CLI/scripts/init-native-config').initNativeConfig();
101
101
  });
102
+ program
103
+ .command('init-metro')
104
+ .description('Ensure Metro can resolve bundle.drop.config.js via extraNodeModules alias')
105
+ .action(() => {
106
+ //eslint-disable-next-line
107
+ require('../CLI/scripts/init-metro-config').initMetroConfig();
108
+ });
102
109
  program
103
110
  .command('whoami')
104
111
  .description('Show currently logged in user')
@@ -0,0 +1,2 @@
1
+ export declare function initMetroConfig(): Promise<void>;
2
+ export default initMetroConfig;
@@ -0,0 +1,66 @@
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.initMetroConfig = initMetroConfig;
7
+ const chalk_1 = __importDefault(require("chalk"));
8
+ const fs_extra_1 = __importDefault(require("fs-extra"));
9
+ const path_1 = __importDefault(require("path"));
10
+ function findProjectRoot(startDir) {
11
+ let dir = path_1.default.resolve(startDir);
12
+ const MAX_UP = 12;
13
+ for (let i = 0; i < MAX_UP; i++) {
14
+ if (fs_extra_1.default.existsSync(path_1.default.join(dir, 'package.json'))) {
15
+ return dir;
16
+ }
17
+ const parent = path_1.default.dirname(dir);
18
+ if (parent === dir)
19
+ break;
20
+ dir = parent;
21
+ }
22
+ return startDir;
23
+ }
24
+ const APPEND_SNIPPET = `
25
+ // Bundle Drop: ensure bundle.drop.config.js is resolvable from node_modules
26
+ (() => {
27
+ const path = require('path');
28
+ module.exports = module.exports || {};
29
+ module.exports.resolver = module.exports.resolver || {};
30
+ module.exports.resolver.extraNodeModules = {
31
+ ...(module.exports.resolver.extraNodeModules || {}),
32
+ 'bundle-drop-config': path.resolve(__dirname, 'bundle.drop.config.js'),
33
+ };
34
+ })();
35
+ `;
36
+ const NEW_METRO_TEMPLATE = `const path = require('path');
37
+ const { getDefaultConfig } = require('@react-native/metro-config');
38
+
39
+ const config = getDefaultConfig(__dirname);
40
+ config.resolver = config.resolver || {};
41
+ config.resolver.extraNodeModules = {
42
+ ...(config.resolver.extraNodeModules || {}),
43
+ 'bundle-drop-config': path.resolve(__dirname, 'bundle.drop.config.js'),
44
+ };
45
+
46
+ module.exports = config;
47
+ ${APPEND_SNIPPET}
48
+ `;
49
+ async function initMetroConfig() {
50
+ const projectRoot = findProjectRoot(process.cwd());
51
+ const metroPath = path_1.default.join(projectRoot, 'metro.config.js');
52
+ if (!fs_extra_1.default.existsSync(metroPath)) {
53
+ fs_extra_1.default.writeFileSync(metroPath, NEW_METRO_TEMPLATE.trim() + '\n', 'utf8');
54
+ console.log(chalk_1.default.green(`✅ Created metro.config.js with Bundle Drop alias at ${metroPath}`));
55
+ return;
56
+ }
57
+ const content = fs_extra_1.default.readFileSync(metroPath, 'utf8');
58
+ if (content.includes('bundle-drop-config')) {
59
+ console.log(chalk_1.default.gray('ℹ️ metro.config.js already contains bundle-drop-config alias.'));
60
+ return;
61
+ }
62
+ const updated = `${content.trim()}\n${APPEND_SNIPPET}`;
63
+ fs_extra_1.default.writeFileSync(metroPath, updated, 'utf8');
64
+ console.log(chalk_1.default.green(`✅ Added bundle-drop-config alias to metro.config.js`));
65
+ }
66
+ exports.default = initMetroConfig;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gfean/react-native-bundle-drop",
3
- "version": "0.1.36",
3
+ "version": "0.1.37",
4
4
  "description": "react native ota by gFean",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -1 +0,0 @@
1
- export {};
package/lib/bootstrap.js DELETED
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const react_native_1 = require("react-native");
4
- const injectImageResolver_1 = require("./injectImageResolver");
5
- const patchImageAutoResolve_1 = require("./patchImageAutoResolve");
6
- (() => {
7
- if (react_native_1.Platform.OS !== 'android') {
8
- return;
9
- }
10
- // Apply the shared resolver/renderer patches early during app startup.
11
- (0, injectImageResolver_1.injectBundleDropImageResolver)();
12
- (0, patchImageAutoResolve_1.patchImageRenderToForceResolve)();
13
- })();