You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We're having trouble figuring out if Storybook users are using the npx storybook@latest upgrade to upgrade Storybook, or if they do it manually or via other ways. If we could know for sure whether they've upgraded Storybook correctly, we could provide much better help to fix their issues.
Solution
Every time someone runs the Storybook upgrade command, we'll track the old and new versions, create a checksum with that info, and add it to .storybook/main.ts. This checksum will help us with telemetry so we know if users are using the upgrade command, and we can also use it to check at runtime if Storybook is installed correctly. If some packages don't match the expected version, we'll prompt users to run the upgrade command to fix the issue and update the checksum.
When users run npx storybook@latest upgrade, detect the from and to versions, create a checksum string with this info. Here's an example with base64 encoding:
Later on, at runtime, the checksum will be parsed to extract the target version.
The extracted version will be compared against the installed Storybook packages.
If discrepancies are found (e.g., some packages match the version while others do not), an error will be thrown, prompting users to run the upgrade command again.
The text was updated successfully, but these errors were encountered:
3. **Validate Checksum at Runtime:**
- Add a validation step in the Storybook initialization process to decode and compare the checksum with the installed versions. This can be done in a new utility file, e.g., `/code/lib/cli/src/validateChecksum.ts`:
```ts
import { decodeChecksum } from './upgrade';
import { getInstalledStorybookVersion } from './helpers';
export const validateChecksum = async (configDir: string) => {
const mainConfigPath = path.resolve(configDir, 'main.ts');
const mainConfigContent = await fs.promises.readFile(mainConfigPath, 'utf8');
const checksumMatch = mainConfigContent.match(/checksum: '([^']+)'/);
if (checksumMatch) {
const { fromVersion, toVersion } = decodeChecksum(checksumMatch[1]);
const installedVersion = await getInstalledStorybookVersion();
if (installedVersion !== toVersion) {
throw new Error(`Storybook version mismatch. Expected: ${toVersion}, Found: ${installedVersion}. Please run 'npx storybook@latest upgrade'.`);
}
}
};
Problem
We're having trouble figuring out if Storybook users are using the
npx storybook@latest upgrade
to upgrade Storybook, or if they do it manually or via other ways. If we could know for sure whether they've upgraded Storybook correctly, we could provide much better help to fix their issues.Solution
Every time someone runs the Storybook upgrade command, we'll track the old and new versions, create a checksum with that info, and add it to
.storybook/main.ts
. This checksum will help us with telemetry so we know if users are using the upgrade command, and we can also use it to check at runtime if Storybook is installed correctly. If some packages don't match the expected version, we'll prompt users to run the upgrade command to fix the issue and update the checksum.When users run
npx storybook@latest upgrade
, detect the from and to versions, create a checksum string with this info. Here's an example with base64 encoding:Then add it to
.storybook/main.ts
e.g.:Later on, at runtime, the checksum will be parsed to extract the target version.
The extracted version will be compared against the installed Storybook packages.
If discrepancies are found (e.g., some packages match the version while others do not), an error will be thrown, prompting users to run the upgrade command again.
The text was updated successfully, but these errors were encountered: