@storybook/codemod 6.4.0-rc.9 → 6.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -103,31 +103,34 @@ function transform({
|
|
103
103
|
var annotations = Object.entries(csf._storyAnnotations[key]).map(function ([annotation, val]) {
|
104
104
|
return t.objectProperty(t.identifier(_rename(annotation)), val);
|
105
105
|
});
|
106
|
-
var init = decl.init,
|
107
|
-
id = decl.id; // only replace arrow function expressions && template
|
108
|
-
// ignore no-arg stories without annotations
|
109
106
|
|
110
|
-
|
107
|
+
if (t.isVariableDeclarator(decl)) {
|
108
|
+
var init = decl.init,
|
109
|
+
id = decl.id; // only replace arrow function expressions && template
|
110
|
+
// ignore no-arg stories without annotations
|
111
111
|
|
112
|
-
|
113
|
-
return;
|
114
|
-
} // Remove the render function when we can hoist the template
|
115
|
-
// const Template = (args) => <Cat {...args} />;
|
116
|
-
// export const A = Template.bind({});
|
112
|
+
var template = getTemplateBindVariable(init);
|
117
113
|
|
114
|
+
if (!t.isArrowFunctionExpression(init) && !template || isSimpleCSFStory(init, annotations)) {
|
115
|
+
return;
|
116
|
+
} // Remove the render function when we can hoist the template
|
117
|
+
// const Template = (args) => <Cat {...args} />;
|
118
|
+
// export const A = Template.bind({});
|
118
119
|
|
119
|
-
var storyFn = template && csf._templates[template];
|
120
|
-
if (!storyFn) storyFn = init;
|
121
|
-
var keyId = t.identifier(key); // @ts-ignore
|
122
120
|
|
123
|
-
|
121
|
+
var storyFn = template && csf._templates[template];
|
122
|
+
if (!storyFn) storyFn = init;
|
123
|
+
var keyId = t.identifier(key); // @ts-ignore
|
124
124
|
|
125
|
-
|
126
|
-
|
127
|
-
|
125
|
+
var typeAnnotation = id.typeAnnotation;
|
126
|
+
|
127
|
+
if (typeAnnotation) {
|
128
|
+
keyId.typeAnnotation = typeAnnotation;
|
129
|
+
}
|
128
130
|
|
129
|
-
|
130
|
-
|
131
|
+
var renderAnnotation = isReactGlobalRenderFn(csf, storyFn) ? [] : [t.objectProperty(t.identifier('render'), storyFn)];
|
132
|
+
objectExports[key] = t.exportNamedDeclaration(t.variableDeclaration('const', [t.variableDeclarator(keyId, t.objectExpression([...renderAnnotation, ...annotations]))]));
|
133
|
+
}
|
131
134
|
});
|
132
135
|
|
133
136
|
var updatedBody = csf._ast.program.body.reduce(function (acc, stmt) {
|
@@ -87,31 +87,34 @@ function transform({
|
|
87
87
|
var annotations = Object.entries(csf._storyAnnotations[key]).map(function ([annotation, val]) {
|
88
88
|
return t.objectProperty(t.identifier(_rename(annotation)), val);
|
89
89
|
});
|
90
|
-
var init = decl.init,
|
91
|
-
id = decl.id; // only replace arrow function expressions && template
|
92
|
-
// ignore no-arg stories without annotations
|
93
90
|
|
94
|
-
|
91
|
+
if (t.isVariableDeclarator(decl)) {
|
92
|
+
var init = decl.init,
|
93
|
+
id = decl.id; // only replace arrow function expressions && template
|
94
|
+
// ignore no-arg stories without annotations
|
95
95
|
|
96
|
-
|
97
|
-
return;
|
98
|
-
} // Remove the render function when we can hoist the template
|
99
|
-
// const Template = (args) => <Cat {...args} />;
|
100
|
-
// export const A = Template.bind({});
|
96
|
+
var template = getTemplateBindVariable(init);
|
101
97
|
|
98
|
+
if (!t.isArrowFunctionExpression(init) && !template || isSimpleCSFStory(init, annotations)) {
|
99
|
+
return;
|
100
|
+
} // Remove the render function when we can hoist the template
|
101
|
+
// const Template = (args) => <Cat {...args} />;
|
102
|
+
// export const A = Template.bind({});
|
102
103
|
|
103
|
-
var storyFn = template && csf._templates[template];
|
104
|
-
if (!storyFn) storyFn = init;
|
105
|
-
var keyId = t.identifier(key); // @ts-ignore
|
106
104
|
|
107
|
-
|
105
|
+
var storyFn = template && csf._templates[template];
|
106
|
+
if (!storyFn) storyFn = init;
|
107
|
+
var keyId = t.identifier(key); // @ts-ignore
|
108
108
|
|
109
|
-
|
110
|
-
|
111
|
-
|
109
|
+
var typeAnnotation = id.typeAnnotation;
|
110
|
+
|
111
|
+
if (typeAnnotation) {
|
112
|
+
keyId.typeAnnotation = typeAnnotation;
|
113
|
+
}
|
112
114
|
|
113
|
-
|
114
|
-
|
115
|
+
var renderAnnotation = isReactGlobalRenderFn(csf, storyFn) ? [] : [t.objectProperty(t.identifier('render'), storyFn)];
|
116
|
+
objectExports[key] = t.exportNamedDeclaration(t.variableDeclaration('const', [t.variableDeclarator(keyId, t.objectExpression([...renderAnnotation, ...annotations]))]));
|
117
|
+
}
|
115
118
|
});
|
116
119
|
|
117
120
|
var updatedBody = csf._ast.program.body.reduce(function (acc, stmt) {
|
@@ -87,31 +87,34 @@ function transform({
|
|
87
87
|
var annotations = Object.entries(csf._storyAnnotations[key]).map(function ([annotation, val]) {
|
88
88
|
return t.objectProperty(t.identifier(_rename(annotation)), val);
|
89
89
|
});
|
90
|
-
var init = decl.init,
|
91
|
-
id = decl.id; // only replace arrow function expressions && template
|
92
|
-
// ignore no-arg stories without annotations
|
93
90
|
|
94
|
-
|
91
|
+
if (t.isVariableDeclarator(decl)) {
|
92
|
+
var init = decl.init,
|
93
|
+
id = decl.id; // only replace arrow function expressions && template
|
94
|
+
// ignore no-arg stories without annotations
|
95
95
|
|
96
|
-
|
97
|
-
return;
|
98
|
-
} // Remove the render function when we can hoist the template
|
99
|
-
// const Template = (args) => <Cat {...args} />;
|
100
|
-
// export const A = Template.bind({});
|
96
|
+
var template = getTemplateBindVariable(init);
|
101
97
|
|
98
|
+
if (!t.isArrowFunctionExpression(init) && !template || isSimpleCSFStory(init, annotations)) {
|
99
|
+
return;
|
100
|
+
} // Remove the render function when we can hoist the template
|
101
|
+
// const Template = (args) => <Cat {...args} />;
|
102
|
+
// export const A = Template.bind({});
|
102
103
|
|
103
|
-
var storyFn = template && csf._templates[template];
|
104
|
-
if (!storyFn) storyFn = init;
|
105
|
-
var keyId = t.identifier(key); // @ts-ignore
|
106
104
|
|
107
|
-
|
105
|
+
var storyFn = template && csf._templates[template];
|
106
|
+
if (!storyFn) storyFn = init;
|
107
|
+
var keyId = t.identifier(key); // @ts-ignore
|
108
108
|
|
109
|
-
|
110
|
-
|
111
|
-
|
109
|
+
var typeAnnotation = id.typeAnnotation;
|
110
|
+
|
111
|
+
if (typeAnnotation) {
|
112
|
+
keyId.typeAnnotation = typeAnnotation;
|
113
|
+
}
|
112
114
|
|
113
|
-
|
114
|
-
|
115
|
+
var renderAnnotation = isReactGlobalRenderFn(csf, storyFn) ? [] : [t.objectProperty(t.identifier('render'), storyFn)];
|
116
|
+
objectExports[key] = t.exportNamedDeclaration(t.variableDeclaration('const', [t.variableDeclarator(keyId, t.objectExpression([...renderAnnotation, ...annotations]))]));
|
117
|
+
}
|
115
118
|
});
|
116
119
|
|
117
120
|
var updatedBody = csf._ast.program.body.reduce(function (acc, stmt) {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@storybook/codemod",
|
3
|
-
"version": "6.4.
|
3
|
+
"version": "6.4.3",
|
4
4
|
"description": "A collection of codemod scripts written with JSCodeshift",
|
5
5
|
"keywords": [
|
6
6
|
"storybook"
|
@@ -44,8 +44,8 @@
|
|
44
44
|
"@babel/types": "^7.12.11",
|
45
45
|
"@mdx-js/mdx": "^1.6.22",
|
46
46
|
"@storybook/csf": "0.0.2--canary.87bc651.0",
|
47
|
-
"@storybook/csf-tools": "6.4.
|
48
|
-
"@storybook/node-logger": "6.4.
|
47
|
+
"@storybook/csf-tools": "6.4.3",
|
48
|
+
"@storybook/node-logger": "6.4.3",
|
49
49
|
"core-js": "^3.8.2",
|
50
50
|
"cross-spawn": "^7.0.3",
|
51
51
|
"globby": "^11.0.2",
|
@@ -62,6 +62,6 @@
|
|
62
62
|
"publishConfig": {
|
63
63
|
"access": "public"
|
64
64
|
},
|
65
|
-
"gitHead": "
|
65
|
+
"gitHead": "3e8133aa834b15a7c7021c6e5e090016491b5218",
|
66
66
|
"sbmodern": "dist/modern/index.js"
|
67
67
|
}
|