fix migrate command

also bring type safety for migrate command to lib/cli
This commit is contained in:
Norbert de Langen 2022-12-09 23:32:46 +01:00
parent d283bb812b
commit c6f4baba2a
No known key found for this signature in database
GPG Key ID: FD0E78AF9A837762
2 changed files with 21 additions and 7 deletions

View File

@ -1,13 +1,10 @@
import { listCodemods, runCodemod } from '@storybook/codemod';
export async function migrate(
migration: any,
{ configDir, glob, dryRun, list, rename, logger, parser }: any
) {
export async function migrate(migration: any, { glob, dryRun, list, rename, logger, parser }: any) {
if (list) {
listCodemods().forEach((key: any) => logger.log(key));
} else if (migration) {
await runCodemod(migration, { configDir, glob, dryRun, logger, rename, parser });
await runCodemod(migration, { glob, dryRun, logger, rename, parser });
} else {
throw new Error('Migrate: please specify a migration name or --list');
}

View File

@ -26,11 +26,19 @@
"import": "./dist/index.mjs",
"types": "./dist/index.d.ts"
},
"./dist/transforms/add-component-parameters.js": "./dist/transforms/add-component-parameters.js",
"./dist/transforms/csf-2-to-3.js": "./dist/transforms/csf-2-to-3.js",
"./dist/transforms/csf-hoist-story-annotations.js": "./dist/transforms/csf-hoist-story-annotations.js",
"./dist/transforms/csf-to-mdx.js": "./dist/transforms/csf-to-mdx.js",
"./dist/transforms/move-builtin-addons.js": "./dist/transforms/move-builtin-addons.js",
"./dist/transforms/storiesof-to-csf.js": "./dist/transforms/storiesof-to-csf.js",
"./dist/transforms/update-addon-info.js": "./dist/transforms/update-addon-info.js",
"./dist/transforms/update-organisation-name.js": "./dist/transforms/update-organisation-name.js",
"./dist/transforms/upgrade-hierarchy-separators.js": "./dist/transforms/upgrade-hierarchy-separators.js",
"./package.json": "./package.json"
},
"main": "dist/index.js",
"module": "dist/index.mjs",
"jsnext:main": "src/index.js",
"types": "dist/index.d.ts",
"scripts": {
"check": "../../../scripts/node_modules/.bin/tsc --noEmit",
@ -61,7 +69,16 @@
"bundler": {
"platform": "node",
"entries": [
"./src/index.js"
"./src/index.js",
"./src/transforms/add-component-parameters.js",
"./src/transforms/csf-2-to-3.js",
"./src/transforms/csf-hoist-story-annotations.js",
"./src/transforms/csf-to-mdx.js",
"./src/transforms/move-builtin-addons.js",
"./src/transforms/storiesof-to-csf.js",
"./src/transforms/update-addon-info.js",
"./src/transforms/update-organisation-name.js",
"./src/transforms/upgrade-hierarchy-separators.js"
]
},
"gitHead": "66a0d588184add900c48d49f3a62743fa9cc5185"