@payfit/unity-illustrations 2.12.3 → 2.12.4

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/README.md CHANGED
@@ -5,3 +5,13 @@ This library was generated with [Nx](https://nx.dev).
5
5
  ## Running unit tests
6
6
 
7
7
  Run `nx test illustrations` to execute the unit tests via [Vitest](https://vitest.dev/).
8
+
9
+ ## Generating assets (pre-build)
10
+
11
+ Run `yarn nx run unity-illustrations:pre-build` to regenerate illustration assets.
12
+
13
+ By default, the command prints a compact summary and periodic progress updates.
14
+ Use verbose mode to display full per-asset logs:
15
+
16
+ - `yarn nx run unity-illustrations:pre-build --verbose`
17
+ - `NX_VERBOSE_LOGGING=true yarn nx run unity-illustrations:pre-build`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payfit/unity-illustrations",
3
- "version": "2.12.3",
3
+ "version": "2.12.4",
4
4
  "module": "./dist/esm/index.js",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -37,7 +37,7 @@
37
37
  "@payfit/hr-app-eslint": "0.0.0-use.local",
38
38
  "@payfit/hr-apps-tsconfigs": "0.0.0-use.local",
39
39
  "@payfit/storybook-config": "0.0.0-use.local",
40
- "@payfit/unity-themes": "2.12.3",
40
+ "@payfit/unity-themes": "2.12.4",
41
41
  "@payfit/vite-configs": "0.0.0-use.local",
42
42
  "@storybook/addon-a11y": "10.2.13",
43
43
  "@storybook/addon-docs": "10.2.13",
@@ -56,7 +56,7 @@
56
56
  "vite": "7.1.12"
57
57
  },
58
58
  "peerDependencies": {
59
- "@payfit/unity-themes": "2.12.3",
59
+ "@payfit/unity-themes": "2.12.4",
60
60
  "react": "18.3.1",
61
61
  "react-dom": "18.3.1"
62
62
  }
@@ -16,6 +16,20 @@ const srcRoot = path.resolve('./src')
16
16
  const outputDir = path.join(srcRoot, 'generated')
17
17
  const assetsOutputDir = path.join(outputDir, 'assets') // Optimized assets go here
18
18
 
19
+ const verboseFromArg = process.argv.some(
20
+ arg => arg === '--verbose' || arg === '-v',
21
+ )
22
+ const verboseFromNx = ['1', 'true', 'yes', 'on'].includes(
23
+ (process.env.NX_VERBOSE_LOGGING ?? '').toLowerCase(),
24
+ )
25
+ const isVerbose = verboseFromArg || verboseFromNx
26
+
27
+ function verboseLog(message: string) {
28
+ if (isVerbose) {
29
+ console.log(message)
30
+ }
31
+ }
32
+
19
33
  // Utility functions
20
34
  function toPascalCase(str: string) {
21
35
  return str
@@ -172,7 +186,7 @@ async function processAsset(assetPath: string) {
172
186
  await fs.writeFile(optimizedAssetPath, optimizedContent, 'utf8')
173
187
 
174
188
  const reduction = (((sizeBefore - sizeAfter) / sizeBefore) * 100).toFixed(1)
175
- console.log(
189
+ verboseLog(
176
190
  `📉 ${assetFile}: ${sizeBefore} → ${sizeAfter} bytes (-${reduction}%)`,
177
191
  )
178
192
  } else {
@@ -184,13 +198,13 @@ async function processAsset(assetPath: string) {
184
198
  // Extract dimensions for animated illustrations
185
199
  if (assetType.category === 'animation') {
186
200
  dimensions = await getImageDimensions(assetPath)
187
- console.log(
201
+ verboseLog(
188
202
  `🎬 ${assetFile}: ${(sizeBefore / 1024).toFixed(2)}KB (animation ${
189
203
  dimensions.width
190
204
  }x${dimensions.height})`,
191
205
  )
192
206
  } else {
193
- console.log(
207
+ verboseLog(
194
208
  `📦 ${assetFile}: ${(sizeBefore / 1024).toFixed(2)}KB (${
195
209
  assetType.animated ? 'animated ' : ''
196
210
  }${assetType.type})`,
@@ -214,6 +228,9 @@ async function processAsset(assetPath: string) {
214
228
 
215
229
  async function main() {
216
230
  console.log('🎨 Generating and optimizing illustration assets...')
231
+ if (isVerbose) {
232
+ console.log('🔎 Verbose mode enabled (full asset logs)')
233
+ }
217
234
 
218
235
  // Ensure output directories exist
219
236
  await fs.mkdir(outputDir, { recursive: true })
@@ -222,11 +239,11 @@ async function main() {
222
239
  // Generate base types file
223
240
  const baseTypesContent = generateBaseTypes()
224
241
  await fs.writeFile(path.join(outputDir, 'types.ts'), baseTypesContent, 'utf8')
225
- console.log('✅ Generated base types')
242
+ verboseLog('✅ Generated base types')
226
243
 
227
244
  // Discover all asset files
228
245
  const assetFiles = await getAllAssetFiles(illustrationsSvgDir)
229
- console.log(`🔍 Found ${assetFiles.length} assets to process...`)
246
+ console.log(`🔍 Found ${assetFiles.length} assets to process`)
230
247
 
231
248
  if (assetFiles.length === 0) {
232
249
  console.warn('⚠️ No assets found! Check your assets directory.')
@@ -256,15 +273,23 @@ async function main() {
256
273
  await fs.writeFile(outPath, moduleContent, 'utf8')
257
274
 
258
275
  components.push(component)
259
- console.log(
276
+ verboseLog(
260
277
  `✅ ${component.originalFileName} → ${component.name}.ts + optimized asset`,
261
278
  )
279
+
280
+ if (!isVerbose && components.length % 25 === 0) {
281
+ console.log(
282
+ `⏳ Processed ${components.length}/${assetFiles.length} assets...`,
283
+ )
284
+ }
262
285
  } catch (error) {
263
- console.log(error)
264
286
  console.error(
265
287
  `❌ Failed to process ${assetPath}:`,
266
288
  (error as Error).message,
267
289
  )
290
+ if (isVerbose) {
291
+ console.error(error)
292
+ }
268
293
  }
269
294
  }
270
295