create-yeow 0.2.26 → 0.2.28

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-yeow",
3
- "version": "0.2.26",
3
+ "version": "0.2.28",
4
4
  "description": "Scaffold a Yeow plugin project",
5
5
  "type": "module",
6
6
  "bin": {
@@ -198,57 +198,48 @@ async function getSourceMapConsumer() {
198
198
 
199
199
  async function printFormattedError(err) {
200
200
  const c = { r: '\x1b[0m', R: '\x1b[31m', Y: '\x1b[33m', C: '\x1b[36m', B: '\x1b[1m', D: '\x1b[2m' };
201
- console.log(`\n${c.R}${c.B} ⛔ JS Error [${err.plugin}]${c.r}`);
202
- console.log(` ${c.Y}${err.message}${c.r}`);
203
- console.log(` ${c.D}at ${err.fileName}:${err.lineNumber}:${err.columnNumber}${c.r}`);
201
+ let out = `\n${c.R}${c.B} ⛔ JS Error [${err.plugin}]${c.r}\n`;
202
+ out += ` ${c.Y}${err.message}${c.r}\n`;
204
203
 
205
- // Try source-map resolution
206
- if (err.fileName === 'main.js' || err.stack) {
207
- const consumer = await getSourceMapConsumer();
208
- if (consumer) {
209
- if (err.lineNumber > 0) {
210
- const orig = consumer.originalPositionFor({ line: err.lineNumber, column: err.columnNumber || 0 });
211
- if (orig.source && orig.line) {
212
- console.log(` ${c.C}→ ${orig.source}:${orig.line}:${orig.column}${c.r}`);
213
- // Print source context
214
- const sources = consumer.sources;
215
- const idx = sources.indexOf(orig.source);
216
- if (idx >= 0) {
217
- const content = consumer.sourceContentFor(orig.source);
218
- if (content) {
219
- const lines = content.split('\n');
220
- const start = Math.max(0, orig.line - 3);
221
- const end = Math.min(lines.length, orig.line + 2);
222
- for (let i = start; i < end; i++) {
223
- const prefix = i === orig.line - 1 ? c.R + ' →' : ' ';
224
- console.log(` ${prefix} ${c.D}${String(i + 1).padStart(4)}|${c.r} ${lines[i]}`);
225
- }
226
- }
204
+ const consumer = (err.fileName === 'main.js' || err.stack) ? await getSourceMapConsumer() : null;
205
+ if (consumer) {
206
+ if (err.lineNumber > 0) {
207
+ const orig = consumer.originalPositionFor({ line: err.lineNumber, column: err.columnNumber || 0 });
208
+ if (orig.source && orig.line) {
209
+ const srcPath = orig.source.replace(/^\.\.\/\.\.\//, '');
210
+ out += ` ${c.C}at ${srcPath}:${orig.line}:${orig.column}${c.r}\n`;
211
+ const content = consumer.sourceContentFor(orig.source);
212
+ if (content) {
213
+ const lines = content.split('\n');
214
+ const start = Math.max(0, orig.line - 3);
215
+ const end = Math.min(lines.length, orig.line + 2);
216
+ for (let i = start; i < end; i++) {
217
+ const prefix = i === orig.line - 1 ? c.R + ' →' : ' ';
218
+ out += ` ${prefix} ${c.D}${String(i + 1).padStart(4)}|${c.r} ${lines[i]}\n`;
227
219
  }
228
220
  }
229
221
  }
230
- // Also resolve stack trace lines if present
231
- if (err.stack) {
232
- const stackLines = err.stack.split('\n');
233
- for (let i = 0; i < Math.min(stackLines.length, 8); i++) {
234
- const line = stackLines[i].trim();
235
- const m = line.match(/at\s+(?:\S+\s+)?\(?(?:\/main\.js|[^:]+):(\d+):(\d+)\)?/);
236
- if (m) {
237
- const orig = consumer.originalPositionFor({ line: parseInt(m[1]), column: parseInt(m[2]) });
238
- if (orig.source) {
239
- const mapped = ` at ${orig.source}:${orig.line}:${orig.column}`;
240
- console.log(` ${c.D}${mapped}${c.r}`);
241
- continue;
242
- }
222
+ }
223
+ if (err.stack) {
224
+ const stackLines = err.stack.split('\n');
225
+ for (let i = 0; i < Math.min(stackLines.length, 8); i++) {
226
+ const line = stackLines[i].trim();
227
+ const m = line.match(/at\s+(?:\S+\s+)?\(?(?:\/main\.js|[^:]+):(\d+):(\d+)\)?/);
228
+ if (m) {
229
+ const orig = consumer.originalPositionFor({ line: parseInt(m[1]), column: parseInt(m[2]) });
230
+ if (orig.source) {
231
+ const srcPath = orig.source.replace(/^\.\.\/\.\.\//, '');
232
+ out += ` ${c.D} at ${srcPath}:${orig.line}:${orig.column}${c.r}\n`;
233
+ continue;
243
234
  }
244
- console.log(` ${c.D} ${line}${c.r}`);
245
235
  }
236
+ out += ` ${c.D} ${line}${c.r}\n`;
246
237
  }
247
- } else if (err.stack) {
248
- err.stack.split('\n').slice(0, 5).forEach(l => console.log(` ${c.D} ${l.trim()}${c.r}`));
249
238
  }
239
+ } else if (err.stack) {
240
+ err.stack.split('\n').slice(0, 5).forEach(l => { out += ` ${c.D} ${l.trim()}${c.r}\n`; });
250
241
  }
251
- console.log();
242
+ console.log(out);
252
243
  }
253
244
 
254
245
  function startServer() {