@spyglassmc/core 0.4.18 → 0.4.19

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.
@@ -95,6 +95,7 @@ export declare class FileUriSupporter implements UriProtocolSupporter {
95
95
  }
96
96
  export declare class ArchiveUriSupporter implements UriProtocolSupporter {
97
97
  private readonly externals;
98
+ private readonly logger;
98
99
  private readonly entries;
99
100
  static readonly Protocol = "archive:";
100
101
  private static readonly SupportedArchiveExtnames;
@@ -154,6 +154,7 @@ export class FileUriSupporter {
154
154
  }
155
155
  export class ArchiveUriSupporter {
156
156
  externals;
157
+ logger;
157
158
  entries;
158
159
  static Protocol = 'archive:';
159
160
  static SupportedArchiveExtnames = ['.tar', '.tar.bz2', '.tar.gz', '.zip'];
@@ -161,8 +162,9 @@ export class ArchiveUriSupporter {
161
162
  /**
162
163
  * @param entries A map from archive names to unzipped entries.
163
164
  */
164
- constructor(externals, entries) {
165
+ constructor(externals, logger, entries) {
165
166
  this.externals = externals;
167
+ this.logger = logger;
166
168
  this.entries = entries;
167
169
  }
168
170
  async hash(uri) {
@@ -199,6 +201,7 @@ export class ArchiveUriSupporter {
199
201
  }
200
202
  *listFiles() {
201
203
  for (const [archiveName, files] of this.entries.entries()) {
204
+ this.logger.info(`[ArchiveUriSupporter#listFiles] Listing ${files.size} files from ${archiveName}`);
202
205
  for (const file of files.values()) {
203
206
  yield ArchiveUriSupporter.getUri(archiveName, file.path);
204
207
  }
@@ -236,27 +239,17 @@ export class ArchiveUriSupporter {
236
239
  if (entries.has(archiveName)) {
237
240
  throw new Error(`A different URI with ${archiveName} already exists`);
238
241
  }
239
- /// Debug message for #1609
240
- logger.info(`[ArchiveUriSupporter#create] Extracting archive ${archiveName} from ${uri}`);
241
242
  const files = await externals.archive.decompressBall(await externals.fs.readFile(uri), { stripLevel: typeof info?.startDepth === 'number' ? info.startDepth : 0 });
242
- const newEntries = new Map(files.map((f) => [f.path.replace(/\\/g, '/'), f]));
243
243
  /// Debug message for #1609
244
- logger.info(`[ArchiveUriSupporter#create] Extracted ${files.length} files, adding ${newEntries.size} entries`);
245
- for (const [path, entry] of [...newEntries.entries()].slice(0, 20)) {
246
- logger.info(`[ArchiveUriSupporter#create] ${path} (${entry.data.length} bytes)`);
247
- }
248
- entries.set(archiveName, newEntries);
244
+ logger.info(`[ArchiveUriSupporter#create] Extracted ${files.length} files from ${archiveName}`);
245
+ entries.set(archiveName, new Map(files.map((f) => [f.path.replace(/\\/g, '/'), f])));
249
246
  }
250
247
  }
251
248
  catch (e) {
252
249
  logger.error(`[ArchiveUriSupporter#create] Bad dependency ${uri}`, e);
253
250
  }
254
251
  }
255
- /// Debug message for #1609
256
- logger.info(`[ArchiveUriSupporter#create] Finalizing with ${entries.size} archives: ${[
257
- ...entries.keys(),
258
- ]}`);
259
- return new ArchiveUriSupporter(externals, entries);
252
+ return new ArchiveUriSupporter(externals, logger, entries);
260
253
  }
261
254
  }
262
255
  async function hashFile(externals, uri) {
@@ -155,9 +155,12 @@ export class Project {
155
155
  */
156
156
  getTrackedFiles() {
157
157
  const extensions = this.meta.getSupportedFileExtensions();
158
+ this.logger.info(`[Project#getTrackedFiles] Supported file extensions: ${extensions}`);
158
159
  const supportedFiles = [...this.#dependencyFiles ?? [], ...this.#watchedFiles]
159
160
  .filter((file) => extensions.includes(fileUtil.extname(file) ?? ''));
161
+ this.logger.info(`[Project#getTrackedFiles] Listed ${supportedFiles.length} supported files`);
160
162
  const filteredFiles = this.ignore.filter(supportedFiles);
163
+ this.logger.info(`[Project#getTrackedFiles] After ignoring, keeping ${filteredFiles.length} tracked files`);
161
164
  return filteredFiles;
162
165
  }
163
166
  constructor({ cacheRoot, defaultConfig, downloader, externals, fs = FileService.create(externals, cacheRoot), initializers = [], isDebugging = false, logger = Logger.create(), profilers = ProfilerFactory.noop(), projectRoots, }) {
@@ -390,6 +393,17 @@ export class Project {
390
393
  __profiler.task('Bind URIs');
391
394
  const files = [...addedFiles, ...changedFiles].sort(this.meta.uriSorter);
392
395
  __profiler.task('Sort URIs');
396
+ const fileCountByExtension = new Map();
397
+ for (const file of files) {
398
+ const ext = fileUtil.extname(file)?.replace(/^\./, '');
399
+ if (ext) {
400
+ fileCountByExtension.set(ext, (fileCountByExtension.get(ext) ?? 0) + 1);
401
+ }
402
+ }
403
+ this.logger.info(`[Project#ready] == Files to bind ==`);
404
+ for (const [ext, count] of fileCountByExtension.entries()) {
405
+ this.logger.info(`[Project#ready] File extension ${ext}: ${count}`);
406
+ }
393
407
  const __bindProfiler = this.profilers.get('project#ready#bind', 'top-n', 50);
394
408
  for (const uri of files) {
395
409
  await this.ensureBindingStarted(uri);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spyglassmc/core",
3
- "version": "0.4.18",
3
+ "version": "0.4.19",
4
4
  "type": "module",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",