@storybook/codemod 6.4.0-rc.7 → 6.4.1

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
- var template = getTemplateBindVariable(init);
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
- if (!t.isArrowFunctionExpression(init) && !template || isSimpleCSFStory(init, annotations)) {
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
- var typeAnnotation = id.typeAnnotation;
121
+ var storyFn = template && csf._templates[template];
122
+ if (!storyFn) storyFn = init;
123
+ var keyId = t.identifier(key); // @ts-ignore
124
124
 
125
- if (typeAnnotation) {
126
- keyId.typeAnnotation = typeAnnotation;
127
- }
125
+ var typeAnnotation = id.typeAnnotation;
126
+
127
+ if (typeAnnotation) {
128
+ keyId.typeAnnotation = typeAnnotation;
129
+ }
128
130
 
129
- var renderAnnotation = isReactGlobalRenderFn(csf, storyFn) ? [] : [t.objectProperty(t.identifier('render'), storyFn)];
130
- objectExports[key] = t.exportNamedDeclaration(t.variableDeclaration('const', [t.variableDeclarator(keyId, t.objectExpression([...renderAnnotation, ...annotations]))]));
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
- var template = getTemplateBindVariable(init);
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
- if (!t.isArrowFunctionExpression(init) && !template || isSimpleCSFStory(init, annotations)) {
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
- var typeAnnotation = id.typeAnnotation;
105
+ var storyFn = template && csf._templates[template];
106
+ if (!storyFn) storyFn = init;
107
+ var keyId = t.identifier(key); // @ts-ignore
108
108
 
109
- if (typeAnnotation) {
110
- keyId.typeAnnotation = typeAnnotation;
111
- }
109
+ var typeAnnotation = id.typeAnnotation;
110
+
111
+ if (typeAnnotation) {
112
+ keyId.typeAnnotation = typeAnnotation;
113
+ }
112
114
 
113
- var renderAnnotation = isReactGlobalRenderFn(csf, storyFn) ? [] : [t.objectProperty(t.identifier('render'), storyFn)];
114
- objectExports[key] = t.exportNamedDeclaration(t.variableDeclaration('const', [t.variableDeclarator(keyId, t.objectExpression([...renderAnnotation, ...annotations]))]));
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
- var template = getTemplateBindVariable(init);
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
- if (!t.isArrowFunctionExpression(init) && !template || isSimpleCSFStory(init, annotations)) {
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
- var typeAnnotation = id.typeAnnotation;
105
+ var storyFn = template && csf._templates[template];
106
+ if (!storyFn) storyFn = init;
107
+ var keyId = t.identifier(key); // @ts-ignore
108
108
 
109
- if (typeAnnotation) {
110
- keyId.typeAnnotation = typeAnnotation;
111
- }
109
+ var typeAnnotation = id.typeAnnotation;
110
+
111
+ if (typeAnnotation) {
112
+ keyId.typeAnnotation = typeAnnotation;
113
+ }
112
114
 
113
- var renderAnnotation = isReactGlobalRenderFn(csf, storyFn) ? [] : [t.objectProperty(t.identifier('render'), storyFn)];
114
- objectExports[key] = t.exportNamedDeclaration(t.variableDeclaration('const', [t.variableDeclarator(keyId, t.objectExpression([...renderAnnotation, ...annotations]))]));
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.0-rc.7",
3
+ "version": "6.4.1",
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.0-rc.7",
48
- "@storybook/node-logger": "6.4.0-rc.7",
47
+ "@storybook/csf-tools": "6.4.1",
48
+ "@storybook/node-logger": "6.4.1",
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": "7162286c0d8d122c7206265fab41c4c191c86d40",
65
+ "gitHead": "bb20e8fef506e05fb9c67dd55b0405b4b1043698",
66
66
  "sbmodern": "dist/modern/index.js"
67
67
  }