@storybook/codemod 7.0.0-alpha.3 → 7.0.0-alpha.33

Sign up to get free protection for your applications and to get access to all the features.
package/dist/cjs/index.js CHANGED
@@ -1,7 +1,5 @@
1
1
  "use strict";
2
2
 
3
- require("core-js/modules/es.symbol.description.js");
4
-
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
@@ -26,8 +24,6 @@ Object.defineProperty(exports, "updateOrganisationName", {
26
24
  }
27
25
  });
28
26
 
29
- require("core-js/modules/es.promise.js");
30
-
31
27
  var _fs = _interopRequireDefault(require("fs"));
32
28
 
33
29
  var _path = _interopRequireDefault(require("path"));
@@ -122,7 +118,8 @@ async function runCodemod(codemod, {
122
118
  if (!dryRun) {
123
119
  var parserArgs = inferredParser ? ['--parser', inferredParser] : [];
124
120
  (0, _crossSpawn.sync)('npx', ['jscodeshift', '-t', `${TRANSFORM_DIR}/${codemod}.js`, ...parserArgs, ...files], {
125
- stdio: 'inherit'
121
+ stdio: 'inherit',
122
+ shell: true
126
123
  });
127
124
  }
128
125
 
@@ -36,5 +36,10 @@ function jscodeshiftToPrettierParser(parser) {
36
36
  ts: 'typescript',
37
37
  tsx: 'typescript'
38
38
  };
39
+
40
+ if (!parser) {
41
+ return 'babel';
42
+ }
43
+
39
44
  return parserMap[parser] || 'babel';
40
45
  }
@@ -52,7 +52,7 @@ function transformer(file, api) {
52
52
  return j.callExpression(j.memberExpression(node, j.identifier('addParameters')), [j.objectExpression([j.property('init', j.identifier('component'), j.identifier(leafName))])]);
53
53
  }
54
54
 
55
- var storiesOfCalls = root.find(j.CallExpression).filter(function (call) {
55
+ root.find(j.CallExpression).filter(function (call) {
56
56
  return call.node.callee.name === 'storiesOf';
57
57
  }).filter(function (call) {
58
58
  return call.node.arguments.length > 0 && call.node.arguments[0].type === 'Literal';
@@ -123,8 +123,12 @@ function transform({
123
123
 
124
124
 
125
125
  var storyFn = template && csf._templates[template];
126
- if (!storyFn) storyFn = init;
127
- var keyId = t.identifier(key); // @ts-ignore
126
+
127
+ if (!storyFn) {
128
+ storyFn = init;
129
+ }
130
+
131
+ var keyId = t.identifier(key); // @ts-expect-error (Converted from ts-ignore)
128
132
 
129
133
  var typeAnnotation = id.typeAnnotation;
130
134
 
@@ -30,7 +30,7 @@ function parseIncludeExclude(prop) {
30
30
  code = _prettyPrint2.code; // eslint-disable-next-line no-eval
31
31
 
32
32
 
33
- return eval(code);
33
+ return (0, eval)(code);
34
34
  }
35
35
  /**
36
36
  * Convert a component's module story file into an MDX file
@@ -1,7 +1,5 @@
1
1
  "use strict";
2
2
 
3
- require("core-js/modules/es.symbol.description.js");
4
-
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
@@ -295,6 +295,6 @@ function transformer(file, api, options) {
295
295
  singleQuote: true
296
296
  };
297
297
  return _prettier.default.format(source, _objectSpread(_objectSpread({}, prettierConfig), {}, {
298
- parser: (0, _utils.jscodeshiftToPrettierParser)(options.parser) || 'babel'
298
+ parser: (0, _utils.jscodeshiftToPrettierParser)(options.parser)
299
299
  }));
300
300
  }
package/dist/esm/index.js CHANGED
@@ -10,9 +10,6 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
10
10
 
11
11
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
12
12
 
13
- import "core-js/modules/es.promise.js";
14
- import "core-js/modules/es.symbol.description.js";
15
-
16
13
  /* eslint import/prefer-default-export: "off" */
17
14
  import fs from 'fs';
18
15
  import path from 'path';
@@ -79,7 +76,8 @@ export async function runCodemod(codemod, {
79
76
  if (!dryRun) {
80
77
  var parserArgs = inferredParser ? ['--parser', inferredParser] : [];
81
78
  spawnSync('npx', ['jscodeshift', '-t', `${TRANSFORM_DIR}/${codemod}.js`, ...parserArgs, ...files], {
82
- stdio: 'inherit'
79
+ stdio: 'inherit',
80
+ shell: true
83
81
  });
84
82
  }
85
83
 
@@ -21,5 +21,10 @@ export function jscodeshiftToPrettierParser(parser) {
21
21
  ts: 'typescript',
22
22
  tsx: 'typescript'
23
23
  };
24
+
25
+ if (!parser) {
26
+ return 'babel';
27
+ }
28
+
24
29
  return parserMap[parser] || 'babel';
25
30
  }
@@ -45,7 +45,7 @@ export default function transformer(file, api) {
45
45
  return j.callExpression(j.memberExpression(node, j.identifier('addParameters')), [j.objectExpression([j.property('init', j.identifier('component'), j.identifier(leafName))])]);
46
46
  }
47
47
 
48
- var storiesOfCalls = root.find(j.CallExpression).filter(function (call) {
48
+ root.find(j.CallExpression).filter(function (call) {
49
49
  return call.node.callee.name === 'storiesOf';
50
50
  }).filter(function (call) {
51
51
  return call.node.arguments.length > 0 && call.node.arguments[0].type === 'Literal';
@@ -107,8 +107,12 @@ function transform({
107
107
 
108
108
 
109
109
  var storyFn = template && csf._templates[template];
110
- if (!storyFn) storyFn = init;
111
- var keyId = t.identifier(key); // @ts-ignore
110
+
111
+ if (!storyFn) {
112
+ storyFn = init;
113
+ }
114
+
115
+ var keyId = t.identifier(key); // @ts-expect-error (Converted from ts-ignore)
112
116
 
113
117
  var typeAnnotation = id.typeAnnotation;
114
118
 
@@ -22,7 +22,7 @@ function parseIncludeExclude(prop) {
22
22
  code = _prettyPrint2.code; // eslint-disable-next-line no-eval
23
23
 
24
24
 
25
- return eval(code);
25
+ return (0, eval)(code);
26
26
  }
27
27
  /**
28
28
  * Convert a component's module story file into an MDX file
@@ -1,5 +1,3 @@
1
- import "core-js/modules/es.symbol.description.js";
2
-
3
1
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
4
2
 
5
3
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -282,6 +282,6 @@ export default function transformer(file, api, options) {
282
282
  singleQuote: true
283
283
  };
284
284
  return prettier.format(source, _objectSpread(_objectSpread({}, prettierConfig), {}, {
285
- parser: jscodeshiftToPrettierParser(options.parser) || 'babel'
285
+ parser: jscodeshiftToPrettierParser(options.parser)
286
286
  }));
287
287
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/codemod",
3
- "version": "7.0.0-alpha.3",
3
+ "version": "7.0.0-alpha.33",
4
4
  "description": "A collection of codemod scripts written with JSCodeshift",
5
5
  "keywords": [
6
6
  "storybook"
@@ -23,13 +23,6 @@
23
23
  "main": "dist/cjs/index.js",
24
24
  "module": "dist/esm/index.js",
25
25
  "jsnext:main": "src/index.js",
26
- "typesVersions": {
27
- "<3.8": {
28
- "*": [
29
- "ts3.4/*"
30
- ]
31
- }
32
- },
33
26
  "files": [
34
27
  "dist/**/*",
35
28
  "README.md",
@@ -38,29 +31,29 @@
38
31
  "!__testfixtures__"
39
32
  ],
40
33
  "scripts": {
41
- "prepare": "node ../../scripts/prepare.js"
34
+ "check": "tsc --noEmit",
35
+ "prep": "node ../../../scripts/prepare.js"
42
36
  },
43
37
  "dependencies": {
44
38
  "@babel/types": "^7.12.11",
45
39
  "@mdx-js/mdx": "^1.6.22",
46
- "@storybook/csf": "0.0.2--canary.4566f4d.1",
47
- "@storybook/csf-tools": "7.0.0-alpha.3",
48
- "@storybook/node-logger": "7.0.0-alpha.3",
49
- "core-js": "^3.8.2",
40
+ "@storybook/csf": "0.0.2--canary.0899bb7.0",
41
+ "@storybook/csf-tools": "7.0.0-alpha.33",
42
+ "@storybook/node-logger": "7.0.0-alpha.33",
50
43
  "cross-spawn": "^7.0.3",
51
44
  "globby": "^11.0.2",
52
45
  "jscodeshift": "^0.13.1",
53
46
  "lodash": "^4.17.21",
54
47
  "prettier": ">=2.2.1 <=2.3.0",
55
- "recast": "^0.19.0",
56
- "regenerator-runtime": "^0.13.7"
48
+ "recast": "^0.19.0"
57
49
  },
58
50
  "devDependencies": {
59
51
  "jest": "^26.6.3",
60
- "jest-specific-snapshot": "^4.0.0"
52
+ "jest-specific-snapshot": "^4.0.0",
53
+ "typescript": "~4.6.3"
61
54
  },
62
55
  "publishConfig": {
63
56
  "access": "public"
64
57
  },
65
- "gitHead": "629b056190993bcee6445471b8cb27208eb401a9"
58
+ "gitHead": "5da5b0fabd04cc5cd5771e8242a960f05d03234a"
66
59
  }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2017 Kadira Inc. <hello@kadira.io>
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.