How to use releaseNotesVersion method in storybook-root

Best JavaScript code snippet using storybook-root

release-notes.ts

Source:release-notes.ts Github

copy

Full Screen

1import semver from '@storybook/semver';2import type { ReleaseNotesData } from '@storybook/core-common';3// We only expect to have release notes available for major and minor releases.4// For this reason, we convert the actual version of the build here so that5// every place that relies on this data can reference the version of the6// release notes that we expect to use.7const getReleaseNotesVersion = (version: string): string => {8 const { major, minor } = semver.parse(version);9 const { version: releaseNotesVersion } = semver.coerce(`${major}.${minor}`);10 return releaseNotesVersion;11};12export const getReleaseNotesFailedState = (version: string) => {13 return {14 success: false,15 currentVersion: getReleaseNotesVersion(version),16 showOnFirstLaunch: false,17 };18};19export const RELEASE_NOTES_CACHE_KEY = 'releaseNotesData';20export const getReleaseNotesData = async (21 currentVersionToParse: string,22 fileSystemCache: any23): Promise<ReleaseNotesData> => {24 let result;25 try {26 const fromCache = (await fileSystemCache.get('releaseNotesData', []).catch(() => {})) || [];27 const releaseNotesVersion = getReleaseNotesVersion(currentVersionToParse);28 const versionHasNotBeenSeen = !fromCache.includes(releaseNotesVersion);29 if (versionHasNotBeenSeen) {30 await fileSystemCache.set('releaseNotesData', [...fromCache, releaseNotesVersion]);31 }32 const sortedHistory = semver.sort(fromCache);33 const highestVersionSeenInThePast = sortedHistory.slice(-1)[0];34 let isUpgrading = false;35 let isMajorOrMinorDiff = false;36 if (highestVersionSeenInThePast) {37 isUpgrading = semver.gt(releaseNotesVersion, highestVersionSeenInThePast);38 const versionDiff = semver.diff(releaseNotesVersion, highestVersionSeenInThePast);39 isMajorOrMinorDiff = versionDiff === 'major' || versionDiff === 'minor';40 }41 result = {42 success: true,43 showOnFirstLaunch:44 versionHasNotBeenSeen &&45 // Only show the release notes if this is not the first time Storybook46 // has been built.47 !!highestVersionSeenInThePast &&48 isUpgrading &&49 isMajorOrMinorDiff,50 currentVersion: releaseNotesVersion,51 };52 } catch (e) {53 result = getReleaseNotesFailedState(currentVersionToParse);54 }55 return result;...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run storybook-root automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful