This repository was archived by the owner on Jan 9, 2025. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.ts
More file actions
106 lines (91 loc) · 2.82 KB
/
build.ts
File metadata and controls
106 lines (91 loc) · 2.82 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import {buildSync, Platform} from "esbuild";
import glob from "fast-glob";
import fs from "fs";
buildSync({
entryPoints: ["./utils/CLIParser.ts"],
outfile: "./utils/CLIParser.js",
platform: "node",
format: "esm",
sourcemap: true
});
const CLIParser = await import("./utils/CLIParser.js");
const {packages} = CLIParser.default.getCommandLineArgumentsValues({
packages: {
type: "string[]"
}
})
const buildFileFilter = (file: string) =>
!packages
|| !file.startsWith("./packages")
|| packages.find(packageToBuild => file.startsWith(`./packages/${packageToBuild}`))
buildSync({
entryPoints: ["./utils/buildRecursively.ts"],
outfile: "./utils/buildRecursively.js",
platform: "node",
format: "esm",
sourcemap: true
});
const buildRecursively = await import("./utils/buildRecursively.js");
const utils = glob.sync("./utils/**/*.ts");
const toBuild = [
...utils,
"./packages/backup/index.ts",
"./packages/gui/index.ts",
"./packages/build/index.ts",
"./packages/deploy/index.ts",
"./packages/run/index.ts",
"./packages/watch/index.ts",
"./packages/watch/fileParser.ts",
"./packages/watch/watcher.ts",
"./packages/watch/fileParser.ts",
"./packages/watch/builder.ts",
"./packages/watch/utils.ts",
"./packages/create/index.ts",
"./packages/create/cli.ts",
"./packages/create/create.ts",
"./packages/share/index.ts",
"./packages/sync/index.ts",
"./packages/webapp/server/index.ts",
"./packages/webapp/server/HTML.ts",
"./packages/webapp/client/react/useAPI.ts",
"./packages/webapp/rpc/createClient.ts",
"./packages/webapp/rpc/createListener.ts",
"./CommandInterface.ts",
"./info.ts",
"./pack.ts",
"./prepare.ts",
"./test.ts",
"./cli.ts"
]
.filter(buildFileFilter)
.filter(file => !file.endsWith(".d.ts"));
await buildRecursively.default(toBuild);
[
{
file: "./packages/sync/rsync/src/RsyncErreur.ts",
platform: "node"
},
{
file: "./packages/deploy/nginx/getAvailablePorts.ts",
platform: "node"
},
{
file: "./packages/watch/client.ts",
platform: "browser"
}
]
.filter(({file}) => buildFileFilter(file))
.forEach(toBundle => buildSync({
entryPoints: [toBundle.file],
outfile: buildRecursively.convertPathToJSExt(toBundle.file),
bundle: true,
sourcemap: true,
format: "esm",
platform: toBundle.platform as Platform
}));
console.log('\x1b[32m%s\x1b[0m', "cli and scripts built");
const version = JSON.parse(fs.readFileSync("./package.json", {encoding: "utf8"})).version;
fs.writeFileSync("./version.ts", `const FullStackedVersion = "${version}";
export default FullStackedVersion;`);
await buildRecursively.default(["./version.ts"], true);
console.log(`v${version}`);