generator-bitloops 0.3.18 → 0.3.20
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 +1 -1
- package/setup/index.js +34 -26
package/package.json
CHANGED
package/setup/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
|
+
import { spawnSync } from 'child_process';
|
|
2
3
|
import { exec, execSync } from 'child_process';
|
|
3
4
|
import Generator from 'yeoman-generator';
|
|
4
5
|
import path from 'path';
|
|
@@ -8,6 +9,8 @@ import { fileURLToPath } from 'url';
|
|
|
8
9
|
const __filename = fileURLToPath(import.meta.url);
|
|
9
10
|
const __dirname = path.dirname(__filename);
|
|
10
11
|
|
|
12
|
+
const DOT = '.';
|
|
13
|
+
|
|
11
14
|
function isKebabCase(str) {
|
|
12
15
|
// Check if the string is empty
|
|
13
16
|
if (!str || str.trim().length === 0) {
|
|
@@ -39,6 +42,12 @@ function toKebabCase(str) {
|
|
|
39
42
|
.join('-');
|
|
40
43
|
}
|
|
41
44
|
|
|
45
|
+
function deleteFileIfExists(filePath) {
|
|
46
|
+
if (fs.existsSync(filePath)) {
|
|
47
|
+
fs.unlinkSync(filePath);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
42
51
|
export default class extends Generator {
|
|
43
52
|
constructor(args, opts) {
|
|
44
53
|
super(args, opts);
|
|
@@ -149,29 +158,28 @@ export default class extends Generator {
|
|
|
149
158
|
.filter(version => !version.includes('-')); // Exclude pre-releases like -alpha or -beta
|
|
150
159
|
|
|
151
160
|
// Sort descending and get the latest
|
|
152
|
-
const latest90 = stableVersions
|
|
161
|
+
const latest90 = stableVersions
|
|
162
|
+
.sort((a, b) => {
|
|
163
|
+
// Split version strings like '9.0.9' into [9, 0, 9]
|
|
164
|
+
const aParts = a.split(DOT).map(Number);
|
|
165
|
+
const bParts = b.split(DOT).map(Number);
|
|
166
|
+
// Compare major, then minor, then patch
|
|
167
|
+
if (aParts[0] !== bParts[0]) return bParts[0] - aParts[0];
|
|
168
|
+
if (aParts[1] !== bParts[1]) return bParts[1] - aParts[1];
|
|
169
|
+
return bParts[2] - aParts[2];
|
|
170
|
+
})[0];
|
|
153
171
|
|
|
154
172
|
if (!latest90) {
|
|
155
|
-
throw new Error('No stable 9.0.x versions found.');
|
|
173
|
+
throw new Error('No stable 9.0.x versions found.');
|
|
156
174
|
}
|
|
157
175
|
|
|
158
|
-
// Log the chosen version (optional)
|
|
159
176
|
this.log(`Latest stable 9.0 version: ${latest90}`);
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
this.spawnCommandSync('npx', [
|
|
163
|
-
'-y',
|
|
164
|
-
`storybook@${latest90}`,
|
|
165
|
-
'init',
|
|
166
|
-
'--no-dev',
|
|
167
|
-
'--yes', // Skip all prompts
|
|
168
|
-
'--type', 'nextjs', // Specify Next.js as the framework
|
|
169
|
-
]);
|
|
177
|
+
//Initializing sb with nextjs+vite
|
|
178
|
+
spawnSync('npx', ['-y', 'storybook@latest', 'init', '--no-dev', '--yes', '--type', 'nextjs', '--builder', 'vite'], { stdio: 'inherit', cwd: this.destinationRoot() });
|
|
170
179
|
this.log('Storybook installed!');
|
|
171
|
-
//
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
// }
|
|
180
|
+
//Verifies the correct nextjs-vite framework is used
|
|
181
|
+
spawnSync('npm', ['install', '--save-dev', '@storybook/nextjs-vite@^9'], { stdio: 'inherit', cwd: this.destinationRoot() });
|
|
182
|
+
this.log('@storybook/nextjs-vite installed!');
|
|
175
183
|
}
|
|
176
184
|
};
|
|
177
185
|
|
|
@@ -179,16 +187,16 @@ export default class extends Generator {
|
|
|
179
187
|
// Conditionally add Cypress
|
|
180
188
|
if (this.options.cypress) {
|
|
181
189
|
this.log('Installing Cypress...');
|
|
182
|
-
|
|
190
|
+
spawnSync('npm', ['install', '--save-dev', 'cypress'], { stdio: 'inherit', cwd: this.destinationRoot() });
|
|
183
191
|
this.log('Cypress installed!');
|
|
184
192
|
if (this.options.bitloops) {
|
|
185
|
-
|
|
193
|
+
spawnSync('npm', [
|
|
186
194
|
'install',
|
|
187
195
|
'--save-dev',
|
|
188
196
|
'mochawesome',
|
|
189
197
|
'mochawesome-merge',
|
|
190
198
|
'mochawesome-report-generator',
|
|
191
|
-
]);
|
|
199
|
+
], { stdio: 'inherit', cwd: this.destinationRoot() });
|
|
192
200
|
}
|
|
193
201
|
}
|
|
194
202
|
};
|
|
@@ -198,7 +206,7 @@ export default class extends Generator {
|
|
|
198
206
|
if (this.options.storybook) {
|
|
199
207
|
this.log('Making Storybook changes...');
|
|
200
208
|
if (this.options.tailwind) {
|
|
201
|
-
|
|
209
|
+
deleteFileIfExists(this.destinationPath('.storybook/preview.ts'));
|
|
202
210
|
this.log('Setting up Tailwind CSS with Storybook...');
|
|
203
211
|
this.fs.copyTpl(
|
|
204
212
|
this.templatePath('storybook.preview.ts'),
|
|
@@ -225,13 +233,13 @@ export default class extends Generator {
|
|
|
225
233
|
);
|
|
226
234
|
}
|
|
227
235
|
|
|
228
|
-
|
|
236
|
+
deleteFileIfExists(this.destinationPath('src/app/page.tsx'));
|
|
229
237
|
this.fs.copyTpl(
|
|
230
238
|
this.templatePath('next.app.page.tsx'),
|
|
231
239
|
this.destinationPath('src/app/page.tsx')
|
|
232
240
|
);
|
|
233
241
|
|
|
234
|
-
|
|
242
|
+
deleteFileIfExists(this.destinationPath('src/app/layout.tsx'));
|
|
235
243
|
this.fs.copyTpl(
|
|
236
244
|
this.templatePath('next.app.layout.tsx'),
|
|
237
245
|
this.destinationPath('src/app/layout.tsx'),
|
|
@@ -239,7 +247,7 @@ export default class extends Generator {
|
|
|
239
247
|
);
|
|
240
248
|
|
|
241
249
|
this.log('Adding Meyer reset in global.css...');
|
|
242
|
-
|
|
250
|
+
deleteFileIfExists(this.destinationPath('src/app/globals.css'));
|
|
243
251
|
this.fs.copyTpl(
|
|
244
252
|
this.templatePath('globals.css'),
|
|
245
253
|
this.destinationPath('src/app/globals.css')
|
|
@@ -276,11 +284,11 @@ export default class extends Generator {
|
|
|
276
284
|
const path = 'cypress/helpers/index.ts';
|
|
277
285
|
this.fs.copyTpl(this.templatePath(path), this.destinationPath(path));
|
|
278
286
|
}
|
|
279
|
-
|
|
287
|
+
spawnSync('npm', [
|
|
280
288
|
'install',
|
|
281
289
|
'--save-dev',
|
|
282
290
|
'react-aria-components',
|
|
283
|
-
]);
|
|
291
|
+
], { stdio: 'inherit', cwd: this.destinationRoot() });
|
|
284
292
|
}
|
|
285
293
|
};
|
|
286
294
|
|