-
Notifications
You must be signed in to change notification settings - Fork 95
/
Copy pathprepare-viewfinder.mts
executable file
·56 lines (48 loc) · 1.53 KB
/
prepare-viewfinder.mts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env -S node --experimental-transform-types --no-warnings
import { spawnSync } from "node:child_process";
import * as fs from "node:fs";
import * as path from "node:path";
import { URL, fileURLToPath } from "node:url";
import { readJSONFile } from "../helpers.js";
const APP_IDENTIFIER = "com.microsoft.ReactNativeViewfinder";
const PACKAGE_MANAGER = "yarn";
const PROJECT_ROOT = fileURLToPath(new URL("../..", import.meta.url));
const APP_ROOT = path.resolve(PROJECT_ROOT, "example");
const APP_MANIFEST = path.resolve(APP_ROOT, "app.json");
const PROJECT_MANIFEST = path.resolve(APP_ROOT, "package.json");
/**
* Configures the app manifest for Viewfinder.
*/
function configureAppManifest() {
const original = readJSONFile(APP_MANIFEST);
const manifest = {
...original,
$schema: undefined,
name: "Viewfinder",
displayName: "Viewfinder",
components: [],
android: {
package: APP_IDENTIFIER,
},
ios: {
bundleIdentifier: APP_IDENTIFIER,
},
};
fs.writeFileSync(APP_MANIFEST, JSON.stringify(manifest, null, 2) + "\n");
}
/**
* Runs the specified command.
*/
function $(command: string, args: string[], options?: Record<string, unknown>) {
const { error, status } = spawnSync(command, args, {
cwd: PROJECT_ROOT,
stdio: "inherit",
...options,
});
if (status !== 0) {
throw error ?? new Error(`Command failed: ${command} ${args.join(" ")}`);
}
}
configureAppManifest();
$("npx", ["@rnx-kit/align-deps", "--write", PROJECT_MANIFEST]);
$(PACKAGE_MANAGER, ["install"]);