From acddd45c05d44708e34b4db6c3c47d7044c1f9eb Mon Sep 17 00:00:00 2001 From: Dave Coleman Date: Thu, 22 Aug 2024 14:34:59 -0700 Subject: [PATCH] working branch for supporting windows contributors (#6313) * remove --extensions as they are unnecessary add is-mingw use isMinGW to use proper slashes on windows git bash * remove logs from preview builder * is-mingw is a dev dep * patching storybook-builder-parcel to solve windows forward slash issues --------- Co-authored-by: David Coleman Co-authored-by: Daniel Lu --- ...book-builder-parcel-https-7ea26540e8.patch | 54 +++++++++++++++++++ package.json | 3 +- packages/@spectrum-icons/color/package.json | 2 +- packages/@spectrum-icons/express/package.json | 2 +- packages/@spectrum-icons/ui/package.json | 2 +- .../@spectrum-icons/workflow/package.json | 2 +- yarn.lock | 23 +++++++- 7 files changed, 82 insertions(+), 6 deletions(-) create mode 100644 .yarn/patches/storybook-builder-parcel-https-7ea26540e8.patch diff --git a/.yarn/patches/storybook-builder-parcel-https-7ea26540e8.patch b/.yarn/patches/storybook-builder-parcel-https-7ea26540e8.patch new file mode 100644 index 00000000000..5f676aad8c2 --- /dev/null +++ b/.yarn/patches/storybook-builder-parcel-https-7ea26540e8.patch @@ -0,0 +1,54 @@ +diff --git a/gen-preview-modern.js b/gen-preview-modern.js +index a1fe3d1ce6b748e533200f5af69a0481e5809c6c..aeed09de7dbaddd4606ac3579a86cb2ba389eb2f 100644 +--- a/gen-preview-modern.js ++++ b/gen-preview-modern.js +@@ -7,9 +7,16 @@ const { + } = require("@storybook/core-common"); + const { logger } = require("@storybook/node-logger"); + const { promise: glob } = require("glob-promise"); ++const isMingw = require('is-mingw'); + +-const absoluteToSpecifier = (generatedEntries, abs) => +- "./" + path.relative(generatedEntries, abs); ++const absoluteToSpecifier = (generatedEntries, abs) => { ++ let relativePath = path.relative(generatedEntries, abs); ++ if (isMingw()) { ++ relativePath = relativePath.replace(/\\/g, '/'); ++ } ++ ++ return "./" + relativePath; ++} + + module.exports.generatePreviewModern = async function generatePreviewModern( + options, +@@ -66,7 +73,7 @@ module.exports.generatePreviewModern = async function generatePreviewModern( + */ + const code = ` + import { composeConfigs, PreviewWeb, ClientApi } from '@storybook/preview-api'; +- ++ + // generateAddonSetupCode + import { createBrowserChannel } from '@storybook/channels'; + import { addons } from '@storybook/preview-api'; +@@ -94,7 +101,7 @@ module.exports.generatePreviewModern = async function generatePreviewModern( + window.__STORYBOOK_CLIENT_API__ = new ClientApi({ storyStore: preview.storyStore }); + + preview.initialize({ importFn, getProjectAnnotations }); +- ++ + `; + // ${generateHMRHandler(frameworkName)}; + return code; +@@ -152,7 +159,11 @@ function toImportPath(relativePath) { + async function toImportFn(stories, generatedEntries) { + const objectEntries = stories.map((file) => { + const ext = path.extname(file); +- const relativePath = /*normalizePath*/ path.relative(process.cwd(), file); ++ let relativePath = /*normalizePath*/ path.relative(process.cwd(), file); ++ if (isMingw()) { ++ relativePath = relativePath.replace(/\\/g, '/'); ++ } ++ + if (![".js", ".jsx", ".ts", ".tsx", ".mdx"].includes(ext)) { + logger.warn( + `Cannot process ${ext} file with storyStoreV7: ${relativePath}` diff --git a/package.json b/package.json index 602d0e46dc3..40c6af242ba 100644 --- a/package.json +++ b/package.json @@ -162,6 +162,7 @@ "glob-promise": "^6.0.5", "identity-obj-proxy": "^3.0.0", "ignore-styles": "^5.0.1", + "is-mingw": "^2.0.0", "jest": "^29.5.0", "jest-environment-jsdom": "^29.5.0", "jest-junit": "^15.0.0", @@ -195,7 +196,7 @@ "sharp": "^0.31.2", "sinon": "^7.3.1", "storybook": "^7.6.19", - "storybook-builder-parcel": "https://gitpkg.vercel.app/mischnic/storybook-parcel/packages/storybook-builder-parcel?master", + "storybook-builder-parcel": "patch:storybook-builder-parcel@https%3A//gitpkg.vercel.app/mischnic/storybook-parcel/packages/storybook-builder-parcel?master#~/.yarn/patches/storybook-builder-parcel-https-7ea26540e8.patch", "storybook-dark-mode": "^3.0.3", "storybook-react-parcel": "https://gitpkg.vercel.app/mischnic/storybook-parcel/packages/storybook-react-parcel?master", "tailwind-variants": "^0.1.18", diff --git a/packages/@spectrum-icons/color/package.json b/packages/@spectrum-icons/color/package.json index 52814974d6c..62e403e588f 100644 --- a/packages/@spectrum-icons/color/package.json +++ b/packages/@spectrum-icons/color/package.json @@ -19,7 +19,7 @@ "build-esm": "cross-env BUILD_ENV=production babel src -d . --extensions '.ts,.tsx' --out-file-extension '.module.mjs' --config-file '../../../babel-esm.config.json'", "generate-types": "tsc --project ./tsconfig.types.json", "build-icons": "yarn build-cjs && yarn build-esm", - "make-icons": "babel-node --extensions '.cjs,.js' --presets @babel/env ./scripts/generateIcons.cjs -i '[]' && yarn generate-types" + "make-icons": "babel-node --presets @babel/env ./scripts/generateIcons.cjs -i '[]' && yarn generate-types" }, "dependencies": { "@adobe/react-spectrum-workflow-color": "1.1.1", diff --git a/packages/@spectrum-icons/express/package.json b/packages/@spectrum-icons/express/package.json index 1ee4c31c919..ab23e6405d3 100644 --- a/packages/@spectrum-icons/express/package.json +++ b/packages/@spectrum-icons/express/package.json @@ -19,7 +19,7 @@ "build-esm": "cross-env BUILD_ENV=production babel src -d . --extensions '.ts,.tsx' --out-file-extension '.module.mjs' --config-file '../../../babel-esm.config.json'", "generate-types": "tsc --project ./tsconfig.types.json", "build-icons": "yarn build-cjs && yarn build-esm", - "make-icons": "babel-node --extensions '.cjs,.js' --presets @babel/env ./scripts/generateIcons.cjs -i '[]' && yarn generate-types" + "make-icons": "babel-node --presets @babel/env ./scripts/generateIcons.cjs -i '[]' && yarn generate-types" }, "dependencies": { "@adobe/spectrum-css-ccx-workflow-icons": "1.0.2", diff --git a/packages/@spectrum-icons/ui/package.json b/packages/@spectrum-icons/ui/package.json index f67e5efefad..1d7d08608ee 100644 --- a/packages/@spectrum-icons/ui/package.json +++ b/packages/@spectrum-icons/ui/package.json @@ -19,7 +19,7 @@ "build-esm": "cross-env BUILD_ENV=production babel src -d . --extensions '.ts,.tsx' --out-file-extension '.module.mjs' --config-file '../../../babel-esm.config.json'", "generate-types": "tsc --project ./tsconfig.types.json", "build-icons": "yarn build-cjs && yarn build-esm", - "make-icons": "babel-node --extensions '.cjs,.js' --presets @babel/env ./scripts/generateIcons.cjs -i '[]' && yarn generate-types" + "make-icons": "babel-node --presets @babel/env ./scripts/generateIcons.cjs -i '[]' && yarn generate-types" }, "dependencies": { "@adobe/react-spectrum-ui": "1.2.1", diff --git a/packages/@spectrum-icons/workflow/package.json b/packages/@spectrum-icons/workflow/package.json index 4eab4a201ee..86eb12de234 100644 --- a/packages/@spectrum-icons/workflow/package.json +++ b/packages/@spectrum-icons/workflow/package.json @@ -19,7 +19,7 @@ "build-esm": "cross-env BUILD_ENV=production babel src -d . --extensions '.ts,.tsx' --out-file-extension '.module.mjs' --config-file '../../../babel-esm.config.json'", "generate-types": "tsc --project ./tsconfig.types.json", "build-icons": "yarn build-cjs && yarn build-esm", - "make-icons": "babel-node --extensions '.cjs,.js' --presets @babel/env ./scripts/generateIcons.cjs -i '[]' && yarn generate-types" + "make-icons": "babel-node --presets @babel/env ./scripts/generateIcons.cjs -i '[]' && yarn generate-types" }, "dependencies": { "@adobe/react-spectrum-workflow": "2.3.5", diff --git a/yarn.lock b/yarn.lock index 6a06979b7d4..aa3677c282c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -21077,6 +21077,13 @@ __metadata: languageName: node linkType: hard +"is-mingw@npm:^2.0.0": + version: 2.0.0 + resolution: "is-mingw@npm:2.0.0" + checksum: 10c0/c1a5a140b611d8286901155ad53729426ecf384b397918edb0d54547b5f84e3ac7c831725f87f1538919b50c7e3065cdf386b28d234ee81c9ca0066b1d46ad77 + languageName: node + linkType: hard + "is-nan@npm:^1.3.2": version: 1.3.2 resolution: "is-nan@npm:1.3.2" @@ -29090,6 +29097,7 @@ __metadata: glob-promise: "npm:^6.0.5" identity-obj-proxy: "npm:^3.0.0" ignore-styles: "npm:^5.0.1" + is-mingw: "npm:^2.0.0" jest: "npm:^29.5.0" jest-environment-jsdom: "npm:^29.5.0" jest-junit: "npm:^15.0.0" @@ -29123,7 +29131,7 @@ __metadata: sharp: "npm:^0.31.2" sinon: "npm:^7.3.1" storybook: "npm:^7.6.19" - storybook-builder-parcel: "https://gitpkg.vercel.app/mischnic/storybook-parcel/packages/storybook-builder-parcel?master" + storybook-builder-parcel: "patch:storybook-builder-parcel@https%3A//gitpkg.vercel.app/mischnic/storybook-parcel/packages/storybook-builder-parcel?master#~/.yarn/patches/storybook-builder-parcel-https-7ea26540e8.patch" storybook-dark-mode: "npm:^3.0.3" storybook-react-parcel: "https://gitpkg.vercel.app/mischnic/storybook-parcel/packages/storybook-react-parcel?master" tailwind-variants: "npm:^0.1.18" @@ -31337,6 +31345,19 @@ __metadata: languageName: node linkType: hard +"storybook-builder-parcel@patch:storybook-builder-parcel@https%3A//gitpkg.vercel.app/mischnic/storybook-parcel/packages/storybook-builder-parcel?master#~/.yarn/patches/storybook-builder-parcel-https-7ea26540e8.patch": + version: 0.0.0 + resolution: "storybook-builder-parcel@patch:storybook-builder-parcel@https%3A//gitpkg.vercel.app/mischnic/storybook-parcel/packages/storybook-builder-parcel?master#~/.yarn/patches/storybook-builder-parcel-https-7ea26540e8.patch::version=0.0.0&hash=08ad7e" + dependencies: + "@storybook/core-common": "npm:7.6.4" + http-proxy-middleware: "npm:^2.0.6" + peerDependencies: + "@parcel/core": ^2.0.0 + react: "*" + checksum: 10c0/565481429f72b5d9ab24bc5929c3fe048e44137125ae69fc5002f8c96bc5cefa736bff09450ed3aa37e165991742b44042ae150556cf66c6796066401f0696cb + languageName: node + linkType: hard + "storybook-dark-mode@npm:^3.0.3": version: 3.0.3 resolution: "storybook-dark-mode@npm:3.0.3"