Skip to content

Commit

Permalink
Merge pull request #29142 from storybookjs/version-patch-from-8.3.1
Browse files Browse the repository at this point in the history
Release: Patch 8.3.2
  • Loading branch information
valentinpalkovic authored Sep 19, 2024
2 parents 43accbc + 833d580 commit e80e5a2
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 11 deletions.
2 changes: 2 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,8 @@ jobs:
mkdir empty-<< parameters.template >>-no-install
cd empty-<< parameters.template >>-no-install
npx storybook init --yes --skip-install
npm install
npm run build-storybook
environment:
IN_STORYBOOK_SANDBOX: true
STORYBOOK_INIT_EMPTY_TYPE: << parameters.template >>
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 8.3.2

- CLI: Fix skip-install for stable latest releases - [#29133](https://github.com/storybookjs/storybook/pull/29133), thanks @valentinpalkovic!
- Core: Do not add packageManager field to package.json during `storybook dev` - [#29152](https://github.com/storybookjs/storybook/pull/29152), thanks @valentinpalkovic!

## 8.3.1

- Angular: Fix sourceDecorator to apply excludeDecorators flag - [#29069](https://github.com/storybookjs/storybook/pull/29069), thanks @JSMike!
Expand Down
54 changes: 54 additions & 0 deletions code/core/src/common/js-package-manager/JsPackageManager.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { beforeEach, describe, expect, it, vi } from 'vitest';

import { JsPackageManager } from './JsPackageManager';

vi.mock('../versions', () => ({
default: {
'@storybook/react': '8.3.0',
},
}));

describe('JsPackageManager', () => {
let jsPackageManager: JsPackageManager;
let mockLatestVersion: ReturnType<typeof vi.fn>;
let mockStorybookPackagesVersions: Record<string, string>;

beforeEach(() => {
mockLatestVersion = vi.fn();
mockStorybookPackagesVersions = {
'@storybook/react': '8.3.0',
};

// @ts-expect-error Ignore abstract class error
jsPackageManager = new JsPackageManager();
jsPackageManager.latestVersion = mockLatestVersion;

vi.clearAllMocks();
});

describe('getVersionedPackages method', () => {
it('should return the latest stable release version when current version is the latest stable release', async () => {
mockLatestVersion.mockResolvedValue('8.3.0');

const result = await jsPackageManager.getVersionedPackages(['@storybook/react']);

expect(result).toEqual(['@storybook/react@^8.3.0']);
});

it('should return the current version when it is not the latest stable release', async () => {
mockLatestVersion.mockResolvedValue('8.3.1');

const result = await jsPackageManager.getVersionedPackages(['@storybook/react']);

expect(result).toEqual(['@storybook/[email protected]']);
});

it('should return the latest stable release version when there is no current version', async () => {
mockLatestVersion.mockResolvedValue('2.0.0');

const result = await jsPackageManager.getVersionedPackages(['@storybook/new-addon@^8.3.0']);

expect(result).toEqual(['@storybook/new-addon@^2.0.0']);
});
});
});
12 changes: 6 additions & 6 deletions code/core/src/common/js-package-manager/JsPackageManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,13 +337,13 @@ export abstract class JsPackageManager {
const k = packageName as keyof typeof storybookPackagesVersions;
const currentVersion = storybookPackagesVersions[k];

if (currentVersion === latestInRange) {
return `${packageName}`;
}
if (currentVersion) {
return `${packageName}@${currentVersion}`;
const isLatestStableRelease = currentVersion === latestInRange;

if (isLatestStableRelease || !currentVersion) {
return `${packageName}@^${latestInRange}`;
}
return `${packageName}@^${latestInRange}`;

return `${packageName}@${currentVersion}`;
})
);
}
Expand Down
24 changes: 21 additions & 3 deletions code/core/src/common/js-package-manager/JsPackageManagerFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,17 +125,35 @@ export class JsPackageManagerFactory {
}

function hasNPM(cwd?: string) {
const npmVersionCommand = spawnSync('npm', ['--version'], { cwd, shell: true });
const npmVersionCommand = spawnSync('npm', ['--version'], {
cwd,
shell: true,
env: {
COREPACK_ENABLE_STRICT: '0',
},
});
return npmVersionCommand.status === 0;
}

function hasPNPM(cwd?: string) {
const pnpmVersionCommand = spawnSync('pnpm', ['--version'], { cwd, shell: true });
const pnpmVersionCommand = spawnSync('pnpm', ['--version'], {
cwd,
shell: true,
env: {
COREPACK_ENABLE_STRICT: '0',
},
});
return pnpmVersionCommand.status === 0;
}

function getYarnVersion(cwd?: string): 1 | 2 | undefined {
const yarnVersionCommand = spawnSync('yarn', ['--version'], { cwd, shell: true });
const yarnVersionCommand = spawnSync('yarn', ['--version'], {
cwd,
shell: true,
env: {
COREPACK_ENABLE_STRICT: '0',
},
});

if (yarnVersionCommand.status !== 0) {
return undefined;
Expand Down
3 changes: 2 additions & 1 deletion code/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -295,5 +295,6 @@
"Dependency Upgrades"
]
]
}
},
"deferredNextVersion": "8.3.2"
}
2 changes: 1 addition & 1 deletion docs/versions/latest.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version":"8.3.1","info":{"plain":"- Angular: Fix sourceDecorator to apply excludeDecorators flag - [#29069](https://github.com/storybookjs/storybook/pull/29069), thanks @JSMike!\n- Core: Do not prebundle better-opn - [#29137](https://github.com/storybookjs/storybook/pull/29137), thanks @valentinpalkovic!\n- Core: Do not prebundle jsdoc-type-pratt-parser - [#29134](https://github.com/storybookjs/storybook/pull/29134), thanks @valentinpalkovic!\n- Next.js: Upgrade sass-loader from ^12 to ^13 - [#29040](https://github.com/storybookjs/storybook/pull/29040), thanks @HoncharenkoZhenya!"}}
{"version":"8.3.2","info":{"plain":"- CLI: Fix skip-install for stable latest releases - [#29133](https://github.com/storybookjs/storybook/pull/29133), thanks @valentinpalkovic!\n- Core: Do not add packageManager field to package.json during `storybook dev` - [#29152](https://github.com/storybookjs/storybook/pull/29152), thanks @valentinpalkovic!"}}

0 comments on commit e80e5a2

Please sign in to comment.