elegance-js 3.0.1 → 3.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/bin/export.js +42 -0
  2. package/package.json +3 -2
package/bin/export.js ADDED
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/env node
2
+ import { spawn, ChildProcess } from "node:child_process";
3
+ import { join, dirname } from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+
6
+ const __filename = fileURLToPath(import.meta.url);
7
+ const __dirname = dirname(__filename);
8
+
9
+ const BUILD_PROD_ENTRY = join(__dirname, "build", "prod.js");
10
+
11
+ const MODE = process.argv.includes("-prod") ? "prod" : "dev";
12
+
13
+ function spawnTs(entry, extraEnv = {}) {
14
+ return spawn("node", ["--import", "ts-arc/register", entry], {
15
+ stdio: ["inherit", "inherit", "inherit", "ipc"],
16
+ env: {
17
+ ...process.env,
18
+ ELEGANCE_DEV_MODE: MODE,
19
+ ARGS: JSON.stringify(process.argv.slice(2)),
20
+ ...extraEnv,
21
+ },
22
+ });
23
+ }
24
+
25
+ function spawnBuild() {
26
+ return spawnTs(BUILD_PROD_ENTRY);
27
+ }
28
+
29
+ function runBuild() {
30
+ return new Promise((resolve, reject) => {
31
+ const build = spawnBuild();
32
+
33
+ build.once("exit", (code) => {
34
+ if (code === 0 || code === null) resolve();
35
+ else reject(new Error(`Build process exited with code ${code}`));
36
+ });
37
+ });
38
+ }
39
+
40
+ (async () => {
41
+ await runBuild();
42
+ })();
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "elegance-js",
3
- "version": "3.0.1",
3
+ "version": "3.0.2",
4
4
  "type": "module",
5
5
  "main": "dist/user-utils.js",
6
6
  "bin": {
7
7
  "bootstrap": "./bin/bootstrap.js",
8
- "elegance": "./bin/run.js"
8
+ "elegance": "./bin/run.js",
9
+ "export": "./bin/export.js"
9
10
  },
10
11
  "files": [
11
12
  "dist"