@gfean/react-native-bundle-drop 0.12.1 → 0.13.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 +1 -1
- package/lib/CLI/cli.js +9 -2
- package/lib/CLI/scripts/aipowered/apply-setup-plan.d.ts +2 -0
- package/lib/CLI/scripts/aipowered/apply-setup-plan.js +6 -3
- package/lib/CLI/scripts/aipowered/backend-client.d.ts +6 -4
- package/lib/CLI/scripts/aipowered/backend-client.js +5 -1
- package/lib/CLI/scripts/aipowered/code-push-residue.d.ts +1 -1
- package/lib/CLI/scripts/aipowered/code-push-residue.js +11 -5
- package/lib/CLI/scripts/aipowered/init-project-config.js +47 -36
- package/lib/CLI/scripts/aipowered/native-setup-context.d.ts +20 -0
- package/lib/CLI/scripts/aipowered/native-setup-context.js +242 -0
- package/lib/CLI/scripts/aipowered/native-setup-metadata.d.ts +16 -0
- package/lib/CLI/scripts/aipowered/native-setup-metadata.js +104 -0
- package/lib/CLI/scripts/aipowered/scanner.d.ts +7 -3
- package/lib/CLI/scripts/aipowered/scanner.js +96 -30
- package/lib/CLI/scripts/aipowered/setup-v2.d.ts +3 -0
- package/lib/CLI/scripts/aipowered/setup-v2.js +53 -0
- package/lib/CLI/scripts/aipowered/types.d.ts +11 -1
- package/lib/CLI/scripts/aipowered/validate-plan.d.ts +3 -1
- package/lib/CLI/scripts/aipowered/validate-plan.js +10 -4
- package/lib/CLI/scripts/doctor.js +18 -6
- package/lib/CLI/scripts/expo/eas-build-proof.js +8 -2
- package/lib/CLI/scripts/expo/package-manager.d.ts +1 -0
- package/lib/CLI/scripts/expo/package-manager.js +7 -3
- package/lib/CLI/scripts/ios-scene-target.d.ts +9 -0
- package/lib/CLI/scripts/ios-scene-target.js +193 -0
- package/lib/CLI/scripts/native-entrypoint-authority.d.ts +1 -0
- package/lib/CLI/scripts/native-entrypoint-authority.js +24 -0
- package/lib/CLI/scripts/native-setup-contract.d.ts +4 -0
- package/lib/CLI/scripts/native-setup-contract.js +28 -14
- package/lib/CLI/scripts/native-startup-validator.d.ts +4 -1
- package/lib/CLI/scripts/native-startup-validator.js +83 -6
- package/lib/CLI/scripts/safe-file-transaction.d.ts +1 -1
- package/lib/CLI/scripts/safe-file-transaction.js +3 -3
- package/lib/CLI/utils/read-xml-plist.d.ts +2 -1
- package/lib/CLI/utils/read-xml-plist.js +7 -3
- package/lib/expo/buildIdentity.js +1 -1
- package/lib/injectImageResolver.js +7 -2
- package/package.json +2 -2
- package/third_party/expo-fingerprint/scheme-1-contract.json +1 -1
|
@@ -19,6 +19,12 @@ const requiredString = (value, field) => {
|
|
|
19
19
|
}
|
|
20
20
|
return value;
|
|
21
21
|
};
|
|
22
|
+
const requiredAliasedString = (legacyValue, currentValue, legacyField, currentField) => {
|
|
23
|
+
if (legacyValue != null && currentValue != null && legacyValue !== currentValue) {
|
|
24
|
+
throw new Error(`Official EAS build metadata has conflicting values for ${legacyField} and ${currentField}.`);
|
|
25
|
+
}
|
|
26
|
+
return requiredString(currentValue ?? legacyValue, currentValue == null ? legacyField : currentField);
|
|
27
|
+
};
|
|
22
28
|
const readOfficialBuild = (projectRoot, buildId) => {
|
|
23
29
|
if (!EAS_BUILD_ID.test(buildId)) {
|
|
24
30
|
throw new Error('Bundle Drop EAS build proof contains an invalid build ID.');
|
|
@@ -60,11 +66,11 @@ async function resolveOfficialEasBuild(params) {
|
|
|
60
66
|
const buildId = requiredString(build.id, 'id');
|
|
61
67
|
const status = requiredString(build.status, 'status');
|
|
62
68
|
const platform = requiredString(build.platform, 'platform').toLowerCase();
|
|
63
|
-
const projectId =
|
|
69
|
+
const projectId = requiredAliasedString(build.project?.id, build.app?.id, 'project.id', 'app.id');
|
|
64
70
|
const sdkVersion = requiredString(build.sdkVersion, 'sdkVersion');
|
|
65
71
|
const appVersion = requiredString(build.appVersion, 'appVersion');
|
|
66
72
|
const appBuildVersion = requiredString(build.appBuildVersion, 'appBuildVersion');
|
|
67
|
-
const runtimeVersion =
|
|
73
|
+
const runtimeVersion = requiredAliasedString(build.runtimeVersion, build.runtime?.version, 'runtimeVersion', 'runtime.version');
|
|
68
74
|
const gitCommitHash = requiredString(build.gitCommitHash, 'gitCommitHash');
|
|
69
75
|
const fingerprintHash = requiredString(build.fingerprint?.hash, 'fingerprint.hash');
|
|
70
76
|
const artifactUrl = build.artifacts?.applicationArchiveUrl || build.artifacts?.buildUrl;
|
|
@@ -7,6 +7,7 @@ export type DependencyMigrationBackup = {
|
|
|
7
7
|
backupDir: string;
|
|
8
8
|
files: string[];
|
|
9
9
|
possibleCreatedFiles: string[];
|
|
10
|
+
packageManifestBackup?: string;
|
|
10
11
|
};
|
|
11
12
|
export declare function restoreDependencyMigration(backup: DependencyMigrationBackup): void;
|
|
12
13
|
export declare function removeExpoUpdatesWithPackageManager(projectRoot: string): DependencyMigrationBackup;
|
|
@@ -51,9 +51,10 @@ function expoUpdatesRemovalCommand(manager) {
|
|
|
51
51
|
function codePushRemovalCommand(manager) {
|
|
52
52
|
return dependencyRemovalCommand(manager, 'react-native-code-push');
|
|
53
53
|
}
|
|
54
|
+
const dependencyBackupPath = (file, backup) => file === 'package.json' ? backup.packageManifestBackup ?? file : file;
|
|
54
55
|
function restoreDependencyMigration(backup) {
|
|
55
56
|
for (const file of backup.files) {
|
|
56
|
-
(0, safe_file_transaction_1.restoreProjectFile)(backup.projectRoot, backup.backupDir, file);
|
|
57
|
+
(0, safe_file_transaction_1.restoreProjectFile)(backup.projectRoot, backup.backupDir, file, dependencyBackupPath(file, backup));
|
|
57
58
|
}
|
|
58
59
|
for (const file of backup.possibleCreatedFiles) {
|
|
59
60
|
if (!backup.files.includes(file)) {
|
|
@@ -62,7 +63,7 @@ function restoreDependencyMigration(backup) {
|
|
|
62
63
|
}
|
|
63
64
|
}
|
|
64
65
|
const removeDependencyWithPackageManager = (params) => {
|
|
65
|
-
const { projectRoot, dependency, backupName } = params;
|
|
66
|
+
const { projectRoot, dependency, backupName, packageManifestBackup } = params;
|
|
66
67
|
const manager = detectPackageManager(projectRoot);
|
|
67
68
|
const command = dependencyRemovalCommand(manager, dependency);
|
|
68
69
|
const files = ['package.json', ...LOCKFILES[manager]].filter(file => (0, safe_file_transaction_1.inspectProjectFile)(projectRoot, file).exists);
|
|
@@ -71,12 +72,13 @@ const removeDependencyWithPackageManager = (params) => {
|
|
|
71
72
|
backupDir: (0, safe_file_transaction_1.createSafeBackupDirectory)(projectRoot, backupName),
|
|
72
73
|
files,
|
|
73
74
|
possibleCreatedFiles: LOCKFILES[manager],
|
|
75
|
+
packageManifestBackup,
|
|
74
76
|
};
|
|
75
77
|
for (const file of files) {
|
|
76
78
|
const target = (0, safe_file_transaction_1.inspectProjectFile)(projectRoot, file);
|
|
77
79
|
if (!target.exists)
|
|
78
80
|
throw new Error(`Package file disappeared before migration: ${file}`);
|
|
79
|
-
(0, safe_file_transaction_1.writeBackupFile)(backup.backupDir, file, target.content, target.mode);
|
|
81
|
+
(0, safe_file_transaction_1.writeBackupFile)(backup.backupDir, dependencyBackupPath(file, backup), target.content, target.mode);
|
|
80
82
|
}
|
|
81
83
|
const result = (0, child_process_1.spawnSync)(command[0], command.slice(1), {
|
|
82
84
|
cwd: projectRoot,
|
|
@@ -118,5 +120,7 @@ function removeCodePushWithPackageManager(projectRoot) {
|
|
|
118
120
|
projectRoot,
|
|
119
121
|
dependency: 'react-native-code-push',
|
|
120
122
|
backupName: 'code-push',
|
|
123
|
+
// Older Metro versions discover package.json inside backup directories.
|
|
124
|
+
packageManifestBackup: 'package.json.bak',
|
|
121
125
|
});
|
|
122
126
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Project only Xcode app target membership and literal Info.plist paths. */
|
|
2
|
+
export declare function readXcodeApplicationTargets(value: unknown, projectDirectory: string): {
|
|
3
|
+
sourcePaths: string[];
|
|
4
|
+
infoPlistPaths: string[];
|
|
5
|
+
}[];
|
|
6
|
+
export declare function readIosSceneTarget(projectRoot: string): Promise<{
|
|
7
|
+
appDelegate: string;
|
|
8
|
+
sceneDelegate: string;
|
|
9
|
+
} | null>;
|
|
@@ -0,0 +1,193 @@
|
|
|
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.readXcodeApplicationTargets = readXcodeApplicationTargets;
|
|
7
|
+
exports.readIosSceneTarget = readIosSceneTarget;
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const safe_file_transaction_1 = require("./safe-file-transaction");
|
|
11
|
+
const dict = (value) => value && typeof value === 'object' && Object.getPrototypeOf(value) === Object.prototype
|
|
12
|
+
? value
|
|
13
|
+
: {};
|
|
14
|
+
const isIdList = (value) => Array.isArray(value) && value.every(item => typeof item === 'string' && item.length > 0);
|
|
15
|
+
const ids = (value) => isIdList(value) ? value : [];
|
|
16
|
+
const xcodeRelativePath = (value) => typeof value === 'string' &&
|
|
17
|
+
value.length > 0 &&
|
|
18
|
+
!/[$\\\\]/.test(value) &&
|
|
19
|
+
!path_1.default.posix.isAbsolute(value) &&
|
|
20
|
+
!value.split('/').some(part => !part || part === '.' || part === '..')
|
|
21
|
+
? value
|
|
22
|
+
: null;
|
|
23
|
+
const requireOne = (items, reason) => {
|
|
24
|
+
if (items.length !== 1)
|
|
25
|
+
throw new Error(reason);
|
|
26
|
+
return items[0];
|
|
27
|
+
};
|
|
28
|
+
const readXcodeProject = (value) => {
|
|
29
|
+
const project = dict(value);
|
|
30
|
+
const objects = dict(project.objects);
|
|
31
|
+
const get = (id) => typeof id === 'string' && Object.prototype.hasOwnProperty.call(objects, id)
|
|
32
|
+
? dict(objects[id])
|
|
33
|
+
: {};
|
|
34
|
+
const root = get(project.rootObject);
|
|
35
|
+
if (root.isa !== 'PBXProject' || root.projectDirPath || root.projectRoot) {
|
|
36
|
+
throw new Error('The Xcode project must resolve iOS source paths from the project directory.');
|
|
37
|
+
}
|
|
38
|
+
const targets = ids(root.targets).map(get);
|
|
39
|
+
const applications = targets.filter(target => target.isa === 'PBXNativeTarget' && target.productType === 'com.apple.product-type.application');
|
|
40
|
+
return { objects, get, root, targets, applications };
|
|
41
|
+
};
|
|
42
|
+
const excludesSceneDelegate = (project) => {
|
|
43
|
+
const { get, objects, root, targets } = project;
|
|
44
|
+
const referencesOtherProjects = root.projectReferences !== undefined &&
|
|
45
|
+
(!Array.isArray(root.projectReferences) || root.projectReferences.length > 0);
|
|
46
|
+
const hasSynchronizedSources = Object.values(objects).some(item => dict(item).isa === 'PBXFileSystemSynchronizedRootGroup');
|
|
47
|
+
if (!isIdList(root.targets) || referencesOtherProjects || hasSynchronizedSources)
|
|
48
|
+
return false;
|
|
49
|
+
return targets.every(target => {
|
|
50
|
+
const nativeTarget = target.isa === 'PBXNativeTarget' && typeof target.productType === 'string';
|
|
51
|
+
const usesCustomBuildRules = target.buildRules !== undefined &&
|
|
52
|
+
(!isIdList(target.buildRules) || target.buildRules.length > 0);
|
|
53
|
+
if ((!nativeTarget && target.isa !== 'PBXAggregateTarget') ||
|
|
54
|
+
target.fileSystemSynchronizedGroups !== undefined || usesCustomBuildRules ||
|
|
55
|
+
!isIdList(target.buildPhases))
|
|
56
|
+
return false;
|
|
57
|
+
return target.buildPhases.map(get).every(phase => {
|
|
58
|
+
if (phase.isa === 'PBXSourcesBuildPhase') {
|
|
59
|
+
return isIdList(phase.files) && phase.files.map(get).every(buildFile => {
|
|
60
|
+
const source = get(buildFile.fileRef);
|
|
61
|
+
const sourcePath = xcodeRelativePath(source.path);
|
|
62
|
+
return buildFile.isa === 'PBXBuildFile' && source.isa === 'PBXFileReference' &&
|
|
63
|
+
sourcePath !== null && !/(?:^|\/)SceneDelegate\.swift$/i.test(sourcePath);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
return typeof phase.isa === 'string';
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
const hasLiteralSceneSettings = (config) => config.isa === 'XCBuildConfiguration' && !Object.keys(config).some(key => key.startsWith('baseConfigurationReference')) &&
|
|
71
|
+
!Object.entries(dict(config.buildSettings))
|
|
72
|
+
.some(([key, value]) => key.startsWith('INFOPLIST_KEY_UIApplicationSceneManifest') ||
|
|
73
|
+
key.startsWith('INFOPLIST_FILE[') ||
|
|
74
|
+
(/^(?:INFOPLIST_PREPROCESS|GENERATE_INFOPLIST_FILE)(?:\[|$)/.test(key) && value !== 'NO'));
|
|
75
|
+
/** Resolve the literal source paths that the app target actually compiles. */
|
|
76
|
+
const targetSourcePaths = (objects, rootGroup, sourceFileIds, projectDirectory) => {
|
|
77
|
+
const results = [];
|
|
78
|
+
const visited = new Set();
|
|
79
|
+
const pending = [{ id: rootGroup, directory: projectDirectory }];
|
|
80
|
+
while (pending.length) {
|
|
81
|
+
const { id, directory } = pending.pop();
|
|
82
|
+
if (visited.has(id))
|
|
83
|
+
throw new Error('iOS project references a source group more than once.');
|
|
84
|
+
visited.add(id);
|
|
85
|
+
const item = dict(objects[id]);
|
|
86
|
+
const group = item.isa === 'PBXGroup';
|
|
87
|
+
if (!group && (item.isa !== 'PBXFileReference' || !sourceFileIds.has(id)))
|
|
88
|
+
continue;
|
|
89
|
+
const base = item.sourceTree === 'SOURCE_ROOT' ? projectDirectory
|
|
90
|
+
: item.sourceTree === '<group>' ? directory : null;
|
|
91
|
+
const name = item.path === undefined && group ? '' : xcodeRelativePath(item.path);
|
|
92
|
+
if (base === null || name === null)
|
|
93
|
+
continue;
|
|
94
|
+
const relativePath = path_1.default.posix.join(base, name);
|
|
95
|
+
if (group) {
|
|
96
|
+
for (const childId of ids(item.children))
|
|
97
|
+
pending.push({ id: childId, directory: relativePath });
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
results.push(relativePath);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return results;
|
|
104
|
+
};
|
|
105
|
+
const targetSourceFileIds = (target, get) => {
|
|
106
|
+
const sourcePhases = ids(target.buildPhases).map(get).filter(item => item.isa === 'PBXSourcesBuildPhase');
|
|
107
|
+
return new Set(sourcePhases.flatMap(phase => ids(phase.files).map(get).flatMap(item => item.isa === 'PBXBuildFile' && typeof item.fileRef === 'string' ? [item.fileRef] : [])));
|
|
108
|
+
};
|
|
109
|
+
/** Project only Xcode app target membership and literal Info.plist paths. */
|
|
110
|
+
function readXcodeApplicationTargets(value, projectDirectory) {
|
|
111
|
+
const { objects, get, root, applications } = readXcodeProject(value);
|
|
112
|
+
return applications.slice(0, 8).map(target => {
|
|
113
|
+
const sourcePaths = targetSourcePaths(objects, String(root.mainGroup), targetSourceFileIds(target, get), projectDirectory);
|
|
114
|
+
const infoPlistPaths = ids(get(target.buildConfigurationList).buildConfigurations).map(get).flatMap(config => {
|
|
115
|
+
const setting = dict(config.buildSettings).INFOPLIST_FILE;
|
|
116
|
+
const infoPlistPath = xcodeRelativePath(typeof setting === 'string'
|
|
117
|
+
? setting.replace(/^\$(?:\((?:SRCROOT|PROJECT_DIR)\)|\{(?:SRCROOT|PROJECT_DIR)\})\//, '')
|
|
118
|
+
: setting);
|
|
119
|
+
return infoPlistPath?.endsWith('.plist') ? [path_1.default.posix.join(projectDirectory, infoPlistPath)] : [];
|
|
120
|
+
});
|
|
121
|
+
return { sourcePaths, infoPlistPaths };
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
async function readIosSceneTarget(projectRoot) {
|
|
125
|
+
const projectNames = fs_1.default.readdirSync(path_1.default.join(projectRoot, 'ios')).filter(file => file.endsWith('.xcodeproj'));
|
|
126
|
+
if (!projectNames.length)
|
|
127
|
+
throw new Error('An Xcode project is required to identify the iOS scene delegate.');
|
|
128
|
+
const { parse, parseOpenStep } = await import('plist');
|
|
129
|
+
const read = (file) => {
|
|
130
|
+
const source = (0, safe_file_transaction_1.inspectProjectFile)(projectRoot, file);
|
|
131
|
+
if (!source.exists)
|
|
132
|
+
throw new Error(`iOS target metadata is missing: ${file}`);
|
|
133
|
+
return source.content;
|
|
134
|
+
};
|
|
135
|
+
const configurationList = (value, get) => ids(get(value).buildConfigurations).map(get);
|
|
136
|
+
const readTargetPlist = (configs) => {
|
|
137
|
+
const buildSettings = configs.map(config => dict(config.buildSettings));
|
|
138
|
+
if (buildSettings.some(settings => settings.INFOPLIST_PREPROCESS === 'YES' ||
|
|
139
|
+
Object.keys(settings).some(key => key.startsWith('INFOPLIST_KEY_UIApplicationSceneManifest')))) {
|
|
140
|
+
throw new Error('The Xcode app uses a computed iOS scene manifest.');
|
|
141
|
+
}
|
|
142
|
+
const infoPlistPath = requireOne([...new Set(buildSettings.map(settings => xcodeRelativePath(settings.INFOPLIST_FILE)))], 'iOS app build configurations must identify the same Info.plist.');
|
|
143
|
+
if (!infoPlistPath?.endsWith('.plist'))
|
|
144
|
+
throw new Error('The iOS app has no literal Info.plist path.');
|
|
145
|
+
const plistSource = read(`ios/${infoPlistPath}`).replace(/^\uFEFF/, '');
|
|
146
|
+
if (!plistSource.trimStart().startsWith('<'))
|
|
147
|
+
throw new Error('iOS Info.plist must be XML.');
|
|
148
|
+
const plist = dict(parse(plistSource));
|
|
149
|
+
if (!Object.keys(plist).length)
|
|
150
|
+
throw new Error('iOS Info.plist must contain a dictionary.');
|
|
151
|
+
return plist;
|
|
152
|
+
};
|
|
153
|
+
const projects = projectNames.map(name => readXcodeProject(parseOpenStep(read(`ios/${name}/project.pbxproj`))));
|
|
154
|
+
if (projects.length > 1 || projects[0].applications.length !== 1) {
|
|
155
|
+
// A legacy fallback here requires positive evidence from every project's declared sources and app configuration.
|
|
156
|
+
const hasApplication = projects.some(project => project.applications.length > 0);
|
|
157
|
+
const dormantScene = hasApplication && projects.every(project => {
|
|
158
|
+
if (!excludesSceneDelegate(project))
|
|
159
|
+
return false;
|
|
160
|
+
const { get, root, applications } = project;
|
|
161
|
+
const projectConfigs = configurationList(root.buildConfigurationList, get);
|
|
162
|
+
if (root.buildConfigurationList !== undefined && !projectConfigs.length)
|
|
163
|
+
return false;
|
|
164
|
+
return projectConfigs.every(hasLiteralSceneSettings) && applications.every(target => {
|
|
165
|
+
const configs = configurationList(target.buildConfigurationList, get);
|
|
166
|
+
return configs.length > 0 && configs.every(hasLiteralSceneSettings) &&
|
|
167
|
+
readTargetPlist(configs).UIApplicationSceneManifest === undefined;
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
if (dormantScene)
|
|
171
|
+
return null;
|
|
172
|
+
throw new Error('Could not prove SceneDelegate is dormant in this multi-target or multi-project iOS app.');
|
|
173
|
+
}
|
|
174
|
+
const { objects, get, root, applications: [target] } = projects[0];
|
|
175
|
+
const plist = readTargetPlist(configurationList(target.buildConfigurationList, get));
|
|
176
|
+
if (plist.UIApplicationSceneManifest === undefined)
|
|
177
|
+
return null;
|
|
178
|
+
const manifest = dict(plist.UIApplicationSceneManifest);
|
|
179
|
+
const roles = dict(manifest.UISceneConfigurations);
|
|
180
|
+
const configurations = roles.UIWindowSceneSessionRoleApplication;
|
|
181
|
+
if (manifest.UIApplicationSupportsMultipleScenes === true ||
|
|
182
|
+
Object.keys(roles).length !== 1 ||
|
|
183
|
+
!Array.isArray(configurations) ||
|
|
184
|
+
configurations.length !== 1 ||
|
|
185
|
+
dict(configurations[0]).UISceneDelegateClassName !== '$(PRODUCT_MODULE_NAME).SceneDelegate') {
|
|
186
|
+
throw new Error('The application scene configuration does not uniquely register SceneDelegate.');
|
|
187
|
+
}
|
|
188
|
+
const delegates = targetSourcePaths(objects, String(root.mainGroup), targetSourceFileIds(target, get), 'ios');
|
|
189
|
+
return {
|
|
190
|
+
appDelegate: requireOne(delegates.filter(file => file.endsWith('/AppDelegate.swift')), 'The iOS app target must compile exactly one AppDelegate.swift.'),
|
|
191
|
+
sceneDelegate: requireOne(delegates.filter(file => file.endsWith('/SceneDelegate.swift')), 'The iOS app target must compile exactly one SceneDelegate.swift.'),
|
|
192
|
+
};
|
|
193
|
+
}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
export type NativeEntrypointPlatform = 'android' | 'ios';
|
|
2
|
+
export declare function findBareIosSceneEntrypoint(projectRoot: string): Promise<string | null>;
|
|
2
3
|
export declare const findNativeEntrypointAuthorityIssue: (projectRoot: string, platform: NativeEntrypointPlatform, entrypoints: string[]) => string | null;
|
|
@@ -4,10 +4,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.findNativeEntrypointAuthorityIssue = void 0;
|
|
7
|
+
exports.findBareIosSceneEntrypoint = findBareIosSceneEntrypoint;
|
|
7
8
|
const fs_1 = __importDefault(require("fs"));
|
|
8
9
|
const path_1 = __importDefault(require("path"));
|
|
9
10
|
const safe_file_transaction_1 = require("./safe-file-transaction");
|
|
10
11
|
const native_setup_contract_1 = require("./native-setup-contract");
|
|
12
|
+
const native_startup_validator_1 = require("./native-startup-validator");
|
|
13
|
+
const ios_scene_target_1 = require("./ios-scene-target");
|
|
11
14
|
const toPosix = (filePath) => filePath.split(path_1.default.sep).join('/');
|
|
12
15
|
const maskXmlComments = (source) => {
|
|
13
16
|
let masked = '';
|
|
@@ -361,6 +364,27 @@ const swiftAuthorityIssue = (projectRoot, entrypoint, mainFiles, swiftFiles) =>
|
|
|
361
364
|
}
|
|
362
365
|
return null;
|
|
363
366
|
};
|
|
367
|
+
async function findBareIosSceneEntrypoint(projectRoot) {
|
|
368
|
+
const { mainFiles, swiftFiles } = findIosAuthoritySources(projectRoot);
|
|
369
|
+
if (!swiftFiles.some(file => file.endsWith('/SceneDelegate.swift')))
|
|
370
|
+
return null;
|
|
371
|
+
const target = await (0, ios_scene_target_1.readIosSceneTarget)(projectRoot);
|
|
372
|
+
if (!target)
|
|
373
|
+
return null;
|
|
374
|
+
const principalIssue = swiftAuthorityIssue(projectRoot, target.appDelegate, mainFiles, swiftFiles);
|
|
375
|
+
if (principalIssue)
|
|
376
|
+
throw new Error(principalIssue);
|
|
377
|
+
const appDelegate = (0, native_setup_contract_1.stripCommentsAndStrings)((0, safe_file_transaction_1.inspectProjectFile)(projectRoot, target.appDelegate).content);
|
|
378
|
+
if (!/\bclass\s+AppDelegate\s*:[^{]*\bUIApplicationDelegate\b/.test(appDelegate) ||
|
|
379
|
+
/\b(?:configurationForConnecting|startReactNative|RCTReactNativeFactory|bundleURL)\b/.test(appDelegate)) {
|
|
380
|
+
throw new Error('AppDelegate uses a custom scene or React Native startup path.');
|
|
381
|
+
}
|
|
382
|
+
const sceneDelegate = (0, safe_file_transaction_1.inspectProjectFile)(projectRoot, target.sceneDelegate);
|
|
383
|
+
if (!sceneDelegate.exists || !(0, native_startup_validator_1.hasBareIosSceneStartup)(sceneDelegate.content)) {
|
|
384
|
+
throw new Error('The registered SceneDelegate does not own a supported React Native scene startup path.');
|
|
385
|
+
}
|
|
386
|
+
return target.sceneDelegate;
|
|
387
|
+
}
|
|
364
388
|
const findNativeEntrypointAuthorityIssue = (projectRoot, platform, entrypoints) => {
|
|
365
389
|
if (!entrypoints.length)
|
|
366
390
|
return null;
|
|
@@ -4,4 +4,8 @@ export declare const IOS_BUNDLE_DROP_MODULE = "BundleDrop";
|
|
|
4
4
|
export declare const IOS_BUNDLE_DROP_LOCATOR_HEADER = "BundleDrop/BundleDropLocator.h";
|
|
5
5
|
export declare const stripCommentsAndStrings: (content: string) => string;
|
|
6
6
|
export declare const stripComments: (content: string) => string;
|
|
7
|
+
export declare const stripCommentsAndStringsWithSourceOffsets: (content: string) => {
|
|
8
|
+
code: string;
|
|
9
|
+
sourceOffsets: number[];
|
|
10
|
+
};
|
|
7
11
|
export { findMissingBareNativeStartupStructure, hasBareAndroidStartupIntegration, hasBareIosStartupIntegration, } from './native-startup-validator';
|
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.hasBareIosStartupIntegration = exports.hasBareAndroidStartupIntegration = exports.findMissingBareNativeStartupStructure = exports.stripComments = exports.stripCommentsAndStrings = exports.IOS_BUNDLE_DROP_LOCATOR_HEADER = exports.IOS_BUNDLE_DROP_MODULE = exports.ANDROID_BUNDLE_DROP_PATHS = exports.ANDROID_BUNDLE_DROP_MODULE = void 0;
|
|
3
|
+
exports.hasBareIosStartupIntegration = exports.hasBareAndroidStartupIntegration = exports.findMissingBareNativeStartupStructure = exports.stripCommentsAndStringsWithSourceOffsets = exports.stripComments = exports.stripCommentsAndStrings = exports.IOS_BUNDLE_DROP_LOCATOR_HEADER = exports.IOS_BUNDLE_DROP_MODULE = exports.ANDROID_BUNDLE_DROP_PATHS = exports.ANDROID_BUNDLE_DROP_MODULE = void 0;
|
|
4
4
|
exports.ANDROID_BUNDLE_DROP_MODULE = 'com.bundledrop.BundleDropModule';
|
|
5
5
|
exports.ANDROID_BUNDLE_DROP_PATHS = 'com.bundledrop.BundleDropNativePaths';
|
|
6
6
|
exports.IOS_BUNDLE_DROP_MODULE = 'BundleDrop';
|
|
7
7
|
exports.IOS_BUNDLE_DROP_LOCATOR_HEADER = 'BundleDrop/BundleDropLocator.h';
|
|
8
|
-
const sanitizeSource = (content, preserveStrings) => {
|
|
8
|
+
const sanitizeSource = (content, preserveStrings, sourceOffsets) => {
|
|
9
9
|
let code = '';
|
|
10
|
+
const append = (start, length = 1) => {
|
|
11
|
+
const end = start + length;
|
|
12
|
+
code += content.slice(start, end);
|
|
13
|
+
if (sourceOffsets) {
|
|
14
|
+
for (let offset = start; offset < end; offset += 1)
|
|
15
|
+
sourceOffsets.push(offset);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
10
18
|
let state = 'code';
|
|
11
19
|
let escaped = false;
|
|
12
20
|
let blockCommentDepth = 0;
|
|
@@ -17,7 +25,7 @@ const sanitizeSource = (content, preserveStrings) => {
|
|
|
17
25
|
if (state === 'line-comment') {
|
|
18
26
|
if (character === '\n') {
|
|
19
27
|
state = 'code';
|
|
20
|
-
|
|
28
|
+
append(index);
|
|
21
29
|
}
|
|
22
30
|
continue;
|
|
23
31
|
}
|
|
@@ -39,26 +47,26 @@ const sanitizeSource = (content, preserveStrings) => {
|
|
|
39
47
|
const closingDelimiter = `"""${tripleQuoteHashes}`;
|
|
40
48
|
if (content.startsWith(closingDelimiter, index)) {
|
|
41
49
|
if (preserveStrings)
|
|
42
|
-
|
|
50
|
+
append(index, closingDelimiter.length);
|
|
43
51
|
index += closingDelimiter.length - 1;
|
|
44
52
|
state = 'code';
|
|
45
53
|
tripleQuoteHashes = '';
|
|
46
54
|
}
|
|
47
55
|
else if (preserveStrings) {
|
|
48
|
-
|
|
56
|
+
append(index);
|
|
49
57
|
}
|
|
50
58
|
continue;
|
|
51
59
|
}
|
|
52
60
|
if (state !== 'code') {
|
|
53
61
|
if (escaped) {
|
|
54
62
|
if (preserveStrings)
|
|
55
|
-
|
|
63
|
+
append(index);
|
|
56
64
|
escaped = false;
|
|
57
65
|
continue;
|
|
58
66
|
}
|
|
59
67
|
if (character === '\\') {
|
|
60
68
|
if (preserveStrings)
|
|
61
|
-
|
|
69
|
+
append(index);
|
|
62
70
|
escaped = true;
|
|
63
71
|
continue;
|
|
64
72
|
}
|
|
@@ -66,7 +74,7 @@ const sanitizeSource = (content, preserveStrings) => {
|
|
|
66
74
|
(state === 'double' && character === '"') ||
|
|
67
75
|
(state === 'template' && character === '`');
|
|
68
76
|
if (preserveStrings)
|
|
69
|
-
|
|
77
|
+
append(index);
|
|
70
78
|
if (closesState)
|
|
71
79
|
state = 'code';
|
|
72
80
|
continue;
|
|
@@ -87,7 +95,7 @@ const sanitizeSource = (content, preserveStrings) => {
|
|
|
87
95
|
state = 'triple-double';
|
|
88
96
|
tripleQuoteHashes = '';
|
|
89
97
|
if (preserveStrings)
|
|
90
|
-
|
|
98
|
+
append(index, 3);
|
|
91
99
|
index += 2;
|
|
92
100
|
continue;
|
|
93
101
|
}
|
|
@@ -95,29 +103,29 @@ const sanitizeSource = (content, preserveStrings) => {
|
|
|
95
103
|
state = 'triple-double';
|
|
96
104
|
tripleQuoteHashes = swiftRawTripleQuote[1];
|
|
97
105
|
if (preserveStrings)
|
|
98
|
-
|
|
106
|
+
append(index, swiftRawTripleQuote[0].length);
|
|
99
107
|
index += swiftRawTripleQuote[0].length - 1;
|
|
100
108
|
continue;
|
|
101
109
|
}
|
|
102
110
|
if (character === "'") {
|
|
103
111
|
state = 'single';
|
|
104
112
|
if (preserveStrings)
|
|
105
|
-
|
|
113
|
+
append(index);
|
|
106
114
|
continue;
|
|
107
115
|
}
|
|
108
116
|
if (character === '"') {
|
|
109
117
|
state = 'double';
|
|
110
118
|
if (preserveStrings)
|
|
111
|
-
|
|
119
|
+
append(index);
|
|
112
120
|
continue;
|
|
113
121
|
}
|
|
114
122
|
if (character === '`') {
|
|
115
123
|
state = 'template';
|
|
116
124
|
if (preserveStrings)
|
|
117
|
-
|
|
125
|
+
append(index);
|
|
118
126
|
continue;
|
|
119
127
|
}
|
|
120
|
-
|
|
128
|
+
append(index);
|
|
121
129
|
}
|
|
122
130
|
return code;
|
|
123
131
|
};
|
|
@@ -125,6 +133,12 @@ const stripCommentsAndStrings = (content) => sanitizeSource(content, false);
|
|
|
125
133
|
exports.stripCommentsAndStrings = stripCommentsAndStrings;
|
|
126
134
|
const stripComments = (content) => sanitizeSource(content, true);
|
|
127
135
|
exports.stripComments = stripComments;
|
|
136
|
+
const stripCommentsAndStringsWithSourceOffsets = (content) => {
|
|
137
|
+
const sourceOffsets = [];
|
|
138
|
+
const code = sanitizeSource(content, false, sourceOffsets);
|
|
139
|
+
return { code, sourceOffsets };
|
|
140
|
+
};
|
|
141
|
+
exports.stripCommentsAndStringsWithSourceOffsets = stripCommentsAndStringsWithSourceOffsets;
|
|
128
142
|
var native_startup_validator_1 = require("./native-startup-validator");
|
|
129
143
|
Object.defineProperty(exports, "findMissingBareNativeStartupStructure", { enumerable: true, get: function () { return native_startup_validator_1.findMissingBareNativeStartupStructure; } });
|
|
130
144
|
Object.defineProperty(exports, "hasBareAndroidStartupIntegration", { enumerable: true, get: function () { return native_startup_validator_1.hasBareAndroidStartupIntegration; } });
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
export declare const hasBareAndroidStartupIntegration: (code: string
|
|
1
|
+
export declare const hasBareAndroidStartupIntegration: (code: string, { checkInlineReactHost }?: {
|
|
2
|
+
checkInlineReactHost?: boolean;
|
|
3
|
+
}) => boolean;
|
|
4
|
+
export declare const hasBareIosSceneStartup: (code: string) => boolean;
|
|
2
5
|
export declare const hasBareIosStartupIntegration: (filePath: string, code: string) => boolean;
|
|
3
6
|
export declare const findMissingBareNativeStartupStructure: (filePath: string, original: string, updated: string) => string[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.findMissingBareNativeStartupStructure = exports.hasBareIosStartupIntegration = exports.hasBareAndroidStartupIntegration = void 0;
|
|
3
|
+
exports.findMissingBareNativeStartupStructure = exports.hasBareIosStartupIntegration = exports.hasBareIosSceneStartup = exports.hasBareAndroidStartupIntegration = void 0;
|
|
4
4
|
const native_setup_contract_1 = require("./native-setup-contract");
|
|
5
5
|
const findBalancedBlockEnd = (code, openingIndex, openingCharacter = '{', closingCharacter = '}') => {
|
|
6
6
|
let depth = 0;
|
|
@@ -453,6 +453,32 @@ const splitTopLevelArguments = (body) => {
|
|
|
453
453
|
}
|
|
454
454
|
return parts;
|
|
455
455
|
};
|
|
456
|
+
const hasInlineReactHostResolver = (nativeCode) => {
|
|
457
|
+
const [reactHost] = authoritativeReactHostBlocks(nativeCode);
|
|
458
|
+
if (!reactHost)
|
|
459
|
+
return false;
|
|
460
|
+
const body = nativeCode.slice(reactHost.bodyStart, reactHost.bodyEnd);
|
|
461
|
+
return hasAuthoritativeLazyHostCall(body, argumentsBody => {
|
|
462
|
+
const paths = splitTopLevelArguments(argumentsBody).filter(argument => /^jsBundleFilePath\s*=/.test(argument));
|
|
463
|
+
if (paths.length !== 1)
|
|
464
|
+
return false;
|
|
465
|
+
const debugGuard = /^jsBundleFilePath\s*=\s*if\s*\(\s*BuildConfig\.DEBUG\s*\)\s*(?:\{\s*null\s*\}|null\b)\s*else\b\s*/;
|
|
466
|
+
const release = paths[0].replace(debugGuard, '');
|
|
467
|
+
if (release === paths[0])
|
|
468
|
+
return false;
|
|
469
|
+
const expression = release.startsWith('{') && release.endsWith('}')
|
|
470
|
+
? release.slice(1, -1).trim()
|
|
471
|
+
: release;
|
|
472
|
+
const [call] = findCallSites(expression, 'BundleDropModule.resolveJSBundleFile');
|
|
473
|
+
if (!call ||
|
|
474
|
+
!['', 'com.bundledrop.'].includes(expression.slice(0, call.start)) ||
|
|
475
|
+
expression.slice(call.end).trim())
|
|
476
|
+
return false;
|
|
477
|
+
const [context, fallback, ...rest] = splitTopLevelArguments(call.argumentsBody);
|
|
478
|
+
return !rest.length && fallback === 'null' &&
|
|
479
|
+
/^(?:applicationContext|this(?:@MainApplication)?|getApplicationContext\(\s*\))$/.test(context);
|
|
480
|
+
});
|
|
481
|
+
};
|
|
456
482
|
const hasValidAndroidModuleResolverCall = (nativeCode, startup) => {
|
|
457
483
|
const calls = findCallSites(startup.method.body, 'BundleDropModule.resolveJSBundleFile');
|
|
458
484
|
if (calls.length !== 1)
|
|
@@ -652,7 +678,7 @@ const resolverFeedsReturnedValue = (body, resolver, expressionBody, language, re
|
|
|
652
678
|
}
|
|
653
679
|
return hasValueFlow && returnIndices.every(index => controlledReturns.has(index));
|
|
654
680
|
};
|
|
655
|
-
const hasBareAndroidStartupIntegration = (code) => {
|
|
681
|
+
const hasBareAndroidStartupIntegration = (code, { checkInlineReactHost = false } = {}) => {
|
|
656
682
|
if (hasNativeCodePushResidue(code))
|
|
657
683
|
return false;
|
|
658
684
|
const nativeCode = (0, native_setup_contract_1.stripCommentsAndStrings)(code);
|
|
@@ -674,6 +700,9 @@ const hasBareAndroidStartupIntegration = (code) => {
|
|
|
674
700
|
}
|
|
675
701
|
if (!hasExactAndroidModuleReference(nativeCode))
|
|
676
702
|
return false;
|
|
703
|
+
if (checkInlineReactHost && mainApplication && hasInlineReactHostResolver(nativeCode)) {
|
|
704
|
+
return hasAndroidLifecycleIntegrity(nativeCode, mainApplication);
|
|
705
|
+
}
|
|
677
706
|
if (!startup ||
|
|
678
707
|
!hasValidAndroidModuleResolverCall(nativeCode, startup) ||
|
|
679
708
|
!resolverFeedsReturnedValue(startup.method.body, 'BundleDropModule.resolveJSBundleFile', startup.method.declaration.trimEnd().endsWith('='), startup.method.language, startup.method.language === 'kotlin' &&
|
|
@@ -750,7 +779,40 @@ const appDelegateSourceUrlPreservesBundleAuthority = (nativeCode, appDelegate) =
|
|
|
750
779
|
return /^(?:return\s+)?(?:self\s*\.\s*)?bundleURL\s*\(\s*\)\s*;?$/.test(source) ||
|
|
751
780
|
resolverFeedsReturnedValue(sourceMethods[0].body, 'BundleDropLocator.bundleURL', false, 'swift');
|
|
752
781
|
};
|
|
753
|
-
const
|
|
782
|
+
const swiftSceneStartupMethod = (nativeCode) => {
|
|
783
|
+
const scene = findNamedType(nativeCode, 'SceneDelegate');
|
|
784
|
+
if (!scene ||
|
|
785
|
+
!/:\s*RCTDefaultReactNativeFactoryDelegate\s*,\s*UIWindowSceneDelegate\s*\{$/.test(scene.declaration)) {
|
|
786
|
+
return null;
|
|
787
|
+
}
|
|
788
|
+
const methods = findDeclaredMethods(nativeCode, SWIFT_BUNDLE_URL_METHOD);
|
|
789
|
+
const bundleMethod = methods[0];
|
|
790
|
+
if (methods.length !== 1 ||
|
|
791
|
+
!/\boverride\s+func\s+bundleURL\b/.test(bundleMethod.declaration) ||
|
|
792
|
+
findContainingType(nativeCode, bundleMethod.declarationStart)?.declarationStart !== scene.declarationStart ||
|
|
793
|
+
findDeclaredMethods(nativeCode, SWIFT_SOURCE_URL_METHOD).length) {
|
|
794
|
+
return null;
|
|
795
|
+
}
|
|
796
|
+
const sceneConnectMethod = /(?:^|\n)\s*func\s+scene\s*\(\s*_\s+scene\s*:\s*UIScene\s*,\s*willConnectTo\s+session\s*:\s*UISceneSession\s*,\s*options\s+connectionOptions\s*:\s*UIScene\.ConnectionOptions\s*\)\s*(\{)/g;
|
|
797
|
+
const launchMethods = methodsOwnedBy(nativeCode, sceneConnectMethod, 'SceneDelegate');
|
|
798
|
+
if (launchMethods.length !== 1)
|
|
799
|
+
return null;
|
|
800
|
+
const release = releaseSource(launchMethods[0].body).trim();
|
|
801
|
+
const stockLaunch = new RegExp([
|
|
802
|
+
/^guard\s+let\s+windowScene\s*=\s*scene\s+as\?\s*UIWindowScene\s+else\s*\{\s*return\s*\}/,
|
|
803
|
+
/dependencyProvider\s*=\s*RCTAppDependencyProvider\s*\(\s*\)/,
|
|
804
|
+
/reactNativeFactory\s*=\s*RCTReactNativeFactory\s*\(\s*delegate\s*:\s*self\s*\)/,
|
|
805
|
+
/window\s*=\s*UIWindow\s*\(\s*windowScene\s*:\s*windowScene\s*\)/,
|
|
806
|
+
/reactNativeFactory\s*\?\.\s*startReactNative\s*\(\s*withModuleName\s*:\s*,/,
|
|
807
|
+
/in\s*:\s*window\s*,\s*connectionOptions\s*:\s*connectionOptions\s*\)$/,
|
|
808
|
+
].map(pattern => pattern.source).join('\\s*'));
|
|
809
|
+
return stockLaunch.test(release) ? bundleMethod : null;
|
|
810
|
+
};
|
|
811
|
+
const hasBareIosSceneStartup = (code) => Boolean(swiftSceneStartupMethod((0, native_setup_contract_1.stripCommentsAndStrings)(code)));
|
|
812
|
+
exports.hasBareIosSceneStartup = hasBareIosSceneStartup;
|
|
813
|
+
const swiftStartupMethod = (nativeCode, filePath) => {
|
|
814
|
+
if (filePath.endsWith('/SceneDelegate.swift'))
|
|
815
|
+
return swiftSceneStartupMethod(nativeCode);
|
|
754
816
|
const methods = findDeclaredMethods(nativeCode, SWIFT_BUNDLE_URL_METHOD);
|
|
755
817
|
if (methods.length !== 1)
|
|
756
818
|
return null;
|
|
@@ -777,6 +839,15 @@ const swiftStartupMethod = (nativeCode) => {
|
|
|
777
839
|
? method
|
|
778
840
|
: null;
|
|
779
841
|
};
|
|
842
|
+
const withoutSceneResolverEdit = (code, method) => {
|
|
843
|
+
const { code: sanitized, sourceOffsets } = (0, native_setup_contract_1.stripCommentsAndStringsWithSourceOffsets)(code);
|
|
844
|
+
const openingBrace = method.declarationStart + method.declaration.lastIndexOf('{');
|
|
845
|
+
const closingBrace = findBalancedBlockEnd(sanitized, openingBrace);
|
|
846
|
+
if (closingBrace <= openingBrace)
|
|
847
|
+
return null;
|
|
848
|
+
return (code.slice(0, sourceOffsets[openingBrace] + 1) + code.slice(sourceOffsets[closingBrace]))
|
|
849
|
+
.replace(/^[ \t]*import[ \t]+BundleDrop[ \t]*\r?\n/gm, '');
|
|
850
|
+
};
|
|
780
851
|
const objcStartupMethods = (nativeCode) => {
|
|
781
852
|
const implementations = findObjcImplementations(nativeCode);
|
|
782
853
|
const appDelegateImplementations = implementations.filter(implementation => implementation.name === 'AppDelegate' && !implementation.category);
|
|
@@ -799,7 +870,7 @@ const hasBareIosStartupIntegration = (filePath, code) => {
|
|
|
799
870
|
return false;
|
|
800
871
|
const nativeCode = (0, native_setup_contract_1.stripCommentsAndStrings)(code);
|
|
801
872
|
if (filePath.endsWith('.swift')) {
|
|
802
|
-
const startupMethod = swiftStartupMethod(nativeCode);
|
|
873
|
+
const startupMethod = swiftStartupMethod(nativeCode, filePath);
|
|
803
874
|
return Boolean(startupMethod &&
|
|
804
875
|
resolverFeedsReturnedValue(startupMethod.body, 'BundleDropLocator.bundleURL', false, 'swift') &&
|
|
805
876
|
new RegExp(`\\bimport\\s+${native_setup_contract_1.IOS_BUNDLE_DROP_MODULE}\\b`).test(nativeCode));
|
|
@@ -920,13 +991,19 @@ const findMissingBareNativeStartupStructure = (filePath, original, updated) => {
|
|
|
920
991
|
])];
|
|
921
992
|
}
|
|
922
993
|
if (filePath.endsWith('.swift')) {
|
|
923
|
-
const originalMethod = swiftStartupMethod(originalCode);
|
|
994
|
+
const originalMethod = swiftStartupMethod(originalCode, filePath);
|
|
924
995
|
if (!originalMethod)
|
|
925
996
|
return substantiveMissing;
|
|
926
|
-
const updatedMethod = swiftStartupMethod(updatedCode);
|
|
997
|
+
const updatedMethod = swiftStartupMethod(updatedCode, filePath);
|
|
927
998
|
if (!updatedMethod)
|
|
928
999
|
return [...substantiveMissing, 'bundleURL'];
|
|
929
1000
|
const missing = [...substantiveMissing];
|
|
1001
|
+
if (filePath.endsWith('/SceneDelegate.swift')) {
|
|
1002
|
+
const originalOutsideResolver = withoutSceneResolverEdit(original, originalMethod);
|
|
1003
|
+
if (originalOutsideResolver === null ||
|
|
1004
|
+
originalOutsideResolver !== withoutSceneResolverEdit(updated, updatedMethod))
|
|
1005
|
+
missing.push('SceneDelegate code outside bundleURL');
|
|
1006
|
+
}
|
|
930
1007
|
if (!preservesSubstantiveNativeTokens(originalMethod.body, updatedMethod.body, originalCodePushAliases)) {
|
|
931
1008
|
missing.push('bundleURL/non-CodePush fallback');
|
|
932
1009
|
}
|
|
@@ -8,5 +8,5 @@ export declare const inspectProjectDirectory: (root: string, relativePath: strin
|
|
|
8
8
|
export declare const writeProjectFileAtomically: (root: string, relativePath: string, content: string, mode?: number) => void;
|
|
9
9
|
export declare const createSafeBackupDirectory: (projectRoot: string, label: string) => string;
|
|
10
10
|
export declare const writeBackupFile: (backupRoot: string, relativePath: string, content: string, mode: number) => void;
|
|
11
|
-
export declare const restoreProjectFile: (projectRoot: string, backupRoot: string, relativePath: string) => void;
|
|
11
|
+
export declare const restoreProjectFile: (projectRoot: string, backupRoot: string, relativePath: string, backupPath?: string) => void;
|
|
12
12
|
export declare const removeProjectFile: (projectRoot: string, relativePath: string) => void;
|
|
@@ -143,10 +143,10 @@ const writeBackupFile = (backupRoot, relativePath, content, mode) => {
|
|
|
143
143
|
writeExclusiveFile(path_1.default.join(backupRoot, relativePath), content, mode);
|
|
144
144
|
};
|
|
145
145
|
exports.writeBackupFile = writeBackupFile;
|
|
146
|
-
const restoreProjectFile = (projectRoot, backupRoot, relativePath) => {
|
|
147
|
-
const backup = (0, exports.inspectProjectFile)(backupRoot,
|
|
146
|
+
const restoreProjectFile = (projectRoot, backupRoot, relativePath, backupPath = relativePath) => {
|
|
147
|
+
const backup = (0, exports.inspectProjectFile)(backupRoot, backupPath);
|
|
148
148
|
if (!backup.exists)
|
|
149
|
-
throw new Error(`Missing transaction backup: ${
|
|
149
|
+
throw new Error(`Missing transaction backup: ${backupPath}`);
|
|
150
150
|
(0, exports.inspectProjectFile)(projectRoot, relativePath);
|
|
151
151
|
(0, exports.writeProjectFileAtomically)(projectRoot, relativePath, backup.content, backup.mode);
|
|
152
152
|
};
|