Skip to content

Commit c20d5d8

Browse files
committed
make sure Storybook will install the latest 8.4.x version regardless of local caching
1 parent bd6eebb commit c20d5d8

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "generator-bitloops",
3-
"version": "0.3.11",
3+
"version": "0.3.12",
44
"description": "Next.js with TypeScript, Tailwind, Storybook and Cypress generator by Bitloops",
55
"license": "MIT",
66
"author": "Bitloops S.A.",

setup/index.js

+22-1
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,30 @@ export default class extends Generator {
138138
// Conditionally initialize Storybook
139139
if (this.options.storybook) {
140140
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
141162
this.spawnCommandSync('npx', [
142163
'-y',
143-
'storybook@^8.4',
164+
`storybook@${latest84}`,
144165
'init',
145166
'--no-dev',
146167
]);

0 commit comments

Comments
 (0)