@aussieljk/forkbook 0.0.1-20 → 0.0.1-21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_browser-chunks/{Color-KALNKPOV.js → Color-7FO5YFB5.js} +1 -1
- package/dist/_browser-chunks/{WithTooltip-66AWY4VQ.js → WithTooltip-QWFSUQZP.js} +1 -1
- package/dist/_browser-chunks/{chunk-OWWV6YG7.js → chunk-5Z3MWCFR.js} +1 -1
- package/dist/_browser-chunks/{chunk-CX37N6FG.js → chunk-BSYOFSF6.js} +9 -9
- package/dist/_browser-chunks/{chunk-4ZGQ4YQ2.js → chunk-FAOLWWRN.js} +1 -1
- package/dist/_browser-chunks/{chunk-TRXLBGLS.js → chunk-ZIZCGWCG.js} +4 -4
- package/dist/_node-chunks/{attached-runtime-YD6HKC4B.js → attached-runtime-UC2CB4GH.js} +34 -34
- package/dist/_node-chunks/{builder-manager-UNJGYVTD.js → builder-manager-S5UUKVOR.js} +17 -19
- package/dist/_node-chunks/{chunk-QEYWG5C7.js → chunk-3335ZZIO.js} +6 -6
- package/dist/_node-chunks/{chunk-75TTPKEA.js → chunk-3D6N6P2R.js} +8 -8
- package/dist/_node-chunks/{chunk-65X3MXFT.js → chunk-3ER54PQM.js} +8 -8
- package/dist/_node-chunks/{chunk-AGLGQNTY.js → chunk-3H5C52QU.js} +6 -6
- package/dist/_node-chunks/{chunk-X6OGIC2G.js → chunk-3UI3TQ7R.js} +6 -6
- package/dist/_node-chunks/{chunk-5LFJQCYN.js → chunk-4C3ACAHV.js} +6 -6
- package/dist/_node-chunks/{chunk-J6FGP2VM.js → chunk-4UTCKJEQ.js} +7 -7
- package/dist/_node-chunks/{chunk-LAJIVWUF.js → chunk-53A5CYDK.js} +92 -17
- package/dist/_node-chunks/{chunk-HHM5X5RQ.js → chunk-53PSBDRK.js} +9 -9
- package/dist/_node-chunks/{chunk-7CWDZLIZ.js → chunk-54MO4QLB.js} +6 -6
- package/dist/_node-chunks/{chunk-QDVIQG3B.js → chunk-5CJMRQZ6.js} +6 -6
- package/dist/_node-chunks/{chunk-U54Q3F7E.js → chunk-5HOM7B4V.js} +6 -6
- package/dist/_node-chunks/{chunk-VNZF62KE.js → chunk-5QG6AXK4.js} +7 -7
- package/dist/_node-chunks/{chunk-LGHTKFSF.js → chunk-67XVZZUO.js} +6 -6
- package/dist/_node-chunks/{chunk-IIGBIVK3.js → chunk-6HQJJDLH.js} +6 -6
- package/dist/_node-chunks/chunk-6IPHWCFI.js +29 -0
- package/dist/_node-chunks/{chunk-ZZ5XMIGW.js → chunk-6XYOFBRD.js} +14 -31
- package/dist/_node-chunks/{chunk-F762PHMI.js → chunk-7IAYDGYH.js} +6 -6
- package/dist/_node-chunks/{chunk-WDANLGYN.js → chunk-7P67PUU2.js} +7 -7
- package/dist/_node-chunks/{chunk-6RYD6ENB.js → chunk-AAK5BBF2.js} +7 -7
- package/dist/_node-chunks/{chunk-VPFU5CEP.js → chunk-BGUVBOOU.js} +8 -8
- package/dist/_node-chunks/{chunk-ZLC4JSBV.js → chunk-BNGBOASQ.js} +6 -6
- package/dist/_node-chunks/{chunk-2GA4VQCS.js → chunk-BWZWCVVH.js} +9 -9
- package/dist/_node-chunks/{chunk-MWKSSYPG.js → chunk-C6HQ6WLU.js} +6 -6
- package/dist/_node-chunks/chunk-CJHRH777.js +20 -0
- package/dist/_node-chunks/{chunk-3ZOSFS7G.js → chunk-COEW4ORP.js} +6 -6
- package/dist/_node-chunks/{chunk-LCNF6BLP.js → chunk-CVHDAEDZ.js} +7 -7
- package/dist/_node-chunks/{chunk-ZX32M4O7.js → chunk-CXGOQNGI.js} +7 -7
- package/dist/_node-chunks/chunk-D4XTQWRM.js +11 -0
- package/dist/_node-chunks/{chunk-EFCBUWOB.js → chunk-D5V6CZ6U.js} +7 -7
- package/dist/_node-chunks/{chunk-CPDP5SQS.js → chunk-DCTXJ4TT.js} +9 -9
- package/dist/_node-chunks/{chunk-LNGSV5UI.js → chunk-DP6WFY3D.js} +7 -7
- package/dist/_node-chunks/{chunk-DQEUNKLX.js → chunk-E23GDXG6.js} +9 -85
- package/dist/_node-chunks/{chunk-SFXFL4TP.js → chunk-E3ZFMURC.js} +8 -8
- package/dist/_node-chunks/{chunk-N4LNGTYL.js → chunk-E6O3NA44.js} +7 -7
- package/dist/_node-chunks/{chunk-UZH2V3WY.js → chunk-ECS3WDOU.js} +7 -7
- package/dist/_node-chunks/{chunk-N5WU4BEY.js → chunk-FB5YJWOH.js} +6 -6
- package/dist/_node-chunks/{chunk-XVSUIOZA.js → chunk-FCK5FM6D.js} +7 -7
- package/dist/_node-chunks/{chunk-3CQI3JH5.js → chunk-FJUGPEJK.js} +6 -6
- package/dist/_node-chunks/{chunk-Z665R6AF.js → chunk-FPYXI76E.js} +7 -7
- package/dist/_node-chunks/{chunk-PJRPETSU.js → chunk-GEWVOY3F.js} +6 -6
- package/dist/_node-chunks/{chunk-FC3V4KZO.js → chunk-GHZ44BFB.js} +7 -7
- package/dist/_node-chunks/{chunk-WTPHQ2NG.js → chunk-GJMFISS3.js} +6 -6
- package/dist/_node-chunks/{chunk-33I6AQU7.js → chunk-GK2Y2RFX.js} +6 -6
- package/dist/_node-chunks/{chunk-7M3TOE4F.js → chunk-GP6YBA2R.js} +6 -6
- package/dist/_node-chunks/{chunk-KAALBGRE.js → chunk-GQUFGJ4D.js} +6 -6
- package/dist/_node-chunks/{chunk-MC4BFUVH.js → chunk-H4CRQDTK.js} +6 -6
- package/dist/_node-chunks/{chunk-IENHXJVB.js → chunk-HCDG54OG.js} +7 -7
- package/dist/_node-chunks/{chunk-2CNN3CRI.js → chunk-HGJMP4EI.js} +8 -8
- package/dist/_node-chunks/chunk-HSX6BDBA.js +18 -0
- package/dist/_node-chunks/{chunk-WMZJ2WK4.js → chunk-IPFPWMT5.js} +1255 -291
- package/dist/_node-chunks/{chunk-FXW52X4U.js → chunk-KRIOC4WF.js} +8 -8
- package/dist/_node-chunks/{chunk-NRXCMSAI.js → chunk-KUL2MJ6N.js} +6 -6
- package/dist/_node-chunks/{chunk-DAYTIH6Z.js → chunk-LUR6QTYB.js} +8 -8
- package/dist/_node-chunks/{chunk-2VJHCGAK.js → chunk-LYS7TI35.js} +8 -8
- package/dist/_node-chunks/{chunk-AVHJZUTH.js → chunk-MDTXL6SN.js} +8 -8
- package/dist/_node-chunks/{chunk-EKYNX5NX.js → chunk-MIIPXT4S.js} +8 -8
- package/dist/_node-chunks/{chunk-WYRBOMQF.js → chunk-MLWGAA2I.js} +8 -7
- package/dist/_node-chunks/{chunk-XF7H5GZM.js → chunk-MWUGCUB5.js} +8 -8
- package/dist/_node-chunks/{chunk-SPAHK37C.js → chunk-MX5MVLEK.js} +6 -6
- package/dist/_node-chunks/{chunk-25A7444H.js → chunk-N44UIGCO.js} +6 -6
- package/dist/_node-chunks/{chunk-JXZONVHW.js → chunk-NP2JHOFY.js} +7 -7
- package/dist/_node-chunks/{chunk-6FWJWEAG.js → chunk-OMNGOPNG.js} +7 -7
- package/dist/_node-chunks/{chunk-WZBMPROH.js → chunk-OO2GTHUF.js} +6 -6
- package/dist/_node-chunks/{chunk-ZN6YOIB2.js → chunk-PC57BIYZ.js} +7 -7
- package/dist/_node-chunks/{chunk-SUQ4OM7Y.js → chunk-PHWMAF5C.js} +6 -6
- package/dist/_node-chunks/{chunk-CJDYU653.js → chunk-PLIQQETC.js} +7 -7
- package/dist/_node-chunks/{chunk-B2EEX2SZ.js → chunk-QMYCIS2U.js} +6 -6
- package/dist/_node-chunks/{chunk-4BE3LRIQ.js → chunk-QZIDK3GX.js} +13 -14
- package/dist/_node-chunks/{chunk-6NLQCV6A.js → chunk-ROJ6RSIJ.js} +7 -7
- package/dist/_node-chunks/{chunk-NZWK62R5.js → chunk-S2NB6QEG.js} +30 -30
- package/dist/_node-chunks/{chunk-GWT4HQZU.js → chunk-S6VCOSQS.js} +6 -6
- package/dist/_node-chunks/{chunk-6OQKMJJA.js → chunk-SEVOOOB2.js} +10 -10
- package/dist/_node-chunks/{chunk-S7RGKBGT.js → chunk-SFT6ZAVN.js} +6 -6
- package/dist/_node-chunks/{chunk-AP4HJ3I3.js → chunk-SXBUK4F6.js} +7 -7
- package/dist/_node-chunks/{chunk-XUZB4FIX.js → chunk-TGF6Q66I.js} +8 -8
- package/dist/_node-chunks/{chunk-AOYLA323.js → chunk-TGFHWGGT.js} +6 -6
- package/dist/_node-chunks/{chunk-GFEH7IBP.js → chunk-TTLSBLPQ.js} +8 -8
- package/dist/_node-chunks/{chunk-VIMGLCNZ.js → chunk-UUAEW2AR.js} +6 -6
- package/dist/_node-chunks/{chunk-JOX7OETB.js → chunk-VQHM66NL.js} +8 -8
- package/dist/_node-chunks/{chunk-ZEYZWDOS.js → chunk-VSTTY3TM.js} +6 -6
- package/dist/_node-chunks/{chunk-N25CZ3RC.js → chunk-XDBSAFUB.js} +7 -7
- package/dist/_node-chunks/{chunk-EG2WLN5V.js → chunk-XTQQGAUZ.js} +7 -7
- package/dist/_node-chunks/{chunk-X2GGQZIN.js → chunk-YMJVSFJT.js} +6 -6
- package/dist/_node-chunks/{chunk-OBPVOYJA.js → chunk-YXEKWVJQ.js} +7 -7
- package/dist/_node-chunks/{chunk-L52VGA36.js → chunk-Z6CUUWJO.js} +7 -7
- package/dist/_node-chunks/{chunk-GEJBTN76.js → chunk-ZAIGR7EV.js} +9 -17
- package/dist/_node-chunks/{chunk-OMMQME7G.js → chunk-ZCFXEFR6.js} +14 -14
- package/dist/_node-chunks/{chunk-DO3CPQAZ.js → chunk-ZHUBOYOD.js} +6 -6
- package/dist/_node-chunks/{chunk-IBLUURAJ.js → chunk-ZHUBTBP2.js} +8 -8
- package/dist/_node-chunks/{chunk-JR7ZCQ77.js → chunk-ZSTIFZHY.js} +6 -6
- package/dist/_node-chunks/dist-TRTHRODT.js +16 -0
- package/dist/_node-chunks/dist-XPLJ5T4W.js +27 -0
- package/dist/_node-chunks/{local-runtime-4ETW6QTI.js → local-runtime-AC7MOWYK.js} +21 -21
- package/dist/_node-chunks/{mdx-plugin-OOYTYMVU.js → mdx-plugin-ZW26VGEP.js} +13 -13
- package/dist/_node-chunks/{monorepo-3AWUYNFD.js → monorepo-T2KZK62Q.js} +11 -11
- package/dist/_node-chunks/{monorepo-optimized-tests-relaxed-limits-no-story-deletion-ORY3BAP5.js → monorepo-optimized-tests-relaxed-limits-no-story-deletion-2CWUUF6H.js} +11 -11
- package/dist/_node-chunks/optimized-tests-4AK3PFSX.js +22 -0
- package/dist/_node-chunks/{pattern-copy-play-AY4DE7ME.js → pattern-copy-play-CMRGEXHM.js} +9 -9
- package/dist/_node-chunks/postinstallAddon-OUQENFYO.js +20 -0
- package/dist/_node-chunks/{rehype-external-links-FGVC633L.js → rehype-external-links-LHOAIJ2E.js} +9 -9
- package/dist/_node-chunks/{rehype-slug-2AZLMC5G.js → rehype-slug-K54MMYY6.js} +9 -9
- package/dist/_node-chunks/{relaxed-limits-QI3YR6CU.js → relaxed-limits-TTL4PWH7.js} +11 -11
- package/dist/_node-chunks/{run-QJJ4FOF3.js → run-6DXBB5F7.js} +28 -26
- package/dist/_node-chunks/{run-WFJZYNZN.js → run-BMTV5ZAO.js} +17 -17
- package/dist/_node-chunks/{setup-V5CRAJMV.js → setup-FDPYW25Y.js} +8 -8
- package/dist/_node-chunks/{vitest.config.4.template-LECBBF3L.js → vitest.config.4.template-2TCFWAAI.js} +7 -7
- package/dist/addon-a11y/manager.js +3 -3
- package/dist/addon-a11y/preset.js +7 -7
- package/dist/addon-comments/manager.js +2 -2
- package/dist/addon-comments/preset.js +43 -15
- package/dist/addon-comments/preview.js +1 -1
- package/dist/addon-docs/blocks.js +9 -9
- package/dist/addon-docs/manager.js +2 -2
- package/dist/addon-docs/preset.js +10 -10
- package/dist/addon-links/preview.d.ts +1 -1
- package/dist/addon-mcp/preset.js +39 -39
- package/dist/addon-mcp/preview.js +1 -1
- package/dist/addon-mcp/tools/preview-stories/preview-stories-app-script.js +2 -2
- package/dist/addon-themes/postinstall.js +7 -7
- package/dist/addon-vitest/constants.js +8 -8
- package/dist/addon-vitest/manager.js +4 -4
- package/dist/addon-vitest/node/coverage-reporter.js +8 -8
- package/dist/addon-vitest/node/vitest.js +18 -18
- package/dist/addon-vitest/postinstall.js +10 -10
- package/dist/addon-vitest/preset.js +18 -18
- package/dist/addon-vitest/vitest-plugin/global-setup.js +8 -8
- package/dist/addon-vitest/vitest-plugin/index.js +18 -18
- package/dist/babel/index.js +30582 -31
- package/dist/bin/core.js +60 -71
- package/dist/bin/dispatcher.js +10 -10
- package/dist/bin/loader.js +8 -8
- package/dist/builder-next/index.js +9 -9
- package/dist/builder-vite/index.js +15 -15
- package/dist/builder-vite/preset.js +13 -13
- package/dist/{chunk-ge-rSPy0.d.ts → chunk-B53gRJBs.d.ts} +22 -4
- package/dist/{chunk-Bubi-WAs.d.ts → chunk-BspNQvZn.d.ts} +1 -6
- package/dist/{chunk-OksNJcvJ.d.ts → chunk-CMx6bGAU.d.ts} +1 -1
- package/dist/{chunk-BsO65uOb.d.ts → chunk-CRmUwbkb.d.ts} +1 -1
- package/dist/{chunk-D2CQlXaR.d.ts → chunk-bhl-7rRD.d.ts} +28 -1
- package/dist/cli/index.d.ts +3 -39
- package/dist/cli/index.js +37 -282
- package/dist/cli/skills/content/index.d.ts +1 -1
- package/dist/cli/skills/content/index.js +1 -1
- package/dist/cli/tools/sdk/child-host.d.ts +1 -1
- package/dist/cli/tools/sdk/child-host.js +17 -17
- package/dist/cli/tools/sdk/index.d.ts +2 -2
- package/dist/cli/tools/sdk/index.js +18 -18
- package/dist/cli-commands/bin/index.js +7 -7
- package/dist/common/index.d.ts +9 -9
- package/dist/common/index.js +89 -91
- package/dist/components/index.js +29 -29
- package/dist/core-events/index.d.ts +12 -5
- package/dist/core-events/index.js +1 -5
- package/dist/core-server/index.d.ts +41 -13
- package/dist/core-server/index.js +247 -98
- package/dist/core-server/presets/common-manager.js +9 -9
- package/dist/core-server/presets/common-override-preset.js +10 -10
- package/dist/core-server/presets/common-preset.js +39 -39
- package/dist/create/bin/index.js +7 -7
- package/dist/create/index.js +15 -15
- package/dist/csf/index.js +6 -7
- package/dist/csf-tools/index.js +13 -13
- package/dist/instrumenter/index.d.ts +1 -1
- package/dist/manager/_manager-chunks/{globals-runtime-D6tkG2NO.js → globals-runtime-BJ6EZqH7.js} +6 -6
- package/dist/manager/_manager-chunks/{globals-runtime-BnWjPJUH.js → globals-runtime-BfXaq_CP.js} +1 -1
- package/dist/manager/_manager-chunks/{globals-runtime-Bv2PBsx6.js → globals-runtime-BkSn_Jpe.js} +2 -2
- package/dist/manager/_manager-chunks/{globals-runtime-D9zzVzSP.js → globals-runtime-Cisw9IIE.js} +2 -2
- package/dist/manager/_manager-chunks/{globals-runtime-DafcXCKU.js → globals-runtime-DpvE_zRs.js} +80 -84
- package/dist/manager/_manager-chunks/{globals-runtime-BDkYPr00.js → globals-runtime-wV08sCKl.js} +2 -2
- package/dist/manager/_manager-chunks/{runtime-DJlTd1qE.js → runtime-4OQZWibO.js} +134 -134
- package/dist/manager/_manager-chunks/{runtime-mjv_40eH.js → runtime-BYxbyNm0.js} +4 -4
- package/dist/manager/_manager-chunks/{runtime-BuPcYKCO.js → runtime-CM4Z8aKR.js} +0 -2
- package/dist/manager/_manager-chunks/{runtime-CGaGp83p.js → runtime-Cjo1UL1u.js} +2 -2
- package/dist/manager/_manager-chunks/{runtime-BhfRBP4G.js → runtime-Cx1-wr6J.js} +1 -1
- package/dist/manager/_manager-chunks/{runtime-CXROgt6G.js → runtime-Cxe_uJRb.js} +8 -8
- package/dist/manager/_manager-chunks/{runtime-DmpQacrn.js → runtime-D702FFTO.js} +5 -7
- package/dist/manager/_manager-chunks/{runtime-Dc6lf19c.js → runtime-DnWFp6Zw.js} +3 -3
- package/dist/manager/_manager-chunks/{runtime-DTUm5K9J.js → runtime-DoYPE6g6.js} +24 -24
- package/dist/manager/_manager-chunks/{runtime-Cn5PJT3-.js → runtime-sppa-0ll.js} +2 -2
- package/dist/manager/globals-runtime.js +1 -1
- package/dist/manager/runtime.js +1 -1
- package/dist/manager-api/index.d.ts +1 -1
- package/dist/manager-api/index.js +1 -1
- package/dist/manager-errors.d.ts +1 -1
- package/dist/mcp/index.d.ts +10 -10
- package/dist/mcp/index.js +10 -10
- package/dist/mocking-utils/index.js +9 -9
- package/dist/next/index.js +9 -9
- package/dist/nextjs-vite/node/index.js +7 -7
- package/dist/nextjs-vite/preset.js +11 -11
- package/dist/nextjs-vite/vite-plugin/index.js +7 -7
- package/dist/nextjs-vite-plugin/index.js +8 -8
- package/dist/nextjs-vite-plugin/mocks/storybook.global.js +8 -8
- package/dist/node-logger/index.d.ts +8 -2
- package/dist/node-logger/index.js +9 -9
- package/dist/oxc-parser/index.js +10 -10
- package/dist/oxc-parser/worker.js +10 -10
- package/dist/preview/_chunks/{runtime-C88AzFBv.js → runtime-Cbq5WjbL.js} +2 -2
- package/dist/preview/_chunks/{runtime-Cpzxe5eK.js → runtime-DDEUZops.js} +12 -16
- package/dist/preview/_chunks/{runtime-BiYuZt-X.js → runtime-DsjyhLpG.js} +8 -6
- package/dist/preview/_chunks/{runtime-MYVHRAoo.js → runtime-Dwi6NFcX.js} +2 -2
- package/dist/preview/runtime.js +1 -1
- package/dist/preview-api/index.d.ts +2 -2
- package/dist/preview-api/index.js +1 -1
- package/dist/preview-errors.d.ts +1 -1
- package/dist/react/docgen/docgen-worker.js +11 -11
- package/dist/react/preset.js +13 -13
- package/dist/react-native/bin/get-stories.js +8 -8
- package/dist/react-native/metro/node.js +10 -10
- package/dist/react-native/metro/withForkbook.js +11 -11
- package/dist/react-native/scripts/generate.js +8 -8
- package/dist/react-vite/node/index.js +7 -7
- package/dist/react-vite/preset.js +8 -8
- package/dist/server-errors.d.ts +1 -1
- package/dist/server-errors.js +9 -9
- package/dist/shared/open-service/index.d.ts +1 -1
- package/dist/shared/open-service/services/docgen/worker/docgen-worker.js +9 -9
- package/dist/telemetry/index.js +11 -11
- package/dist/types/index.d.ts +2 -2
- package/package.json +1 -1
- package/dist/_node-chunks/chunk-CGVVOUBC.js +0 -18
- package/dist/_node-chunks/chunk-QQNRWEHL.js +0 -972
- package/dist/_node-chunks/chunk-RAIWLNFA.js +0 -30606
- package/dist/_node-chunks/chunk-VYCVBW5Q.js +0 -92
- package/dist/_node-chunks/chunk-WYCITRIE.js +0 -11
- package/dist/_node-chunks/chunk-ZHRCL7PG.js +0 -148
- package/dist/_node-chunks/dist-HBFOS25E.js +0 -16
- package/dist/_node-chunks/dist-Q2XNFC24.js +0 -27
- package/dist/_node-chunks/optimized-tests-DOKSUJAM.js +0 -22
- package/dist/_node-chunks/postinstallAddon-L46G75CD.js +0 -20
- package/dist/chunk-CDMZhRke.d.ts +0 -30
|
@@ -1,46 +1,24 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_wrk1cj8d1xj from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_wrk1cj8d1xj from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_wrk1cj8d1xj from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_wrk1cj8d1xj.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_wrk1cj8d1xj.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_wrk1cj8d1xj.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Forkbook's esbuild configuration
|
|
11
11
|
// ------------------------------------------------------------
|
|
12
12
|
import {
|
|
13
13
|
require_dist
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-CVHDAEDZ.js";
|
|
15
|
+
import {
|
|
16
|
+
RN_FORKBOOK_DIR
|
|
17
|
+
} from "./chunk-C6HQ6WLU.js";
|
|
15
18
|
import {
|
|
16
19
|
cache,
|
|
17
20
|
up as up3
|
|
18
|
-
} from "./chunk-
|
|
19
|
-
import {
|
|
20
|
-
FORKBOOK_PACKAGE_PATTERNS,
|
|
21
|
-
FORKBOOK_RERUN_INSTRUCTION,
|
|
22
|
-
JsPackageManager,
|
|
23
|
-
defaultConfigDir,
|
|
24
|
-
extractFrameworkPackageName,
|
|
25
|
-
frameworkPackages,
|
|
26
|
-
getAddonNames,
|
|
27
|
-
getAgeInMinutes,
|
|
28
|
-
getConfigInfo,
|
|
29
|
-
getErrorLogs,
|
|
30
|
-
getInterpretedFile,
|
|
31
|
-
getLatestStableVersionAdheringToMinimumAgeGate,
|
|
32
|
-
getPrettyPackageManagerName,
|
|
33
|
-
getStorybookRerunCommand,
|
|
34
|
-
hasStorybookMinimumAgeExclusions,
|
|
35
|
-
loadMainConfig,
|
|
36
|
-
normalizeAddonName,
|
|
37
|
-
parsePackageData,
|
|
38
|
-
parsePackageTimeMap,
|
|
39
|
-
parsePositiveIntegerConfigValue,
|
|
40
|
-
parseReleaseTime,
|
|
41
|
-
validateConfigurationFiles,
|
|
42
|
-
versions_default
|
|
43
|
-
} from "./chunk-QQNRWEHL.js";
|
|
21
|
+
} from "./chunk-ROJ6RSIJ.js";
|
|
44
22
|
import {
|
|
45
23
|
createModuleResolver,
|
|
46
24
|
isSelfContained,
|
|
@@ -48,42 +26,45 @@ import {
|
|
|
48
26
|
resolveReferencedValue,
|
|
49
27
|
sourceOf,
|
|
50
28
|
unwrapExpression
|
|
51
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-LYS7TI35.js";
|
|
52
30
|
import {
|
|
53
31
|
logger
|
|
54
|
-
} from "./chunk-
|
|
55
|
-
import {
|
|
56
|
-
STORY_FILE_TEST_REGEXP,
|
|
57
|
-
exec,
|
|
58
|
-
execNode,
|
|
59
|
-
execSync,
|
|
60
|
-
getStoryImportPathFromEntry
|
|
61
|
-
} from "./chunk-LAJIVWUF.js";
|
|
32
|
+
} from "./chunk-MDTXL6SN.js";
|
|
62
33
|
import {
|
|
63
34
|
BUN_LOCKFILE,
|
|
64
35
|
BUN_LOCKFILE_BINARY,
|
|
65
36
|
NPM_LOCKFILE,
|
|
66
37
|
PNPM_LOCKFILE,
|
|
38
|
+
STORY_FILE_TEST_REGEXP,
|
|
67
39
|
YARN_LOCKFILE,
|
|
40
|
+
exec,
|
|
41
|
+
execNode,
|
|
42
|
+
execSync,
|
|
43
|
+
findFilesUp,
|
|
68
44
|
getProjectRoot,
|
|
45
|
+
getStoryImportPathFromEntry,
|
|
69
46
|
normalizeStoryPath
|
|
70
|
-
} from "./chunk-
|
|
47
|
+
} from "./chunk-53A5CYDK.js";
|
|
71
48
|
import {
|
|
72
49
|
any,
|
|
73
50
|
from,
|
|
74
51
|
up,
|
|
75
52
|
up2
|
|
76
|
-
} from "./chunk-
|
|
53
|
+
} from "./chunk-MX5MVLEK.js";
|
|
54
|
+
import {
|
|
55
|
+
invariant
|
|
56
|
+
} from "./chunk-GQUFGJ4D.js";
|
|
77
57
|
import {
|
|
78
58
|
importModule,
|
|
79
59
|
resolveModulePath,
|
|
80
60
|
resolvePackageDir,
|
|
81
61
|
safeResolveModule
|
|
82
|
-
} from "./chunk-
|
|
62
|
+
} from "./chunk-PC57BIYZ.js";
|
|
83
63
|
import {
|
|
84
64
|
jsModuleExtensions,
|
|
85
|
-
jsTsSourceExtensions
|
|
86
|
-
|
|
65
|
+
jsTsSourceExtensions,
|
|
66
|
+
storybookConfigExtensions
|
|
67
|
+
} from "./chunk-7IAYDGYH.js";
|
|
87
68
|
import {
|
|
88
69
|
ExecaCommandFailedError,
|
|
89
70
|
PackageInstallDependencyConflictError,
|
|
@@ -94,29 +75,70 @@ import {
|
|
|
94
75
|
PnpmIgnoredBuildsError,
|
|
95
76
|
PnpmNoTtyModulesDirError,
|
|
96
77
|
StorybookError
|
|
97
|
-
} from "./chunk-
|
|
78
|
+
} from "./chunk-HGJMP4EI.js";
|
|
98
79
|
import {
|
|
99
80
|
require_picocolors
|
|
100
|
-
} from "./chunk-
|
|
81
|
+
} from "./chunk-HCDG54OG.js";
|
|
101
82
|
import {
|
|
102
83
|
slash
|
|
103
|
-
} from "./chunk-
|
|
84
|
+
} from "./chunk-3H5C52QU.js";
|
|
104
85
|
import {
|
|
86
|
+
glob,
|
|
105
87
|
globSync
|
|
106
|
-
} from "./chunk-
|
|
88
|
+
} from "./chunk-TTLSBLPQ.js";
|
|
107
89
|
import {
|
|
108
90
|
require_picomatch
|
|
109
|
-
} from "./chunk-
|
|
91
|
+
} from "./chunk-Z6CUUWJO.js";
|
|
110
92
|
import {
|
|
111
93
|
__toESM
|
|
112
|
-
} from "./chunk-
|
|
94
|
+
} from "./chunk-YMJVSFJT.js";
|
|
95
|
+
|
|
96
|
+
// src/common/versions.ts
|
|
97
|
+
var versions_default = { "@aussieljk/forkbook": "0.0.1-21" };
|
|
113
98
|
|
|
114
99
|
// src/common/presets.ts
|
|
115
100
|
import { logger as logger2 } from "@aussieljk/forkbook/internal/node-logger";
|
|
116
101
|
import { CriticalPresetLoadError } from "@aussieljk/forkbook/internal/server-errors";
|
|
117
102
|
import { readFileSync } from "node:fs";
|
|
118
|
-
import { isAbsolute, join, parse, resolve } from "pathe";
|
|
119
|
-
import { dedent } from "ts-dedent";
|
|
103
|
+
import { isAbsolute, join, parse, resolve as resolve2 } from "pathe";
|
|
104
|
+
import { dedent as dedent2 } from "ts-dedent";
|
|
105
|
+
|
|
106
|
+
// src/common/utils/interpret-files.ts
|
|
107
|
+
import { existsSync } from "node:fs";
|
|
108
|
+
import { extname } from "node:path";
|
|
109
|
+
var typescriptFallbackExtensions = {
|
|
110
|
+
".js": [".ts", ".tsx"],
|
|
111
|
+
".mjs": [".mts"],
|
|
112
|
+
".cjs": [".cts"],
|
|
113
|
+
".jsx": [".tsx"]
|
|
114
|
+
}, supportedExtensions = storybookConfigExtensions;
|
|
115
|
+
function getInterpretedFile(pathToFile) {
|
|
116
|
+
return supportedExtensions.map((ext) => pathToFile.endsWith(ext) ? pathToFile : `${pathToFile}${ext}`).find((candidate) => existsSync(candidate));
|
|
117
|
+
}
|
|
118
|
+
var importResolver = createModuleResolver({
|
|
119
|
+
extensions: [...supportedExtensions],
|
|
120
|
+
mainFields: ["module", "main"]
|
|
121
|
+
});
|
|
122
|
+
function resolveImport(id, options) {
|
|
123
|
+
try {
|
|
124
|
+
return resolveSync(id, options.basedir);
|
|
125
|
+
} catch (error) {
|
|
126
|
+
let ext = extname(id), fallbackExtensions = typescriptFallbackExtensions[ext];
|
|
127
|
+
if (!fallbackExtensions)
|
|
128
|
+
throw error;
|
|
129
|
+
let fallbackError = error, baseId = id.slice(0, -ext.length);
|
|
130
|
+
for (let fallbackExtension of fallbackExtensions)
|
|
131
|
+
try {
|
|
132
|
+
return resolveSync(`${baseId}${fallbackExtension}`, options.basedir);
|
|
133
|
+
} catch (err) {
|
|
134
|
+
fallbackError = err;
|
|
135
|
+
}
|
|
136
|
+
throw fallbackError;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
function resolveSync(id, basedir) {
|
|
140
|
+
return importResolver.resolveSync(basedir, id);
|
|
141
|
+
}
|
|
120
142
|
|
|
121
143
|
// src/common/utils/strip-abs-node-modules-path.ts
|
|
122
144
|
import { posix, sep } from "node:path";
|
|
@@ -128,6 +150,23 @@ function stripAbsNodeModulesPath(absPath) {
|
|
|
128
150
|
return normalizePath(splits[splits.length - 1]);
|
|
129
151
|
}
|
|
130
152
|
|
|
153
|
+
// src/common/utils/validate-configuration-files.ts
|
|
154
|
+
import { resolve } from "node:path";
|
|
155
|
+
import { once } from "@aussieljk/forkbook/internal/node-logger";
|
|
156
|
+
import { MainFileMissingError } from "@aussieljk/forkbook/internal/server-errors";
|
|
157
|
+
import { dedent } from "ts-dedent";
|
|
158
|
+
async function validateConfigurationFiles(configDir, cwd) {
|
|
159
|
+
let extensionsPattern = `{${Array.from(supportedExtensions).join(",")}}`, mainConfigMatches = await glob(slash(resolve(configDir, `main${extensionsPattern}`)), {
|
|
160
|
+
cwd: cwd ?? process.cwd(),
|
|
161
|
+
expandDirectories: !1
|
|
162
|
+
}), [mainConfigPath] = mainConfigMatches;
|
|
163
|
+
if (mainConfigMatches.length > 1 && once.warn(dedent`
|
|
164
|
+
Multiple main files found in your configDir (${resolve(configDir)}).
|
|
165
|
+
Forkbook will use the first one found and ignore the others. Please remove the extra files.
|
|
166
|
+
`), !mainConfigPath)
|
|
167
|
+
throw new MainFileMissingError({ location: configDir });
|
|
168
|
+
}
|
|
169
|
+
|
|
131
170
|
// src/common/presets.ts
|
|
132
171
|
var isObject = (val) => val != null && typeof val == "object" && Array.isArray(val) === !1, isFunction = (val) => typeof val == "function";
|
|
133
172
|
function resolvePresetFunction(input, presetOptions, storybookOptions) {
|
|
@@ -186,7 +225,7 @@ ${item}`
|
|
|
186
225
|
if (!resolved) {
|
|
187
226
|
let packageName = isAbsolute(name) ? readAddonManifest(name)?.name : void 0;
|
|
188
227
|
logger2.warn(
|
|
189
|
-
packageName ?
|
|
228
|
+
packageName ? dedent2`
|
|
190
229
|
Could not resolve addon "${packageName}", skipping.
|
|
191
230
|
It is installed at ${name}, but none of its preset, manager or preview entry points could be resolved.
|
|
192
231
|
If your main config wraps it in getAbsolutePath(), try referencing "${packageName}" directly instead.
|
|
@@ -240,7 +279,7 @@ async function loadPreset(input, level, storybookOptions) {
|
|
|
240
279
|
}
|
|
241
280
|
];
|
|
242
281
|
}
|
|
243
|
-
throw new Error(
|
|
282
|
+
throw new Error(dedent2`
|
|
244
283
|
${input} is not a valid preset
|
|
245
284
|
`);
|
|
246
285
|
} catch (error) {
|
|
@@ -291,7 +330,7 @@ async function getPresets(presets, storybookOptions) {
|
|
|
291
330
|
async function loadAllPresets(options) {
|
|
292
331
|
let { corePresets = [], overridePresets = [], ...restOptions } = options;
|
|
293
332
|
validateConfigurationFiles(options.configDir);
|
|
294
|
-
let mainUrl = getInterpretedFile(
|
|
333
|
+
let mainUrl = getInterpretedFile(resolve2(options.configDir, "main")), presetsConfig = [...corePresets, mainUrl, ...overridePresets];
|
|
295
334
|
return getPresets(presetsConfig, restOptions);
|
|
296
335
|
}
|
|
297
336
|
|
|
@@ -311,7 +350,7 @@ async function writeFileWithRetry(file, data, options) {
|
|
|
311
350
|
return;
|
|
312
351
|
} catch (err) {
|
|
313
352
|
if (attempt < 5 && err instanceof Error && "code" in err && err.code === "EBUSY")
|
|
314
|
-
await new Promise((
|
|
353
|
+
await new Promise((resolve10) => setTimeout(resolve10, 100));
|
|
315
354
|
else
|
|
316
355
|
throw err;
|
|
317
356
|
}
|
|
@@ -405,18 +444,18 @@ function createFileSystemCache(options) {
|
|
|
405
444
|
return new FileSystemCache(options);
|
|
406
445
|
}
|
|
407
446
|
|
|
408
|
-
// src/common/utils/resolve-path-in-
|
|
447
|
+
// src/common/utils/resolve-path-in-cache.ts
|
|
409
448
|
import { join as join3 } from "node:path";
|
|
410
|
-
function
|
|
411
|
-
let cacheDirectory = cache("
|
|
412
|
-
cacheDirectory ||= join3(process.cwd(), "node_modules", ".cache", "
|
|
449
|
+
function resolvePathInForkbookCache(fileOrDirectoryName, sub = "default") {
|
|
450
|
+
let cacheDirectory = cache("forkbook");
|
|
451
|
+
cacheDirectory ||= join3(process.cwd(), "node_modules", ".cache", "forkbook");
|
|
413
452
|
let version = versions_default["@aussieljk/forkbook"] || "unknown";
|
|
414
453
|
return join3(cacheDirectory, version, sub, fileOrDirectoryName);
|
|
415
454
|
}
|
|
416
455
|
|
|
417
456
|
// src/common/utils/cache.ts
|
|
418
457
|
var cache2 = createFileSystemCache({
|
|
419
|
-
basePath:
|
|
458
|
+
basePath: resolvePathInForkbookCache("dev-server"),
|
|
420
459
|
ns: "forkbook"
|
|
421
460
|
// A grouping namespace for items.
|
|
422
461
|
});
|
|
@@ -459,15 +498,15 @@ function parseList(str) {
|
|
|
459
498
|
function getEnvConfig(program, configEnv) {
|
|
460
499
|
Object.keys(configEnv).forEach((fieldName) => {
|
|
461
500
|
let envVarName = configEnv[fieldName], envVarValue = process.env[envVarName];
|
|
462
|
-
envVarValue && (program[fieldName] = envVarValue);
|
|
501
|
+
envVarValue && !program[fieldName] && (program[fieldName] = envVarValue);
|
|
463
502
|
});
|
|
464
503
|
}
|
|
465
504
|
var createLogStream = async (logFileName = "forkbook.log") => {
|
|
466
505
|
let finalLogPath = join4(process.cwd(), logFileName), temporaryLogPath = await temporaryFile({ name: logFileName }), logStream = createWriteStream(temporaryLogPath, { encoding: "utf8" });
|
|
467
|
-
return new Promise((
|
|
506
|
+
return new Promise((resolve10, reject) => {
|
|
468
507
|
logStream.once("open", () => {
|
|
469
508
|
let clearLogFile = async () => writeFile2(temporaryLogPath, ""), removeLogFile = async () => rm2(temporaryLogPath, { recursive: !0, force: !0 });
|
|
470
|
-
|
|
509
|
+
resolve10({ logStream, moveLogFile: async () => copyFile(temporaryLogPath, finalLogPath).then(removeLogFile), clearLogFile, removeLogFile, readLogFile: async () => readFile2(temporaryLogPath, { encoding: "utf8" }) });
|
|
471
510
|
}), logStream.once("error", reject);
|
|
472
511
|
});
|
|
473
512
|
}, isCorePackage = (pkg) => pkg === "@aussieljk/forkbook" || pkg.startsWith("@aussieljk/forkbook/"), isSatelliteAddon = (pkg) => satellite_addons_default.includes(pkg);
|
|
@@ -528,7 +567,7 @@ function readManifestName(dir) {
|
|
|
528
567
|
}
|
|
529
568
|
|
|
530
569
|
// src/common/utils/common-glob-options.ts
|
|
531
|
-
var NODE_MODULES_RE = /node_modules/, commonGlobOptions = (
|
|
570
|
+
var NODE_MODULES_RE = /node_modules/, commonGlobOptions = (glob2) => NODE_MODULES_RE.test(glob2) ? {} : { ignore: ["**/node_modules/**"] };
|
|
532
571
|
|
|
533
572
|
// src/common/utils/deep-merge.ts
|
|
534
573
|
function deepMerge(target, source) {
|
|
@@ -538,6 +577,30 @@ function deepMerge(target, source) {
|
|
|
538
577
|
return result;
|
|
539
578
|
}
|
|
540
579
|
|
|
580
|
+
// src/common/utils/default-config-dir.ts
|
|
581
|
+
function defaultConfigDir() {
|
|
582
|
+
return ".forkbook";
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
// src/common/utils/framework.ts
|
|
586
|
+
import {
|
|
587
|
+
SupportedBuilder,
|
|
588
|
+
SupportedFramework,
|
|
589
|
+
SupportedRenderer
|
|
590
|
+
} from "@aussieljk/forkbook/internal/types";
|
|
591
|
+
var frameworkToRenderer = {
|
|
592
|
+
// frameworks
|
|
593
|
+
[SupportedFramework.NEXTJS_VITE]: SupportedRenderer.REACT,
|
|
594
|
+
[SupportedFramework.REACT_VITE]: SupportedRenderer.REACT,
|
|
595
|
+
// renderers
|
|
596
|
+
[SupportedRenderer.REACT_NATIVE]: SupportedRenderer.REACT_NATIVE,
|
|
597
|
+
[SupportedRenderer.REACT]: SupportedRenderer.REACT
|
|
598
|
+
}, frameworkToBuilder = {
|
|
599
|
+
// frameworks
|
|
600
|
+
[SupportedFramework.NEXTJS_VITE]: SupportedBuilder.VITE,
|
|
601
|
+
[SupportedFramework.REACT_VITE]: SupportedBuilder.VITE
|
|
602
|
+
};
|
|
603
|
+
|
|
541
604
|
// src/common/utils/get-builder-options.ts
|
|
542
605
|
async function getBuilderOptions(options) {
|
|
543
606
|
let framework = await options.presets.apply("framework", {}, options);
|
|
@@ -547,6 +610,17 @@ async function getBuilderOptions(options) {
|
|
|
547
610
|
return typeof builder != "string" && builder?.options ? builder.options : {};
|
|
548
611
|
}
|
|
549
612
|
|
|
613
|
+
// src/common/utils/get-pkg-pr-new-package-specifier.ts
|
|
614
|
+
var PKG_PR_NEW_FORKBOOK_SPECIFIER_RE = /^(https?:\/\/[^/\s]*pkg\.pr\.new\/(?:[^@\s/]+\/[^@\s/]+\/)?)(?:create-storybook|storybook|@storybook\/[^@\s]+)(@[^\s]+)$/, isPkgPrNewVersionSpecifier = (storybookVersionSpecifier) => !!storybookVersionSpecifier?.match(PKG_PR_NEW_FORKBOOK_SPECIFIER_RE), getPkgPrNewPackageSpecifier = (packageName, storybookVersionSpecifier) => {
|
|
615
|
+
if (!storybookVersionSpecifier)
|
|
616
|
+
return;
|
|
617
|
+
let match = storybookVersionSpecifier.match(PKG_PR_NEW_FORKBOOK_SPECIFIER_RE);
|
|
618
|
+
if (!match)
|
|
619
|
+
return;
|
|
620
|
+
let [, prefix, suffix] = match;
|
|
621
|
+
return `${prefix}${packageName}${suffix}`;
|
|
622
|
+
};
|
|
623
|
+
|
|
550
624
|
// src/common/utils/get-storybook-version-specifier-from-ancestry.ts
|
|
551
625
|
var PKG_PR_NEW_CLI_SPECIFIER_IN_TEXT_RE = /https?:\/\/[^/\s'"]*pkg\.pr\.new\/(?:[^@\s/]+\/[^@\s/]+\/)?(?:create-storybook|storybook)@[^\s'"]+/, PACKAGE_AT_SPECIFIER_RE = /\s@aussieljk\/forkbook@([^\s'"]+)/, stripQuotedUrls = (command) => command.replace(/['"](https?:\/\/[^'"]+)['"]/g, "$1"), getStorybookVersionSpecifierFromAncestry = (ancestry) => {
|
|
552
626
|
for (let ancestor of ancestry.toReversed()) {
|
|
@@ -568,37 +642,881 @@ var FORKBOOK_VERSION_SPECIFIER_ENV = "FORKBOOK_VERSION_SPECIFIER", resolveStoryb
|
|
|
568
642
|
return fromEnv || getStorybookVersionSpecifierFromAncestry(ancestry);
|
|
569
643
|
};
|
|
570
644
|
|
|
645
|
+
// src/common/utils/get-framework-name.ts
|
|
646
|
+
import { dedent as dedent4 } from "ts-dedent";
|
|
647
|
+
|
|
648
|
+
// src/common/utils/get-storybook-info.ts
|
|
649
|
+
import { existsSync as existsSync2, readFileSync as readFileSync5 } from "node:fs";
|
|
650
|
+
import { basename, dirname as dirname3, join as join8 } from "node:path";
|
|
651
|
+
import {
|
|
652
|
+
SupportedBuilder as SupportedBuilder2,
|
|
653
|
+
SupportedFramework as SupportedFramework2,
|
|
654
|
+
SupportedRenderer as SupportedRenderer2
|
|
655
|
+
} from "@aussieljk/forkbook/internal/types";
|
|
656
|
+
|
|
657
|
+
// src/common/js-package-manager/JsPackageManager.ts
|
|
658
|
+
import { readFileSync as readFileSync4, writeFileSync as writeFileSync2 } from "node:fs";
|
|
659
|
+
import { dirname as dirname2, isAbsolute as isAbsolute2, join as join6, normalize as normalize2, resolve as resolve3 } from "node:path";
|
|
660
|
+
import { logger as logger5, prompt } from "@aussieljk/forkbook/internal/node-logger";
|
|
661
|
+
|
|
662
|
+
// ../../node_modules/detect-indent/index.js
|
|
663
|
+
var INDENT_REGEX = /^(?:( )+|\t+)/, INDENT_TYPE_SPACE = "space";
|
|
664
|
+
function shouldIgnoreSingleSpace(ignoreSingleSpaces, indentType, value) {
|
|
665
|
+
return ignoreSingleSpaces && indentType === INDENT_TYPE_SPACE && value === 1;
|
|
666
|
+
}
|
|
667
|
+
function makeIndentsMap(string, ignoreSingleSpaces) {
|
|
668
|
+
let indents = /* @__PURE__ */ new Map(), previousSize = 0, previousIndentType, key;
|
|
669
|
+
for (let line of string.split(/\n/g)) {
|
|
670
|
+
if (!line)
|
|
671
|
+
continue;
|
|
672
|
+
let matches = line.match(INDENT_REGEX);
|
|
673
|
+
if (matches === null)
|
|
674
|
+
previousSize = 0, previousIndentType = "";
|
|
675
|
+
else {
|
|
676
|
+
let indent = matches[0].length, indentType = matches[1] ? INDENT_TYPE_SPACE : "tab";
|
|
677
|
+
if (shouldIgnoreSingleSpace(ignoreSingleSpaces, indentType, indent))
|
|
678
|
+
continue;
|
|
679
|
+
indentType !== previousIndentType && (previousSize = 0), previousIndentType = indentType;
|
|
680
|
+
let use = 1, weight = 0, indentDifference = indent - previousSize;
|
|
681
|
+
if (previousSize = indent, indentDifference === 0)
|
|
682
|
+
use = 0, weight = 1;
|
|
683
|
+
else {
|
|
684
|
+
let absoluteIndentDifference = Math.abs(indentDifference);
|
|
685
|
+
if (shouldIgnoreSingleSpace(ignoreSingleSpaces, indentType, absoluteIndentDifference))
|
|
686
|
+
continue;
|
|
687
|
+
key = encodeIndentsKey(indentType, absoluteIndentDifference);
|
|
688
|
+
}
|
|
689
|
+
let entry = indents.get(key);
|
|
690
|
+
indents.set(key, entry === void 0 ? [1, 0] : [entry[0] + use, entry[1] + weight]);
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
return indents;
|
|
694
|
+
}
|
|
695
|
+
function encodeIndentsKey(indentType, indentAmount) {
|
|
696
|
+
return (indentType === INDENT_TYPE_SPACE ? "s" : "t") + String(indentAmount);
|
|
697
|
+
}
|
|
698
|
+
function decodeIndentsKey(indentsKey) {
|
|
699
|
+
let type = indentsKey[0] === "s" ? INDENT_TYPE_SPACE : "tab", amount = Number(indentsKey.slice(1));
|
|
700
|
+
return { type, amount };
|
|
701
|
+
}
|
|
702
|
+
function getMostUsedKey(indents) {
|
|
703
|
+
let result, maxUsed = 0, maxWeight = 0;
|
|
704
|
+
for (let [key, [usedCount, weight]] of indents)
|
|
705
|
+
(usedCount > maxUsed || usedCount === maxUsed && weight > maxWeight) && (maxUsed = usedCount, maxWeight = weight, result = key);
|
|
706
|
+
return result;
|
|
707
|
+
}
|
|
708
|
+
function makeIndentString(type, amount) {
|
|
709
|
+
return (type === INDENT_TYPE_SPACE ? " " : " ").repeat(amount);
|
|
710
|
+
}
|
|
711
|
+
function detectIndent(string) {
|
|
712
|
+
if (typeof string != "string")
|
|
713
|
+
throw new TypeError("Expected a string");
|
|
714
|
+
let indents = makeIndentsMap(string, !0);
|
|
715
|
+
indents.size === 0 && (indents = makeIndentsMap(string, !1));
|
|
716
|
+
let keyOfMostUsedIndent = getMostUsedKey(indents), type, amount = 0, indent = "";
|
|
717
|
+
return keyOfMostUsedIndent !== void 0 && ({ type, amount } = decodeIndentsKey(keyOfMostUsedIndent), indent = makeIndentString(type, amount)), {
|
|
718
|
+
amount,
|
|
719
|
+
type,
|
|
720
|
+
indent
|
|
721
|
+
};
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
// src/common/js-package-manager/JsPackageManager.ts
|
|
725
|
+
var import_picocolors = __toESM(require_picocolors(), 1);
|
|
726
|
+
import { coerce, gt as gt2, satisfies, validRange } from "semver";
|
|
727
|
+
|
|
728
|
+
// src/common/utils/HandledError.ts
|
|
729
|
+
var HandledError = class extends Error {
|
|
730
|
+
constructor(error) {
|
|
731
|
+
super(String(error));
|
|
732
|
+
this.handled = !0;
|
|
733
|
+
typeof error != "string" && (this.cause = error);
|
|
734
|
+
}
|
|
735
|
+
};
|
|
736
|
+
|
|
737
|
+
// src/common/js-package-manager/util.ts
|
|
738
|
+
import { gt, prerelease, valid } from "semver";
|
|
739
|
+
var FORKBOOK_PACKAGE_PATTERNS = ["@aussieljk/forkbook", "@storybook/*"], escapePatternForRegex = (pattern) => pattern.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), packagePatternToRegex = (pattern) => new RegExp(`^${escapePatternForRegex(pattern).replace(/\\\*/g, ".*")}$`), hasStorybookMinimumAgeExclusions = (configuredPatterns) => FORKBOOK_PACKAGE_PATTERNS.every(
|
|
740
|
+
(storybookPattern) => configuredPatterns.some(
|
|
741
|
+
(configuredPattern) => packagePatternToRegex(configuredPattern).test(storybookPattern)
|
|
742
|
+
)
|
|
743
|
+
), parsePackageData = (packageName = "") => {
|
|
744
|
+
let [first, second, third] = packageName.replace(/[└─├]+/g, "").trim().split("@"), version = (third || second).replace("npm:", "");
|
|
745
|
+
return { name: third ? `@${second}` : first, value: { version, location: "" } };
|
|
746
|
+
}, parsePositiveIntegerConfigValue = (value) => {
|
|
747
|
+
let normalizedValue = value?.trim() ?? "";
|
|
748
|
+
if (!normalizedValue || normalizedValue === "undefined" || normalizedValue === "null" || normalizedValue === "false")
|
|
749
|
+
return null;
|
|
750
|
+
let parsedValue = Number.parseInt(normalizedValue, 10);
|
|
751
|
+
return !Number.isFinite(parsedValue) || parsedValue <= 0 ? null : parsedValue;
|
|
752
|
+
}, parseReleaseTime = (value) => {
|
|
753
|
+
if (typeof value != "string" || value.length === 0)
|
|
754
|
+
return null;
|
|
755
|
+
let releaseTime = new Date(value);
|
|
756
|
+
return Number.isNaN(releaseTime.getTime()) ? null : releaseTime;
|
|
757
|
+
}, parsePackageTimeMap = (value) => {
|
|
758
|
+
if (Array.isArray(value) && value.length === 1 && (value = value[0]), !value || typeof value != "object" || Array.isArray(value))
|
|
759
|
+
return null;
|
|
760
|
+
let timeMap = {};
|
|
761
|
+
for (let [version, releaseTime] of Object.entries(value))
|
|
762
|
+
typeof releaseTime == "string" && releaseTime.length > 0 && (timeMap[version] = releaseTime);
|
|
763
|
+
return timeMap;
|
|
764
|
+
}, getAgeInMinutes = (publishedAt, now = /* @__PURE__ */ new Date()) => Math.floor((now.getTime() - publishedAt.getTime()) / 6e4), getLatestStableVersionAdheringToMinimumAgeGate = (timeMap, minimumAgeGateMinutes, now = /* @__PURE__ */ new Date()) => {
|
|
765
|
+
let cutoff = now.getTime() - minimumAgeGateMinutes * 6e4, latestStableVersion = null;
|
|
766
|
+
for (let [version, releaseTime] of Object.entries(timeMap)) {
|
|
767
|
+
if (!valid(version) || prerelease(version))
|
|
768
|
+
continue;
|
|
769
|
+
let publishedAt = parseReleaseTime(releaseTime);
|
|
770
|
+
!publishedAt || publishedAt.getTime() > cutoff || (!latestStableVersion || gt(version, latestStableVersion)) && (latestStableVersion = version);
|
|
771
|
+
}
|
|
772
|
+
return latestStableVersion;
|
|
773
|
+
};
|
|
774
|
+
function getVitestStorybookRunCommand(packageManager, file) {
|
|
775
|
+
let args = ["vitest", "--project", "storybook", "run"];
|
|
776
|
+
return file && args.push(file), packageManager.getPackageCommand(args);
|
|
777
|
+
}
|
|
778
|
+
function getMswInitCommand(packageManager) {
|
|
779
|
+
return packageManager.getPackageCommand(["msw", "init", "./public", "--save"]);
|
|
780
|
+
}
|
|
781
|
+
var FORKBOOK_RERUN_INSTRUCTION = "Please rerun Forkbook creation with:", getStorybookRerunCommand = (compatibleVersion) => compatibleVersion ? `npx @aussieljk/forkbook@${compatibleVersion} init` : "npx @aussieljk/forkbook@<compatible-version> init", getErrorLogs = (error) => {
|
|
782
|
+
if (typeof error == "string")
|
|
783
|
+
return error;
|
|
784
|
+
if (error && typeof error == "object") {
|
|
785
|
+
let structuredError = error, structuredLogs = [
|
|
786
|
+
structuredError.shortMessage,
|
|
787
|
+
structuredError.originalMessage,
|
|
788
|
+
structuredError.stderr,
|
|
789
|
+
structuredError.stdout,
|
|
790
|
+
structuredError.message
|
|
791
|
+
].filter((entry) => typeof entry == "string" && entry.length > 0);
|
|
792
|
+
if (structuredLogs.length > 0)
|
|
793
|
+
return structuredLogs.join(`
|
|
794
|
+
`);
|
|
795
|
+
}
|
|
796
|
+
return String(error);
|
|
797
|
+
}, INSTALL_ERROR_TAIL_LINES = 15, getInstallErrorTail = (error, lines = INSTALL_ERROR_TAIL_LINES) => {
|
|
798
|
+
let output = getErrorLogs(error).trimEnd();
|
|
799
|
+
return output ? output.split(`
|
|
800
|
+
`).slice(-lines).join(`
|
|
801
|
+
`).trim() : "";
|
|
802
|
+
};
|
|
803
|
+
|
|
804
|
+
// src/common/js-package-manager/vite-plus-versions.ts
|
|
805
|
+
import { logger as logger4 } from "@aussieljk/forkbook/internal/node-logger";
|
|
806
|
+
var cachedVersions;
|
|
807
|
+
async function getVitePlusVersions() {
|
|
808
|
+
if (cachedVersions !== void 0)
|
|
809
|
+
return cachedVersions;
|
|
810
|
+
try {
|
|
811
|
+
let mod = await import("vite-plus/versions"), versions = mod.versions ?? mod;
|
|
812
|
+
if (versions && typeof versions.vite == "string")
|
|
813
|
+
return logger4.debug(`Detected vite-plus: vite=${versions.vite}, vitest=${versions.vitest ?? "N/A"}`), cachedVersions = versions, versions;
|
|
814
|
+
} catch {
|
|
815
|
+
}
|
|
816
|
+
return cachedVersions = null, null;
|
|
817
|
+
}
|
|
818
|
+
function clearVitePlusCache() {
|
|
819
|
+
cachedVersions = void 0;
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
// src/common/js-package-manager/JsPackageManager.ts
|
|
823
|
+
var PackageManagerName = /* @__PURE__ */ ((PackageManagerName2) => (PackageManagerName2.NPM = "npm", PackageManagerName2.YARN1 = "yarn1", PackageManagerName2.YARN2 = "yarn2", PackageManagerName2.PNPM = "pnpm", PackageManagerName2.BUN = "bun", PackageManagerName2))(PackageManagerName || {}), indentSymbol = /* @__PURE__ */ Symbol("indent"), PACKAGE_MANAGER_LABEL = {
|
|
824
|
+
npm: "npm",
|
|
825
|
+
yarn1: "Yarn Classic (v1)",
|
|
826
|
+
yarn2: "Yarn Berry",
|
|
827
|
+
pnpm: "pnpm",
|
|
828
|
+
bun: "Bun"
|
|
829
|
+
};
|
|
830
|
+
function isValidPackageManagerName(name) {
|
|
831
|
+
return Object.hasOwn(PACKAGE_MANAGER_LABEL, name);
|
|
832
|
+
}
|
|
833
|
+
function getPrettyPackageManagerName(packageManager) {
|
|
834
|
+
return packageManager ? isValidPackageManagerName(packageManager) ? PACKAGE_MANAGER_LABEL[packageManager] : packageManager : "unknown package manager";
|
|
835
|
+
}
|
|
836
|
+
function getPackageDetails(pkg) {
|
|
837
|
+
let isScopedPackage = pkg.startsWith("@"), scopeSeparatorIndex = isScopedPackage ? pkg.indexOf("/") : -1, versionSeparatorIndex = isScopedPackage ? scopeSeparatorIndex === -1 ? -1 : pkg.indexOf("@", scopeSeparatorIndex + 1) : pkg.indexOf("@");
|
|
838
|
+
if (versionSeparatorIndex <= 0)
|
|
839
|
+
return [pkg, void 0];
|
|
840
|
+
let packageName = pkg.slice(0, versionSeparatorIndex), packageVersion = pkg.slice(versionSeparatorIndex + 1);
|
|
841
|
+
return [packageName, packageVersion];
|
|
842
|
+
}
|
|
843
|
+
var JsPackageManager = class _JsPackageManager {
|
|
844
|
+
static {
|
|
845
|
+
/** Cache for latest version results to avoid repeated network calls. */
|
|
846
|
+
this.latestVersionCache = /* @__PURE__ */ new Map();
|
|
847
|
+
}
|
|
848
|
+
static {
|
|
849
|
+
/** Cache for installed version results to avoid repeated file system calls. */
|
|
850
|
+
this.installedVersionCache = /* @__PURE__ */ new Map();
|
|
851
|
+
}
|
|
852
|
+
static {
|
|
853
|
+
/** Cache for package.json files to avoid repeated file system calls. */
|
|
854
|
+
this.packageJsonCache = /* @__PURE__ */ new Map();
|
|
855
|
+
}
|
|
856
|
+
constructor(options) {
|
|
857
|
+
this.cwd = options?.cwd || process.cwd(), this.instanceDir = options?.configDir ? isAbsolute2(options?.configDir) ? dirname2(options?.configDir) : dirname2(join6(this.cwd, options?.configDir)) : this.cwd, this.packageJsonPaths = _JsPackageManager.listAllPackageJsonPaths(
|
|
858
|
+
this.instanceDir,
|
|
859
|
+
options?.storiesPaths
|
|
860
|
+
), this.primaryPackageJson = this.#getPrimaryPackageJson();
|
|
861
|
+
}
|
|
862
|
+
isStorybookInMonorepo() {
|
|
863
|
+
let turboJsonPath = up2("turbo.json", { last: getProjectRoot() }), rushJsonPath = up2("rush.json", { last: getProjectRoot() }), nxJsonPath = up2("nx.json", { last: getProjectRoot() });
|
|
864
|
+
if (turboJsonPath || rushJsonPath || nxJsonPath)
|
|
865
|
+
return !0;
|
|
866
|
+
let packageJsonPaths = findFilesUp(["package.json"]);
|
|
867
|
+
if (packageJsonPaths.length === 0)
|
|
868
|
+
return !1;
|
|
869
|
+
for (let packageJsonPath of packageJsonPaths) {
|
|
870
|
+
let packageJsonFile = readFileSync4(packageJsonPath, "utf8");
|
|
871
|
+
if (JSON.parse(packageJsonFile).workspaces)
|
|
872
|
+
return !0;
|
|
873
|
+
}
|
|
874
|
+
return !1;
|
|
875
|
+
}
|
|
876
|
+
async installDependencies(options) {
|
|
877
|
+
try {
|
|
878
|
+
await prompt.executeTaskWithSpinner(() => this.runInstall(options), {
|
|
879
|
+
id: "install-dependencies",
|
|
880
|
+
intro: "Installing dependencies...",
|
|
881
|
+
error: "Installation of dependencies failed!",
|
|
882
|
+
success: "Dependencies installed"
|
|
883
|
+
});
|
|
884
|
+
} catch (error) {
|
|
885
|
+
let tail = getInstallErrorTail(error);
|
|
886
|
+
throw tail && (logger5.error(tail), error instanceof Error && !error.message.includes(tail) && (error.message = `${error.message}
|
|
887
|
+
|
|
888
|
+
${tail}`)), error;
|
|
889
|
+
}
|
|
890
|
+
this.clearInstalledVersionCache();
|
|
891
|
+
}
|
|
892
|
+
async precheckStorybookPackageInstall(options) {
|
|
893
|
+
}
|
|
894
|
+
async dedupeDependencies(options) {
|
|
895
|
+
await prompt.executeTask(
|
|
896
|
+
(_signal) => this.runInternalCommand("dedupe", [...options?.force ? ["--force"] : []], this.cwd),
|
|
897
|
+
{
|
|
898
|
+
intro: "Deduplicating dependencies...",
|
|
899
|
+
error: "An error occurred while deduplicating dependencies.",
|
|
900
|
+
success: "Dependencies deduplicated"
|
|
901
|
+
}
|
|
902
|
+
), this.clearInstalledVersionCache();
|
|
903
|
+
}
|
|
904
|
+
/** Read the `package.json` file available in the provided directory */
|
|
905
|
+
static getPackageJson(packageJsonPath) {
|
|
906
|
+
let absolutePath = normalize2(resolve3(packageJsonPath)), cached = _JsPackageManager.packageJsonCache.get(absolutePath);
|
|
907
|
+
if (cached)
|
|
908
|
+
return logger5.debug(`Using cached package.json for ${absolutePath}...`), cached;
|
|
909
|
+
let jsonContent = readFileSync4(absolutePath, "utf8"), packageJSON = JSON.parse(jsonContent);
|
|
910
|
+
packageJSON[indentSymbol] = detectIndent(jsonContent).indent ?? 2;
|
|
911
|
+
let result = {
|
|
912
|
+
...packageJSON,
|
|
913
|
+
dependencies: { ...packageJSON.dependencies || {} },
|
|
914
|
+
devDependencies: { ...packageJSON.devDependencies || {} },
|
|
915
|
+
peerDependencies: { ...packageJSON.peerDependencies || {} }
|
|
916
|
+
};
|
|
917
|
+
return _JsPackageManager.packageJsonCache.set(absolutePath, result), result;
|
|
918
|
+
}
|
|
919
|
+
#getIndent(filePath) {
|
|
920
|
+
try {
|
|
921
|
+
return _JsPackageManager.getPackageJson(filePath)[indentSymbol];
|
|
922
|
+
} catch {
|
|
923
|
+
return 2;
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
writePackageJson(packageJson, directory = this.cwd) {
|
|
927
|
+
let packageJsonToWrite = { ...packageJson };
|
|
928
|
+
["dependencies", "devDependencies", "peerDependencies"].forEach((type) => {
|
|
929
|
+
packageJsonToWrite[type] && Object.keys(packageJsonToWrite[type]).length === 0 && delete packageJsonToWrite[type];
|
|
930
|
+
});
|
|
931
|
+
let filePath = join6(directory, "package.json"), indent = this.#getIndent(filePath), packageJsonPath = normalize2(resolve3(directory, "package.json")), content = `${JSON.stringify(packageJsonToWrite, null, indent)}
|
|
932
|
+
`;
|
|
933
|
+
writeFileSync2(packageJsonPath, content, "utf8");
|
|
934
|
+
let cachedPackageJson = packageJsonToWrite;
|
|
935
|
+
cachedPackageJson.dependencies = { ...packageJsonToWrite.dependencies || {} }, cachedPackageJson.devDependencies = { ...packageJsonToWrite.devDependencies || {} }, cachedPackageJson.peerDependencies = { ...packageJsonToWrite.peerDependencies || {} }, cachedPackageJson[indentSymbol] = indent, _JsPackageManager.packageJsonCache.set(packageJsonPath, cachedPackageJson);
|
|
936
|
+
}
|
|
937
|
+
getAllDependencies() {
|
|
938
|
+
let allDependencies = {};
|
|
939
|
+
for (let packageJsonPath of this.packageJsonPaths) {
|
|
940
|
+
let packageJson = _JsPackageManager.getPackageJson(packageJsonPath), { dependencies, devDependencies, peerDependencies } = packageJson;
|
|
941
|
+
Object.assign(allDependencies, dependencies, devDependencies, peerDependencies);
|
|
942
|
+
}
|
|
943
|
+
return allDependencies;
|
|
944
|
+
}
|
|
945
|
+
isDependencyInstalled(dependency) {
|
|
946
|
+
return Object.keys(this.getAllDependencies()).includes(dependency);
|
|
947
|
+
}
|
|
948
|
+
/**
|
|
949
|
+
* Resolve the effective version/range of a declared dependency: the installed version if present,
|
|
950
|
+
* otherwise the declared semver range. Returns null when the package is not declared or only a
|
|
951
|
+
* non-semver specifier is declared. PNPMProxy additionally resolves pnpm `catalog:` references.
|
|
952
|
+
*/
|
|
953
|
+
async getDeclaredVersionSpecifier(packageName) {
|
|
954
|
+
let installed = await this.getInstalledVersion(packageName);
|
|
955
|
+
if (installed)
|
|
956
|
+
return installed;
|
|
957
|
+
let declared = this.getAllDependencies()[packageName];
|
|
958
|
+
return declared && validRange(declared) ? declared : null;
|
|
959
|
+
}
|
|
960
|
+
/**
|
|
961
|
+
* Pin `packages` to `version`, mirroring how `anchorPackage` is declared. The base implementation
|
|
962
|
+
* pins each directly (`pkg@version`). PNPMProxy overrides this to honor pnpm catalogs: when
|
|
963
|
+
* `anchorPackage` is declared through a catalog, the packages are registered in that catalog and
|
|
964
|
+
* referenced as `catalog:` instead. Returns the install specifiers to write to package.json.
|
|
965
|
+
*/
|
|
966
|
+
applyVersionToRelatedPackages(packages, version, _anchorPackage) {
|
|
967
|
+
return packages.map((pkg) => `${pkg}@${version}`);
|
|
968
|
+
}
|
|
969
|
+
/**
|
|
970
|
+
* Add dependencies to a project using `yarn add` or `npm install`.
|
|
971
|
+
*
|
|
972
|
+
* @example
|
|
973
|
+
*
|
|
974
|
+
* ```ts
|
|
975
|
+
* addDependencies(options, [
|
|
976
|
+
* `@aussieljk/forkbook/react@${storybookVersion}`,
|
|
977
|
+
* `@aussieljk/forkbook/addon-links@${linksVersion}`,
|
|
978
|
+
* ]);
|
|
979
|
+
* ```
|
|
980
|
+
*
|
|
981
|
+
* @param {Object} options Contains `skipInstall`, `packageJson` and `installAsDevDependencies`
|
|
982
|
+
* which we use to determine how we install packages.
|
|
983
|
+
* @param {Array} dependencies Contains a list of packages to add.
|
|
984
|
+
*/
|
|
985
|
+
async addDependencies(options, dependencies) {
|
|
986
|
+
let {
|
|
987
|
+
skipInstall,
|
|
988
|
+
writeOutputToFile = !0,
|
|
989
|
+
packageJsonInfo = this.primaryPackageJson
|
|
990
|
+
} = options;
|
|
991
|
+
if (skipInstall) {
|
|
992
|
+
let { operationDir, packageJson } = packageJsonInfo, dependenciesMap = {};
|
|
993
|
+
for (let dep of dependencies) {
|
|
994
|
+
let [packageName, packageVersion] = getPackageDetails(dep);
|
|
995
|
+
dependenciesMap[packageName] = packageVersion ?? "latest";
|
|
996
|
+
}
|
|
997
|
+
let targetDeps = packageJson[options.type];
|
|
998
|
+
Object.assign(targetDeps, dependenciesMap), this.writePackageJson(packageJson, operationDir);
|
|
999
|
+
} else
|
|
1000
|
+
try {
|
|
1001
|
+
let result = this.runAddDeps(
|
|
1002
|
+
dependencies,
|
|
1003
|
+
options.type === "devDependencies",
|
|
1004
|
+
writeOutputToFile
|
|
1005
|
+
);
|
|
1006
|
+
return this.clearInstalledVersionCache(), result;
|
|
1007
|
+
} catch (e) {
|
|
1008
|
+
throw logger5.error(`
|
|
1009
|
+
An error occurred while adding dependencies to your package.json:`), logger5.log(String(e)), typeof e == "object" && e !== null && "fromStorybook" in e && e.fromStorybook ? e : new HandledError(e);
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
/**
|
|
1013
|
+
* Removing dependencies from the package.json file, which is found first starting from the
|
|
1014
|
+
* instance root. The method does not run a package manager install like `npm install`.
|
|
1015
|
+
*
|
|
1016
|
+
* @example
|
|
1017
|
+
*
|
|
1018
|
+
* ```ts
|
|
1019
|
+
* removeDependencies([`@aussieljk/forkbook/react`]);
|
|
1020
|
+
* ```
|
|
1021
|
+
*
|
|
1022
|
+
* @param dependencies Contains a list of packages to remove.
|
|
1023
|
+
*/
|
|
1024
|
+
async removeDependencies(dependencies) {
|
|
1025
|
+
for (let pjPath of this.packageJsonPaths)
|
|
1026
|
+
try {
|
|
1027
|
+
let packageJson = _JsPackageManager.getPackageJson(pjPath), modified = !1;
|
|
1028
|
+
if (dependencies.forEach((dep) => {
|
|
1029
|
+
packageJson.dependencies && packageJson.dependencies[dep] && (delete packageJson.dependencies[dep], modified = !0), packageJson.devDependencies && packageJson.devDependencies[dep] && (delete packageJson.devDependencies[dep], modified = !0), packageJson.peerDependencies && packageJson.peerDependencies[dep] && (delete packageJson.peerDependencies[dep], modified = !0);
|
|
1030
|
+
}), modified) {
|
|
1031
|
+
this.writePackageJson(packageJson, dirname2(pjPath));
|
|
1032
|
+
break;
|
|
1033
|
+
}
|
|
1034
|
+
} catch (e) {
|
|
1035
|
+
logger5.warn(`Could not process ${pjPath} for dependency removal: ${String(e)}`);
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1038
|
+
/**
|
|
1039
|
+
* Return an array of strings matching following format: `<storybook_package_name>@<package_latest_version>`
|
|
1040
|
+
*
|
|
1041
|
+
* For packages in the storybook monorepo, when the latest version is equal to the version of the
|
|
1042
|
+
* current CLI the version is not added to the string.
|
|
1043
|
+
*
|
|
1044
|
+
* When a package is in the monorepo, and the version is not equal to the CLI version, the version
|
|
1045
|
+
* is taken from the versions.ts file and added to the string.
|
|
1046
|
+
*
|
|
1047
|
+
* When a package is not in the monorepo, we don't change the package version and return the package name as is.
|
|
1048
|
+
* The package manager will resolve the latest version of the package upon installing it.
|
|
1049
|
+
*
|
|
1050
|
+
* @param packages
|
|
1051
|
+
*/
|
|
1052
|
+
getVersionedPackages(packages, options) {
|
|
1053
|
+
return Promise.all(
|
|
1054
|
+
packages.map(async (pkg) => {
|
|
1055
|
+
let [packageName, packageVersion] = getPackageDetails(pkg);
|
|
1056
|
+
if (!(packageName in versions_default))
|
|
1057
|
+
return pkg;
|
|
1058
|
+
if (packageName in versions_default) {
|
|
1059
|
+
let pkgPrNewSpecifier = getPkgPrNewPackageSpecifier(
|
|
1060
|
+
packageName,
|
|
1061
|
+
options?.storybookVersionSpecifier
|
|
1062
|
+
);
|
|
1063
|
+
if (pkgPrNewSpecifier)
|
|
1064
|
+
return `${packageName}@${pkgPrNewSpecifier}`;
|
|
1065
|
+
}
|
|
1066
|
+
let latestInRange = await this.latestVersion(packageName, packageVersion), currentVersion = versions_default[packageName];
|
|
1067
|
+
return currentVersion === latestInRange || !currentVersion ? `${packageName}@^${latestInRange}` : `${packageName}@${currentVersion}`;
|
|
1068
|
+
})
|
|
1069
|
+
);
|
|
1070
|
+
}
|
|
1071
|
+
/**
|
|
1072
|
+
* Return an array of string standing for the latest version of the input packages. To be able to
|
|
1073
|
+
* identify which version goes with which package the order of the input array is keep.
|
|
1074
|
+
*
|
|
1075
|
+
* @param packageNames
|
|
1076
|
+
*/
|
|
1077
|
+
getVersions(...packageNames) {
|
|
1078
|
+
return Promise.all(
|
|
1079
|
+
packageNames.map((packageName) => this.getVersion(packageName))
|
|
1080
|
+
);
|
|
1081
|
+
}
|
|
1082
|
+
/**
|
|
1083
|
+
* Return the latest version of the input package available on npmjs registry. If constraint are
|
|
1084
|
+
* provided it return the latest version matching the constraints.
|
|
1085
|
+
*
|
|
1086
|
+
* For `@storybook/*` packages the latest version is retrieved from `cli/src/versions.json` file
|
|
1087
|
+
* directly
|
|
1088
|
+
*
|
|
1089
|
+
* @param packageName The name of the package
|
|
1090
|
+
* @param constraint A valid semver constraint, example: '1.x || >=2.5.0 || 5.0.0 - 7.2.3'
|
|
1091
|
+
*/
|
|
1092
|
+
async getVersion(packageName, constraint) {
|
|
1093
|
+
let current;
|
|
1094
|
+
packageName in versions_default && (current = versions_default[packageName]);
|
|
1095
|
+
let latest;
|
|
1096
|
+
try {
|
|
1097
|
+
if (latest = await this.latestVersion(packageName, constraint), !latest)
|
|
1098
|
+
throw new Error(`No version found for ${packageName}`);
|
|
1099
|
+
} catch (e) {
|
|
1100
|
+
if (current)
|
|
1101
|
+
return logger5.warn(`
|
|
1102
|
+
${import_picocolors.default.yellow(String(e))}`), current;
|
|
1103
|
+
throw logger5.error(`
|
|
1104
|
+
${import_picocolors.default.red(String(e))}`), new HandledError(e);
|
|
1105
|
+
}
|
|
1106
|
+
return `^${current && (!constraint || satisfies(current, constraint)) && gt2(current, latest) ? current : latest}`;
|
|
1107
|
+
}
|
|
1108
|
+
/**
|
|
1109
|
+
* Get the latest version of the package available on npmjs.com. If constraint is set then it
|
|
1110
|
+
* returns a version satisfying it, otherwise the latest version available is returned.
|
|
1111
|
+
*
|
|
1112
|
+
* @param packageName Name of the package
|
|
1113
|
+
* @param constraint Version range to use to constraint the returned version
|
|
1114
|
+
*/
|
|
1115
|
+
async latestVersion(packageName, constraint) {
|
|
1116
|
+
let cacheKey = constraint ? `${packageName}@${constraint}` : packageName, cachedVersion = _JsPackageManager.latestVersionCache.get(cacheKey);
|
|
1117
|
+
if (cachedVersion)
|
|
1118
|
+
return logger5.debug(`Using cached version for ${packageName}...`), cachedVersion;
|
|
1119
|
+
let result;
|
|
1120
|
+
logger5.debug(`Getting CLI versions from NPM for ${packageName}...`);
|
|
1121
|
+
try {
|
|
1122
|
+
if (!constraint)
|
|
1123
|
+
result = await this.runGetVersions(packageName, !1);
|
|
1124
|
+
else {
|
|
1125
|
+
let latestVersionSatisfyingTheConstraint = (await this.runGetVersions(packageName, !0)).reverse().find((version) => satisfies(version, constraint));
|
|
1126
|
+
invariant(
|
|
1127
|
+
latestVersionSatisfyingTheConstraint != null,
|
|
1128
|
+
`No version satisfying the constraint: ${packageName}${constraint}`
|
|
1129
|
+
), result = latestVersionSatisfyingTheConstraint;
|
|
1130
|
+
}
|
|
1131
|
+
return _JsPackageManager.latestVersionCache.set(cacheKey, result), result;
|
|
1132
|
+
} catch (e) {
|
|
1133
|
+
return logger5.debug(`Failed to fetch the latest version for ${packageName}: ${String(e)}`), _JsPackageManager.latestVersionCache.set(cacheKey, null), null;
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
1136
|
+
/**
|
|
1137
|
+
* Clear the latest version cache. Useful for testing or when you want to refresh version
|
|
1138
|
+
* information.
|
|
1139
|
+
*
|
|
1140
|
+
* @param packageName Optional package name to clear only specific entries. If not provided,
|
|
1141
|
+
* clears all cache.
|
|
1142
|
+
*/
|
|
1143
|
+
static clearLatestVersionCache(packageName) {
|
|
1144
|
+
packageName ? Array.from(_JsPackageManager.latestVersionCache.keys()).filter(
|
|
1145
|
+
(key) => key === packageName || key.startsWith(`${packageName}@`)
|
|
1146
|
+
).forEach((key) => _JsPackageManager.latestVersionCache.delete(key)) : _JsPackageManager.latestVersionCache.clear();
|
|
1147
|
+
}
|
|
1148
|
+
/**
|
|
1149
|
+
* Clear the installed version cache for a specific package or all packages.
|
|
1150
|
+
*
|
|
1151
|
+
* @param packageName Optional package name to clear from cache. If not provided, clears all.
|
|
1152
|
+
*/
|
|
1153
|
+
clearInstalledVersionCache(packageName) {
|
|
1154
|
+
packageName ? Array.from(_JsPackageManager.installedVersionCache.keys()).filter(
|
|
1155
|
+
(key) => key.endsWith(`::${packageName}`)
|
|
1156
|
+
).forEach((key) => _JsPackageManager.installedVersionCache.delete(key)) : _JsPackageManager.installedVersionCache.clear();
|
|
1157
|
+
}
|
|
1158
|
+
/**
|
|
1159
|
+
* Clear both the latest version cache and installed version cache. This should be called after
|
|
1160
|
+
* any operation that modifies dependencies.
|
|
1161
|
+
*/
|
|
1162
|
+
clearAllVersionCaches() {
|
|
1163
|
+
_JsPackageManager.clearLatestVersionCache(), this.clearInstalledVersionCache();
|
|
1164
|
+
}
|
|
1165
|
+
addStorybookCommandInScripts(options) {
|
|
1166
|
+
let storybookCmd = `forkbook dev -p ${options?.port ?? 6006}`, buildStorybookCmd = "forkbook build", preCommand = options?.preCommand ? this.getRunCommand(options.preCommand) : void 0;
|
|
1167
|
+
this.addScripts({
|
|
1168
|
+
forkbook: [preCommand, storybookCmd].filter(Boolean).join(" && "),
|
|
1169
|
+
"build-forkbook": [preCommand, buildStorybookCmd].filter(Boolean).join(" && ")
|
|
1170
|
+
});
|
|
1171
|
+
}
|
|
1172
|
+
addScripts(scripts) {
|
|
1173
|
+
let { operationDir, packageJson } = this.#getPrimaryPackageJson();
|
|
1174
|
+
packageJson.scripts = {
|
|
1175
|
+
...packageJson.scripts,
|
|
1176
|
+
...scripts
|
|
1177
|
+
}, this.writePackageJson(packageJson, operationDir);
|
|
1178
|
+
}
|
|
1179
|
+
addPackageResolutions(versions) {
|
|
1180
|
+
let { operationDir, packageJson } = this.#getPrimaryPackageJson(), resolutions = this.getResolutions(packageJson, versions);
|
|
1181
|
+
this.writePackageJson({ ...packageJson, ...resolutions }, operationDir);
|
|
1182
|
+
}
|
|
1183
|
+
/** Returns the installed version of a specified package */
|
|
1184
|
+
async getInstalledVersion(packageName) {
|
|
1185
|
+
let cacheKey = packageName;
|
|
1186
|
+
try {
|
|
1187
|
+
let cachedVersion = _JsPackageManager.installedVersionCache.get(cacheKey);
|
|
1188
|
+
if (cachedVersion !== void 0)
|
|
1189
|
+
return logger5.debug(`Using cached installed version for ${packageName}...`), cachedVersion;
|
|
1190
|
+
logger5.debug(`Getting installed version for ${packageName}...`);
|
|
1191
|
+
let version = null, vitePlusVersions = await getVitePlusVersions();
|
|
1192
|
+
if (vitePlusVersions?.[packageName] && (version = vitePlusVersions[packageName]), !version) {
|
|
1193
|
+
let installations = await this.findInstallations([packageName]);
|
|
1194
|
+
installations && (version = Object.entries(installations.dependencies)[0]?.[1]?.[0].version || null);
|
|
1195
|
+
}
|
|
1196
|
+
if (!version)
|
|
1197
|
+
return logger5.debug(`No installations found for ${packageName}`), _JsPackageManager.installedVersionCache.set(cacheKey, null), null;
|
|
1198
|
+
let coercedVersion = coerce(version, { includePrerelease: !0 })?.toString() ?? version;
|
|
1199
|
+
return logger5.debug(`Installed version for ${packageName}: ${coercedVersion}`), _JsPackageManager.installedVersionCache.set(cacheKey, coercedVersion), coercedVersion;
|
|
1200
|
+
} catch (e) {
|
|
1201
|
+
return logger5.error(`Error getting installed version for ${packageName}: ${String(e)}`), _JsPackageManager.installedVersionCache.set(cacheKey, null), null;
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
async isPackageInstalled(packageName) {
|
|
1205
|
+
return await this.getInstalledVersion(packageName) !== null;
|
|
1206
|
+
}
|
|
1207
|
+
/**
|
|
1208
|
+
* Searches for a dependency/devDependency in all package.json files and returns the version of
|
|
1209
|
+
* the dependency.
|
|
1210
|
+
*/
|
|
1211
|
+
getDependencyVersion(dependency) {
|
|
1212
|
+
return logger5.debug(`Getting dependency version for ${dependency}...`), this.packageJsonPaths.map((path) => {
|
|
1213
|
+
let packageJson = _JsPackageManager.getPackageJson(path);
|
|
1214
|
+
return packageJson.dependencies?.[dependency] ?? packageJson.devDependencies?.[dependency];
|
|
1215
|
+
}).filter(Boolean)[0] ?? null;
|
|
1216
|
+
}
|
|
1217
|
+
// Helper to read and check a package.json for storybook dependency
|
|
1218
|
+
static hasStorybookDependency(packageJsonPath) {
|
|
1219
|
+
try {
|
|
1220
|
+
let content = readFileSync4(packageJsonPath, "utf-8"), packageJson = JSON.parse(content);
|
|
1221
|
+
return !!(packageJson.dependencies && packageJson.dependencies.storybook || packageJson.devDependencies && packageJson.devDependencies.storybook);
|
|
1222
|
+
} catch {
|
|
1223
|
+
return !1;
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
// Helper to read and check a package.json for storybook dependency
|
|
1227
|
+
static hasAnyStorybookDependency(packageJsonPath) {
|
|
1228
|
+
try {
|
|
1229
|
+
let content = readFileSync4(packageJsonPath, "utf-8"), packageJson = JSON.parse(content), allDeps = {
|
|
1230
|
+
...packageJson.dependencies,
|
|
1231
|
+
...packageJson.devDependencies
|
|
1232
|
+
};
|
|
1233
|
+
return Object.keys(allDeps).some(
|
|
1234
|
+
(dep) => dep.includes("storybook") || dep === "@aussieljk/forkbook"
|
|
1235
|
+
);
|
|
1236
|
+
} catch {
|
|
1237
|
+
return !1;
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1240
|
+
/**
|
|
1241
|
+
* Find the primary package.json file in the project root. The primary package.json file is the
|
|
1242
|
+
* one that contains the `storybook` dependency. If no primary package.json file is found, the
|
|
1243
|
+
* function will return the package.json file in the project root.
|
|
1244
|
+
*/
|
|
1245
|
+
#findPrimaryPackageJsonPath() {
|
|
1246
|
+
for (let packageJsonPath of this.packageJsonPaths)
|
|
1247
|
+
if (_JsPackageManager.hasStorybookDependency(packageJsonPath))
|
|
1248
|
+
return packageJsonPath;
|
|
1249
|
+
return this.packageJsonPaths[0] ?? resolve3(this.cwd, "package.json");
|
|
1250
|
+
}
|
|
1251
|
+
/** List all package.json files starting from the given directory and stopping at the project root. */
|
|
1252
|
+
static listAllPackageJsonPaths(instanceDir, storiesPaths) {
|
|
1253
|
+
let packageJsonPaths = findFilesUp(["package.json"], instanceDir);
|
|
1254
|
+
if (!storiesPaths)
|
|
1255
|
+
return packageJsonPaths;
|
|
1256
|
+
let projectRoot = getProjectRoot(), relevantPackageJsons = globSync("**/package.json", {
|
|
1257
|
+
cwd: projectRoot,
|
|
1258
|
+
absolute: !0,
|
|
1259
|
+
expandDirectories: !1,
|
|
1260
|
+
ignore: ["**/node_modules/**", "**/dist/**"]
|
|
1261
|
+
}).filter((packageJsonPath) => {
|
|
1262
|
+
let packageDir = dirname2(packageJsonPath);
|
|
1263
|
+
return storiesPaths.some((storyPath) => storyPath.startsWith(packageDir));
|
|
1264
|
+
});
|
|
1265
|
+
return Array.from(/* @__PURE__ */ new Set([...packageJsonPaths, ...relevantPackageJsons]));
|
|
1266
|
+
}
|
|
1267
|
+
/**
|
|
1268
|
+
* Get the primary package.json file and its operation directory. The primary package.json file is
|
|
1269
|
+
* the one that contains the storybook dependency. If the primary package.json file is not found,
|
|
1270
|
+
* the function returns information about thepackage.json file in the current working directory.
|
|
1271
|
+
*/
|
|
1272
|
+
#getPrimaryPackageJson() {
|
|
1273
|
+
let finalTargetPackageJsonPath = this.#findPrimaryPackageJsonPath();
|
|
1274
|
+
return _JsPackageManager.getPackageJsonInfo(finalTargetPackageJsonPath);
|
|
1275
|
+
}
|
|
1276
|
+
static getPackageJsonInfo(packageJsonPath) {
|
|
1277
|
+
logger5.debug(`Getting package.json info for ${packageJsonPath}...`);
|
|
1278
|
+
let operationDir = dirname2(packageJsonPath);
|
|
1279
|
+
return {
|
|
1280
|
+
packageJsonPath,
|
|
1281
|
+
operationDir,
|
|
1282
|
+
get packageJson() {
|
|
1283
|
+
return _JsPackageManager.getPackageJson(packageJsonPath);
|
|
1284
|
+
}
|
|
1285
|
+
};
|
|
1286
|
+
}
|
|
1287
|
+
};
|
|
1288
|
+
|
|
1289
|
+
// src/common/utils/normalize-path.ts
|
|
1290
|
+
import { posix as posix2 } from "node:path";
|
|
1291
|
+
function normalizePath2(p) {
|
|
1292
|
+
return posix2.normalize(p.replace(/\\/g, "/"));
|
|
1293
|
+
}
|
|
1294
|
+
|
|
1295
|
+
// src/common/utils/get-addon-names.ts
|
|
1296
|
+
var normalizeAddonName = (addon) => {
|
|
1297
|
+
let name = "";
|
|
1298
|
+
if (typeof addon == "string" ? name = addon : typeof addon == "object" && (name = addon.name), !name.startsWith("."))
|
|
1299
|
+
return name = normalizePath2(name), name = name.replace(/.*node_modules\//, ""), name.replace(/\/dist\/.*$/, "").replace(/\.[mc]?[tj]?sx?$/, "").replace(/\/register$/, "").replace(/\/manager$/, "").replace(/\/preset$/, "");
|
|
1300
|
+
}, getAddonNames = (mainConfig) => (mainConfig.addons || []).map(normalizeAddonName).filter((item) => item != null);
|
|
1301
|
+
|
|
1302
|
+
// src/common/utils/get-renderer-name.ts
|
|
1303
|
+
async function getRendererName(options) {
|
|
1304
|
+
let core = await options.presets.apply("core", {}, options);
|
|
1305
|
+
return !core || !core.renderer ? getFrameworkName(options) : core.renderer;
|
|
1306
|
+
}
|
|
1307
|
+
async function extractRenderer(frameworkName) {
|
|
1308
|
+
let extractedFrameworkName = extractFrameworkPackageName(frameworkName), framework = frameworkPackages[extractedFrameworkName];
|
|
1309
|
+
return framework ? frameworkToRenderer[framework] : null;
|
|
1310
|
+
}
|
|
1311
|
+
|
|
1312
|
+
// src/common/utils/get-storybook-configuration.ts
|
|
1313
|
+
function getStorybookConfiguration(storybookScript, shortName, longName) {
|
|
1314
|
+
if (!storybookScript)
|
|
1315
|
+
return null;
|
|
1316
|
+
let parts = storybookScript.split(/[\s='"]+/), index = parts.indexOf(longName);
|
|
1317
|
+
return index === -1 && (index = parts.indexOf(shortName)), index === -1 ? null : parts[index + 1];
|
|
1318
|
+
}
|
|
1319
|
+
|
|
1320
|
+
// src/common/utils/load-main-config.ts
|
|
1321
|
+
import { readFile as readFile3, rm as rm3, writeFile as writeFile3 } from "node:fs/promises";
|
|
1322
|
+
import { join as join7, parse as parse2, relative, resolve as resolve4 } from "node:path";
|
|
1323
|
+
import { logger as logger6 } from "@aussieljk/forkbook/internal/node-logger";
|
|
1324
|
+
import { MainFileEvaluationError } from "@aussieljk/forkbook/internal/server-errors";
|
|
1325
|
+
import { dedent as dedent3 } from "ts-dedent";
|
|
1326
|
+
async function loadMainConfig({
|
|
1327
|
+
configDir = defaultConfigDir(),
|
|
1328
|
+
cwd,
|
|
1329
|
+
skipCache
|
|
1330
|
+
}) {
|
|
1331
|
+
await validateConfigurationFiles(configDir, cwd);
|
|
1332
|
+
let mainPath = getInterpretedFile(resolve4(configDir, "main"));
|
|
1333
|
+
try {
|
|
1334
|
+
return await importModule(mainPath, { skipCache });
|
|
1335
|
+
} catch (e) {
|
|
1336
|
+
if (!(e instanceof Error))
|
|
1337
|
+
throw e;
|
|
1338
|
+
if (e.message.includes("not defined in ES module scope")) {
|
|
1339
|
+
logger6.info(
|
|
1340
|
+
"Loading main config failed as the file does not seem to be valid ESM. Trying a temporary fix, please ensure the main config is valid ESM."
|
|
1341
|
+
);
|
|
1342
|
+
let comment = "// end of Forkbook 10 migration assistant header, you can delete the above code", content = await readFile3(mainPath, "utf-8");
|
|
1343
|
+
if (!content.includes(comment)) {
|
|
1344
|
+
let header = dedent3`
|
|
1345
|
+
import { createRequire } from "node:module";
|
|
1346
|
+
import { dirname } from "node:path";
|
|
1347
|
+
import { fileURLToPath } from "node:url";
|
|
1348
|
+
|
|
1349
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
1350
|
+
const __dirname = dirname(__filename);
|
|
1351
|
+
const require = createRequire(import.meta.url);
|
|
1352
|
+
`, { ext, name, dir } = parse2(mainPath), modifiedMainPath = join7(dir, `${name}.tmp.${ext}`);
|
|
1353
|
+
await writeFile3(modifiedMainPath, [header, comment, content].join(`
|
|
1354
|
+
|
|
1355
|
+
`));
|
|
1356
|
+
let out;
|
|
1357
|
+
try {
|
|
1358
|
+
out = await importModule(modifiedMainPath);
|
|
1359
|
+
} finally {
|
|
1360
|
+
await rm3(modifiedMainPath);
|
|
1361
|
+
}
|
|
1362
|
+
return out;
|
|
1363
|
+
}
|
|
1364
|
+
}
|
|
1365
|
+
throw new MainFileEvaluationError({
|
|
1366
|
+
location: relative(process.cwd(), mainPath),
|
|
1367
|
+
error: e
|
|
1368
|
+
});
|
|
1369
|
+
}
|
|
1370
|
+
}
|
|
1371
|
+
|
|
1372
|
+
// src/common/utils/get-storybook-info.ts
|
|
1373
|
+
var rendererPackages = {
|
|
1374
|
+
"@aussieljk/forkbook/react": SupportedRenderer2.REACT,
|
|
1375
|
+
"@storybook/react-native": SupportedRenderer2.REACT_NATIVE
|
|
1376
|
+
}, frameworkPackages = {
|
|
1377
|
+
"@aussieljk/forkbook/react-vite": SupportedFramework2.REACT_VITE,
|
|
1378
|
+
"@aussieljk/forkbook/nextjs-vite": SupportedFramework2.NEXTJS_VITE
|
|
1379
|
+
}, builderPackages = {
|
|
1380
|
+
"@aussieljk/forkbook/builder-vite": SupportedBuilder2.VITE
|
|
1381
|
+
}, findDependency = ({ dependencies, devDependencies, peerDependencies }, predicate) => [
|
|
1382
|
+
Object.entries(dependencies || {}).find(predicate),
|
|
1383
|
+
Object.entries(devDependencies || {}).find(predicate),
|
|
1384
|
+
Object.entries(peerDependencies || {}).find(predicate)
|
|
1385
|
+
], getStorybookVersionSpecifier = (configDir) => {
|
|
1386
|
+
let packageJsonPaths = JsPackageManager.listAllPackageJsonPaths(dirname3(configDir));
|
|
1387
|
+
for (let packageJsonPath of packageJsonPaths) {
|
|
1388
|
+
let packageJson = JSON.parse(readFileSync5(packageJsonPath, "utf-8")), [dep, devDep, peerDep] = findDependency(
|
|
1389
|
+
packageJson,
|
|
1390
|
+
([key]) => key === "@aussieljk/forkbook"
|
|
1391
|
+
), [pkg, version] = dep || devDep || peerDep || [];
|
|
1392
|
+
if (pkg && version)
|
|
1393
|
+
return version;
|
|
1394
|
+
}
|
|
1395
|
+
}, findConfigFile = (prefix, configDir) => {
|
|
1396
|
+
let filePrefix = join8(configDir, prefix), extension = storybookConfigExtensions.find((ext) => existsSync2(`${filePrefix}${ext}`));
|
|
1397
|
+
return extension ? `${filePrefix}${extension}` : null;
|
|
1398
|
+
}, getConfigInfo = (configDir) => {
|
|
1399
|
+
let storybookConfigDir = configDir ?? defaultConfigDir();
|
|
1400
|
+
if (!existsSync2(storybookConfigDir)) {
|
|
1401
|
+
let packageJsonPaths = JsPackageManager.listAllPackageJsonPaths(storybookConfigDir);
|
|
1402
|
+
for (let packageJsonPath of packageJsonPaths) {
|
|
1403
|
+
let storybookScript = JSON.parse(readFileSync5(packageJsonPath, "utf-8")).scripts?.forkbook;
|
|
1404
|
+
if (storybookScript && !configDir) {
|
|
1405
|
+
let configParam = getStorybookConfiguration(storybookScript, "-c", "--config-dir");
|
|
1406
|
+
if (configParam) {
|
|
1407
|
+
storybookConfigDir = configParam;
|
|
1408
|
+
break;
|
|
1409
|
+
}
|
|
1410
|
+
}
|
|
1411
|
+
}
|
|
1412
|
+
}
|
|
1413
|
+
return {
|
|
1414
|
+
configDir: storybookConfigDir,
|
|
1415
|
+
mainConfigPath: findConfigFile("main", storybookConfigDir),
|
|
1416
|
+
previewConfigPath: findConfigFile("preview", storybookConfigDir),
|
|
1417
|
+
managerConfigPath: findConfigFile("manager", storybookConfigDir)
|
|
1418
|
+
};
|
|
1419
|
+
}, getStorybookInfo = async (configDir = defaultConfigDir(), cwd, { skipCache } = {}) => {
|
|
1420
|
+
let configInfo = getConfigInfo(configDir), mainConfig = await loadMainConfig({
|
|
1421
|
+
configDir: configInfo.configDir,
|
|
1422
|
+
cwd,
|
|
1423
|
+
// When the main config may have been rewritten earlier in the same process (e.g. by
|
|
1424
|
+
// `forkbook add`), callers must skip the module cache to read the
|
|
1425
|
+
// current on-disk config instead of a stale, previously-evaluated version.
|
|
1426
|
+
skipCache
|
|
1427
|
+
});
|
|
1428
|
+
invariant(mainConfig, `Unable to find or evaluate ${configInfo.mainConfigPath}`);
|
|
1429
|
+
let frameworkValue = mainConfig.framework, frameworkField = typeof frameworkValue == "string" ? frameworkValue : frameworkValue?.name, addons = getAddonNames(mainConfig), versionSpecifier = getStorybookVersionSpecifier(configDir);
|
|
1430
|
+
if (!frameworkField)
|
|
1431
|
+
return basename(configInfo.configDir) === RN_FORKBOOK_DIR ? {
|
|
1432
|
+
...configInfo,
|
|
1433
|
+
versionSpecifier,
|
|
1434
|
+
addons,
|
|
1435
|
+
mainConfig,
|
|
1436
|
+
frameworkPackage: "@storybook/react-native",
|
|
1437
|
+
rendererPackage: "@storybook/react-native",
|
|
1438
|
+
renderer: SupportedRenderer2.REACT_NATIVE,
|
|
1439
|
+
mainConfigPath: configInfo.mainConfigPath ?? void 0,
|
|
1440
|
+
previewConfigPath: configInfo.previewConfigPath ?? void 0,
|
|
1441
|
+
managerConfigPath: configInfo.managerConfigPath ?? void 0
|
|
1442
|
+
} : {
|
|
1443
|
+
...configInfo,
|
|
1444
|
+
versionSpecifier,
|
|
1445
|
+
addons,
|
|
1446
|
+
mainConfig,
|
|
1447
|
+
mainConfigPath: configInfo.mainConfigPath ?? void 0,
|
|
1448
|
+
previewConfigPath: configInfo.previewConfigPath ?? void 0,
|
|
1449
|
+
managerConfigPath: configInfo.managerConfigPath ?? void 0
|
|
1450
|
+
};
|
|
1451
|
+
let frameworkPackage = extractFrameworkPackageName(frameworkField), framework = frameworkPackages[frameworkPackage], renderer = await extractRenderer(frameworkPackage), builder = frameworkToBuilder[framework], rendererPackage = Object.entries(rendererPackages).find(
|
|
1452
|
+
([, value]) => value === renderer
|
|
1453
|
+
)?.[0], builderPackage = Object.entries(builderPackages).find(
|
|
1454
|
+
([, value]) => value === builder
|
|
1455
|
+
)?.[0];
|
|
1456
|
+
return {
|
|
1457
|
+
...configInfo,
|
|
1458
|
+
addons,
|
|
1459
|
+
mainConfig,
|
|
1460
|
+
framework,
|
|
1461
|
+
versionSpecifier,
|
|
1462
|
+
renderer: renderer ?? void 0,
|
|
1463
|
+
builder: builder ?? void 0,
|
|
1464
|
+
frameworkPackage,
|
|
1465
|
+
rendererPackage,
|
|
1466
|
+
builderPackage,
|
|
1467
|
+
mainConfigPath: configInfo.mainConfigPath ?? void 0,
|
|
1468
|
+
previewConfigPath: configInfo.previewConfigPath ?? void 0,
|
|
1469
|
+
managerConfigPath: configInfo.managerConfigPath ?? void 0
|
|
1470
|
+
};
|
|
1471
|
+
};
|
|
1472
|
+
|
|
1473
|
+
// src/common/utils/get-framework-name.ts
|
|
1474
|
+
async function getFrameworkName(options) {
|
|
1475
|
+
let framework = await options.presets.apply("framework", "", options);
|
|
1476
|
+
if (!framework)
|
|
1477
|
+
throw new Error(dedent4`
|
|
1478
|
+
You must specify a framework in '.forkbook/main.js' config.
|
|
1479
|
+
|
|
1480
|
+
https://forkbook.ljk.dev/docs/migration#framework-field-mandatory
|
|
1481
|
+
`);
|
|
1482
|
+
return typeof framework == "object" ? framework.name : framework;
|
|
1483
|
+
}
|
|
1484
|
+
var extractFrameworkPackageName = (framework) => {
|
|
1485
|
+
let normalizedPath = normalizePath2(framework);
|
|
1486
|
+
return Object.keys(frameworkPackages).find((pkg) => normalizedPath.endsWith(pkg)) ?? framework;
|
|
1487
|
+
};
|
|
1488
|
+
|
|
571
1489
|
// src/common/utils/get-storybook-refs.ts
|
|
572
|
-
import { readFile as
|
|
573
|
-
import { dirname as
|
|
1490
|
+
import { readFile as readFile5 } from "node:fs/promises";
|
|
1491
|
+
import { dirname as dirname5 } from "node:path";
|
|
574
1492
|
|
|
575
1493
|
// src/common/utils/read-dependency-manifest.ts
|
|
576
|
-
import { readFile as
|
|
577
|
-
import { dirname as
|
|
578
|
-
import { logger as
|
|
1494
|
+
import { readFile as readFile4 } from "node:fs/promises";
|
|
1495
|
+
import { dirname as dirname4, join as join9 } from "node:path";
|
|
1496
|
+
import { logger as logger7 } from "@aussieljk/forkbook/internal/node-logger";
|
|
579
1497
|
var readDependencyManifest = async (directory, dependency) => {
|
|
580
|
-
let subpath = from(directory,
|
|
1498
|
+
let subpath = from(directory, join9(dependency, "package.json"), !0);
|
|
581
1499
|
if (subpath)
|
|
582
1500
|
try {
|
|
583
|
-
let manifest = JSON.parse(await
|
|
1501
|
+
let manifest = JSON.parse(await readFile4(subpath, { encoding: "utf8" }));
|
|
584
1502
|
if (manifest?.name)
|
|
585
1503
|
return manifest;
|
|
586
1504
|
} catch {
|
|
587
1505
|
}
|
|
588
1506
|
let entry = from(directory, dependency, !0);
|
|
589
1507
|
if (!entry) {
|
|
590
|
-
|
|
1508
|
+
logger7.debug(`readDependencyManifest: could not resolve "${dependency}"`);
|
|
591
1509
|
return;
|
|
592
1510
|
}
|
|
593
|
-
let dir =
|
|
1511
|
+
let dir = dirname4(entry);
|
|
594
1512
|
for (; ; ) {
|
|
595
1513
|
try {
|
|
596
|
-
let manifest = JSON.parse(await
|
|
1514
|
+
let manifest = JSON.parse(await readFile4(join9(dir, "package.json"), { encoding: "utf8" }));
|
|
597
1515
|
if (manifest?.name)
|
|
598
1516
|
return manifest;
|
|
599
1517
|
} catch {
|
|
600
1518
|
}
|
|
601
|
-
let parent =
|
|
1519
|
+
let parent = dirname4(dir);
|
|
602
1520
|
if (parent === dir)
|
|
603
1521
|
return;
|
|
604
1522
|
dir = parent;
|
|
@@ -610,7 +1528,7 @@ var getAutoRefs = async (options) => {
|
|
|
610
1528
|
let location = up3({ cwd: options.configDir, last: getProjectRoot() });
|
|
611
1529
|
if (!location)
|
|
612
1530
|
return {};
|
|
613
|
-
let directory =
|
|
1531
|
+
let directory = dirname5(location), { dependencies = [], devDependencies = [] } = JSON.parse(await readFile5(location, { encoding: "utf8" })) || {}, deps = Object.keys({ ...dependencies, ...devDependencies }), list = await Promise.all(
|
|
614
1532
|
deps.map(async (d) => {
|
|
615
1533
|
let manifest = await readDependencyManifest(directory, d), ref = manifest?.storybook;
|
|
616
1534
|
if (manifest?.name && ref?.url)
|
|
@@ -669,16 +1587,16 @@ async function getRefs(options) {
|
|
|
669
1587
|
|
|
670
1588
|
// src/common/utils/glob-to-regexp.ts
|
|
671
1589
|
var pico = __toESM(require_picomatch(), 1);
|
|
672
|
-
function globToRegexp(
|
|
673
|
-
let regex = pico.makeRe(
|
|
1590
|
+
function globToRegexp(glob2) {
|
|
1591
|
+
let regex = pico.makeRe(glob2, {
|
|
674
1592
|
fastpaths: !1,
|
|
675
1593
|
noglobstar: !1,
|
|
676
1594
|
bash: !1
|
|
677
1595
|
});
|
|
678
1596
|
if (!regex.source.startsWith("^"))
|
|
679
|
-
throw new Error(`Invalid glob: >> ${
|
|
680
|
-
return
|
|
681
|
-
["^\\.",
|
|
1597
|
+
throw new Error(`Invalid glob: >> ${glob2} >> ${regex}`);
|
|
1598
|
+
return glob2.startsWith("./") ? new RegExp(
|
|
1599
|
+
["^\\.", glob2.startsWith("./**") ? "" : "[\\\\/]", regex.source.substring(1)].join("")
|
|
682
1600
|
) : regex;
|
|
683
1601
|
}
|
|
684
1602
|
|
|
@@ -689,14 +1607,14 @@ var interpolate = (template, bindings) => Object.entries(bindings).reduce((acc,
|
|
|
689
1607
|
}, template);
|
|
690
1608
|
|
|
691
1609
|
// src/common/utils/load-manager-or-addons-file.ts
|
|
692
|
-
import { resolve as
|
|
693
|
-
import { logger as
|
|
694
|
-
import { dedent as
|
|
1610
|
+
import { resolve as resolve5 } from "node:path";
|
|
1611
|
+
import { logger as logger8 } from "@aussieljk/forkbook/internal/node-logger";
|
|
1612
|
+
import { dedent as dedent5 } from "ts-dedent";
|
|
695
1613
|
function loadManagerOrAddonsFile({ configDir }) {
|
|
696
|
-
let storybookCustomAddonsPath = getInterpretedFile(
|
|
697
|
-
if ((storybookCustomAddonsPath || storybookCustomManagerPath) &&
|
|
698
|
-
throw new Error(
|
|
699
|
-
You have both a "addons.js" and a "manager.js", remove the "addons.js" file from your configDir (${
|
|
1614
|
+
let storybookCustomAddonsPath = getInterpretedFile(resolve5(configDir, "addons")), storybookCustomManagerPath = getInterpretedFile(resolve5(configDir, "manager"));
|
|
1615
|
+
if ((storybookCustomAddonsPath || storybookCustomManagerPath) && logger8.step("Loading custom manager config"), storybookCustomAddonsPath && storybookCustomManagerPath)
|
|
1616
|
+
throw new Error(dedent5`
|
|
1617
|
+
You have both a "addons.js" and a "manager.js", remove the "addons.js" file from your configDir (${resolve5(
|
|
700
1618
|
configDir,
|
|
701
1619
|
"addons"
|
|
702
1620
|
)})`);
|
|
@@ -704,13 +1622,13 @@ function loadManagerOrAddonsFile({ configDir }) {
|
|
|
704
1622
|
}
|
|
705
1623
|
|
|
706
1624
|
// src/common/utils/load-preview-or-config-file.ts
|
|
707
|
-
import { resolve as
|
|
708
|
-
import { dedent as
|
|
1625
|
+
import { resolve as resolve6 } from "node:path";
|
|
1626
|
+
import { dedent as dedent6 } from "ts-dedent";
|
|
709
1627
|
function loadPreviewOrConfigFile({ configDir }) {
|
|
710
|
-
let storybookConfigPath = getInterpretedFile(
|
|
1628
|
+
let storybookConfigPath = getInterpretedFile(resolve6(configDir, "config")), storybookPreviewPath = getInterpretedFile(resolve6(configDir, "preview"));
|
|
711
1629
|
if (storybookConfigPath && storybookPreviewPath)
|
|
712
|
-
throw new Error(
|
|
713
|
-
You have both a "config.js" and a "preview.js", remove the "config.js" file from your configDir (${
|
|
1630
|
+
throw new Error(dedent6`
|
|
1631
|
+
You have both a "config.js" and a "preview.js", remove the "config.js" file from your configDir (${resolve6(
|
|
714
1632
|
configDir,
|
|
715
1633
|
"config"
|
|
716
1634
|
)})`);
|
|
@@ -718,19 +1636,19 @@ function loadPreviewOrConfigFile({ configDir }) {
|
|
|
718
1636
|
}
|
|
719
1637
|
|
|
720
1638
|
// src/common/utils/log-config.ts
|
|
721
|
-
var
|
|
1639
|
+
var import_picocolors2 = __toESM(require_picocolors(), 1);
|
|
722
1640
|
function logConfig(caption, config) {
|
|
723
|
-
console.log(
|
|
1641
|
+
console.log(import_picocolors2.default.cyan(String(caption))), console.dir(config, { depth: null });
|
|
724
1642
|
}
|
|
725
1643
|
|
|
726
1644
|
// src/common/utils/normalize-stories.ts
|
|
727
1645
|
var pico2 = __toESM(require_picomatch(), 1);
|
|
728
1646
|
import { lstatSync } from "node:fs";
|
|
729
|
-
import { basename, dirname as
|
|
1647
|
+
import { basename as basename2, dirname as dirname6, relative as relative2, resolve as resolve7 } from "node:path";
|
|
730
1648
|
import { InvalidStoriesEntryError } from "@aussieljk/forkbook/internal/server-errors";
|
|
731
1649
|
var DEFAULT_TITLE_PREFIX = "", DEFAULT_FILES_PATTERN = "**/*.@(mdx|stories.@(js|jsx|mjs|ts|tsx))", isDirectory = (configDir, entry) => {
|
|
732
1650
|
try {
|
|
733
|
-
return lstatSync(
|
|
1651
|
+
return lstatSync(resolve7(configDir, entry)).isDirectory();
|
|
734
1652
|
} catch {
|
|
735
1653
|
return !1;
|
|
736
1654
|
}
|
|
@@ -739,7 +1657,7 @@ var DEFAULT_TITLE_PREFIX = "", DEFAULT_FILES_PATTERN = "**/*.@(mdx|stories.@(js|
|
|
|
739
1657
|
workingDir,
|
|
740
1658
|
directory
|
|
741
1659
|
}) => {
|
|
742
|
-
let directoryFromConfig =
|
|
1660
|
+
let directoryFromConfig = resolve7(configDir, directory), directoryFromWorking = relative2(workingDir, directoryFromConfig);
|
|
743
1661
|
return normalizeStoryPath(directoryFromWorking);
|
|
744
1662
|
}, normalizeStoriesEntry = (entry, { configDir, workingDir, defaultFilesPattern = DEFAULT_FILES_PATTERN }) => {
|
|
745
1663
|
let specifierWithoutMatcher;
|
|
@@ -758,8 +1676,8 @@ var DEFAULT_TITLE_PREFIX = "", DEFAULT_FILES_PATTERN = "**/*.@(mdx|stories.@(js|
|
|
|
758
1676
|
files: defaultFilesPattern
|
|
759
1677
|
} : specifierWithoutMatcher = {
|
|
760
1678
|
titlePrefix: DEFAULT_TITLE_PREFIX,
|
|
761
|
-
directory:
|
|
762
|
-
files:
|
|
1679
|
+
directory: dirname6(entry),
|
|
1680
|
+
files: basename2(entry)
|
|
763
1681
|
};
|
|
764
1682
|
} else
|
|
765
1683
|
specifierWithoutMatcher = {
|
|
@@ -786,9 +1704,9 @@ var DEFAULT_TITLE_PREFIX = "", DEFAULT_FILES_PATTERN = "**/*.@(mdx|stories.@(js|
|
|
|
786
1704
|
};
|
|
787
1705
|
|
|
788
1706
|
// src/common/utils/readTemplate.ts
|
|
789
|
-
import { readFile as
|
|
1707
|
+
import { readFile as readFile6 } from "node:fs/promises";
|
|
790
1708
|
async function readTemplate(filename) {
|
|
791
|
-
return
|
|
1709
|
+
return readFile6(filename, {
|
|
792
1710
|
encoding: "utf8"
|
|
793
1711
|
});
|
|
794
1712
|
}
|
|
@@ -937,27 +1855,27 @@ function getComponentExpressionName(node) {
|
|
|
937
1855
|
|
|
938
1856
|
// src/common/utils/remove.ts
|
|
939
1857
|
import { readConfig, writeConfig } from "@aussieljk/forkbook/internal/csf-tools";
|
|
940
|
-
import { logger as
|
|
941
|
-
import { dedent as
|
|
1858
|
+
import { logger as logger9 } from "@aussieljk/forkbook/internal/node-logger";
|
|
1859
|
+
import { dedent as dedent7 } from "ts-dedent";
|
|
942
1860
|
async function removeAddon(addon, options) {
|
|
943
1861
|
let { packageManager, skipInstall } = options, { mainConfigPath, configDir } = getConfigInfo(options.configDir);
|
|
944
1862
|
if (typeof configDir > "u")
|
|
945
|
-
throw new Error(
|
|
1863
|
+
throw new Error(dedent7`
|
|
946
1864
|
Unable to find storybook config directory
|
|
947
1865
|
`);
|
|
948
1866
|
if (!mainConfigPath) {
|
|
949
|
-
|
|
1867
|
+
logger9.error("Unable to find the Forkbook main config");
|
|
950
1868
|
return;
|
|
951
1869
|
}
|
|
952
1870
|
let main = await readConfig(mainConfigPath);
|
|
953
|
-
|
|
1871
|
+
logger9.debug(`Uninstalling ${addon}`), await packageManager.removeDependencies([addon]), skipInstall || await packageManager.installDependencies();
|
|
954
1872
|
try {
|
|
955
1873
|
let entries = (main.getNamesFromPath(["addons"]) ?? []).filter(
|
|
956
1874
|
(name) => normalizeAddonName(name) === addon
|
|
957
1875
|
);
|
|
958
|
-
entries.length > 0 && (
|
|
1876
|
+
entries.length > 0 && (logger9.debug(`Removing '${addon}' from main.js addons field.`), entries.forEach((entry) => main.removeEntryFromArray(["addons"], entry)), await writeConfig(main));
|
|
959
1877
|
} catch (err) {
|
|
960
|
-
|
|
1878
|
+
logger9.warn(`Failed to remove '${addon}' from main.js addons field. ${String(err)}`);
|
|
961
1879
|
}
|
|
962
1880
|
}
|
|
963
1881
|
|
|
@@ -968,27 +1886,27 @@ function isPreservingSymlinks() {
|
|
|
968
1886
|
}
|
|
969
1887
|
|
|
970
1888
|
// src/common/utils/template.ts
|
|
971
|
-
import { existsSync, readFileSync as
|
|
972
|
-
import { join as
|
|
1889
|
+
import { existsSync as existsSync3, readFileSync as readFileSync6 } from "node:fs";
|
|
1890
|
+
import { join as join10, resolve as resolve8 } from "pathe";
|
|
973
1891
|
var interpolate2 = (string, data = {}) => Object.entries(data).reduce((acc, [k, v]) => acc.replace(new RegExp(`%${k}%`, "g"), v), string);
|
|
974
1892
|
function getPreviewBodyTemplate(configDirPath, interpolations) {
|
|
975
|
-
let base =
|
|
976
|
-
|
|
1893
|
+
let base = readFileSync6(
|
|
1894
|
+
join10(resolvePackageDir("@aussieljk/forkbook"), "assets/server/base-preview-body.html"),
|
|
977
1895
|
"utf8"
|
|
978
|
-
), bodyHtmlPath =
|
|
979
|
-
return
|
|
1896
|
+
), bodyHtmlPath = resolve8(configDirPath, "preview-body.html"), result = base;
|
|
1897
|
+
return existsSync3(bodyHtmlPath) && (result = readFileSync6(bodyHtmlPath, "utf8") + result), interpolate2(result, interpolations);
|
|
980
1898
|
}
|
|
981
1899
|
function getPreviewHeadTemplate(configDirPath, interpolations) {
|
|
982
|
-
let base =
|
|
983
|
-
|
|
1900
|
+
let base = readFileSync6(
|
|
1901
|
+
join10(resolvePackageDir("@aussieljk/forkbook"), "assets/server/base-preview-head.html"),
|
|
984
1902
|
"utf8"
|
|
985
|
-
), headHtmlPath =
|
|
986
|
-
return
|
|
1903
|
+
), headHtmlPath = resolve8(configDirPath, "preview-head.html"), result = base;
|
|
1904
|
+
return existsSync3(headHtmlPath) && (result += readFileSync6(headHtmlPath, "utf8")), interpolate2(result, interpolations);
|
|
987
1905
|
}
|
|
988
1906
|
|
|
989
1907
|
// src/common/utils/tsconfig.ts
|
|
990
|
-
import { existsSync as
|
|
991
|
-
import { basename as
|
|
1908
|
+
import { existsSync as existsSync4, readFileSync as readFileSync7, statSync } from "node:fs";
|
|
1909
|
+
import { basename as basename3, dirname as dirname7, extname as extname2, relative as relative3, resolve as resolve9 } from "node:path";
|
|
992
1910
|
var import_picomatch = __toESM(require_picomatch(), 1);
|
|
993
1911
|
import { parse as parseJsonc } from "jsonc-parser";
|
|
994
1912
|
var TSCONFIG_CANDIDATES = ["tsconfig.json", "tsconfig.base.json", "tsconfig.app.json"], DEFAULT_EXCLUDE_PATTERNS = ["node_modules", "bower_components", "jspm_packages"], findTsconfigPath = (cwd) => {
|
|
@@ -1002,16 +1920,16 @@ var TSCONFIG_CANDIDATES = ["tsconfig.json", "tsconfig.base.json", "tsconfig.app.
|
|
|
1002
1920
|
let rootTsconfigPath = findTsconfigPath(cwd);
|
|
1003
1921
|
if (!rootTsconfigPath)
|
|
1004
1922
|
return;
|
|
1005
|
-
let absoluteFilePath =
|
|
1923
|
+
let absoluteFilePath = resolve9(filePath), matchingConfigs = collectTsconfigEntries(rootTsconfigPath, /* @__PURE__ */ new Set()).filter(
|
|
1006
1924
|
(entry) => tsconfigIncludesFile(entry, absoluteFilePath)
|
|
1007
1925
|
);
|
|
1008
1926
|
return matchingConfigs.sort((left, right) => compareTsconfigEntries(absoluteFilePath, left, right)), matchingConfigs[0]?.path ?? rootTsconfigPath;
|
|
1009
|
-
}, findTsconfigPathForPath = (path) => isDirectoryPath(path) ? findTsconfigPath(path) : findTsconfigPathForFile(
|
|
1010
|
-
let normalizedConfigPath =
|
|
1011
|
-
return resolved.absoluteBaseUrl ?? resolved.pathsBasePath ??
|
|
1927
|
+
}, findTsconfigPathForPath = (path) => isDirectoryPath(path) ? findTsconfigPath(path) : findTsconfigPathForFile(dirname7(path), path), getTsconfigPathsBaseDir = (configPath) => {
|
|
1928
|
+
let normalizedConfigPath = resolve9(configPath), resolved = resolvePathsBase(normalizedConfigPath, /* @__PURE__ */ new Set());
|
|
1929
|
+
return resolved.absoluteBaseUrl ?? resolved.pathsBasePath ?? dirname7(normalizedConfigPath);
|
|
1012
1930
|
};
|
|
1013
1931
|
function resolvePathsBase(configPath, seen) {
|
|
1014
|
-
let normalizedConfigPath =
|
|
1932
|
+
let normalizedConfigPath = resolve9(configPath);
|
|
1015
1933
|
if (seen.has(normalizedConfigPath))
|
|
1016
1934
|
return {};
|
|
1017
1935
|
seen.add(normalizedConfigPath);
|
|
@@ -1028,20 +1946,20 @@ function resolvePathsBase(configPath, seen) {
|
|
|
1028
1946
|
}
|
|
1029
1947
|
let ownBaseUrl = config.compilerOptions?.baseUrl, ownPaths = config.compilerOptions?.paths;
|
|
1030
1948
|
return {
|
|
1031
|
-
absoluteBaseUrl: typeof ownBaseUrl == "string" && ownBaseUrl.length > 0 ?
|
|
1032
|
-
pathsBasePath: ownPaths != null && typeof ownPaths == "object" ?
|
|
1949
|
+
absoluteBaseUrl: typeof ownBaseUrl == "string" && ownBaseUrl.length > 0 ? resolve9(dirname7(normalizedConfigPath), ownBaseUrl) : inherited.absoluteBaseUrl,
|
|
1950
|
+
pathsBasePath: ownPaths != null && typeof ownPaths == "object" ? dirname7(normalizedConfigPath) : inherited.pathsBasePath
|
|
1033
1951
|
};
|
|
1034
1952
|
}
|
|
1035
1953
|
function isDirectoryPath(path) {
|
|
1036
1954
|
try {
|
|
1037
|
-
if (
|
|
1955
|
+
if (existsSync4(path))
|
|
1038
1956
|
return statSync(path).isDirectory();
|
|
1039
1957
|
} catch {
|
|
1040
1958
|
}
|
|
1041
|
-
return
|
|
1959
|
+
return extname2(path) === "";
|
|
1042
1960
|
}
|
|
1043
1961
|
function collectTsconfigEntries(configPath, seen) {
|
|
1044
|
-
let normalizedConfigPath =
|
|
1962
|
+
let normalizedConfigPath = resolve9(configPath);
|
|
1045
1963
|
if (seen.has(normalizedConfigPath))
|
|
1046
1964
|
return [];
|
|
1047
1965
|
seen.add(normalizedConfigPath);
|
|
@@ -1054,20 +1972,20 @@ function collectTsconfigEntries(configPath, seen) {
|
|
|
1054
1972
|
] : [];
|
|
1055
1973
|
}
|
|
1056
1974
|
function getReferencedTsconfigPaths(configPath, config) {
|
|
1057
|
-
return (Array.isArray(config.references) ? config.references : []).map((reference) => reference.path).filter((referencePath) => typeof referencePath == "string").map((referencePath) =>
|
|
1975
|
+
return (Array.isArray(config.references) ? config.references : []).map((reference) => reference.path).filter((referencePath) => typeof referencePath == "string").map((referencePath) => resolve9(dirname7(configPath), referencePath)).flatMap((referencePath) => resolveReferenceConfigPaths(referencePath));
|
|
1058
1976
|
}
|
|
1059
1977
|
function resolveReferenceConfigPaths(referencePath) {
|
|
1060
|
-
return referencePath.endsWith(".json") ? [referencePath] : TSCONFIG_CANDIDATES.map((candidate) =>
|
|
1978
|
+
return referencePath.endsWith(".json") ? [referencePath] : TSCONFIG_CANDIDATES.map((candidate) => resolve9(referencePath, candidate));
|
|
1061
1979
|
}
|
|
1062
1980
|
function tsconfigIncludesFile(entry, filePath) {
|
|
1063
|
-
let configDir =
|
|
1981
|
+
let configDir = dirname7(entry.path), relativeFilePath = normalizePath3(relative3(configDir, filePath));
|
|
1064
1982
|
if (relativeFilePath.startsWith("../") || relativeFilePath === ".." || isReferencesShell(entry.config))
|
|
1065
1983
|
return !1;
|
|
1066
1984
|
let ownership = resolveOwnershipSpec(entry.path, entry.config, /* @__PURE__ */ new Set());
|
|
1067
1985
|
if (ownership.files && ownership.files.length > 0) {
|
|
1068
|
-
let normalizedFilePath =
|
|
1986
|
+
let normalizedFilePath = normalizePath3(filePath);
|
|
1069
1987
|
return ownership.files.some(
|
|
1070
|
-
(candidatePath) =>
|
|
1988
|
+
(candidatePath) => normalizePath3(resolve9(configDir, candidatePath)) === normalizedFilePath
|
|
1071
1989
|
);
|
|
1072
1990
|
}
|
|
1073
1991
|
let includePatterns = getIncludePatterns(ownership, entry.config);
|
|
@@ -1080,7 +1998,7 @@ function tsconfigIncludesFile(entry, filePath) {
|
|
|
1080
1998
|
return matchesPatterns(relativeFilePath, excludePatterns) ? !1 : matchesPatterns(relativeFilePath, includePatterns);
|
|
1081
1999
|
}
|
|
1082
2000
|
function resolveOwnershipSpec(configPath, config, seen) {
|
|
1083
|
-
let normalizedConfigPath =
|
|
2001
|
+
let normalizedConfigPath = resolve9(configPath);
|
|
1084
2002
|
if (seen.has(normalizedConfigPath))
|
|
1085
2003
|
return {};
|
|
1086
2004
|
seen.add(normalizedConfigPath);
|
|
@@ -1092,7 +2010,7 @@ function resolveOwnershipSpec(configPath, config, seen) {
|
|
|
1092
2010
|
let baseOwnership = resolveOwnershipSpec(extendsPath, baseConfig, seen);
|
|
1093
2011
|
ownership = mergeOwnershipSpec(
|
|
1094
2012
|
ownership,
|
|
1095
|
-
rebaseOwnershipSpec(baseOwnership,
|
|
2013
|
+
rebaseOwnershipSpec(baseOwnership, dirname7(extendsPath), dirname7(normalizedConfigPath))
|
|
1096
2014
|
);
|
|
1097
2015
|
}
|
|
1098
2016
|
return mergeOwnershipSpec(ownership, ownOwnershipSpec(config));
|
|
@@ -1101,19 +2019,19 @@ function getExtendsPaths(configPath, config) {
|
|
|
1101
2019
|
return (typeof config.extends == "string" ? [config.extends] : Array.isArray(config.extends) ? config.extends.filter((value) => typeof value == "string") : []).map((extendsPath) => resolveExtendsPath(configPath, extendsPath));
|
|
1102
2020
|
}
|
|
1103
2021
|
function resolveExtendsPath(configPath, extendsPath) {
|
|
1104
|
-
let resolved =
|
|
1105
|
-
if (
|
|
2022
|
+
let resolved = resolve9(dirname7(configPath), extendsPath);
|
|
2023
|
+
if (existsSync4(resolved))
|
|
1106
2024
|
return resolved;
|
|
1107
2025
|
if (!resolved.endsWith(".json")) {
|
|
1108
2026
|
let withJson = `${resolved}.json`;
|
|
1109
|
-
if (
|
|
2027
|
+
if (existsSync4(withJson))
|
|
1110
2028
|
return withJson;
|
|
1111
2029
|
}
|
|
1112
2030
|
return resolved;
|
|
1113
2031
|
}
|
|
1114
2032
|
function ownOwnershipSpec(config) {
|
|
1115
2033
|
let ownership = {};
|
|
1116
|
-
return config.files !== void 0 && (ownership.files = asStringArray(config.files).map(
|
|
2034
|
+
return config.files !== void 0 && (ownership.files = asStringArray(config.files).map(normalizePath3)), config.include !== void 0 && (ownership.include = asStringArray(config.include).map(normalizePath3)), config.exclude !== void 0 && (ownership.exclude = asStringArray(config.exclude).map(normalizePath3)), ownership;
|
|
1117
2035
|
}
|
|
1118
2036
|
function mergeOwnershipSpec(base, overlay) {
|
|
1119
2037
|
return {
|
|
@@ -1130,7 +2048,7 @@ function rebaseOwnershipSpec(ownership, fromDir, toDir) {
|
|
|
1130
2048
|
};
|
|
1131
2049
|
}
|
|
1132
2050
|
function rebasePattern(pattern, fromDir, toDir) {
|
|
1133
|
-
return
|
|
2051
|
+
return normalizePath3(relative3(toDir, resolve9(fromDir, pattern)));
|
|
1134
2052
|
}
|
|
1135
2053
|
function isReferencesShell(config) {
|
|
1136
2054
|
if (!Array.isArray(config.references))
|
|
@@ -1139,18 +2057,18 @@ function isReferencesShell(config) {
|
|
|
1139
2057
|
return !hasOwnFiles && !hasOwnInclude;
|
|
1140
2058
|
}
|
|
1141
2059
|
function getIncludePatterns(ownership, leafConfig) {
|
|
1142
|
-
return ownership.include && ownership.include.length > 0 ? ownership.include.map(normalizeTsconfigPattern) : ownership.files && ownership.files.length > 0 ? ownership.files.map(
|
|
2060
|
+
return ownership.include && ownership.include.length > 0 ? ownership.include.map(normalizeTsconfigPattern) : ownership.files && ownership.files.length > 0 ? ownership.files.map(normalizePath3) : Array.isArray(leafConfig.files) && leafConfig.files.length === 0 && !ownership.include ? [] : ["**/*"];
|
|
1143
2061
|
}
|
|
1144
2062
|
function compareTsconfigEntries(filePath, left, right) {
|
|
1145
|
-
let leftDir =
|
|
2063
|
+
let leftDir = dirname7(left.path), rightDir = dirname7(right.path), leftDepth = normalizePath3(relative3(leftDir, filePath)).split("/").length, rightDepth = normalizePath3(relative3(rightDir, filePath)).split("/").length;
|
|
1146
2064
|
if (leftDepth !== rightDepth)
|
|
1147
2065
|
return leftDepth - rightDepth;
|
|
1148
|
-
let leftIsPrimaryTsconfig =
|
|
1149
|
-
return (
|
|
2066
|
+
let leftIsPrimaryTsconfig = basename3(left.path) === "tsconfig.json" ? 1 : 0;
|
|
2067
|
+
return (basename3(right.path) === "tsconfig.json" ? 1 : 0) - leftIsPrimaryTsconfig;
|
|
1150
2068
|
}
|
|
1151
2069
|
function readTsconfigConfig(configPath) {
|
|
1152
2070
|
try {
|
|
1153
|
-
let content =
|
|
2071
|
+
let content = readFileSync7(configPath, "utf-8"), errors = [], config = parseJsonc(content, errors, { allowTrailingComma: !0 });
|
|
1154
2072
|
return errors.length ? void 0 : config;
|
|
1155
2073
|
} catch {
|
|
1156
2074
|
return;
|
|
@@ -1160,10 +2078,10 @@ function matchesPatterns(filePath, patterns) {
|
|
|
1160
2078
|
return patterns.some((pattern) => (0, import_picomatch.default)(pattern, { dot: !0 })(filePath));
|
|
1161
2079
|
}
|
|
1162
2080
|
function normalizeTsconfigPattern(pattern) {
|
|
1163
|
-
let normalizedPattern =
|
|
2081
|
+
let normalizedPattern = normalizePath3(pattern);
|
|
1164
2082
|
return normalizedPattern.endsWith("/") ? `${normalizedPattern}**/*` : !import_picomatch.default.scan(normalizedPattern).isGlob && !/\.[^/]+$/.test(normalizedPattern) ? `${normalizedPattern}/**/*` : normalizedPattern;
|
|
1165
2083
|
}
|
|
1166
|
-
function
|
|
2084
|
+
function normalizePath3(value) {
|
|
1167
2085
|
return value.replaceAll("\\", "/");
|
|
1168
2086
|
}
|
|
1169
2087
|
function asStringArray(value) {
|
|
@@ -1195,15 +2113,15 @@ function validateFrameworkName(frameworkName) {
|
|
|
1195
2113
|
}
|
|
1196
2114
|
|
|
1197
2115
|
// src/common/utils/babel.ts
|
|
1198
|
-
import { readFileSync as
|
|
2116
|
+
import { readFileSync as readFileSync8 } from "node:fs";
|
|
1199
2117
|
import { createRequire } from "node:module";
|
|
1200
|
-
import { logger as
|
|
2118
|
+
import { logger as logger10 } from "@aussieljk/forkbook/internal/node-logger";
|
|
1201
2119
|
var require2 = createRequire(import.meta.url), getBabelPresetEnvMajor = () => {
|
|
1202
2120
|
try {
|
|
1203
|
-
let pkgPath = require2.resolve("@babel/preset-env/package.json"), { version } = JSON.parse(
|
|
2121
|
+
let pkgPath = require2.resolve("@babel/preset-env/package.json"), { version } = JSON.parse(readFileSync8(pkgPath, "utf8")), parsed = Number.parseInt(version, 10);
|
|
1204
2122
|
return Number.isNaN(parsed) ? void 0 : parsed;
|
|
1205
2123
|
} catch {
|
|
1206
|
-
|
|
2124
|
+
logger10.debug(
|
|
1207
2125
|
"Could not determine @babel/preset-env version in use. In case of runtime errors with @babel/preset-env, you may need to set the babelRemoveBugfixes feature flag in your `main.ts` file."
|
|
1208
2126
|
);
|
|
1209
2127
|
return;
|
|
@@ -1211,9 +2129,9 @@ var require2 = createRequire(import.meta.url), getBabelPresetEnvMajor = () => {
|
|
|
1211
2129
|
};
|
|
1212
2130
|
|
|
1213
2131
|
// src/common/utils/formatter.ts
|
|
1214
|
-
import { readFileSync as
|
|
1215
|
-
import { dirname as
|
|
1216
|
-
import { parse as
|
|
2132
|
+
import { readFileSync as readFileSync9 } from "node:fs";
|
|
2133
|
+
import { dirname as dirname8 } from "node:path";
|
|
2134
|
+
import { parse as parse3 } from "jsonc-parser";
|
|
1217
2135
|
import { format } from "oxfmt";
|
|
1218
2136
|
var CONFIG_FILES = [".oxfmtrc.json", ".oxfmtrc.jsonc"];
|
|
1219
2137
|
async function formatCode(filePath, content, options = {}) {
|
|
@@ -1225,20 +2143,20 @@ async function formatCode(filePath, content, options = {}) {
|
|
|
1225
2143
|
}
|
|
1226
2144
|
}
|
|
1227
2145
|
async function formatFileContent(filePath, content) {
|
|
1228
|
-
let configPath = any(CONFIG_FILES, { cwd:
|
|
2146
|
+
let configPath = any(CONFIG_FILES, { cwd: dirname8(filePath) });
|
|
1229
2147
|
if (!configPath)
|
|
1230
2148
|
return content;
|
|
1231
|
-
let { $schema, ignorePatterns, overrides, ...options } =
|
|
1232
|
-
|
|
2149
|
+
let { $schema, ignorePatterns, overrides, ...options } = parse3(
|
|
2150
|
+
readFileSync9(configPath, "utf8")
|
|
1233
2151
|
);
|
|
1234
2152
|
return formatCode(filePath, content, options);
|
|
1235
2153
|
}
|
|
1236
2154
|
|
|
1237
2155
|
// src/common/utils/get-story-id.ts
|
|
1238
|
-
import { relative as
|
|
2156
|
+
import { relative as relative4 } from "node:path";
|
|
1239
2157
|
import { normalizeStories as normalizeStories2, normalizeStoryPath as normalizeStoryPath2 } from "@aussieljk/forkbook/internal/common";
|
|
1240
2158
|
import { sanitize as sanitize2, storyNameFromExport, toId } from "@aussieljk/forkbook/internal/csf/csf-utils";
|
|
1241
|
-
import { dedent as
|
|
2159
|
+
import { dedent as dedent8 } from "ts-dedent";
|
|
1242
2160
|
|
|
1243
2161
|
// src/shared/story-index/autoTitle.ts
|
|
1244
2162
|
var sanitize = (parts) => {
|
|
@@ -1266,7 +2184,7 @@ var userOrAutoTitleFromSpecifier = (fileName, entry, userTitle) => {
|
|
|
1266
2184
|
|
|
1267
2185
|
// src/common/utils/posix.ts
|
|
1268
2186
|
import { posix as posixPath, sep as sep2 } from "node:path";
|
|
1269
|
-
var
|
|
2187
|
+
var posix3 = (localPath, seperator = sep2) => localPath.split(seperator).filter(Boolean).join(posixPath.sep);
|
|
1270
2188
|
|
|
1271
2189
|
// src/common/utils/get-story-id.ts
|
|
1272
2190
|
async function getStoryId(data, options) {
|
|
@@ -1276,7 +2194,7 @@ async function getStoryId(data, options) {
|
|
|
1276
2194
|
configDir: options.configDir
|
|
1277
2195
|
});
|
|
1278
2196
|
if (autoTitle === void 0)
|
|
1279
|
-
throw new Error(
|
|
2197
|
+
throw new Error(dedent8`
|
|
1280
2198
|
The new story file was successfully generated, but we are unable to index it. Please ensure that the new Story file is matched by the 'stories' glob pattern in your Forkbook configuration.
|
|
1281
2199
|
`);
|
|
1282
2200
|
let storyName = storyNameFromExport(data.exportedStoryName), storyId = toId(autoTitle, storyName), kind = sanitize2(autoTitle);
|
|
@@ -1292,7 +2210,7 @@ function getStoryTitle({
|
|
|
1292
2210
|
let normalizedStories = normalizeStories2(stories, {
|
|
1293
2211
|
configDir,
|
|
1294
2212
|
workingDir
|
|
1295
|
-
}), relativePath =
|
|
2213
|
+
}), relativePath = relative4(workingDir, storyFilePath), importPath = posix3(normalizeStoryPath2(relativePath));
|
|
1296
2214
|
return normalizedStories.map((normalizeStory) => userOrAutoTitleFromSpecifier(importPath, normalizeStory, userTitle)).filter(Boolean)[0];
|
|
1297
2215
|
}
|
|
1298
2216
|
|
|
@@ -1316,14 +2234,14 @@ function createLazyDocgenMiddleware({
|
|
|
1316
2234
|
}
|
|
1317
2235
|
|
|
1318
2236
|
// src/common/utils/sync-main-preview-addons.ts
|
|
1319
|
-
var
|
|
2237
|
+
var import_picocolors3 = __toESM(require_picocolors(), 1);
|
|
1320
2238
|
import { types as t3 } from "@aussieljk/forkbook/internal/babel";
|
|
1321
2239
|
import {
|
|
1322
2240
|
isCsfFactoryPreview,
|
|
1323
2241
|
readConfig as readConfig2,
|
|
1324
2242
|
writeConfig as writeConfig2
|
|
1325
2243
|
} from "@aussieljk/forkbook/internal/csf-tools";
|
|
1326
|
-
import { logger as
|
|
2244
|
+
import { logger as logger11 } from "@aussieljk/forkbook/internal/node-logger";
|
|
1327
2245
|
|
|
1328
2246
|
// src/common/utils/get-addon-annotations.ts
|
|
1329
2247
|
import { createRequire as createRequire2 } from "node:module";
|
|
@@ -1381,9 +2299,9 @@ async function syncPreviewAddonsWithMainConfig(mainConfig, previewConfig, config
|
|
|
1381
2299
|
)) : (previewConfig.setImport({ namespace: annotations.importName }, annotations.importPath), previewConfig.appendNodeToArray(["addons"], t3.identifier(annotations.importName))));
|
|
1382
2300
|
}
|
|
1383
2301
|
}
|
|
1384
|
-
return syncedAddons.length > 0 &&
|
|
1385
|
-
`Synchronizing addons from main config in ${
|
|
1386
|
-
${syncedAddons.map(
|
|
2302
|
+
return syncedAddons.length > 0 && logger11.log(
|
|
2303
|
+
`Synchronizing addons from main config in ${import_picocolors3.default.cyan(previewConfig.fileName)}:
|
|
2304
|
+
${syncedAddons.map(import_picocolors3.default.magenta).join(", ")}`
|
|
1387
2305
|
), previewConfig;
|
|
1388
2306
|
}
|
|
1389
2307
|
|
|
@@ -1537,13 +2455,13 @@ async function setupAddonInConfig({
|
|
|
1537
2455
|
}
|
|
1538
2456
|
|
|
1539
2457
|
// src/common/js-package-manager/JsPackageManagerFactory.ts
|
|
1540
|
-
import { existsSync as
|
|
1541
|
-
import { basename as
|
|
2458
|
+
import { existsSync as existsSync7, readFileSync as readFileSync15 } from "node:fs";
|
|
2459
|
+
import { basename as basename4, join as join17, parse as parse4, relative as relative5 } from "node:path";
|
|
1542
2460
|
|
|
1543
2461
|
// src/common/utils/command.ts
|
|
1544
|
-
import { logger as
|
|
1545
|
-
import { existsSync as
|
|
1546
|
-
import { delimiter, join as
|
|
2462
|
+
import { logger as logger12, prompt as prompt2 } from "@aussieljk/forkbook/internal/node-logger";
|
|
2463
|
+
import { existsSync as existsSync5 } from "node:fs";
|
|
2464
|
+
import { delimiter, join as join11 } from "node:path";
|
|
1547
2465
|
|
|
1548
2466
|
// src/common/utils/categorize-execa-error.ts
|
|
1549
2467
|
var PACKAGE_MANAGER_COMMANDS = /* @__PURE__ */ new Set(["npm", "pnpm", "yarn", "bun"]), PACKAGE_INSTALL_ARGS = /* @__PURE__ */ new Set(["install", "add", "ci", "i"]);
|
|
@@ -1630,7 +2548,7 @@ function getExecOptions({
|
|
|
1630
2548
|
cwd,
|
|
1631
2549
|
timeout,
|
|
1632
2550
|
shell,
|
|
1633
|
-
stdio: stdio ??
|
|
2551
|
+
stdio: stdio ?? prompt2.getPreferredStdio(),
|
|
1634
2552
|
env: {
|
|
1635
2553
|
...COMMON_ENV_VARS,
|
|
1636
2554
|
...env
|
|
@@ -1640,7 +2558,7 @@ function getExecOptions({
|
|
|
1640
2558
|
}
|
|
1641
2559
|
function executeCommand(options) {
|
|
1642
2560
|
let { command, args = [], ignoreError = !1 } = options;
|
|
1643
|
-
|
|
2561
|
+
logger12.debug(`Executing command: ${command} ${args.join(" ")}`);
|
|
1644
2562
|
let commandVariations = resolveCommand(command), execaProcess = tryCommandVariations(commandVariations, args, getExecOptions(options));
|
|
1645
2563
|
return ignoreError ? execaProcess.catch(() => {
|
|
1646
2564
|
}) : attachCategorizedExecaFailureHandler(execaProcess, { command, args }), execaProcess;
|
|
@@ -1672,14 +2590,14 @@ function shouldRetry(error, isLastVariation) {
|
|
|
1672
2590
|
return isCommandNotFoundError(error) && !isLastVariation;
|
|
1673
2591
|
}
|
|
1674
2592
|
function isExecutableInPath(command) {
|
|
1675
|
-
return (process.env.PATH || "").split(delimiter).some((dir) =>
|
|
2593
|
+
return (process.env.PATH || "").split(delimiter).some((dir) => existsSync5(join11(dir, command)));
|
|
1676
2594
|
}
|
|
1677
2595
|
function tryCommandVariations(commandVariations, args, options) {
|
|
1678
2596
|
if (commandVariations.length <= 1)
|
|
1679
2597
|
return exec(commandVariations[0], args, options);
|
|
1680
2598
|
for (let cmd of commandVariations.slice(0, -1))
|
|
1681
2599
|
if (isExecutableInPath(cmd))
|
|
1682
|
-
return
|
|
2600
|
+
return logger12.debug(`Resolved command variation: ${cmd}`), exec(cmd, args, options);
|
|
1683
2601
|
return exec(commandVariations[commandVariations.length - 1], args, options);
|
|
1684
2602
|
}
|
|
1685
2603
|
function tryCommandVariationsSync(commandVariations, args, options) {
|
|
@@ -1691,7 +2609,7 @@ function tryCommandVariationsSync(commandVariations, args, options) {
|
|
|
1691
2609
|
} catch (error) {
|
|
1692
2610
|
if (lastError = error, !shouldRetry(error, i === commandVariations.length - 1))
|
|
1693
2611
|
throw error;
|
|
1694
|
-
|
|
2612
|
+
logger12.debug(`Command "${cmd}" not found, trying next variation...`);
|
|
1695
2613
|
}
|
|
1696
2614
|
}
|
|
1697
2615
|
throw lastError;
|
|
@@ -1710,15 +2628,15 @@ function resolveCommand(command) {
|
|
|
1710
2628
|
}
|
|
1711
2629
|
|
|
1712
2630
|
// src/common/js-package-manager/BUNProxy.ts
|
|
1713
|
-
import { readFileSync as
|
|
1714
|
-
import { join as
|
|
1715
|
-
import { logger as
|
|
2631
|
+
import { readFileSync as readFileSync10, writeFileSync as writeFileSync3 } from "node:fs";
|
|
2632
|
+
import { join as join12 } from "node:path";
|
|
2633
|
+
import { logger as logger13, prompt as prompt3 } from "@aussieljk/forkbook/internal/node-logger";
|
|
1716
2634
|
import {
|
|
1717
2635
|
FindPackageVersionsError,
|
|
1718
2636
|
MinimumReleaseAgeHandledError
|
|
1719
2637
|
} from "@aussieljk/forkbook/internal/server-errors";
|
|
1720
2638
|
import sort from "semver/functions/sort.js";
|
|
1721
|
-
import { dedent as
|
|
2639
|
+
import { dedent as dedent9 } from "ts-dedent";
|
|
1722
2640
|
var BUNProxy = class extends JsPackageManager {
|
|
1723
2641
|
constructor() {
|
|
1724
2642
|
super(...arguments);
|
|
@@ -1746,11 +2664,11 @@ var BUNProxy = class extends JsPackageManager {
|
|
|
1746
2664
|
return `bunx ${args.join(" ")}`;
|
|
1747
2665
|
}
|
|
1748
2666
|
async getModulePackageJSON(packageName) {
|
|
1749
|
-
let wantedPath =
|
|
2667
|
+
let wantedPath = join12("node_modules", packageName, "package.json"), packageJsonPath = up2(wantedPath, {
|
|
1750
2668
|
cwd: this.primaryPackageJson.operationDir,
|
|
1751
2669
|
last: getProjectRoot()
|
|
1752
2670
|
});
|
|
1753
|
-
return packageJsonPath ? JSON.parse(
|
|
2671
|
+
return packageJsonPath ? JSON.parse(readFileSync10(packageJsonPath, "utf-8")) : null;
|
|
1754
2672
|
}
|
|
1755
2673
|
getInstallArgs() {
|
|
1756
2674
|
return this.installArgs || (this.installArgs = []), this.installArgs;
|
|
@@ -1787,7 +2705,7 @@ var BUNProxy = class extends JsPackageManager {
|
|
|
1787
2705
|
let result = await await exec2({ packageDepth: 0 }), commandResult = typeof result.stdout == "string" ? result.stdout : "", parsedOutput = JSON.parse(commandResult);
|
|
1788
2706
|
return this.mapDependencies(parsedOutput, pattern);
|
|
1789
2707
|
} catch (err) {
|
|
1790
|
-
|
|
2708
|
+
logger13.debug(
|
|
1791
2709
|
`An issue occurred while trying to find dependencies metadata using npm: ${err}`
|
|
1792
2710
|
);
|
|
1793
2711
|
return;
|
|
@@ -1807,7 +2725,7 @@ var BUNProxy = class extends JsPackageManager {
|
|
|
1807
2725
|
command: "bun",
|
|
1808
2726
|
args: ["install", ...this.getInstallArgs(), ...options?.force ? ["--force"] : []],
|
|
1809
2727
|
cwd: this.cwd,
|
|
1810
|
-
stdio:
|
|
2728
|
+
stdio: prompt3.getPreferredStdio()
|
|
1811
2729
|
});
|
|
1812
2730
|
}
|
|
1813
2731
|
async installDependencies(options) {
|
|
@@ -1824,7 +2742,7 @@ var BUNProxy = class extends JsPackageManager {
|
|
|
1824
2742
|
failedPackage: this.extractMinimumReleaseAgePackage(logs),
|
|
1825
2743
|
cause: error
|
|
1826
2744
|
});
|
|
1827
|
-
throw
|
|
2745
|
+
throw logger13.error(handledError.message), handledError;
|
|
1828
2746
|
}
|
|
1829
2747
|
throw error;
|
|
1830
2748
|
}
|
|
@@ -1850,11 +2768,11 @@ var BUNProxy = class extends JsPackageManager {
|
|
|
1850
2768
|
Math.ceil(minimumReleaseAgeSeconds / 60)
|
|
1851
2769
|
);
|
|
1852
2770
|
if (nonInteractive) {
|
|
1853
|
-
this.updateMinimumReleaseAgeExcludes(),
|
|
1854
|
-
|
|
2771
|
+
this.updateMinimumReleaseAgeExcludes(), logger13.info(
|
|
2772
|
+
dedent9`
|
|
1855
2773
|
bun minimumReleaseAge would block storybook@${storybookVersion} from being installed because it was released within the configured minimumReleaseAge window, so Forkbook updated minimumReleaseAgeExcludes for this project automatically.
|
|
1856
2774
|
|
|
1857
|
-
Added patterns:
|
|
2775
|
+
Added patterns: ${FORKBOOK_PACKAGE_PATTERNS.join(", ")}
|
|
1858
2776
|
|
|
1859
2777
|
Read more:
|
|
1860
2778
|
- https://bun.com/docs/pm/cli/install#minimum-release-age
|
|
@@ -1862,7 +2780,7 @@ var BUNProxy = class extends JsPackageManager {
|
|
|
1862
2780
|
);
|
|
1863
2781
|
return;
|
|
1864
2782
|
}
|
|
1865
|
-
|
|
2783
|
+
logger13.warn(
|
|
1866
2784
|
`bun minimumReleaseAge will block storybook@${storybookVersion} from being installed because it was released within the disallowed immaturity window.`
|
|
1867
2785
|
);
|
|
1868
2786
|
let rerunError = new MinimumReleaseAgeHandledError({
|
|
@@ -1871,7 +2789,7 @@ var BUNProxy = class extends JsPackageManager {
|
|
|
1871
2789
|
compatibleVersion
|
|
1872
2790
|
})
|
|
1873
2791
|
});
|
|
1874
|
-
if (await
|
|
2792
|
+
if (await prompt3.select(
|
|
1875
2793
|
{
|
|
1876
2794
|
message: "How would you like to proceed?",
|
|
1877
2795
|
options: [
|
|
@@ -1887,14 +2805,14 @@ var BUNProxy = class extends JsPackageManager {
|
|
|
1887
2805
|
},
|
|
1888
2806
|
{
|
|
1889
2807
|
onCancel: () => {
|
|
1890
|
-
throw
|
|
2808
|
+
throw logger13.error(rerunError.message), rerunError;
|
|
1891
2809
|
}
|
|
1892
2810
|
}
|
|
1893
2811
|
) === "exclude") {
|
|
1894
2812
|
this.updateMinimumReleaseAgeExcludes();
|
|
1895
2813
|
return;
|
|
1896
2814
|
}
|
|
1897
|
-
throw
|
|
2815
|
+
throw logger13.error(rerunError.message), rerunError;
|
|
1898
2816
|
}
|
|
1899
2817
|
async getRegistryURL() {
|
|
1900
2818
|
let result = await executeCommand({
|
|
@@ -1978,7 +2896,7 @@ var BUNProxy = class extends JsPackageManager {
|
|
|
1978
2896
|
compatibleVersion
|
|
1979
2897
|
}) {
|
|
1980
2898
|
let rerunCommand = getStorybookRerunCommand(compatibleVersion);
|
|
1981
|
-
return
|
|
2899
|
+
return dedent9`
|
|
1982
2900
|
bun minimumReleaseAge blocked storybook@${currentVersion} from being installed.
|
|
1983
2901
|
|
|
1984
2902
|
${FORKBOOK_RERUN_INSTRUCTION}
|
|
@@ -1989,7 +2907,7 @@ var BUNProxy = class extends JsPackageManager {
|
|
|
1989
2907
|
`;
|
|
1990
2908
|
}
|
|
1991
2909
|
updateMinimumReleaseAgeExcludes() {
|
|
1992
|
-
let bunfigPath =
|
|
2910
|
+
let bunfigPath = join12(this.cwd, "bunfig.toml"), currentContent = this.readBunfig() ?? "", lineEnding = currentContent.includes(`\r
|
|
1993
2911
|
`) ? `\r
|
|
1994
2912
|
` : `
|
|
1995
2913
|
`, replacement = [
|
|
@@ -2007,7 +2925,7 @@ var BUNProxy = class extends JsPackageManager {
|
|
|
2007
2925
|
),
|
|
2008
2926
|
currentContent.slice(installSectionRange.end)
|
|
2009
2927
|
].join("") : this.updateMinimumReleaseAgeExcludesInContent(currentContent, replacement, lineEnding);
|
|
2010
|
-
|
|
2928
|
+
writeFileSync3(bunfigPath, nextContent);
|
|
2011
2929
|
}
|
|
2012
2930
|
updateMinimumReleaseAgeExcludesInContent(content, replacement, lineEnding) {
|
|
2013
2931
|
return content.match(/^minimumReleaseAgeExcludes\s*=\s*\[[\s\S]*?\]/m) ? content.replace(/^minimumReleaseAgeExcludes\s*=\s*\[[\s\S]*?\]/m, replacement) : content.match(/^minimumReleaseAge\s*=\s*.+$/m) ? content.replace(
|
|
@@ -2033,7 +2951,7 @@ var BUNProxy = class extends JsPackageManager {
|
|
|
2033
2951
|
}
|
|
2034
2952
|
readBunfig() {
|
|
2035
2953
|
try {
|
|
2036
|
-
return
|
|
2954
|
+
return readFileSync10(join12(this.cwd, "bunfig.toml"), "utf-8");
|
|
2037
2955
|
} catch {
|
|
2038
2956
|
return null;
|
|
2039
2957
|
}
|
|
@@ -2065,15 +2983,15 @@ var BUNProxy = class extends JsPackageManager {
|
|
|
2065
2983
|
};
|
|
2066
2984
|
|
|
2067
2985
|
// src/common/js-package-manager/NPMProxy.ts
|
|
2068
|
-
import { readFileSync as
|
|
2069
|
-
import { dirname as
|
|
2070
|
-
import { logger as
|
|
2986
|
+
import { readFileSync as readFileSync11 } from "node:fs";
|
|
2987
|
+
import { dirname as dirname9, join as join13 } from "node:path";
|
|
2988
|
+
import { logger as logger14, prompt as prompt4 } from "@aussieljk/forkbook/internal/node-logger";
|
|
2071
2989
|
import {
|
|
2072
2990
|
FindPackageVersionsError as FindPackageVersionsError2,
|
|
2073
2991
|
MinimumReleaseAgeHandledError as MinimumReleaseAgeHandledError2
|
|
2074
2992
|
} from "@aussieljk/forkbook/internal/server-errors";
|
|
2075
2993
|
import sort2 from "semver/functions/sort.js";
|
|
2076
|
-
import { dedent as
|
|
2994
|
+
import { dedent as dedent10 } from "ts-dedent";
|
|
2077
2995
|
var NPM_CONFIG_WORKSPACE_ARGS = ["--workspaces=false", "--include-workspace-root"];
|
|
2078
2996
|
var NPMProxy = class extends JsPackageManager {
|
|
2079
2997
|
constructor() {
|
|
@@ -2090,11 +3008,11 @@ var NPMProxy = class extends JsPackageManager {
|
|
|
2090
3008
|
return `npm run ${command}`;
|
|
2091
3009
|
}
|
|
2092
3010
|
async getModulePackageJSON(packageName) {
|
|
2093
|
-
let wantedPath =
|
|
3011
|
+
let wantedPath = join13("node_modules", packageName, "package.json"), packageJsonPath = up2(wantedPath, {
|
|
2094
3012
|
cwd: this.primaryPackageJson.operationDir,
|
|
2095
3013
|
last: getProjectRoot()
|
|
2096
3014
|
});
|
|
2097
|
-
return packageJsonPath ? JSON.parse(
|
|
3015
|
+
return packageJsonPath ? JSON.parse(readFileSync11(packageJsonPath, "utf-8")) : null;
|
|
2098
3016
|
}
|
|
2099
3017
|
getInstallArgs() {
|
|
2100
3018
|
return this.installArgs || (this.installArgs = []), this.installArgs;
|
|
@@ -2141,7 +3059,7 @@ var NPMProxy = class extends JsPackageManager {
|
|
|
2141
3059
|
let childProcess = await exec2({ packageDepth: 0 }), commandResult = typeof childProcess.stdout == "string" ? childProcess.stdout : "", parsedOutput = JSON.parse(commandResult);
|
|
2142
3060
|
return this.mapDependencies(parsedOutput, pattern);
|
|
2143
3061
|
} catch (e) {
|
|
2144
|
-
|
|
3062
|
+
logger14.debug(`Error finding installations for ${pattern.join(", ")}: ${String(e)}`);
|
|
2145
3063
|
return;
|
|
2146
3064
|
}
|
|
2147
3065
|
}
|
|
@@ -2160,7 +3078,7 @@ var NPMProxy = class extends JsPackageManager {
|
|
|
2160
3078
|
return packageJsonPath && patterns?.length && globSync(
|
|
2161
3079
|
patterns.filter((pattern) => !pattern.startsWith("!")).map((pattern) => `${pattern}/package.json`),
|
|
2162
3080
|
{
|
|
2163
|
-
cwd:
|
|
3081
|
+
cwd: dirname9(ancestorPath),
|
|
2164
3082
|
absolute: !0,
|
|
2165
3083
|
expandDirectories: !1,
|
|
2166
3084
|
ignore: patterns.filter((pattern) => pattern.startsWith("!")).map((pattern) => `${pattern.slice(1)}/package.json`)
|
|
@@ -2170,8 +3088,8 @@ var NPMProxy = class extends JsPackageManager {
|
|
|
2170
3088
|
return executeCommand({
|
|
2171
3089
|
command: "npm",
|
|
2172
3090
|
args: ["install", ...this.getInstallArgs(), ...options?.force ? ["--force"] : []],
|
|
2173
|
-
cwd: workspacePackageJsonPath ?
|
|
2174
|
-
stdio:
|
|
3091
|
+
cwd: workspacePackageJsonPath ? dirname9(workspacePackageJsonPath) : this.cwd,
|
|
3092
|
+
stdio: prompt4.getPreferredStdio()
|
|
2175
3093
|
});
|
|
2176
3094
|
}
|
|
2177
3095
|
async installDependencies(options) {
|
|
@@ -2187,7 +3105,7 @@ var NPMProxy = class extends JsPackageManager {
|
|
|
2187
3105
|
failedPackage: this.extractMinimumReleaseAgePackage(logs),
|
|
2188
3106
|
cause: error
|
|
2189
3107
|
});
|
|
2190
|
-
throw
|
|
3108
|
+
throw logger14.error(handledError.message), handledError;
|
|
2191
3109
|
}
|
|
2192
3110
|
throw error;
|
|
2193
3111
|
}
|
|
@@ -2216,7 +3134,7 @@ var NPMProxy = class extends JsPackageManager {
|
|
|
2216
3134
|
compatibleVersion
|
|
2217
3135
|
})
|
|
2218
3136
|
});
|
|
2219
|
-
throw
|
|
3137
|
+
throw logger14.error(error.message), error;
|
|
2220
3138
|
}
|
|
2221
3139
|
async getRegistryURL() {
|
|
2222
3140
|
let result = await executeCommand({
|
|
@@ -2232,7 +3150,7 @@ var NPMProxy = class extends JsPackageManager {
|
|
|
2232
3150
|
return installAsDevDependencies && (args = ["-D", ...args]), executeCommand({
|
|
2233
3151
|
command: "npm",
|
|
2234
3152
|
args: ["install", ...args, ...this.getInstallArgs()],
|
|
2235
|
-
stdio:
|
|
3153
|
+
stdio: prompt4.getPreferredStdio(),
|
|
2236
3154
|
cwd: this.primaryPackageJson.operationDir
|
|
2237
3155
|
});
|
|
2238
3156
|
}
|
|
@@ -2300,7 +3218,7 @@ var NPMProxy = class extends JsPackageManager {
|
|
|
2300
3218
|
compatibleVersion
|
|
2301
3219
|
}) {
|
|
2302
3220
|
let rerunCommand = getStorybookRerunCommand(compatibleVersion);
|
|
2303
|
-
return
|
|
3221
|
+
return dedent10`
|
|
2304
3222
|
npm min-release-age blocked storybook@${currentVersion} from being installed.
|
|
2305
3223
|
|
|
2306
3224
|
${FORKBOOK_RERUN_INSTRUCTION}
|
|
@@ -2327,16 +3245,16 @@ var NPMProxy = class extends JsPackageManager {
|
|
|
2327
3245
|
};
|
|
2328
3246
|
|
|
2329
3247
|
// src/common/js-package-manager/PNPMProxy.ts
|
|
2330
|
-
import { existsSync as
|
|
2331
|
-
import { join as
|
|
2332
|
-
import { logger as
|
|
3248
|
+
import { existsSync as existsSync6, readFileSync as readFileSync12, writeFileSync as writeFileSync4 } from "node:fs";
|
|
3249
|
+
import { join as join14 } from "node:path";
|
|
3250
|
+
import { logger as logger15, prompt as prompt5 } from "@aussieljk/forkbook/internal/node-logger";
|
|
2333
3251
|
import {
|
|
2334
3252
|
FindPackageVersionsError as FindPackageVersionsError3,
|
|
2335
3253
|
MinimumReleaseAgeHandledError as MinimumReleaseAgeHandledError3
|
|
2336
3254
|
} from "@aussieljk/forkbook/internal/server-errors";
|
|
2337
3255
|
var import_yaml = __toESM(require_dist(), 1);
|
|
2338
|
-
import { coerce, gte } from "semver";
|
|
2339
|
-
import { dedent as
|
|
3256
|
+
import { coerce as coerce2, gte } from "semver";
|
|
3257
|
+
import { dedent as dedent11 } from "ts-dedent";
|
|
2340
3258
|
var PNPM_ALLOW_BUILD_DLX_MIN = "10.2.0", PNPMProxy = class extends JsPackageManager {
|
|
2341
3259
|
constructor() {
|
|
2342
3260
|
super(...arguments);
|
|
@@ -2346,7 +3264,7 @@ var PNPM_ALLOW_BUILD_DLX_MIN = "10.2.0", PNPMProxy = class extends JsPackageMana
|
|
|
2346
3264
|
#pnpmVersion;
|
|
2347
3265
|
detectWorkspaceRoot() {
|
|
2348
3266
|
let pnpmWorkspaceYaml = `${process.cwd()}/pnpm-workspace.yaml`;
|
|
2349
|
-
return
|
|
3267
|
+
return existsSync6(pnpmWorkspaceYaml);
|
|
2350
3268
|
}
|
|
2351
3269
|
getCommandName() {
|
|
2352
3270
|
return "pnpm";
|
|
@@ -2364,7 +3282,7 @@ var PNPM_ALLOW_BUILD_DLX_MIN = "10.2.0", PNPMProxy = class extends JsPackageMana
|
|
|
2364
3282
|
if (this.#pnpmVersion !== void 0)
|
|
2365
3283
|
return this.#pnpmVersion;
|
|
2366
3284
|
try {
|
|
2367
|
-
|
|
3285
|
+
logger15.debug("Executing command: pnpm --version");
|
|
2368
3286
|
let stdout = executeCommandSync({
|
|
2369
3287
|
cwd: this.cwd,
|
|
2370
3288
|
command: "pnpm",
|
|
@@ -2378,7 +3296,7 @@ var PNPM_ALLOW_BUILD_DLX_MIN = "10.2.0", PNPMProxy = class extends JsPackageMana
|
|
|
2378
3296
|
return this.#pnpmVersion;
|
|
2379
3297
|
}
|
|
2380
3298
|
#pnpmGte(minimum) {
|
|
2381
|
-
let version =
|
|
3299
|
+
let version = coerce2(this.#readPnpmVersion());
|
|
2382
3300
|
return version != null && gte(version, minimum);
|
|
2383
3301
|
}
|
|
2384
3302
|
/**
|
|
@@ -2439,16 +3357,16 @@ var PNPM_ALLOW_BUILD_DLX_MIN = "10.2.0", PNPMProxy = class extends JsPackageMana
|
|
|
2439
3357
|
}), commandResult = typeof childProcess.stdout == "string" ? childProcess.stdout : "", parsedOutput = JSON.parse(commandResult);
|
|
2440
3358
|
return this.mapDependencies(parsedOutput, pattern);
|
|
2441
3359
|
} catch (e) {
|
|
2442
|
-
|
|
3360
|
+
logger15.debug(`Error finding installations for ${pattern.join(", ")}: ${String(e)}`);
|
|
2443
3361
|
return;
|
|
2444
3362
|
}
|
|
2445
3363
|
}
|
|
2446
3364
|
async getModulePackageJSON(packageName) {
|
|
2447
|
-
let wantedPath =
|
|
3365
|
+
let wantedPath = join14("node_modules", packageName, "package.json"), packageJsonPath = up2(wantedPath, {
|
|
2448
3366
|
cwd: this.primaryPackageJson.operationDir,
|
|
2449
3367
|
last: getProjectRoot()
|
|
2450
3368
|
});
|
|
2451
|
-
return packageJsonPath ? JSON.parse(
|
|
3369
|
+
return packageJsonPath ? JSON.parse(readFileSync12(packageJsonPath, "utf-8")) : null;
|
|
2452
3370
|
}
|
|
2453
3371
|
getResolutions(packageJson, versions) {
|
|
2454
3372
|
return {
|
|
@@ -2498,12 +3416,12 @@ var PNPM_ALLOW_BUILD_DLX_MIN = "10.2.0", PNPMProxy = class extends JsPackageMana
|
|
|
2498
3416
|
if (!path)
|
|
2499
3417
|
return null;
|
|
2500
3418
|
try {
|
|
2501
|
-
let doc = (0, import_yaml.parseDocument)(
|
|
3419
|
+
let doc = (0, import_yaml.parseDocument)(readFileSync12(path, "utf8"));
|
|
2502
3420
|
if (doc.errors.length > 0)
|
|
2503
3421
|
throw doc.errors[0];
|
|
2504
3422
|
return { path, doc };
|
|
2505
3423
|
} catch (e) {
|
|
2506
|
-
return
|
|
3424
|
+
return logger15.debug(`Could not read pnpm workspace file ${path}: ${String(e)}`), null;
|
|
2507
3425
|
}
|
|
2508
3426
|
}
|
|
2509
3427
|
/**
|
|
@@ -2526,23 +3444,23 @@ var PNPM_ALLOW_BUILD_DLX_MIN = "10.2.0", PNPMProxy = class extends JsPackageMana
|
|
|
2526
3444
|
#registerCatalogEntries(packages, version, anchorPackage, catalogName) {
|
|
2527
3445
|
let workspace = this.#readWorkspaceYaml();
|
|
2528
3446
|
if (!workspace)
|
|
2529
|
-
return
|
|
3447
|
+
return logger15.warn(
|
|
2530
3448
|
`Could not read pnpm-workspace.yaml to register catalog entries for: ${packages.join(", ")}`
|
|
2531
3449
|
), !1;
|
|
2532
3450
|
try {
|
|
2533
3451
|
let keyPath = this.#catalogKeyPath(workspace.doc, catalogName), anchorVersion = workspace.doc.getIn([...keyPath, anchorPackage]), entryVersion = typeof anchorVersion == "string" || typeof anchorVersion == "number" ? String(anchorVersion) : version, changed = !1;
|
|
2534
3452
|
for (let pkg of packages)
|
|
2535
3453
|
workspace.doc.getIn([...keyPath, pkg]) === void 0 && (workspace.doc.setIn([...keyPath, pkg], entryVersion), changed = !0);
|
|
2536
|
-
return changed &&
|
|
3454
|
+
return changed && writeFileSync4(workspace.path, workspace.doc.toString(), "utf8"), !0;
|
|
2537
3455
|
} catch (e) {
|
|
2538
|
-
return
|
|
3456
|
+
return logger15.warn(`Could not update pnpm catalog in ${workspace.path}: ${String(e)}`), !1;
|
|
2539
3457
|
}
|
|
2540
3458
|
}
|
|
2541
3459
|
runInstall(options) {
|
|
2542
3460
|
return executeCommand({
|
|
2543
3461
|
command: "pnpm",
|
|
2544
3462
|
args: ["install", ...this.getInstallArgs("install"), ...options?.force ? ["--force"] : []],
|
|
2545
|
-
stdio:
|
|
3463
|
+
stdio: prompt5.getPreferredStdio(),
|
|
2546
3464
|
cwd: this.cwd
|
|
2547
3465
|
});
|
|
2548
3466
|
}
|
|
@@ -2561,7 +3479,7 @@ var PNPM_ALLOW_BUILD_DLX_MIN = "10.2.0", PNPMProxy = class extends JsPackageMana
|
|
|
2561
3479
|
failedPackage: this.extractFailedPackage(logs),
|
|
2562
3480
|
cause: error
|
|
2563
3481
|
});
|
|
2564
|
-
throw
|
|
3482
|
+
throw logger15.error(handledError.message), handledError;
|
|
2565
3483
|
}
|
|
2566
3484
|
throw error;
|
|
2567
3485
|
}
|
|
@@ -2581,11 +3499,11 @@ var PNPM_ALLOW_BUILD_DLX_MIN = "10.2.0", PNPMProxy = class extends JsPackageMana
|
|
|
2581
3499
|
minimumReleaseAge
|
|
2582
3500
|
);
|
|
2583
3501
|
if (nonInteractive) {
|
|
2584
|
-
await this.updateMinimumReleaseAgeExclude(),
|
|
2585
|
-
|
|
3502
|
+
await this.updateMinimumReleaseAgeExclude(), logger15.info(
|
|
3503
|
+
dedent11`
|
|
2586
3504
|
pnpm minimumReleaseAge would block storybook@${storybookVersion} from being installed because it was released within the configured minimumReleaseAge window, so Forkbook updated minimumReleaseAgeExclude for this project automatically.
|
|
2587
3505
|
|
|
2588
|
-
Added patterns:
|
|
3506
|
+
Added patterns: ${FORKBOOK_PACKAGE_PATTERNS.join(", ")}
|
|
2589
3507
|
|
|
2590
3508
|
Read more:
|
|
2591
3509
|
- https://pnpm.io/settings#minimumreleaseage
|
|
@@ -2594,7 +3512,7 @@ var PNPM_ALLOW_BUILD_DLX_MIN = "10.2.0", PNPMProxy = class extends JsPackageMana
|
|
|
2594
3512
|
);
|
|
2595
3513
|
return;
|
|
2596
3514
|
}
|
|
2597
|
-
|
|
3515
|
+
logger15.warn(
|
|
2598
3516
|
`pnpm minimumReleaseAge will block storybook@${storybookVersion} from being installed because it was published within the configured minimum-release-age window.`
|
|
2599
3517
|
);
|
|
2600
3518
|
let rerunError = new MinimumReleaseAgeHandledError3({
|
|
@@ -2603,7 +3521,7 @@ var PNPM_ALLOW_BUILD_DLX_MIN = "10.2.0", PNPMProxy = class extends JsPackageMana
|
|
|
2603
3521
|
compatibleVersion
|
|
2604
3522
|
})
|
|
2605
3523
|
});
|
|
2606
|
-
if (await
|
|
3524
|
+
if (await prompt5.select(
|
|
2607
3525
|
{
|
|
2608
3526
|
message: "How would you like to proceed?",
|
|
2609
3527
|
options: [
|
|
@@ -2619,14 +3537,14 @@ var PNPM_ALLOW_BUILD_DLX_MIN = "10.2.0", PNPMProxy = class extends JsPackageMana
|
|
|
2619
3537
|
},
|
|
2620
3538
|
{
|
|
2621
3539
|
onCancel: () => {
|
|
2622
|
-
throw
|
|
3540
|
+
throw logger15.error(rerunError.message), rerunError;
|
|
2623
3541
|
}
|
|
2624
3542
|
}
|
|
2625
3543
|
) === "exclude") {
|
|
2626
3544
|
await this.updateMinimumReleaseAgeExclude();
|
|
2627
3545
|
return;
|
|
2628
3546
|
}
|
|
2629
|
-
throw
|
|
3547
|
+
throw logger15.error(rerunError.message), rerunError;
|
|
2630
3548
|
}
|
|
2631
3549
|
runAddDeps(dependencies, installAsDevDependencies) {
|
|
2632
3550
|
let args = [...dependencies];
|
|
@@ -2635,7 +3553,7 @@ var PNPM_ALLOW_BUILD_DLX_MIN = "10.2.0", PNPMProxy = class extends JsPackageMana
|
|
|
2635
3553
|
return executeCommand({
|
|
2636
3554
|
command: "pnpm",
|
|
2637
3555
|
args: commandArgs,
|
|
2638
|
-
stdio:
|
|
3556
|
+
stdio: prompt5.getPreferredStdio(),
|
|
2639
3557
|
cwd: this.primaryPackageJson.operationDir
|
|
2640
3558
|
});
|
|
2641
3559
|
}
|
|
@@ -2726,7 +3644,7 @@ var PNPM_ALLOW_BUILD_DLX_MIN = "10.2.0", PNPMProxy = class extends JsPackageMana
|
|
|
2726
3644
|
compatibleVersion
|
|
2727
3645
|
}) {
|
|
2728
3646
|
let rerunCommand = getStorybookRerunCommand(compatibleVersion);
|
|
2729
|
-
return
|
|
3647
|
+
return dedent11`
|
|
2730
3648
|
pnpm minimumReleaseAge blocked storybook@${currentVersion} from being installed.
|
|
2731
3649
|
|
|
2732
3650
|
${FORKBOOK_RERUN_INSTRUCTION}
|
|
@@ -2740,7 +3658,7 @@ var PNPM_ALLOW_BUILD_DLX_MIN = "10.2.0", PNPMProxy = class extends JsPackageMana
|
|
|
2740
3658
|
let currentMinimumReleaseAgeExclude = await this.getMinimumReleaseAgeExclude(), nextMinimumReleaseAgeExclude = Array.from(
|
|
2741
3659
|
/* @__PURE__ */ new Set([...currentMinimumReleaseAgeExclude, ...FORKBOOK_PACKAGE_PATTERNS])
|
|
2742
3660
|
);
|
|
2743
|
-
await
|
|
3661
|
+
await prompt5.executeTaskWithSpinner(
|
|
2744
3662
|
() => this.runInternalCommand(
|
|
2745
3663
|
"config",
|
|
2746
3664
|
[
|
|
@@ -2778,10 +3696,10 @@ var PNPM_ALLOW_BUILD_DLX_MIN = "10.2.0", PNPMProxy = class extends JsPackageMana
|
|
|
2778
3696
|
};
|
|
2779
3697
|
|
|
2780
3698
|
// src/common/js-package-manager/Yarn1Proxy.ts
|
|
2781
|
-
import { readFileSync as
|
|
2782
|
-
import { join as
|
|
3699
|
+
import { readFileSync as readFileSync13 } from "node:fs";
|
|
3700
|
+
import { join as join15 } from "node:path";
|
|
2783
3701
|
import process2 from "node:process";
|
|
2784
|
-
import { logger as
|
|
3702
|
+
import { logger as logger16, prompt as prompt6 } from "@aussieljk/forkbook/internal/node-logger";
|
|
2785
3703
|
import { FindPackageVersionsError as FindPackageVersionsError4 } from "@aussieljk/forkbook/internal/server-errors";
|
|
2786
3704
|
var Yarn1Proxy = class extends JsPackageManager {
|
|
2787
3705
|
constructor() {
|
|
@@ -2827,11 +3745,11 @@ var Yarn1Proxy = class extends JsPackageManager {
|
|
|
2827
3745
|
});
|
|
2828
3746
|
}
|
|
2829
3747
|
async getModulePackageJSON(packageName) {
|
|
2830
|
-
let wantedPath =
|
|
3748
|
+
let wantedPath = join15("node_modules", packageName, "package.json"), packageJsonPath = up2(wantedPath, {
|
|
2831
3749
|
cwd: this.primaryPackageJson.operationDir,
|
|
2832
3750
|
last: getProjectRoot()
|
|
2833
3751
|
});
|
|
2834
|
-
return packageJsonPath ? JSON.parse(
|
|
3752
|
+
return packageJsonPath ? JSON.parse(readFileSync13(packageJsonPath, "utf-8")) : null;
|
|
2835
3753
|
}
|
|
2836
3754
|
async getRegistryURL() {
|
|
2837
3755
|
let childProcess = await executeCommand({
|
|
@@ -2855,7 +3773,7 @@ var Yarn1Proxy = class extends JsPackageManager {
|
|
|
2855
3773
|
}), commandResult = typeof result.stdout == "string" ? result.stdout : "", parsedOutput = JSON.parse(commandResult);
|
|
2856
3774
|
return this.mapDependencies(parsedOutput, pattern);
|
|
2857
3775
|
} catch (e) {
|
|
2858
|
-
|
|
3776
|
+
logger16.debug(`Error finding installations for ${pattern.join(", ")}: ${String(e)}`);
|
|
2859
3777
|
return;
|
|
2860
3778
|
}
|
|
2861
3779
|
}
|
|
@@ -2871,7 +3789,7 @@ var Yarn1Proxy = class extends JsPackageManager {
|
|
|
2871
3789
|
return executeCommand({
|
|
2872
3790
|
command: "yarn",
|
|
2873
3791
|
args: ["install", ...this.getInstallArgs(), ...options?.force ? ["--force"] : []],
|
|
2874
|
-
stdio:
|
|
3792
|
+
stdio: prompt6.getPreferredStdio(),
|
|
2875
3793
|
cwd: this.cwd
|
|
2876
3794
|
});
|
|
2877
3795
|
}
|
|
@@ -2880,7 +3798,7 @@ var Yarn1Proxy = class extends JsPackageManager {
|
|
|
2880
3798
|
return installAsDevDependencies && (args = ["-D", ...args]), executeCommand({
|
|
2881
3799
|
command: "yarn",
|
|
2882
3800
|
args: ["add", ...this.getInstallArgs(), ...args],
|
|
2883
|
-
stdio:
|
|
3801
|
+
stdio: prompt6.getPreferredStdio(),
|
|
2884
3802
|
cwd: this.primaryPackageJson.operationDir
|
|
2885
3803
|
});
|
|
2886
3804
|
}
|
|
@@ -2930,14 +3848,14 @@ var Yarn1Proxy = class extends JsPackageManager {
|
|
|
2930
3848
|
};
|
|
2931
3849
|
|
|
2932
3850
|
// src/common/js-package-manager/Yarn2Proxy.ts
|
|
2933
|
-
import { readFileSync as
|
|
2934
|
-
import { join as
|
|
2935
|
-
import { prompt as
|
|
3851
|
+
import { readFileSync as readFileSync14 } from "node:fs";
|
|
3852
|
+
import { join as join16 } from "node:path";
|
|
3853
|
+
import { prompt as prompt7 } from "@aussieljk/forkbook/internal/node-logger";
|
|
2936
3854
|
import {
|
|
2937
3855
|
FindPackageVersionsError as FindPackageVersionsError5,
|
|
2938
3856
|
MinimumReleaseAgeHandledError as MinimumReleaseAgeHandledError4
|
|
2939
3857
|
} from "@aussieljk/forkbook/internal/server-errors";
|
|
2940
|
-
import { dedent as
|
|
3858
|
+
import { dedent as dedent12 } from "ts-dedent";
|
|
2941
3859
|
var Yarn2Proxy = class extends JsPackageManager {
|
|
2942
3860
|
constructor() {
|
|
2943
3861
|
super(...arguments);
|
|
@@ -2999,11 +3917,11 @@ var Yarn2Proxy = class extends JsPackageManager {
|
|
|
2999
3917
|
}
|
|
3000
3918
|
}
|
|
3001
3919
|
async getModulePackageJSON(packageName) {
|
|
3002
|
-
let wantedPath =
|
|
3920
|
+
let wantedPath = join16("node_modules", packageName, "package.json"), packageJsonPath = up2(wantedPath, {
|
|
3003
3921
|
cwd: this.primaryPackageJson.operationDir,
|
|
3004
3922
|
last: getProjectRoot()
|
|
3005
3923
|
});
|
|
3006
|
-
return packageJsonPath ? JSON.parse(
|
|
3924
|
+
return packageJsonPath ? JSON.parse(readFileSync14(packageJsonPath, "utf-8")) : null;
|
|
3007
3925
|
}
|
|
3008
3926
|
getResolutions(packageJson, versions) {
|
|
3009
3927
|
return {
|
|
@@ -3018,7 +3936,7 @@ var Yarn2Proxy = class extends JsPackageManager {
|
|
|
3018
3936
|
command: "yarn",
|
|
3019
3937
|
args: ["install", ...this.getInstallArgs()],
|
|
3020
3938
|
cwd: this.cwd,
|
|
3021
|
-
stdio:
|
|
3939
|
+
stdio: prompt7.getPreferredStdio()
|
|
3022
3940
|
});
|
|
3023
3941
|
}
|
|
3024
3942
|
async installDependencies(options) {
|
|
@@ -3063,10 +3981,10 @@ var Yarn2Proxy = class extends JsPackageManager {
|
|
|
3063
3981
|
);
|
|
3064
3982
|
if (nonInteractive) {
|
|
3065
3983
|
await this.updatePreapprovedPackages(), logger.info(
|
|
3066
|
-
|
|
3984
|
+
dedent12`
|
|
3067
3985
|
yarn npmMinimalAgeGate would block storybook@${storybookVersion} from being installed because it was released within the configured npmMinimalAgeGate window, so Forkbook updated npmPreapprovedPackages for this project automatically.
|
|
3068
3986
|
|
|
3069
|
-
Added patterns:
|
|
3987
|
+
Added patterns: ${FORKBOOK_PACKAGE_PATTERNS.join(", ")}
|
|
3070
3988
|
|
|
3071
3989
|
Read more:
|
|
3072
3990
|
- https://yarnpkg.com/configuration/yarnrc#npmMinimalAgeGate
|
|
@@ -3084,7 +4002,7 @@ var Yarn2Proxy = class extends JsPackageManager {
|
|
|
3084
4002
|
compatibleVersion
|
|
3085
4003
|
})
|
|
3086
4004
|
});
|
|
3087
|
-
if (await
|
|
4005
|
+
if (await prompt7.select(
|
|
3088
4006
|
{
|
|
3089
4007
|
message: "How would you like to proceed?",
|
|
3090
4008
|
options: [
|
|
@@ -3114,7 +4032,7 @@ var Yarn2Proxy = class extends JsPackageManager {
|
|
|
3114
4032
|
return installAsDevDependencies && (args = ["-D", ...args]), executeCommand({
|
|
3115
4033
|
command: "yarn",
|
|
3116
4034
|
args: ["add", ...this.getInstallArgs(), ...args],
|
|
3117
|
-
stdio:
|
|
4035
|
+
stdio: prompt7.getPreferredStdio(),
|
|
3118
4036
|
cwd: this.primaryPackageJson.operationDir
|
|
3119
4037
|
});
|
|
3120
4038
|
}
|
|
@@ -3194,7 +4112,7 @@ var Yarn2Proxy = class extends JsPackageManager {
|
|
|
3194
4112
|
compatibleVersion
|
|
3195
4113
|
}) {
|
|
3196
4114
|
let rerunCommand = getStorybookRerunCommand(compatibleVersion);
|
|
3197
|
-
return
|
|
4115
|
+
return dedent12`
|
|
3198
4116
|
yarn npmMinimalAgeGate blocked storybook@${currentVersion} from being installed.
|
|
3199
4117
|
|
|
3200
4118
|
${FORKBOOK_RERUN_INSTRUCTION}
|
|
@@ -3208,7 +4126,7 @@ var Yarn2Proxy = class extends JsPackageManager {
|
|
|
3208
4126
|
let currentPreapprovedPackages = await this.getPreapprovedPackages(), nextPreapprovedPackages = Array.from(
|
|
3209
4127
|
/* @__PURE__ */ new Set([...currentPreapprovedPackages, ...FORKBOOK_PACKAGE_PATTERNS])
|
|
3210
4128
|
);
|
|
3211
|
-
await
|
|
4129
|
+
await prompt7.executeTaskWithSpinner(
|
|
3212
4130
|
() => this.runInternalCommand(
|
|
3213
4131
|
"config",
|
|
3214
4132
|
["set", "npmPreapprovedPackages", "--json", JSON.stringify(nextPreapprovedPackages)],
|
|
@@ -3277,9 +4195,9 @@ var JsPackageManagerFactory = class {
|
|
|
3277
4195
|
up2(BUN_LOCKFILE, { cwd, last: root }),
|
|
3278
4196
|
up2(BUN_LOCKFILE_BINARY, { cwd, last: root })
|
|
3279
4197
|
].filter(Boolean).sort((a, b) => {
|
|
3280
|
-
let dirA =
|
|
4198
|
+
let dirA = parse4(a).dir, dirB = parse4(b).dir, compare = relative5(dirA, dirB);
|
|
3281
4199
|
return dirA === dirB ? 0 : compare.startsWith("..") ? -1 : 1;
|
|
3282
|
-
})[0], closestLockfile = closestLockfilePath &&
|
|
4200
|
+
})[0], closestLockfile = closestLockfilePath && basename4(closestLockfilePath), yarnVersion = getYarnVersion(cwd);
|
|
3283
4201
|
if (yarnVersion && closestLockfile === YARN_LOCKFILE)
|
|
3284
4202
|
return yarnVersion === 1 ? "yarn1" /* YARN1 */ : "yarn2" /* YARN2 */;
|
|
3285
4203
|
if (hasPNPM(cwd) && closestLockfile === PNPM_LOCKFILE)
|
|
@@ -3389,10 +4307,10 @@ function hasPNPM(cwd) {
|
|
|
3389
4307
|
function getYarnVersionFromPackageJson(cwd, root) {
|
|
3390
4308
|
let effectiveRoot = root ?? getProjectRoot(), directories = up(cwd ?? process.cwd(), { last: effectiveRoot });
|
|
3391
4309
|
for (let dir of directories) {
|
|
3392
|
-
let packageJsonPath =
|
|
3393
|
-
if (
|
|
4310
|
+
let packageJsonPath = join17(dir, "package.json");
|
|
4311
|
+
if (existsSync7(packageJsonPath))
|
|
3394
4312
|
try {
|
|
3395
|
-
let packageManager = JSON.parse(
|
|
4313
|
+
let packageManager = JSON.parse(readFileSync15(packageJsonPath, "utf-8")).packageManager;
|
|
3396
4314
|
if (typeof packageManager == "string") {
|
|
3397
4315
|
let match = packageManager.match(/^yarn@(\d+)\./);
|
|
3398
4316
|
if (match)
|
|
@@ -3426,12 +4344,12 @@ function getYarnVersion(cwd) {
|
|
|
3426
4344
|
}
|
|
3427
4345
|
|
|
3428
4346
|
// src/common/js-package-manager/warnOnYarn1.ts
|
|
3429
|
-
import { once } from "@aussieljk/forkbook/internal/node-logger";
|
|
4347
|
+
import { once as once2 } from "@aussieljk/forkbook/internal/node-logger";
|
|
3430
4348
|
var PACKAGE_MANAGER_INSTALL_DOCS_URL = "https://forkbook.ljk.dev/docs/get-started/install";
|
|
3431
4349
|
function warnOnYarn1(packageManagerType) {
|
|
3432
4350
|
if (packageManagerType === "yarn1" /* YARN1 */)
|
|
3433
4351
|
try {
|
|
3434
|
-
|
|
4352
|
+
once2.warn(
|
|
3435
4353
|
`${getPrettyPackageManagerName(packageManagerType)} is supported on a best-effort basis. Forkbook works best with npm, pnpm, or Yarn Berry. For more information, see: ${PACKAGE_MANAGER_INSTALL_DOCS_URL}`
|
|
3436
4354
|
);
|
|
3437
4355
|
} catch {
|
|
@@ -3439,7 +4357,7 @@ function warnOnYarn1(packageManagerType) {
|
|
|
3439
4357
|
}
|
|
3440
4358
|
|
|
3441
4359
|
// src/common/utils/scan-and-transform-files.ts
|
|
3442
|
-
import { logger as
|
|
4360
|
+
import { logger as logger17, prompt as prompt8 } from "@aussieljk/forkbook/internal/node-logger";
|
|
3443
4361
|
async function scanAndTransformFiles({
|
|
3444
4362
|
promptMessage = "Enter a custom glob pattern to scan (or press enter to use default):",
|
|
3445
4363
|
defaultGlob = "**/*.{mjs,cjs,js,jsx,ts,tsx,mdx}",
|
|
@@ -3448,12 +4366,12 @@ async function scanAndTransformFiles({
|
|
|
3448
4366
|
transformFn,
|
|
3449
4367
|
transformOptions
|
|
3450
4368
|
}) {
|
|
3451
|
-
let
|
|
4369
|
+
let glob2 = force ? defaultGlob : await prompt8.text({
|
|
3452
4370
|
message: promptMessage,
|
|
3453
4371
|
initialValue: defaultGlob
|
|
3454
4372
|
});
|
|
3455
|
-
|
|
3456
|
-
let { glob: globFiles } = await import("./dist-
|
|
4373
|
+
logger17.log("Scanning for affected files...");
|
|
4374
|
+
let { glob: globFiles } = await import("./dist-XPLJ5T4W.js"), sourceFiles = await globFiles([glob2], {
|
|
3457
4375
|
expandDirectories: !1,
|
|
3458
4376
|
...commonGlobOptions(""),
|
|
3459
4377
|
ignore: ["**/node_modules/**"],
|
|
@@ -3461,7 +4379,7 @@ async function scanAndTransformFiles({
|
|
|
3461
4379
|
cwd: getProjectRoot(),
|
|
3462
4380
|
absolute: !0
|
|
3463
4381
|
});
|
|
3464
|
-
return
|
|
4382
|
+
return logger17.log(`Scanning ${sourceFiles.length} files...`), transformFn(sourceFiles, transformOptions, dryRun);
|
|
3465
4383
|
}
|
|
3466
4384
|
|
|
3467
4385
|
// src/common/utils/transform-imports.ts
|
|
@@ -3475,12 +4393,12 @@ function transformImports(source, renamedImports) {
|
|
|
3475
4393
|
}
|
|
3476
4394
|
|
|
3477
4395
|
// src/common/utils/file-lock.ts
|
|
3478
|
-
import { logger as
|
|
4396
|
+
import { logger as logger18 } from "@aussieljk/forkbook/internal/node-logger";
|
|
3479
4397
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
3480
|
-
import { readFileSync as
|
|
3481
|
-
import { mkdir as mkdir2, open, readFile as
|
|
3482
|
-
import { dirname as
|
|
3483
|
-
var POLL_INTERVAL_MS = 50, DEFAULT_STALE_AFTER_MS = 3e4, DEFAULT_WAIT_BUDGET_MS = 2e4, MALFORMED_LOCK_GRACE_MS = 5e3, errorCode = (error) => typeof error == "object" && error !== null && "code" in error ? error.code : void 0, delay = (ms) => new Promise((
|
|
4398
|
+
import { readFileSync as readFileSync16, rmSync as rmSync2 } from "node:fs";
|
|
4399
|
+
import { mkdir as mkdir2, open, readFile as readFile7, rm as rm4, stat, utimes } from "node:fs/promises";
|
|
4400
|
+
import { dirname as dirname10 } from "node:path";
|
|
4401
|
+
var POLL_INTERVAL_MS = 50, DEFAULT_STALE_AFTER_MS = 3e4, DEFAULT_WAIT_BUDGET_MS = 2e4, MALFORMED_LOCK_GRACE_MS = 5e3, errorCode = (error) => typeof error == "object" && error !== null && "code" in error ? error.code : void 0, delay = (ms) => new Promise((resolve10) => setTimeout(resolve10, ms)), isProcessAlive = (pid) => {
|
|
3484
4402
|
try {
|
|
3485
4403
|
return process.kill(pid, 0), !0;
|
|
3486
4404
|
} catch (error) {
|
|
@@ -3488,12 +4406,12 @@ var POLL_INTERVAL_MS = 50, DEFAULT_STALE_AFTER_MS = 3e4, DEFAULT_WAIT_BUDGET_MS
|
|
|
3488
4406
|
}
|
|
3489
4407
|
}, readPayload = async (lockPath) => {
|
|
3490
4408
|
try {
|
|
3491
|
-
return JSON.parse(await
|
|
4409
|
+
return JSON.parse(await readFile7(lockPath, "utf8"));
|
|
3492
4410
|
} catch {
|
|
3493
4411
|
return;
|
|
3494
4412
|
}
|
|
3495
4413
|
}, tryAcquire = async (lockPath) => {
|
|
3496
|
-
await mkdir2(
|
|
4414
|
+
await mkdir2(dirname10(lockPath), { recursive: !0 });
|
|
3497
4415
|
let handle;
|
|
3498
4416
|
try {
|
|
3499
4417
|
handle = await open(lockPath, "wx");
|
|
@@ -3506,7 +4424,7 @@ var POLL_INTERVAL_MS = 50, DEFAULT_STALE_AFTER_MS = 3e4, DEFAULT_WAIT_BUDGET_MS
|
|
|
3506
4424
|
try {
|
|
3507
4425
|
await handle.writeFile(JSON.stringify(payload));
|
|
3508
4426
|
} catch (error) {
|
|
3509
|
-
throw await handle.close(), await
|
|
4427
|
+
throw await handle.close(), await rm4(lockPath, { force: !0 }).catch(() => {
|
|
3510
4428
|
}), error;
|
|
3511
4429
|
}
|
|
3512
4430
|
return await handle.close(), payload.token;
|
|
@@ -3518,10 +4436,10 @@ var POLL_INTERVAL_MS = 50, DEFAULT_STALE_AFTER_MS = 3e4, DEFAULT_WAIT_BUDGET_MS
|
|
|
3518
4436
|
return errorCode(error) === "ENOENT";
|
|
3519
4437
|
}
|
|
3520
4438
|
let payload = await readPayload(lockPath), holderPid = typeof payload?.pid == "number" ? payload.pid : void 0, age = Date.now() - stats.mtimeMs;
|
|
3521
|
-
return (holderPid !== void 0 ? !isProcessAlive(holderPid) || age > staleAfterMs : age > MALFORMED_LOCK_GRACE_MS) ? ((await readPayload(lockPath))?.token !== payload?.token || (await
|
|
4439
|
+
return (holderPid !== void 0 ? !isProcessAlive(holderPid) || age > staleAfterMs : age > MALFORMED_LOCK_GRACE_MS) ? ((await readPayload(lockPath))?.token !== payload?.token || (await rm4(lockPath, { force: !0 }), logger18.debug(`Cleared an abandoned lock at ${lockPath} (holder pid ${holderPid ?? "unknown"})`)), !0) : !1;
|
|
3522
4440
|
}, releaseIfOurs = (lockPath, token) => {
|
|
3523
4441
|
try {
|
|
3524
|
-
JSON.parse(
|
|
4442
|
+
JSON.parse(readFileSync16(lockPath, "utf8"))?.token === token && rmSync2(lockPath, { force: !0 });
|
|
3525
4443
|
} catch {
|
|
3526
4444
|
}
|
|
3527
4445
|
}, holdLock = (lockPath, token, staleAfterMs) => {
|
|
@@ -3627,13 +4545,18 @@ function getProcessAncestry(pid = process.pid) {
|
|
|
3627
4545
|
}
|
|
3628
4546
|
|
|
3629
4547
|
export {
|
|
4548
|
+
versions_default,
|
|
4549
|
+
supportedExtensions,
|
|
4550
|
+
getInterpretedFile,
|
|
4551
|
+
resolveImport,
|
|
4552
|
+
validateConfigurationFiles,
|
|
3630
4553
|
resolveAddonName,
|
|
3631
4554
|
loadPreset,
|
|
3632
4555
|
getPresets,
|
|
3633
4556
|
loadAllPresets,
|
|
3634
4557
|
FileSystemCache,
|
|
3635
4558
|
createFileSystemCache,
|
|
3636
|
-
|
|
4559
|
+
resolvePathInForkbookCache,
|
|
3637
4560
|
cache2 as cache,
|
|
3638
4561
|
temporaryDirectory,
|
|
3639
4562
|
temporaryFile,
|
|
@@ -3646,10 +4569,51 @@ export {
|
|
|
3646
4569
|
findStorybookPackageRoot,
|
|
3647
4570
|
commonGlobOptions,
|
|
3648
4571
|
deepMerge,
|
|
4572
|
+
defaultConfigDir,
|
|
4573
|
+
frameworkToRenderer,
|
|
4574
|
+
frameworkToBuilder,
|
|
3649
4575
|
getBuilderOptions,
|
|
4576
|
+
isPkgPrNewVersionSpecifier,
|
|
4577
|
+
getPkgPrNewPackageSpecifier,
|
|
3650
4578
|
getStorybookVersionSpecifierFromAncestry,
|
|
3651
4579
|
FORKBOOK_VERSION_SPECIFIER_ENV,
|
|
3652
4580
|
resolveStorybookVersionSpecifier,
|
|
4581
|
+
HandledError,
|
|
4582
|
+
FORKBOOK_PACKAGE_PATTERNS,
|
|
4583
|
+
hasStorybookMinimumAgeExclusions,
|
|
4584
|
+
parsePackageData,
|
|
4585
|
+
parsePositiveIntegerConfigValue,
|
|
4586
|
+
parseReleaseTime,
|
|
4587
|
+
parsePackageTimeMap,
|
|
4588
|
+
getAgeInMinutes,
|
|
4589
|
+
getLatestStableVersionAdheringToMinimumAgeGate,
|
|
4590
|
+
getVitestStorybookRunCommand,
|
|
4591
|
+
getMswInitCommand,
|
|
4592
|
+
FORKBOOK_RERUN_INSTRUCTION,
|
|
4593
|
+
getStorybookRerunCommand,
|
|
4594
|
+
getErrorLogs,
|
|
4595
|
+
INSTALL_ERROR_TAIL_LINES,
|
|
4596
|
+
getInstallErrorTail,
|
|
4597
|
+
getVitePlusVersions,
|
|
4598
|
+
clearVitePlusCache,
|
|
4599
|
+
PackageManagerName,
|
|
4600
|
+
getPrettyPackageManagerName,
|
|
4601
|
+
getPackageDetails,
|
|
4602
|
+
JsPackageManager,
|
|
4603
|
+
normalizeAddonName,
|
|
4604
|
+
getAddonNames,
|
|
4605
|
+
getRendererName,
|
|
4606
|
+
extractRenderer,
|
|
4607
|
+
getStorybookConfiguration,
|
|
4608
|
+
loadMainConfig,
|
|
4609
|
+
rendererPackages,
|
|
4610
|
+
frameworkPackages,
|
|
4611
|
+
builderPackages,
|
|
4612
|
+
findConfigFile,
|
|
4613
|
+
getConfigInfo,
|
|
4614
|
+
getStorybookInfo,
|
|
4615
|
+
getFrameworkName,
|
|
4616
|
+
extractFrameworkPackageName,
|
|
3653
4617
|
readDependencyManifest,
|
|
3654
4618
|
getAutoRefs,
|
|
3655
4619
|
checkRef,
|
|
@@ -3680,7 +4644,7 @@ export {
|
|
|
3680
4644
|
formatCode,
|
|
3681
4645
|
formatFileContent,
|
|
3682
4646
|
userOrAutoTitleFromSpecifier,
|
|
3683
|
-
|
|
4647
|
+
posix3 as posix,
|
|
3684
4648
|
getStoryId,
|
|
3685
4649
|
getStoryTitle,
|
|
3686
4650
|
createLazyDocgenMiddleware,
|