From d8c959502bf371a803d93c5aeffc09d1cd35d8e1 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Wed, 25 Sep 2024 10:02:12 +0200 Subject: [PATCH] remove use of camelcase for es-toolkit, remove use of picky --- code/core/package.json | 3 +-- .../utils/get-component-variable-name.ts | 5 +++-- code/core/src/manager-api/lib/merge.ts | 7 ------ code/core/src/manager-api/modules/layout.ts | 8 +++---- code/lib/blocks/package.json | 2 +- code/lib/codemod/package.json | 3 +-- code/lib/codemod/src/transforms/mdx-to-csf.ts | 2 +- code/lib/source-loader/package.json | 2 +- code/package.json | 2 +- code/renderers/react/package.json | 2 +- code/yarn.lock | 22 +++++++++---------- scripts/package.json | 2 +- scripts/yarn.lock | 10 ++++----- 13 files changed, 30 insertions(+), 40 deletions(-) diff --git a/code/core/package.json b/code/core/package.json index 7aefe83a3b10..fd1815c5384d 100644 --- a/code/core/package.json +++ b/code/core/package.json @@ -342,7 +342,6 @@ "babel-plugin-react-docgen": "4.2.1", "boxen": "^7.1.1", "browser-dtector": "^3.4.0", - "camelcase": "^8.0.0", "chai": "^4.4.1", "chalk": "^5.3.0", "cli-table3": "^0.6.1", @@ -360,7 +359,7 @@ "diff": "^5.2.0", "downshift": "^9.0.4", "ejs": "^3.1.10", - "es-toolkit": "^1.20.0", + "es-toolkit": "^1.21.0", "esbuild": "^0.18.0 || ^0.19.0 || ^0.20.0 || ^0.21.0 || ^0.22.0 || ^0.23.0", "esbuild-plugin-alias": "^0.2.1", "execa": "^8.0.1", diff --git a/code/core/src/core-server/utils/get-component-variable-name.ts b/code/core/src/core-server/utils/get-component-variable-name.ts index bc29ff9e51d6..dc0dc91e7b96 100644 --- a/code/core/src/core-server/utils/get-component-variable-name.ts +++ b/code/core/src/core-server/utils/get-component-variable-name.ts @@ -1,3 +1,5 @@ +import { camelCase } from 'es-toolkit'; + /** * Get a valid variable name for a component. * @@ -5,8 +7,7 @@ * @returns A valid variable name. */ export const getComponentVariableName = async (name: string) => { - const camelCase = await import('camelcase'); - const camelCased = camelCase.default(name.replace(/^[^a-zA-Z_$]*/, ''), { pascalCase: true }); + const camelCased = camelCase(name.replace(/^[^a-zA-Z_$]*/, '')); const sanitized = camelCased.replace(/[^a-zA-Z_$]+/, ''); return sanitized; }; diff --git a/code/core/src/manager-api/lib/merge.ts b/code/core/src/manager-api/lib/merge.ts index 92ada66badba..f00195c304b2 100644 --- a/code/core/src/manager-api/lib/merge.ts +++ b/code/core/src/manager-api/lib/merge.ts @@ -71,10 +71,3 @@ export const noArrayMerge = (a: TObj, ...b: Partial[]): TObj = return target as TObj; }; - -export function picky, K extends keyof T>( - obj: T, - keys: K[] -): Partial> { - return omitBy(pick(obj, keys), (v) => v === undefined); -} diff --git a/code/core/src/manager-api/modules/layout.ts b/code/core/src/manager-api/modules/layout.ts index b90d552f4478..710219b2c5fd 100644 --- a/code/core/src/manager-api/modules/layout.ts +++ b/code/core/src/manager-api/modules/layout.ts @@ -5,9 +5,9 @@ import { global } from '@storybook/global'; import { SET_CONFIG } from '@storybook/core/core-events'; -import { isEqual as deepEqual, omitBy, pick, toMerged } from 'es-toolkit'; +import { isEqual as deepEqual, pick, toMerged } from 'es-toolkit'; -import merge, { picky } from '../lib/merge'; +import merge from '../lib/merge'; import type { ModuleFn } from '../lib/types'; import type { State } from '../root'; @@ -354,14 +354,14 @@ export const init: ModuleFn = ({ store, provider, singleStory const updatedLayout = { ...layout, ...(options.layout || {}), - ...picky(options, Object.keys(layout)), + ...pick(options, Object.keys(layout)), ...(singleStory && { navSize: 0 }), }; const updatedUi = { ...ui, ...options.ui, - ...toMerged(options.ui || {}, picky(options, Object.keys(ui))), + ...toMerged(options.ui || {}, pick(options, Object.keys(ui))), }; const updatedTheme = { diff --git a/code/lib/blocks/package.json b/code/lib/blocks/package.json index 9dbebde00ab2..bc598ece7aba 100644 --- a/code/lib/blocks/package.json +++ b/code/lib/blocks/package.json @@ -48,7 +48,7 @@ "@storybook/icons": "^1.2.10", "color-convert": "^2.0.1", "dequal": "^2.0.2", - "es-toolkit": "^1.20.0", + "es-toolkit": "^1.21.0", "markdown-to-jsx": "^7.4.5", "memoizerific": "^1.11.3", "polished": "^4.2.2", diff --git a/code/lib/codemod/package.json b/code/lib/codemod/package.json index 359ce07d0e6e..f150b9a647cd 100644 --- a/code/lib/codemod/package.json +++ b/code/lib/codemod/package.json @@ -61,7 +61,7 @@ "@storybook/csf": "^0.1.11", "@types/cross-spawn": "^6.0.2", "cross-spawn": "^7.0.3", - "es-toolkit": "^1.20.0", + "es-toolkit": "^1.21.0", "globby": "^14.0.1", "jscodeshift": "^0.15.1", "prettier": "^3.1.1", @@ -71,7 +71,6 @@ "devDependencies": { "@types/jscodeshift": "^0.11.10", "ansi-regex": "^6.0.1", - "camelcase": "^8.0.0", "mdast-util-mdx-jsx": "^3.0.0", "mdast-util-mdxjs-esm": "^2.0.1", "remark": "^15.0.1", diff --git a/code/lib/codemod/src/transforms/mdx-to-csf.ts b/code/lib/codemod/src/transforms/mdx-to-csf.ts index e290322beae0..c83f900d0d87 100644 --- a/code/lib/codemod/src/transforms/mdx-to-csf.ts +++ b/code/lib/codemod/src/transforms/mdx-to-csf.ts @@ -11,7 +11,7 @@ import { types as t, } from '@storybook/core/babel'; -import camelCase from 'camelcase'; +import { camelCase } from 'es-toolkit'; import type { FileInfo } from 'jscodeshift'; import type { MdxFlowExpression } from 'mdast-util-mdx-expression'; import type { diff --git a/code/lib/source-loader/package.json b/code/lib/source-loader/package.json index eec99d8b58ff..d7882750db5b 100644 --- a/code/lib/source-loader/package.json +++ b/code/lib/source-loader/package.json @@ -45,7 +45,7 @@ }, "dependencies": { "@storybook/csf": "^0.1.11", - "es-toolkit": "^1.20.0", + "es-toolkit": "^1.21.0", "estraverse": "^5.2.0", "prettier": "^3.1.1" }, diff --git a/code/package.json b/code/package.json index 7c82b7e8e826..01e77911a0f6 100644 --- a/code/package.json +++ b/code/package.json @@ -184,7 +184,7 @@ "create-storybook": "workspace:*", "cross-env": "^7.0.3", "danger": "^12.3.3", - "es-toolkit": "^1.20.0", + "es-toolkit": "^1.21.0", "esbuild": "^0.18.0 || ^0.19.0 || ^0.20.0 || ^0.21.0 || ^0.22.0 || ^0.23.0", "esbuild-loader": "^4.2.0", "esbuild-plugin-alias": "^0.2.1", diff --git a/code/renderers/react/package.json b/code/renderers/react/package.json index a2f6f86a6523..ea77fec881ae 100644 --- a/code/renderers/react/package.json +++ b/code/renderers/react/package.json @@ -89,7 +89,7 @@ "@types/semver": "^7.3.4", "@types/util-deprecate": "^1.0.0", "babel-plugin-react-docgen": "^4.2.1", - "es-toolkit": "^1.20.0", + "es-toolkit": "^1.21.0", "expect-type": "^0.15.0", "require-from-string": "^2.0.2" }, diff --git a/code/yarn.lock b/code/yarn.lock index 568fa35b4933..38a3cc7844a1 100644 --- a/code/yarn.lock +++ b/code/yarn.lock @@ -5757,7 +5757,7 @@ __metadata: "@types/color-convert": "npm:^2.0.0" color-convert: "npm:^2.0.1" dequal: "npm:^2.0.2" - es-toolkit: "npm:^1.20.0" + es-toolkit: "npm:^1.21.0" markdown-to-jsx: "npm:^7.4.5" memoizerific: "npm:^1.11.3" polished: "npm:^4.2.2" @@ -5928,9 +5928,8 @@ __metadata: "@types/cross-spawn": "npm:^6.0.2" "@types/jscodeshift": "npm:^0.11.10" ansi-regex: "npm:^6.0.1" - camelcase: "npm:^8.0.0" cross-spawn: "npm:^7.0.3" - es-toolkit: "npm:^1.20.0" + es-toolkit: "npm:^1.21.0" globby: "npm:^14.0.1" jscodeshift: "npm:^0.15.1" mdast-util-mdx-jsx: "npm:^3.0.0" @@ -6054,7 +6053,6 @@ __metadata: boxen: "npm:^7.1.1" browser-assert: "npm:^1.2.1" browser-dtector: "npm:^3.4.0" - camelcase: "npm:^8.0.0" chai: "npm:^4.4.1" chalk: "npm:^5.3.0" cli-table3: "npm:^0.6.1" @@ -6072,7 +6070,7 @@ __metadata: diff: "npm:^5.2.0" downshift: "npm:^9.0.4" ejs: "npm:^3.1.10" - es-toolkit: "npm:^1.20.0" + es-toolkit: "npm:^1.21.0" esbuild: "npm:^0.18.0 || ^0.19.0 || ^0.20.0 || ^0.21.0 || ^0.22.0 || ^0.23.0" esbuild-plugin-alias: "npm:^0.2.1" esbuild-register: "npm:^3.5.0" @@ -6757,7 +6755,7 @@ __metadata: acorn-jsx: "npm:^5.3.1" acorn-walk: "npm:^7.2.0" babel-plugin-react-docgen: "npm:^4.2.1" - es-toolkit: "npm:^1.20.0" + es-toolkit: "npm:^1.21.0" escodegen: "npm:^2.1.0" expect-type: "npm:^0.15.0" html-tags: "npm:^3.1.0" @@ -6881,7 +6879,7 @@ __metadata: create-storybook: "workspace:*" cross-env: "npm:^7.0.3" danger: "npm:^12.3.3" - es-toolkit: "npm:^1.20.0" + es-toolkit: "npm:^1.21.0" esbuild: "npm:^0.18.0 || ^0.19.0 || ^0.20.0 || ^0.21.0 || ^0.22.0 || ^0.23.0" esbuild-loader: "npm:^4.2.0" esbuild-plugin-alias: "npm:^0.2.1" @@ -6983,7 +6981,7 @@ __metadata: resolution: "@storybook/source-loader@workspace:lib/source-loader" dependencies: "@storybook/csf": "npm:^0.1.11" - es-toolkit: "npm:^1.20.0" + es-toolkit: "npm:^1.21.0" estraverse: "npm:^5.2.0" prettier: "npm:^3.1.1" typescript: "npm:^5.3.2" @@ -14060,10 +14058,10 @@ __metadata: languageName: node linkType: hard -"es-toolkit@npm:^1.20.0": - version: 1.20.0 - resolution: "es-toolkit@npm:1.20.0" - checksum: 10c0/566a517ec97d4b2431d220d4eb9a7cc37a1b397521b4e230c9e53d647c2b4e0b8c2e91030e1de6e8080c30f9f05ee5281d13d3c2dd37ec1193a13bc24e2fd70c +"es-toolkit@npm:^1.21.0": + version: 1.21.0 + resolution: "es-toolkit@npm:1.21.0" + checksum: 10c0/894a63f8ce5b2e5c1be242c8e8eace6364ea1212d01cdf89594d2cc582c5e1574114ad2ee7022ad5206561c4d5170511d83b38853257249860e56178768854ea languageName: node linkType: hard diff --git a/scripts/package.json b/scripts/package.json index dcbd970d5cb3..13351afb5827 100644 --- a/scripts/package.json +++ b/scripts/package.json @@ -107,7 +107,7 @@ "detect-port": "^1.6.1", "ejs": "^3.1.10", "ejs-lint": "^2.0.0", - "es-toolkit": "^1.20.0", + "es-toolkit": "^1.21.0", "esbuild": "^0.23.0", "esbuild-plugin-alias": "^0.2.1", "eslint": "^8.57.0", diff --git a/scripts/yarn.lock b/scripts/yarn.lock index c91898d0dfd0..25f08bde9c99 100644 --- a/scripts/yarn.lock +++ b/scripts/yarn.lock @@ -1558,7 +1558,7 @@ __metadata: detect-port: "npm:^1.6.1" ejs: "npm:^3.1.10" ejs-lint: "npm:^2.0.0" - es-toolkit: "npm:^1.20.0" + es-toolkit: "npm:^1.21.0" esbuild: "npm:^0.23.0" esbuild-plugin-alias: "npm:^0.2.1" eslint: "npm:^8.57.0" @@ -5271,10 +5271,10 @@ __metadata: languageName: node linkType: hard -"es-toolkit@npm:^1.20.0": - version: 1.20.0 - resolution: "es-toolkit@npm:1.20.0" - checksum: 10c0/566a517ec97d4b2431d220d4eb9a7cc37a1b397521b4e230c9e53d647c2b4e0b8c2e91030e1de6e8080c30f9f05ee5281d13d3c2dd37ec1193a13bc24e2fd70c +"es-toolkit@npm:^1.21.0": + version: 1.21.0 + resolution: "es-toolkit@npm:1.21.0" + checksum: 10c0/894a63f8ce5b2e5c1be242c8e8eace6364ea1212d01cdf89594d2cc582c5e1574114ad2ee7022ad5206561c4d5170511d83b38853257249860e56178768854ea languageName: node linkType: hard