@gfean/react-native-bundle-drop 0.5.1 → 0.7.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/BundleDrop.podspec +96 -0
- package/README.md +194 -5
- package/android/build.gradle +66 -0
- package/android/src/main/java/com/bundledrop/BundleDropBoundedDownloader.kt +86 -0
- package/android/src/main/java/com/bundledrop/BundleDropModule.kt +206 -13
- package/android/src/main/java/com/bundledrop/BundleDropNativePaths.kt +43 -13
- package/android/src/main/java/com/bundledrop/BundleDropOtaResolver.kt +35 -0
- package/android/src/main/java/com/bundledrop/BundleDropRuntimeCrypto.kt +81 -0
- package/android/src/main/java/com/bundledrop/BundleDropStartupRecovery.kt +1117 -0
- package/ios/BundleDropBridge.m +45 -0
- package/ios/BundleDropLocator.swift +66 -4
- package/ios/BundleDropModule.swift +181 -3
- package/ios/BundleDropOtaResolver.swift +137 -29
- package/ios/BundleDropRuntimeCrypto.swift +45 -0
- package/ios/BundleDropStartupRecovery.swift +1108 -0
- package/ios/BundleDropStartupRecoveryAdapter.swift +301 -0
- package/lib/CLI/cli.d.ts +1 -0
- package/lib/CLI/cli.js +57 -6
- 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 +162 -22
- package/lib/CLI/scripts/expo/configure-expo.js +52 -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 +198 -14
- package/lib/CLI/scripts/login-cli.js +31 -7
- 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/write-runtime-identity.d.ts +19 -0
- package/lib/CLI/scripts/native/write-runtime-identity.js +92 -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/CLI/scripts/upload-cli.d.ts +12 -2
- package/lib/CLI/scripts/upload-cli.js +74 -11
- package/lib/CLI/serverUrl.d.ts +3 -0
- package/lib/CLI/serverUrl.js +31 -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/bundleInfo.d.ts +2 -0
- package/lib/bundleInfo.js +16 -1
- package/lib/context.d.ts +1 -1
- package/lib/context.js +12 -2
- package/lib/fs/bundlePointer.d.ts +1 -17
- package/lib/fs/bundlePointer.js +5 -93
- package/lib/index.d.ts +2 -0
- package/lib/index.js +3 -1
- package/lib/install/bundleInstallShared.js +4 -4
- 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 +134 -66
- package/lib/manager/reporting.d.ts +8 -1
- package/lib/manager/reporting.js +17 -22
- package/lib/manager/rollbackState.d.ts +18 -52
- package/lib/manager/rollbackState.js +115 -216
- package/lib/manager/updateCheck.d.ts +1 -0
- package/lib/manager/updateCheck.js +224 -78
- package/lib/manager/updateState.d.ts +2 -1
- package/lib/manager/updateState.js +59 -6
- package/lib/metro.d.ts +8 -1
- package/lib/metro.js +69 -19
- package/lib/native/bundleDropNative.d.ts +62 -0
- package/lib/native/bundleDropNative.js +268 -2
- 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 +16 -5
- 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 +82 -67
- 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 +68 -0
- package/lib/runtime-delivery/bootstrapConfig.js +278 -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 +11 -0
- package/lib/runtime-delivery/manifestState.js +123 -0
- package/lib/runtime-delivery/manifestVerifier.d.ts +13 -0
- package/lib/runtime-delivery/manifestVerifier.js +335 -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/lib/scripts/bundle.d.ts +9 -2
- package/lib/scripts/bundle.js +68 -18
- package/lib/scripts/download-bundle.d.ts +1 -0
- package/lib/scripts/download-bundle.js +2 -2
- package/lib/scripts/resolveModule.d.ts +2 -0
- package/lib/scripts/resolveModule.js +5 -0
- package/package.json +5 -2
- package/plugin/xcodeBuildPhase.js +2 -1
|
@@ -1,63 +1,82 @@
|
|
|
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.detectPackageManager = detectPackageManager;
|
|
7
4
|
exports.expoUpdatesRemovalCommand = expoUpdatesRemovalCommand;
|
|
5
|
+
exports.codePushRemovalCommand = codePushRemovalCommand;
|
|
8
6
|
exports.restoreDependencyMigration = restoreDependencyMigration;
|
|
9
7
|
exports.removeExpoUpdatesWithPackageManager = removeExpoUpdatesWithPackageManager;
|
|
10
|
-
|
|
11
|
-
const path_1 = __importDefault(require("path"));
|
|
8
|
+
exports.removeCodePushWithPackageManager = removeCodePushWithPackageManager;
|
|
12
9
|
const child_process_1 = require("child_process");
|
|
10
|
+
const safe_file_transaction_1 = require("../safe-file-transaction");
|
|
13
11
|
const LOCKFILES = {
|
|
14
12
|
npm: ['package-lock.json', 'npm-shrinkwrap.json'],
|
|
15
13
|
yarn: ['yarn.lock'],
|
|
16
14
|
pnpm: ['pnpm-lock.yaml'],
|
|
17
15
|
bun: ['bun.lock', 'bun.lockb'],
|
|
18
16
|
};
|
|
17
|
+
const inspectPackageManagerInputs = (projectRoot) => {
|
|
18
|
+
const packageFile = (0, safe_file_transaction_1.inspectProjectFile)(projectRoot, 'package.json');
|
|
19
|
+
if (!packageFile.exists)
|
|
20
|
+
throw new Error('package.json is required for dependency migration.');
|
|
21
|
+
const lockfiles = new Set();
|
|
22
|
+
for (const lockfile of [...new Set(Object.values(LOCKFILES).flat())]) {
|
|
23
|
+
if ((0, safe_file_transaction_1.inspectProjectFile)(projectRoot, lockfile).exists)
|
|
24
|
+
lockfiles.add(lockfile);
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
packageJson: JSON.parse(packageFile.content),
|
|
28
|
+
lockfiles,
|
|
29
|
+
};
|
|
30
|
+
};
|
|
19
31
|
function detectPackageManager(projectRoot) {
|
|
20
|
-
const packageJson =
|
|
32
|
+
const { packageJson, lockfiles } = inspectPackageManagerInputs(projectRoot);
|
|
21
33
|
const declared = packageJson.packageManager?.split('@')[0];
|
|
22
34
|
if (declared && declared in LOCKFILES)
|
|
23
35
|
return declared;
|
|
24
36
|
for (const manager of ['pnpm', 'yarn', 'bun', 'npm']) {
|
|
25
|
-
if (LOCKFILES[manager].some(lockfile =>
|
|
37
|
+
if (LOCKFILES[manager].some(lockfile => lockfiles.has(lockfile))) {
|
|
26
38
|
return manager;
|
|
27
39
|
}
|
|
28
40
|
}
|
|
29
41
|
return 'npm';
|
|
30
42
|
}
|
|
31
|
-
|
|
43
|
+
const dependencyRemovalCommand = (manager, dependency) => {
|
|
32
44
|
return manager === 'npm'
|
|
33
|
-
? ['npm', 'uninstall',
|
|
34
|
-
: [manager, 'remove',
|
|
45
|
+
? ['npm', 'uninstall', dependency, '--legacy-peer-deps']
|
|
46
|
+
: [manager, 'remove', dependency];
|
|
47
|
+
};
|
|
48
|
+
function expoUpdatesRemovalCommand(manager) {
|
|
49
|
+
return dependencyRemovalCommand(manager, 'expo-updates');
|
|
50
|
+
}
|
|
51
|
+
function codePushRemovalCommand(manager) {
|
|
52
|
+
return dependencyRemovalCommand(manager, 'react-native-code-push');
|
|
35
53
|
}
|
|
36
54
|
function restoreDependencyMigration(backup) {
|
|
37
55
|
for (const file of backup.files) {
|
|
38
|
-
|
|
56
|
+
(0, safe_file_transaction_1.restoreProjectFile)(backup.projectRoot, backup.backupDir, file);
|
|
39
57
|
}
|
|
40
58
|
for (const file of backup.possibleCreatedFiles) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
fs_extra_1.default.unlinkSync(targetPath);
|
|
59
|
+
if (!backup.files.includes(file)) {
|
|
60
|
+
(0, safe_file_transaction_1.removeProjectFile)(backup.projectRoot, file);
|
|
44
61
|
}
|
|
45
62
|
}
|
|
46
63
|
}
|
|
47
|
-
|
|
64
|
+
const removeDependencyWithPackageManager = (params) => {
|
|
65
|
+
const { projectRoot, dependency, backupName } = params;
|
|
48
66
|
const manager = detectPackageManager(projectRoot);
|
|
49
|
-
const command =
|
|
50
|
-
const files = ['package.json', ...LOCKFILES[manager]].filter(file =>
|
|
67
|
+
const command = dependencyRemovalCommand(manager, dependency);
|
|
68
|
+
const files = ['package.json', ...LOCKFILES[manager]].filter(file => (0, safe_file_transaction_1.inspectProjectFile)(projectRoot, file).exists);
|
|
51
69
|
const backup = {
|
|
52
70
|
projectRoot,
|
|
53
|
-
backupDir:
|
|
71
|
+
backupDir: (0, safe_file_transaction_1.createSafeBackupDirectory)(projectRoot, backupName),
|
|
54
72
|
files,
|
|
55
73
|
possibleCreatedFiles: LOCKFILES[manager],
|
|
56
74
|
};
|
|
57
75
|
for (const file of files) {
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
76
|
+
const target = (0, safe_file_transaction_1.inspectProjectFile)(projectRoot, file);
|
|
77
|
+
if (!target.exists)
|
|
78
|
+
throw new Error(`Package file disappeared before migration: ${file}`);
|
|
79
|
+
(0, safe_file_transaction_1.writeBackupFile)(backup.backupDir, file, target.content, target.mode);
|
|
61
80
|
}
|
|
62
81
|
const result = (0, child_process_1.spawnSync)(command[0], command.slice(1), {
|
|
63
82
|
cwd: projectRoot,
|
|
@@ -66,19 +85,38 @@ function removeExpoUpdatesWithPackageManager(projectRoot) {
|
|
|
66
85
|
});
|
|
67
86
|
if (result.error || result.status !== 0) {
|
|
68
87
|
restoreDependencyMigration(backup);
|
|
69
|
-
throw new Error(`Failed to remove
|
|
88
|
+
throw new Error(`Failed to remove ${dependency} with ${manager}. Package files were restored; ` +
|
|
70
89
|
'run your package manager install if node_modules needs repair.');
|
|
71
90
|
}
|
|
72
|
-
const
|
|
91
|
+
const migratedPackage = (0, safe_file_transaction_1.inspectProjectFile)(projectRoot, 'package.json');
|
|
92
|
+
if (!migratedPackage.exists) {
|
|
93
|
+
restoreDependencyMigration(backup);
|
|
94
|
+
throw new Error(`${manager} completed but package.json is missing.`);
|
|
95
|
+
}
|
|
96
|
+
const packageJson = JSON.parse(migratedPackage.content);
|
|
73
97
|
const stillDeclared = [
|
|
74
98
|
packageJson.dependencies,
|
|
75
99
|
packageJson.devDependencies,
|
|
76
100
|
packageJson.optionalDependencies,
|
|
77
101
|
packageJson.peerDependencies,
|
|
78
|
-
].some(dependencies => Boolean(dependencies?.[
|
|
102
|
+
].some(dependencies => Boolean(dependencies?.[dependency]));
|
|
79
103
|
if (stillDeclared) {
|
|
80
104
|
restoreDependencyMigration(backup);
|
|
81
|
-
throw new Error(`${manager} completed but
|
|
105
|
+
throw new Error(`${manager} completed but ${dependency} is still declared in package.json.`);
|
|
82
106
|
}
|
|
83
107
|
return backup;
|
|
108
|
+
};
|
|
109
|
+
function removeExpoUpdatesWithPackageManager(projectRoot) {
|
|
110
|
+
return removeDependencyWithPackageManager({
|
|
111
|
+
projectRoot,
|
|
112
|
+
dependency: 'expo-updates',
|
|
113
|
+
backupName: 'expo-updates',
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
function removeCodePushWithPackageManager(projectRoot) {
|
|
117
|
+
return removeDependencyWithPackageManager({
|
|
118
|
+
projectRoot,
|
|
119
|
+
dependency: 'react-native-code-push',
|
|
120
|
+
backupName: 'code-push',
|
|
121
|
+
});
|
|
84
122
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ProjectType } from '../../expo';
|
|
2
|
+
import { type RuntimeDeliveryBootstrapLockfile } from '../../runtime-delivery/bootstrapConfig';
|
|
2
3
|
type Project = {
|
|
3
4
|
name: string;
|
|
4
5
|
slug: string;
|
|
@@ -9,6 +10,7 @@ type Org = {
|
|
|
9
10
|
orgId: string;
|
|
10
11
|
name: string;
|
|
11
12
|
};
|
|
13
|
+
export { normalizeRuntimeDeliveryBootstrap } from '../../runtime-delivery/bootstrapConfig';
|
|
12
14
|
export declare function getBundleDropConfigPath(startDir?: string): string;
|
|
13
15
|
export declare function hasExistingBundleDropConfig(startDir?: string): boolean;
|
|
14
16
|
export declare function initConfig(params: {
|
|
@@ -20,13 +22,11 @@ export declare function initConfig(params: {
|
|
|
20
22
|
dryRun?: boolean;
|
|
21
23
|
projectType?: ProjectType;
|
|
22
24
|
}): Promise<{
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
projectSlug?: undefined;
|
|
29
|
-
} | {
|
|
25
|
+
bootstrapPath?: string;
|
|
26
|
+
bootstrapContent?: string;
|
|
27
|
+
bootstrap?: RuntimeDeliveryBootstrapLockfile;
|
|
28
|
+
runtimeDeliveryAvailable?: boolean;
|
|
29
|
+
bootstrapRetired?: boolean;
|
|
30
30
|
configPath: string;
|
|
31
31
|
content: string;
|
|
32
32
|
created: boolean;
|
|
@@ -3,18 +3,72 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.normalizeRuntimeDeliveryBootstrap = void 0;
|
|
6
7
|
exports.getBundleDropConfigPath = getBundleDropConfigPath;
|
|
7
8
|
exports.hasExistingBundleDropConfig = hasExistingBundleDropConfig;
|
|
8
9
|
exports.initConfig = initConfig;
|
|
9
10
|
const axios_1 = __importDefault(require("axios"));
|
|
10
11
|
const chalk_1 = __importDefault(require("chalk"));
|
|
11
12
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
13
|
+
const module_1 = require("module");
|
|
12
14
|
const path_1 = __importDefault(require("path"));
|
|
13
15
|
const prompts_1 = __importDefault(require("prompts"));
|
|
16
|
+
const bootstrapConfig_1 = require("../../runtime-delivery/bootstrapConfig");
|
|
17
|
+
const safe_file_transaction_1 = require("./safe-file-transaction");
|
|
18
|
+
const serverUrl_1 = require("../serverUrl");
|
|
14
19
|
const DOCS_PROJECT_CREATION_URL = 'https://bundledrop.app/docs/project-creation';
|
|
15
20
|
const DOCS_INSTALLATION_URL = 'https://bundledrop.app/docs/installation';
|
|
16
|
-
|
|
17
|
-
|
|
21
|
+
var bootstrapConfig_2 = require("../../runtime-delivery/bootstrapConfig");
|
|
22
|
+
Object.defineProperty(exports, "normalizeRuntimeDeliveryBootstrap", { enumerable: true, get: function () { return bootstrapConfig_2.normalizeRuntimeDeliveryBootstrap; } });
|
|
23
|
+
function isRecord(value) {
|
|
24
|
+
return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
|
|
25
|
+
}
|
|
26
|
+
function validateProjectCredentials(value, expected) {
|
|
27
|
+
if (!isRecord(value)) {
|
|
28
|
+
throw new Error('Project credentials response is malformed. Existing local credentials were preserved.');
|
|
29
|
+
}
|
|
30
|
+
const projectId = typeof value.projectId === 'string' ? value.projectId.trim() : '';
|
|
31
|
+
const projectSlug = typeof value.projectSlug === 'string' ? value.projectSlug.trim() : '';
|
|
32
|
+
const orgId = typeof value.orgId === 'string' ? value.orgId.trim() : '';
|
|
33
|
+
const orgSlug = typeof value.orgSlug === 'string' ? value.orgSlug.trim() : '';
|
|
34
|
+
const runtimeDeliveryMode = value.runtimeDeliveryMode;
|
|
35
|
+
const downloadApiKey = value.downloadApiKey;
|
|
36
|
+
const downloadKeyHint = value.downloadKeyHint;
|
|
37
|
+
if (!projectId || !projectSlug || !orgId || !orgSlug) {
|
|
38
|
+
throw new Error('Project credentials response is missing its authoritative project identity. ' +
|
|
39
|
+
'Existing local credentials were preserved.');
|
|
40
|
+
}
|
|
41
|
+
if (runtimeDeliveryMode !== undefined &&
|
|
42
|
+
!['v1', 'shadow', 'v2'].includes(runtimeDeliveryMode)) {
|
|
43
|
+
throw new Error('Project credentials response contains an invalid legacy runtime delivery mode. ' +
|
|
44
|
+
'Existing local credentials were preserved.');
|
|
45
|
+
}
|
|
46
|
+
if (projectSlug !== expected.projectSlug || orgSlug !== expected.orgSlug) {
|
|
47
|
+
throw new Error(`Project credentials identity mismatch: expected ${expected.orgSlug}/${expected.projectSlug}, ` +
|
|
48
|
+
`received ${orgSlug}/${projectSlug}. Existing local credentials were preserved.`);
|
|
49
|
+
}
|
|
50
|
+
if (downloadApiKey !== undefined && typeof downloadApiKey !== 'string') {
|
|
51
|
+
throw new Error('Project credentials response contains an invalid download key. Existing local credentials were preserved.');
|
|
52
|
+
}
|
|
53
|
+
if (downloadKeyHint !== undefined &&
|
|
54
|
+
downloadKeyHint !== null &&
|
|
55
|
+
typeof downloadKeyHint !== 'string') {
|
|
56
|
+
throw new Error('Project credentials response contains an invalid download key hint. Existing local credentials were preserved.');
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
projectId,
|
|
60
|
+
projectSlug,
|
|
61
|
+
orgId,
|
|
62
|
+
orgSlug,
|
|
63
|
+
runtimeDeliveryMode: runtimeDeliveryMode,
|
|
64
|
+
downloadApiKey: typeof downloadApiKey === 'string' ? downloadApiKey : undefined,
|
|
65
|
+
downloadKeyHint: typeof downloadKeyHint === 'string'
|
|
66
|
+
? downloadKeyHint
|
|
67
|
+
: downloadKeyHint === null
|
|
68
|
+
? null
|
|
69
|
+
: undefined,
|
|
70
|
+
runtimeDelivery: value.runtimeDelivery,
|
|
71
|
+
};
|
|
18
72
|
}
|
|
19
73
|
function createBundleDropConfig(values) {
|
|
20
74
|
const projectTypeConfig = values.projectType
|
|
@@ -61,23 +115,111 @@ ${projectTypeConfig} serverUrl: ${JSON.stringify(values.serverUrl)},
|
|
|
61
115
|
`;
|
|
62
116
|
}
|
|
63
117
|
async function fetchProjectCredentials(params) {
|
|
64
|
-
const baseUrl = normalizeServerUrl(params.serverUrl);
|
|
65
|
-
const url = `${baseUrl}/projects/${encodeURIComponent(params.projectSlug)}/credentials
|
|
118
|
+
const baseUrl = (0, serverUrl_1.normalizeServerUrl)(params.serverUrl);
|
|
119
|
+
const url = `${baseUrl}/projects/${encodeURIComponent(params.projectSlug)}/credentials` +
|
|
120
|
+
`?orgSlug=${encodeURIComponent(params.orgSlug)}`;
|
|
121
|
+
let response;
|
|
66
122
|
try {
|
|
67
|
-
|
|
123
|
+
response = await axios_1.default.get(url, {
|
|
68
124
|
headers: {
|
|
69
125
|
Accept: 'application/json',
|
|
70
126
|
Authorization: `Bearer ${params.authToken}`,
|
|
71
127
|
},
|
|
72
128
|
timeout: 15000,
|
|
73
129
|
});
|
|
74
|
-
return res.data || null;
|
|
75
130
|
}
|
|
76
131
|
catch (err) {
|
|
77
132
|
console.log(chalk_1.default.yellow(`⚠️ Failed to fetch project credentials from ${url}. Please verify login and project access.\n` +
|
|
78
133
|
`If the project is not set up yet, see ${DOCS_PROJECT_CREATION_URL}`));
|
|
79
134
|
return null;
|
|
80
135
|
}
|
|
136
|
+
return validateProjectCredentials(response.data, {
|
|
137
|
+
orgSlug: params.orgSlug,
|
|
138
|
+
projectSlug: params.projectSlug,
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
function createBootstrapResult(params) {
|
|
142
|
+
if (!params.credentials)
|
|
143
|
+
return {};
|
|
144
|
+
const legacyMode = params.credentials.runtimeDeliveryMode;
|
|
145
|
+
if (params.credentials.runtimeDelivery === null ||
|
|
146
|
+
legacyMode === 'v1' ||
|
|
147
|
+
legacyMode === 'shadow') {
|
|
148
|
+
return {
|
|
149
|
+
runtimeDeliveryAvailable: false,
|
|
150
|
+
bootstrapRetired: true,
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
const bootstrap = (0, bootstrapConfig_1.createRuntimeDeliveryBootstrapLockfile)({
|
|
154
|
+
identity: {
|
|
155
|
+
serverUrl: params.serverUrl,
|
|
156
|
+
orgSlug: params.orgSlug,
|
|
157
|
+
projectSlug: params.projectSlug,
|
|
158
|
+
projectId: params.credentials.projectId,
|
|
159
|
+
orgId: params.credentials.orgId,
|
|
160
|
+
},
|
|
161
|
+
runtimeDelivery: params.credentials.runtimeDelivery,
|
|
162
|
+
});
|
|
163
|
+
if (!bootstrap) {
|
|
164
|
+
return legacyMode === 'v2' || params.credentials.runtimeDelivery !== undefined
|
|
165
|
+
? { runtimeDeliveryAvailable: true }
|
|
166
|
+
: {};
|
|
167
|
+
}
|
|
168
|
+
return {
|
|
169
|
+
bootstrap,
|
|
170
|
+
bootstrapPath: (0, bootstrapConfig_1.runtimeDeliveryBootstrapPath)(params.projectRoot),
|
|
171
|
+
bootstrapContent: (0, bootstrapConfig_1.serializeRuntimeDeliveryBootstrapLockfile)(bootstrap),
|
|
172
|
+
runtimeDeliveryAvailable: true,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
async function persistBootstrap(projectRoot, result) {
|
|
176
|
+
if (result.bootstrap) {
|
|
177
|
+
const bootstrapPath = await (0, bootstrapConfig_1.writeRuntimeDeliveryBootstrapLockfile)({
|
|
178
|
+
projectRoot,
|
|
179
|
+
bootstrap: result.bootstrap,
|
|
180
|
+
});
|
|
181
|
+
const persisted = (0, bootstrapConfig_1.readRuntimeDeliveryLockfile)({
|
|
182
|
+
projectRoot,
|
|
183
|
+
expectedIdentity: result.bootstrap.project,
|
|
184
|
+
});
|
|
185
|
+
if (!persisted ||
|
|
186
|
+
(0, bootstrapConfig_1.serializeRuntimeDeliveryBootstrapLockfile)(persisted) !==
|
|
187
|
+
(0, bootstrapConfig_1.serializeRuntimeDeliveryBootstrapLockfile)(result.bootstrap)) {
|
|
188
|
+
throw new Error('Runtime delivery lockfile validation failed after writing. The legacy bootstrap was preserved.');
|
|
189
|
+
}
|
|
190
|
+
await (0, bootstrapConfig_1.removeLegacyRuntimeDeliveryBootstrap)(projectRoot);
|
|
191
|
+
await (0, bootstrapConfig_1.ensureRuntimeDeliveryBootstrapGitignore)(projectRoot);
|
|
192
|
+
console.log(chalk_1.default.green(`✅ Synced Bundle Drop runtime delivery lockfile at ${bootstrapPath}`));
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
if (result.bootstrapRetired) {
|
|
196
|
+
const removedPaths = await (0, bootstrapConfig_1.removeAllRuntimeDeliveryBootstraps)(projectRoot);
|
|
197
|
+
console.log(chalk_1.default.green(removedPaths.length
|
|
198
|
+
? `✅ Removed runtime delivery bootstrap files because delivery is disabled for this project: ${removedPaths.join(', ')}`
|
|
199
|
+
: '✅ Runtime delivery is disabled for this project; no bootstrap file is present.'));
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
function loadExistingConfig(configPath, content) {
|
|
203
|
+
try {
|
|
204
|
+
const moduleLike = { exports: {} };
|
|
205
|
+
const localRequire = (0, module_1.createRequire)(configPath);
|
|
206
|
+
const load = new Function('module', 'exports', 'require', '__dirname', '__filename', content);
|
|
207
|
+
load(moduleLike, moduleLike.exports, localRequire, path_1.default.dirname(configPath), configPath);
|
|
208
|
+
const config = moduleLike.exports;
|
|
209
|
+
if (!config.serverUrl || !config.org?.slug || !config.project?.slug)
|
|
210
|
+
return null;
|
|
211
|
+
return {
|
|
212
|
+
projectType: config.projectType,
|
|
213
|
+
serverUrl: (0, serverUrl_1.normalizeServerUrl)(config.serverUrl),
|
|
214
|
+
orgSlug: config.org.slug,
|
|
215
|
+
projectName: config.project.name || '',
|
|
216
|
+
projectSlug: config.project.slug,
|
|
217
|
+
apiKey: config.project.apiKey || '',
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
catch {
|
|
221
|
+
return null;
|
|
222
|
+
}
|
|
81
223
|
}
|
|
82
224
|
function findProjectRoot(startDir) {
|
|
83
225
|
let dir = path_1.default.resolve(startDir);
|
|
@@ -101,13 +243,43 @@ function hasExistingBundleDropConfig(startDir = process.cwd()) {
|
|
|
101
243
|
}
|
|
102
244
|
async function initConfig(params) {
|
|
103
245
|
const configPath = getBundleDropConfigPath();
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
246
|
+
const projectRoot = path_1.default.dirname(configPath);
|
|
247
|
+
const existingConfigFile = (0, safe_file_transaction_1.inspectProjectFile)(projectRoot, 'bundle.drop.config.js');
|
|
248
|
+
if (existingConfigFile.exists) {
|
|
249
|
+
const existing = loadExistingConfig(configPath, existingConfigFile.content);
|
|
250
|
+
let bootstrapResult = {};
|
|
251
|
+
if (existing && params.authToken) {
|
|
252
|
+
(0, serverUrl_1.assertMatchingServerOrigin)(existing.serverUrl, params.serverUrl);
|
|
253
|
+
const credentials = await fetchProjectCredentials({
|
|
254
|
+
serverUrl: existing.serverUrl,
|
|
255
|
+
orgSlug: existing.orgSlug,
|
|
256
|
+
projectSlug: existing.projectSlug,
|
|
257
|
+
authToken: params.authToken,
|
|
258
|
+
});
|
|
259
|
+
bootstrapResult = createBootstrapResult({
|
|
260
|
+
projectRoot,
|
|
261
|
+
serverUrl: existing.serverUrl,
|
|
262
|
+
orgSlug: existing.orgSlug,
|
|
263
|
+
projectSlug: existing.projectSlug,
|
|
264
|
+
credentials,
|
|
265
|
+
});
|
|
266
|
+
if (!params.dryRun)
|
|
267
|
+
await persistBootstrap(projectRoot, bootstrapResult);
|
|
268
|
+
}
|
|
269
|
+
console.log(chalk_1.default.yellow(`ℹ️ Preserving existing bundle.drop.config.js at ${configPath}.` +
|
|
270
|
+
(bootstrapResult.bootstrap
|
|
271
|
+
? ' Runtime delivery bootstrap is ready to sync.'
|
|
272
|
+
: bootstrapResult.bootstrapRetired
|
|
273
|
+
? ' Runtime delivery setup is synchronized.'
|
|
274
|
+
: ` No valid runtime delivery bootstrap was returned; see ${DOCS_INSTALLATION_URL}`)));
|
|
107
275
|
return {
|
|
108
276
|
configPath,
|
|
109
|
-
content:
|
|
277
|
+
content: existingConfigFile.content,
|
|
110
278
|
created: false,
|
|
279
|
+
serverUrl: existing?.serverUrl,
|
|
280
|
+
orgSlug: existing?.orgSlug,
|
|
281
|
+
projectSlug: existing?.projectSlug,
|
|
282
|
+
...bootstrapResult,
|
|
111
283
|
};
|
|
112
284
|
}
|
|
113
285
|
let orgSlug = '';
|
|
@@ -172,11 +344,13 @@ async function initConfig(params) {
|
|
|
172
344
|
if (org)
|
|
173
345
|
orgSlug = org.slug;
|
|
174
346
|
}
|
|
175
|
-
let resolvedServerUrl = normalizeServerUrl(params.serverUrl);
|
|
176
|
-
let apiKey = params.downloadApiKey || '';
|
|
347
|
+
let resolvedServerUrl = (0, serverUrl_1.normalizeServerUrl)(params.serverUrl);
|
|
348
|
+
let apiKey = params.authToken ? '' : params.downloadApiKey || '';
|
|
349
|
+
let credentials = null;
|
|
177
350
|
if (projectSlug && params.authToken) {
|
|
178
|
-
|
|
351
|
+
credentials = await fetchProjectCredentials({
|
|
179
352
|
serverUrl: resolvedServerUrl,
|
|
353
|
+
orgSlug,
|
|
180
354
|
projectSlug,
|
|
181
355
|
authToken: params.authToken,
|
|
182
356
|
});
|
|
@@ -211,9 +385,18 @@ async function initConfig(params) {
|
|
|
211
385
|
console.log(chalk_1.default.cyan(`Dry-run bundle.drop.config.js preview:\n${previewContent}`));
|
|
212
386
|
}
|
|
213
387
|
else {
|
|
214
|
-
|
|
388
|
+
(0, safe_file_transaction_1.writeProjectFileAtomically)(projectRoot, 'bundle.drop.config.js', content);
|
|
215
389
|
console.log(chalk_1.default.green(`✅ Created bundle.drop.config.js at ${configPath}`));
|
|
216
390
|
}
|
|
391
|
+
const bootstrapResult = createBootstrapResult({
|
|
392
|
+
projectRoot,
|
|
393
|
+
serverUrl: resolvedServerUrl,
|
|
394
|
+
orgSlug,
|
|
395
|
+
projectSlug,
|
|
396
|
+
credentials,
|
|
397
|
+
});
|
|
398
|
+
if (!params.dryRun)
|
|
399
|
+
await persistBootstrap(projectRoot, bootstrapResult);
|
|
217
400
|
return {
|
|
218
401
|
configPath,
|
|
219
402
|
content,
|
|
@@ -221,6 +404,7 @@ async function initConfig(params) {
|
|
|
221
404
|
serverUrl: resolvedServerUrl,
|
|
222
405
|
orgSlug,
|
|
223
406
|
projectSlug,
|
|
407
|
+
...bootstrapResult,
|
|
224
408
|
};
|
|
225
409
|
}
|
|
226
410
|
exports.default = initConfig;
|
|
@@ -15,11 +15,10 @@ const child_process_1 = require("child_process");
|
|
|
15
15
|
const init_config_1 = require("./init-config");
|
|
16
16
|
const post_init_1 = require("./post-init");
|
|
17
17
|
const expo_1 = require("../../expo");
|
|
18
|
+
const serverUrl_1 = require("../serverUrl");
|
|
18
19
|
const LOGIN_TIMEOUT_MS = 10 * 60 * 1000;
|
|
19
20
|
const DOCS_MANUAL_SETUP_URL = 'https://bundledrop.app/docs/manual-setup';
|
|
20
|
-
const getBaseUrl = () => process.env.BUNDLE_DROP_SERVER_URL
|
|
21
|
-
? process.env.BUNDLE_DROP_SERVER_URL.replace(/\/$/, '')
|
|
22
|
-
: 'https://api.bundledrop.app';
|
|
21
|
+
const getBaseUrl = () => (0, serverUrl_1.normalizeServerUrl)(process.env.BUNDLE_DROP_SERVER_URL);
|
|
23
22
|
exports.getBaseUrl = getBaseUrl;
|
|
24
23
|
const getClientName = () => {
|
|
25
24
|
const hostname = os_1.default.hostname();
|
|
@@ -267,8 +266,16 @@ const login = async () => {
|
|
|
267
266
|
});
|
|
268
267
|
loginCompleted = true;
|
|
269
268
|
console.log(chalk_1.default.green('✅ Logged in successfully as:'), chalk_1.default.cyan(`${authFile.user.firstName} ${authFile.user.lastName}`));
|
|
270
|
-
|
|
271
|
-
|
|
269
|
+
const hadConfig = (0, init_config_1.hasExistingBundleDropConfig)();
|
|
270
|
+
if (hadConfig) {
|
|
271
|
+
await (0, init_config_1.initConfig)({
|
|
272
|
+
serverUrl: baseUrl,
|
|
273
|
+
projects: authFile.projects,
|
|
274
|
+
organizations: authFile.organizations,
|
|
275
|
+
downloadApiKey: authFile.downloadApiKey,
|
|
276
|
+
authToken: authFile.token,
|
|
277
|
+
dryRun: false,
|
|
278
|
+
});
|
|
272
279
|
return;
|
|
273
280
|
}
|
|
274
281
|
const projectType = (0, expo_1.detectProjectType)({ projectRoot: process.cwd() });
|
|
@@ -278,12 +285,29 @@ const login = async () => {
|
|
|
278
285
|
organizations: authFile.organizations,
|
|
279
286
|
downloadApiKey: authFile.downloadApiKey,
|
|
280
287
|
authToken: authFile.token,
|
|
288
|
+
dryRun: true,
|
|
281
289
|
projectType,
|
|
282
290
|
});
|
|
283
|
-
if (configResult
|
|
291
|
+
if (configResult && fs_extra_1.default.existsSync(configResult.configPath)) {
|
|
284
292
|
createdConfigPath = configResult.configPath;
|
|
285
293
|
}
|
|
286
|
-
await (0, post_init_1.runPostInitPrompts)({
|
|
294
|
+
await (0, post_init_1.runPostInitPrompts)({
|
|
295
|
+
projectType,
|
|
296
|
+
...(configResult?.bootstrapContent
|
|
297
|
+
? { runtimeDeliveryBootstrap: { content: configResult.bootstrapContent } }
|
|
298
|
+
: {}),
|
|
299
|
+
...(configResult
|
|
300
|
+
? {
|
|
301
|
+
virtualConfig: {
|
|
302
|
+
content: configResult.content,
|
|
303
|
+
serverUrl: configResult.serverUrl,
|
|
304
|
+
orgSlug: configResult.orgSlug,
|
|
305
|
+
projectSlug: configResult.projectSlug,
|
|
306
|
+
authToken: authFile.token,
|
|
307
|
+
},
|
|
308
|
+
}
|
|
309
|
+
: {}),
|
|
310
|
+
});
|
|
287
311
|
}
|
|
288
312
|
catch (error) {
|
|
289
313
|
const message = axios_1.default.isAxiosError(error)
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const METRO_CONFIG_FILES: readonly ["metro.config.js", "metro.config.cjs", "metro.config.mjs", "metro.config.ts"];
|
|
2
|
+
export type MetroWrapper = 'withBundleDrop' | 'withBundleDropExpo';
|
|
3
|
+
export declare const hasExecutableMetroWrapperReference: (source: string, wrapper: MetroWrapper) => boolean;
|
|
4
|
+
export declare const hasExecutableMetroModuleReference: (source: string, moduleName: string) => boolean;
|
|
5
|
+
export declare const hasAuthoritativeMetroWrapper: (source: string, wrapper: MetroWrapper) => boolean;
|
|
6
|
+
export declare const findSingleMetroConfig: (projectRoot: string) => "metro.config.js" | "metro.config.cjs" | "metro.config.mjs" | "metro.config.ts";
|
|
7
|
+
export declare const newCommonJsMetroConfigFile: (projectRoot: string) => "metro.config.js" | "metro.config.cjs";
|
|
8
|
+
export declare const assertCommonJsMetroConfig: (projectRoot: string, relativePath: string) => void;
|