generator-bitloops 0.3.4 → 0.3.6

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 +23 -39
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "generator-bitloops",
3
- "version": "0.3.4",
3
+ "version": "0.3.6",
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
  });});
@@ -96,10 +97,11 @@ export default class extends Generator {
96
97
  this.installStorybook = function() {
97
98
  // Conditionally initialize Storybook
98
99
  if (this.options.storybook) {
99
- this.log("Adding Storybook...");
100
- this.spawnCommandSync('npx', ['-y', 'storybook@8.4', 'init', '--no-dev']);
101
- // if (this.options.tailwind) {
102
- // Tailwind CSS specific setup if needed
100
+ this.log('Installing Storybook...');
101
+ this.spawnCommandSync('npx', ['-y', 'storybook@^8.4', 'init', '--no-dev']);
102
+ this.log('Storybook installed!');
103
+ // if (this.options.tailwind && this.options.storybook) {
104
+ // Tailwind CSS specific setup for older versions of Storybook
103
105
  // this.spawnCommandSync('npx', ['storybook@latest', 'add', '@storybook/addon-styling-webpack']);
104
106
  // }
105
107
  }
@@ -108,33 +110,16 @@ export default class extends Generator {
108
110
  this.installCypress = function() {
109
111
  // Conditionally add Cypress
110
112
  if (this.options.cypress) {
111
- this.log("Adding Cypress...");
113
+ this.log('Installing Cypress...');
112
114
  this.spawnCommandSync('npm', ['install', '--save-dev', 'cypress']);
115
+ this.log('Cypress installed!');
113
116
  }
114
117
  }
115
118
 
116
119
  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
120
  // Conditionally initialize Storybook
136
121
  if (this.options.storybook) {
137
- this.log("Making Storybook changes...");
122
+ this.log('Making Storybook changes...');
138
123
  if (this.options.tailwind) {
139
124
  fs.unlinkSync(this.destinationPath('.storybook/preview.ts'));
140
125
  this.log('Setting up Tailwind CSS with Storybook...');
@@ -158,7 +143,7 @@ export default class extends Generator {
158
143
  }
159
144
 
160
145
  if (this.options.cypress) {
161
- this.log("Adding Cypress config...");
146
+ this.log('Adding Cypress config...');
162
147
  this.fs.copyTpl(
163
148
  this.templatePath('cypress.config.ts'),
164
149
  this.destinationPath('cypress.config.ts'),
@@ -228,13 +213,12 @@ export default class extends Generator {
228
213
 
229
214
  async main() {
230
215
  await this.installNextJS();
231
- this.log('Installing Storybook');
232
216
  this.installStorybook();
233
- this.log('Installing Cypress');
234
217
  this.installCypress();
235
- this.log('Patching files');
236
218
  await this.patchFiles();
237
- await this.commitChanges();
219
+ if (this.options.git) {
220
+ await this.commitChanges();
221
+ }
238
222
  }
239
223
 
240
224
  end() {