generator-bitloops 0.3.3 → 0.3.5

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/setup/index.js +22 -33
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "generator-bitloops",
3
- "version": "0.3.3",
3
+ "version": "0.3.5",
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
@@ -56,19 +56,20 @@ export default class extends Generator {
56
56
  default: false,
57
57
  });
58
58
 
59
+ this.option('git', {
60
+ type: Boolean,
61
+ description: 'Commit changes to git',
62
+ default: false,
63
+ });
64
+
59
65
  this.installNextJS = async function() {
60
66
  // Clone Next.js template with Tailwind if specified, using the project name
61
- const createNextAppCommand = ['-y', 'create-next-app@latest'];
67
+ const createNextAppCommand = ['-y', 'create-next-app@14.2.16'];
62
68
  createNextAppCommand.push(toKebabCase(this.options.project)); // Use the project name for the directory
63
69
  createNextAppCommand.push('--app');
64
70
  createNextAppCommand.push('--empty');
65
71
  createNextAppCommand.push('--src-dir');
66
- if (this.options.storybook) {
67
- // Disable TurboPack for Storybook compatibility given the Next.js downgrade that will follow
68
- createNextAppCommand.push('--no-turbopack');
69
- } else {
70
- createNextAppCommand.push('--turbopack');
71
- }
72
+ // createNextAppCommand.push('--turbopack'); when we go to Next.js 15
72
73
  createNextAppCommand.push('--import-alias');
73
74
  createNextAppCommand.push('@/*');
74
75
  createNextAppCommand.push('--use-npm');
@@ -85,9 +86,9 @@ export default class extends Generator {
85
86
  }
86
87
 
87
88
  this.log("Installing Next.js...");
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
+ const patchPackages = '';//'next@14 react@18 react-dom@18';
90
+ const additionalPackages = `react-tooltip ${patchPackages}`;
91
+ await new Promise((resolve, error) => {exec(`npx ${createNextAppCommand.join(' ')} && cd ${toKebabCase(this.options.project)} && npm install ${additionalPackages}`).on('exit', (code) => {
91
92
  this.destinationRoot(this.destinationPath(toKebabCase(this.options.project)));
92
93
  resolve();
93
94
  });});
@@ -98,8 +99,8 @@ export default class extends Generator {
98
99
  if (this.options.storybook) {
99
100
  this.log("Adding Storybook...");
100
101
  this.spawnCommandSync('npx', ['-y', 'storybook@8.4', 'init', '--no-dev']);
101
- // if (this.options.tailwind) {
102
- // Tailwind CSS specific setup if needed
102
+ // if (this.options.tailwind && this.options.storybook) {
103
+ // Tailwind CSS specific setup for older versions of Storybook
103
104
  // this.spawnCommandSync('npx', ['storybook@latest', 'add', '@storybook/addon-styling-webpack']);
104
105
  // }
105
106
  }
@@ -114,24 +115,6 @@ export default class extends Generator {
114
115
  }
115
116
 
116
117
  this.patchFiles = async function() {
117
- if (this.options.storybook) {
118
- if (this.options.typescript) {
119
- this.log('Replace Next.js\' TypeScript configuration file with JS...');
120
- // Remove TypeScript configuration files given they require Next.js 15
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
- }
127
- this.fs.copyTpl(
128
- this.templatePath('next.config.js'),
129
- this.destinationPath('next.config.js'),
130
- );
131
- this.log(`Created next.config.js instead`);
132
- }
133
- }
134
-
135
118
  // Conditionally initialize Storybook
136
119
  if (this.options.storybook) {
137
120
  this.log("Making Storybook changes...");
@@ -158,7 +141,7 @@ export default class extends Generator {
158
141
  }
159
142
 
160
143
  if (this.options.cypress) {
161
- this.log("Adding Cypress config...");
144
+ this.log('Adding Cypress config...');
162
145
  this.fs.copyTpl(
163
146
  this.templatePath('cypress.config.ts'),
164
147
  this.destinationPath('cypress.config.ts'),
@@ -200,7 +183,11 @@ export default class extends Generator {
200
183
 
201
184
  this.commitChanges = async function() {
202
185
  this.log('Committing changes to git...');
203
- await new Promise((resolve, error) => {exec('git add . && git commit -m "Initial setup"').on('exit', (code) => {
186
+ await new Promise((resolve) => {exec(`cd ${toKebabCase(this.options.project)} && git add . && git commit -m "Initial setup"`).on('exit', (code) => {
187
+ if (code !== 0) {
188
+ this.log('Error committing changes to git! ', code);
189
+ resolve();
190
+ }
204
191
  this.log('Git changes committed!');
205
192
  resolve();
206
193
  });});
@@ -230,7 +217,9 @@ export default class extends Generator {
230
217
  this.installCypress();
231
218
  this.log('Patching files');
232
219
  await this.patchFiles();
233
- await this.commitChanges();
220
+ if (this.options.git) {
221
+ await this.commitChanges();
222
+ }
234
223
  }
235
224
 
236
225
  end() {