Skip to content

Commit

Permalink
fix(storybook): add missing value on release list
Browse files Browse the repository at this point in the history
  • Loading branch information
dpellier committed Nov 16, 2023
1 parent 53f552c commit 1e6a59f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
21 changes: 15 additions & 6 deletions packages/storybook/.storybook/utils/get-repo-releases.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
/**
* execution from directory: `npm list:releases`
* execution from directory: `yarn list:releases`
* execution from monorepo with lerna `lerna run list:releases`
*/
const fetch = require('node-fetch');
const fs = require('fs');
const fetch = require('node-fetch');
const path = require('path');
const { version: currentVersion } = require (path.resolve(process.cwd(), 'package.json'));

const file = './public/releases.js';

(async () => {
Expand All @@ -19,10 +21,17 @@ const file = './public/releases.js';
availableVersions.latest = 'latest';
withErrors = true;
} else {
const versions = Object.keys(data.versions);
versions.sort().reverse().map((version, key) => {
const last = !key;
availableVersions[version + (last ? ' (latest)' : '')] = last ? 'latest' : version;
const versions = Object.keys(data.versions).sort().reverse();

// During release, npm registry does not know yet the new version that will get published
// so we need to add it manually
if (versions.length && versions[0] !== currentVersion) {
versions.unshift(currentVersion);
}

versions.forEach((version, index) => {
const latest = index === 0;
availableVersions[version + (latest ? ' (latest)' : '')] = latest ? 'latest' : version;
});
}

Expand Down
2 changes: 1 addition & 1 deletion packages/storybook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"main": "index.js",
"scripts": {
"build:storybook": "yarn list:releases && build-storybook -o dist",
"list:releases": "yarn node .storybook/utils/get-repo-releases.js",
"list:releases": "node .storybook/utils/get-repo-releases.js",
"prepare": "npm run build:storybook",
"start": "yarn list:releases && start-storybook -p 6006",
"start:nocache": "yarn list:releases && start-storybook -p 6006 --no-manager-cache",
Expand Down

0 comments on commit 1e6a59f

Please sign in to comment.