generator-bitloops 0.3.11 → 0.3.13
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 +23 -2
package/package.json
CHANGED
package/setup/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
|
-
import { exec } from 'child_process';
|
|
2
|
+
import { exec, execSync } from 'child_process';
|
|
3
3
|
import Generator from 'yeoman-generator';
|
|
4
4
|
import path from 'path';
|
|
5
5
|
import { fileURLToPath } from 'url';
|
|
@@ -138,9 +138,30 @@ export default class extends Generator {
|
|
|
138
138
|
// Conditionally initialize Storybook
|
|
139
139
|
if (this.options.storybook) {
|
|
140
140
|
this.log('Installing Storybook...');
|
|
141
|
+
const versionsRaw = execSync('npm view storybook versions --json', {
|
|
142
|
+
encoding: 'utf-8',
|
|
143
|
+
});
|
|
144
|
+
const versions = JSON.parse(versionsRaw);
|
|
145
|
+
|
|
146
|
+
// Filter for stable 8.4.x versions (exclude alpha/beta)
|
|
147
|
+
const stableVersions = versions
|
|
148
|
+
.filter(version => version.startsWith('8.4.'))
|
|
149
|
+
.filter(version => !version.includes('-')); // Exclude pre-releases like -alpha or -beta
|
|
150
|
+
|
|
151
|
+
// Sort descending and get the latest
|
|
152
|
+
const latest84 = stableVersions.sort((a, b) => (a > b ? -1 : 1))[0];
|
|
153
|
+
|
|
154
|
+
if (!latest84) {
|
|
155
|
+
throw new Error('No stable 8.4.x versions found.');
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// Log the chosen version (optional)
|
|
159
|
+
this.log(`Latest stable 8.4 version: ${latest84}`);
|
|
160
|
+
|
|
161
|
+
// Use `this.spawnCommandSync` with the selected version
|
|
141
162
|
this.spawnCommandSync('npx', [
|
|
142
163
|
'-y',
|
|
143
|
-
|
|
164
|
+
`storybook@${latest84}`,
|
|
144
165
|
'init',
|
|
145
166
|
'--no-dev',
|
|
146
167
|
]);
|