Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

@storybook/codemod

Package Overview
Dependencies
Maintainers
12
Versions
3038
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@storybook/codemod - npm Package Compare versions

Comparing version
10.2.12
to
10.2.13
+97
dist/_node-chunks/chunk-I25T43II.js
import CJS_COMPAT_NODE_URL_e9k6epg02qk from 'node:url';
import CJS_COMPAT_NODE_PATH_e9k6epg02qk from 'node:path';
import CJS_COMPAT_NODE_MODULE_e9k6epg02qk from "node:module";
var __filename = CJS_COMPAT_NODE_URL_e9k6epg02qk.fileURLToPath(import.meta.url);
var __dirname = CJS_COMPAT_NODE_PATH_e9k6epg02qk.dirname(__filename);
var require = CJS_COMPAT_NODE_MODULE_e9k6epg02qk.createRequire(import.meta.url);
// ------------------------------------------------------------
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
// ------------------------------------------------------------
// src/transforms/upgrade-deprecated-types.ts
import { core as babel, types as t } from "storybook/internal/babel";
import { loadCsf, printCsf } from "storybook/internal/csf-tools";
import { logger } from "storybook/internal/node-logger";
import prettier from "prettier";
var deprecatedTypes = [
"ComponentStory",
"ComponentStoryFn",
"ComponentStoryObj",
"ComponentMeta",
"Story"
];
function migrateType(oldType) {
return oldType === "Story" || oldType === "ComponentStory" ? "StoryFn" : oldType.replace("Component", "");
}
async function transform(info, api, options) {
let csf = loadCsf(info.source, { makeTitle: (title) => title }), fileNode = csf._ast, file = new babel.File(
{ filename: info.path },
{ code: info.source, ast: fileNode }
);
upgradeDeprecatedTypes(file);
let output = printCsf(csf).code;
try {
output = await prettier.format(output, {
...await prettier.resolveConfig(info.path),
filepath: info.path
});
} catch {
logger.log(`Failed applying prettier to ${info.path}.`);
}
return output;
}
var parser = "tsx";
function upgradeDeprecatedTypes(file) {
let importedNamespaces = /* @__PURE__ */ new Set(), typeReferencesToUpdate = /* @__PURE__ */ new Set(), existingImports = [];
file.path.traverse({
ImportDeclaration: (path) => {
existingImports.push(
...path.get("specifiers").map((specifier) => ({
name: specifier.node.local.name,
isAlias: !(specifier.isImportSpecifier() && t.isIdentifier(specifier.node.imported) && specifier.node.local.name === specifier.node.imported.name),
path: specifier
}))
), path.node.source.value.startsWith("@storybook") && path.get("specifiers").forEach((specifier) => {
if (specifier.isImportNamespaceSpecifier() && importedNamespaces.add(specifier.node.local.name), !specifier.isImportSpecifier())
return;
let imported = specifier.get("imported");
if (imported.isIdentifier() && deprecatedTypes.includes(imported.node.name)) {
imported.node.name === specifier.node.local.name && typeReferencesToUpdate.add(specifier.node.local.name);
let newType = migrateType(imported.node.name);
if (!existingImports.some((it) => it.name === newType))
imported.replaceWith(t.identifier(newType)), existingImports.push({ name: newType, isAlias: !1, path: specifier });
else {
let existingImport = existingImports.find((it) => it.name === newType && it.isAlias);
if (existingImport)
throw existingImport.path.buildCodeFrameError(
`This codemod does not support local imports that are called the same as a storybook import.
Rename this local import and try again.`
);
specifier.remove();
}
}
});
}
}), file.path.traverse({
TSTypeReference: (path) => {
let typeName = path.get("typeName");
if (typeName.isIdentifier())
typeReferencesToUpdate.has(typeName.node.name) && typeName.replaceWith(t.identifier(migrateType(typeName.node.name)));
else if (typeName.isTSQualifiedName()) {
let namespace = typeName.get("left");
if (namespace.isIdentifier() && importedNamespaces.has(namespace.node.name)) {
let right = typeName.get("right");
deprecatedTypes.includes(right.node.name) && right.replaceWith(t.identifier(migrateType(right.node.name)));
}
}
}
});
}
export {
transform,
parser,
upgradeDeprecatedTypes
};
+6
-6

@@ -1,8 +0,8 @@

import CJS_COMPAT_NODE_URL_w24dlb3cqpe from 'node:url';
import CJS_COMPAT_NODE_PATH_w24dlb3cqpe from 'node:path';
import CJS_COMPAT_NODE_MODULE_w24dlb3cqpe from "node:module";
import CJS_COMPAT_NODE_URL_e9k6epg02qk from 'node:url';
import CJS_COMPAT_NODE_PATH_e9k6epg02qk from 'node:path';
import CJS_COMPAT_NODE_MODULE_e9k6epg02qk from "node:module";
var __filename = CJS_COMPAT_NODE_URL_w24dlb3cqpe.fileURLToPath(import.meta.url);
var __dirname = CJS_COMPAT_NODE_PATH_w24dlb3cqpe.dirname(__filename);
var require = CJS_COMPAT_NODE_MODULE_w24dlb3cqpe.createRequire(import.meta.url);
var __filename = CJS_COMPAT_NODE_URL_e9k6epg02qk.fileURLToPath(import.meta.url);
var __dirname = CJS_COMPAT_NODE_PATH_e9k6epg02qk.dirname(__filename);
var require = CJS_COMPAT_NODE_MODULE_e9k6epg02qk.createRequire(import.meta.url);

@@ -9,0 +9,0 @@ // ------------------------------------------------------------

@@ -1,8 +0,8 @@

import CJS_COMPAT_NODE_URL_w24dlb3cqpe from 'node:url';
import CJS_COMPAT_NODE_PATH_w24dlb3cqpe from 'node:path';
import CJS_COMPAT_NODE_MODULE_w24dlb3cqpe from "node:module";
import CJS_COMPAT_NODE_URL_e9k6epg02qk from 'node:url';
import CJS_COMPAT_NODE_PATH_e9k6epg02qk from 'node:path';
import CJS_COMPAT_NODE_MODULE_e9k6epg02qk from "node:module";
var __filename = CJS_COMPAT_NODE_URL_w24dlb3cqpe.fileURLToPath(import.meta.url);
var __dirname = CJS_COMPAT_NODE_PATH_w24dlb3cqpe.dirname(__filename);
var require = CJS_COMPAT_NODE_MODULE_w24dlb3cqpe.createRequire(import.meta.url);
var __filename = CJS_COMPAT_NODE_URL_e9k6epg02qk.fileURLToPath(import.meta.url);
var __dirname = CJS_COMPAT_NODE_PATH_e9k6epg02qk.dirname(__filename);
var require = CJS_COMPAT_NODE_MODULE_e9k6epg02qk.createRequire(import.meta.url);

@@ -14,3 +14,3 @@ // ------------------------------------------------------------

upgradeDeprecatedTypes
} from "../_node-chunks/chunk-FJGU5H2I.js";
} from "../_node-chunks/chunk-I25T43II.js";

@@ -17,0 +17,0 @@ // src/transforms/csf-2-to-3.ts

@@ -1,8 +0,8 @@

import CJS_COMPAT_NODE_URL_w24dlb3cqpe from 'node:url';
import CJS_COMPAT_NODE_PATH_w24dlb3cqpe from 'node:path';
import CJS_COMPAT_NODE_MODULE_w24dlb3cqpe from "node:module";
import CJS_COMPAT_NODE_URL_e9k6epg02qk from 'node:url';
import CJS_COMPAT_NODE_PATH_e9k6epg02qk from 'node:path';
import CJS_COMPAT_NODE_MODULE_e9k6epg02qk from "node:module";
var __filename = CJS_COMPAT_NODE_URL_w24dlb3cqpe.fileURLToPath(import.meta.url);
var __dirname = CJS_COMPAT_NODE_PATH_w24dlb3cqpe.dirname(__filename);
var require = CJS_COMPAT_NODE_MODULE_w24dlb3cqpe.createRequire(import.meta.url);
var __filename = CJS_COMPAT_NODE_URL_e9k6epg02qk.fileURLToPath(import.meta.url);
var __dirname = CJS_COMPAT_NODE_PATH_e9k6epg02qk.dirname(__filename);
var require = CJS_COMPAT_NODE_MODULE_e9k6epg02qk.createRequire(import.meta.url);

@@ -9,0 +9,0 @@ // ------------------------------------------------------------

@@ -1,8 +0,8 @@

import CJS_COMPAT_NODE_URL_w24dlb3cqpe from 'node:url';
import CJS_COMPAT_NODE_PATH_w24dlb3cqpe from 'node:path';
import CJS_COMPAT_NODE_MODULE_w24dlb3cqpe from "node:module";
import CJS_COMPAT_NODE_URL_e9k6epg02qk from 'node:url';
import CJS_COMPAT_NODE_PATH_e9k6epg02qk from 'node:path';
import CJS_COMPAT_NODE_MODULE_e9k6epg02qk from "node:module";
var __filename = CJS_COMPAT_NODE_URL_w24dlb3cqpe.fileURLToPath(import.meta.url);
var __dirname = CJS_COMPAT_NODE_PATH_w24dlb3cqpe.dirname(__filename);
var require = CJS_COMPAT_NODE_MODULE_w24dlb3cqpe.createRequire(import.meta.url);
var __filename = CJS_COMPAT_NODE_URL_e9k6epg02qk.fileURLToPath(import.meta.url);
var __dirname = CJS_COMPAT_NODE_PATH_e9k6epg02qk.dirname(__filename);
var require = CJS_COMPAT_NODE_MODULE_e9k6epg02qk.createRequire(import.meta.url);

@@ -16,3 +16,3 @@ // ------------------------------------------------------------

upgradeDeprecatedTypes
} from "../_node-chunks/chunk-FJGU5H2I.js";
} from "../_node-chunks/chunk-I25T43II.js";
export {

@@ -19,0 +19,0 @@ transform as default,

@@ -1,8 +0,8 @@

import CJS_COMPAT_NODE_URL_w24dlb3cqpe from 'node:url';
import CJS_COMPAT_NODE_PATH_w24dlb3cqpe from 'node:path';
import CJS_COMPAT_NODE_MODULE_w24dlb3cqpe from "node:module";
import CJS_COMPAT_NODE_URL_e9k6epg02qk from 'node:url';
import CJS_COMPAT_NODE_PATH_e9k6epg02qk from 'node:path';
import CJS_COMPAT_NODE_MODULE_e9k6epg02qk from "node:module";
var __filename = CJS_COMPAT_NODE_URL_w24dlb3cqpe.fileURLToPath(import.meta.url);
var __dirname = CJS_COMPAT_NODE_PATH_w24dlb3cqpe.dirname(__filename);
var require = CJS_COMPAT_NODE_MODULE_w24dlb3cqpe.createRequire(import.meta.url);
var __filename = CJS_COMPAT_NODE_URL_e9k6epg02qk.fileURLToPath(import.meta.url);
var __dirname = CJS_COMPAT_NODE_PATH_e9k6epg02qk.dirname(__filename);
var require = CJS_COMPAT_NODE_MODULE_e9k6epg02qk.createRequire(import.meta.url);

@@ -9,0 +9,0 @@ // ------------------------------------------------------------

{
"name": "@storybook/codemod",
"version": "10.2.12",
"version": "10.2.13",
"description": "A collection of codemod scripts written with JSCodeshift",

@@ -48,3 +48,3 @@ "keywords": [

"prettier": "^3.7.1",
"storybook": "10.2.12",
"storybook": "10.2.13",
"tiny-invariant": "^1.3.1",

@@ -51,0 +51,0 @@ "tinyglobby": "^0.2.13"

import CJS_COMPAT_NODE_URL_w24dlb3cqpe from 'node:url';
import CJS_COMPAT_NODE_PATH_w24dlb3cqpe from 'node:path';
import CJS_COMPAT_NODE_MODULE_w24dlb3cqpe from "node:module";
var __filename = CJS_COMPAT_NODE_URL_w24dlb3cqpe.fileURLToPath(import.meta.url);
var __dirname = CJS_COMPAT_NODE_PATH_w24dlb3cqpe.dirname(__filename);
var require = CJS_COMPAT_NODE_MODULE_w24dlb3cqpe.createRequire(import.meta.url);
// ------------------------------------------------------------
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
// ------------------------------------------------------------
// src/transforms/upgrade-deprecated-types.ts
import { core as babel, types as t } from "storybook/internal/babel";
import { loadCsf, printCsf } from "storybook/internal/csf-tools";
import { logger } from "storybook/internal/node-logger";
import prettier from "prettier";
var deprecatedTypes = [
"ComponentStory",
"ComponentStoryFn",
"ComponentStoryObj",
"ComponentMeta",
"Story"
];
function migrateType(oldType) {
return oldType === "Story" || oldType === "ComponentStory" ? "StoryFn" : oldType.replace("Component", "");
}
async function transform(info, api, options) {
let csf = loadCsf(info.source, { makeTitle: (title) => title }), fileNode = csf._ast, file = new babel.File(
{ filename: info.path },
{ code: info.source, ast: fileNode }
);
upgradeDeprecatedTypes(file);
let output = printCsf(csf).code;
try {
output = await prettier.format(output, {
...await prettier.resolveConfig(info.path),
filepath: info.path
});
} catch {
logger.log(`Failed applying prettier to ${info.path}.`);
}
return output;
}
var parser = "tsx";
function upgradeDeprecatedTypes(file) {
let importedNamespaces = /* @__PURE__ */ new Set(), typeReferencesToUpdate = /* @__PURE__ */ new Set(), existingImports = [];
file.path.traverse({
ImportDeclaration: (path) => {
existingImports.push(
...path.get("specifiers").map((specifier) => ({
name: specifier.node.local.name,
isAlias: !(specifier.isImportSpecifier() && t.isIdentifier(specifier.node.imported) && specifier.node.local.name === specifier.node.imported.name),
path: specifier
}))
), path.node.source.value.startsWith("@storybook") && path.get("specifiers").forEach((specifier) => {
if (specifier.isImportNamespaceSpecifier() && importedNamespaces.add(specifier.node.local.name), !specifier.isImportSpecifier())
return;
let imported = specifier.get("imported");
if (imported.isIdentifier() && deprecatedTypes.includes(imported.node.name)) {
imported.node.name === specifier.node.local.name && typeReferencesToUpdate.add(specifier.node.local.name);
let newType = migrateType(imported.node.name);
if (!existingImports.some((it) => it.name === newType))
imported.replaceWith(t.identifier(newType)), existingImports.push({ name: newType, isAlias: !1, path: specifier });
else {
let existingImport = existingImports.find((it) => it.name === newType && it.isAlias);
if (existingImport)
throw existingImport.path.buildCodeFrameError(
`This codemod does not support local imports that are called the same as a storybook import.
Rename this local import and try again.`
);
specifier.remove();
}
}
});
}
}), file.path.traverse({
TSTypeReference: (path) => {
let typeName = path.get("typeName");
if (typeName.isIdentifier())
typeReferencesToUpdate.has(typeName.node.name) && typeName.replaceWith(t.identifier(migrateType(typeName.node.name)));
else if (typeName.isTSQualifiedName()) {
let namespace = typeName.get("left");
if (namespace.isIdentifier() && importedNamespaces.has(namespace.node.name)) {
let right = typeName.get("right");
deprecatedTypes.includes(right.node.name) && right.replaceWith(t.identifier(migrateType(right.node.name)));
}
}
}
});
}
export {
transform,
parser,
upgradeDeprecatedTypes
};