Skip to content

Commit e46747e

Browse files
authored
Merge pull request #28835 from storybookjs/norbert/use-node-20
Build: Use node 22 in monorepo
2 parents 3b87230 + 1f7250b commit e46747e

File tree

39 files changed

+233
-11713
lines changed

39 files changed

+233
-11713
lines changed

.circleci/config.yml

+28-15
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ parameters:
1616
default: "next"
1717

1818
executors:
19-
sb_node_18_classic:
19+
sb_node_22_classic:
2020
parameters:
2121
class:
2222
description: The Resource class
@@ -25,7 +25,7 @@ executors:
2525
default: "small"
2626
working_directory: /tmp/storybook
2727
docker:
28-
- image: cimg/node:18.19.1
28+
- image: cimg/node:22.6.0
2929
environment:
3030
NODE_OPTIONS: --max_old_space_size=6144
3131
resource_class: <<parameters.class>>
@@ -38,7 +38,20 @@ executors:
3838
default: "small"
3939
working_directory: /tmp/storybook
4040
docker:
41-
- image: cimg/node:18.19.1-browsers
41+
- image: cimg/node:18.20.3-browsers
42+
environment:
43+
NODE_OPTIONS: --max_old_space_size=6144
44+
resource_class: <<parameters.class>>
45+
sb_node_22_browsers:
46+
parameters:
47+
class:
48+
description: The Resource class
49+
type: enum
50+
enum: ["small", "medium", "medium+", "large", "xlarge"]
51+
default: "small"
52+
working_directory: /tmp/storybook
53+
docker:
54+
- image: cimg/node:22.6.0-browsers
4255
environment:
4356
NODE_OPTIONS: --max_old_space_size=6144
4457
resource_class: <<parameters.class>>
@@ -108,7 +121,7 @@ jobs:
108121
pretty-docs:
109122
executor:
110123
class: medium
111-
name: sb_node_18_classic
124+
name: sb_node_22_classic
112125
steps:
113126
- git-shallow-clone/checkout_advanced:
114127
clone_options: "--depth 1 --verbose"
@@ -134,7 +147,7 @@ jobs:
134147
build:
135148
executor:
136149
class: xlarge
137-
name: sb_node_18_classic
150+
name: sb_node_22_classic
138151
steps:
139152
- git-shallow-clone/checkout_advanced:
140153
clone_options: "--depth 1 --verbose"
@@ -179,7 +192,7 @@ jobs:
179192
lint:
180193
executor:
181194
class: large
182-
name: sb_node_18_classic
195+
name: sb_node_22_classic
183196
steps:
184197
- git-shallow-clone/checkout_advanced:
185198
clone_options: "--depth 1 --verbose"
@@ -195,7 +208,7 @@ jobs:
195208
check:
196209
executor:
197210
class: xlarge
198-
name: sb_node_18_classic
211+
name: sb_node_22_classic
199212
steps:
200213
- git-shallow-clone/checkout_advanced:
201214
clone_options: "--depth 1 --verbose"
@@ -213,7 +226,7 @@ jobs:
213226
- report-workflow-on-failure
214227
- cancel-workflow-on-failure
215228
script-checks:
216-
executor: sb_node_18_browsers
229+
executor: sb_node_22_browsers
217230
steps:
218231
- git-shallow-clone/checkout_advanced:
219232
clone_options: "--depth 1 --verbose"
@@ -241,7 +254,7 @@ jobs:
241254
unit-tests:
242255
executor:
243256
class: xlarge
244-
name: sb_node_18_browsers
257+
name: sb_node_22_browsers
245258
steps:
246259
- git-shallow-clone/checkout_advanced:
247260
clone_options: "--depth 1 --verbose"
@@ -263,7 +276,7 @@ jobs:
263276
coverage:
264277
executor:
265278
class: small
266-
name: sb_node_18_browsers
279+
name: sb_node_22_browsers
267280
steps:
268281
- git-shallow-clone/checkout_advanced:
269282
clone_options: "--depth 1 --verbose"
@@ -274,7 +287,7 @@ jobs:
274287
chromatic-internal-storybook:
275288
executor:
276289
class: medium+
277-
name: sb_node_18_browsers
290+
name: sb_node_22_browsers
278291
environment:
279292
NODE_OPTIONS: --max_old_space_size=6144
280293
steps:
@@ -296,7 +309,7 @@ jobs:
296309
type: integer
297310
executor:
298311
class: medium
299-
name: sb_node_18_browsers
312+
name: sb_node_22_browsers
300313
parallelism: << parameters.parallelism >>
301314
steps:
302315
- git-shallow-clone/checkout_advanced:
@@ -343,7 +356,7 @@ jobs:
343356
type: integer
344357
executor:
345358
class: large
346-
name: sb_node_18_browsers
359+
name: sb_node_22_browsers
347360
parallelism: << parameters.parallelism >>
348361
steps:
349362
- git-shallow-clone/checkout_advanced:
@@ -424,7 +437,7 @@ jobs:
424437
type: integer
425438
executor:
426439
class: medium
427-
name: sb_node_18_browsers
440+
name: sb_node_22_browsers
428441
parallelism: << parameters.parallelism >>
429442
steps:
430443
- checkout
@@ -507,7 +520,7 @@ jobs:
507520
test-empty-init:
508521
executor:
509522
class: medium
510-
name: sb_node_18_browsers
523+
name: sb_node_22_browsers
511524
parameters:
512525
packageManager:
513526
type: string

.nvmrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
18.19.1
1+
22.6.0

code/addons/interactions/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
"devDependencies": {
6363
"@devtools-ds/object-inspector": "^1.1.2",
6464
"@storybook/icons": "^1.2.5",
65-
"@types/node": "^18.0.0",
65+
"@types/node": "^22.0.0",
6666
"formik": "^2.2.9",
6767
"react": "^18.2.0",
6868
"react-dom": "^18.2.0",

code/builders/builder-vite/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
},
5656
"devDependencies": {
5757
"@types/express": "^4.17.21",
58-
"@types/node": "^18.0.0",
58+
"@types/node": "^22.0.0",
5959
"glob": "^10.0.0",
6060
"slash": "^5.0.0",
6161
"typescript": "^5.3.2",

code/builders/builder-webpack5/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
},
6565
"dependencies": {
6666
"@storybook/core-webpack": "workspace:*",
67-
"@types/node": "^18.0.0",
67+
"@types/node": "^22.0.0",
6868
"@types/semver": "^7.3.4",
6969
"browser-assert": "^1.2.1",
7070
"case-sensitive-paths-webpack-plugin": "^2.4.0",

code/core/package.json

+2-4
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,6 @@
271271
"dependencies": {
272272
"@storybook/csf": "^0.1.11",
273273
"@types/express": "^4.17.21",
274-
"@types/node": "^18.0.0",
275274
"browser-assert": "^1.2.1",
276275
"esbuild": "^0.18.0 || ^0.19.0 || ^0.20.0 || ^0.21.0 || ^0.22.0 || ^0.23.0",
277276
"esbuild-register": "^3.5.0",
@@ -314,8 +313,7 @@
314313
"@types/fs-extra": "^11.0.1",
315314
"@types/js-yaml": "^4.0.5",
316315
"@types/lodash": "^4.14.167",
317-
"@types/mock-fs": "^4.13.1",
318-
"@types/node": "^18.0.0",
316+
"@types/node": "^22.0.0",
319317
"@types/npmlog": "^7.0.0",
320318
"@types/picomatch": "^2.3.0",
321319
"@types/prettier": "^3.0.0",
@@ -375,8 +373,8 @@
375373
"leven": "^4.0.0",
376374
"lodash": "^4.17.21",
377375
"markdown-to-jsx": "^7.4.5",
376+
"memfs": "^4.11.1",
378377
"memoizerific": "^1.11.3",
379-
"mock-fs": "^5.2.0",
380378
"nanoid": "^4.0.2",
381379
"npmlog": "^7.0.0",
382380
"open": "^8.4.0",

code/core/src/common/utils/__tests__/interpret-files.test.ts

+15-9
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
1-
import { describe, afterEach, it, expect } from 'vitest';
2-
import mock from 'mock-fs';
1+
import { describe, afterEach, it, expect, vi } from 'vitest';
32
import { getInterpretedFile } from '../interpret-files';
3+
import { vol } from 'memfs';
4+
5+
vi.mock('fs', async () => {
6+
const memfs = await vi.importActual('memfs');
7+
8+
return { default: memfs.fs, ...(memfs as any).fs };
9+
});
410

511
describe('interpret-files', () => {
612
it('will interpret file as file.ts when it exists in fs', () => {
7-
mock({
13+
vol.fromNestedJSON({
814
'path/to/file.ts': 'ts file contents',
915
});
1016

@@ -14,7 +20,7 @@ describe('interpret-files', () => {
1420
});
1521

1622
it('will interpret file as file.js when both are in fs', () => {
17-
mock({
23+
vol.fromNestedJSON({
1824
'path/to/file.js': 'js file contents',
1925
'path/to/file.ts': 'ts file contents',
2026
});
@@ -25,7 +31,7 @@ describe('interpret-files', () => {
2531
});
2632

2733
it('will interpret file even if extension is already present', () => {
28-
mock({
34+
vol.fromNestedJSON({
2935
'path/to/file.js': 'js file contents',
3036
'path/to/file.ts': 'ts file contents',
3137
});
@@ -36,7 +42,7 @@ describe('interpret-files', () => {
3642
});
3743

3844
it('will return undefined if there is no candidate of a file in fs', () => {
39-
mock({
45+
vol.fromNestedJSON({
4046
'path/to/file.js': 'js file contents',
4147
});
4248

@@ -46,7 +52,7 @@ describe('interpret-files', () => {
4652
});
4753

4854
it('will interpret file as file.mts when it exists in fs', () => {
49-
mock({
55+
vol.fromNestedJSON({
5056
'path/to/file.mts': 'ts file contents',
5157
});
5258

@@ -56,7 +62,7 @@ describe('interpret-files', () => {
5662
});
5763

5864
it('will interpret file as file.cts when it exists in fs', () => {
59-
mock({
65+
vol.fromNestedJSON({
6066
'path/to/file.cts': 'ts file contents',
6167
});
6268

@@ -65,5 +71,5 @@ describe('interpret-files', () => {
6571
expect(file).toEqual('path/to/file.cts');
6672
});
6773

68-
afterEach(mock.restore);
74+
afterEach(() => vol.reset());
6975
});

code/core/src/common/utils/__tests__/template.test.ts

+16-22
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
1-
import { describe, beforeEach, afterEach, it, expect } from 'vitest';
2-
import mock from 'mock-fs';
1+
import { describe, beforeEach, afterEach, it, expect, vi } from 'vitest';
32
import { getPreviewHeadTemplate, getPreviewBodyTemplate } from '../template';
43
import { dirname } from 'node:path';
54

5+
import { vol } from 'memfs';
6+
7+
vi.mock('fs', async () => {
8+
const memfs = await vi.importActual('memfs');
9+
10+
return { default: memfs.fs, ...(memfs as any).fs };
11+
});
12+
613
const HEAD_HTML_CONTENTS = '<script>console.log("custom script!");</script>';
714
const BASE_HTML_CONTENTS = '<script>console.log("base script!");</script>';
815

@@ -12,18 +19,17 @@ const BODY_HTML_CONTENTS = '<div>custom body contents</div>';
1219
const base = dirname(require.resolve('@storybook/core/package.json'));
1320

1421
describe('server.getPreviewHeadHtml', () => {
22+
afterEach(() => {
23+
vol.reset();
24+
});
1525
describe('when .storybook/preview-head.html does not exist', () => {
1626
beforeEach(() => {
17-
mock({
27+
vol.fromNestedJSON({
1828
[`${base}/assets/server/base-preview-head.html`]: BASE_HTML_CONTENTS,
1929
config: {},
2030
});
2131
});
2232

23-
afterEach(() => {
24-
mock.restore();
25-
});
26-
2733
it('return an empty string', () => {
2834
const result = getPreviewHeadTemplate('./config');
2935
expect(result).toEqual(BASE_HTML_CONTENTS);
@@ -32,18 +38,14 @@ describe('server.getPreviewHeadHtml', () => {
3238

3339
describe('when .storybook/preview-head.html exists', () => {
3440
beforeEach(() => {
35-
mock({
41+
vol.fromNestedJSON({
3642
[`${base}/assets/server/base-preview-head.html`]: BASE_HTML_CONTENTS,
3743
config: {
3844
'preview-head.html': HEAD_HTML_CONTENTS,
3945
},
4046
});
4147
});
4248

43-
afterEach(() => {
44-
mock.restore();
45-
});
46-
4749
it('return the contents of the file', () => {
4850
const result = getPreviewHeadTemplate('./config');
4951
expect(result).toEqual(BASE_HTML_CONTENTS + HEAD_HTML_CONTENTS);
@@ -54,16 +56,12 @@ describe('server.getPreviewHeadHtml', () => {
5456
describe('server.getPreviewBodyHtml', () => {
5557
describe('when .storybook/preview-body.html does not exist', () => {
5658
beforeEach(() => {
57-
mock({
59+
vol.fromNestedJSON({
5860
[`${base}/assets/server/base-preview-body.html`]: BASE_BODY_HTML_CONTENTS,
5961
config: {},
6062
});
6163
});
6264

63-
afterEach(() => {
64-
mock.restore();
65-
});
66-
6765
it('return an empty string', () => {
6866
const result = getPreviewBodyTemplate('./config');
6967
expect(result).toEqual(BASE_BODY_HTML_CONTENTS);
@@ -72,18 +70,14 @@ describe('server.getPreviewBodyHtml', () => {
7270

7371
describe('when .storybook/preview-body.html exists', () => {
7472
beforeEach(() => {
75-
mock({
73+
vol.fromNestedJSON({
7674
[`${base}/assets/server/base-preview-body.html`]: BASE_BODY_HTML_CONTENTS,
7775
config: {
7876
'preview-body.html': BODY_HTML_CONTENTS,
7977
},
8078
});
8179
});
8280

83-
afterEach(() => {
84-
mock.restore();
85-
});
86-
8781
it('return the contents of the file', () => {
8882
const result = getPreviewBodyTemplate('./config');
8983
expect(result).toEqual(BODY_HTML_CONTENTS + BASE_BODY_HTML_CONTENTS);

code/frameworks/angular/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"@storybook/manager-api": "workspace:^",
4545
"@storybook/preview-api": "workspace:^",
4646
"@storybook/theming": "workspace:^",
47-
"@types/node": "^18.0.0",
47+
"@types/node": "^22.0.0",
4848
"@types/react": "^18.0.37",
4949
"@types/react-dom": "^18.0.11",
5050
"@types/semver": "^7.3.4",

code/frameworks/html-vite/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"magic-string": "^0.30.0"
5353
},
5454
"devDependencies": {
55-
"@types/node": "^18.0.0",
55+
"@types/node": "^22.0.0",
5656
"typescript": "^5.3.2"
5757
},
5858
"peerDependencies": {

0 commit comments

Comments
 (0)