@ptkl/toolkit 0.9.0 → 0.9.1
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/bin/toolkit.js +3 -1
- package/dist/commands/forge.js +42 -17
- package/package.json +1 -1
package/dist/bin/toolkit.js
CHANGED
package/dist/commands/forge.js
CHANGED
|
@@ -6,6 +6,29 @@ import { writeFileSync, readFileSync, rmSync, existsSync } from "fs";
|
|
|
6
6
|
import axios from 'axios';
|
|
7
7
|
import Util from "../lib/util.js";
|
|
8
8
|
import { join } from 'path';
|
|
9
|
+
function formatBuildError(reason) {
|
|
10
|
+
const lines = [];
|
|
11
|
+
if (reason.id || reason.loc) {
|
|
12
|
+
const file = reason.id || reason.loc?.file || '';
|
|
13
|
+
const loc = reason.loc ? `:${reason.loc.line}:${reason.loc.column}` : '';
|
|
14
|
+
if (file)
|
|
15
|
+
lines.push(` File: ${file}${loc}`);
|
|
16
|
+
}
|
|
17
|
+
if (reason.plugin) {
|
|
18
|
+
lines.push(` Plugin: ${reason.plugin}`);
|
|
19
|
+
}
|
|
20
|
+
if (reason.message) {
|
|
21
|
+
lines.push(` Error: ${reason.message}`);
|
|
22
|
+
}
|
|
23
|
+
if (reason.frame) {
|
|
24
|
+
lines.push('');
|
|
25
|
+
lines.push(reason.frame);
|
|
26
|
+
}
|
|
27
|
+
if (!reason.frame && reason.cause) {
|
|
28
|
+
lines.push(` Cause: ${reason.cause?.message || String(reason.cause)}`);
|
|
29
|
+
}
|
|
30
|
+
return lines.join('\n') || String(reason);
|
|
31
|
+
}
|
|
9
32
|
class ForgeCommand {
|
|
10
33
|
register() {
|
|
11
34
|
return new Command("forge")
|
|
@@ -77,20 +100,27 @@ class ForgeCommand {
|
|
|
77
100
|
ssrRenderer,
|
|
78
101
|
};
|
|
79
102
|
const client = Util.getClientForProfile();
|
|
80
|
-
// get base url of the platform
|
|
103
|
+
// get base url of the platform cliente
|
|
81
104
|
const baseUrl = client.getPlatformBaseURL();
|
|
82
105
|
// Different build approach for public vs platform apps
|
|
83
106
|
if (type === 'public') {
|
|
84
107
|
// Public apps: standard SPA build with index.html
|
|
85
108
|
manifest.icon = icon;
|
|
86
109
|
console.log("Building public app...");
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
110
|
+
try {
|
|
111
|
+
await build({
|
|
112
|
+
root: path,
|
|
113
|
+
build: {
|
|
114
|
+
outDir: distPath,
|
|
115
|
+
emptyOutDir: true,
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
console.error('\n❌ Public app build failed:');
|
|
121
|
+
console.error(formatBuildError(error));
|
|
122
|
+
throw new Error('Public app build failed.');
|
|
123
|
+
}
|
|
94
124
|
console.log("✅ Public app build completed successfully");
|
|
95
125
|
// Build SSR renderer if specified for public apps
|
|
96
126
|
if (ssrRenderer) {
|
|
@@ -123,7 +153,8 @@ class ForgeCommand {
|
|
|
123
153
|
console.log('✓ SSR renderer built successfully');
|
|
124
154
|
}
|
|
125
155
|
catch (error) {
|
|
126
|
-
console.error('
|
|
156
|
+
console.error('\n❌ Failed to build SSR renderer:');
|
|
157
|
+
console.error(formatBuildError(error));
|
|
127
158
|
throw new Error('SSR renderer build failed.');
|
|
128
159
|
}
|
|
129
160
|
}
|
|
@@ -245,10 +276,7 @@ class ForgeCommand {
|
|
|
245
276
|
const reason = result.reason;
|
|
246
277
|
console.error(`\n View: ${viewName}`);
|
|
247
278
|
console.error(` Input: ${views[viewName]}`);
|
|
248
|
-
console.error(
|
|
249
|
-
if (reason?.stack) {
|
|
250
|
-
console.error(`\n${reason.stack}`);
|
|
251
|
-
}
|
|
279
|
+
console.error(formatBuildError(reason));
|
|
252
280
|
});
|
|
253
281
|
throw new Error('View build failed. See errors above.');
|
|
254
282
|
}
|
|
@@ -264,10 +292,7 @@ class ForgeCommand {
|
|
|
264
292
|
const reason = result.reason;
|
|
265
293
|
console.error(`\n Script: ${scriptName}`);
|
|
266
294
|
console.error(` Input: ${scripts[scriptName]}`);
|
|
267
|
-
console.error(
|
|
268
|
-
if (reason?.stack) {
|
|
269
|
-
console.error(`\n${reason.stack}`);
|
|
270
|
-
}
|
|
295
|
+
console.error(formatBuildError(reason));
|
|
271
296
|
});
|
|
272
297
|
throw new Error('Script build failed. See errors above.');
|
|
273
298
|
}
|