Skip to content

Commit fe55b72

Browse files
authored
Merge pull request #27185 from storybookjs/version-patch-from-8.1.1
Release: Patch 8.1.2
2 parents 07404c2 + cf848df commit fe55b72

File tree

21 files changed

+404
-402
lines changed

21 files changed

+404
-402
lines changed

.github/workflows/prepare-non-patch-release.yml

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,6 @@ jobs:
113113
run: |
114114
yarn release:version --deferred --release-type ${{ inputs.release-type || 'prerelease' }} ${{ inputs.pre-id && format('{0} {1}', '--pre-id', inputs.pre-id) || '' }} --verbose
115115
116-
- name: Check release vs prerelease
117-
id: is-prerelease
118-
run: yarn release:is-prerelease ${{ steps.bump-version.outputs.next-version }} --verbose
119-
120116
- name: Write changelog
121117
env:
122118
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -133,19 +129,6 @@ jobs:
133129
git commit -m "Write changelog for ${{ steps.bump-version.outputs.next-version }} [skip ci]" || true
134130
git push --force origin version-non-patch-from-${{ steps.bump-version.outputs.current-version }}
135131
136-
- name: Resolve merge-conflicts with base branch
137-
if: steps.is-prerelease.outputs.prerelease == 'false'
138-
working-directory: .
139-
env:
140-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
141-
run: |
142-
git config pull.rebase false
143-
git pull --no-commit --no-ff origin latest-release || true
144-
git checkout --ours .
145-
git add .
146-
git commit --no-verify -m "Merge latest-release into version-non-patch-from-${{ steps.bump-version.outputs.current-version }} with conflicts resolved to ours [skip ci]"
147-
git push origin version-non-patch-from-${{ steps.bump-version.outputs.current-version }}
148-
149132
- name: Generate PR description
150133
id: description
151134
env:
@@ -162,14 +145,13 @@ jobs:
162145
gh pr edit \
163146
--repo "${{github.repository }}" \
164147
--title "Release: $CAPITALIZED_RELEASE_TYPE ${{ inputs.pre-id && format('{0} ', inputs.pre-id) }}${{ steps.bump-version.outputs.next-version }}" \
165-
--base ${{ steps.is-prerelease.outputs.prerelease == 'true' && 'next-release' || 'latest-release' }} \
166148
--body "${{ steps.description.outputs.description }}"
167149
else
168150
gh pr create \
169151
--repo "${{github.repository }}"\
170152
--title "Release: $CAPITALIZED_RELEASE_TYPE ${{ inputs.pre-id && format('{0} ', inputs.pre-id) }}${{ steps.bump-version.outputs.next-version }}" \
171153
--label "release" \
172-
--base ${{ steps.is-prerelease.outputs.prerelease == 'true' && 'next-release' || 'latest-release' }} \
154+
--base next-release \
173155
--head version-non-patch-from-${{ steps.bump-version.outputs.current-version }} \
174156
--body "${{ steps.description.outputs.description }}"
175157
fi

.github/workflows/publish.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,14 @@ jobs:
154154
git merge ${{ github.ref_name }}
155155
git push origin ${{ steps.target.outputs.target }}
156156
157+
- name: Force push from 'next' to 'latest-release' and 'main' on minor/major releases
158+
if: github.ref_name == 'next-release' && steps.is-prerelease.outputs.prerelease == 'false'
159+
run: |
160+
git checkout next
161+
git pull
162+
git push --force origin latest-release
163+
git push --force origin main
164+
157165
- name: Sync CHANGELOG.md from `main` to `next`
158166
if: steps.target.outputs.target == 'main'
159167
working-directory: .

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 8.1.2
2+
3+
- Angular: Fix filtering of workspace config styles - [#27108](https://github.com/storybookjs/storybook/pull/27108), thanks @valentinpalkovic!
4+
- Next.js: Avoid interfering with the svgr loader - [#27198](https://github.com/storybookjs/storybook/pull/27198), thanks @seanparmelee!
5+
16
## 8.1.1
27

38
- Docgen: Only add react-docgen info when a component is defined in the file - [#26967](https://github.com/storybookjs/storybook/pull/26967), thanks @glenjamin!

code/builders/builder-webpack5/src/preview/iframe-webpack.config.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { dirname, join, resolve } from 'path';
22
import { DefinePlugin, HotModuleReplacementPlugin, ProgressPlugin, ProvidePlugin } from 'webpack';
33
import type { Configuration } from 'webpack';
44
import HtmlWebpackPlugin from 'html-webpack-plugin';
5+
56
// @ts-expect-error (I removed this on purpose, because it's incorrect)
67
import CaseSensitivePathsPlugin from 'case-sensitive-paths-webpack-plugin';
78
import TerserWebpackPlugin from 'terser-webpack-plugin';
@@ -53,7 +54,11 @@ const storybookPaths: Record<string, string> = {
5354
};
5455

5556
export default async (
56-
options: Options & { typescriptOptions: TypescriptOptions }
57+
options: Options & {
58+
typescriptOptions: TypescriptOptions;
59+
/* Build entries, which should not be linked in the iframe HTML file */
60+
excludeChunks?: string[];
61+
}
5762
): Promise<Configuration> => {
5863
const {
5964
outputDir = join('.', 'public'),
@@ -64,6 +69,7 @@ export default async (
6469
previewUrl,
6570
typescriptOptions,
6671
features,
72+
excludeChunks = [],
6773
} = options;
6874

6975
const isProd = configType === 'PRODUCTION';
@@ -172,6 +178,7 @@ export default async (
172178
alwaysWriteToDisk: true,
173179
inject: false,
174180
template,
181+
excludeChunks,
175182
templateParameters: {
176183
version: packageJson.version,
177184
globals: {
Lines changed: 71 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,8 @@
1-
import {
2-
BuilderContext,
3-
BuilderHandlerFn,
4-
BuilderOutput,
5-
BuilderOutputLike,
6-
Target,
7-
createBuilder,
8-
targetFromTargetString,
9-
} from '@angular-devkit/architect';
1+
import { BuilderContext, BuilderOutput, createBuilder } from '@angular-devkit/architect';
102
import { JsonObject } from '@angular-devkit/core';
11-
import { from, of, throwError } from 'rxjs';
12-
import { catchError, map, mapTo, switchMap } from 'rxjs/operators';
133
import { sync as findUpSync } from 'find-up';
144
import { sync as readUpSync } from 'read-pkg-up';
15-
import { BrowserBuilderOptions, StylePreprocessorOptions } from '@angular-devkit/build-angular';
5+
import { StylePreprocessorOptions } from '@angular-devkit/build-angular';
166

177
import { CLIOptions } from '@storybook/types';
188
import { getEnvConfig, versions } from '@storybook/core-common';
@@ -22,11 +12,13 @@ import { buildStaticStandalone, withTelemetry } from '@storybook/core-server';
2212
import {
2313
AssetPattern,
2414
SourceMapUnion,
15+
StyleClass,
2516
StyleElement,
2617
} from '@angular-devkit/build-angular/src/builders/browser/schema';
2718
import { StandaloneOptions } from '../utils/standalone-options';
2819
import { runCompodoc } from '../utils/run-compodoc';
2920
import { errorSummary, printErrorDetails } from '../utils/error-handler';
21+
import { setup } from '../utils/setup';
3022

3123
addToGlobalContext('cliVersion', versions.storybook);
3224

@@ -59,119 +51,86 @@ export type StorybookBuilderOptions = JsonObject & {
5951

6052
export type StorybookBuilderOutput = JsonObject & BuilderOutput & { [key: string]: any };
6153

62-
type StandaloneBuildOptions = StandaloneOptions & { outputDir: string };
63-
64-
const commandBuilder: BuilderHandlerFn<StorybookBuilderOptions> = (
65-
options,
66-
context
67-
): BuilderOutputLike => {
68-
const builder = from(setup(options, context)).pipe(
69-
switchMap(({ tsConfig }) => {
70-
const docTSConfig = findUpSync('tsconfig.doc.json', { cwd: options.configDir });
71-
const runCompodoc$ = options.compodoc
72-
? runCompodoc(
73-
{ compodocArgs: options.compodocArgs, tsconfig: docTSConfig ?? tsConfig },
74-
context
75-
).pipe(mapTo({ tsConfig }))
76-
: of({});
77-
78-
return runCompodoc$.pipe(mapTo({ tsConfig }));
79-
}),
80-
map(({ tsConfig }) => {
81-
getEnvConfig(options, {
82-
staticDir: 'SBCONFIG_STATIC_DIR',
83-
outputDir: 'SBCONFIG_OUTPUT_DIR',
84-
configDir: 'SBCONFIG_CONFIG_DIR',
85-
});
86-
87-
const {
88-
browserTarget,
89-
stylePreprocessorOptions,
90-
styles,
91-
configDir,
92-
docs,
93-
loglevel,
94-
test,
95-
outputDir,
96-
quiet,
97-
enableProdMode = true,
98-
webpackStatsJson,
99-
statsJson,
100-
debugWebpack,
101-
disableTelemetry,
102-
assets,
103-
previewUrl,
104-
sourceMap = false,
105-
} = options;
106-
107-
const standaloneOptions: StandaloneBuildOptions = {
108-
packageJson: readUpSync({ cwd: __dirname }).packageJson,
109-
configDir,
110-
...(docs ? { docs } : {}),
111-
loglevel,
112-
outputDir,
113-
test,
114-
quiet,
115-
enableProdMode,
116-
disableTelemetry,
117-
angularBrowserTarget: browserTarget,
118-
angularBuilderContext: context,
119-
angularBuilderOptions: {
120-
...(stylePreprocessorOptions ? { stylePreprocessorOptions } : {}),
121-
...(styles ? { styles } : {}),
122-
...(assets ? { assets } : {}),
123-
sourceMap,
124-
},
125-
tsConfig,
126-
webpackStatsJson,
127-
statsJson,
128-
debugWebpack,
129-
previewUrl,
130-
};
131-
132-
return standaloneOptions;
133-
}),
134-
switchMap((standaloneOptions) => runInstance({ ...standaloneOptions, mode: 'static' })),
135-
map(() => {
136-
return { success: true };
137-
})
138-
);
139-
140-
return builder as any as BuilderOutput;
141-
};
54+
type StandaloneBuildOptions = StandaloneOptions & { outputDir: string; excludeChunks: string[] };
14255

143-
export default createBuilder(commandBuilder);
56+
const commandBuilder = async (
57+
options: StorybookBuilderOptions,
58+
context: BuilderContext
59+
): Promise<BuilderOutput> => {
60+
const { tsConfig, angularBuilderContext, angularBuilderOptions } = await setup(options, context);
14461

145-
async function setup(options: StorybookBuilderOptions, context: BuilderContext) {
146-
let browserOptions: (JsonObject & BrowserBuilderOptions) | undefined;
147-
let browserTarget: Target | undefined;
62+
const docTSConfig = findUpSync('tsconfig.doc.json', { cwd: options.configDir });
14863

149-
if (options.browserTarget) {
150-
browserTarget = targetFromTargetString(options.browserTarget);
151-
browserOptions = await context.validateOptions<JsonObject & BrowserBuilderOptions>(
152-
await context.getTargetOptions(browserTarget),
153-
await context.getBuilderNameForTarget(browserTarget)
64+
if (options.compodoc) {
65+
await runCompodoc(
66+
{ compodocArgs: options.compodocArgs, tsconfig: docTSConfig ?? tsConfig },
67+
context
15468
);
15569
}
15670

157-
return {
158-
tsConfig:
159-
options.tsConfig ??
160-
findUpSync('tsconfig.json', { cwd: options.configDir }) ??
161-
browserOptions.tsConfig,
71+
getEnvConfig(options, {
72+
staticDir: 'SBCONFIG_STATIC_DIR',
73+
outputDir: 'SBCONFIG_OUTPUT_DIR',
74+
configDir: 'SBCONFIG_CONFIG_DIR',
75+
});
76+
77+
const {
78+
configDir,
79+
docs,
80+
loglevel,
81+
test,
82+
outputDir,
83+
quiet,
84+
enableProdMode = true,
85+
webpackStatsJson,
86+
statsJson,
87+
debugWebpack,
88+
disableTelemetry,
89+
previewUrl,
90+
} = options;
91+
92+
const standaloneOptions: StandaloneBuildOptions = {
93+
packageJson: readUpSync({ cwd: __dirname }).packageJson,
94+
configDir,
95+
...(docs ? { docs } : {}),
96+
excludeChunks: angularBuilderOptions.styles
97+
?.filter((style) => typeof style !== 'string' && style.inject === false)
98+
.map((s: StyleClass) => s.bundleName),
99+
loglevel,
100+
outputDir,
101+
test,
102+
quiet,
103+
enableProdMode,
104+
disableTelemetry,
105+
angularBrowserTarget: options.browserTarget,
106+
angularBuilderContext,
107+
angularBuilderOptions,
108+
tsConfig,
109+
webpackStatsJson,
110+
statsJson,
111+
debugWebpack,
112+
previewUrl,
162113
};
163-
}
164114

165-
function runInstance(options: StandaloneBuildOptions) {
166-
return from(
167-
withTelemetry(
115+
await runInstance({ ...standaloneOptions, mode: 'static' });
116+
117+
return { success: true };
118+
};
119+
120+
export default createBuilder(commandBuilder);
121+
122+
async function runInstance(options: StandaloneBuildOptions) {
123+
try {
124+
await withTelemetry(
168125
'build',
169126
{
170127
cliOptions: options,
171128
presetOptions: { ...options, corePresets: [], overridePresets: [] },
172129
printError: printErrorDetails,
173130
},
174131
() => buildStaticStandalone(options)
175-
)
176-
).pipe(catchError((error: any) => throwError(errorSummary(error))));
132+
);
133+
} catch (error) {
134+
throw new Error(errorSummary(error));
135+
}
177136
}

0 commit comments

Comments
 (0)