generator-bitloops 0.3.28 → 0.3.30

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": "generator-bitloops",
3
- "version": "0.3.28",
3
+ "version": "0.3.30",
4
4
  "description": "Next.js with TypeScript, Tailwind, Storybook and Cypress generator by Bitloops",
5
5
  "license": "MIT",
6
6
  "author": "Bitloops S.A.",
package/setup/index.js CHANGED
@@ -10,6 +10,7 @@ const __filename = fileURLToPath(import.meta.url);
10
10
  const __dirname = path.dirname(__filename);
11
11
 
12
12
  const DOT = '.';
13
+ const STORYBOOK_FOLDER = '.storybook';
13
14
  const PLATFORM_NEXT_FOLDER = 'platform-next';
14
15
  const PLATFORM_NEXT_SRC_FOLDER = `${PLATFORM_NEXT_FOLDER}/src`;
15
16
  const PLATFORM_VITE_FOLDER = 'platform-vite';
@@ -262,11 +263,10 @@ export default class extends Generator {
262
263
  );
263
264
  this.log('Storybook installed!');
264
265
  // Verifies the correct nextjs-vite framework is used
265
- spawnSync(
266
- 'pnpm',
267
- ['add', '-D', '@storybook/nextjs-vite@^10'],
268
- { stdio: 'inherit', cwd: this.destinationRoot() },
269
- );
266
+ spawnSync('pnpm', ['add', '-D', '@storybook/nextjs-vite@^10'], {
267
+ stdio: 'inherit',
268
+ cwd: this.destinationRoot(),
269
+ });
270
270
  this.log('@storybook/nextjs-vite installed!');
271
271
  }
272
272
  };
@@ -300,11 +300,10 @@ export default class extends Generator {
300
300
  // Conditionally add i18n packages
301
301
  if (this.options.i18n) {
302
302
  this.log('Installing i18n packages...');
303
- spawnSync(
304
- 'pnpm',
305
- ['add', 'i18next', 'i18next-icu', 'react-i18next'],
306
- { stdio: 'inherit', cwd: this.destinationRoot() },
307
- );
303
+ spawnSync('pnpm', ['add', 'i18next', 'i18next-icu', 'react-i18next'], {
304
+ stdio: 'inherit',
305
+ cwd: this.destinationRoot(),
306
+ });
308
307
  this.log('i18n packages installed!');
309
308
  }
310
309
  };
@@ -313,11 +312,10 @@ export default class extends Generator {
313
312
  // Conditionally add Base UI
314
313
  if (this.options.baseUi) {
315
314
  this.log('Installing Base UI...');
316
- spawnSync(
317
- 'pnpm',
318
- ['add', '@base-ui/react@^1.1.0'],
319
- { stdio: 'inherit', cwd: this.destinationRoot() },
320
- );
315
+ spawnSync('pnpm', ['add', '@base-ui/react@^1.1.0'], {
316
+ stdio: 'inherit',
317
+ cwd: this.destinationRoot(),
318
+ });
321
319
  this.log('Base UI installed!');
322
320
  }
323
321
  };
@@ -326,11 +324,10 @@ export default class extends Generator {
326
324
  // Conditionally add Redux Toolkit and React Redux
327
325
  if (this.options.redux) {
328
326
  this.log('Installing Redux Toolkit and React Redux...');
329
- spawnSync(
330
- 'pnpm',
331
- ['add', '@reduxjs/toolkit', 'react-redux'],
332
- { stdio: 'inherit', cwd: this.destinationRoot() },
333
- );
327
+ spawnSync('pnpm', ['add', '@reduxjs/toolkit', 'react-redux'], {
328
+ stdio: 'inherit',
329
+ cwd: this.destinationRoot(),
330
+ });
334
331
  this.log('Redux Toolkit and React Redux installed!');
335
332
  }
336
333
  };
@@ -366,11 +363,10 @@ export default class extends Generator {
366
363
  // Conditionally add web-vitals
367
364
  if (this.options.webVitals) {
368
365
  this.log('Installing web-vitals...');
369
- spawnSync(
370
- 'pnpm',
371
- ['add', 'web-vitals'],
372
- { stdio: 'inherit', cwd: this.destinationRoot() },
373
- );
366
+ spawnSync('pnpm', ['add', 'web-vitals'], {
367
+ stdio: 'inherit',
368
+ cwd: this.destinationRoot(),
369
+ });
374
370
  this.log('web-vitals installed!');
375
371
  }
376
372
  };
@@ -379,11 +375,10 @@ export default class extends Generator {
379
375
  // Conditionally add Zod
380
376
  if (this.options.zod) {
381
377
  this.log('Installing Zod...');
382
- spawnSync(
383
- 'pnpm',
384
- ['add', 'zod'],
385
- { stdio: 'inherit', cwd: this.destinationRoot() },
386
- );
378
+ spawnSync('pnpm', ['add', 'zod'], {
379
+ stdio: 'inherit',
380
+ cwd: this.destinationRoot(),
381
+ });
387
382
  this.log('Zod installed!');
388
383
  }
389
384
  };
@@ -392,11 +387,10 @@ export default class extends Generator {
392
387
  // Conditionally add @next/bundle-analyzer
393
388
  if (this.options.bundleAnalyzer) {
394
389
  this.log('Installing @next/bundle-analyzer...');
395
- spawnSync(
396
- 'pnpm',
397
- ['add', '-D', '@next/bundle-analyzer'],
398
- { stdio: 'inherit', cwd: this.destinationRoot() },
399
- );
390
+ spawnSync('pnpm', ['add', '-D', '@next/bundle-analyzer'], {
391
+ stdio: 'inherit',
392
+ cwd: this.destinationRoot(),
393
+ });
400
394
  this.log('@next/bundle-analyzer installed!');
401
395
  }
402
396
  };
@@ -405,11 +399,10 @@ export default class extends Generator {
405
399
  // Conditionally add react-icons
406
400
  if (this.options.reactIcons) {
407
401
  this.log('Installing react-icons...');
408
- spawnSync(
409
- 'pnpm',
410
- ['add', 'react-icons'],
411
- { stdio: 'inherit', cwd: this.destinationRoot() },
412
- );
402
+ spawnSync('pnpm', ['add', 'react-icons'], {
403
+ stdio: 'inherit',
404
+ cwd: this.destinationRoot(),
405
+ });
413
406
  this.log('react-icons installed!');
414
407
  }
415
408
  };
@@ -418,17 +411,15 @@ export default class extends Generator {
418
411
  // Conditionally add Mock Service Worker
419
412
  if (this.options.msw) {
420
413
  this.log('Installing Mock Service Worker (MSW)...');
421
- spawnSync(
422
- 'pnpm',
423
- ['add', '-D', 'msw'],
424
- { stdio: 'inherit', cwd: this.destinationRoot() },
425
- );
414
+ spawnSync('pnpm', ['add', '-D', 'msw'], {
415
+ stdio: 'inherit',
416
+ cwd: this.destinationRoot(),
417
+ });
426
418
  // Initialize MSW
427
- spawnSync(
428
- 'npx',
429
- ['msw', 'init', 'public/', '--save'],
430
- { stdio: 'inherit', cwd: this.destinationRoot() },
431
- );
419
+ spawnSync('npx', ['msw', 'init', 'public/', '--save'], {
420
+ stdio: 'inherit',
421
+ cwd: this.destinationRoot(),
422
+ });
432
423
  this.log('MSW installed!');
433
424
  }
434
425
  };
@@ -437,11 +428,10 @@ export default class extends Generator {
437
428
  // Conditionally add babel-plugin-react-compiler
438
429
  if (this.options.reactCompiler) {
439
430
  this.log('Installing babel-plugin-react-compiler...');
440
- spawnSync(
441
- 'pnpm',
442
- ['add', '-D', 'babel-plugin-react-compiler'],
443
- { stdio: 'inherit', cwd: this.destinationRoot() },
444
- );
431
+ spawnSync('pnpm', ['add', '-D', 'babel-plugin-react-compiler'], {
432
+ stdio: 'inherit',
433
+ cwd: this.destinationRoot(),
434
+ });
445
435
  this.log('babel-plugin-react-compiler installed!');
446
436
  }
447
437
  };
@@ -450,11 +440,10 @@ export default class extends Generator {
450
440
  // Add intl-messageformat when i18n is enabled
451
441
  if (this.options.i18n) {
452
442
  this.log('Installing intl-messageformat...');
453
- spawnSync(
454
- 'pnpm',
455
- ['add', 'intl-messageformat'],
456
- { stdio: 'inherit', cwd: this.destinationRoot() },
457
- );
443
+ spawnSync('pnpm', ['add', 'intl-messageformat'], {
444
+ stdio: 'inherit',
445
+ cwd: this.destinationRoot(),
446
+ });
458
447
  this.log('intl-messageformat installed!');
459
448
  }
460
449
  };
@@ -508,14 +497,26 @@ export default class extends Generator {
508
497
  // Conditionally initialize Storybook
509
498
  if (this.options.storybook) {
510
499
  this.log('Making Storybook changes...');
511
- if (this.options.tailwind) {
512
- deleteFileIfExists(this.destinationPath('.storybook/preview.ts'));
513
- this.log('Setting up Tailwind CSS with Storybook...');
500
+
501
+ // Copy .storybook template files
502
+ const storybookFiles = [
503
+ `${STORYBOOK_FOLDER}/main.ts`,
504
+ `${STORYBOOK_FOLDER}/vitest.setup.ts`,
505
+ ];
506
+
507
+ // Delete .storybook/preview.ts if it exists (generated by storybook init)
508
+ deleteFileIfExists(
509
+ this.destinationPath(`${STORYBOOK_FOLDER}/preview.ts`),
510
+ );
511
+
512
+ storybookFiles.forEach((filePath) => {
513
+ deleteFileIfExists(this.destinationPath(filePath));
514
514
  this.fs.copyTpl(
515
- this.templatePath('storybook.preview.ts'),
516
- this.destinationPath('.storybook/preview.ts'),
515
+ this.templatePath(filePath),
516
+ this.destinationPath(filePath),
517
517
  );
518
- }
518
+ });
519
+
519
520
  this.log('Removing default Storybook stories...');
520
521
  try {
521
522
  fs.rmSync(this.destinationPath('src/stories'), {
@@ -0,0 +1,32 @@
1
+ import type { StorybookConfig } from '@storybook/nextjs-vite';
2
+ import path from 'path';
3
+ import { fileURLToPath } from 'url';
4
+
5
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
6
+
7
+ const config: StorybookConfig = {
8
+ "stories": [
9
+ "../src/**/*.mdx",
10
+ "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"
11
+ ],
12
+ "addons": [
13
+ "@chromatic-com/storybook",
14
+ "@storybook/addon-vitest",
15
+ "@storybook/addon-a11y",
16
+ "@storybook/addon-docs"
17
+ ],
18
+ "framework": "@storybook/nextjs-vite",
19
+ "staticDirs": [
20
+ "../public"
21
+ ],
22
+ async viteFinal(config) {
23
+ if (config.resolve) {
24
+ config.resolve.alias = {
25
+ ...config.resolve.alias,
26
+ '@/primitives': path.resolve(__dirname, '../platform-vite/src'),
27
+ };
28
+ }
29
+ return config;
30
+ }
31
+ };
32
+ export default config;
@@ -0,0 +1,7 @@
1
+ import * as a11yAddonAnnotations from "@storybook/addon-a11y/preview";
2
+ import { setProjectAnnotations } from '@storybook/nextjs-vite';
3
+ import * as projectAnnotations from './preview';
4
+
5
+ // This is an important step to apply the right configuration when testing your stories.
6
+ // More info at: https://storybook.js.org/docs/api/portable-stories/portable-stories-vitest#setprojectannotations
7
+ setProjectAnnotations([a11yAddonAnnotations, projectAnnotations]);
@@ -1,15 +0,0 @@
1
- import type { Preview } from "@storybook/react";
2
- import "../src/app/globals.css";
3
-
4
- const preview: Preview = {
5
- parameters: {
6
- controls: {
7
- matchers: {
8
- color: /(background|color)$/i,
9
- date: /Date$/i,
10
- },
11
- },
12
- },
13
- };
14
-
15
- export default preview;