@akanjs/cli 2.4.1-rc.3 → 2.4.1-rc.5
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/.build-stamp +1 -0
- package/{agent.command-h4afc69n.js → agent.command-t4346579.js} +6 -6
- package/{application.command-jkmbsd1x.js → application.command-zkmeemdt.js} +5 -4
- package/{applicationBuildRunner-ny84tjhc.js → applicationBuildRunner-5w8j9yp7.js} +2 -1
- package/buildBatch.proc.js +20 -3
- package/{capacitorApp-y0h6cgft.js → capacitorApp-wnxzrppx.js} +2 -2
- package/{cloud.command-53j76grx.js → cloud.command-5ztqxppm.js} +8 -7
- package/{context.command-ds3mka9p.js → context.command-smwxwgwf.js} +13 -13
- package/{guideline.command-ya0dh44f.js → guideline.command-1r0esdjs.js} +3 -3
- package/incrementalBuilder.proc.js +90 -34
- package/index-0fn1r7gg.js +466 -0
- package/{index-1fpjvqhs.js → index-0jwvs8vp.js} +11 -11
- package/{index-a6sbyy0b.js → index-0t7pwff2.js} +3 -0
- package/{index-h6ca6qg0.js → index-2v10yr8g.js} +1 -1
- package/{index-m9pca6jv.js → index-2v6a4wd5.js} +4 -4
- package/{index-45aj5ry0.js → index-3sd2vape.js} +3 -3
- package/{index-gb26e7z0.js → index-ahpcr9ss.js} +3 -3
- package/{index-8rc0bm04.js → index-eay4t1te.js} +2 -2
- package/{index-qaq13qk3.js → index-eqxmxan6.js} +1 -1
- package/{index-pmm9e2jf.js → index-fh990y67.js} +2 -2
- package/{index-dynknvzd.js → index-gr4cjv99.js} +3 -3
- package/{index-1xdrsbry.js → index-hk58kr1m.js} +1 -1
- package/{index-85msc0wg.js → index-jbtn8h1y.js} +3 -3
- package/{index-q7zcac6n.js → index-khzzttv1.js} +108 -191
- package/{index-rgfxj6qc.js → index-n5y2gbf2.js} +307 -15
- package/{index-n6h3482q.js → index-nv7et4t3.js} +2 -2
- package/{index-hwzpw9c1.js → index-pya1h7wx.js} +3 -3
- package/{index-hdqztm58.js → index-qpz4csbs.js} +1 -1
- package/{index-0hjg9qs5.js → index-s9yajzkj.js} +5 -5
- package/{index-fmky5k3p.js → index-wh201a76.js} +5 -5
- package/{index-swf4bmbg.js → index-y4kg682s.js} +1 -1
- package/index.js +18 -18
- package/{library.command-r15zdqvp.js → library.command-jrew04m6.js} +3 -3
- package/{localRegistry.command-25sv5hmt.js → localRegistry.command-m08dkm1b.js} +7 -6
- package/{module.command-tnj2bzst.js → module.command-p98t7522.js} +6 -6
- package/{package.command-5x5m0ej1.js → package.command-57dyrfmn.js} +3 -3
- package/package.json +2 -2
- package/{page.command-c6xdx0xm.js → page.command-tas6f3na.js} +3 -3
- package/{primitive.command-q1ycj5vr.js → primitive.command-bjrbsakw.js} +7 -7
- package/{quality.command-es67wvdp.js → quality.command-zavaafbw.js} +2 -2
- package/{repair.command-677675vw.js → repair.command-je57wx67.js} +5 -5
- package/{scalar.command-bmrmp8n4.js → scalar.command-gqqyy1kr.js} +5 -5
- package/{workflow.command-64550hka.js → workflow.command-d6mrc47s.js} +10 -10
- package/{workspace.command-pmfxxfew.js → workspace.command-bbg96z8k.js} +20 -19
package/.build-stamp
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
97b051f1849d61848768f6c43d1dbcc90953864ce31504f1f376a61adb4481fb
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
AgentScript
|
|
4
|
-
} from "./index-
|
|
5
|
-
import"./index-
|
|
6
|
-
import"./index-
|
|
7
|
-
import"./index-
|
|
4
|
+
} from "./index-pya1h7wx.js";
|
|
5
|
+
import"./index-eay4t1te.js";
|
|
6
|
+
import"./index-2v10yr8g.js";
|
|
7
|
+
import"./index-eqxmxan6.js";
|
|
8
8
|
import {
|
|
9
9
|
Workspace,
|
|
10
10
|
command
|
|
11
|
-
} from "./index-
|
|
12
|
-
import"./index-
|
|
11
|
+
} from "./index-qpz4csbs.js";
|
|
12
|
+
import"./index-0t7pwff2.js";
|
|
13
13
|
import"./index-61keag0s.js";
|
|
14
14
|
import"./index-6pz1j0zj.js";
|
|
15
15
|
import"./index-r24hmh0q.js";
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
ApplicationScript
|
|
4
|
-
} from "./index-
|
|
4
|
+
} from "./index-n5y2gbf2.js";
|
|
5
5
|
import {
|
|
6
6
|
getMobileTargetChoices
|
|
7
7
|
} from "./index-76rn3g2c.js";
|
|
8
|
-
import"./index-
|
|
8
|
+
import"./index-fh990y67.js";
|
|
9
9
|
import {
|
|
10
10
|
App,
|
|
11
11
|
Exec,
|
|
12
12
|
Sys,
|
|
13
13
|
Workspace,
|
|
14
14
|
command
|
|
15
|
-
} from "./index-
|
|
15
|
+
} from "./index-qpz4csbs.js";
|
|
16
16
|
import"./index-fgc8r6dj.js";
|
|
17
|
-
import"./index-
|
|
17
|
+
import"./index-0t7pwff2.js";
|
|
18
18
|
import"./index-61keag0s.js";
|
|
19
|
+
import"./index-0fn1r7gg.js";
|
|
19
20
|
import"./index-6pz1j0zj.js";
|
|
20
21
|
import"./index-r24hmh0q.js";
|
|
21
22
|
|
package/buildBatch.proc.js
CHANGED
|
@@ -2,14 +2,16 @@
|
|
|
2
2
|
import {
|
|
3
3
|
AppExecutor,
|
|
4
4
|
WorkspaceExecutor
|
|
5
|
-
} from "./index-
|
|
5
|
+
} from "./index-0t7pwff2.js";
|
|
6
6
|
import"./index-61keag0s.js";
|
|
7
7
|
import {
|
|
8
8
|
CsrArtifactBuilder,
|
|
9
9
|
CssCompiler,
|
|
10
10
|
FontOptimizer,
|
|
11
|
-
PagesBundleBuilder
|
|
12
|
-
|
|
11
|
+
PagesBundleBuilder,
|
|
12
|
+
SsrBaseArtifactBuilder
|
|
13
|
+
} from "./index-khzzttv1.js";
|
|
14
|
+
import"./index-0fn1r7gg.js";
|
|
13
15
|
import"./index-6pz1j0zj.js";
|
|
14
16
|
import"./index-r24hmh0q.js";
|
|
15
17
|
|
|
@@ -28,6 +30,8 @@ class BuildBatch {
|
|
|
28
30
|
this.#result = { generation: request.generation, errors: {} };
|
|
29
31
|
}
|
|
30
32
|
async run() {
|
|
33
|
+
if (this.#request.needs.includes("base"))
|
|
34
|
+
await this.#buildBase();
|
|
31
35
|
if (this.#request.needs.includes("csr"))
|
|
32
36
|
await this.#buildCsr();
|
|
33
37
|
if (this.#request.needs.includes("pages"))
|
|
@@ -51,6 +55,19 @@ class BuildBatch {
|
|
|
51
55
|
}
|
|
52
56
|
});
|
|
53
57
|
}
|
|
58
|
+
async#buildBase() {
|
|
59
|
+
const started = Date.now();
|
|
60
|
+
try {
|
|
61
|
+
const { artifact, optimizedFonts } = await new SsrBaseArtifactBuilder(this.#app).build();
|
|
62
|
+
this.#result.artifact = artifact;
|
|
63
|
+
this.#result.optimizedFonts = optimizedFonts;
|
|
64
|
+
this.#logger.verbose(`base-artifact ok buildId=${artifact.pagesBundleBuildId} (${Date.now() - started}ms)`);
|
|
65
|
+
} catch (err) {
|
|
66
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
67
|
+
this.#logger.error(`base-artifact failed: ${message}`);
|
|
68
|
+
this.#result.errors.base = message;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
54
71
|
async#buildCsr() {
|
|
55
72
|
const started = Date.now();
|
|
56
73
|
try {
|
|
@@ -24,9 +24,9 @@ import {
|
|
|
24
24
|
selectLocalDevHost,
|
|
25
25
|
sortIosRunTargets,
|
|
26
26
|
writeRootCapacitorConfig
|
|
27
|
-
} from "./index-
|
|
27
|
+
} from "./index-hk58kr1m.js";
|
|
28
28
|
import"./index-76rn3g2c.js";
|
|
29
|
-
import"./index-
|
|
29
|
+
import"./index-0t7pwff2.js";
|
|
30
30
|
import"./index-61keag0s.js";
|
|
31
31
|
import"./index-6pz1j0zj.js";
|
|
32
32
|
import"./index-r24hmh0q.js";
|
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
CloudScript
|
|
4
|
-
} from "./index-
|
|
5
|
-
import"./index-
|
|
4
|
+
} from "./index-s9yajzkj.js";
|
|
5
|
+
import"./index-gr4cjv99.js";
|
|
6
6
|
import {
|
|
7
7
|
GlobalConfig
|
|
8
8
|
} from "./index-5vvwc0cz.js";
|
|
9
|
-
import"./index-
|
|
9
|
+
import"./index-n5y2gbf2.js";
|
|
10
10
|
import"./index-76rn3g2c.js";
|
|
11
|
-
import"./index-
|
|
12
|
-
import"./index-
|
|
11
|
+
import"./index-fh990y67.js";
|
|
12
|
+
import"./index-nv7et4t3.js";
|
|
13
13
|
import {
|
|
14
14
|
Workspace,
|
|
15
15
|
command
|
|
16
|
-
} from "./index-
|
|
16
|
+
} from "./index-qpz4csbs.js";
|
|
17
17
|
import"./index-fgc8r6dj.js";
|
|
18
|
-
import"./index-
|
|
18
|
+
import"./index-0t7pwff2.js";
|
|
19
19
|
import"./index-x53a5nya.js";
|
|
20
20
|
import"./index-61keag0s.js";
|
|
21
|
+
import"./index-0fn1r7gg.js";
|
|
21
22
|
import"./index-6pz1j0zj.js";
|
|
22
23
|
import"./index-r24hmh0q.js";
|
|
23
24
|
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
ContextScript
|
|
4
|
-
} from "./index-
|
|
5
|
-
import"./index-
|
|
6
|
-
import"./index-
|
|
7
|
-
import"./index-
|
|
8
|
-
import"./index-
|
|
9
|
-
import"./index-
|
|
10
|
-
import"./index-
|
|
4
|
+
} from "./index-0jwvs8vp.js";
|
|
5
|
+
import"./index-jbtn8h1y.js";
|
|
6
|
+
import"./index-3sd2vape.js";
|
|
7
|
+
import"./index-ahpcr9ss.js";
|
|
8
|
+
import"./index-2v6a4wd5.js";
|
|
9
|
+
import"./index-wh201a76.js";
|
|
10
|
+
import"./index-y4kg682s.js";
|
|
11
11
|
import"./index-ss469dec.js";
|
|
12
|
-
import"./index-
|
|
13
|
-
import"./index-
|
|
14
|
-
import"./index-
|
|
15
|
-
import"./index-
|
|
12
|
+
import"./index-hk58kr1m.js";
|
|
13
|
+
import"./index-eay4t1te.js";
|
|
14
|
+
import"./index-2v10yr8g.js";
|
|
15
|
+
import"./index-eqxmxan6.js";
|
|
16
16
|
import"./index-5vvwc0cz.js";
|
|
17
17
|
import"./index-76rn3g2c.js";
|
|
18
18
|
import {
|
|
19
19
|
Workspace,
|
|
20
20
|
command
|
|
21
|
-
} from "./index-
|
|
22
|
-
import"./index-
|
|
21
|
+
} from "./index-qpz4csbs.js";
|
|
22
|
+
import"./index-0t7pwff2.js";
|
|
23
23
|
import"./index-61keag0s.js";
|
|
24
24
|
import"./index-6pz1j0zj.js";
|
|
25
25
|
import"./index-r24hmh0q.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
Prompter
|
|
4
|
-
} from "./index-
|
|
4
|
+
} from "./index-eqxmxan6.js";
|
|
5
5
|
import {
|
|
6
6
|
AiSession
|
|
7
7
|
} from "./index-5vvwc0cz.js";
|
|
@@ -10,10 +10,10 @@ import {
|
|
|
10
10
|
command,
|
|
11
11
|
runner,
|
|
12
12
|
script
|
|
13
|
-
} from "./index-
|
|
13
|
+
} from "./index-qpz4csbs.js";
|
|
14
14
|
import {
|
|
15
15
|
getDirname
|
|
16
|
-
} from "./index-
|
|
16
|
+
} from "./index-0t7pwff2.js";
|
|
17
17
|
import {
|
|
18
18
|
FileSys
|
|
19
19
|
} from "./index-61keag0s.js";
|
|
@@ -5,18 +5,19 @@ import {
|
|
|
5
5
|
import {
|
|
6
6
|
AppExecutor,
|
|
7
7
|
WorkspaceExecutor
|
|
8
|
-
} from "./index-
|
|
8
|
+
} from "./index-0t7pwff2.js";
|
|
9
9
|
import"./index-61keag0s.js";
|
|
10
10
|
import {
|
|
11
11
|
AutoImportSync,
|
|
12
12
|
DevChangePlanner,
|
|
13
13
|
DevGeneratedIndexSync,
|
|
14
14
|
GraphClientEntryDiscovery,
|
|
15
|
+
RouteClientBuilder
|
|
16
|
+
} from "./index-khzzttv1.js";
|
|
17
|
+
import {
|
|
15
18
|
HmrWatcher,
|
|
16
|
-
RouteClientBuilder,
|
|
17
|
-
SsrBaseArtifactBuilder,
|
|
18
19
|
WatchRootResolver
|
|
19
|
-
} from "./index-
|
|
20
|
+
} from "./index-0fn1r7gg.js";
|
|
20
21
|
import"./index-6pz1j0zj.js";
|
|
21
22
|
import"./index-r24hmh0q.js";
|
|
22
23
|
|
|
@@ -90,6 +91,39 @@ class BuildBatchRunner {
|
|
|
90
91
|
}
|
|
91
92
|
}
|
|
92
93
|
|
|
94
|
+
// pkgs/@akanjs/devkit/incrementalBuilder/builderChannel.ts
|
|
95
|
+
class BuilderChannel {
|
|
96
|
+
static #flushTimeoutMs = 5000;
|
|
97
|
+
static #flushing = new Set;
|
|
98
|
+
static send(message) {
|
|
99
|
+
const send = process.send;
|
|
100
|
+
if (!send)
|
|
101
|
+
return Promise.resolve();
|
|
102
|
+
const flushed = new Promise((resolve) => {
|
|
103
|
+
const timer = setTimeout(resolve, BuilderChannel.#flushTimeoutMs);
|
|
104
|
+
send.call(process, message, undefined, undefined, () => {
|
|
105
|
+
clearTimeout(timer);
|
|
106
|
+
resolve();
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
BuilderChannel.#flushing.add(flushed);
|
|
110
|
+
flushed.then(() => BuilderChannel.#flushing.delete(flushed));
|
|
111
|
+
return flushed;
|
|
112
|
+
}
|
|
113
|
+
static emit(message) {
|
|
114
|
+
BuilderChannel.send(message);
|
|
115
|
+
}
|
|
116
|
+
static async drain() {
|
|
117
|
+
let flushed = 0;
|
|
118
|
+
while (BuilderChannel.#flushing.size) {
|
|
119
|
+
const pending = [...BuilderChannel.#flushing];
|
|
120
|
+
flushed += pending.length;
|
|
121
|
+
await Promise.all(pending);
|
|
122
|
+
}
|
|
123
|
+
return flushed;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
93
127
|
// pkgs/@akanjs/devkit/incrementalBuilder/incrementalBuilder.proc.ts
|
|
94
128
|
class IncrementalBuilder {
|
|
95
129
|
#logger = new Logger2("IncrementalBuilder");
|
|
@@ -102,6 +136,7 @@ class IncrementalBuilder {
|
|
|
102
136
|
#changePlanner;
|
|
103
137
|
#generatedIndexSync;
|
|
104
138
|
#autoImportSync;
|
|
139
|
+
#watcher = null;
|
|
105
140
|
#generation = 0;
|
|
106
141
|
#csrActive = IncrementalBuilder.#csrArmedByEnv();
|
|
107
142
|
#workQueue = Promise.resolve();
|
|
@@ -130,7 +165,7 @@ class IncrementalBuilder {
|
|
|
130
165
|
return `${this.#app.cwdPath}/.akan/artifact`;
|
|
131
166
|
}
|
|
132
167
|
async handleBuildRoute(msg) {
|
|
133
|
-
|
|
168
|
+
await this.#enqueueWork(`build-route:${msg.routeId}`, async () => BuilderChannel.send(await this.#handleBuildRoute(msg)));
|
|
134
169
|
}
|
|
135
170
|
async#handleBuildRoute(msg) {
|
|
136
171
|
try {
|
|
@@ -169,7 +204,7 @@ class IncrementalBuilder {
|
|
|
169
204
|
#sendBuildStatus(phase, { generation, ok, files, message }) {
|
|
170
205
|
if (typeof generation !== "number")
|
|
171
206
|
return;
|
|
172
|
-
|
|
207
|
+
BuilderChannel.emit({
|
|
173
208
|
type: "build-status",
|
|
174
209
|
data: {
|
|
175
210
|
generation,
|
|
@@ -204,7 +239,7 @@ class IncrementalBuilder {
|
|
|
204
239
|
#reportMetrics() {
|
|
205
240
|
if (!this.#idle || this.#shuttingDown)
|
|
206
241
|
return;
|
|
207
|
-
|
|
242
|
+
BuilderChannel.emit({
|
|
208
243
|
type: "builder-metrics",
|
|
209
244
|
data: { rssBytes: process.memoryUsage.rss(), generation: this.#generation, workCount: this.#workCount }
|
|
210
245
|
});
|
|
@@ -226,7 +261,8 @@ class IncrementalBuilder {
|
|
|
226
261
|
await this.#cssRebuildQueue.catch(() => {
|
|
227
262
|
return;
|
|
228
263
|
});
|
|
229
|
-
|
|
264
|
+
const flushed = await BuilderChannel.drain();
|
|
265
|
+
this.#logger.info(`drained in ${Date.now() - started}ms${flushed ? ` after flushing ${flushed} ipc write(s)` : ""}; exiting for recycle`);
|
|
230
266
|
process.exit(0);
|
|
231
267
|
}
|
|
232
268
|
get shuttingDown() {
|
|
@@ -300,7 +336,8 @@ class IncrementalBuilder {
|
|
|
300
336
|
await this.#enqueueWork("hmr-batch", async () => this.#handleWatchBatch(appDir, artifactDir, batch));
|
|
301
337
|
}
|
|
302
338
|
});
|
|
303
|
-
watcher.start();
|
|
339
|
+
await watcher.start();
|
|
340
|
+
this.#watcher = watcher;
|
|
304
341
|
this.#logger.verbose(`watching ${roots.length} roots`);
|
|
305
342
|
}
|
|
306
343
|
async#handleWatchBatch(appDir, artifactDir, batch) {
|
|
@@ -314,6 +351,7 @@ class IncrementalBuilder {
|
|
|
314
351
|
if (autoImport.changedFiles.length > 0)
|
|
315
352
|
this.#logger.verbose(`[auto-import] inserted imports into ${autoImport.changedFiles.length} file(s)`);
|
|
316
353
|
const indexSync = await this.#generatedIndexSync.syncForBatch(batch.files);
|
|
354
|
+
await this.#watcher?.absorb([...autoImport.changedFiles, ...indexSync.changedFiles]);
|
|
317
355
|
const { files, kinds, expandedBatch, event, hasSyncErrors } = prepareDevWatchBatch({
|
|
318
356
|
generation,
|
|
319
357
|
batch,
|
|
@@ -335,7 +373,7 @@ class IncrementalBuilder {
|
|
|
335
373
|
if (hasSyncErrors) {
|
|
336
374
|
this.#sendBuildStatus("barrel", { generation, ok: false, files, message: indexSync.errors.join(`
|
|
337
375
|
`) });
|
|
338
|
-
|
|
376
|
+
BuilderChannel.emit(event);
|
|
339
377
|
return;
|
|
340
378
|
}
|
|
341
379
|
if (indexSync.changedFiles.length > 0)
|
|
@@ -360,7 +398,7 @@ class IncrementalBuilder {
|
|
|
360
398
|
needs.push("pages");
|
|
361
399
|
needs.push("css");
|
|
362
400
|
}
|
|
363
|
-
|
|
401
|
+
BuilderChannel.emit(event);
|
|
364
402
|
if (needs.length > 0)
|
|
365
403
|
await this.#runBatch({ generation, needs, changedFiles: files });
|
|
366
404
|
else if (kinds.includes("css")) {
|
|
@@ -374,14 +412,15 @@ class IncrementalBuilder {
|
|
|
374
412
|
changedFiles
|
|
375
413
|
}) {
|
|
376
414
|
const started = Date.now();
|
|
377
|
-
const result = await this.#batchRunner.run(await this.#batchRequest({ generation, needs, changedFiles }), (msg) =>
|
|
415
|
+
const result = await this.#batchRunner.run(await this.#batchRequest({ generation, needs, changedFiles }), (msg) => BuilderChannel.emit(msg));
|
|
378
416
|
if (result.optimizedFonts)
|
|
379
417
|
this.#optimizedFonts = result.optimizedFonts;
|
|
380
418
|
if (result.cssAssets)
|
|
381
419
|
this.#artifact = { ...this.#artifact, cssAssets: result.cssAssets };
|
|
382
420
|
if (result.crashed) {
|
|
383
421
|
for (const need of needs)
|
|
384
|
-
|
|
422
|
+
if (need !== "base")
|
|
423
|
+
this.#sendBuildStatus(need, { generation, ok: false, files: changedFiles, message: result.errors[need] });
|
|
385
424
|
}
|
|
386
425
|
if (needs.includes("css"))
|
|
387
426
|
this.#logger.verbose(`css-rebuild checked (${Date.now() - started}ms)`);
|
|
@@ -408,7 +447,7 @@ class IncrementalBuilder {
|
|
|
408
447
|
async boot() {
|
|
409
448
|
if (this.#watch)
|
|
410
449
|
await this.installWatcher();
|
|
411
|
-
|
|
450
|
+
BuilderChannel.emit({ type: "builder-ready" });
|
|
412
451
|
this.#logger.verbose(`ready (watch=${this.#watch})`);
|
|
413
452
|
}
|
|
414
453
|
async announceRecoveredState(changedFiles) {
|
|
@@ -420,7 +459,7 @@ class IncrementalBuilder {
|
|
|
420
459
|
async announceBootState() {
|
|
421
460
|
const generation = ++this.#generation;
|
|
422
461
|
const reason = "builder-recycle";
|
|
423
|
-
|
|
462
|
+
await BuilderChannel.send({
|
|
424
463
|
type: "pages-updated",
|
|
425
464
|
data: {
|
|
426
465
|
bundlePath: this.#artifact.pagesBundlePath,
|
|
@@ -435,24 +474,25 @@ class IncrementalBuilder {
|
|
|
435
474
|
cssUrl,
|
|
436
475
|
Buffer.from(await Bun.file(path2.join(this.#artifactDir, cssRelPath)).arrayBuffer()).toString("base64")
|
|
437
476
|
])));
|
|
438
|
-
|
|
477
|
+
await BuilderChannel.send({
|
|
439
478
|
type: "css-updated",
|
|
440
479
|
data: { cssAssets, cssBase64ByUrl, generation, changedFiles: [], reason }
|
|
441
480
|
});
|
|
442
481
|
this.#logger.verbose(`announced boot state after recycle generation=${generation}`);
|
|
443
482
|
}
|
|
444
483
|
async handleBuildCsr(msg) {
|
|
445
|
-
|
|
484
|
+
await this.#enqueueWork("build-csr", async () => {
|
|
446
485
|
const started = Date.now();
|
|
447
486
|
const result = await this.#batchRunner.run(await this.#batchRequest({ generation: this.#generation, needs: ["csr"], changedFiles: [] }));
|
|
448
487
|
const error = result.errors.csr;
|
|
449
488
|
if (error) {
|
|
450
489
|
this.#logger.error(`csr-build failed: ${error}`);
|
|
451
|
-
|
|
490
|
+
await BuilderChannel.send({ type: "build-csr-res", id: msg.id, ok: false, error });
|
|
491
|
+
return;
|
|
452
492
|
}
|
|
453
493
|
this.#csrActive = true;
|
|
454
494
|
this.#logger.info(`csr-build ok on demand (${Date.now() - started}ms); rebuilding CSR on every save now`);
|
|
455
|
-
|
|
495
|
+
await BuilderChannel.send({ type: "build-csr-res", id: msg.id, ok: true });
|
|
456
496
|
});
|
|
457
497
|
}
|
|
458
498
|
#shouldRebuildCsr() {
|
|
@@ -461,10 +501,25 @@ class IncrementalBuilder {
|
|
|
461
501
|
static #csrArmedByEnv() {
|
|
462
502
|
return process.env.AKAN_DEV_CSR_REBUILD === "1";
|
|
463
503
|
}
|
|
464
|
-
static async#buildBootDeps(app) {
|
|
465
|
-
const
|
|
504
|
+
static async#buildBootDeps(app, runner) {
|
|
505
|
+
const result = await runner.run({
|
|
506
|
+
appName: app.name,
|
|
507
|
+
workspaceRoot: app.workspace.workspaceRoot,
|
|
508
|
+
repoName: app.workspace.repoName,
|
|
509
|
+
generation: 0,
|
|
510
|
+
needs: ["base"],
|
|
511
|
+
changedFiles: [],
|
|
512
|
+
pageKeys: null,
|
|
513
|
+
optimizedFonts: null,
|
|
514
|
+
cssAssets: null,
|
|
515
|
+
artifactDir: path2.resolve(`${app.cwdPath}/.akan/artifact`)
|
|
516
|
+
});
|
|
517
|
+
if (result.errors.base)
|
|
518
|
+
throw new Error(result.errors.base);
|
|
519
|
+
if (!result.artifact || !result.optimizedFonts)
|
|
520
|
+
throw new Error("boot build reported success without an artifact; the build worker likely died");
|
|
466
521
|
const discovery = await GraphClientEntryDiscovery.create(app);
|
|
467
|
-
return { artifact, optimizedFonts, discovery };
|
|
522
|
+
return { artifact: result.artifact, optimizedFonts: result.optimizedFonts, discovery };
|
|
468
523
|
}
|
|
469
524
|
async rearmCsrFromEnv() {
|
|
470
525
|
if (!IncrementalBuilder.#csrArmedByEnv())
|
|
@@ -478,18 +533,18 @@ class IncrementalBuilder {
|
|
|
478
533
|
this.#logger.verbose("csr-rearm ok; this session had CSR armed before the builder restarted");
|
|
479
534
|
});
|
|
480
535
|
}
|
|
481
|
-
static #recoverBoot(app, bootError, logger) {
|
|
536
|
+
static #recoverBoot(app, bootError, logger, runner) {
|
|
482
537
|
const firstMessage = bootError instanceof Error ? bootError.message : String(bootError);
|
|
483
538
|
logger.error(`boot build failed; entering degraded watch mode until the error is fixed: ${firstMessage}`);
|
|
484
539
|
let generation = 0;
|
|
485
540
|
const sendFailure = (files, message) => {
|
|
486
|
-
|
|
541
|
+
BuilderChannel.emit({
|
|
487
542
|
type: "build-status",
|
|
488
543
|
data: { generation, phase: "pages", ok: false, files, message: `Boot build failed: ${message}` }
|
|
489
544
|
});
|
|
490
545
|
};
|
|
491
546
|
sendFailure([], firstMessage);
|
|
492
|
-
|
|
547
|
+
BuilderChannel.emit({ type: "builder-ready" });
|
|
493
548
|
return new Promise((resolve, reject) => {
|
|
494
549
|
(async () => {
|
|
495
550
|
const roots = await new WatchRootResolver(app).resolve();
|
|
@@ -502,7 +557,7 @@ class IncrementalBuilder {
|
|
|
502
557
|
try {
|
|
503
558
|
if (new Set(batch.kinds).has("config"))
|
|
504
559
|
await app.getConfig({ refresh: true });
|
|
505
|
-
const deps = await IncrementalBuilder.#buildBootDeps(app);
|
|
560
|
+
const deps = await IncrementalBuilder.#buildBootDeps(app, runner);
|
|
506
561
|
const builder = new IncrementalBuilder({ app, watch: true, initialGeneration: generation, ...deps });
|
|
507
562
|
watcher.stop();
|
|
508
563
|
logger.info(`boot build recovered generation=${generation}`);
|
|
@@ -514,7 +569,7 @@ class IncrementalBuilder {
|
|
|
514
569
|
}
|
|
515
570
|
}
|
|
516
571
|
});
|
|
517
|
-
watcher.start();
|
|
572
|
+
await watcher.start();
|
|
518
573
|
logger.warn(`[degraded] watching ${roots.length} roots for a fix`);
|
|
519
574
|
})().catch(reject);
|
|
520
575
|
});
|
|
@@ -544,19 +599,19 @@ class IncrementalBuilder {
|
|
|
544
599
|
if (msg.type === "build-route") {
|
|
545
600
|
const error = builder?.shuttingDown ? recyclingError : bootingError;
|
|
546
601
|
if (!builder || builder.shuttingDown) {
|
|
547
|
-
|
|
602
|
+
BuilderChannel.emit({ type: "build-route-res", id: msg.id, ok: false, error });
|
|
548
603
|
return;
|
|
549
604
|
}
|
|
550
|
-
builder.handleBuildRoute(msg)
|
|
605
|
+
builder.handleBuildRoute(msg);
|
|
551
606
|
return;
|
|
552
607
|
}
|
|
553
608
|
if (msg.type === "build-csr") {
|
|
554
609
|
const error = builder?.shuttingDown ? recyclingError : bootingError;
|
|
555
610
|
if (!builder || builder.shuttingDown) {
|
|
556
|
-
|
|
611
|
+
BuilderChannel.emit({ type: "build-csr-res", id: msg.id, ok: false, error });
|
|
557
612
|
return;
|
|
558
613
|
}
|
|
559
|
-
builder.handleBuildCsr(msg)
|
|
614
|
+
builder.handleBuildCsr(msg);
|
|
560
615
|
}
|
|
561
616
|
});
|
|
562
617
|
process.on("disconnect", () => {
|
|
@@ -564,19 +619,20 @@ class IncrementalBuilder {
|
|
|
564
619
|
process.exit(0);
|
|
565
620
|
});
|
|
566
621
|
let recoveredFiles = null;
|
|
622
|
+
const bootRunner = new BuildBatchRunner({ workspaceRoot, cwd: app.cwdPath });
|
|
567
623
|
try {
|
|
568
|
-
builder = new IncrementalBuilder({ app, watch, ...await IncrementalBuilder.#buildBootDeps(app) });
|
|
624
|
+
builder = new IncrementalBuilder({ app, watch, ...await IncrementalBuilder.#buildBootDeps(app, bootRunner) });
|
|
569
625
|
} catch (err) {
|
|
570
626
|
if (!watch)
|
|
571
627
|
throw err;
|
|
572
|
-
const recovered = await IncrementalBuilder.#recoverBoot(app, err, logger);
|
|
628
|
+
const recovered = await IncrementalBuilder.#recoverBoot(app, err, logger, bootRunner);
|
|
573
629
|
builder = recovered.builder;
|
|
574
630
|
recoveredFiles = recovered.changedFiles;
|
|
575
631
|
}
|
|
576
632
|
await builder.boot();
|
|
577
633
|
if (recoveredFiles)
|
|
578
634
|
await builder.announceRecoveredState(recoveredFiles);
|
|
579
|
-
else if (process.env.
|
|
635
|
+
else if (process.env.AKAN_BUILDER_ANNOUNCE_BOOT === "1")
|
|
580
636
|
await builder.announceBootState();
|
|
581
637
|
await builder.rearmCsrFromEnv();
|
|
582
638
|
}
|