generator-bitloops 0.2.0 → 0.3.1

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
@@ -2,8 +2,8 @@
2
2
 
3
3
  The Bitloops Generator is used by the Bitloops Platform to setup your Bitloops projects.
4
4
 
5
- Nonetheless, you can use it independently to setup your next next.js project with TypeScript, Tailwind, Storybook and Cypress all ready to go!
5
+ Nonetheless, you can use it independently to setup your next Next.js project with TypeScript, Tailwind, Storybook and Cypress all ready to go!
6
6
 
7
7
  ## How to run it
8
8
 
9
- `npx generator-bitloops setup --project="Your Project Name" --nextjs --typescript --tailwind --storybook --cypress`
9
+ `npx -y generator-bitloops setup --project="Your Project Name" --nextjs --typescript --tailwind --storybook --cypress`
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "generator-bitloops",
3
- "version": "0.2.0",
4
- "description": "Bitloops Yeoman generator",
3
+ "version": "0.3.1",
4
+ "description": "Next.js with TypeScript, Tailwind, Storybook and Cypress generator by Bitloops",
5
5
  "license": "MIT",
6
6
  "author": "Bitloops S.A.",
7
7
  "repository": {
@@ -15,7 +15,7 @@
15
15
  "files": [
16
16
  "app",
17
17
  "setup",
18
- "cli.js"
18
+ "cli.mjs"
19
19
  ],
20
20
  "keywords": [
21
21
  "bitloops",
package/setup/index.js CHANGED
@@ -85,7 +85,9 @@ export default class extends Generator {
85
85
  }
86
86
 
87
87
  this.log("Installing Next.js...");
88
- await new Promise((resolve, error) => {exec(`npx ${createNextAppCommand.join(' ')} && cd ${toKebabCase(this.options.project)} && npm install next@14 react@18 react-dom@18`).on('exit', (code) => {
88
+ const additionalPackages = 'react-tooltip';
89
+ const patchPackages = `next@14 react@18 react-dom@18 ${additionalPackages}`;
90
+ await new Promise((resolve, error) => {exec(`npx ${createNextAppCommand.join(' ')} && cd ${toKebabCase(this.options.project)} && npm install ${patchPackages}`).on('exit', (code) => {
89
91
  this.destinationRoot(this.destinationPath(toKebabCase(this.options.project)));
90
92
  resolve();
91
93
  });});
@@ -95,10 +97,11 @@ export default class extends Generator {
95
97
  // Conditionally initialize Storybook
96
98
  if (this.options.storybook) {
97
99
  this.log("Adding Storybook...");
98
- this.spawnCommandSync('npx', ['-y', 'storybook@latest', 'init', '--no-dev']);
99
- if (this.options.tailwind) {
100
- this.spawnCommandSync('npx', ['storybook@latest', 'add', '@storybook/addon-styling-webpack']);
101
- }
100
+ this.spawnCommandSync('npx', ['-y', 'storybook@7.4', 'init', '--no-dev']);
101
+ // if (this.options.tailwind) {
102
+ // Tailwind CSS specific setup if needed
103
+ // this.spawnCommandSync('npx', ['storybook@latest', 'add', '@storybook/addon-styling-webpack']);
104
+ // }
102
105
  }
103
106
  }
104
107
 
@@ -115,14 +118,17 @@ export default class extends Generator {
115
118
  if (this.options.typescript) {
116
119
  this.log('Replace Next.js\' TypeScript configuration file with JS...');
117
120
  // Remove TypeScript configuration files given they require Next.js 15
118
- fs.unlinkSync(this.destinationPath('next.config.ts'));
119
- console.log('Template Path:', this.templatePath('next.config.js'));
120
- console.log('Destination Path:', this.destinationPath('next.config.js'));
121
+ try {
122
+ fs.unlinkSync(this.destinationPath('next.config.ts'));
123
+ this.log(`Deleted next.config.ts`);
124
+ } catch (err) {
125
+ console.error('Error deleting next.config.ts:', err);
126
+ }
121
127
  this.fs.copyTpl(
122
128
  this.templatePath('next.config.js'),
123
129
  this.destinationPath('next.config.js'),
124
- );
125
- this.log(`Deleted next.config.ts and created next.config.js instead`);
130
+ );
131
+ this.log(`Created next.config.js instead`);
126
132
  }
127
133
  }
128
134
 
@@ -178,6 +184,18 @@ export default class extends Generator {
178
184
  this.templatePath('globals.css'),
179
185
  this.destinationPath('src/app/globals.css'),
180
186
  );
187
+
188
+ this.log('Adding Bitloops support components...');
189
+ this.fs.copyTpl(
190
+ this.templatePath('src.components.bitloops.Unsupported.tsx'),
191
+ this.destinationPath('src/components/bitloops/Unsupported.tsx'),
192
+ );
193
+ if (this.options.storybook) {
194
+ this.fs.copyTpl(
195
+ this.templatePath('src.components.bitloops.Unsupported.stories.tsx'),
196
+ this.destinationPath('src/components/bitloops/Unsupported.stories.tsx'),
197
+ );
198
+ }
181
199
  }
182
200
  }
183
201
 
@@ -0,0 +1,27 @@
1
+ import { Meta, StoryObj } from '@storybook/react';
2
+ import { UnsupportedElement, UnsupportedElementProps } from './Unsupported';
3
+
4
+ const meta: Meta<typeof UnsupportedElement> = {
5
+ title: 'Bitloops/Unsupported',
6
+ component: UnsupportedElement,
7
+ parameters: {
8
+ layout: 'centered',
9
+ },
10
+ tags: ['autodocs'],
11
+ };
12
+
13
+ export default meta;
14
+
15
+ const props: UnsupportedElementProps = {
16
+ type: 'VECTOR',
17
+ elementClassName: 'w-128 h-32',
18
+ };
19
+
20
+ type Story = StoryObj<typeof UnsupportedElement>;
21
+
22
+ export const Default: Story = {
23
+ args: props,
24
+ parameters: {
25
+ layout: 'fullscreen',
26
+ },
27
+ };
@@ -0,0 +1,33 @@
1
+ import { Tooltip } from 'react-tooltip';
2
+ import 'react-tooltip/dist/react-tooltip.css';
3
+
4
+ type UnsupportedType =
5
+ | 'VECTOR'
6
+ | 'GROUP'
7
+ | 'STAR'
8
+ | 'ELLIPSE'
9
+ | 'LINE'
10
+ | 'REGULAR_POLYGON'
11
+ | 'SLICE'
12
+ | 'IMAGE';
13
+
14
+ export type UnsupportedElementProps = {
15
+ type: UnsupportedType;
16
+ elementClassName: string;
17
+ };
18
+ export function UnsupportedElement(props: UnsupportedElementProps) {
19
+ const { type, elementClassName } = props;
20
+ return (
21
+ <div
22
+ className={`${elementClassName} relative group border border-red-500 border-dashed`}
23
+ data-tooltip-id='tooltip'
24
+ data-tooltip-content={`Unsupported: ${type}`}
25
+ >
26
+ <Tooltip
27
+ id='tooltip'
28
+ place='top'
29
+ className='bg-black text-white p-2 rounded-[4px] text-xs whitespace-nowrap'
30
+ />
31
+ </div>
32
+ );
33
+ }