-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsync-repo.ts
45 lines (40 loc) · 1.46 KB
/
sync-repo.ts
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
import Degit from "degit";
import fs from "fs-extra";
import path from "node:path";
const tempDir = path.resolve(".temp");
async function main() {
if (fs.existsSync(tempDir)) {
fs.rmSync(tempDir, { recursive: true });
}
fs.mkdirSync(tempDir);
const degit = Degit("modiimedia/arri", {
force: true,
});
await degit.clone(tempDir);
fs.copySync(path.resolve(tempDir, "languages/swift/swift-client"), ".", {
overwrite: true,
});
fs.copySync(path.resolve(tempDir, "LICENSE"), "LICENSE");
if (fs.existsSync(".gitignore")) {
let gitIgnore = fs.readFileSync(".gitignore", "utf8");
if (!gitIgnore.includes("node_modules")) {
gitIgnore += "\nnode_modules\n**/node_modules";
}
if (!gitIgnore.includes(".temp")) {
gitIgnore += "\n.temp";
}
fs.writeFileSync(".gitignore", gitIgnore, "utf8");
}
if (fs.existsSync("project.json")) {
fs.rmSync("project.json");
}
if (fs.existsSync("README.md")) {
let readme = fs.readFileSync("README.md", "utf8");
readme = `_**Attention**:_
_This repo is a mirror of a subdirectory in the Arri RPC monorepo. It only exists to facilitate distribution for the Swift Package Manager. To submit an issue or make a PR please go to the [official Arri repo](https://github.com/modiimedia/arri)._
${readme}`;
fs.writeFileSync("README.md", readme, "utf8");
}
process.exit(0);
}
main();