From 517d80c705313a0cdf7e1d5196f5bb7369521a9d Mon Sep 17 00:00:00 2001 From: Zyie <24736175+Zyie@users.noreply.github.com> Date: Thu, 9 May 2024 14:31:13 +0100 Subject: [PATCH] update logs --- src/core/Asset.ts | 4 ++-- src/core/AssetPack.ts | 12 ++++-------- src/image/compress.ts | 2 +- src/image/mipmap.ts | 2 +- src/json/index.ts | 2 +- src/texture-packer/packer/createTextureData.ts | 4 ++-- src/texture-packer/texturePacker.ts | 4 ++-- src/texture-packer/texturePackerManifestMod.ts | 4 ++-- test/texture-packer/texturePacker.test.ts | 2 +- 9 files changed, 16 insertions(+), 20 deletions(-) diff --git a/src/core/Asset.ts b/src/core/Asset.ts index e12f362..8766a6e 100644 --- a/src/core/Asset.ts +++ b/src/core/Asset.ts @@ -108,7 +108,7 @@ export class Asset { if (this.isFolder) { - Logger.warn('[Assetpack] folders should not have buffers!. Contact the developer of Assetpack'); + Logger.warn('[AssetPack] folders should not have buffers!. Contact the developer of Assetpack'); } if (!this._buffer) @@ -130,7 +130,7 @@ export class Asset { if (this.isFolder) { - Logger.warn('[Assetpack] folders should not have hashes. Contact the developer of the Assetpack'); + Logger.warn('[AssetPack] folders should not have hashes. Contact the developer of the Assetpack'); } this._hash ??= getHash(this.buffer); diff --git a/src/core/AssetPack.ts b/src/core/AssetPack.ts index 5545526..f0e7397 100644 --- a/src/core/AssetPack.ts +++ b/src/core/AssetPack.ts @@ -45,14 +45,10 @@ export class AssetPack const { pipes, cache, cacheLocation } = this.config; - // make a hash.. - const cacheName = generateCacheName(this.config); - + AssetCache.location = cacheLocation!; let assetCacheData = null; let assetCache: AssetCache | null = null; - AssetCache.location = cacheLocation!; - // if there is no cache, lets just go ahead and remove the output folder // and the cached info folder if (!cache) @@ -65,7 +61,7 @@ export class AssetPack // create the asset cache, this is used to store the asset graph information // so if you restart the process, it can pick up where it left off assetCache = new AssetCache({ - cacheName, + cacheName: generateCacheName(this.config), }); // read the cache data, this will be used to restore the asset graph @@ -74,11 +70,11 @@ export class AssetPack if (assetCacheData) { - Logger.info('cache found.'); + Logger.info('[AssetPack] cache found.'); } else { - Logger.warn('cache not found, clearing output folder'); + Logger.warn('[AssetPack] cache not found, clearing output folder'); // to be safe - lets nuke the folder as the cache is empty fs.removeSync(this._outputPath); diff --git a/src/image/compress.ts b/src/image/compress.ts index 2e480df..f297a23 100644 --- a/src/image/compress.ts +++ b/src/image/compress.ts @@ -112,7 +112,7 @@ export function compress(options: CompressOptions = {}): AssetPipe } catch (error) { - throw new Error(`[AssetPack] Failed to mipmap image: ${asset.path} - ${error}`); + throw new Error(`[AssetPack][mipmap] Failed to mipmap image: ${asset.path} - ${error}`); } // now create our new assets diff --git a/src/json/index.ts b/src/json/index.ts index f3fabc0..025d9a0 100644 --- a/src/json/index.ts +++ b/src/json/index.ts @@ -35,7 +35,7 @@ export function json(_options: JsonOptions = {}): AssetPipe } catch (e) { - Logger.warn(`[json] Failed to compress json file: ${asset.path}`); + Logger.warn(`[AssetPack][json] Failed to compress json file: ${asset.path}`); return [asset]; } diff --git a/src/texture-packer/packer/createTextureData.ts b/src/texture-packer/packer/createTextureData.ts index 700a58c..c7eb935 100644 --- a/src/texture-packer/packer/createTextureData.ts +++ b/src/texture-packer/packer/createTextureData.ts @@ -23,7 +23,7 @@ export async function createTextureData(options: Required) if (!metaData.width || !metaData.height) { - throw new Error(`[Assetpack][packTextures] Could not get metadata for ${texture.path}`); + throw new Error(`[AssetPack][packTextures] Could not get metadata for ${texture.path}`); } const newWidth = Math.ceil(metaData.width * scale); @@ -57,7 +57,7 @@ export async function createTextureData(options: Required) let result = await sharpImage.toBuffer({ resolveWithObject: true }).catch((error) => { // eslint-disable-next-line max-len - Logger.warn(`[Assetpack][packTextures] Failed to process texture: ${texture.path} - ${error}, using empty pixel texture instead.`); + Logger.warn(`[AssetPack][packTextures] Failed to process texture: ${texture.path} - ${error}, using empty pixel texture instead.`); return { data: null, info: null }; }); diff --git a/src/texture-packer/texturePacker.ts b/src/texture-packer/texturePacker.ts index 221d4dd..a44f9c4 100644 --- a/src/texture-packer/texturePacker.ts +++ b/src/texture-packer/texturePacker.ts @@ -43,7 +43,7 @@ function checkForTexturePackerShortcutClashes( if (clashes.length > 0) { // eslint-disable-next-line max-len - Logger.warn(`[Assetpack][texturePacker] Texture Packer Shortcut clash detected for between ${clashes.join(', ')}. This means that 'nameStyle' is set to 'short' and different sprite sheets have frames that share the same name. Please either rename the files or set 'nameStyle' in the texture packer options to 'relative'`); + Logger.warn(`[AssetPack][texturePacker] Texture Packer Shortcut clash detected for between ${clashes.join(', ')}. This means that 'nameStyle' is set to 'short' and different sprite sheets have frames that share the same name. Please either rename the files or set 'nameStyle' in the texture packer options to 'relative'`); } } @@ -74,7 +74,7 @@ export function texturePacker(_options: TexturePackerOptions = {}): AssetPipe // Check if console.warn was called expect(mockWarn).toHaveBeenCalled(); // eslint-disable-next-line max-len - expect(mockWarn).toHaveBeenCalledWith(`[Assetpack][texturePacker] Texture Packer Shortcut clash detected for between sprite9.png, sprite8.png, sprite7.png, sprite6.png, sprite5.png, sprite4.png, sprite3.png, sprite2.png, sprite1.png, sprite0.png. This means that 'nameStyle' is set to 'short' and different sprite sheets have frames that share the same name. Please either rename the files or set 'nameStyle' in the texture packer options to 'relative'`); // Adjust this line based on expected message + expect(mockWarn).toHaveBeenCalledWith(`[AssetPack][texturePacker] Texture Packer Shortcut clash detected for between sprite9.png, sprite8.png, sprite7.png, sprite6.png, sprite5.png, sprite4.png, sprite3.png, sprite2.png, sprite1.png, sprite0.png. This means that 'nameStyle' is set to 'short' and different sprite sheets have frames that share the same name. Please either rename the files or set 'nameStyle' in the texture packer options to 'relative'`); // Adjust this line based on expected message // Restore console.warn mockWarn.mockRestore();