forked from penrose/penrose
-
Notifications
You must be signed in to change notification settings - Fork 0
/
turboConfig.js
executable file
·35 lines (33 loc) · 1.12 KB
/
turboConfig.js
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
#!/usr/bin/env node
const fs = require("fs");
const yaml = require("js-yaml");
const path = require("path");
const basePipeline = {
build: { dependsOn: ["^build"], outputs: [] },
"build-decls": { dependsOn: ["^build-decls"], outputs: [] },
typecheck: { dependsOn: ["build-decls"], outputs: [] },
};
const turboJSON = {
$schema: "https://turborepo.org/schema.json",
pipeline: { ...basePipeline },
};
const packagesDir = "packages";
for (const package of fs.readdirSync(packagesDir)) {
const p = path.join(packagesDir, package, "package.json");
if (!fs.existsSync(p)) continue;
const { name, turbo } = JSON.parse(fs.readFileSync(p).toString());
if (!turbo) continue;
for (const [script, unparsed] of Object.entries(turbo)) {
const config = yaml.load(`{${unparsed}}`);
const entry = {
dependsOn: [
...(basePipeline[script]?.dependsOn ?? []),
...(config.deps ?? []),
],
outputs: config.out ?? [],
};
if ("cache" in config) entry.cache = config.cache;
turboJSON.pipeline[`${name}#${script}`] = entry;
}
}
fs.writeFileSync("turbo.json", JSON.stringify(turboJSON, null, 2));