Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions code/core/src/cli/angular/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import semver from 'semver';

export const ANGULAR_JSON_PATH = 'angular.json';

/** Must stay inside the `>=2.0.0` peer range that `@storybook/angular-vite` declares. */
export const ANALOG_VITE_PLUGIN_ANGULAR_VERSION = '^2.5.2';
/** Must stay inside the `>=2.7.3` peer range that `@storybook/angular-vite` declares. */
export const ANALOG_VITE_PLUGIN_ANGULAR_VERSION = '^2.7.3';

export const toDevkitVersion = (ngRange?: string | null): string | undefined => {
if (!ngRange) {
Expand Down
2 changes: 1 addition & 1 deletion code/frameworks/angular-vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
"zone.js": "^0.16.2"
},
"peerDependencies": {
"@analogjs/vite-plugin-angular": ">=2.0.0",
"@analogjs/vite-plugin-angular": ">=2.7.3",
"@angular-devkit/architect": ">=0.2100.0 < 0.2300.0",
"@angular-devkit/core": ">=21.0.0 < 23.0.0",
"@angular/build": ">=21.0.0 < 23.0.0",
Expand Down
7 changes: 6 additions & 1 deletion code/lib/cli-storybook/src/sandbox-templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,9 @@ export type Template = {
*
* The gate is enforced transitively, so this has to name the whole family of
* packages published in lockstep with the prerelease, not just the direct
* dependency. Stable templates should leave this unset.
* dependency. Stable templates should leave this unset, unless a dependency
* must adopt a compatibility release as soon as a peer it tracks clears the
* gate.
*/
minAgeGateExemptions?: string[];
/** Additional options to pass to the initiate command when initializing Storybook. */
Expand Down Expand Up @@ -683,6 +685,7 @@ export const baseTemplates = {
extraCiSteps: {
ensureMinNodeVersion: true,
},
minAgeGateExemptions: ['@analogjs/vite-plugin-angular'],
expected: {
framework: '@storybook/angular-vite',
renderer: '@storybook/angular-vite',
Expand Down Expand Up @@ -715,6 +718,7 @@ export const baseTemplates = {
extraCiSteps: {
ensureMinNodeVersion: true,
},
minAgeGateExemptions: ['@analogjs/vite-plugin-angular'],
expected: {
framework: '@storybook/angular-vite',
renderer: '@storybook/angular-vite',
Expand Down Expand Up @@ -755,6 +759,7 @@ export const baseTemplates = {
extraCiSteps: {
ensureMinNodeVersion: true,
},
minAgeGateExemptions: ['@analogjs/vite-plugin-angular'],
Comment thread
valentinpalkovic marked this conversation as resolved.
expected: {
framework: '@storybook/angular-vite',
renderer: '@storybook/angular-vite',
Expand Down
2 changes: 1 addition & 1 deletion scripts/tasks/sandbox-parts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ export const create: Task['run'] = async ({ key, template, sandboxDir }, { dryRu

export const install: Task['run'] = async ({ sandboxDir, key }, { link, dryRun, debug }) => {
const cwd = sandboxDir;
await installYarn2({ cwd, dryRun, debug });
await installYarn2({ cwd, dryRun, debug, key });

if (link) {
await executeCLIStep(steps.link, {
Expand Down
11 changes: 8 additions & 3 deletions scripts/utils/preapprove-local-packages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,14 @@ export const LOCALLY_PUBLISHED_PACKAGE_PATTERNS = [
* quarantined.
*
* Merges with whatever is already allowed, so a template that names its own prerelease
* packages does not lose them.
* packages does not lose them. `extraPatterns` carries the template's `minAgeGateExemptions`
* for dependencies that only `storybook init` adds, which the published `.yarnrc.yml` cannot
* know about.
*/
export async function preapproveLocallyPublishedPackages(cwd: string) {
export async function preapproveLocallyPublishedPackages(
cwd: string,
extraPatterns: string[] = []
) {
const configPath = join(cwd, '.yarnrc.yml');

let config: Record<string, unknown> = {};
Expand All @@ -40,7 +45,7 @@ export async function preapproveLocallyPublishedPackages(cwd: string) {
: [];

config.npmPreapprovedPackages = Array.from(
new Set([...existing, ...LOCALLY_PUBLISHED_PACKAGE_PATTERNS])
new Set([...existing, ...LOCALLY_PUBLISHED_PACKAGE_PATTERNS, ...extraPatterns])
);

await writeFile(configPath, yml.stringify(config));
Expand Down
24 changes: 19 additions & 5 deletions scripts/utils/yarn.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe('installYarn2', () => {
it('keeps the published lockfile instead of resolving from scratch', async () => {
publishedSandbox();

await installYarn2({ cwd: SANDBOX, dryRun: false, debug: false });
await installYarn2({ cwd: SANDBOX, dryRun: false, debug: false, key: 'react-vite/default-ts' });

// Emptying this made every CI run re-resolve the whole tree against live npm.
expect(vol.readFileSync(`${SANDBOX}/yarn.lock`, 'utf-8')).toContain('version: 4.1.2');
Expand All @@ -56,7 +56,7 @@ describe('installYarn2', () => {
it('leaves the age gate in force', async () => {
publishedSandbox();

await installYarn2({ cwd: SANDBOX, dryRun: false, debug: false });
await installYarn2({ cwd: SANDBOX, dryRun: false, debug: false, key: 'react-vite/default-ts' });

expect(readConfig().npmMinimalAgeGate).toBe(10080);
expect(yarnCommands()).not.toContain('npmMinimalAgeGate 0');
Expand All @@ -65,7 +65,7 @@ describe('installYarn2', () => {
it('preapproves the locally published Storybook packages instead', async () => {
publishedSandbox();

await installYarn2({ cwd: SANDBOX, dryRun: false, debug: false });
await installYarn2({ cwd: SANDBOX, dryRun: false, debug: false, key: 'react-vite/default-ts' });

// They are published to Verdaccio seconds before this install, so they can never
// satisfy the gate on their own.
Expand All @@ -83,16 +83,30 @@ describe('installYarn2', () => {
it('keeps a template allowlist rather than replacing it', async () => {
publishedSandbox({ npmPreapprovedPackages: ['next', '@next/*'] });

await installYarn2({ cwd: SANDBOX, dryRun: false, debug: false });
await installYarn2({ cwd: SANDBOX, dryRun: false, debug: false, key: 'react-vite/default-ts' });

const approved: string[] = readConfig().npmPreapprovedPackages;
expect(approved).toEqual(expect.arrayContaining(['next', '@next/*', 'storybook']));
});

it('preapproves the template exemptions for dependencies that init adds', async () => {
publishedSandbox();

await installYarn2({
cwd: SANDBOX,
dryRun: false,
debug: false,
key: 'angular-vite/default-ts',
});

// The published sandbox predates Storybook, so its `.yarnrc.yml` cannot name them.
expect(readConfig().npmPreapprovedPackages).toContain('@analogjs/vite-plugin-angular');
});

it('does not write a yarnPath next to the pinned packageManager', async () => {
publishedSandbox();

await installYarn2({ cwd: SANDBOX, dryRun: false, debug: false });
await installYarn2({ cwd: SANDBOX, dryRun: false, debug: false, key: 'react-vite/default-ts' });

// corepack aborts when `yarnPath` and `packageManager` disagree.
expect(yarnCommands()).not.toContain('yarn set version');
Expand Down
9 changes: 7 additions & 2 deletions scripts/utils/yarn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ export const addPackageResolutions = async ({ cwd, dryRun }: YarnOptions) => {
await writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2));
};

export const installYarn2 = async ({ cwd, dryRun, debug }: YarnOptions) => {
export const installYarn2 = async ({
cwd,
dryRun,
debug,
key,
}: YarnOptions & { key: AllTemplatesKey }) => {
await mkdir(cwd, { recursive: true });

// The published sandbox ships a lockfile and a `.yarnrc.yml` carrying the age gate.
Expand All @@ -47,7 +52,7 @@ export const installYarn2 = async ({ cwd, dryRun, debug }: YarnOptions) => {
// Our own Storybook packages are published to Verdaccio seconds before this install,
// so they can never satisfy the gate. Name them instead of switching it off, exactly
// as sandbox generation does for the `after-storybook` install.
await preapproveLocallyPublishedPackages(cwd);
await preapproveLocallyPublishedPackages(cwd, allTemplates[key].minAgeGateExemptions);

const command = [
// No `yarn set version` here: the sandbox pins Yarn through the `packageManager`
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10098,7 +10098,7 @@ __metadata:
vite: "npm:>=8.0.0"
zone.js: "npm:^0.16.2"
peerDependencies:
"@analogjs/vite-plugin-angular": ">=2.0.0"
"@analogjs/vite-plugin-angular": ">=2.7.3"
"@angular-devkit/architect": ">=0.2100.0 < 0.2300.0"
"@angular-devkit/core": ">=21.0.0 < 23.0.0"
"@angular/build": ">=21.0.0 < 23.0.0"
Expand Down
Loading