-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.js
34 lines (29 loc) · 931 Bytes
/
build.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
import fs from 'fs';
const templates = fs
.readdirSync('./templates', { withFileTypes: true })
.filter((x) => x.isDirectory)
.map((x) => x.name);
for (const template of templates) {
const compilerPkg = JSON.parse(
fs.readFileSync(`../oc-template-${template}-compiler/package.json`, 'utf8')
);
const templatePkg = JSON.parse(
fs.readFileSync(`./templates/${template}/package.json`, 'utf8')
);
const ocServerPkg = JSON.parse(
fs.readFileSync(`../oc-server/package.json`, 'utf8')
);
templatePkg.devDependencies[
`oc-template-${template}-compiler`
] = `^${compilerPkg.version}`;
templatePkg.devDependencies['oc-server'] = `^${ocServerPkg.version}`;
fs.writeFileSync(
`./templates/${template}/package.json`,
JSON.stringify(templatePkg, null, 2)
);
fs.cpSync(
`./templates/${template}`,
`../oc-template-${template}-compiler/scaffold/src`,
{ recursive: true }
);
}