@storybook/codemod 11.0.0-alpha.5 → 11.0.0-alpha.7
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.
- package/dist/_node-chunks/{chunk-TQ5P2KTN.js → chunk-I4FB73AT.js} +6 -6
- package/dist/index.js +6 -6
- package/dist/transforms/csf-2-to-3.js +22 -9
- package/dist/transforms/find-implicit-spies.js +6 -6
- package/dist/transforms/upgrade-deprecated-types.js +7 -7
- package/dist/transforms/upgrade-hierarchy-separators.js +6 -6
- package/package.json +2 -2
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_ppo5qkb13mm from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_ppo5qkb13mm from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_ppo5qkb13mm from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_ppo5qkb13mm.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_ppo5qkb13mm.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_ppo5qkb13mm.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_ppo5qkb13mm from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_ppo5qkb13mm from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_ppo5qkb13mm from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_ppo5qkb13mm.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_ppo5qkb13mm.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_ppo5qkb13mm.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_ppo5qkb13mm from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_ppo5qkb13mm from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_ppo5qkb13mm from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_ppo5qkb13mm.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_ppo5qkb13mm.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_ppo5qkb13mm.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
11
|
// ------------------------------------------------------------
|
|
12
12
|
import {
|
|
13
13
|
upgradeDeprecatedTypes
|
|
14
|
-
} from "../_node-chunks/chunk-
|
|
14
|
+
} from "../_node-chunks/chunk-I4FB73AT.js";
|
|
15
15
|
|
|
16
16
|
// src/transforms/csf-2-to-3.ts
|
|
17
17
|
import { core as babel, types as t } from "storybook/internal/babel";
|
|
@@ -19,7 +19,20 @@ import { loadCsf, printCsf } from "storybook/internal/csf-tools";
|
|
|
19
19
|
import { logger } from "storybook/internal/node-logger";
|
|
20
20
|
import prettier from "prettier";
|
|
21
21
|
import invariant from "tiny-invariant";
|
|
22
|
-
var { isIdentifier, isTSTypeAnnotation, isTSTypeReference } = t, renameAnnotation = (annotation) => annotation === "storyName" ? "name" : annotation,
|
|
22
|
+
var { isIdentifier, isTSTypeAnnotation, isTSTypeReference } = t, renameAnnotation = (annotation) => annotation === "storyName" ? "name" : annotation, annotationProperties = (annotations) => {
|
|
23
|
+
let fields = /* @__PURE__ */ new Map();
|
|
24
|
+
for (let [annotation, value] of Object.entries(annotations)) {
|
|
25
|
+
if (annotation === "story" && t.isObjectExpression(value)) {
|
|
26
|
+
for (let prop of value.properties)
|
|
27
|
+
t.isObjectProperty(prop) && t.isIdentifier(prop.key) && fields.set(prop.key.name, prop.value);
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
fields.set(annotation, value);
|
|
31
|
+
}
|
|
32
|
+
return [...fields].map(
|
|
33
|
+
([annotation, value]) => t.objectProperty(t.identifier(renameAnnotation(annotation)), value)
|
|
34
|
+
);
|
|
35
|
+
}, getTemplateBindVariable = (init) => t.isCallExpression(init) && t.isMemberExpression(init.callee) && t.isIdentifier(init.callee.object) && t.isIdentifier(init.callee.property) && init.callee.property.name === "bind" && (init.arguments.length === 0 || init.arguments.length === 1 && t.isObjectExpression(init.arguments[0]) && init.arguments[0].properties.length === 0) ? init.callee.object.name : null, isStoryAnnotation = (stmt, objectExports) => t.isExpressionStatement(stmt) && t.isAssignmentExpression(stmt.expression) && t.isMemberExpression(stmt.expression.left) && t.isIdentifier(stmt.expression.left.object) && objectExports[stmt.expression.left.object.name], getNewExport = (stmt, objectExports) => {
|
|
23
36
|
if (t.isExportNamedDeclaration(stmt) && t.isVariableDeclaration(stmt.declaration) && stmt.declaration.declarations.length === 1) {
|
|
24
37
|
let decl = stmt.declaration.declarations[0];
|
|
25
38
|
if (t.isVariableDeclarator(decl) && t.isIdentifier(decl.id))
|
|
@@ -62,7 +75,7 @@ async function transform(info, api, options) {
|
|
|
62
75
|
{ code: info.source, ast: csf._ast }
|
|
63
76
|
), importHelper = new StorybookImportHelper(file, info), objectExports = {};
|
|
64
77
|
Object.entries(csf._storyExports).forEach(([key, decl]) => {
|
|
65
|
-
let annotations =
|
|
78
|
+
let annotations = annotationProperties(csf._storyAnnotations[key]);
|
|
66
79
|
if (t.isVariableDeclarator(decl)) {
|
|
67
80
|
let { init, id } = decl;
|
|
68
81
|
invariant(init, "Inital value should be declared");
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_ppo5qkb13mm from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_ppo5qkb13mm from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_ppo5qkb13mm from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_ppo5qkb13mm.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_ppo5qkb13mm.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_ppo5qkb13mm.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_ppo5qkb13mm from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_ppo5qkb13mm from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_ppo5qkb13mm from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_ppo5qkb13mm.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_ppo5qkb13mm.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_ppo5qkb13mm.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
parser,
|
|
14
14
|
transform,
|
|
15
15
|
upgradeDeprecatedTypes
|
|
16
|
-
} from "../_node-chunks/chunk-
|
|
16
|
+
} from "../_node-chunks/chunk-I4FB73AT.js";
|
|
17
17
|
export {
|
|
18
18
|
transform as default,
|
|
19
19
|
parser,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_ppo5qkb13mm from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_ppo5qkb13mm from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_ppo5qkb13mm from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_ppo5qkb13mm.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_ppo5qkb13mm.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_ppo5qkb13mm.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/codemod",
|
|
3
|
-
"version": "11.0.0-alpha.
|
|
3
|
+
"version": "11.0.0-alpha.7",
|
|
4
4
|
"description": "A collection of codemod scripts written with JSCodeshift",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook"
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"es-toolkit": "^1.43.0",
|
|
47
47
|
"jscodeshift": "^17.4.0",
|
|
48
48
|
"prettier": "^3.7.1",
|
|
49
|
-
"storybook": "11.0.0-alpha.
|
|
49
|
+
"storybook": "11.0.0-alpha.7",
|
|
50
50
|
"tiny-invariant": "^1.3.1",
|
|
51
51
|
"tinyglobby": "^0.2.13"
|
|
52
52
|
},
|