@mastra/deployer 0.0.0-error-handler-fix-20251020202607 → 0.0.0-execa-dynamic-import-20260304221256
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/CHANGELOG.md +1850 -5
- package/LICENSE.md +15 -0
- package/dist/arktype-aI7TBD0R-MD6ESOAI.js +8 -0
- package/dist/arktype-aI7TBD0R-MD6ESOAI.js.map +1 -0
- package/dist/arktype-aI7TBD0R-MS2OLT4Z.cjs +10 -0
- package/dist/arktype-aI7TBD0R-MS2OLT4Z.cjs.map +1 -0
- package/dist/build/analyze/analyzeEntry.d.ts +8 -4
- package/dist/build/analyze/analyzeEntry.d.ts.map +1 -1
- package/dist/build/analyze/bundleExternals.d.ts +8 -7
- package/dist/build/analyze/bundleExternals.d.ts.map +1 -1
- package/dist/build/analyze/constants.d.ts.map +1 -1
- package/dist/build/analyze.cjs +2 -2
- package/dist/build/analyze.d.ts +7 -7
- package/dist/build/analyze.d.ts.map +1 -1
- package/dist/build/analyze.js +1 -1
- package/dist/build/babel/remove-all-options-except.d.ts +1 -1
- package/dist/build/babel/remove-all-options-except.d.ts.map +1 -1
- package/dist/build/babel/remove-deployer.d.ts.map +1 -1
- package/dist/build/bundler.cjs +3 -3
- package/dist/build/bundler.d.ts +5 -3
- package/dist/build/bundler.d.ts.map +1 -1
- package/dist/build/bundler.js +1 -1
- package/dist/build/bundlerOptions.d.ts +1 -1
- package/dist/build/bundlerOptions.d.ts.map +1 -1
- package/dist/build/deployer.d.ts +1 -1
- package/dist/build/deployer.d.ts.map +1 -1
- package/dist/build/index.cjs +31 -22
- package/dist/build/index.d.ts +2 -1
- package/dist/build/index.d.ts.map +1 -1
- package/dist/build/index.js +6 -5
- package/dist/build/package-info.d.ts +9 -0
- package/dist/build/package-info.d.ts.map +1 -0
- package/dist/build/plugins/esm-shim.d.ts +14 -0
- package/dist/build/plugins/esm-shim.d.ts.map +1 -0
- package/dist/build/plugins/module-resolve-map.d.ts +3 -0
- package/dist/build/plugins/module-resolve-map.d.ts.map +1 -0
- package/dist/build/plugins/node-gyp-detector.d.ts +3 -0
- package/dist/build/plugins/node-gyp-detector.d.ts.map +1 -0
- package/dist/build/plugins/node-modules-extension-resolver.d.ts +7 -0
- package/dist/build/plugins/node-modules-extension-resolver.d.ts.map +1 -1
- package/dist/build/plugins/pino.d.ts.map +1 -1
- package/dist/build/plugins/remove-all-except.d.ts +10 -0
- package/dist/build/plugins/remove-all-except.d.ts.map +1 -0
- package/dist/build/plugins/subpath-externals-resolver.d.ts +3 -0
- package/dist/build/plugins/subpath-externals-resolver.d.ts.map +1 -0
- package/dist/build/plugins/tsconfig-paths.d.ts +8 -0
- package/dist/build/plugins/tsconfig-paths.d.ts.map +1 -1
- package/dist/build/serverOptions.d.ts +1 -1
- package/dist/build/serverOptions.d.ts.map +1 -1
- package/dist/build/shared/extract-mastra-option.d.ts +5 -9
- package/dist/build/shared/extract-mastra-option.d.ts.map +1 -1
- package/dist/build/types.d.ts +18 -0
- package/dist/build/types.d.ts.map +1 -1
- package/dist/build/utils.d.ts +79 -4
- package/dist/build/utils.d.ts.map +1 -1
- package/dist/build/watcher.d.ts +4 -1
- package/dist/build/watcher.d.ts.map +1 -1
- package/dist/bundler/index.cjs +6 -2
- package/dist/bundler/index.d.ts +13 -10
- package/dist/bundler/index.d.ts.map +1 -1
- package/dist/bundler/index.js +1 -1
- package/dist/chunk-32UHMKRP.cjs +95 -0
- package/dist/chunk-32UHMKRP.cjs.map +1 -0
- package/dist/chunk-6UIXBIO6.js +1322 -0
- package/dist/chunk-6UIXBIO6.js.map +1 -0
- package/dist/chunk-73SEUI3W.cjs +1353 -0
- package/dist/chunk-73SEUI3W.cjs.map +1 -0
- package/dist/chunk-ANF3UFZ3.js +318 -0
- package/dist/chunk-ANF3UFZ3.js.map +1 -0
- package/dist/{chunk-5QFG6SCM.js → chunk-DPDWM7HQ.js} +2 -2
- package/dist/chunk-DPDWM7HQ.js.map +1 -0
- package/dist/chunk-EBHDMP6N.cjs +122 -0
- package/dist/chunk-EBHDMP6N.cjs.map +1 -0
- package/dist/{chunk-WAWEQ3DP.js → chunk-EZBW45SX.js} +72 -32
- package/dist/chunk-EZBW45SX.js.map +1 -0
- package/dist/chunk-G7R456H2.cjs +108 -0
- package/dist/chunk-G7R456H2.cjs.map +1 -0
- package/dist/chunk-IMLDKOVJ.js +98 -0
- package/dist/chunk-IMLDKOVJ.js.map +1 -0
- package/dist/chunk-JNSGICDP.js +159 -0
- package/dist/chunk-JNSGICDP.js.map +1 -0
- package/dist/{chunk-3JYRSECU.cjs → chunk-JVBCN3RH.cjs} +4 -4
- package/dist/chunk-JVBCN3RH.cjs.map +1 -0
- package/dist/{chunk-LGC3GUMR.cjs → chunk-MEHKYO3L.cjs} +89 -153
- package/dist/chunk-MEHKYO3L.cjs.map +1 -0
- package/dist/chunk-NQTC7BHX.cjs +4 -0
- package/dist/chunk-NQTC7BHX.cjs.map +1 -0
- package/dist/chunk-O73YCD6A.js +262 -0
- package/dist/chunk-O73YCD6A.js.map +1 -0
- package/dist/chunk-PF6MO6L3.cjs +162 -0
- package/dist/chunk-PF6MO6L3.cjs.map +1 -0
- package/dist/{chunk-HMMDNIEQ.cjs → chunk-R2SYO6PH.cjs} +79 -39
- package/dist/chunk-R2SYO6PH.cjs.map +1 -0
- package/dist/chunk-TFSGAJE4.cjs +16 -0
- package/dist/chunk-TFSGAJE4.cjs.map +1 -0
- package/dist/chunk-UCL7MHBL.js +93 -0
- package/dist/chunk-UCL7MHBL.js.map +1 -0
- package/dist/chunk-UPVHAZ5Q.cjs +288 -0
- package/dist/chunk-UPVHAZ5Q.cjs.map +1 -0
- package/dist/chunk-UQZFTY5Q.cjs +8 -0
- package/dist/chunk-UQZFTY5Q.cjs.map +1 -0
- package/dist/{chunk-465ZVXAK.js → chunk-USX4L64H.js} +83 -146
- package/dist/chunk-USX4L64H.js.map +1 -0
- package/dist/chunk-V3HWDUN7.js +6 -0
- package/dist/chunk-V3HWDUN7.js.map +1 -0
- package/dist/chunk-WGU72NH4.js +14 -0
- package/dist/chunk-WGU72NH4.js.map +1 -0
- package/dist/chunk-XN3FKMO6.js +97 -0
- package/dist/chunk-XN3FKMO6.js.map +1 -0
- package/dist/chunk-YEOQZ6LM.js +3 -0
- package/dist/chunk-YEOQZ6LM.js.map +1 -0
- package/dist/chunk-YIUDHDPS.cjs +351 -0
- package/dist/chunk-YIUDHDPS.cjs.map +1 -0
- package/dist/default-u_dwuiYb-BOJNVDPF.js +3 -0
- package/dist/default-u_dwuiYb-BOJNVDPF.js.map +1 -0
- package/dist/default-u_dwuiYb-HYOFMURU.cjs +9 -0
- package/dist/default-u_dwuiYb-HYOFMURU.cjs.map +1 -0
- package/dist/deploy/log.d.ts +1 -1
- package/dist/deploy/log.d.ts.map +1 -1
- package/dist/docs/SKILL.md +31 -0
- package/dist/docs/assets/SOURCE_MAP.json +27 -0
- package/dist/docs/references/docs-deployment-cloud-providers.md +15 -0
- package/dist/docs/references/docs-deployment-mastra-server.md +122 -0
- package/dist/docs/references/docs-deployment-monorepo.md +142 -0
- package/dist/docs/references/docs-deployment-overview.md +62 -0
- package/dist/docs/references/docs-deployment-web-framework.md +52 -0
- package/dist/docs/references/docs-deployment-workflow-runners.md +9 -0
- package/dist/docs/references/reference-deployer.md +100 -0
- package/dist/effect-QlVUlMFu-FWNF43NY.cjs +17 -0
- package/dist/effect-QlVUlMFu-FWNF43NY.cjs.map +1 -0
- package/dist/effect-QlVUlMFu-UDX7FFQO.js +15 -0
- package/dist/effect-QlVUlMFu-UDX7FFQO.js.map +1 -0
- package/dist/esm-6PM2YB3Y.cjs +1336 -0
- package/dist/esm-6PM2YB3Y.cjs.map +1 -0
- package/dist/esm-CAB7GAHT.js +1289 -0
- package/dist/esm-CAB7GAHT.js.map +1 -0
- package/dist/index.cjs +11 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +5 -16
- package/dist/index.js.map +1 -1
- package/dist/server/handlers/a2a.d.ts +1 -1
- package/dist/server/handlers/health.d.ts +5 -0
- package/dist/server/handlers/health.d.ts.map +1 -0
- package/dist/server/handlers/restart-active-runs.d.ts +3 -0
- package/dist/server/handlers/restart-active-runs.d.ts.map +1 -0
- package/dist/server/handlers/utils/query-parsers.d.ts +15 -0
- package/dist/server/handlers/utils/query-parsers.d.ts.map +1 -1
- package/dist/server/handlers/utils.d.ts +0 -7
- package/dist/server/handlers/utils.d.ts.map +1 -1
- package/dist/server/index.cjs +2983 -10849
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.ts +3 -12
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +2983 -10850
- package/dist/server/index.js.map +1 -1
- package/dist/server/types.d.ts +1 -1
- package/dist/server/types.d.ts.map +1 -1
- package/dist/server/welcome.d.ts +1 -1
- package/dist/server/welcome.d.ts.map +1 -1
- package/dist/services/index.cjs +4 -4
- package/dist/services/index.js +1 -1
- package/dist/sury-CWZTCd75-2U3FQUNZ.cjs +17 -0
- package/dist/sury-CWZTCd75-2U3FQUNZ.cjs.map +1 -0
- package/dist/sury-CWZTCd75-52HHC6OD.js +15 -0
- package/dist/sury-CWZTCd75-52HHC6OD.js.map +1 -0
- package/dist/typebox-Dei93FPO-EBJ4ULZC.cjs +10 -0
- package/dist/typebox-Dei93FPO-EBJ4ULZC.cjs.map +1 -0
- package/dist/typebox-Dei93FPO-TURR2FV5.js +8 -0
- package/dist/typebox-Dei93FPO-TURR2FV5.js.map +1 -0
- package/dist/valibot--1zFm7rT-KH26NMFX.cjs +17 -0
- package/dist/valibot--1zFm7rT-KH26NMFX.cjs.map +1 -0
- package/dist/valibot--1zFm7rT-O4VBDBTD.js +15 -0
- package/dist/valibot--1zFm7rT-O4VBDBTD.js.map +1 -0
- package/dist/valibot-D_HTw1Gn-EVIH6VOI.js +43 -0
- package/dist/valibot-D_HTw1Gn-EVIH6VOI.js.map +1 -0
- package/dist/valibot-D_HTw1Gn-YHTB53Q2.cjs +45 -0
- package/dist/valibot-D_HTw1Gn-YHTB53Q2.cjs.map +1 -0
- package/dist/validator/custom-resolver.cjs +46 -12
- package/dist/validator/custom-resolver.cjs.map +1 -1
- package/dist/validator/custom-resolver.d.ts +15 -1
- package/dist/validator/custom-resolver.d.ts.map +1 -1
- package/dist/validator/custom-resolver.js +44 -11
- package/dist/validator/custom-resolver.js.map +1 -1
- package/dist/validator/validate.d.ts +16 -1
- package/dist/validator/validate.d.ts.map +1 -1
- package/dist/zod-Bwrt9trS-SFESLKHY.cjs +31 -0
- package/dist/zod-Bwrt9trS-SFESLKHY.cjs.map +1 -0
- package/dist/zod-Bwrt9trS-UDJPKIQS.js +29 -0
- package/dist/zod-Bwrt9trS-UDJPKIQS.js.map +1 -0
- package/dist/zod-DSgpEGAE-3CP5FXLX.cjs +39 -0
- package/dist/zod-DSgpEGAE-3CP5FXLX.cjs.map +1 -0
- package/dist/zod-DSgpEGAE-EQI5QBJK.js +37 -0
- package/dist/zod-DSgpEGAE-EQI5QBJK.js.map +1 -0
- package/package.json +34 -35
- package/dist/build/babel/get-deployer.d.ts +0 -3
- package/dist/build/babel/get-deployer.d.ts.map +0 -1
- package/dist/build/babel/remove-all-options-bundler.d.ts +0 -5
- package/dist/build/babel/remove-all-options-bundler.d.ts.map +0 -1
- package/dist/build/babel/remove-all-options-deployer.d.ts +0 -5
- package/dist/build/babel/remove-all-options-deployer.d.ts.map +0 -1
- package/dist/build/babel/remove-all-options-server.d.ts +0 -5
- package/dist/build/babel/remove-all-options-server.d.ts.map +0 -1
- package/dist/build/babel/remove-all-options-telemetry.d.ts +0 -5
- package/dist/build/babel/remove-all-options-telemetry.d.ts.map +0 -1
- package/dist/build/customInstrumentation.d.ts +0 -10
- package/dist/build/customInstrumentation.d.ts.map +0 -1
- package/dist/build/telemetry.d.ts +0 -8
- package/dist/build/telemetry.d.ts.map +0 -1
- package/dist/chunk-3JYRSECU.cjs.map +0 -1
- package/dist/chunk-465ZVXAK.js.map +0 -1
- package/dist/chunk-5QFG6SCM.js.map +0 -1
- package/dist/chunk-CEXVMFUD.js +0 -1265
- package/dist/chunk-CEXVMFUD.js.map +0 -1
- package/dist/chunk-CKUCDCGI.js +0 -168
- package/dist/chunk-CKUCDCGI.js.map +0 -1
- package/dist/chunk-HMMDNIEQ.cjs.map +0 -1
- package/dist/chunk-LGC3GUMR.cjs.map +0 -1
- package/dist/chunk-MCDDO4WY.cjs +0 -1309
- package/dist/chunk-MCDDO4WY.cjs.map +0 -1
- package/dist/chunk-OYO2MJED.cjs +0 -195
- package/dist/chunk-OYO2MJED.cjs.map +0 -1
- package/dist/chunk-SBTEIZ3B.js +0 -26
- package/dist/chunk-SBTEIZ3B.js.map +0 -1
- package/dist/chunk-WAWEQ3DP.js.map +0 -1
- package/dist/chunk-WIQEFIRX.cjs +0 -28
- package/dist/chunk-WIQEFIRX.cjs.map +0 -1
- package/dist/server/handlers/auth/defaults.d.ts +0 -3
- package/dist/server/handlers/auth/defaults.d.ts.map +0 -1
- package/dist/server/handlers/auth/helpers.d.ts +0 -11
- package/dist/server/handlers/auth/helpers.d.ts.map +0 -1
- package/dist/server/handlers/auth/index.d.ts +0 -11
- package/dist/server/handlers/auth/index.d.ts.map +0 -1
- package/dist/server/handlers/prompt.d.ts +0 -3
- package/dist/server/handlers/prompt.d.ts.map +0 -1
- package/dist/server/handlers/routes/agent-builder/handlers.d.ts +0 -17
- package/dist/server/handlers/routes/agent-builder/handlers.d.ts.map +0 -1
- package/dist/server/handlers/routes/agent-builder/router.d.ts +0 -4
- package/dist/server/handlers/routes/agent-builder/router.d.ts.map +0 -1
- package/dist/server/handlers/routes/agents/handlers.d.ts +0 -363
- package/dist/server/handlers/routes/agents/handlers.d.ts.map +0 -1
- package/dist/server/handlers/routes/agents/router.d.ts +0 -5
- package/dist/server/handlers/routes/agents/router.d.ts.map +0 -1
- package/dist/server/handlers/routes/agents/voice.d.ts +0 -18
- package/dist/server/handlers/routes/agents/voice.d.ts.map +0 -1
- package/dist/server/handlers/routes/logs/handlers.d.ts +0 -5
- package/dist/server/handlers/routes/logs/handlers.d.ts.map +0 -1
- package/dist/server/handlers/routes/logs/router.d.ts +0 -3
- package/dist/server/handlers/routes/logs/router.d.ts.map +0 -1
- package/dist/server/handlers/routes/mcp/handlers.d.ts +0 -139
- package/dist/server/handlers/routes/mcp/handlers.d.ts.map +0 -1
- package/dist/server/handlers/routes/mcp/router.d.ts +0 -4
- package/dist/server/handlers/routes/mcp/router.d.ts.map +0 -1
- package/dist/server/handlers/routes/memory/handlers.d.ts +0 -17
- package/dist/server/handlers/routes/memory/handlers.d.ts.map +0 -1
- package/dist/server/handlers/routes/memory/router.d.ts +0 -4
- package/dist/server/handlers/routes/memory/router.d.ts.map +0 -1
- package/dist/server/handlers/routes/observability/handlers.d.ts +0 -6
- package/dist/server/handlers/routes/observability/handlers.d.ts.map +0 -1
- package/dist/server/handlers/routes/observability/router.d.ts +0 -3
- package/dist/server/handlers/routes/observability/router.d.ts.map +0 -1
- package/dist/server/handlers/routes/scores/handlers.d.ts +0 -300
- package/dist/server/handlers/routes/scores/handlers.d.ts.map +0 -1
- package/dist/server/handlers/routes/scores/router.d.ts +0 -4
- package/dist/server/handlers/routes/scores/router.d.ts.map +0 -1
- package/dist/server/handlers/routes/telemetry/handlers.d.ts +0 -4
- package/dist/server/handlers/routes/telemetry/handlers.d.ts.map +0 -1
- package/dist/server/handlers/routes/telemetry/router.d.ts +0 -3
- package/dist/server/handlers/routes/telemetry/router.d.ts.map +0 -1
- package/dist/server/handlers/routes/tools/handlers.d.ts +0 -7
- package/dist/server/handlers/routes/tools/handlers.d.ts.map +0 -1
- package/dist/server/handlers/routes/tools/router.d.ts +0 -4
- package/dist/server/handlers/routes/tools/router.d.ts.map +0 -1
- package/dist/server/handlers/routes/vector/handlers.d.ts +0 -10
- package/dist/server/handlers/routes/vector/handlers.d.ts.map +0 -1
- package/dist/server/handlers/routes/vector/router.d.ts +0 -4
- package/dist/server/handlers/routes/vector/router.d.ts.map +0 -1
- package/dist/server/handlers/routes/workflows/handlers.d.ts +0 -20
- package/dist/server/handlers/routes/workflows/handlers.d.ts.map +0 -1
- package/dist/server/handlers/routes/workflows/legacyWorkflows.d.ts +0 -11
- package/dist/server/handlers/routes/workflows/legacyWorkflows.d.ts.map +0 -1
- package/dist/server/handlers/routes/workflows/router.d.ts +0 -4
- package/dist/server/handlers/routes/workflows/router.d.ts.map +0 -1
- package/dist/templates/instrumentation-template.js +0 -172
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/build/package-info.ts","../src/build/plugins/esbuild.ts","../src/build/babel/remove-deployer.ts","../src/build/plugins/remove-deployer.ts","../src/build/plugins/tsconfig-paths.ts","../src/build/plugins/esm-shim.ts","../src/build/plugins/subpath-externals-resolver.ts"],"names":["babel","path","removeDeployer","babel2","tsConfigPath","resolved"],"mappings":";;;;;;;;;;;;AAWA,eAAsB,kBAAA,CAAmB,aAAqB,UAAA,EAA6C;AACzG,EAAA,IAAI,QAAA;AAEJ,EAAA,IAAI;AACF,IAAA,IAAI,OAAA,GAA4C,MAAA;AAChD,IAAA,IAAI,UAAA,EAAY;AACd,MAAA,IAAI,CAAC,UAAA,CAAW,UAAA,CAAW,SAAS,CAAA,EAAG;AACrC,QAAA,UAAA,GAAa,aAAA,CAAc,UAAU,CAAA,CAAE,IAAA;AAAA,MACzC;AAEA,MAAA,OAAA,GAAU;AAAA,QACR,KAAA,EAAO,CAAC,UAAU;AAAA,OACpB;AAAA,IACF;AAEA,IAAA,MAAM,GAAA,GAAM,MAAM,cAAA,CAAe,WAAA,EAAa,OAAO,CAAA;AACrD,IAAA,QAAA,GAAW,KAAK,QAAA,IAAY,IAAA;AAAA,EAC9B,CAAA,CAAA,MAAQ;AACN,IAAA,QAAA,GAAW,IAAA;AAAA,EACb;AAEA,EAAA,OAAO,QAAA;AACT;AC/BO,SAAS,OAAA,CAAQ,OAAA,GAAiD,EAAC,EAAG;AAC3E,EAAA,OAAO,eAAA,CAAgB;AAAA,IACrB,MAAA,EAAQ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,EAAI;AACZ,MAAA,IAAI,GAAG,UAAA,CAAW,GAAG,KAAK,EAAA,CAAG,UAAA,CAAW,GAAG,CAAA,EAAG;AAC5C,QAAA,OAAO,IAAA;AAAA,MACT;AAEA,MAAA,MAAM,oBAAoB,SAAA,CAAU,IAAA,CAAK,cAAY,yBAAA,CAA0B,EAAA,EAAI,QAAQ,CAAC,CAAA;AAC5F,MAAA,IAAI,iBAAA,EAAmB;AACrB,QAAA,OAAO;AAAA,UACL,EAAA;AAAA,UACA,QAAA,EAAU;AAAA,SACZ;AAAA,MACF;AAAA,IACF;AAAA,GACF;AACF","file":"chunk-ANF3UFZ3.js","sourcesContent":["/**\n * Note: This function depends on local-pkg and should only be used at build-time.\n * It is in a separate file to avoid including local-pkg in runtime code.\n */\n\nimport { pathToFileURL } from 'node:url';\nimport { getPackageInfo } from 'local-pkg';\n\n/**\n * Get package root path\n */\nexport async function getPackageRootPath(packageName: string, parentPath?: string): Promise<string | null> {\n let rootPath: string | null;\n\n try {\n let options: { paths?: string[] } | undefined = undefined;\n if (parentPath) {\n if (!parentPath.startsWith('file://')) {\n parentPath = pathToFileURL(parentPath).href;\n }\n\n options = {\n paths: [parentPath],\n };\n }\n\n const pkg = await getPackageInfo(packageName, options);\n rootPath = pkg?.rootPath ?? null;\n } catch {\n rootPath = null;\n }\n\n return rootPath;\n}\n","import originalEsbuild from 'rollup-plugin-esbuild';\n\nexport function esbuild(options: Parameters<typeof originalEsbuild>[0] = {}) {\n return originalEsbuild({\n target: 'node20',\n platform: 'node',\n minify: false,\n ...options,\n });\n}\n","import babel from '@babel/core';\n\nexport function removeDeployer() {\n const t = babel.types;\n\n // Helper to remove deployer property from an object and clean up its binding\n function removeDeployerFromObject(\n objectExpr: babel.types.ObjectExpression,\n scope: { getBinding: (name: string) => { path?: babel.NodePath } | undefined },\n ): babel.types.ObjectProperty | undefined {\n const deployerProp = objectExpr.properties.find(\n prop => t.isObjectProperty(prop) && t.isIdentifier(prop.key) && prop.key.name === 'deployer',\n ) as babel.types.ObjectProperty | undefined;\n\n if (deployerProp) {\n objectExpr.properties = objectExpr.properties.filter(prop => prop !== deployerProp);\n\n // Clean up the deployer binding if it's a reference\n if (t.isIdentifier(deployerProp.value)) {\n const deployerBinding = scope.getBinding(deployerProp.value.name);\n if (deployerBinding) {\n deployerBinding.path?.parentPath?.remove();\n }\n }\n }\n\n return deployerProp;\n }\n\n return {\n name: 'remove-deployer',\n visitor: {\n NewExpression(path, state) {\n // is a variable declaration\n const varDeclaratorPath = path.findParent(path => t.isVariableDeclarator(path.node));\n if (!varDeclaratorPath) {\n return;\n }\n\n const parentNode = path.parentPath.node;\n // check if it's a const of mastra\n if (!t.isVariableDeclarator(parentNode) || !t.isIdentifier(parentNode.id) || parentNode.id.name !== 'mastra') {\n return;\n }\n\n if (!state.hasReplaced) {\n state.hasReplaced = true;\n const newMastraObj = t.cloneNode(path.node);\n if (t.isObjectExpression(newMastraObj.arguments[0]) && newMastraObj.arguments[0].properties?.length) {\n const objectArg = newMastraObj.arguments[0];\n let foundDeployer = false;\n\n // First, check for direct deployer property\n const directDeployer = removeDeployerFromObject(objectArg, state.file.scope);\n if (directDeployer) {\n foundDeployer = true;\n }\n\n // Then, check spread elements for deployer properties\n for (const prop of objectArg.properties) {\n if (t.isSpreadElement(prop) && t.isIdentifier(prop.argument)) {\n const spreadBinding = state.file.scope.getBinding(prop.argument.name);\n if (spreadBinding?.path && t.isVariableDeclarator(spreadBinding.path.node)) {\n const init = spreadBinding.path.node.init;\n if (t.isObjectExpression(init)) {\n const spreadDeployer = removeDeployerFromObject(init, state.file.scope);\n if (spreadDeployer) {\n foundDeployer = true;\n }\n }\n }\n }\n }\n\n if (foundDeployer) {\n path.replaceWith(newMastraObj);\n }\n }\n }\n },\n },\n } as babel.PluginObj;\n}\n","import * as babel from '@babel/core';\nimport type { Plugin } from 'rollup';\n\nimport { removeDeployer as removeDeployerBabelPlugin } from '../babel/remove-deployer';\n\nexport function removeDeployer(mastraEntry: string, options?: { sourcemap?: boolean }): Plugin {\n return {\n name: 'remove-deployer',\n transform(code, id) {\n if (id !== mastraEntry) {\n return;\n }\n\n return new Promise((resolve, reject) => {\n babel.transform(\n code,\n {\n babelrc: false,\n configFile: false,\n filename: id,\n plugins: [removeDeployerBabelPlugin],\n sourceMaps: options?.sourcemap,\n },\n (err, result) => {\n if (err) {\n return reject(err);\n }\n\n resolve({\n code: result!.code!,\n map: result!.map!,\n });\n },\n );\n });\n },\n } satisfies Plugin;\n}\n","import fs from 'node:fs';\nimport path, { normalize } from 'node:path';\nimport type { Plugin } from 'rollup';\nimport stripJsonComments from 'strip-json-comments';\nimport type { RegisterOptions } from 'typescript-paths';\nimport { createHandler } from 'typescript-paths';\n\nconst PLUGIN_NAME = 'tsconfig-paths';\n\nexport type PluginOptions = Omit<RegisterOptions, 'loggerID'> & { localResolve?: boolean };\n\n/**\n * Check if a tsconfig file has path mappings configured.\n * Exported for testing purposes.\n *\n * @param tsConfigPath - Path to the tsconfig.json file\n * @returns true if the tsconfig has paths configured or extends another config, false otherwise\n */\nexport function hasPaths(tsConfigPath: string): boolean {\n try {\n const content = fs.readFileSync(tsConfigPath, 'utf8');\n const config = JSON.parse(stripJsonComments(content));\n return !!(\n (config.compilerOptions?.paths && Object.keys(config.compilerOptions.paths).length > 0) ||\n (typeof config.extends === 'string' && config.extends.length > 0) ||\n (Array.isArray(config.extends) && config.extends.length > 0)\n );\n } catch {\n return false;\n }\n}\n\nexport function tsConfigPaths({ tsConfigPath, respectCoreModule, localResolve }: PluginOptions = {}): Plugin {\n const handlerCache = new Map<string, ReturnType<typeof createHandler>>();\n\n // Find tsconfig.json file starting from a directory and walking up\n function findTsConfigForFile(filePath: string): string | null {\n let currentDir = path.dirname(filePath);\n const root = path.parse(currentDir).root;\n\n while (currentDir !== root) {\n const tsConfigPath = path.join(currentDir, 'tsconfig.json');\n\n if (fs.existsSync(tsConfigPath)) {\n // Check if this tsconfig has path mappings\n if (hasPaths(tsConfigPath)) {\n return tsConfigPath;\n }\n }\n\n // Also check for tsconfig.base.json (common in NX)\n const tsConfigBasePath = path.join(currentDir, 'tsconfig.base.json');\n if (fs.existsSync(tsConfigBasePath)) {\n if (hasPaths(tsConfigBasePath)) {\n return tsConfigBasePath;\n }\n }\n\n currentDir = path.dirname(currentDir);\n }\n\n return null;\n }\n\n // Get or create handler for a specific tsconfig file\n function getHandlerForFile(filePath: string): ReturnType<typeof createHandler> | null {\n // If a specific tsConfigPath was provided, use it\n if (tsConfigPath && typeof tsConfigPath === 'string') {\n if (!handlerCache.has(tsConfigPath)) {\n handlerCache.set(\n tsConfigPath,\n createHandler({\n log: () => {},\n tsConfigPath,\n respectCoreModule,\n falllback: moduleName => fs.existsSync(moduleName),\n }),\n );\n }\n return handlerCache.get(tsConfigPath)!;\n }\n\n // Find appropriate tsconfig for this file\n const configPath = findTsConfigForFile(filePath);\n if (!configPath) {\n return null;\n }\n\n // Cache handlers to avoid recreation\n if (!handlerCache.has(configPath)) {\n handlerCache.set(\n configPath,\n createHandler({\n log: () => {},\n tsConfigPath: configPath,\n respectCoreModule,\n falllback: moduleName => fs.existsSync(moduleName),\n }),\n );\n }\n\n return handlerCache.get(configPath)!;\n }\n\n // Simple alias resolution using dynamic handler\n function resolveAlias(request: string, importer: string): string | null | undefined {\n // Get the appropriate handler for this file\n const dynamicHandler = getHandlerForFile(importer);\n if (!dynamicHandler) {\n return null;\n }\n\n const resolved = dynamicHandler(request, normalize(importer));\n return resolved;\n }\n\n return {\n name: PLUGIN_NAME,\n resolveId: {\n order: 'pre',\n async handler(request, importer, options) {\n if (!importer || request.startsWith('\\0') || importer.charCodeAt(0) === 0) {\n return null;\n }\n\n // Convert relative paths to absolute to ensure proper tsconfig path resolution\n // This allows path aliases to work regardless of how the importer path is provided\n if (!path.isAbsolute(importer)) {\n importer = path.resolve(process.cwd(), importer);\n }\n\n const moduleName = resolveAlias(request, importer);\n // No tsconfig alias found, so we need to resolve it normally\n if (!moduleName) {\n const resolved = await this.resolve(request, importer, { skipSelf: true, ...options });\n if (!resolved) {\n return null;\n }\n\n // If localResolve is true, we need to check if the importer has been resolved by the tsconfig-paths plugin\n // if so, we need to resolve the request from the importer instead of the root and mark it as external\n if (localResolve) {\n const importerInfo = this.getModuleInfo(importer);\n const importerPluginMeta = importerInfo?.meta?.[PLUGIN_NAME];\n\n if (!request.startsWith('./') && !request.startsWith('../') && importerPluginMeta?.resolved) {\n return {\n ...resolved,\n external: !request.startsWith('hono/') && request !== 'hono',\n };\n }\n }\n\n return {\n ...resolved,\n meta: {\n ...(resolved.meta || {}),\n },\n };\n }\n\n // When a module does not have an extension, we need to resolve it to a file\n if (!path.extname(moduleName)) {\n const resolved = await this.resolve(moduleName, importer, { skipSelf: true, ...options });\n\n if (!resolved) {\n return null;\n }\n\n return {\n ...resolved,\n meta: {\n ...resolved.meta,\n [PLUGIN_NAME]: {\n resolved: true,\n },\n },\n };\n }\n\n // Always pass through bundler's resolution to ensure proper path normalization\n const resolved = await this.resolve(moduleName, importer, { skipSelf: true, ...options });\n\n if (!resolved) {\n return null;\n }\n\n return {\n ...resolved,\n meta: {\n ...resolved.meta,\n [PLUGIN_NAME]: {\n resolved: true,\n },\n },\n };\n },\n },\n } satisfies Plugin;\n}\n","import originalEsmShim from '@rollup/plugin-esm-shim';\nimport type { Plugin } from 'rollup';\n\n// Regex to detect DECLARATIONS of __filename, __dirname\n// Using non-capturing group (?:) for slightly better performance\nconst FilenameDeclarationRegex = /(?:const|let|var)\\s+__filename/;\nconst DirnameDeclarationRegex = /(?:const|let|var)\\s+__dirname/;\n\n/**\n * Custom ESM shim plugin wrapper that respects user-declared __filename/__dirname variables.\n *\n * The original @rollup/plugin-esm-shim would inject shims even when users had already declared\n * their own __filename/__dirname, causing \"Identifier '__filename' has already been declared\" errors.\n *\n * This wrapper checks if the user has already declared these variables and skips the shim injection\n * if so. If either variable is declared, we skip the shim entirely since the original plugin injects\n * both together and we assume users who declare one will also handle the other if needed.\n */\nexport function esmShim(): Plugin {\n const original = originalEsmShim();\n\n return {\n name: 'esm-shim',\n renderChunk(code, chunk, opts, meta) {\n // Fast path: use includes() first to avoid regex if identifiers aren't present\n const hasFilename = code.includes('__filename');\n const hasDirname = code.includes('__dirname');\n\n // If user declared either __filename or __dirname, skip shim injection entirely\n // since the original plugin injects both together\n const userDeclaredFilename = hasFilename && FilenameDeclarationRegex.test(code);\n const userDeclaredDirname = hasDirname && DirnameDeclarationRegex.test(code);\n\n if (userDeclaredFilename || userDeclaredDirname) {\n return null;\n }\n\n // Otherwise, delegate to the original plugin\n if (typeof original.renderChunk === 'function') {\n return original.renderChunk.call(this, code, chunk, opts, meta);\n }\n\n return null;\n },\n };\n}\n\nexport default esmShim;\n","import type { Plugin } from 'rollup';\nimport { isDependencyPartOfPackage } from '../utils';\n\nexport function subpathExternalsResolver(externals: string[]): Plugin {\n return {\n name: 'subpath-externals-resolver',\n resolveId(id) {\n if (id.startsWith('.') || id.startsWith('/')) {\n return null;\n }\n\n const isPartOfExternals = externals.some(external => isDependencyPartOfPackage(id, external));\n if (isPartOfExternals) {\n return {\n id,\n external: true,\n };\n }\n },\n } satisfies Plugin;\n}\n"]}
|
|
@@ -394,5 +394,5 @@ var FileService = class {
|
|
|
394
394
|
};
|
|
395
395
|
|
|
396
396
|
export { Deps, DepsService, EnvService, FileService, createChildProcessLogger, createPinoStream };
|
|
397
|
-
//# sourceMappingURL=chunk-
|
|
398
|
-
//# sourceMappingURL=chunk-
|
|
397
|
+
//# sourceMappingURL=chunk-DPDWM7HQ.js.map
|
|
398
|
+
//# sourceMappingURL=chunk-DPDWM7HQ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/deploy/log.ts","../src/services/deps.ts","../src/services/env.ts","../src/services/fs.ts"],"names":["fs","fs2","fileURLToPath","path"],"mappings":";;;;;;;;;;;AAIO,IAAM,gBAAA,GAAmB,CAAC,MAAA,KAA0B;AACzD,EAAA,OAAO,IAAI,SAAA,CAAU;AAAA,IACnB,SAAA,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,IAAI,KAAA,CAAM,sDAAA,GAAyD,KAAA,CAAM,IAAA,CAAK,IAAI,CAAC,CAAA;AAAA,EAC3F;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOO,gCAAgC,KAAA,EAAqC;AAC1E,IAAA,KAAA,MAAW,KAAK,KAAA,EAAO;AACrB,MAAA,IAAIA,YAAAA,CAAG,UAAA,CAAW,CAAC,CAAA,EAAG;AACpB,QAAA,OAAO,CAAA;AAAA,MACT;AAAA,IACF;AAEA,IAAA,OAAO,MAAA;AAAA,EACT;AAAA,EAEO,mBAAA,CAAoB;AAAA,IACzB,QAAA;AAAA,IACA;AAAA,GACF,EAGG;AACD,IAAA,IAAI,WAAA,GAAcA,YAAAA,CAAG,YAAA,CAAa,QAAA,EAAU,MAAM,CAAA;AAClD,IAAA,YAAA,CAAa,OAAA,CAAQ,CAAC,EAAE,MAAA,EAAQ,SAAQ,KAAM;AAC5C,MAAA,WAAA,GAAc,WAAA,CAAY,UAAA,CAAW,MAAA,EAAQ,OAAO,CAAA;AAAA,IACtD,CAAC,CAAA;AAED,IAAAA,YAAAA,CAAG,aAAA,CAAc,QAAA,EAAU,WAAW,CAAA;AAAA,EACxC;AACF","file":"chunk-DPDWM7HQ.js","sourcesContent":["import { spawn } from 'node:child_process';\nimport { Transform } from 'node:stream';\nimport type { IMastraLogger } from '@mastra/core/logger';\n\nexport const createPinoStream = (logger: IMastraLogger) => {\n return new Transform({\n transform(chunk, _encoding, callback) {\n // Convert Buffer/string to string and trim whitespace\n const line = chunk.toString().trim();\n\n if (line) {\n console.info(line);\n // Log each line through Pino\n logger.info(line);\n }\n\n // Pass through the original data\n callback(null, chunk);\n },\n });\n};\n\nexport function createChildProcessLogger({ logger, root }: { logger: IMastraLogger; root: string }) {\n const pinoStream = createPinoStream(logger);\n return async ({ cmd, args, env }: { cmd: string; args: string[]; env: Record<string, string> }) => {\n try {\n const subprocess = spawn(cmd, args, {\n cwd: root,\n shell: true,\n env,\n });\n\n // Pipe stdout and stderr through the Pino stream\n subprocess.stdout?.pipe(pinoStream);\n subprocess.stderr?.pipe(pinoStream);\n\n // Wait for the process to complete\n return new Promise((resolve, reject) => {\n subprocess.on('close', code => {\n pinoStream.end();\n if (code === 0) {\n resolve({ success: true });\n } else {\n reject(new Error(`Process exited with code ${code}`));\n }\n });\n\n subprocess.on('error', error => {\n pinoStream.end();\n logger.error('Process failed', { error });\n reject(error);\n });\n });\n } catch (error) {\n console.error(error);\n logger.error('Process failed', { error });\n pinoStream.end();\n return { success: false, error };\n }\n };\n}\n","import fs from 'node:fs';\nimport fsPromises from 'node:fs/promises';\nimport path, { dirname } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { MastraBase } from '@mastra/core/base';\nimport { readJSON, writeJSON, ensureFile } from 'fs-extra/esm';\nimport type { PackageJson } from 'type-fest';\n\nimport { createChildProcessLogger } from '../deploy/log.js';\n\ntype PackageManager = 'npm' | 'yarn' | 'pnpm' | 'bun';\n\ninterface ArchitectureOptions {\n os?: string[];\n cpu?: string[];\n libc?: string[];\n}\n\nexport class Deps extends MastraBase {\n private packageManager: PackageManager;\n private rootDir: string;\n\n constructor(rootDir = process.cwd()) {\n super({ component: 'DEPLOYER', name: 'DEPS' });\n\n this.rootDir = rootDir;\n this.packageManager = this.getPackageManager();\n }\n\n private findLockFile(dir: string): string | null {\n const lockFiles = ['pnpm-lock.yaml', 'package-lock.json', 'yarn.lock', 'bun.lock'];\n for (const file of lockFiles) {\n if (fs.existsSync(path.join(dir, file))) {\n return file;\n }\n }\n const parentDir = path.resolve(dir, '..');\n if (parentDir !== dir) {\n return this.findLockFile(parentDir);\n }\n return null;\n }\n\n private getPackageManager(): PackageManager {\n const lockFile = this.findLockFile(this.rootDir);\n switch (lockFile) {\n case 'pnpm-lock.yaml':\n return 'pnpm';\n case 'package-lock.json':\n return 'npm';\n case 'yarn.lock':\n return 'yarn';\n case 'bun.lock':\n return 'bun';\n default:\n return 'npm';\n }\n }\n\n public getWorkspaceDependencyPath({ pkgName, version }: { pkgName: string; version: string }) {\n return `file:./workspace-module/${pkgName}-${version}.tgz`;\n }\n\n public async pack({ dir, destination, sanitizedName }: { dir: string; destination: string; sanitizedName: string }) {\n const cpLogger = createChildProcessLogger({\n logger: this.logger,\n root: dir,\n });\n\n let packCmd = 'pack';\n let destinationFlag = `--pack-destination ${destination}`;\n if (this.packageManager === 'yarn') {\n // %s includes an '@' at the start of packages names with an '@'\n // so we need to use our sanitizedName instead.\n destinationFlag = `--out ${destination}/${sanitizedName}-%v.tgz`;\n }\n if (this.packageManager === 'bun') {\n // bun uses `pm pack` instead of `pack`\n packCmd = 'pm pack';\n // bun uses --destination instead of --pack-destination\n destinationFlag = `--destination ${destination}`;\n }\n\n return cpLogger({\n cmd: `${this.packageManager} ${packCmd} ${destinationFlag}`,\n args: [],\n env: {\n PATH: process.env.PATH!,\n },\n });\n }\n\n private async writePnpmConfig(dir: string, options: ArchitectureOptions) {\n const packageJsonPath = path.join(dir, 'package.json');\n const packageJson = await readJSON(packageJsonPath);\n\n packageJson.pnpm = {\n ...packageJson.pnpm,\n supportedArchitectures: {\n os: options.os || [],\n cpu: options.cpu || [],\n libc: options.libc || [],\n },\n };\n\n await writeJSON(packageJsonPath, packageJson, { spaces: 2 });\n }\n\n private async writeYarnConfig(dir: string, options: ArchitectureOptions) {\n const yarnrcPath = path.join(dir, '.yarnrc.yml');\n const config = {\n supportedArchitectures: {\n cpu: options.cpu || [],\n os: options.os || [],\n libc: options.libc || [],\n },\n };\n\n await fsPromises.writeFile(\n yarnrcPath,\n `supportedArchitectures:\\n${Object.entries(config.supportedArchitectures)\n .map(([key, value]) => ` ${key}: ${JSON.stringify(value)}`)\n .join('\\n')}`,\n );\n }\n\n private getNpmArgs(options: ArchitectureOptions): string[] {\n const args: string[] = [];\n if (options.cpu) args.push(`--cpu=${options.cpu.join(',')}`);\n if (options.os) args.push(`--os=${options.os.join(',')}`);\n if (options.libc) args.push(`--libc=${options.libc.join(',')}`);\n return args;\n }\n\n /**\n * Depending on whether we want to install or add a package, this function returns the appropriate commands.\n * All package managers support both commands (e.g. npm install has an alias on \"add\")\n */\n private getPackageManagerCommand(pm: PackageManager, type: 'install' | 'add'): string {\n const cmd = type === 'install' ? 'install' : 'add';\n\n switch (pm) {\n case 'npm':\n return `${cmd} --audit=false --fund=false --loglevel=error --progress=false --update-notifier=false`;\n case 'yarn':\n return `${cmd}`;\n case 'pnpm':\n return cmd === 'install' ? `${cmd} --ignore-workspace --loglevel=error` : `${cmd} --loglevel=error`;\n case 'bun':\n return cmd;\n default:\n return cmd;\n }\n }\n\n public async install({\n dir = this.rootDir,\n architecture,\n }: { dir?: string; architecture?: ArchitectureOptions } = {}) {\n const pm = this.packageManager;\n const installCommand = this.getPackageManagerCommand(pm, 'install');\n let args: string[] = [];\n\n switch (pm) {\n case 'pnpm':\n if (architecture) {\n await this.writePnpmConfig(dir, architecture);\n }\n break;\n case 'yarn':\n // similar to --ignore-workspace but for yarn\n await ensureFile(path.join(dir, 'yarn.lock'));\n if (architecture) {\n await this.writeYarnConfig(dir, architecture);\n }\n break;\n case 'npm':\n if (architecture) {\n args = this.getNpmArgs(architecture);\n }\n break;\n default:\n // Do nothing\n }\n\n const cpLogger = createChildProcessLogger({\n logger: this.logger,\n root: dir,\n });\n\n return cpLogger({\n cmd: `${pm} ${installCommand}`,\n args,\n env: process.env as Record<string, string>,\n });\n }\n\n public async installPackages(packages: string[]) {\n const pm = this.packageManager;\n const installCommand = this.getPackageManagerCommand(pm, 'add');\n\n const env: Record<string, string> = {\n PATH: process.env.PATH!,\n };\n\n if (process.env.npm_config_registry) {\n env.npm_config_registry = process.env.npm_config_registry;\n }\n\n const cpLogger = createChildProcessLogger({\n logger: this.logger,\n root: '',\n });\n\n return cpLogger({\n cmd: `${pm} ${installCommand}`,\n args: packages,\n env,\n });\n }\n\n public async checkDependencies(dependencies: string[]): Promise<string> {\n try {\n const packageJsonPath = path.join(this.rootDir, 'package.json');\n\n try {\n await fsPromises.access(packageJsonPath);\n } catch {\n return 'No package.json file found in the current directory';\n }\n\n const packageJson = await readJSON(packageJsonPath);\n for (const dependency of dependencies) {\n if (!packageJson.dependencies || !packageJson.dependencies[dependency]) {\n return `Please install ${dependency} before running this command (${this.packageManager} install ${dependency})`;\n }\n }\n\n return 'ok';\n } catch (err) {\n console.error(err);\n return 'Could not check dependencies';\n }\n }\n\n public async getProjectName() {\n try {\n const packageJsonPath = path.join(this.rootDir, 'package.json');\n const pkg = await readJSON(packageJsonPath);\n return pkg.name;\n } catch (err) {\n throw err;\n }\n }\n\n public async getPackageVersion() {\n const __filename = fileURLToPath(import.meta.url);\n const __dirname = dirname(__filename);\n const pkgJsonPath = path.join(__dirname, '..', '..', 'package.json');\n\n const content = (await readJSON(pkgJsonPath)) as PackageJson;\n return content.version;\n }\n\n public async addScriptsToPackageJson(scripts: Record<string, string>) {\n const packageJson = await readJSON('package.json');\n packageJson.scripts = {\n ...packageJson.scripts,\n ...scripts,\n };\n await writeJSON('package.json', packageJson, { spaces: 2 });\n }\n}\n\nexport class DepsService extends Deps {}\n","import * as fs from 'node:fs';\n\nexport abstract class EnvService {\n abstract getEnvValue(key: string): Promise<string | null>;\n abstract setEnvValue(key: string, value: string): Promise<void>;\n}\n\nexport class FileEnvService extends EnvService {\n private filePath: string;\n\n constructor(filePath: string) {\n super();\n this.filePath = filePath;\n }\n\n private readFile(filePath: string): Promise<string> {\n return new Promise((resolve, reject) => {\n fs.readFile(filePath, 'utf8', (err: NodeJS.ErrnoException | null, data: string) => {\n if (err) reject(err);\n else resolve(data);\n });\n });\n }\n\n private writeFile({ filePath, data }: { filePath: string; data: string }): Promise<void> {\n return new Promise((resolve, reject) => {\n fs.writeFile(filePath, data, 'utf8', (err: NodeJS.ErrnoException | null) => {\n if (err) reject(err);\n else resolve();\n });\n });\n }\n\n private async updateEnvData({\n key,\n value,\n filePath = this.filePath,\n data,\n }: {\n key: string;\n value: string;\n filePath?: string;\n data: string;\n }): Promise<string> {\n const regex = new RegExp(`^${key}=.*$`, 'm');\n if (data.match(regex)) {\n data = data.replace(regex, `${key}=${value}`);\n } else {\n data += `\\n${key}=${value}`;\n }\n await this.writeFile({ filePath, data });\n console.info(`${key} set to ${value} in ENV file.`);\n return data;\n }\n\n async getEnvValue(key: string): Promise<string | null> {\n try {\n const data = await this.readFile(this.filePath);\n const regex = new RegExp(`^${key}=(.*)$`, 'm');\n const match = data.match(regex);\n return match?.[1] || null;\n } catch (err) {\n console.error(`Error reading ENV value: ${err}`);\n return null;\n }\n }\n\n async setEnvValue(key: string, value: string): Promise<void> {\n try {\n const data = await this.readFile(this.filePath);\n await this.updateEnvData({ key, value, data });\n } catch (err) {\n console.error(`Error writing ENV value: ${err}`);\n }\n }\n}\n","import fs from 'node:fs';\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nimport fsExtra from 'fs-extra/esm';\n\nimport { FileEnvService } from './env.js';\n\nexport class FileService {\n /**\n *\n * @param inputFile the file in the starter files directory to copy\n * @param outputFilePath the destination path\n * @param replaceIfExists flag to replace if it exists\n * @returns\n */\n public async copyStarterFile(inputFile: string, outputFilePath: string, replaceIfExists?: boolean) {\n const __filename = fileURLToPath(import.meta.url);\n const __dirname = path.dirname(__filename);\n const filePath = path.resolve(__dirname, '..', 'starter-files', inputFile);\n const fileString = fs.readFileSync(filePath, 'utf8');\n\n if (fs.existsSync(outputFilePath) && !replaceIfExists) {\n console.info(`${outputFilePath} already exists`);\n return false;\n }\n\n await fsExtra.outputFile(outputFilePath, fileString);\n\n return true;\n }\n\n public async setupEnvFile({ dbUrl }: { dbUrl: string }) {\n const envPath = path.join(process.cwd(), '.env.development');\n\n await fsExtra.ensureFile(envPath);\n\n const fileEnvService = new FileEnvService(envPath);\n await fileEnvService.setEnvValue('DB_URL', dbUrl);\n }\n\n public getFirstExistingFile(files: string[]): string {\n for (const f of files) {\n if (fs.existsSync(f)) {\n return f;\n }\n }\n\n throw new Error('Missing required file, checked the following paths: ' + files.join(', '));\n }\n\n /**\n * Returns the first existing file from the provided array, or undefined if none exist\n * @param files array of file paths to check\n * @returns the first existing file path or undefined\n */\n public getFirstExistingFileOrUndefined(files: string[]): string | undefined {\n for (const f of files) {\n if (fs.existsSync(f)) {\n return f;\n }\n }\n\n return undefined;\n }\n\n public replaceValuesInFile({\n filePath,\n replacements,\n }: {\n filePath: string;\n replacements: { search: string; replace: string }[];\n }) {\n let fileContent = fs.readFileSync(filePath, 'utf8');\n replacements.forEach(({ search, replace }) => {\n fileContent = fileContent.replaceAll(search, replace);\n });\n\n fs.writeFileSync(filePath, fileContent);\n }\n}\n"]}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkUPVHAZ5Q_cjs = require('./chunk-UPVHAZ5Q.cjs');
|
|
4
|
+
var chunk73SEUI3W_cjs = require('./chunk-73SEUI3W.cjs');
|
|
5
|
+
var chunkR2SYO6PH_cjs = require('./chunk-R2SYO6PH.cjs');
|
|
6
|
+
var chunkYIUDHDPS_cjs = require('./chunk-YIUDHDPS.cjs');
|
|
7
|
+
var chunkG7R456H2_cjs = require('./chunk-G7R456H2.cjs');
|
|
8
|
+
var path = require('path');
|
|
9
|
+
var logger = require('@mastra/core/logger');
|
|
10
|
+
var pkg = require('empathic/package');
|
|
11
|
+
var rollup = require('rollup');
|
|
12
|
+
|
|
13
|
+
function _interopNamespace(e) {
|
|
14
|
+
if (e && e.__esModule) return e;
|
|
15
|
+
var n = Object.create(null);
|
|
16
|
+
if (e) {
|
|
17
|
+
Object.keys(e).forEach(function (k) {
|
|
18
|
+
if (k !== 'default') {
|
|
19
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
20
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function () { return e[k]; }
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
n.default = e;
|
|
28
|
+
return Object.freeze(n);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
var pkg__namespace = /*#__PURE__*/_interopNamespace(pkg);
|
|
32
|
+
|
|
33
|
+
async function getInputOptions2(entryFile, platform, env, {
|
|
34
|
+
sourcemap = false,
|
|
35
|
+
bundlerOptions = {
|
|
36
|
+
enableSourcemap: false,
|
|
37
|
+
enableEsmShim: true,
|
|
38
|
+
externals: true
|
|
39
|
+
}
|
|
40
|
+
} = {}) {
|
|
41
|
+
const closestPkgJson = pkg__namespace.up({ cwd: path.dirname(entryFile) });
|
|
42
|
+
const projectRoot = closestPkgJson ? path.dirname(chunkG7R456H2_cjs.slash(closestPkgJson)) : chunkG7R456H2_cjs.slash(process.cwd());
|
|
43
|
+
const { workspaceMap, workspaceRoot } = await chunk73SEUI3W_cjs.getWorkspaceInformation({ mastraEntryFile: entryFile });
|
|
44
|
+
const analyzeEntryResult = await chunk73SEUI3W_cjs.analyzeBundle(
|
|
45
|
+
[entryFile],
|
|
46
|
+
entryFile,
|
|
47
|
+
{
|
|
48
|
+
outputDir: path.posix.join(process.cwd(), ".mastra", ".build"),
|
|
49
|
+
projectRoot: workspaceRoot || process.cwd(),
|
|
50
|
+
platform,
|
|
51
|
+
isDev: true,
|
|
52
|
+
bundlerOptions
|
|
53
|
+
},
|
|
54
|
+
logger.noopLogger
|
|
55
|
+
);
|
|
56
|
+
const deps = /* @__PURE__ */ new Map();
|
|
57
|
+
for (const [dep, metadata] of analyzeEntryResult.dependencies.entries()) {
|
|
58
|
+
const pkgName = chunkG7R456H2_cjs.getPackageName(dep);
|
|
59
|
+
if (pkgName && workspaceMap.has(pkgName)) {
|
|
60
|
+
deps.set(dep, metadata);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
const inputOptions = await chunkR2SYO6PH_cjs.getInputOptions(
|
|
64
|
+
entryFile,
|
|
65
|
+
{
|
|
66
|
+
dependencies: deps,
|
|
67
|
+
externalDependencies: /* @__PURE__ */ new Map(),
|
|
68
|
+
workspaceMap
|
|
69
|
+
},
|
|
70
|
+
platform,
|
|
71
|
+
env,
|
|
72
|
+
{ sourcemap, isDev: true, workspaceRoot, projectRoot, externalsPreset: bundlerOptions?.externals === true }
|
|
73
|
+
);
|
|
74
|
+
if (Array.isArray(inputOptions.plugins)) {
|
|
75
|
+
const plugins = [];
|
|
76
|
+
inputOptions.plugins.forEach((plugin) => {
|
|
77
|
+
if (plugin?.name === "node-resolve") {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
if (plugin?.name === "tsconfig-paths") {
|
|
81
|
+
plugins.push(
|
|
82
|
+
chunkYIUDHDPS_cjs.tsConfigPaths({
|
|
83
|
+
localResolve: true
|
|
84
|
+
})
|
|
85
|
+
);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
plugins.push(plugin);
|
|
89
|
+
});
|
|
90
|
+
inputOptions.plugins = plugins;
|
|
91
|
+
inputOptions.plugins.push(chunk73SEUI3W_cjs.aliasHono());
|
|
92
|
+
inputOptions.plugins.push(chunkR2SYO6PH_cjs.nodeModulesExtensionResolver());
|
|
93
|
+
}
|
|
94
|
+
return inputOptions;
|
|
95
|
+
}
|
|
96
|
+
async function createWatcher(inputOptions, outputOptions) {
|
|
97
|
+
const watcher = await rollup.watch({
|
|
98
|
+
...inputOptions,
|
|
99
|
+
output: {
|
|
100
|
+
...outputOptions,
|
|
101
|
+
format: "esm",
|
|
102
|
+
entryFileNames: "[name].mjs",
|
|
103
|
+
chunkFileNames: "[name].mjs"
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
return watcher;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// src/build/serverOptions.ts
|
|
110
|
+
async function getServerOptions(entryFile, outputDir, logger) {
|
|
111
|
+
const result = await chunkUPVHAZ5Q_cjs.extractMastraOption("server", entryFile, outputDir, logger);
|
|
112
|
+
if (!result) {
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
return result.getConfig();
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
exports.createWatcher = createWatcher;
|
|
119
|
+
exports.getInputOptions = getInputOptions2;
|
|
120
|
+
exports.getServerOptions = getServerOptions;
|
|
121
|
+
//# sourceMappingURL=chunk-EBHDMP6N.cjs.map
|
|
122
|
+
//# sourceMappingURL=chunk-EBHDMP6N.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/build/watcher.ts","../src/build/serverOptions.ts"],"names":["getInputOptions","pkg","dirname","slash","getWorkspaceInformation","analyzeBundle","posix","noopLogger","getPackageName","tsConfigPaths","aliasHono","nodeModulesExtensionResolver","watch","extractMastraOption"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeA,eAAsBA,gBAAAA,CACpB,SAAA,EACA,QAAA,EACA,GAAA,EACA;AAAA,EACE,SAAA,GAAY,KAAA;AAAA,EACZ,cAAA,GAAiB;AAAA,IACf,eAAA,EAAiB,KAAA;AAAA,IACjB,aAAA,EAAe,IAAA;AAAA,IACf,SAAA,EAAW;AAAA;AAEf,CAAA,GAA8D,EAAC,EAC/D;AACA,EAAA,MAAM,iBAAqBC,cAAA,CAAA,EAAA,CAAG,EAAE,KAAKC,YAAA,CAAQ,SAAS,GAAG,CAAA;AACzD,EAAA,MAAM,WAAA,GAAc,cAAA,GAAiBA,YAAA,CAAQC,uBAAA,CAAM,cAAc,CAAC,CAAA,GAAIA,uBAAA,CAAM,OAAA,CAAQ,GAAA,EAAK,CAAA;AACzF,EAAA,MAAM,EAAE,cAAc,aAAA,EAAc,GAAI,MAAMC,yCAAA,CAAwB,EAAE,eAAA,EAAiB,SAAA,EAAW,CAAA;AAEpG,EAAA,MAAM,qBAAqB,MAAMC,+BAAA;AAAA,IAC/B,CAAC,SAAS,CAAA;AAAA,IACV,SAAA;AAAA,IACA;AAAA,MACE,WAAWC,UAAA,CAAM,IAAA,CAAK,QAAQ,GAAA,EAAI,EAAG,WAAW,QAAQ,CAAA;AAAA,MACxD,WAAA,EAAa,aAAA,IA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gB,CAAA;AAAA,IAC/B,CAAC,CAAA;AAED,IAAA,YAAA,CAAa,OAAA,GAAU,OAAA;AACvB,IAAA,YAAA,CAAa,OAAA,CAAQ,IAAA,CAAKC,2BAAA,EAAW,CAAA;AAErC,IAAA,YAAA,CAAa,OAAA,CAAQ,IAAA,CAAKC,8CAAA,EAA8B,CAAA;AAAA,EAC1D;AAEA,EAAA,OAAO,YAAA;AACT;AAEA,eAAsB,aAAA,CAAc,cAA4B,aAAA,EAA8B;AAC5F,EAAA,MAAM,OAAA,GAAU,MAAMC,YAAA,CAAM;AAAA,IAC1B,GAAG,YAAA;AAAA,IACH,MAAA,EAAQ;AAAA,MACN,GAAG,aAAA;AAAA,MACH,MAAA,EAAQ,KAAA;AAAA,MACR,cAAA,EAAgB,YAAA;AAAA,MAChB,cAAA,EAAgB;AAAA;AAClB,GACD,CAAA;AAED,EAAA,OAAO,OAAA;AACT;;;AC9FA,eAAsB,gBAAA,CACpB,SAAA,EACA,SAAA,EACA,MAAA,EACkC;AAClC,EAAA,MAAM,SAAS,MAAMC,qCAAA,CAAoB,QAAA,EAAU,SAAA,EAAW,WAAW,MAAM,CAAA;AAC/E,EAAA,IAAI,CAAC,MAAA,EAAQ;AACX,IAAA,OAAO,IAAA;AAAA,EACT;AAEA,EAAA,OAAO,OAAO,SAAA,EAAU;AAC1B","file":"chunk-EBHDMP6N.cjs","sourcesContent":["import { dirname, posix } from 'node:path';\nimport { noopLogger } from '@mastra/core/logger';\nimport * as pkg from 'empathic/package';\nimport type { InputOptions, OutputOptions, Plugin } from 'rollup';\nimport { watch } from 'rollup';\nimport { getWorkspaceInformation } from '../bundler/workspaceDependencies';\nimport { analyzeBundle } from './analyze';\nimport { getInputOptions as getBundlerInputOptions } from './bundler';\nimport { aliasHono } from './plugins/hono-alias';\nimport { nodeModulesExtensionResolver } from './plugins/node-modules-extension-resolver';\nimport { tsConfigPaths } from './plugins/tsconfig-paths';\nimport type { BundlerOptions } from './types';\nimport { getPackageName, slash } from './utils';\nimport type { BundlerPlatform } from './utils';\n\nexport async function getInputOptions(\n entryFile: string,\n platform: BundlerPlatform,\n env?: Record<string, string>,\n {\n sourcemap = false,\n bundlerOptions = {\n enableSourcemap: false,\n enableEsmShim: true,\n externals: true,\n },\n }: { sourcemap?: boolean; bundlerOptions?: BundlerOptions } = {},\n) {\n const closestPkgJson = pkg.up({ cwd: dirname(entryFile) });\n const projectRoot = closestPkgJson ? dirname(slash(closestPkgJson)) : slash(process.cwd());\n const { workspaceMap, workspaceRoot } = await getWorkspaceInformation({ mastraEntryFile: entryFile });\n\n const analyzeEntryResult = await analyzeBundle(\n [entryFile],\n entryFile,\n {\n outputDir: posix.join(process.cwd(), '.mastra', '.build'),\n projectRoot: workspaceRoot || process.cwd(),\n platform,\n isDev: true,\n bundlerOptions,\n },\n noopLogger,\n );\n\n const deps = /* @__PURE__ */ new Map();\n for (const [dep, metadata] of analyzeEntryResult.dependencies.entries()) {\n const pkgName = getPackageName(dep);\n if (pkgName && workspaceMap.has(pkgName)) {\n deps.set(dep, metadata);\n }\n }\n\n const inputOptions = await getBundlerInputOptions(\n entryFile,\n {\n dependencies: deps,\n externalDependencies: new Map(),\n workspaceMap,\n },\n platform,\n env,\n { sourcemap, isDev: true, workspaceRoot, projectRoot, externalsPreset: bundlerOptions?.externals === true },\n );\n\n if (Array.isArray(inputOptions.plugins)) {\n // filter out node-resolve plugin so all node_modules are external\n // and tsconfig-paths plugin as we are injection a custom one\n const plugins = [] as Plugin[];\n inputOptions.plugins.forEach(plugin => {\n if ((plugin as Plugin | undefined)?.name === 'node-resolve') {\n return;\n }\n\n if ((plugin as Plugin | undefined)?.name === 'tsconfig-paths') {\n plugins.push(\n tsConfigPaths({\n localResolve: true,\n }),\n );\n return;\n }\n\n plugins.push(plugin as Plugin);\n });\n\n inputOptions.plugins = plugins;\n inputOptions.plugins.push(aliasHono());\n // fixes imports like lodash/fp/get\n inputOptions.plugins.push(nodeModulesExtensionResolver());\n }\n\n return inputOptions;\n}\n\nexport async function createWatcher(inputOptions: InputOptions, outputOptions: OutputOptions) {\n const watcher = await watch({\n ...inputOptions,\n output: {\n ...outputOptions,\n format: 'esm',\n entryFileNames: '[name].mjs',\n chunkFileNames: '[name].mjs',\n },\n });\n\n return watcher;\n}\n","import type { IMastraLogger } from '@mastra/core/logger';\nimport type { Config } from '@mastra/core/mastra';\nimport { extractMastraOption, extractMastraOptionBundler } from './shared/extract-mastra-option';\n\nexport function getServerOptionsBundler(\n entryFile: string,\n result: {\n hasCustomConfig: false;\n },\n) {\n return extractMastraOptionBundler('server', entryFile, result);\n}\n\nexport async function getServerOptions(\n entryFile: string,\n outputDir: string,\n logger?: IMastraLogger,\n): Promise<Config['server'] | null> {\n const result = await extractMastraOption('server', entryFile, outputDir, logger);\n if (!result) {\n return null;\n }\n\n return result.getConfig();\n}\n"]}
|
|
@@ -1,40 +1,79 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getPackageRootPath, subpathExternalsResolver, tsConfigPaths, esbuild, esmShim, removeDeployer } from './chunk-ANF3UFZ3.js';
|
|
2
|
+
import { isBuiltinModule, getPackageName, getNodeResolveOptions, slash } from './chunk-XN3FKMO6.js';
|
|
3
|
+
import { isAbsolute, join } from 'path';
|
|
4
|
+
import { pathToFileURL, fileURLToPath } from 'url';
|
|
5
|
+
import { optimizeLodashImports } from '@optimize-lodash/rollup-plugin';
|
|
2
6
|
import alias from '@rollup/plugin-alias';
|
|
3
7
|
import commonjs from '@rollup/plugin-commonjs';
|
|
4
8
|
import json from '@rollup/plugin-json';
|
|
5
9
|
import nodeResolve from '@rollup/plugin-node-resolve';
|
|
6
|
-
import esmShim from '@rollup/plugin-esm-shim';
|
|
7
|
-
import { pathToFileURL, fileURLToPath } from 'url';
|
|
8
10
|
import { rollup } from 'rollup';
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
+
import { readFile } from 'fs/promises';
|
|
12
|
+
|
|
13
|
+
async function getPackageJSON(pkgName, importer) {
|
|
14
|
+
const pkgRoot = await getPackageRootPath(pkgName, importer);
|
|
15
|
+
if (!pkgRoot) {
|
|
16
|
+
throw new Error(`Package ${pkgName} not found`);
|
|
17
|
+
}
|
|
18
|
+
const pkgJSON = JSON.parse(await readFile(join(pkgRoot, "package.json"), "utf-8"));
|
|
19
|
+
return pkgJSON;
|
|
20
|
+
}
|
|
21
|
+
function nodeModulesExtensionResolver() {
|
|
22
|
+
const nodeResolvePlugin = nodeResolve();
|
|
23
|
+
return {
|
|
24
|
+
name: "node-modules-extension-resolver",
|
|
25
|
+
async resolveId(id, importer, options) {
|
|
26
|
+
if (!importer || id.startsWith(".") || id.startsWith("/") || isBuiltinModule(id) || isAbsolute(id)) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
const parts = id.split("/");
|
|
30
|
+
const isScoped = id.startsWith("@");
|
|
31
|
+
if (isScoped && parts.length === 2 || !isScoped && parts.length === 1) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
const pkgName = getPackageName(id);
|
|
35
|
+
if (!pkgName) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
try {
|
|
39
|
+
const packageJSON = await getPackageJSON(pkgName, importer);
|
|
40
|
+
if (!!packageJSON.exports) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
const packageRoot = await getPackageRootPath(pkgName, importer);
|
|
44
|
+
const nodeResolved = await nodeResolvePlugin.resolveId?.handler?.call(this, id, importer, options);
|
|
45
|
+
if (!nodeResolved?.id) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
let filePath = nodeResolved.id;
|
|
49
|
+
if (nodeResolved.resolvedBy === "commonjs--resolver") {
|
|
50
|
+
filePath = filePath.substring(1).split("?")[0];
|
|
51
|
+
}
|
|
52
|
+
const resolvedImportPath = filePath.replace(packageRoot, pkgName);
|
|
53
|
+
return {
|
|
54
|
+
id: resolvedImportPath,
|
|
55
|
+
external: true
|
|
56
|
+
};
|
|
57
|
+
} catch (err) {
|
|
58
|
+
console.error(err);
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
}
|
|
11
64
|
|
|
65
|
+
// src/build/bundler.ts
|
|
12
66
|
async function getInputOptions(entryFile, analyzedBundleInfo, platform, env = { "process.env.NODE_ENV": JSON.stringify("production") }, {
|
|
13
67
|
sourcemap = false,
|
|
14
68
|
isDev = false,
|
|
15
69
|
projectRoot,
|
|
16
70
|
workspaceRoot = void 0,
|
|
17
|
-
enableEsmShim = true
|
|
71
|
+
enableEsmShim = true,
|
|
72
|
+
externalsPreset = false
|
|
18
73
|
}) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}) : nodeResolve({
|
|
23
|
-
preferBuiltins: false,
|
|
24
|
-
browser: true
|
|
25
|
-
});
|
|
26
|
-
const externalsCopy = /* @__PURE__ */ new Set();
|
|
27
|
-
for (const external of analyzedBundleInfo.externalDependencies) {
|
|
28
|
-
if (external.startsWith("@")) {
|
|
29
|
-
const [scope, name] = external.split("/", 3);
|
|
30
|
-
externalsCopy.add(`${scope}/${name}`);
|
|
31
|
-
externalsCopy.add(`${scope}/${name}/*`);
|
|
32
|
-
} else {
|
|
33
|
-
externalsCopy.add(external);
|
|
34
|
-
externalsCopy.add(`${external}/*`);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
const externals = Array.from(externalsCopy);
|
|
74
|
+
const nodeResolvePlugin = nodeResolve(getNodeResolveOptions(platform));
|
|
75
|
+
const externalsCopy = new Set(analyzedBundleInfo.externalDependencies.keys());
|
|
76
|
+
const externals = externalsPreset ? [] : Array.from(externalsCopy);
|
|
38
77
|
const normalizedEntryFile = slash(entryFile);
|
|
39
78
|
return {
|
|
40
79
|
logLevel: process.env.MASTRA_BUNDLER_DEBUG === "true" ? "debug" : "silent",
|
|
@@ -42,6 +81,7 @@ async function getInputOptions(entryFile, analyzedBundleInfo, platform, env = {
|
|
|
42
81
|
preserveSymlinks: true,
|
|
43
82
|
external: externals,
|
|
44
83
|
plugins: [
|
|
84
|
+
subpathExternalsResolver(externals),
|
|
45
85
|
{
|
|
46
86
|
name: "alias-optimized-deps",
|
|
47
87
|
resolveId(id) {
|
|
@@ -101,7 +141,7 @@ async function getInputOptions(entryFile, analyzedBundleInfo, platform, env = {
|
|
|
101
141
|
optimizeLodashImports({
|
|
102
142
|
include: "**/*.{js,ts,mjs,cjs}"
|
|
103
143
|
}),
|
|
104
|
-
commonjs({
|
|
144
|
+
externalsPreset ? null : commonjs({
|
|
105
145
|
extensions: [".js", ".ts"],
|
|
106
146
|
transformMixedEsModules: true,
|
|
107
147
|
esmExternals(id) {
|
|
@@ -109,15 +149,15 @@ async function getInputOptions(entryFile, analyzedBundleInfo, platform, env = {
|
|
|
109
149
|
}
|
|
110
150
|
}),
|
|
111
151
|
enableEsmShim ? esmShim() : void 0,
|
|
112
|
-
nodeResolvePlugin,
|
|
152
|
+
externalsPreset ? nodeModulesExtensionResolver() : nodeResolvePlugin,
|
|
113
153
|
// for debugging
|
|
114
154
|
// {
|
|
115
155
|
// name: 'logger',
|
|
116
|
-
// //@ts-
|
|
156
|
+
// //@ts-expect-error
|
|
117
157
|
// resolveId(id, ...args) {
|
|
118
158
|
// console.log({ id, args });
|
|
119
159
|
// },
|
|
120
|
-
// // @ts-
|
|
160
|
+
// // @ts-expect-error
|
|
121
161
|
// transform(code, id) {
|
|
122
162
|
// if (code.includes('class Duplexify ')) {
|
|
123
163
|
// console.log({ duplex: id });
|
|
@@ -151,6 +191,6 @@ async function createBundler(inputOptions, outputOptions) {
|
|
|
151
191
|
};
|
|
152
192
|
}
|
|
153
193
|
|
|
154
|
-
export { createBundler, getInputOptions };
|
|
155
|
-
//# sourceMappingURL=chunk-
|
|
156
|
-
//# sourceMappingURL=chunk-
|
|
194
|
+
export { createBundler, getInputOptions, nodeModulesExtensionResolver };
|
|
195
|
+
//# sourceMappingURL=chunk-EZBW45SX.js.map
|
|
196
|
+
//# sourceMappingURL=chunk-EZBW45SX.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/build/plugins/node-modules-extension-resolver.ts","../src/build/bundler.ts"],"names":["nodeResolve","join"],"mappings":";;;;;;;;;;;;AAYA,eAAe,cAAA,CAAe,SAAiB,QAAA,EAAwC;AACrF,EAAA,MAAM,OAAA,GAAU,MAAM,kBAAA,CAAmB,OAAA,EAAS,QAAQ,CAAA;AAC1D,EAAA,IAAI,CAAC,OAAA,EAAS;AACZ,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,QAAA,EAAW,OAAO,CAAA,UAAA,CAAY,CAAA;AAAA,EAChD;AAEA,EAAA,MAAM,OAAA,GAAU,IAAA,CAAK,KAAA,CAAM,MAAM,QAAA,CAAS,KAAK,OAAA,EAAS,cAAc,CAAA,EAAG,OAAO,CAAC,CAAA;AACjF,EAAA,OAAO,OAAA;AACT;AASO,SAAS,4BAAA,GAAuC;AAErD,EAAA,MAAM,oBAAoB,WAAA,EAAY;AAEtC,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,iCAAA;AAAA,IACN,MAAM,SAAA,CAAU,EAAA,EAAI,QAAA,EAAU,OAAA,EAAS;AAErC,MAAA,IAAI,CAAC,QAAA,IAAY,EAAA,CAAG,UAAA,CAAW,GAAG,CAAA,IAAK,EAAA,CAAG,UAAA,CAAW,GAAG,KAAK,eAAA,CAAgB,EAAE,CAAA,IAAK,UAAA,CAAW,EAAE,CAAA,EAAG;AAClG,QAAA,OAAO,IAAA;AAAA,MACT;AAGA,MAAA,MAAM,KAAA,GAAQ,EAAA,CAAG,KAAA,CAAM,GAAG,CAAA;AAC1B,MAAA,MAAM,QAAA,GAAW,EAAA,CAAG,UAAA,CAAW,GAAG,CAAA;AAClC,MAAA,IAAK,QAAA,IAAY,MAAM,MAAA,KAAW,CAAA,IAAO,CAAC,QAAA,IAAY,KAAA,CAAM,WAAW,CAAA,EAAI;AACzE,QAAA,OAAO,IAAA;AAAA,MACT;AA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EAAyB,IAAA;AAAA,QACzB,aAAa,EAAA,EAAI;AACf,UAAA,OAAO,SAAA,CAAU,SAAS,EAAE,CAAA;AAAA,QAC9B;AAAA,OACD,CAAA;AAAA,MACL,aAAA,GAAgB,SAAQ,GAAI,MAAA;AAAA,MAC5B,eAAA,GAAkB,8BAA6B,GAAI,iBAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAenD,IAAA,EAAK;AAAA,MACL,cAAA,CAAe,SAAA,EAAW,EAAE,SAAA,EAAW,CAAA;AAAA;AAAA,MAEvC,OAAA,CAAQ;AAAA,QACN,OAAA,EAAS,SAAA;AAAA,QACT;AAAA,OACD;AAAA,KACH,CAAE,OAAO,OAAO;AAAA,GAClB;AACF;AAEA,eAAsB,aAAA,CACpB,cACA,aAAA,EACA;AACA,EAAA,MAAM,OAAA,GAAU,MAAM,MAAA,CAAO,YAAY,CAAA;AAEzC,EAAA,OAAO;AAAA,IACL,OAAO,MAAM;AACX,MAAA,OAAO,QAAQ,KAAA,CAAM;AAAA,QACnB,GAAG,aAAA;AAAA,QACH,MAAA,EAAQ,KAAA;AAAA,QACR,cAAA,EAAgB,YAAA;AAAA,QAChB,cAAA,EAAgB;AAAA,OACjB,CAAA;AAAA,IACH,CAAA;AAAA,IACA,OAAO,MAAM;AACX,MAAA,OAAO,QAAQ,KAAA,EAAM;AAAA,IACvB;AAAA,GACF;AACF","file":"chunk-EZBW45SX.js","sourcesContent":["import { readFile } from 'node:fs/promises';\nimport { join, isAbsolute } from 'node:path';\nimport nodeResolve from '@rollup/plugin-node-resolve';\nimport type { Plugin } from 'rollup';\nimport type { PackageJson } from 'type-fest';\nimport { getPackageRootPath } from '../package-info';\nimport { getPackageName, isBuiltinModule } from '../utils';\n\n/**\n * Check if a package has an exports field in its package.json.\n * Results are cached to avoid repeated filesystem reads.\n */\nasync function getPackageJSON(pkgName: string, importer: string): Promise<PackageJson> {\n const pkgRoot = await getPackageRootPath(pkgName, importer);\n if (!pkgRoot) {\n throw new Error(`Package ${pkgName} not found`);\n }\n\n const pkgJSON = JSON.parse(await readFile(join(pkgRoot, 'package.json'), 'utf-8')) as PackageJson;\n return pkgJSON;\n}\n\n/**\n * Rollup plugin that resolves module extensions for external dependencies.\n *\n * This plugin handles ESM compatibility for external imports when node-resolve is not used:\n * - Packages WITH exports field (e.g., hono, date-fns): Keep imports as-is or strip redundant extensions\n * - Packages WITHOUT exports field (e.g., lodash): Add .js extension for direct file imports\n */\nexport function nodeModulesExtensionResolver(): Plugin {\n // Create a single instance of node-resolve to reuse\n const nodeResolvePlugin = nodeResolve();\n\n return {\n name: 'node-modules-extension-resolver',\n async resolveId(id, importer, options) {\n // Skip relative imports, absolute paths, no importer, or builtin modules\n if (!importer || id.startsWith('.') || id.startsWith('/') || isBuiltinModule(id) || isAbsolute(id)) {\n return null;\n }\n\n // Skip direct package imports (e.g., 'lodash', '@mastra/core')\n const parts = id.split('/');\n const isScoped = id.startsWith('@');\n if ((isScoped && parts.length === 2) || (!isScoped && parts.length === 1)) {\n return null;\n }\n\n const pkgName = getPackageName(id);\n if (!pkgName) {\n return null;\n }\n\n try {\n const packageJSON = await getPackageJSON(pkgName, importer);\n // if it has exports, node should be able to rsolve it, if not the exports map is wrong.\n if (!!packageJSON.exports) {\n return null;\n }\n\n const packageRoot = await getPackageRootPath(pkgName, importer);\n // @ts-expect-error - handle is part of resolveId signature\n const nodeResolved = await nodeResolvePlugin.resolveId?.handler?.call(this, id, importer, options);\n // if we cannot resolve it, it's not a valid import so we let node handle it\n if (!nodeResolved?.id) {\n return null;\n }\n\n let filePath = nodeResolved.id;\n if (nodeResolved.resolvedBy === 'commonjs--resolver') {\n filePath = filePath.substring(1).split('?')[0];\n }\n\n const resolvedImportPath = filePath.replace(packageRoot, pkgName);\n\n return {\n id: resolvedImportPath,\n external: true,\n };\n } catch (err) {\n console.error(err);\n return null;\n }\n },\n };\n}\n","import { join } from 'node:path';\nimport { fileURLToPath, pathToFileURL } from 'node:url';\nimport { optimizeLodashImports } from '@optimize-lodash/rollup-plugin';\nimport alias from '@rollup/plugin-alias';\nimport commonjs from '@rollup/plugin-commonjs';\nimport json from '@rollup/plugin-json';\nimport nodeResolve from '@rollup/plugin-node-resolve';\nimport { rollup } from 'rollup';\nimport type { InputOptions, OutputOptions, Plugin } from 'rollup';\nimport type { analyzeBundle } from './analyze';\nimport { esbuild } from './plugins/esbuild';\nimport { esmShim } from './plugins/esm-shim';\nimport { nodeModulesExtensionResolver } from './plugins/node-modules-extension-resolver';\nimport { removeDeployer } from './plugins/remove-deployer';\nimport { subpathExternalsResolver } from './plugins/subpath-externals-resolver';\nimport { tsConfigPaths } from './plugins/tsconfig-paths';\nimport { getNodeResolveOptions, slash } from './utils';\nimport type { BundlerPlatform } from './utils';\n\nexport async function getInputOptions(\n entryFile: string,\n analyzedBundleInfo: Awaited<ReturnType<typeof analyzeBundle>>,\n platform: BundlerPlatform,\n env: Record<string, string> = { 'process.env.NODE_ENV': JSON.stringify('production') },\n {\n sourcemap = false,\n isDev = false,\n projectRoot,\n workspaceRoot = undefined,\n enableEsmShim = true,\n externalsPreset = false,\n }: {\n sourcemap?: boolean;\n isDev?: boolean;\n workspaceRoot?: string;\n projectRoot: string;\n enableEsmShim?: boolean;\n externalsPreset?: boolean;\n },\n): Promise<InputOptions> {\n const nodeResolvePlugin = nodeResolve(getNodeResolveOptions(platform));\n\n const externalsCopy = new Set<string>(analyzedBundleInfo.externalDependencies.keys());\n const externals = externalsPreset ? [] : Array.from(externalsCopy);\n\n const normalizedEntryFile = slash(entryFile);\n return {\n logLevel: process.env.MASTRA_BUNDLER_DEBUG === 'true' ? 'debug' : 'silent',\n treeshake: 'smallest',\n preserveSymlinks: true,\n external: externals,\n plugins: [\n subpathExternalsResolver(externals),\n {\n name: 'alias-optimized-deps',\n resolveId(id: string) {\n if (!analyzedBundleInfo.dependencies.has(id)) {\n return null;\n }\n\n const filename = analyzedBundleInfo.dependencies.get(id)!;\n const absolutePath = join(workspaceRoot || projectRoot, filename);\n\n // During `mastra dev` we want to keep deps as external\n if (isDev) {\n return {\n id: process.platform === 'win32' ? pathToFileURL(absolutePath).href : absolutePath,\n external: true,\n };\n }\n\n // For production builds return the absolute path as-is so Rollup can handle itself\n return {\n id: absolutePath,\n external: false,\n };\n },\n } satisfies Plugin,\n alias({\n entries: [\n {\n find: /^\\#server$/,\n replacement: slash(fileURLToPath(import.meta.resolve('@mastra/deployer/server'))),\n },\n {\n find: /^\\@mastra\\/server\\/(.*)/,\n replacement: `@mastra/server/$1`,\n customResolver: id => {\n if (id.startsWith('@mastra/server')) {\n return {\n id: fileURLToPath(import.meta.resolve(id)),\n };\n }\n },\n },\n { find: /^\\#mastra$/, replacement: normalizedEntryFile },\n ],\n }),\n tsConfigPaths(),\n {\n name: 'tools-rewriter',\n resolveId(id: string) {\n if (id === '#tools') {\n return {\n id: './tools.mjs',\n external: true,\n };\n }\n },\n } satisfies Plugin,\n esbuild({\n platform,\n define: env,\n }),\n optimizeLodashImports({\n include: '**/*.{js,ts,mjs,cjs}',\n }),\n externalsPreset\n ? null\n : commonjs({\n extensions: ['.js', '.ts'],\n transformMixedEsModules: true,\n esmExternals(id) {\n return externals.includes(id);\n },\n }),\n enableEsmShim ? esmShim() : undefined,\n externalsPreset ? nodeModulesExtensionResolver() : nodeResolvePlugin,\n // for debugging\n // {\n // name: 'logger',\n // //@ts-expect-error\n // resolveId(id, ...args) {\n // console.log({ id, args });\n // },\n // // @ts-expect-error\n // transform(code, id) {\n // if (code.includes('class Duplexify ')) {\n // console.log({ duplex: id });\n // }\n // },\n // },\n json(),\n removeDeployer(entryFile, { sourcemap }),\n // treeshake unused imports\n esbuild({\n include: entryFile,\n platform,\n }),\n ].filter(Boolean),\n } satisfies InputOptions;\n}\n\nexport async function createBundler(\n inputOptions: InputOptions,\n outputOptions: Partial<OutputOptions> & { dir: string },\n) {\n const bundler = await rollup(inputOptions);\n\n return {\n write: () => {\n return bundler.write({\n ...outputOptions,\n format: 'esm',\n entryFileNames: '[name].mjs',\n chunkFileNames: '[name].mjs',\n });\n },\n close: () => {\n return bundler.close();\n },\n };\n}\n"]}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var module$1 = require('module');
|
|
4
|
+
var path = require('path');
|
|
5
|
+
|
|
6
|
+
// src/build/utils.ts
|
|
7
|
+
function getNodeResolveOptions(platform) {
|
|
8
|
+
if (platform === "browser") {
|
|
9
|
+
return {
|
|
10
|
+
preferBuiltins: false,
|
|
11
|
+
browser: true,
|
|
12
|
+
exportConditions: ["browser", "worker", "default"]
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
return {
|
|
16
|
+
preferBuiltins: true,
|
|
17
|
+
exportConditions: ["node"]
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function detectRuntime() {
|
|
21
|
+
if (process.versions?.bun) {
|
|
22
|
+
return "bun";
|
|
23
|
+
}
|
|
24
|
+
return "node";
|
|
25
|
+
}
|
|
26
|
+
function isDependencyPartOfPackage(dep, packageName) {
|
|
27
|
+
if (dep === packageName) {
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
return dep.startsWith(`${packageName}/`);
|
|
31
|
+
}
|
|
32
|
+
function getPackageName(id) {
|
|
33
|
+
const parts = id.split("/");
|
|
34
|
+
if (id.startsWith("@")) {
|
|
35
|
+
return parts.slice(0, 2).join("/");
|
|
36
|
+
}
|
|
37
|
+
return parts[0];
|
|
38
|
+
}
|
|
39
|
+
function getCompiledDepCachePath(rootPath, packageName) {
|
|
40
|
+
return slash(path.join(rootPath, "node_modules", ".cache", packageName));
|
|
41
|
+
}
|
|
42
|
+
function slash(path) {
|
|
43
|
+
const isExtendedLengthPath = path.startsWith("\\\\?\\");
|
|
44
|
+
if (isExtendedLengthPath) {
|
|
45
|
+
return path;
|
|
46
|
+
}
|
|
47
|
+
return path.replaceAll("\\", "/");
|
|
48
|
+
}
|
|
49
|
+
function rollupSafeName(name, rootDir) {
|
|
50
|
+
const rel = path.relative(rootDir, name);
|
|
51
|
+
let entry = slash(rel);
|
|
52
|
+
entry = entry.replace(/^(\.\.\/)+/, "");
|
|
53
|
+
entry = entry.replace(/^\/+/, "");
|
|
54
|
+
entry = entry.replace(/^[A-Za-z]:\//, "");
|
|
55
|
+
if (!entry) {
|
|
56
|
+
entry = slash(path.basename(name));
|
|
57
|
+
}
|
|
58
|
+
return entry;
|
|
59
|
+
}
|
|
60
|
+
function normalizeStudioBase(studioBase) {
|
|
61
|
+
studioBase = studioBase.trim();
|
|
62
|
+
if (studioBase.includes("..") || studioBase.includes("?") || studioBase.includes("#")) {
|
|
63
|
+
throw new Error(`Invalid base path: "${studioBase}". Base path cannot contain '..', '?', or '#'`);
|
|
64
|
+
}
|
|
65
|
+
studioBase = studioBase.replace(/\/+/g, "/");
|
|
66
|
+
if (studioBase === "/" || studioBase === "") {
|
|
67
|
+
return "";
|
|
68
|
+
}
|
|
69
|
+
if (studioBase.endsWith("/")) {
|
|
70
|
+
studioBase = studioBase.slice(0, -1);
|
|
71
|
+
}
|
|
72
|
+
if (!studioBase.startsWith("/")) {
|
|
73
|
+
studioBase = `/${studioBase}`;
|
|
74
|
+
}
|
|
75
|
+
return studioBase;
|
|
76
|
+
}
|
|
77
|
+
function injectStudioHtmlConfig(html, config) {
|
|
78
|
+
html = html.replace(`'%%MASTRA_SERVER_HOST%%'`, config.host);
|
|
79
|
+
html = html.replace(`'%%MASTRA_SERVER_PORT%%'`, config.port);
|
|
80
|
+
html = html.replace(`'%%MASTRA_SERVER_PROTOCOL%%'`, config.protocol);
|
|
81
|
+
html = html.replace(`'%%MASTRA_API_PREFIX%%'`, config.apiPrefix);
|
|
82
|
+
html = html.replace(`'%%MASTRA_HIDE_CLOUD_CTA%%'`, config.hideCloudCta);
|
|
83
|
+
html = html.replace(`'%%MASTRA_CLOUD_API_ENDPOINT%%'`, config.cloudApiEndpoint);
|
|
84
|
+
html = html.replace(`'%%MASTRA_EXPERIMENTAL_FEATURES%%'`, config.experimentalFeatures);
|
|
85
|
+
html = html.replace(`'%%MASTRA_TELEMETRY_DISABLED%%'`, config.telemetryDisabled);
|
|
86
|
+
html = html.replace(`'%%MASTRA_REQUEST_CONTEXT_PRESETS%%'`, config.requestContextPresets);
|
|
87
|
+
if (config.autoDetectUrl) {
|
|
88
|
+
html = html.replace(`'%%MASTRA_AUTO_DETECT_URL%%'`, config.autoDetectUrl);
|
|
89
|
+
}
|
|
90
|
+
html = html.replaceAll("%%MASTRA_STUDIO_BASE_PATH%%", config.basePath);
|
|
91
|
+
return html;
|
|
92
|
+
}
|
|
93
|
+
function isBuiltinModule(specifier) {
|
|
94
|
+
return module$1.builtinModules.includes(specifier) || specifier.startsWith("node:") || module$1.builtinModules.includes(specifier.replace(/^node:/, ""));
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
exports.detectRuntime = detectRuntime;
|
|
98
|
+
exports.getCompiledDepCachePath = getCompiledDepCachePath;
|
|
99
|
+
exports.getNodeResolveOptions = getNodeResolveOptions;
|
|
100
|
+
exports.getPackageName = getPackageName;
|
|
101
|
+
exports.injectStudioHtmlConfig = injectStudioHtmlConfig;
|
|
102
|
+
exports.isBuiltinModule = isBuiltinModule;
|
|
103
|
+
exports.isDependencyPartOfPackage = isDependencyPartOfPackage;
|
|
104
|
+
exports.normalizeStudioBase = normalizeStudioBase;
|
|
105
|
+
exports.rollupSafeName = rollupSafeName;
|
|
106
|
+
exports.slash = slash;
|
|
107
|
+
//# sourceMappingURL=chunk-G7R456H2.cjs.map
|
|
108
|
+
//# sourceMappingURL=chunk-G7R456H2.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/build/utils.ts"],"names":["join","relative","basename","builtinModules"],"mappings":";;;;;;AA0BO,SAAS,sBAAsB,QAAA,EAAqD;AACzF,EAAA,IAAI,aAAa,SAAA,EAAW;AAC1B,IAAA,OAAO;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,CAAO,aAAa,CAAA;AAAA,EAC1E;AACA,EAAA,IAAA,GAAO,IAAA,CAAK,UAAA,CAAW,6BAAA,EAA+B,MAAA,CAAO,QAAQ,CAAA;AAErE,EAAA,OAAO,IAAA;AACT;AAOO,SAAS,gBAAgB,SAAA,EAA4B;AAC1D,EAAA,OACEC,uBAAA,CAAe,QAAA,CAAS,SAAS,CAAA,IACjC,UAAU,UAAA,CAAW,OAAO,CAAA,IAC5BA,uBAAA,CAAe,QAAA,CAAS,SAAA,CAAU,OAAA,CAAQ,QAAA,EAAU,EAAE,CAAC,CAAA;AAE3D","file":"chunk-G7R456H2.cjs","sourcesContent":["import { execSync } from 'node:child_process';\nimport { existsSync, mkdirSync } from 'node:fs';\nimport { builtinModules } from 'node:module';\nimport { basename, join, relative } from 'node:path';\nimport type { RollupNodeResolveOptions } from '@rollup/plugin-node-resolve';\n\n/** The detected JavaScript runtime environment */\nexport type RuntimePlatform = 'node' | 'bun';\n\n/**\n * The esbuild/bundler platform setting.\n * - 'node': Assumes Node.js environment, externalizes built-in modules\n * - 'browser': Assumes browser environment, polyfills Node APIs\n * - 'neutral': Runtime-agnostic, preserves all globals as-is (used for Bun)\n */\nexport type BundlerPlatform = 'node' | 'browser' | 'neutral';\n\n/**\n * Get nodeResolve plugin options based on the target platform.\n *\n * For 'browser' platform (e.g., Cloudflare Workers), uses browser-compatible\n * export conditions so packages like the Cloudflare SDK resolve to their\n * web runtime instead of Node.js-specific code.\n *\n * For 'node' and 'neutral' (Bun) platforms, uses Node.js module resolution.\n */\nexport function getNodeResolveOptions(platform: BundlerPlatform): RollupNodeResolveOptions {\n if (platform === 'browser') {\n return {\n preferBuiltins: false,\n browser: true,\n exportConditions: ['browser', 'worker', 'default'],\n };\n }\n return {\n preferBuiltins: true,\n exportConditions: ['node'],\n };\n}\n\n/**\n * Detect the current JavaScript runtime environment.\n *\n * This is used by the bundler to determine the appropriate esbuild platform\n * setting. When running under Bun, we need to use 'neutral' platform to\n * preserve Bun-specific globals (like Bun.s3).\n */\nexport function detectRuntime(): RuntimePlatform {\n if (process.versions?.bun) {\n return 'bun';\n }\n return 'node';\n}\n\nexport function upsertMastraDir({ dir = process.cwd() }: { dir?: string }) {\n const dirPath = join(dir, '.mastra');\n\n if (!existsSync(dirPath)) {\n mkdirSync(dirPath, { recursive: true });\n execSync(`echo \".mastra\" >> .gitignore`);\n }\n}\n\nexport function isDependencyPartOfPackage(dep: string, packageName: string) {\n if (dep === packageName) {\n return true;\n }\n\n return dep.startsWith(`${packageName}/`);\n}\n\n/**\n * Get the package name from a module ID\n */\nexport function getPackageName(id: string) {\n const parts = id.split('/');\n\n if (id.startsWith('@')) {\n return parts.slice(0, 2).join('/');\n }\n\n return parts[0];\n}\n\n/**\n * During `mastra dev` we are compiling TS files to JS (inside workspaces) so that users can just their workspace packages.\n * We store these compiled files inside `node_modules/.cache` for each workspace package.\n */\nexport function getCompiledDepCachePath(rootPath: string, packageName: string) {\n return slash(join(rootPath, 'node_modules', '.cache', packageName));\n}\n\n/**\n * Convert windows backslashes to posix slashes\n *\n * @example\n * ```ts\n * slash('C:\\\\Users\\\\user\\\\code\\\\mastra') // 'C:/Users/user/code/mastra'\n * ```\n */\nexport function slash(path: string) {\n const isExtendedLengthPath = path.startsWith('\\\\\\\\?\\\\');\n\n if (isExtendedLengthPath) {\n return path;\n }\n\n return path.replaceAll('\\\\', '/');\n}\n\n/**\n * Make a Rollup-safe name: pathless, POSIX, and without parent/absolute segments\n */\nexport function rollupSafeName(name: string, rootDir: string) {\n const rel = relative(rootDir, name);\n let entry = slash(rel);\n entry = entry.replace(/^(\\.\\.\\/)+/, '');\n entry = entry.replace(/^\\/+/, '');\n entry = entry.replace(/^[A-Za-z]:\\//, '');\n if (!entry) {\n entry = slash(basename(name));\n }\n return entry;\n}\n\n/**\n * Native binding loaders and infrastructure packages that should be ignored when identifying the actual package that requires native bindings\n */\nconst NATIVE_BINDING_LOADERS = [\n 'node-gyp-build',\n 'prebuild-install',\n 'bindings',\n 'node-addon-api',\n 'node-pre-gyp',\n 'nan', // Native Abstractions for Node.js\n] as const;\n\n/**\n * Finds the first real package from node_modules that likely contains native bindings, filtering out virtual modules and native binding loader infrastructure.\n *\n * @param moduleIds - Array of module IDs from a Rollup chunk\n * @returns The module ID of the actual native package, or undefined if not found\n *\n * @example\n * const moduleIds = [\n * '\\x00/path/node_modules/bcrypt/bcrypt.js?commonjs-module',\n * '/path/node_modules/node-gyp-build/index.js',\n * '/path/node_modules/bcrypt/bcrypt.js',\n * ];\n * findNativePackageModule(moduleIds); // Returns '/path/node_modules/bcrypt/bcrypt.js'\n */\nexport function findNativePackageModule(moduleIds: string[]): string | undefined {\n return moduleIds.find(id => {\n // Skip virtual modules (Rollup plugin-generated)\n if (id.startsWith('\\x00')) {\n return false;\n }\n\n // Must be from node_modules\n if (!id.includes('/node_modules/')) {\n return false;\n }\n\n // Skip native binding loader infrastructure\n for (const loader of NATIVE_BINDING_LOADERS) {\n if (id.includes(`/${loader}/`) || id.includes(`/${loader}@`)) {\n return false;\n }\n }\n\n return true;\n });\n}\n\n/**\n * Ensures that server.studioBase is normalized:\n * - Adds leading slash if missing (e.g., 'admin' → '/admin')\n * - Removes trailing slashes (e.g., '/admin/' → '/admin')\n * - Normalizes multiple slashes to single slash (e.g., '//api' → '/api')\n * - Returns empty string for root paths ('/' or '')\n *\n * @param studioBase - The studioBase path to normalize\n * @returns Normalized studioBase path string\n * @throws Error if path contains invalid characters ('..', '?', '#')\n */\nexport function normalizeStudioBase(studioBase: string): string {\n studioBase = studioBase.trim();\n\n // Validate: no path traversal, no query params, no special chars\n if (studioBase.includes('..') || studioBase.includes('?') || studioBase.includes('#')) {\n throw new Error(`Invalid base path: \"${studioBase}\". Base path cannot contain '..', '?', or '#'`);\n }\n\n // Normalize multiple slashes to single slash\n studioBase = studioBase.replace(/\\/+/g, '/');\n\n // Handle default value cases\n if (studioBase === '/' || studioBase === '') {\n return '';\n }\n\n // Remove trailing slash\n if (studioBase.endsWith('/')) {\n studioBase = studioBase.slice(0, -1);\n }\n\n // Add leading slash if missing\n if (!studioBase.startsWith('/')) {\n studioBase = `/${studioBase}`;\n }\n\n return studioBase;\n}\n\n/**\n * Configuration values for Studio's index.html placeholder injection.\n *\n * Each value is the **exact JavaScript expression** that replaces the\n * corresponding `'%%PLACEHOLDER%%'` token (including surrounding quotes).\n *\n * For literal strings pass `\"'value'\"` (quoted).\n * For runtime expressions pass the raw JS, e.g. `\"window.location.hostname\"`.\n */\nexport interface StudioInjectionConfig {\n host: string;\n port: string;\n protocol: string;\n apiPrefix: string;\n basePath: string;\n hideCloudCta: string;\n cloudApiEndpoint: string;\n experimentalFeatures: string;\n telemetryDisabled: string;\n requestContextPresets: string;\n autoDetectUrl?: string;\n}\n\n/**\n * Replace all `%%MASTRA_*%%` placeholders in the Studio `index.html` with the\n * supplied configuration values.\n *\n * The `<base href>` tag and the `window.MASTRA_STUDIO_BASE_PATH` assignment\n * use `basePath` as a plain string (no surrounding quotes), while all other\n * placeholders replace `'%%TOKEN%%'` (with surrounding single-quotes in the\n * source HTML) with the provided expression verbatim.\n */\nexport function injectStudioHtmlConfig(html: string, config: StudioInjectionConfig): string {\n html = html.replace(`'%%MASTRA_SERVER_HOST%%'`, config.host);\n html = html.replace(`'%%MASTRA_SERVER_PORT%%'`, config.port);\n html = html.replace(`'%%MASTRA_SERVER_PROTOCOL%%'`, config.protocol);\n html = html.replace(`'%%MASTRA_API_PREFIX%%'`, config.apiPrefix);\n html = html.replace(`'%%MASTRA_HIDE_CLOUD_CTA%%'`, config.hideCloudCta);\n html = html.replace(`'%%MASTRA_CLOUD_API_ENDPOINT%%'`, config.cloudApiEndpoint);\n html = html.replace(`'%%MASTRA_EXPERIMENTAL_FEATURES%%'`, config.experimentalFeatures);\n html = html.replace(`'%%MASTRA_TELEMETRY_DISABLED%%'`, config.telemetryDisabled);\n html = html.replace(`'%%MASTRA_REQUEST_CONTEXT_PRESETS%%'`, config.requestContextPresets);\n if (config.autoDetectUrl) {\n html = html.replace(`'%%MASTRA_AUTO_DETECT_URL%%'`, config.autoDetectUrl);\n }\n html = html.replaceAll('%%MASTRA_STUDIO_BASE_PATH%%', config.basePath);\n\n return html;\n}\n\n/**\n * Check if a module is a Node.js builtin module\n * @param specifier - Module specifier\n * @returns True if it's a builtin module\n */\nexport function isBuiltinModule(specifier: string): boolean {\n return (\n builtinModules.includes(specifier) ||\n specifier.startsWith('node:') ||\n builtinModules.includes(specifier.replace(/^node:/, ''))\n );\n}\n"]}
|