@bb-labs/bldr 0.0.16 → 0.0.17
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.
- package/dist/core/builder.js +26 -27
- package/dist/index.js +2 -0
- package/package.json +2 -1
package/dist/core/builder.js
CHANGED
|
@@ -10,7 +10,7 @@ export async function build(args) {
|
|
|
10
10
|
const cfg = readTsConfig(tsconfigPath);
|
|
11
11
|
if (!cfg.outDir || !cfg.rootDir) {
|
|
12
12
|
throw new Error([
|
|
13
|
-
|
|
13
|
+
`❌ tsconfig must specify both "compilerOptions.outDir" and "compilerOptions.rootDir" for dist sync`,
|
|
14
14
|
`Found: rootDir=${String(cfg.rootDir)} outDir=${String(cfg.outDir)}`,
|
|
15
15
|
`File: ${tsconfigPath}`,
|
|
16
16
|
].join("\n"));
|
|
@@ -27,19 +27,19 @@ export async function build(args) {
|
|
|
27
27
|
state.ui.destroy();
|
|
28
28
|
state.ui = undefined;
|
|
29
29
|
}
|
|
30
|
-
console.log("\n
|
|
30
|
+
console.log("\n⏳ Shutting down...");
|
|
31
31
|
try {
|
|
32
32
|
if (state.watcher) {
|
|
33
33
|
await state.watcher.close();
|
|
34
34
|
}
|
|
35
|
-
console.log("
|
|
35
|
+
console.log("✅ Src watcher closed");
|
|
36
36
|
}
|
|
37
37
|
catch (error) {
|
|
38
|
-
console.error(
|
|
38
|
+
console.error(`❌ Error closing src watcher: ${error}`);
|
|
39
39
|
}
|
|
40
40
|
const killProcess = (name, p) => {
|
|
41
41
|
if (p && !p.killed) {
|
|
42
|
-
console.log(
|
|
42
|
+
console.log(`🔄 Killing ${name}...`);
|
|
43
43
|
p.kill();
|
|
44
44
|
return new Promise((resolve) => {
|
|
45
45
|
const timeout = setTimeout(() => {
|
|
@@ -56,7 +56,7 @@ export async function build(args) {
|
|
|
56
56
|
return Promise.resolve();
|
|
57
57
|
};
|
|
58
58
|
await Promise.all([killProcess("tsc", state.tsc), killProcess("tsc-alias", state.alias)]);
|
|
59
|
-
console.log("
|
|
59
|
+
console.log("✅ All processes cleaned up");
|
|
60
60
|
process.exit(code);
|
|
61
61
|
};
|
|
62
62
|
// Register shutdown handlers
|
|
@@ -68,30 +68,29 @@ export async function build(args) {
|
|
|
68
68
|
state.ui?.logToBldr(args.join(" "));
|
|
69
69
|
};
|
|
70
70
|
console.error = (...args) => {
|
|
71
|
-
state.ui?.logToBldr(`{red-fg}
|
|
71
|
+
state.ui?.logToBldr(`{red-fg}❌ ${args.join(" ")}{/red-fg}`);
|
|
72
72
|
};
|
|
73
73
|
}
|
|
74
|
-
const prefix = args.watch ? "" : "[bldr] ";
|
|
75
74
|
console.log([
|
|
76
|
-
`\n
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
75
|
+
`\n📦 Project : ${rel(cwd, tsconfigPath)}`,
|
|
76
|
+
`📁 Root Dir : ${rel(cwd, rootDirAbs)}`,
|
|
77
|
+
`📁 Out Dir : ${rel(cwd, outDirAbs)}`,
|
|
78
|
+
`➡️ Mode : ${args.watch ? "Watch" : "Build"}\n`,
|
|
80
79
|
].join("\n"));
|
|
81
|
-
console.log(
|
|
80
|
+
console.log(`📦 Cleaning output directory...`);
|
|
82
81
|
await rmIfExists(outDirAbs);
|
|
83
|
-
console.log(
|
|
82
|
+
console.log(`✅ Output directory cleaned`);
|
|
84
83
|
const tscArgs = ["-p", tsconfigPath, "--pretty"];
|
|
85
84
|
const aliasArgs = ["-p", tsconfigPath];
|
|
86
85
|
if (!args.watch) {
|
|
87
86
|
try {
|
|
88
|
-
console.log(
|
|
87
|
+
console.log(`\n📦 Starting build...`);
|
|
89
88
|
await run("tsc", tscArgs, cwd);
|
|
90
89
|
await run("tsc-alias", aliasArgs, cwd);
|
|
91
|
-
console.log(
|
|
90
|
+
console.log(`✅ Build completed successfully!`);
|
|
92
91
|
}
|
|
93
92
|
catch (error) {
|
|
94
|
-
console.error(
|
|
93
|
+
console.error(`❌ Build failed, cleaning output directory...`);
|
|
95
94
|
await rmIfExists(outDirAbs);
|
|
96
95
|
throw error;
|
|
97
96
|
}
|
|
@@ -99,14 +98,14 @@ export async function build(args) {
|
|
|
99
98
|
}
|
|
100
99
|
// Watch mode initial pass
|
|
101
100
|
try {
|
|
102
|
-
console.log(
|
|
101
|
+
console.log(`\n📦 Starting initial build...`);
|
|
103
102
|
await run("tsc", tscArgs, cwd);
|
|
104
103
|
await run("tsc-alias", aliasArgs, cwd);
|
|
105
|
-
console.log(
|
|
104
|
+
console.log(`✅ Initial build completed`);
|
|
106
105
|
}
|
|
107
106
|
catch (error) {
|
|
108
107
|
if (state.ui) {
|
|
109
|
-
state.ui.tscBox.insertBottom(
|
|
108
|
+
state.ui.tscBox.insertBottom(`❌ Initial build failed: ${error.message}{/red-fg}`);
|
|
110
109
|
state.ui.tscBox.setScrollPerc(100);
|
|
111
110
|
state.ui.screen.render();
|
|
112
111
|
}
|
|
@@ -129,14 +128,14 @@ export async function build(args) {
|
|
|
129
128
|
p.stderr?.on("data", handleData);
|
|
130
129
|
p.on("error", (error) => {
|
|
131
130
|
if (state.ui) {
|
|
132
|
-
box.insertBottom(
|
|
131
|
+
box.insertBottom(`❌ ${error}{/red-fg}`);
|
|
133
132
|
box.setScrollPerc(100);
|
|
134
133
|
state.ui.screen.render();
|
|
135
134
|
}
|
|
136
135
|
});
|
|
137
136
|
p.on("exit", (code) => {
|
|
138
137
|
if (code !== 0 && code !== null) {
|
|
139
|
-
console.error(
|
|
138
|
+
console.error(`❌ ${p === state.tsc ? "tsc" : "tsc-alias"} exited with code ${code}`);
|
|
140
139
|
}
|
|
141
140
|
// If one of them exits unexpectedly in watch mode, we might want to shut down or restart
|
|
142
141
|
// For now, let's just shut down if it's not a normal exit
|
|
@@ -175,26 +174,26 @@ export async function build(args) {
|
|
|
175
174
|
await queuedOperation(absPath, async () => {
|
|
176
175
|
if (isTsLike(absPath)) {
|
|
177
176
|
await cleaner.removeEmittedForSource(absPath);
|
|
178
|
-
console.log(
|
|
177
|
+
console.log(`🔄 Sync: removed output for ${path.relative(rootDirAbs, absPath)}`);
|
|
179
178
|
}
|
|
180
179
|
else {
|
|
181
180
|
const outPath = path.join(outDirAbs, path.relative(rootDirAbs, absPath));
|
|
182
181
|
await rmIfExists(outPath);
|
|
183
|
-
console.log(
|
|
182
|
+
console.log(`🔄 Sync: removed asset ${path.relative(rootDirAbs, absPath)}`);
|
|
184
183
|
}
|
|
185
184
|
});
|
|
186
185
|
}
|
|
187
186
|
catch (error) {
|
|
188
|
-
console.error(
|
|
187
|
+
console.error(`❌ Error handling file deletion ${absPath}: ${error}`);
|
|
189
188
|
}
|
|
190
189
|
});
|
|
191
190
|
srcWatcher.on("unlinkDir", async (absDir) => {
|
|
192
191
|
try {
|
|
193
192
|
await cleaner.removeOutDirForSourceDir(absDir);
|
|
194
|
-
console.log(
|
|
193
|
+
console.log(`🔄 Sync: removed directory ${path.relative(rootDirAbs, absDir)}`);
|
|
195
194
|
}
|
|
196
195
|
catch (error) {
|
|
197
|
-
console.error(
|
|
196
|
+
console.error(`❌ Error handling directory deletion ${absDir}: ${error}`);
|
|
198
197
|
}
|
|
199
198
|
});
|
|
200
199
|
}
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,8 @@ import { parseArgs } from "./utils/args.js";
|
|
|
3
3
|
import { build } from "./core/builder.js";
|
|
4
4
|
import { checkDependencies } from "./utils/process.js";
|
|
5
5
|
async function main() {
|
|
6
|
+
console.log("------------- bldr -------------");
|
|
7
|
+
console.log("📦 Initializing...");
|
|
6
8
|
// Check if required dependencies are installed
|
|
7
9
|
const depsOk = await checkDependencies();
|
|
8
10
|
if (!depsOk) {
|