History

Refactor mobile remote search and review state

- Move composer path search and source-control discovery into shared managed state - Persist review async/loading state in atoms and add coverage - Update mobile/web composers and review highlighter initialization

Julius Marminge committed 6 months ago

Commit e793c071 parent ab95f1137 files · +1366 −545Browse files

Showing the changes to scripts (4 of 37 files). Show all

Unified · Split

4 files
  1. scripts/mobile-native-static-check.ts +3 −13
  2. scripts/patch-expo-dev-launcher.mjs +0 −63
  3. scripts/patch-pierre-diffs-utils.mjs +0 −105
  4. scripts/patch-react-native-nitro-modules.mjs +0 −73
scripts/mobile-native-static-check.ts+3−13
@@ -40,8 +40,10 @@ const sourceExtensions = new Set([".swift", ".kt", ".kts"]); · 39 unmodified lines
4040 const excludedDirectories = new Set([
4141 ".expo",
4242 ".git",
43+ "android",
4344 "build",
4445 "DerivedData",
46+ "ios",
4547 "node_modules",
4648 "Pods",
4749 "Vendor",
@@ -188,19 +190,7 @@ const runNativeStaticChecks = Effect.fn("runNativeStaticChecks")(function* () { · 140 unmodified lines
188190 }
189191 }
190192
191− const androidProject = path.join(root, "android");
192− const gradlew = path.join(
193− androidProject,
194− process.platform === "win32" ? "gradlew.bat" : "gradlew",
195− );
196− const fs = yield* FileSystem.FileSystem;
197−
198− if (yield* fs.exists(gradlew)) {
199− const stat = yield* fs.stat(gradlew);
200− if (stat.type === "File") {
201− yield* runCommand(gradlew, ["lint"], androidProject);
202− }
203− }
193+ yield* Console.log("Skipping generated native project folders: android/, ios/.");
204194 });
205195
206196 export const mobileNativeStaticCheckCommand = Command.make("mobile-native-static-check", {}, () =>
scripts/patch-expo-dev-launcher.mjs+0−63
@@ -1,63 +0,0 @@
1−import { existsSync, readdirSync, readFileSync, writeFileSync } from "node:fs";
2−import { join } from "node:path";
3−
4−const root = process.cwd();
5−
6−const candidates = [join(root, "node_modules/expo-dev-launcher/ios/EXDevLauncherController.m")];
7−
8−const bunStorePath = join(root, "node_modules/.bun");
9−
10−if (existsSync(bunStorePath)) {
11− for (const entry of readdirSync(bunStorePath)) {
12− if (!entry.startsWith("expo-dev-launcher@")) {
13− continue;
14− }
15−
16− candidates.push(
17− join(bunStorePath, entry, "node_modules/expo-dev-launcher/ios/EXDevLauncherController.m"),
18− );
19− }
20−}
21−
22−const targetLine = "[manager updateCurrentBridge:self.appBridge];";
23−const replacement = [
24− " // Expo SDK 55's dev launcher still references `self.appBridge`,",
25− " // but React Native 0.83 removed that property from the delegate base class.",
26− " // Newer Expo builds stop updating the dev menu bridge here.",
27−].join("\n");
28−
29−let patchedCount = 0;
30−let locatedCount = 0;
31−
32−for (const filePath of candidates) {
33− if (!existsSync(filePath)) {
34− continue;
35− }
36−
37− locatedCount += 1;
38− const source = readFileSync(filePath, "utf8");
39−
40− if (source.includes(replacement)) {
41− continue;
42− }
43−
44− if (!source.includes(targetLine)) {
45− throw new Error(
46− `Found expo-dev-launcher source at ${filePath}, but the expected bridge line was missing.`,
47− );
48− }
49−
50− const nextSource = source.replace(` ${targetLine}`, replacement);
51− writeFileSync(filePath, nextSource);
52− patchedCount += 1;
53−}
54−
55−if (patchedCount > 0) {
56− console.log(
57− `[patch-expo-dev-launcher] patched ${patchedCount} expo-dev-launcher installation(s).`,
58− );
59−} else if (locatedCount > 0) {
60− console.log("[patch-expo-dev-launcher] expo-dev-launcher already patched.");
61−} else {
62− console.log("[patch-expo-dev-launcher] expo-dev-launcher not installed; skipping.");
63−}
scripts/patch-pierre-diffs-utils.mjs+0−105
@@ -1,105 +0,0 @@
1−import { existsSync, readdirSync, readFileSync, writeFileSync } from "node:fs";
2−import { join } from "node:path";
3−
4−const root = process.cwd();
5−const bunStorePath = join(root, "node_modules/.bun");
6−
7−const packageDirs = [];
8−
9−if (existsSync(join(root, "node_modules/@pierre/diffs"))) {
10− packageDirs.push(join(root, "node_modules/@pierre/diffs"));
11−}
12−
13−if (existsSync(bunStorePath)) {
14− for (const entry of readdirSync(bunStorePath)) {
15− if (!entry.startsWith("@pierre+diffs@")) {
16− continue;
17− }
18−
19− packageDirs.push(join(bunStorePath, entry, "node_modules/@pierre/diffs"));
20− }
21−}
22−
23−const utilsIndexJs = [
24− 'export { parsePatchFiles, processFile, processPatch } from "./parsePatchFiles.js";',
25− "export {",
26− " EXTENSION_TO_FILE_FORMAT,",
27− " getCustomExtensionsMap,",
28− " getCustomExtensionsVersion,",
29− " getFiletypeFromFileName,",
30− " replaceCustomExtensions,",
31− " setCustomExtension,",
32− '} from "./getFiletypeFromFileName.js";',
33− "",
34−].join("\n");
35−
36−const utilsIndexDts = [
37− 'export { parsePatchFiles, processFile, processPatch } from "./parsePatchFiles.js";',
38− "export {",
39− " EXTENSION_TO_FILE_FORMAT,",
40− " getCustomExtensionsMap,",
41− " getCustomExtensionsVersion,",
42− " getFiletypeFromFileName,",
43− " replaceCustomExtensions,",
44− " setCustomExtension,",
45− '} from "./getFiletypeFromFileName.js";',
46− 'export type { ChangeTypes, FileDiffMetadata, ParsedPatch, SupportedLanguages } from "../types.js";',
47− "",
48−].join("\n");
49−
50−let patchedCount = 0;
51−let locatedCount = 0;
52−
53−for (const packageDir of packageDirs) {
54− if (!existsSync(packageDir)) {
55− continue;
56− }
57−
58− locatedCount += 1;
59−
60− const packageJsonPath = join(packageDir, "package.json");
61− const utilsIndexJsPath = join(packageDir, "dist/utils/index.js");
62− const utilsIndexDtsPath = join(packageDir, "dist/utils/index.d.ts");
63−
64− const pkg = JSON.parse(readFileSync(packageJsonPath, "utf8"));
65− const currentUtilsExport = pkg.exports?.["./utils"];
66−
67− const expectedUtilsExport = {
68− types: "./dist/utils/index.d.ts",
69− import: "./dist/utils/index.js",
70− };
71−
72− const needsExportPatch =
73− currentUtilsExport?.types !== expectedUtilsExport.types ||
74− currentUtilsExport?.import !== expectedUtilsExport.import;
75−
76− if (needsExportPatch) {
77− pkg.exports = {
78− ...pkg.exports,
79− "./utils": expectedUtilsExport,
80− };
81− writeFileSync(packageJsonPath, `${JSON.stringify(pkg, null, 2)}\n`);
82− }
83−
84− const currentJs = existsSync(utilsIndexJsPath) ? readFileSync(utilsIndexJsPath, "utf8") : null;
85− if (currentJs !== utilsIndexJs) {
86− writeFileSync(utilsIndexJsPath, utilsIndexJs);
87− }
88−
89− const currentDts = existsSync(utilsIndexDtsPath) ? readFileSync(utilsIndexDtsPath, "utf8") : null;
90− if (currentDts !== utilsIndexDts) {
91− writeFileSync(utilsIndexDtsPath, utilsIndexDts);
92− }
93−
94− if (needsExportPatch || currentJs !== utilsIndexJs || currentDts !== utilsIndexDts) {
95− patchedCount += 1;
96− }
97−}
98−
99−if (patchedCount > 0) {
100− console.log(`[patch-pierre-diffs-utils] patched ${patchedCount} @pierre/diffs installation(s).`);
101−} else if (locatedCount > 0) {
102− console.log("[patch-pierre-diffs-utils] @pierre/diffs already patched.");
103−} else {
104− console.log("[patch-pierre-diffs-utils] @pierre/diffs not installed; skipping.");
105−}
scripts/patch-react-native-nitro-modules.mjs+0−73
@@ -1,73 +0,0 @@
1−import { existsSync, readdirSync, readFileSync, writeFileSync } from "node:fs";
2−import { join } from "node:path";
3−
4−const root = process.cwd();
5−
6−const candidates = [join(root, "node_modules/react-native-nitro-modules/package.json")];
7−
8−const bunStorePath = join(root, "node_modules/.bun");
9−
10−if (existsSync(bunStorePath)) {
11− for (const entry of readdirSync(bunStorePath)) {
12− if (!entry.startsWith("react-native-nitro-modules@")) {
13− continue;
14− }
15−
16− candidates.push(
17− join(bunStorePath, entry, "node_modules/react-native-nitro-modules/package.json"),
18− );
19− }
20−}
21−
22−let patchedCount = 0;
23−let locatedCount = 0;
24−
25−for (const filePath of candidates) {
26− if (!existsSync(filePath)) {
27− continue;
28− }
29−
30− locatedCount += 1;
31−
32− const source = readFileSync(filePath, "utf8");
33− const pkg = JSON.parse(source);
34−
35− if (pkg.codegenConfig == null || typeof pkg.codegenConfig !== "object") {
36− throw new Error(
37− `Found react-native-nitro-modules package at ${filePath}, but codegenConfig was missing.`,
38− );
39− }
40−
41− const iosConfig =
42− pkg.codegenConfig.ios != null && typeof pkg.codegenConfig.ios === "object"
43− ? pkg.codegenConfig.ios
44− : {};
45−
46− const modulesProvider =
47− iosConfig.modulesProvider != null && typeof iosConfig.modulesProvider === "object"
48− ? iosConfig.modulesProvider
49− : {};
50−
51− if (modulesProvider.NitroModules === "NativeNitroModules") {
52− continue;
53− }
54−
55− modulesProvider.NitroModules = "NativeNitroModules";
56− iosConfig.modulesProvider = modulesProvider;
57− pkg.codegenConfig.ios = iosConfig;
58−
59− writeFileSync(filePath, `${JSON.stringify(pkg, null, 2)}\n`);
60− patchedCount += 1;
61−}
62−
63−if (patchedCount > 0) {
64− console.log(
65− `[patch-react-native-nitro-modules] patched ${patchedCount} react-native-nitro-modules installation(s).`,
66− );
67−} else if (locatedCount > 0) {
68− console.log("[patch-react-native-nitro-modules] react-native-nitro-modules already patched.");
69−} else {
70− console.log(
71− "[patch-react-native-nitro-modules] react-native-nitro-modules not installed; skipping.",
72− );
73−}