Skip to content

Commit

Permalink
working branch for supporting windows contributors (adobe#6313)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
Co-authored-by: Daniel Lu <[email protected]>
  • Loading branch information
3 people authored Aug 22, 2024
1 parent 25a2a30 commit acddd45
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 6 deletions.
54 changes: 54 additions & 0 deletions .yarn/patches/storybook-builder-parcel-https-7ea26540e8.patch
Original file line number Diff line number Diff line change
@@ -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}`
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/@spectrum-icons/color/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/@spectrum-icons/express/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/@spectrum-icons/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/@spectrum-icons/workflow/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
23 changes: 22 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit acddd45

Please sign in to comment.