@matter/tools 0.11.9-alpha.0-20241209-06a8040e1 → 0.12.0-alpha.0-20241211-6d80d8b5c

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 (43) hide show
  1. package/dist/cjs/building/project.js +1 -1
  2. package/dist/cjs/building/project.js.map +1 -1
  3. package/dist/cjs/index.d.ts +1 -0
  4. package/dist/cjs/index.d.ts.map +1 -1
  5. package/dist/cjs/index.js +1 -0
  6. package/dist/cjs/index.js.map +1 -1
  7. package/dist/cjs/running/cli.d.ts.map +1 -1
  8. package/dist/cjs/running/cli.js +25 -30
  9. package/dist/cjs/running/cli.js.map +1 -1
  10. package/dist/cjs/running/ensure-compiled.d.ts +11 -0
  11. package/dist/cjs/running/ensure-compiled.d.ts.map +1 -0
  12. package/dist/cjs/running/ensure-compiled.js +69 -0
  13. package/dist/cjs/running/ensure-compiled.js.map +6 -0
  14. package/dist/cjs/util/bootstrap.mjs +10 -8
  15. package/dist/cjs/util/progress.d.ts +2 -1
  16. package/dist/cjs/util/progress.d.ts.map +1 -1
  17. package/dist/cjs/util/progress.js +14 -2
  18. package/dist/cjs/util/progress.js.map +1 -1
  19. package/dist/esm/building/project.js +2 -2
  20. package/dist/esm/building/project.js.map +1 -1
  21. package/dist/esm/index.d.ts +1 -0
  22. package/dist/esm/index.d.ts.map +1 -1
  23. package/dist/esm/index.js +2 -1
  24. package/dist/esm/index.js.map +1 -1
  25. package/dist/esm/running/cli.d.ts.map +1 -1
  26. package/dist/esm/running/cli.js +27 -32
  27. package/dist/esm/running/cli.js.map +1 -1
  28. package/dist/esm/running/ensure-compiled.d.ts +11 -0
  29. package/dist/esm/running/ensure-compiled.d.ts.map +1 -0
  30. package/dist/esm/running/ensure-compiled.js +49 -0
  31. package/dist/esm/running/ensure-compiled.js.map +6 -0
  32. package/dist/esm/util/bootstrap.mjs +10 -8
  33. package/dist/esm/util/progress.d.ts +2 -1
  34. package/dist/esm/util/progress.d.ts.map +1 -1
  35. package/dist/esm/util/progress.js +15 -3
  36. package/dist/esm/util/progress.js.map +1 -1
  37. package/package.json +6 -1
  38. package/src/building/project.ts +1 -1
  39. package/src/index.ts +1 -0
  40. package/src/running/cli.ts +36 -36
  41. package/src/running/ensure-compiled.ts +57 -0
  42. package/src/util/bootstrap.mjs +10 -8
  43. package/src/util/progress.ts +20 -3
@@ -25,13 +25,15 @@ function fatal(why, error) {
25
25
  async function findFile(name) {
26
26
  let dir = dirname(fileURLToPath(import.meta.url));
27
27
  while (true) {
28
- const path = resolve(dir, name);
29
- try {
30
- await stat(path);
31
- return path;
32
- } catch (e) {
33
- if (e.code !== "ENOENT") {
34
- fatal("there was an unexpected error searching the filesystem", e);
28
+ if (!dir.endsWith("/dist/esm")) {
29
+ const path = resolve(dir, name);
30
+ try {
31
+ await stat(path);
32
+ return path;
33
+ } catch (e) {
34
+ if (e.code !== "ENOENT") {
35
+ fatal("there was an unexpected error searching the filesystem", e);
36
+ }
35
37
  }
36
38
  }
37
39
 
@@ -88,7 +90,7 @@ async function bootstrap() {
88
90
  if (code === 0) {
89
91
  resolve();
90
92
  } else {
91
- fatal(`esbuild existing with code ${code}`);
93
+ fatal(`esbuild exited with code ${code}`);
92
94
  }
93
95
  });
94
96
  });
@@ -81,6 +81,7 @@ export class Progress {
81
81
  #refreshInterval?: ReturnType<typeof setInterval>;
82
82
  #spinnerPosition = 0;
83
83
  #spinnerWindow?: number;
84
+ #subtasks = Array<string>();
84
85
 
85
86
  constructor() {}
86
87
 
@@ -129,7 +130,11 @@ export class Progress {
129
130
  return;
130
131
  }
131
132
 
132
- writeStatus(` ${colors.yellow(this.#spinner)} ${this.#ongoingText}`, true);
133
+ const subtask = this.#subtasks.length
134
+ ? colors.dim(` (${colors.dim(this.#subtasks[this.#subtasks.length - 1])})`)
135
+ : "";
136
+
137
+ writeStatus(` ${colors.yellow(this.#spinner)} ${this.#ongoingText}${subtask}`, true);
133
138
  }
134
139
 
135
140
  success(text: string) {
@@ -169,6 +174,16 @@ export class Progress {
169
174
  }
170
175
  }
171
176
 
177
+ async subtask(text: string, fn: () => Promise<void>) {
178
+ this.#subtasks.push(text);
179
+
180
+ try {
181
+ await fn();
182
+ } finally {
183
+ this.#subtasks.pop();
184
+ }
185
+ }
186
+
172
187
  #updateSpinner() {
173
188
  if (!stdout.isTTY) {
174
189
  return false;
@@ -186,15 +201,17 @@ export class Progress {
186
201
  return true;
187
202
  }
188
203
 
189
- async run(what: string, fn: () => void | Promise<void>) {
204
+ async run<T>(what: string, fn: () => T | Promise<T>) {
190
205
  this.update(what);
206
+ let result: T;
191
207
  try {
192
- await fn();
208
+ result = await fn();
193
209
  } catch (e) {
194
210
  this.failure(what);
195
211
  throw e;
196
212
  }
197
213
  this.success(what);
214
+ return result;
198
215
  }
199
216
 
200
217
  get #duration() {