@gfean/react-native-bundle-drop 0.5.1 → 0.6.0
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/README.md +168 -4
- package/android/build.gradle +1 -0
- package/android/src/main/java/com/bundledrop/BundleDropBoundedDownloader.kt +86 -0
- package/android/src/main/java/com/bundledrop/BundleDropModule.kt +69 -0
- package/android/src/main/java/com/bundledrop/BundleDropRuntimeCrypto.kt +81 -0
- package/ios/BundleDropBridge.m +18 -0
- package/ios/BundleDropLocator.swift +48 -2
- package/ios/BundleDropModule.swift +75 -0
- package/ios/BundleDropRuntimeCrypto.swift +45 -0
- package/lib/CLI/cli.d.ts +1 -0
- package/lib/CLI/cli.js +54 -2
- package/lib/CLI/scripts/aipowered/apply-setup-plan.js +7 -17
- package/lib/CLI/scripts/aipowered/backend-client.js +29 -4
- package/lib/CLI/scripts/aipowered/code-push-residue.d.ts +5 -0
- package/lib/CLI/scripts/aipowered/code-push-residue.js +126 -0
- package/lib/CLI/scripts/aipowered/credential-safety.d.ts +1 -0
- package/lib/CLI/scripts/aipowered/credential-safety.js +14 -0
- package/lib/CLI/scripts/aipowered/diff-preview.js +12 -4
- package/lib/CLI/scripts/aipowered/init-project-config.d.ts +4 -0
- package/lib/CLI/scripts/aipowered/init-project-config.js +221 -45
- package/lib/CLI/scripts/aipowered/scanner.d.ts +1 -0
- package/lib/CLI/scripts/aipowered/scanner.js +164 -32
- package/lib/CLI/scripts/aipowered/terminal-safety.d.ts +4 -0
- package/lib/CLI/scripts/aipowered/terminal-safety.js +124 -0
- package/lib/CLI/scripts/aipowered/validate-plan.d.ts +3 -0
- package/lib/CLI/scripts/aipowered/validate-plan.js +1080 -19
- package/lib/CLI/scripts/bare-metro-config.d.ts +1 -1
- package/lib/CLI/scripts/bare-metro-config.js +24 -32
- package/lib/CLI/scripts/doctor.js +143 -22
- package/lib/CLI/scripts/expo/configure-expo.js +51 -60
- package/lib/CLI/scripts/expo/package-manager.d.ts +2 -0
- package/lib/CLI/scripts/expo/package-manager.js +63 -25
- package/lib/CLI/scripts/init-config.d.ts +7 -7
- package/lib/CLI/scripts/init-config.js +185 -10
- package/lib/CLI/scripts/login-cli.js +29 -4
- package/lib/CLI/scripts/metro-config-authority.d.ts +8 -0
- package/lib/CLI/scripts/metro-config-authority.js +303 -0
- package/lib/CLI/scripts/native-entrypoint-authority.d.ts +2 -0
- package/lib/CLI/scripts/native-entrypoint-authority.js +378 -0
- package/lib/CLI/scripts/native-setup-contract.d.ts +2 -2
- package/lib/CLI/scripts/native-setup-contract.js +63 -33
- package/lib/CLI/scripts/native-startup-validator.d.ts +3 -0
- package/lib/CLI/scripts/native-startup-validator.js +964 -0
- package/lib/CLI/scripts/safe-file-transaction.d.ts +12 -0
- package/lib/CLI/scripts/safe-file-transaction.js +159 -0
- package/lib/api/clientApi.d.ts +3 -1
- package/lib/api/clientApi.js +14 -0
- package/lib/api/types.d.ts +39 -0
- package/lib/context.d.ts +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.js +3 -1
- package/lib/install/installFromZip.d.ts +3 -0
- package/lib/install/installFromZip.js +10 -1
- package/lib/loadConfig.d.ts +17 -1
- package/lib/loadConfig.js +16 -0
- package/lib/manager/downloadAndInstall.d.ts +3 -2
- package/lib/manager/downloadAndInstall.js +111 -46
- package/lib/manager/rollbackState.d.ts +3 -1
- package/lib/manager/rollbackState.js +2 -2
- package/lib/manager/updateCheck.d.ts +1 -0
- package/lib/manager/updateCheck.js +218 -78
- package/lib/metro.d.ts +8 -1
- package/lib/metro.js +68 -19
- package/lib/native/bundleDropNative.js +2 -1
- package/lib/native/fs.d.ts +6 -0
- package/lib/native/fs.js +24 -0
- package/lib/patch-engine/installFromPatchSet.d.ts +2 -0
- package/lib/patch-engine/installFromPatchSet.js +14 -3
- package/lib/patch-engine/patchTransport.d.ts +2 -0
- package/lib/patch-engine/patchTransport.js +9 -0
- package/lib/runtime/initState.d.ts +5 -0
- package/lib/runtime/initState.js +4 -0
- package/lib/runtime/service.js +60 -3
- package/lib/runtime-delivery/artifactCapability.d.ts +1 -0
- package/lib/runtime-delivery/artifactCapability.js +32 -0
- package/lib/runtime-delivery/authorityLeaseVerifier.d.ts +3 -0
- package/lib/runtime-delivery/authorityLeaseVerifier.js +106 -0
- package/lib/runtime-delivery/bootstrapConfig.d.ts +50 -0
- package/lib/runtime-delivery/bootstrapConfig.js +217 -0
- package/lib/runtime-delivery/diagnostics.d.ts +17 -0
- package/lib/runtime-delivery/diagnostics.js +58 -0
- package/lib/runtime-delivery/encoding.d.ts +5 -0
- package/lib/runtime-delivery/encoding.js +132 -0
- package/lib/runtime-delivery/heartbeat.d.ts +3 -0
- package/lib/runtime-delivery/heartbeat.js +88 -0
- package/lib/runtime-delivery/localResolver.d.ts +23 -0
- package/lib/runtime-delivery/localResolver.js +81 -0
- package/lib/runtime-delivery/manifestState.d.ts +9 -0
- package/lib/runtime-delivery/manifestState.js +102 -0
- package/lib/runtime-delivery/manifestVerifier.d.ts +13 -0
- package/lib/runtime-delivery/manifestVerifier.js +329 -0
- package/lib/runtime-delivery/runtimeDelivery.d.ts +19 -0
- package/lib/runtime-delivery/runtimeDelivery.js +375 -0
- package/lib/runtime-delivery/types.d.ts +87 -0
- package/lib/runtime-delivery/types.js +6 -0
- package/package.json +2 -2
|
@@ -1,52 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.planBareMetroConfig = planBareMetroConfig;
|
|
7
|
-
const
|
|
8
|
-
const
|
|
4
|
+
const safe_file_transaction_1 = require("./safe-file-transaction");
|
|
5
|
+
const metro_config_authority_1 = require("./metro-config-authority");
|
|
9
6
|
const APPEND_SNIPPET = `
|
|
10
|
-
// Bundle Drop:
|
|
11
|
-
(
|
|
12
|
-
|
|
13
|
-
module.exports = module.exports || {};
|
|
14
|
-
module.exports.resolver = module.exports.resolver || {};
|
|
15
|
-
module.exports.resolver.extraNodeModules = {
|
|
16
|
-
...(module.exports.resolver.extraNodeModules || {}),
|
|
17
|
-
'bundle-drop-config': path.resolve(__dirname, 'bundle.drop.config.js'),
|
|
18
|
-
};
|
|
19
|
-
})();
|
|
7
|
+
// Bundle Drop: merge package-managed runtime delivery bootstrap into Metro.
|
|
8
|
+
const { withBundleDrop } = require('@gfean/react-native-bundle-drop/metro');
|
|
9
|
+
module.exports = withBundleDrop(module.exports || {}, { projectRoot: __dirname });
|
|
20
10
|
`;
|
|
21
|
-
const NEW_METRO_TEMPLATE = `const
|
|
22
|
-
const {
|
|
11
|
+
const NEW_METRO_TEMPLATE = `const { getDefaultConfig } = require('@react-native/metro-config');
|
|
12
|
+
const { withBundleDrop } = require('@gfean/react-native-bundle-drop/metro');
|
|
23
13
|
|
|
24
14
|
const config = getDefaultConfig(__dirname);
|
|
25
|
-
|
|
26
|
-
config.resolver.extraNodeModules = {
|
|
27
|
-
...(config.resolver.extraNodeModules || {}),
|
|
28
|
-
'bundle-drop-config': path.resolve(__dirname, 'bundle.drop.config.js'),
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
module.exports = config;
|
|
15
|
+
module.exports = withBundleDrop(config, { projectRoot: __dirname });
|
|
32
16
|
`;
|
|
33
17
|
function planBareMetroConfig(projectRoot) {
|
|
34
|
-
const
|
|
35
|
-
if (!
|
|
18
|
+
const metroConfigPath = (0, metro_config_authority_1.findSingleMetroConfig)(projectRoot);
|
|
19
|
+
if (!metroConfigPath) {
|
|
36
20
|
return {
|
|
37
|
-
file:
|
|
21
|
+
file: (0, metro_config_authority_1.newCommonJsMetroConfigFile)(projectRoot),
|
|
38
22
|
original: null,
|
|
39
23
|
updated: `${NEW_METRO_TEMPLATE.trim()}\n`,
|
|
40
|
-
reason: 'Create the bare React Native Metro
|
|
24
|
+
reason: 'Create the bare React Native Metro wrapper for Bundle Drop.',
|
|
41
25
|
};
|
|
42
26
|
}
|
|
43
|
-
const
|
|
44
|
-
|
|
27
|
+
const metroFile = (0, safe_file_transaction_1.inspectProjectFile)(projectRoot, metroConfigPath);
|
|
28
|
+
const content = metroFile.content;
|
|
29
|
+
if ((0, metro_config_authority_1.hasAuthoritativeMetroWrapper)(content, 'withBundleDrop'))
|
|
45
30
|
return null;
|
|
31
|
+
if ((0, metro_config_authority_1.hasExecutableMetroWrapperReference)(content, 'withBundleDrop')) {
|
|
32
|
+
throw new Error(`${metroConfigPath} contains a non-authoritative withBundleDrop reference. ` +
|
|
33
|
+
'Remove the dead, aliased, or malformed wrapper before rerunning setup.');
|
|
34
|
+
}
|
|
35
|
+
(0, metro_config_authority_1.assertCommonJsMetroConfig)(projectRoot, metroConfigPath);
|
|
46
36
|
return {
|
|
47
|
-
file:
|
|
37
|
+
file: metroConfigPath,
|
|
48
38
|
original: content,
|
|
49
39
|
updated: `${content.trim()}\n${APPEND_SNIPPET}`,
|
|
50
|
-
reason: '
|
|
40
|
+
reason: content.includes('bundle-drop-config')
|
|
41
|
+
? 'Migrate the legacy Bundle Drop alias to the package-managed Metro wrapper.'
|
|
42
|
+
: 'Add the Bundle Drop Metro wrapper without replacing the existing config.',
|
|
51
43
|
};
|
|
52
44
|
}
|
|
@@ -8,15 +8,19 @@ exports.runDoctor = runDoctor;
|
|
|
8
8
|
const chalk_1 = __importDefault(require("chalk"));
|
|
9
9
|
const fs_1 = __importDefault(require("fs"));
|
|
10
10
|
const path_1 = __importDefault(require("path"));
|
|
11
|
+
const child_process_1 = require("child_process");
|
|
11
12
|
const native_setup_contract_1 = require("./native-setup-contract");
|
|
12
13
|
const expo_1 = require("../../expo");
|
|
13
14
|
const build_receipt_1 = require("./expo/build-receipt");
|
|
14
15
|
const scanner_1 = require("./aipowered/scanner");
|
|
16
|
+
const bootstrapConfig_1 = require("../../runtime-delivery/bootstrapConfig");
|
|
17
|
+
const native_entrypoint_authority_1 = require("./native-entrypoint-authority");
|
|
18
|
+
const metro_config_authority_1 = require("./metro-config-authority");
|
|
19
|
+
const safe_file_transaction_1 = require("./safe-file-transaction");
|
|
15
20
|
const PACKAGE_NAME = '@gfean/react-native-bundle-drop';
|
|
16
21
|
const ANDROID_MARKER = 'com.bundledrop.EXPO_ENABLED';
|
|
17
22
|
const IOS_MARKER = 'BundleDropExpoEnabled';
|
|
18
23
|
const IOS_RECEIPT_PHASE = 'Bundle Drop: Write iOS build identity';
|
|
19
|
-
const METRO_CONFIG_EXTENSIONS = ['js', 'ts', 'cjs', 'mjs'];
|
|
20
24
|
const pluginName = (plugin) => typeof plugin === 'string'
|
|
21
25
|
? plugin
|
|
22
26
|
: Array.isArray(plugin) && typeof plugin[0] === 'string'
|
|
@@ -40,24 +44,124 @@ const checkExpoUpdates = (projectRoot, exp) => {
|
|
|
40
44
|
message: 'Active expo-updates can own startup. Migrate it and create a new native binary.',
|
|
41
45
|
};
|
|
42
46
|
};
|
|
43
|
-
const findFiles = (directory, suffix) => {
|
|
47
|
+
const findFiles = (directory, suffix, budget = { visitedEntries: 0 }) => {
|
|
44
48
|
const files = [];
|
|
45
49
|
if (fs_1.default.existsSync(directory)) {
|
|
46
50
|
for (const entry of fs_1.default.readdirSync(directory, { withFileTypes: true })) {
|
|
51
|
+
budget.visitedEntries += 1;
|
|
52
|
+
if (budget.visitedEntries > 5000) {
|
|
53
|
+
throw new Error('Native doctor source scan exceeded 5000 filesystem entries.');
|
|
54
|
+
}
|
|
47
55
|
if (entry.name === 'Pods' || entry.name === 'build')
|
|
48
56
|
continue;
|
|
49
57
|
const entryPath = path_1.default.join(directory, entry.name);
|
|
50
58
|
if (entry.isDirectory())
|
|
51
|
-
files.push(...findFiles(entryPath, suffix));
|
|
59
|
+
files.push(...findFiles(entryPath, suffix, budget));
|
|
52
60
|
else if (entry.name.endsWith(suffix))
|
|
53
61
|
files.push(entryPath);
|
|
54
62
|
}
|
|
55
63
|
}
|
|
56
64
|
return files;
|
|
57
65
|
};
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
66
|
+
const inspectMetroConfig = (projectRoot) => {
|
|
67
|
+
try {
|
|
68
|
+
const file = (0, metro_config_authority_1.findSingleMetroConfig)(projectRoot);
|
|
69
|
+
return file
|
|
70
|
+
? { file, content: (0, safe_file_transaction_1.inspectProjectFile)(projectRoot, file).content, issue: null }
|
|
71
|
+
: { file: undefined, content: '', issue: 'No Metro config file was found.' };
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
return { file: undefined, content: '', issue: error.message };
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
const runtimeDeliveryBootstrapGitState = (projectRoot) => {
|
|
78
|
+
const relativePath = path_1.default.join('.bundle-drop', 'runtime-delivery.generated.json');
|
|
79
|
+
const runGit = (args) => (0, child_process_1.spawnSync)('git', args, {
|
|
80
|
+
cwd: projectRoot,
|
|
81
|
+
stdio: 'ignore',
|
|
82
|
+
});
|
|
83
|
+
const repository = runGit(['rev-parse', '--is-inside-work-tree']);
|
|
84
|
+
if (repository.error || repository.status !== 0)
|
|
85
|
+
return null;
|
|
86
|
+
if (runGit(['check-ignore', '--no-index', '-q', '--', relativePath]).status === 0) {
|
|
87
|
+
return 'ignored';
|
|
88
|
+
}
|
|
89
|
+
return runGit(['ls-files', '--error-unmatch', '--', relativePath]).status === 0
|
|
90
|
+
? 'tracked'
|
|
91
|
+
: 'untracked';
|
|
92
|
+
};
|
|
93
|
+
const checkRuntimeDeliveryBootstrap = (projectRoot) => {
|
|
94
|
+
const configPath = path_1.default.join(projectRoot, 'bundle.drop.config.js');
|
|
95
|
+
if (!fs_1.default.existsSync(configPath)) {
|
|
96
|
+
return {
|
|
97
|
+
name: 'Runtime delivery bootstrap',
|
|
98
|
+
status: 'error',
|
|
99
|
+
message: 'bundle.drop.config.js is required before runtime delivery can be validated.',
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
try {
|
|
103
|
+
delete require.cache[require.resolve(configPath)];
|
|
104
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
105
|
+
const config = require(configPath);
|
|
106
|
+
if (!config.serverUrl || !config.org?.slug || !config.project?.slug) {
|
|
107
|
+
throw new Error('bundle.drop.config.js is missing serverUrl, org.slug, or project.slug.');
|
|
108
|
+
}
|
|
109
|
+
const bootstrap = (0, bootstrapConfig_1.readGeneratedRuntimeDeliveryBootstrap)({
|
|
110
|
+
projectRoot,
|
|
111
|
+
expectedIdentity: {
|
|
112
|
+
serverUrl: config.serverUrl,
|
|
113
|
+
orgSlug: config.org.slug,
|
|
114
|
+
projectSlug: config.project.slug,
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
if (bootstrap) {
|
|
118
|
+
const gitState = runtimeDeliveryBootstrapGitState(projectRoot);
|
|
119
|
+
if (gitState === 'ignored') {
|
|
120
|
+
return {
|
|
121
|
+
name: 'Runtime delivery bootstrap',
|
|
122
|
+
status: 'error',
|
|
123
|
+
message: 'The runtime delivery bootstrap is ignored by Git and will be missing from clean builds. ' +
|
|
124
|
+
'Run `bundle-drop sync` to repair .gitignore.',
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
if (gitState === 'untracked') {
|
|
128
|
+
return {
|
|
129
|
+
name: 'Runtime delivery bootstrap',
|
|
130
|
+
status: 'warning',
|
|
131
|
+
message: `Runtime delivery bootstrap is valid with ` +
|
|
132
|
+
`${Object.keys(bootstrap.runtimeDelivery.publicKeys).length} public key(s), ` +
|
|
133
|
+
'but it is not committed yet.',
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
return {
|
|
137
|
+
name: 'Runtime delivery bootstrap',
|
|
138
|
+
status: 'pass',
|
|
139
|
+
message: `Runtime delivery bootstrap is pinned with ${Object.keys(bootstrap.runtimeDelivery.publicKeys).length} public key(s).`,
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
if (config.runtimeDelivery) {
|
|
143
|
+
return {
|
|
144
|
+
name: 'Runtime delivery bootstrap',
|
|
145
|
+
status: 'warning',
|
|
146
|
+
message: 'Stale inline runtime delivery config is ignored. Remove runtimeDelivery from ' +
|
|
147
|
+
'bundle.drop.config.js, migrate Metro with `bundle-drop init`, and use `bundle-drop sync` ' +
|
|
148
|
+
'for package-managed trust.',
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
return {
|
|
152
|
+
name: 'Runtime delivery bootstrap',
|
|
153
|
+
status: 'warning',
|
|
154
|
+
message: 'No runtime delivery bootstrap is pinned. Run `bundle-drop sync` to create or repair it.',
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
catch (error) {
|
|
158
|
+
return {
|
|
159
|
+
name: 'Runtime delivery bootstrap',
|
|
160
|
+
status: 'error',
|
|
161
|
+
message: `${error.message} Run \`bundle-drop sync\` to repair it.`,
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
};
|
|
61
165
|
const checkCommittedNativeIntegration = (projectRoot, platform) => {
|
|
62
166
|
if (platform === 'android') {
|
|
63
167
|
const androidRoot = path_1.default.join(projectRoot, 'android');
|
|
@@ -94,6 +198,7 @@ const checkCommittedNativeIntegration = (projectRoot, platform) => {
|
|
|
94
198
|
};
|
|
95
199
|
async function inspectExpoProject(projectRoot, platforms) {
|
|
96
200
|
const checks = [];
|
|
201
|
+
checks.push(checkRuntimeDeliveryBootstrap(projectRoot));
|
|
97
202
|
const { exp } = (0, expo_1.evaluateExpoConfig)(projectRoot);
|
|
98
203
|
const plugins = (exp.plugins || []).map(pluginName);
|
|
99
204
|
const bundleDropPluginCount = plugins.filter(name => name === PACKAGE_NAME).length;
|
|
@@ -134,14 +239,16 @@ async function inspectExpoProject(projectRoot, platforms) {
|
|
|
134
239
|
if (nativeCheck)
|
|
135
240
|
checks.push(nativeCheck);
|
|
136
241
|
}
|
|
137
|
-
const
|
|
138
|
-
const
|
|
242
|
+
const metro = inspectMetroConfig(projectRoot);
|
|
243
|
+
const hasExpoMetroWrapper = !metro.issue &&
|
|
244
|
+
(0, metro_config_authority_1.hasAuthoritativeMetroWrapper)(metro.content, 'withBundleDropExpo') &&
|
|
245
|
+
(0, metro_config_authority_1.hasExecutableMetroModuleReference)(metro.content, 'expo/metro-config');
|
|
139
246
|
checks.push({
|
|
140
247
|
name: 'Expo Metro wrapper',
|
|
141
|
-
status:
|
|
142
|
-
message:
|
|
248
|
+
status: hasExpoMetroWrapper ? 'pass' : 'error',
|
|
249
|
+
message: hasExpoMetroWrapper
|
|
143
250
|
? 'Existing Expo Metro configuration is preserved through withBundleDropExpo.'
|
|
144
|
-
: 'Metro must
|
|
251
|
+
: metro.issue || 'Metro must export withBundleDropExpo(...) and preserve expo/metro-config.',
|
|
145
252
|
});
|
|
146
253
|
const runtimeAuthorities = new Map(platforms.map(platform => [
|
|
147
254
|
platform,
|
|
@@ -299,18 +406,30 @@ const checkBareStartupIntegration = (projectRoot, platform) => {
|
|
|
299
406
|
? ['MainApplication.kt', 'MainApplication.java']
|
|
300
407
|
: ['AppDelegate.swift', 'AppDelegate.mm', 'AppDelegate.m'];
|
|
301
408
|
const entrypoints = entrypointNames.flatMap(name => findFiles(nativeRoot, name));
|
|
302
|
-
const
|
|
409
|
+
const relativeEntrypoints = entrypoints.map(filePath => path_1.default.relative(projectRoot, filePath).split(path_1.default.sep).join('/'));
|
|
410
|
+
let authorityIssue = null;
|
|
411
|
+
try {
|
|
412
|
+
authorityIssue = (0, native_entrypoint_authority_1.findNativeEntrypointAuthorityIssue)(projectRoot, platform, relativeEntrypoints);
|
|
413
|
+
}
|
|
414
|
+
catch (error) {
|
|
415
|
+
authorityIssue = error.message;
|
|
416
|
+
}
|
|
417
|
+
const hasIntegration = entrypoints.length === 1 && entrypoints.every(filePath => {
|
|
303
418
|
const content = fs_1.default.readFileSync(filePath, 'utf8');
|
|
304
419
|
return platform === 'android'
|
|
305
420
|
? (0, native_setup_contract_1.hasBareAndroidStartupIntegration)(content)
|
|
306
421
|
: (0, native_setup_contract_1.hasBareIosStartupIntegration)(filePath, content);
|
|
307
|
-
});
|
|
422
|
+
}) && !authorityIssue;
|
|
308
423
|
return {
|
|
309
424
|
name: `${platform} OTA startup ownership`,
|
|
310
425
|
status: hasIntegration ? 'pass' : 'error',
|
|
311
|
-
message:
|
|
312
|
-
? `
|
|
313
|
-
:
|
|
426
|
+
message: entrypoints.length > 1
|
|
427
|
+
? `Multiple ${platform} application entrypoints were found; resolve startup ownership manually.`
|
|
428
|
+
: authorityIssue
|
|
429
|
+
? `Native application entrypoint authority is ambiguous: ${authorityIssue}`
|
|
430
|
+
: hasIntegration
|
|
431
|
+
? `The ${platform} application entrypoint asks Bundle Drop for the cold-start bundle.`
|
|
432
|
+
: `The ${platform} application entrypoint does not hand cold-start bundle resolution to Bundle Drop.`,
|
|
314
433
|
};
|
|
315
434
|
};
|
|
316
435
|
const checkBareNativeAutolinking = (projectRoot, platform) => {
|
|
@@ -358,8 +477,9 @@ const checkBareNativeAutolinking = (projectRoot, platform) => {
|
|
|
358
477
|
};
|
|
359
478
|
function inspectBareProject(projectRoot, platforms) {
|
|
360
479
|
const configPath = path_1.default.join(projectRoot, 'bundle.drop.config.js');
|
|
361
|
-
const
|
|
362
|
-
const
|
|
480
|
+
const metro = inspectMetroConfig(projectRoot);
|
|
481
|
+
const hasBareMetroWrapper = !metro.issue &&
|
|
482
|
+
(0, metro_config_authority_1.hasAuthoritativeMetroWrapper)(metro.content, 'withBundleDrop');
|
|
363
483
|
const checks = [
|
|
364
484
|
{
|
|
365
485
|
name: 'Bundle Drop config',
|
|
@@ -370,11 +490,12 @@ function inspectBareProject(projectRoot, platforms) {
|
|
|
370
490
|
},
|
|
371
491
|
{
|
|
372
492
|
name: 'Bare Metro alias',
|
|
373
|
-
status:
|
|
374
|
-
message:
|
|
375
|
-
? 'Metro
|
|
376
|
-
: 'Metro
|
|
493
|
+
status: hasBareMetroWrapper ? 'pass' : 'error',
|
|
494
|
+
message: hasBareMetroWrapper
|
|
495
|
+
? 'Metro uses the package-managed Bundle Drop wrapper.'
|
|
496
|
+
: metro.issue || 'Metro must export withBundleDrop(...) so generated trust data is bundled.',
|
|
377
497
|
},
|
|
498
|
+
checkRuntimeDeliveryBootstrap(projectRoot),
|
|
378
499
|
checkBarePackageMetadata(projectRoot),
|
|
379
500
|
];
|
|
380
501
|
for (const platform of platforms) {
|
|
@@ -10,9 +10,11 @@ exports.hasDynamicExpoConfig = hasDynamicExpoConfig;
|
|
|
10
10
|
exports.restoreExpoConfiguration = restoreExpoConfiguration;
|
|
11
11
|
exports.applyExpoConfigurationChanges = applyExpoConfigurationChanges;
|
|
12
12
|
const crypto_1 = __importDefault(require("crypto"));
|
|
13
|
-
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
14
13
|
const path_1 = __importDefault(require("path"));
|
|
15
14
|
const projectType_1 = require("../../../expo/projectType");
|
|
15
|
+
const bootstrapConfig_1 = require("../../../runtime-delivery/bootstrapConfig");
|
|
16
|
+
const safe_file_transaction_1 = require("../safe-file-transaction");
|
|
17
|
+
const metro_config_authority_1 = require("../metro-config-authority");
|
|
16
18
|
var projectType_2 = require("../../../expo/projectType");
|
|
17
19
|
Object.defineProperty(exports, "setBundleDropProjectType", { enumerable: true, get: function () { return projectType_2.setBundleDropProjectType; } });
|
|
18
20
|
const PACKAGE_NAME = '@gfean/react-native-bundle-drop';
|
|
@@ -75,7 +77,7 @@ module.exports = withBundleDropExpo(getDefaultConfig(__dirname), {
|
|
|
75
77
|
const updateBundleDropConfig = (content) => {
|
|
76
78
|
return (0, projectType_1.setBundleDropProjectType)(content, 'expo');
|
|
77
79
|
};
|
|
78
|
-
const findFirstExisting = (projectRoot, candidates) => candidates.find(candidate =>
|
|
80
|
+
const findFirstExisting = (projectRoot, candidates) => candidates.find(candidate => (0, safe_file_transaction_1.inspectProjectFile)(projectRoot, candidate).exists);
|
|
79
81
|
function planExpoProjectConfiguration(params) {
|
|
80
82
|
const changes = [];
|
|
81
83
|
const appConfigFile = findFirstExisting(params.projectRoot, [
|
|
@@ -84,9 +86,9 @@ function planExpoProjectConfiguration(params) {
|
|
|
84
86
|
'app.config.cjs',
|
|
85
87
|
'app.config.mjs',
|
|
86
88
|
]);
|
|
87
|
-
const
|
|
88
|
-
if (!appConfigFile &&
|
|
89
|
-
const original =
|
|
89
|
+
const appJson = (0, safe_file_transaction_1.inspectProjectFile)(params.projectRoot, 'app.json');
|
|
90
|
+
if (!appConfigFile && appJson.exists) {
|
|
91
|
+
const original = appJson.content;
|
|
90
92
|
const updated = updateAppJson(original, params.migrateExpoUpdates);
|
|
91
93
|
if (updated !== original) {
|
|
92
94
|
changes.push({
|
|
@@ -97,15 +99,15 @@ function planExpoProjectConfiguration(params) {
|
|
|
97
99
|
});
|
|
98
100
|
}
|
|
99
101
|
}
|
|
100
|
-
const metroFile =
|
|
101
|
-
'metro.config.js',
|
|
102
|
-
'metro.config.ts',
|
|
103
|
-
'metro.config.cjs',
|
|
104
|
-
'metro.config.mjs',
|
|
105
|
-
]);
|
|
102
|
+
const metroFile = (0, metro_config_authority_1.findSingleMetroConfig)(params.projectRoot);
|
|
106
103
|
if (metroFile) {
|
|
107
|
-
const original =
|
|
108
|
-
if (!
|
|
104
|
+
const original = (0, safe_file_transaction_1.inspectProjectFile)(params.projectRoot, metroFile).content;
|
|
105
|
+
if (!(0, metro_config_authority_1.hasAuthoritativeMetroWrapper)(original, 'withBundleDropExpo')) {
|
|
106
|
+
if ((0, metro_config_authority_1.hasExecutableMetroWrapperReference)(original, 'withBundleDropExpo')) {
|
|
107
|
+
throw new Error(`${metroFile} contains a non-authoritative withBundleDropExpo reference. ` +
|
|
108
|
+
'Remove the dead, aliased, or malformed wrapper before rerunning setup.');
|
|
109
|
+
}
|
|
110
|
+
(0, metro_config_authority_1.assertCommonJsMetroConfig)(params.projectRoot, metroFile);
|
|
109
111
|
changes.push({
|
|
110
112
|
file: metroFile,
|
|
111
113
|
original,
|
|
@@ -115,17 +117,18 @@ function planExpoProjectConfiguration(params) {
|
|
|
115
117
|
}
|
|
116
118
|
}
|
|
117
119
|
else {
|
|
120
|
+
const newMetroFile = (0, metro_config_authority_1.newCommonJsMetroConfigFile)(params.projectRoot);
|
|
118
121
|
changes.push({
|
|
119
|
-
file:
|
|
122
|
+
file: newMetroFile,
|
|
120
123
|
original: null,
|
|
121
124
|
updated: NEW_EXPO_METRO_CONFIG,
|
|
122
125
|
reason: 'Create an Expo Metro config with the Bundle Drop wrapper.',
|
|
123
126
|
});
|
|
124
127
|
}
|
|
125
|
-
const
|
|
126
|
-
const bundleConfigExists =
|
|
128
|
+
const bundleConfigFile = (0, safe_file_transaction_1.inspectProjectFile)(params.projectRoot, 'bundle.drop.config.js');
|
|
129
|
+
const bundleConfigExists = bundleConfigFile.exists;
|
|
127
130
|
const bundleConfig = bundleConfigExists
|
|
128
|
-
?
|
|
131
|
+
? bundleConfigFile.content
|
|
129
132
|
: params.bundleConfigContent;
|
|
130
133
|
if (!bundleConfig) {
|
|
131
134
|
throw new Error('bundle.drop.config.js is required before Expo configuration can be planned.');
|
|
@@ -140,8 +143,10 @@ function planExpoProjectConfiguration(params) {
|
|
|
140
143
|
});
|
|
141
144
|
}
|
|
142
145
|
if (params.migrateExpoUpdates) {
|
|
143
|
-
const
|
|
144
|
-
|
|
146
|
+
const packageFile = (0, safe_file_transaction_1.inspectProjectFile)(params.projectRoot, 'package.json');
|
|
147
|
+
if (!packageFile.exists)
|
|
148
|
+
throw new Error('package.json is required for expo-updates migration.');
|
|
149
|
+
const packageJson = packageFile.content;
|
|
145
150
|
const updatedPackageJson = updatePackageJson(packageJson);
|
|
146
151
|
if (updatedPackageJson !== packageJson) {
|
|
147
152
|
changes.push({
|
|
@@ -152,28 +157,27 @@ function planExpoProjectConfiguration(params) {
|
|
|
152
157
|
});
|
|
153
158
|
}
|
|
154
159
|
}
|
|
155
|
-
const
|
|
156
|
-
const fingerprintIgnore =
|
|
157
|
-
? fs_extra_1.default.readFileSync(fingerprintIgnorePath, 'utf8')
|
|
158
|
-
: '';
|
|
160
|
+
const fingerprintIgnoreFile = (0, safe_file_transaction_1.inspectProjectFile)(params.projectRoot, '.fingerprintignore');
|
|
161
|
+
const fingerprintIgnore = fingerprintIgnoreFile.exists ? fingerprintIgnoreFile.content : '';
|
|
159
162
|
if (EXPO_RUNTIME_SOURCE_PATTERN.test(updatedBundleConfig) &&
|
|
160
163
|
!fingerprintIgnore.split(/\r?\n/).includes(TRANSIENT_GRADLE_KOTLIN_FINGERPRINT_PATTERN)) {
|
|
161
164
|
changes.push({
|
|
162
165
|
file: '.fingerprintignore',
|
|
163
|
-
original:
|
|
166
|
+
original: fingerprintIgnoreFile.exists ? fingerprintIgnore : null,
|
|
164
167
|
updated: `${fingerprintIgnore.trimEnd()}${fingerprintIgnore.trim() ? '\n' : ''}` +
|
|
165
168
|
`${TRANSIENT_GRADLE_KOTLIN_FINGERPRINT_PATTERN}\n`,
|
|
166
169
|
reason: 'Exclude transient Gradle Kotlin compiler sessions from Expo runtime fingerprints.',
|
|
167
170
|
});
|
|
168
171
|
}
|
|
169
|
-
const
|
|
170
|
-
const gitignore =
|
|
171
|
-
|
|
172
|
+
const gitignoreFile = (0, safe_file_transaction_1.inspectProjectFile)(params.projectRoot, '.gitignore');
|
|
173
|
+
const gitignore = gitignoreFile.exists ? gitignoreFile.content : '';
|
|
174
|
+
const updatedGitignore = (0, bootstrapConfig_1.addRuntimeDeliveryBootstrapGitignoreRules)(gitignore);
|
|
175
|
+
if (updatedGitignore !== gitignore) {
|
|
172
176
|
changes.push({
|
|
173
177
|
file: '.gitignore',
|
|
174
|
-
original:
|
|
175
|
-
updated:
|
|
176
|
-
reason: '
|
|
178
|
+
original: gitignoreFile.exists ? gitignore : null,
|
|
179
|
+
updated: updatedGitignore,
|
|
180
|
+
reason: 'Commit the public trust bootstrap while ignoring generated runtime artifacts.',
|
|
177
181
|
});
|
|
178
182
|
}
|
|
179
183
|
return changes;
|
|
@@ -193,6 +197,7 @@ const assertSetupPathAllowed = (file) => {
|
|
|
193
197
|
const allowed = file === 'package.json' ||
|
|
194
198
|
file === '.fingerprintignore' ||
|
|
195
199
|
file === '.gitignore' ||
|
|
200
|
+
file === '.bundle-drop/runtime-delivery.generated.json' ||
|
|
196
201
|
file === 'bundle.drop.config.js' ||
|
|
197
202
|
file === 'app.json' ||
|
|
198
203
|
/^app\.config\.(js|ts|cjs|mjs)$/.test(file) ||
|
|
@@ -203,61 +208,47 @@ const assertSetupPathAllowed = (file) => {
|
|
|
203
208
|
};
|
|
204
209
|
function restoreExpoConfiguration(result) {
|
|
205
210
|
for (const changed of [...result.changedFiles].reverse()) {
|
|
206
|
-
const targetPath = path_1.default.join(result.projectRoot, changed.file);
|
|
207
|
-
const backupPath = path_1.default.join(result.backupDir, changed.file);
|
|
208
211
|
if (changed.existed) {
|
|
209
|
-
|
|
212
|
+
(0, safe_file_transaction_1.restoreProjectFile)(result.projectRoot, result.backupDir, changed.file);
|
|
210
213
|
}
|
|
211
|
-
else
|
|
212
|
-
|
|
214
|
+
else {
|
|
215
|
+
(0, safe_file_transaction_1.removeProjectFile)(result.projectRoot, changed.file);
|
|
213
216
|
}
|
|
214
217
|
}
|
|
215
218
|
if (result.buildReceiptInvalidated) {
|
|
216
219
|
const receiptFile = path_1.default.join('.bundle-drop', 'build-identity.json');
|
|
217
|
-
|
|
218
|
-
const backupPath = path_1.default.join(result.backupDir, receiptFile);
|
|
219
|
-
fs_extra_1.default.ensureDirSync(path_1.default.dirname(targetPath));
|
|
220
|
-
fs_extra_1.default.copyFileSync(backupPath, targetPath);
|
|
220
|
+
(0, safe_file_transaction_1.restoreProjectFile)(result.projectRoot, result.backupDir, receiptFile);
|
|
221
221
|
}
|
|
222
222
|
}
|
|
223
223
|
function applyExpoConfigurationChanges(params) {
|
|
224
224
|
const result = {
|
|
225
225
|
projectRoot: params.projectRoot,
|
|
226
|
-
backupDir:
|
|
226
|
+
backupDir: (0, safe_file_transaction_1.createSafeBackupDirectory)(params.projectRoot, 'expo-setup'),
|
|
227
227
|
changedFiles: [],
|
|
228
228
|
buildReceiptInvalidated: false,
|
|
229
229
|
};
|
|
230
230
|
try {
|
|
231
231
|
const receiptFile = path_1.default.join('.bundle-drop', 'build-identity.json');
|
|
232
|
-
const
|
|
233
|
-
if (
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
fs_extra_1.default.copyFileSync(receiptPath, backupPath);
|
|
237
|
-
fs_extra_1.default.unlinkSync(receiptPath);
|
|
232
|
+
const receipt = (0, safe_file_transaction_1.inspectProjectFile)(params.projectRoot, receiptFile);
|
|
233
|
+
if (receipt.exists) {
|
|
234
|
+
(0, safe_file_transaction_1.writeBackupFile)(result.backupDir, receiptFile, receipt.content, receipt.mode);
|
|
235
|
+
(0, safe_file_transaction_1.removeProjectFile)(params.projectRoot, receiptFile);
|
|
238
236
|
result.buildReceiptInvalidated = true;
|
|
239
237
|
}
|
|
240
238
|
for (const change of params.changes) {
|
|
241
239
|
assertSetupPathAllowed(change.file);
|
|
242
|
-
const
|
|
243
|
-
|
|
244
|
-
if (exists !== (change.original !== null)) {
|
|
240
|
+
const target = (0, safe_file_transaction_1.inspectProjectFile)(params.projectRoot, change.file);
|
|
241
|
+
if (target.exists !== (change.original !== null)) {
|
|
245
242
|
throw new Error(`File existence changed since Expo setup preview: ${change.file}`);
|
|
246
243
|
}
|
|
247
|
-
if (exists) {
|
|
248
|
-
|
|
249
|
-
if (sha256(current) !== sha256(change.original || '')) {
|
|
244
|
+
if (target.exists) {
|
|
245
|
+
if (sha256(target.content) !== sha256(change.original || '')) {
|
|
250
246
|
throw new Error(`File changed since Expo setup preview: ${change.file}`);
|
|
251
247
|
}
|
|
252
|
-
|
|
253
|
-
fs_extra_1.default.ensureDirSync(path_1.default.dirname(backupPath));
|
|
254
|
-
fs_extra_1.default.copyFileSync(targetPath, backupPath);
|
|
248
|
+
(0, safe_file_transaction_1.writeBackupFile)(result.backupDir, change.file, target.content, target.mode);
|
|
255
249
|
}
|
|
256
|
-
result.changedFiles.push({ file: change.file, existed: exists });
|
|
257
|
-
|
|
258
|
-
const temporaryPath = `${targetPath}.bundledrop-tmp`;
|
|
259
|
-
fs_extra_1.default.writeFileSync(temporaryPath, change.updated, 'utf8');
|
|
260
|
-
fs_extra_1.default.renameSync(temporaryPath, targetPath);
|
|
250
|
+
result.changedFiles.push({ file: change.file, existed: target.exists });
|
|
251
|
+
(0, safe_file_transaction_1.writeProjectFileAtomically)(params.projectRoot, change.file, change.updated, target.mode);
|
|
261
252
|
}
|
|
262
253
|
return result;
|
|
263
254
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export type SupportedPackageManager = 'npm' | 'yarn' | 'pnpm' | 'bun';
|
|
2
2
|
export declare function detectPackageManager(projectRoot: string): SupportedPackageManager;
|
|
3
3
|
export declare function expoUpdatesRemovalCommand(manager: SupportedPackageManager): string[];
|
|
4
|
+
export declare function codePushRemovalCommand(manager: SupportedPackageManager): string[];
|
|
4
5
|
export type DependencyMigrationBackup = {
|
|
5
6
|
projectRoot: string;
|
|
6
7
|
backupDir: string;
|
|
@@ -9,3 +10,4 @@ export type DependencyMigrationBackup = {
|
|
|
9
10
|
};
|
|
10
11
|
export declare function restoreDependencyMigration(backup: DependencyMigrationBackup): void;
|
|
11
12
|
export declare function removeExpoUpdatesWithPackageManager(projectRoot: string): DependencyMigrationBackup;
|
|
13
|
+
export declare function removeCodePushWithPackageManager(projectRoot: string): DependencyMigrationBackup;
|