1
1
#!/usr/bin/env zx
2
2
3
- import boxen from " boxen" ;
4
- import dedent from " dedent" ;
5
- import { readFile } from 'fs/promises' ;
6
- import { globalPackages as globalManagerPackages } from "@ storybook/manager/globals" ;
7
- import { globalPackages as globalPreviewPackages } from "@ storybook/preview/globals" ;
3
+ import boxen from ' boxen' ;
4
+ import dedent from ' dedent' ;
5
+ import { readFile } from 'node: fs/promises' ;
6
+ import { globalPackages as globalManagerPackages } from ' storybook/internal/ manager/globals' ;
7
+ import { globalPackages as globalPreviewPackages } from ' storybook/internal/ preview/globals' ;
8
8
9
9
const packageJson = await readFile ( './package.json' , 'utf8' ) . then ( JSON . parse ) ;
10
10
@@ -17,44 +17,44 @@ $.verbose = false;
17
17
/**
18
18
* Check that meta data has been updated
19
19
*/
20
- if ( name . includes ( " addon-kit" ) || displayName . includes ( " Addon Kit" ) ) {
21
- console . error (
22
- boxen (
23
- dedent `
24
- ${ chalk . red . bold ( " Missing metadata" ) }
20
+ if ( name . includes ( ' addon-kit' ) || displayName . includes ( ' Addon Kit' ) ) {
21
+ console . error (
22
+ boxen (
23
+ dedent `
24
+ ${ chalk . red . bold ( ' Missing metadata' ) }
25
25
26
26
${ chalk . red ( dedent `Your package name and/or displayName includes default values from the Addon Kit.
27
27
The addon gallery filters out all such addons.
28
28
29
29
Please configure appropriate metadata before publishing your addon. For more info, see:
30
30
https://storybook.js.org/docs/react/addons/addon-catalog#addon-metadata` ) } `,
31
- { padding : 1 , borderColor : " red" }
32
- )
33
- ) ;
31
+ { padding : 1 , borderColor : ' red' } ,
32
+ ) ,
33
+ ) ;
34
34
35
- exitCode = 1 ;
35
+ exitCode = 1 ;
36
36
}
37
37
38
38
/**
39
39
* Check that README has been updated
40
40
*/
41
41
const readmeTestStrings =
42
- " # Storybook Addon Kit|Click the \\*\\*Use this template\\*\\* button to get started.|https://user-images.githubusercontent.com/42671/106809879-35b32000-663a-11eb-9cdc-89f178b5273f.gif" ;
42
+ ' # Storybook Addon Kit|Click the \\*\\*Use this template\\*\\* button to get started.|https://user-images.githubusercontent.com/42671/106809879-35b32000-663a-11eb-9cdc-89f178b5273f.gif' ;
43
43
44
44
if ( ( await $ `cat README.md | grep -E ${ readmeTestStrings } ` . exitCode ) == 0 ) {
45
- console . error (
46
- boxen (
47
- dedent `
48
- ${ chalk . red . bold ( " README not updated" ) }
45
+ console . error (
46
+ boxen (
47
+ dedent `
48
+ ${ chalk . red . bold ( ' README not updated' ) }
49
49
50
50
${ chalk . red ( dedent `You are using the default README.md file that comes with the addon kit.
51
51
Please update it to provide info on what your addon does and how to use it.` ) }
52
52
` ,
53
- { padding : 1 , borderColor : " red" }
54
- )
55
- ) ;
53
+ { padding : 1 , borderColor : ' red' } ,
54
+ ) ,
55
+ ) ;
56
56
57
- exitCode = 1 ;
57
+ exitCode = 1 ;
58
58
}
59
59
60
60
/**
@@ -63,24 +63,23 @@ if ((await $`cat README.md | grep -E ${readmeTestStrings}`.exitCode) == 0) {
63
63
const peerDependencies = Object . keys ( packageJson . peerDependencies || { } ) ;
64
64
const globalPackages = [ ...globalManagerPackages , ...globalPreviewPackages ] ;
65
65
peerDependencies . forEach ( ( dependency ) => {
66
- if ( globalPackages . includes ( dependency ) ) {
67
- console . error (
68
- boxen (
69
- dedent `
70
- ${ chalk . red . bold ( " Unnecessary peer dependency" ) }
66
+ if ( globalPackages . includes ( dependency ) ) {
67
+ console . error (
68
+ boxen (
69
+ dedent `
70
+ ${ chalk . red . bold ( ' Unnecessary peer dependency' ) }
71
71
72
72
${ chalk . red ( dedent `You have a peer dependency on ${ chalk . bold ( dependency ) } which is most likely unnecessary
73
73
as that is provided by Storybook directly.
74
74
Check the "bundling" section in README.md for more information.
75
75
If you are absolutely sure you are doing it correct, you should remove this check from scripts/prepublish-checks.js.` ) }
76
76
` ,
77
- { padding : 1 , borderColor : "red" }
78
- )
79
- ) ;
80
-
81
- exitCode = 1 ;
82
-
83
- }
84
- } )
77
+ { padding : 1 , borderColor : 'red' } ,
78
+ ) ,
79
+ ) ;
80
+
81
+ exitCode = 1 ;
82
+ }
83
+ } ) ;
85
84
86
85
process . exit ( exitCode ) ;
0 commit comments