@storybook/codemod 10.2.2 → 10.2.4
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-BLRWKP4I.js → chunk-PBNK2RP2.js} +6 -6
- package/dist/index.js +61 -12
- package/dist/transforms/csf-2-to-3.js +7 -7
- 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_75qurk433c from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_75qurk433c from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_75qurk433c from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_75qurk433c.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_75qurk433c.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_75qurk433c.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_75qurk433c from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_75qurk433c from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_75qurk433c from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_75qurk433c.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_75qurk433c.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_75qurk433c.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
@@ -13,9 +13,58 @@ var require = CJS_COMPAT_NODE_MODULE_v8ximstttxp.createRequire(import.meta.url);
|
|
|
13
13
|
// src/index.ts
|
|
14
14
|
import { readdirSync } from "node:fs";
|
|
15
15
|
import { rename as renameAsync } from "node:fs/promises";
|
|
16
|
-
import { extname, join } from "node:path";
|
|
16
|
+
import { extname as extname2, join as join2 } from "node:path";
|
|
17
17
|
import { resolvePackageDir } from "storybook/internal/common";
|
|
18
18
|
import { sync as spawnSync } from "cross-spawn";
|
|
19
|
+
|
|
20
|
+
// ../../../node_modules/pathe/dist/shared/pathe.ff20891b.mjs
|
|
21
|
+
var _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
22
|
+
function normalizeWindowsPath(input = "") {
|
|
23
|
+
return input && input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
|
|
24
|
+
}
|
|
25
|
+
var _UNC_REGEX = /^[/\\]{2}/, _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/, _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
|
|
26
|
+
var normalize = function(path2) {
|
|
27
|
+
if (path2.length === 0)
|
|
28
|
+
return ".";
|
|
29
|
+
path2 = normalizeWindowsPath(path2);
|
|
30
|
+
let isUNCPath = path2.match(_UNC_REGEX), isPathAbsolute = isAbsolute(path2), trailingSeparator = path2[path2.length - 1] === "/";
|
|
31
|
+
return path2 = normalizeString(path2, !isPathAbsolute), path2.length === 0 ? isPathAbsolute ? "/" : trailingSeparator ? "./" : "." : (trailingSeparator && (path2 += "/"), _DRIVE_LETTER_RE.test(path2) && (path2 += "/"), isUNCPath ? isPathAbsolute ? `//${path2}` : `//./${path2}` : isPathAbsolute && !isAbsolute(path2) ? `/${path2}` : path2);
|
|
32
|
+
};
|
|
33
|
+
function normalizeString(path2, allowAboveRoot) {
|
|
34
|
+
let res = "", lastSegmentLength = 0, lastSlash = -1, dots = 0, char = null;
|
|
35
|
+
for (let index = 0; index <= path2.length; ++index) {
|
|
36
|
+
if (index < path2.length)
|
|
37
|
+
char = path2[index];
|
|
38
|
+
else {
|
|
39
|
+
if (char === "/")
|
|
40
|
+
break;
|
|
41
|
+
char = "/";
|
|
42
|
+
}
|
|
43
|
+
if (char === "/") {
|
|
44
|
+
if (!(lastSlash === index - 1 || dots === 1)) if (dots === 2) {
|
|
45
|
+
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
|
46
|
+
if (res.length > 2) {
|
|
47
|
+
let lastSlashIndex = res.lastIndexOf("/");
|
|
48
|
+
lastSlashIndex === -1 ? (res = "", lastSegmentLength = 0) : (res = res.slice(0, lastSlashIndex), lastSegmentLength = res.length - 1 - res.lastIndexOf("/")), lastSlash = index, dots = 0;
|
|
49
|
+
continue;
|
|
50
|
+
} else if (res.length > 0) {
|
|
51
|
+
res = "", lastSegmentLength = 0, lastSlash = index, dots = 0;
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
allowAboveRoot && (res += res.length > 0 ? "/.." : "..", lastSegmentLength = 2);
|
|
56
|
+
} else
|
|
57
|
+
res.length > 0 ? res += `/${path2.slice(lastSlash + 1, index)}` : res = path2.slice(lastSlash + 1, index), lastSegmentLength = index - lastSlash - 1;
|
|
58
|
+
lastSlash = index, dots = 0;
|
|
59
|
+
} else char === "." && dots !== -1 ? ++dots : dots = -1;
|
|
60
|
+
}
|
|
61
|
+
return res;
|
|
62
|
+
}
|
|
63
|
+
var isAbsolute = function(p) {
|
|
64
|
+
return _IS_ABSOLUTE_RE.test(p);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
// src/index.ts
|
|
19
68
|
import { glob as tinyglobby } from "tinyglobby";
|
|
20
69
|
|
|
21
70
|
// src/lib/utils.ts
|
|
@@ -31,7 +80,7 @@ function jscodeshiftToPrettierParser(parser) {
|
|
|
31
80
|
}
|
|
32
81
|
|
|
33
82
|
// src/index.ts
|
|
34
|
-
var TRANSFORM_DIR =
|
|
83
|
+
var TRANSFORM_DIR = join2(resolvePackageDir("@storybook/codemod"), "dist", "transforms");
|
|
35
84
|
function listCodemods() {
|
|
36
85
|
return readdirSync(TRANSFORM_DIR).filter((fname) => fname.endsWith(".js")).map((fname) => fname.slice(0, -3));
|
|
37
86
|
}
|
|
@@ -53,10 +102,10 @@ async function runCodemod(codemod, {
|
|
|
53
102
|
throw new Error(`Codemod rename: expected format "from:to", got "${rename}"`);
|
|
54
103
|
let inferredParser = parser;
|
|
55
104
|
if (!parser) {
|
|
56
|
-
let extension =
|
|
105
|
+
let extension = extname2(glob).slice(1);
|
|
57
106
|
jscodeshiftToPrettierParser(extension) !== "babel" && (inferredParser = extension);
|
|
58
107
|
}
|
|
59
|
-
let files = await tinyglobby([glob, "!**/node_modules", "!**/dist"]), extensions = new Set(files.map((file) =>
|
|
108
|
+
let files = await tinyglobby([normalize(glob), "!**/node_modules", "!**/dist"]), extensions = new Set(files.map((file) => extname2(file).slice(1))), commaSeparatedExtensions = Array.from(extensions).join(",");
|
|
60
109
|
if (logger.step(`Applying ${codemod}: ${files.length} files`), files.length === 0) {
|
|
61
110
|
logger.step(`No matching files for glob: ${glob}`);
|
|
62
111
|
return;
|
|
@@ -65,7 +114,7 @@ async function runCodemod(codemod, {
|
|
|
65
114
|
let parserArgs = inferredParser ? ["--parser", inferredParser] : [], result = spawnSync(
|
|
66
115
|
"node",
|
|
67
116
|
[
|
|
68
|
-
|
|
117
|
+
join2(resolvePackageDir("jscodeshift"), "bin", "jscodeshift"),
|
|
69
118
|
// this makes sure codeshift doesn't transform our own source code with babel
|
|
70
119
|
// which is faster, and also makes sure the user won't see babel messages such as:
|
|
71
120
|
// [BABEL] Note: The code generator has deoptimised the styling of repo/node_modules/prettier/index.js as it exceeds the max of 500KB.
|
|
@@ -75,7 +124,7 @@ async function runCodemod(codemod, {
|
|
|
75
124
|
"-t",
|
|
76
125
|
`${TRANSFORM_DIR}/${codemod}.js`,
|
|
77
126
|
...parserArgs,
|
|
78
|
-
...files
|
|
127
|
+
...files
|
|
79
128
|
],
|
|
80
129
|
{
|
|
81
130
|
stdio: "inherit"
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_75qurk433c from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_75qurk433c from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_75qurk433c from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_75qurk433c.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_75qurk433c.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_75qurk433c.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-PBNK2RP2.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";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_75qurk433c from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_75qurk433c from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_75qurk433c from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_75qurk433c.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_75qurk433c.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_75qurk433c.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_75qurk433c from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_75qurk433c from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_75qurk433c from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_75qurk433c.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_75qurk433c.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_75qurk433c.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-PBNK2RP2.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_75qurk433c from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_75qurk433c from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_75qurk433c from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_75qurk433c.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_75qurk433c.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_75qurk433c.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": "10.2.
|
|
3
|
+
"version": "10.2.4",
|
|
4
4
|
"description": "A collection of codemod scripts written with JSCodeshift",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook"
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"es-toolkit": "^1.43.0",
|
|
46
46
|
"jscodeshift": "^0.15.1",
|
|
47
47
|
"prettier": "^3.7.1",
|
|
48
|
-
"storybook": "10.2.
|
|
48
|
+
"storybook": "10.2.4",
|
|
49
49
|
"tiny-invariant": "^1.3.1",
|
|
50
50
|
"tinyglobby": "^0.2.13"
|
|
51
51
|
},
|