-
Notifications
You must be signed in to change notification settings - Fork 567
Expand file tree
/
Copy pathbuild.js
More file actions
42 lines (36 loc) · 1.19 KB
/
build.js
File metadata and controls
42 lines (36 loc) · 1.19 KB
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
import * as fs from "node:fs";
import * as path from "node:path";
import { fileURLToPath } from "node:url";
import { rimraf } from "rimraf";
const projectRoot = path.join(import.meta.dirname, "../..");
const frontend = packageDir("@home-assistant-matter-hub/frontend", "dist");
const backend = packageDir("@home-assistant-matter-hub/backend", "dist");
const dist = path.resolve(import.meta.dirname, "dist");
await rimraf(dist);
fs.cpSync(frontend, path.join(dist, "frontend"), {
recursive: true,
});
fs.cpSync(backend, path.join(dist, "backend"), {
recursive: true,
});
fs.cpSync(
path.join(projectRoot, "README.md"),
path.join(import.meta.dirname, "README.md"),
);
fs.cpSync(
path.join(projectRoot, "LICENSE"),
path.join(import.meta.dirname, "LICENSE"),
);
/**
* Resolve a directory in a package
* @param {string} packageName The path of the package json
* @param {string} directory The dist dir in the package
* @returns {string}
*/
function packageDir(packageName, directory) {
const packageJsonPath = fileURLToPath(
import.meta.resolve(path.join(packageName, "package.json")),
);
const packagePath = path.dirname(packageJsonPath);
return path.join(packagePath, directory);
}