@sonordev/site-kit 5.5.0 → 5.6.0
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/agent-manifest.json +1 -1
- package/dist/AnalyticsProvider-6PXC7UDP.js +32 -0
- package/dist/{AnalyticsProvider-WDDW3IJW.js.map → AnalyticsProvider-6PXC7UDP.js.map} +1 -1
- package/dist/AnalyticsProvider-FVQIYSLY.mjs +11 -0
- package/dist/{AnalyticsProvider-KFXAH4GR.mjs.map → AnalyticsProvider-FVQIYSLY.mjs.map} +1 -1
- package/dist/{BlogViewTracker-D4DIEP4Q.js → BlogViewTracker-S4HSRCW7.js} +6 -6
- package/dist/{BlogViewTracker-D4DIEP4Q.js.map → BlogViewTracker-S4HSRCW7.js.map} +1 -1
- package/dist/{BlogViewTracker-ZVEGGH3Y.mjs → BlogViewTracker-ZUGLBOVI.mjs} +5 -5
- package/dist/{BlogViewTracker-ZVEGGH3Y.mjs.map → BlogViewTracker-ZUGLBOVI.mjs.map} +1 -1
- package/dist/ChatWidget-2TQWCXWP.js +22 -0
- package/dist/{ChatWidget-2ZYPYIMQ.js.map → ChatWidget-2TQWCXWP.js.map} +1 -1
- package/dist/ChatWidget-DG52ZIE6.mjs +13 -0
- package/dist/{ChatWidget-FYCCLMQE.mjs.map → ChatWidget-DG52ZIE6.mjs.map} +1 -1
- package/dist/EngageWidget-2VUJADIU.mjs +12 -0
- package/dist/{EngageWidget-6HUZYOY7.mjs.map → EngageWidget-2VUJADIU.mjs.map} +1 -1
- package/dist/EngageWidget-Z7RC2INM.js +21 -0
- package/dist/{EngageWidget-MYQTBBW6.js.map → EngageWidget-Z7RC2INM.js.map} +1 -1
- package/dist/{FileField-OZZHWGPA.mjs → FileField-FSQ7W3A5.mjs} +5 -5
- package/dist/{FileField-OZZHWGPA.mjs.map → FileField-FSQ7W3A5.mjs.map} +1 -1
- package/dist/{FileField-JK2S24XU.js → FileField-UOQHL25J.js} +6 -6
- package/dist/{FileField-JK2S24XU.js.map → FileField-UOQHL25J.js.map} +1 -1
- package/dist/{FormSpotlight-XV42L72H.mjs → FormSpotlight-RHL5FWM2.mjs} +3 -3
- package/dist/{FormSpotlight-XV42L72H.mjs.map → FormSpotlight-RHL5FWM2.mjs.map} +1 -1
- package/dist/{FormSpotlight-5AXFQU5M.js → FormSpotlight-TED32NHP.js} +15 -15
- package/dist/{FormSpotlight-5AXFQU5M.js.map → FormSpotlight-TED32NHP.js.map} +1 -1
- package/dist/{FormStage-RUK675HV.mjs → FormStage-DINIRFOX.mjs} +3 -3
- package/dist/{FormStage-RUK675HV.mjs.map → FormStage-DINIRFOX.mjs.map} +1 -1
- package/dist/{FormStage-HATUHNRV.js → FormStage-PFEBKHGY.js} +13 -13
- package/dist/{FormStage-HATUHNRV.js.map → FormStage-PFEBKHGY.js.map} +1 -1
- package/dist/ManagedForm-43WLCUAK.js +23 -0
- package/dist/{ManagedForm-JWEXJEXK.js.map → ManagedForm-43WLCUAK.js.map} +1 -1
- package/dist/ManagedForm-545YAUFC.mjs +14 -0
- package/dist/{ManagedForm-OA3MNGXT.mjs.map → ManagedForm-545YAUFC.mjs.map} +1 -1
- package/dist/{ManagedNewsletterForm-AAHH63KT.js → ManagedNewsletterForm-I3QN57HB.js} +8 -8
- package/dist/{ManagedNewsletterForm-AAHH63KT.js.map → ManagedNewsletterForm-I3QN57HB.js.map} +1 -1
- package/dist/{ManagedNewsletterForm-HZKTNWLW.mjs → ManagedNewsletterForm-ZPY5RRKX.mjs} +7 -7
- package/dist/{ManagedNewsletterForm-HZKTNWLW.mjs.map → ManagedNewsletterForm-ZPY5RRKX.mjs.map} +1 -1
- package/dist/{SignalCore-X3GDGBZD.mjs → SignalCore-EEH5IM4U.mjs} +5 -5
- package/dist/{SignalCore-X3GDGBZD.mjs.map → SignalCore-EEH5IM4U.mjs.map} +1 -1
- package/dist/{SignalCore-YSNZYBKJ.js → SignalCore-M4AXIMV4.js} +11 -11
- package/dist/{SignalCore-YSNZYBKJ.js.map → SignalCore-M4AXIMV4.js.map} +1 -1
- package/dist/SitemapSync-46G7LVZS.mjs +9 -0
- package/dist/{SitemapSync-2PTDBH5E.mjs.map → SitemapSync-46G7LVZS.mjs.map} +1 -1
- package/dist/SitemapSync-XK4JKCS7.js +18 -0
- package/dist/{SitemapSync-3SFAI546.js.map → SitemapSync-XK4JKCS7.js.map} +1 -1
- package/dist/SitemapSync.d.ts +3 -2
- package/dist/SitemapSync.d.ts.map +1 -1
- package/dist/analytics/AnalyticsProvider.d.ts +3 -1
- package/dist/analytics/AnalyticsProvider.d.ts.map +1 -1
- package/dist/analytics/WebVitals.d.ts +3 -1
- package/dist/analytics/WebVitals.d.ts.map +1 -1
- package/dist/analytics/index.js +13 -13
- package/dist/analytics/index.mjs +5 -5
- package/dist/analytics/send-gate.d.ts +8 -37
- package/dist/analytics/send-gate.d.ts.map +1 -1
- package/dist/blog/index.js +20 -20
- package/dist/blog/index.mjs +3 -3
- package/dist/blog/server-ui.js +14 -14
- package/dist/blog/server-ui.mjs +2 -2
- package/dist/{chunk-RMMHWSPP.mjs → chunk-473WDGQZ.mjs} +3 -3
- package/dist/{chunk-RMMHWSPP.mjs.map → chunk-473WDGQZ.mjs.map} +1 -1
- package/dist/{chunk-FYVLQ3OU.js → chunk-53KMRZT7.js} +3 -3
- package/dist/{chunk-FYVLQ3OU.js.map → chunk-53KMRZT7.js.map} +1 -1
- package/dist/{chunk-S6FEC6UT.mjs → chunk-5KIEZHVK.mjs} +14 -17
- package/dist/chunk-5KIEZHVK.mjs.map +1 -0
- package/dist/{chunk-MCJF2KJ6.js → chunk-5KIO6FXE.js} +5 -5
- package/dist/{chunk-MCJF2KJ6.js.map → chunk-5KIO6FXE.js.map} +1 -1
- package/dist/chunk-5RNAUYWE.js +50 -0
- package/dist/chunk-5RNAUYWE.js.map +1 -0
- package/dist/{chunk-MU7IEPDG.mjs → chunk-5UFDHGFE.mjs} +3 -3
- package/dist/{chunk-MU7IEPDG.mjs.map → chunk-5UFDHGFE.mjs.map} +1 -1
- package/dist/{chunk-V6NOM7PJ.mjs → chunk-6OP5XSMM.mjs} +3 -3
- package/dist/{chunk-V6NOM7PJ.mjs.map → chunk-6OP5XSMM.mjs.map} +1 -1
- package/dist/{chunk-TALEV3IH.mjs → chunk-7AUDKXY5.mjs} +3 -3
- package/dist/{chunk-TALEV3IH.mjs.map → chunk-7AUDKXY5.mjs.map} +1 -1
- package/dist/{chunk-3B6CXGAK.mjs → chunk-7C7XO5HX.mjs} +3 -3
- package/dist/{chunk-3B6CXGAK.mjs.map → chunk-7C7XO5HX.mjs.map} +1 -1
- package/dist/chunk-A6UYV475.mjs +45 -0
- package/dist/chunk-A6UYV475.mjs.map +1 -0
- package/dist/{chunk-ZRQFG3L6.mjs → chunk-AHZR4VGY.mjs} +4 -4
- package/dist/{chunk-ZRQFG3L6.mjs.map → chunk-AHZR4VGY.mjs.map} +1 -1
- package/dist/{chunk-YYAFHIY7.js → chunk-AY7JBGYC.js} +14 -14
- package/dist/{chunk-YYAFHIY7.js.map → chunk-AY7JBGYC.js.map} +1 -1
- package/dist/{chunk-CT5REGAK.js → chunk-B64AZC6P.js} +14 -14
- package/dist/{chunk-CT5REGAK.js.map → chunk-B64AZC6P.js.map} +1 -1
- package/dist/{chunk-VAS3LH5W.js → chunk-B6O7D5U4.js} +55 -49
- package/dist/chunk-B6O7D5U4.js.map +1 -0
- package/dist/{chunk-A3F5GRNJ.js → chunk-BWSMUSDB.js} +8 -8
- package/dist/{chunk-A3F5GRNJ.js.map → chunk-BWSMUSDB.js.map} +1 -1
- package/dist/{chunk-2CMSWJWC.js → chunk-BZLIOT7Q.js} +18 -18
- package/dist/{chunk-2CMSWJWC.js.map → chunk-BZLIOT7Q.js.map} +1 -1
- package/dist/{chunk-DRLHQQBH.mjs → chunk-C2MSD2UM.mjs} +4 -4
- package/dist/{chunk-DRLHQQBH.mjs.map → chunk-C2MSD2UM.mjs.map} +1 -1
- package/dist/{chunk-YNC5D3FT.js → chunk-CQRLKNHQ.js} +12 -12
- package/dist/{chunk-YNC5D3FT.js.map → chunk-CQRLKNHQ.js.map} +1 -1
- package/dist/{chunk-RZUZMUTN.mjs → chunk-CQS5ZYI6.mjs} +21 -9
- package/dist/chunk-CQS5ZYI6.mjs.map +1 -0
- package/dist/{chunk-W5NVW23S.js → chunk-DHIWR7CG.js} +4 -4
- package/dist/{chunk-W5NVW23S.js.map → chunk-DHIWR7CG.js.map} +1 -1
- package/dist/chunk-DQUBETXH.mjs +6 -0
- package/dist/{chunk-WDBCXRTT.mjs.map → chunk-DQUBETXH.mjs.map} +1 -1
- package/dist/{chunk-TX2QQ7IX.mjs → chunk-GJ6NOLGC.mjs} +3 -3
- package/dist/{chunk-TX2QQ7IX.mjs.map → chunk-GJ6NOLGC.mjs.map} +1 -1
- package/dist/{chunk-R4MX6EOM.mjs → chunk-GPLCPMVD.mjs} +7 -7
- package/dist/{chunk-R4MX6EOM.mjs.map → chunk-GPLCPMVD.mjs.map} +1 -1
- package/dist/{chunk-2OU4KBUN.js → chunk-H3D3ZGOJ.js} +15 -15
- package/dist/{chunk-2OU4KBUN.js.map → chunk-H3D3ZGOJ.js.map} +1 -1
- package/dist/{chunk-UZL2QU2V.mjs → chunk-H44XZUOV.mjs} +4 -4
- package/dist/{chunk-UZL2QU2V.mjs.map → chunk-H44XZUOV.mjs.map} +1 -1
- package/dist/{chunk-OFSA7LUH.mjs → chunk-HIHAXEPD.mjs} +4 -4
- package/dist/{chunk-OFSA7LUH.mjs.map → chunk-HIHAXEPD.mjs.map} +1 -1
- package/dist/{chunk-DYULWKDC.mjs → chunk-IYCLN3XS.mjs} +14 -33
- package/dist/chunk-IYCLN3XS.mjs.map +1 -0
- package/dist/{chunk-BNOQXDPJ.js → chunk-JE5DWAE6.js} +4 -4
- package/dist/{chunk-BNOQXDPJ.js.map → chunk-JE5DWAE6.js.map} +1 -1
- package/dist/{chunk-VYHRAICF.mjs → chunk-JNABXCLY.mjs} +4 -4
- package/dist/{chunk-VYHRAICF.mjs.map → chunk-JNABXCLY.mjs.map} +1 -1
- package/dist/{chunk-4XGACM7D.mjs → chunk-K2V3ZW36.mjs} +3 -3
- package/dist/{chunk-4XGACM7D.mjs.map → chunk-K2V3ZW36.mjs.map} +1 -1
- package/dist/chunk-KSL3WA2I.js +8 -0
- package/dist/{chunk-SUZ3ZLB2.js.map → chunk-KSL3WA2I.js.map} +1 -1
- package/dist/{chunk-HX3BRMOX.js → chunk-KY6M76JW.js} +3 -3
- package/dist/{chunk-HX3BRMOX.js.map → chunk-KY6M76JW.js.map} +1 -1
- package/dist/{chunk-X2XFLYZ3.mjs → chunk-LCSYJXIO.mjs} +3 -3
- package/dist/{chunk-X2XFLYZ3.mjs.map → chunk-LCSYJXIO.mjs.map} +1 -1
- package/dist/{chunk-UNPEMSLK.js → chunk-N2PGTPWN.js} +24 -12
- package/dist/chunk-N2PGTPWN.js.map +1 -0
- package/dist/{chunk-7PPNXORV.mjs → chunk-OA7KKOAK.mjs} +25 -31
- package/dist/chunk-OA7KKOAK.mjs.map +1 -0
- package/dist/{chunk-QEGUI2Q2.js → chunk-OC7AO7XS.js} +15 -15
- package/dist/{chunk-QEGUI2Q2.js.map → chunk-OC7AO7XS.js.map} +1 -1
- package/dist/{chunk-5TGAUWNO.mjs → chunk-QNPVVWR7.mjs} +3 -3
- package/dist/{chunk-5TGAUWNO.mjs.map → chunk-QNPVVWR7.mjs.map} +1 -1
- package/dist/{chunk-MNYM2XU4.js → chunk-R3KTBKSW.js} +4 -4
- package/dist/{chunk-MNYM2XU4.js.map → chunk-R3KTBKSW.js.map} +1 -1
- package/dist/{chunk-WIZRCI6J.mjs → chunk-RIYAMYLV.mjs} +3 -3
- package/dist/{chunk-WIZRCI6J.mjs.map → chunk-RIYAMYLV.mjs.map} +1 -1
- package/dist/{chunk-SQVYLIIN.js → chunk-S4RC6VAQ.js} +16 -19
- package/dist/chunk-S4RC6VAQ.js.map +1 -0
- package/dist/{chunk-Z6S4MWSR.js → chunk-SYGGZZMU.js} +21 -17
- package/dist/chunk-SYGGZZMU.js.map +1 -0
- package/dist/{chunk-FF5N5D3D.js → chunk-T5VTQUNF.js} +8 -8
- package/dist/{chunk-FF5N5D3D.js.map → chunk-T5VTQUNF.js.map} +1 -1
- package/dist/{chunk-G5HUI4BO.mjs → chunk-USKIL6V6.mjs} +3 -3
- package/dist/{chunk-G5HUI4BO.mjs.map → chunk-USKIL6V6.mjs.map} +1 -1
- package/dist/{chunk-PIPLBBDH.js → chunk-UU47DGHE.js} +22 -41
- package/dist/chunk-UU47DGHE.js.map +1 -0
- package/dist/{chunk-XQYC4KMH.mjs → chunk-VHZ4LHQT.mjs} +48 -42
- package/dist/chunk-VHZ4LHQT.mjs.map +1 -0
- package/dist/{chunk-Q26VZNM2.js → chunk-X5TCH7VZ.js} +3 -3
- package/dist/{chunk-Q26VZNM2.js.map → chunk-X5TCH7VZ.js.map} +1 -1
- package/dist/{chunk-QFNSM77X.js → chunk-XK5AIWQG.js} +3 -3
- package/dist/{chunk-QFNSM77X.js.map → chunk-XK5AIWQG.js.map} +1 -1
- package/dist/{chunk-KAUUGRYB.js → chunk-XR32C47O.js} +26 -32
- package/dist/chunk-XR32C47O.js.map +1 -0
- package/dist/{chunk-HBI67P7Y.mjs → chunk-YCI36ZUS.mjs} +18 -14
- package/dist/chunk-YCI36ZUS.mjs.map +1 -0
- package/dist/{chunk-HFJQMIFM.js → chunk-YYN4YZYZ.js} +4 -4
- package/dist/{chunk-HFJQMIFM.js.map → chunk-YYN4YZYZ.js.map} +1 -1
- package/dist/cli/api/{uptrade.d.ts → sonor.d.ts} +3 -2
- package/dist/cli/api/sonor.d.ts.map +1 -0
- package/dist/cli/commands/config-regression.test.d.ts +2 -0
- package/dist/cli/commands/config-regression.test.d.ts.map +1 -0
- package/dist/cli/commands/faqs.d.ts.map +1 -1
- package/dist/cli/commands/images.d.ts.map +1 -1
- package/dist/cli/commands/locations.d.ts.map +1 -1
- package/dist/cli/commands/migrate.d.ts.map +1 -1
- package/dist/cli/commands/setup.d.ts.map +1 -1
- package/dist/cli/config.d.ts +31 -0
- package/dist/cli/config.d.ts.map +1 -0
- package/dist/cli/config.test.d.ts +2 -0
- package/dist/cli/config.test.d.ts.map +1 -0
- package/dist/cli/index.js +459 -470
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/index.mjs +452 -463
- package/dist/cli/index.mjs.map +1 -1
- package/dist/cli/migrator/index.d.ts +1 -0
- package/dist/cli/migrator/index.d.ts.map +1 -1
- package/dist/cli/state.d.ts +7 -0
- package/dist/cli/state.d.ts.map +1 -0
- package/dist/cli/state.test.d.ts +2 -0
- package/dist/cli/state.test.d.ts.map +1 -0
- package/dist/client/index.js +4 -4
- package/dist/client/index.mjs +3 -3
- package/dist/commerce/index.js +57 -57
- package/dist/commerce/index.mjs +6 -6
- package/dist/engage/EngageWidget.d.ts +3 -2
- package/dist/engage/EngageWidget.d.ts.map +1 -1
- package/dist/engage/index.js +11 -10
- package/dist/engage/index.js.map +1 -1
- package/dist/engage/index.mjs +8 -7
- package/dist/engage/index.mjs.map +1 -1
- package/dist/fleet/FleetHeartbeat.d.ts +3 -2
- package/dist/fleet/FleetHeartbeat.d.ts.map +1 -1
- package/dist/fleet/heartbeat.d.ts +3 -2
- package/dist/fleet/heartbeat.d.ts.map +1 -1
- package/dist/fleet/heartbeat.test.d.ts +2 -0
- package/dist/fleet/heartbeat.test.d.ts.map +1 -0
- package/dist/fleet/index.js +9 -8
- package/dist/fleet/index.mjs +5 -4
- package/dist/forms/index.js +16 -16
- package/dist/forms/index.mjs +9 -9
- package/dist/forms/server.js +10 -10
- package/dist/forms/server.mjs +8 -8
- package/dist/forms/static.js +7 -7
- package/dist/forms/static.mjs +6 -6
- package/dist/images/index.js +11 -11
- package/dist/images/index.mjs +4 -4
- package/dist/index.js +64 -64
- package/dist/index.mjs +10 -10
- package/dist/layout/SiteKitClientProviders.d.ts.map +1 -1
- package/dist/layout/client.d.ts.map +1 -1
- package/dist/layout/client.js +9 -8
- package/dist/layout/client.mjs +8 -7
- package/dist/layout/index.js +11 -10
- package/dist/layout/index.js.map +1 -1
- package/dist/layout/index.mjs +9 -8
- package/dist/layout/index.mjs.map +1 -1
- package/dist/layout/types.d.ts +2 -0
- package/dist/layout/types.d.ts.map +1 -1
- package/dist/maps/index.js +5 -5
- package/dist/maps/index.mjs +3 -3
- package/dist/search/index.js +4 -4
- package/dist/search/index.mjs +3 -3
- package/dist/seo/client.js +6 -6
- package/dist/seo/client.mjs +5 -5
- package/dist/seo/index.js +6 -6
- package/dist/seo/index.mjs +5 -5
- package/dist/server/index.js +3 -3
- package/dist/server/index.mjs +2 -2
- package/dist/shared/reporting-gate.d.ts +43 -0
- package/dist/shared/reporting-gate.d.ts.map +1 -0
- package/dist/shared/version.d.ts +1 -1
- package/dist/signal/index.js +11 -11
- package/dist/signal/index.mjs +2 -2
- package/dist/sync/AddToCalendar.d.ts +19 -0
- package/dist/sync/AddToCalendar.d.ts.map +1 -0
- package/dist/sync/BookingWidget.d.ts.map +1 -1
- package/dist/sync/add-to-calendar.test.d.ts +2 -0
- package/dist/sync/add-to-calendar.test.d.ts.map +1 -0
- package/dist/sync/api-errors.test.d.ts +2 -0
- package/dist/sync/api-errors.test.d.ts.map +1 -0
- package/dist/sync/api.d.ts.map +1 -1
- package/dist/sync/index.js +17 -17
- package/dist/sync/index.mjs +4 -4
- package/dist/sync/types.d.ts +14 -0
- package/dist/sync/types.d.ts.map +1 -1
- package/package.json +4 -4
- package/dist/AnalyticsProvider-KFXAH4GR.mjs +0 -11
- package/dist/AnalyticsProvider-WDDW3IJW.js +0 -32
- package/dist/ChatWidget-2ZYPYIMQ.js +0 -22
- package/dist/ChatWidget-FYCCLMQE.mjs +0 -13
- package/dist/EngageWidget-6HUZYOY7.mjs +0 -11
- package/dist/EngageWidget-MYQTBBW6.js +0 -20
- package/dist/ManagedForm-JWEXJEXK.js +0 -23
- package/dist/ManagedForm-OA3MNGXT.mjs +0 -14
- package/dist/SitemapSync-2PTDBH5E.mjs +0 -9
- package/dist/SitemapSync-3SFAI546.js +0 -18
- package/dist/chunk-7PPNXORV.mjs.map +0 -1
- package/dist/chunk-DYULWKDC.mjs.map +0 -1
- package/dist/chunk-HBI67P7Y.mjs.map +0 -1
- package/dist/chunk-KAUUGRYB.js.map +0 -1
- package/dist/chunk-NVSWTDWU.mjs +0 -25
- package/dist/chunk-NVSWTDWU.mjs.map +0 -1
- package/dist/chunk-OL2QBWAU.js +0 -29
- package/dist/chunk-OL2QBWAU.js.map +0 -1
- package/dist/chunk-PIPLBBDH.js.map +0 -1
- package/dist/chunk-RZUZMUTN.mjs.map +0 -1
- package/dist/chunk-S6FEC6UT.mjs.map +0 -1
- package/dist/chunk-SQVYLIIN.js.map +0 -1
- package/dist/chunk-SUZ3ZLB2.js +0 -8
- package/dist/chunk-UNPEMSLK.js.map +0 -1
- package/dist/chunk-VAS3LH5W.js.map +0 -1
- package/dist/chunk-WDBCXRTT.mjs +0 -6
- package/dist/chunk-XQYC4KMH.mjs.map +0 -1
- package/dist/chunk-Z6S4MWSR.js.map +0 -1
- package/dist/cli/api/uptrade.d.ts.map +0 -1
package/dist/cli/index.mjs
CHANGED
|
@@ -4,11 +4,11 @@ import { parse } from '../chunk-5YA6SI4Z.mjs';
|
|
|
4
4
|
import { buildOgHtml, TITLE_MAX_PX, OG_REPORT_ATTR } from '../chunk-UJ6CHZAI.mjs';
|
|
5
5
|
import { require_main } from '../chunk-NNZDWY3L.mjs';
|
|
6
6
|
import { findAppDirForDiscovery, discoverNextJsRoutes } from '../chunk-XIJ4F6IE.mjs';
|
|
7
|
-
import { SITE_KIT_VERSION } from '../chunk-
|
|
7
|
+
import { SITE_KIT_VERSION } from '../chunk-DQUBETXH.mjs';
|
|
8
8
|
import { __commonJS, __require, __toESM, __export, __privateAdd, __publicField, __privateGet, __privateMethod, __privateSet, __privateWrapper } from '../chunk-BEXTDHO4.mjs';
|
|
9
9
|
import { EventEmitter } from 'events';
|
|
10
10
|
import childProcess, { execFile as execFile$1, execSync, spawnSync, spawn } from 'child_process';
|
|
11
|
-
import
|
|
11
|
+
import path12, { win32, posix } from 'path';
|
|
12
12
|
import * as fs from 'fs';
|
|
13
13
|
import fs__default, { realpathSync, existsSync, readFileSync, readdirSync, statSync, readlinkSync, readdir as readdir$1, lstatSync, rmSync, mkdtempSync, writeFileSync } from 'fs';
|
|
14
14
|
import process2 from 'process';
|
|
@@ -6202,10 +6202,10 @@ var require_lib2 = __commonJS({
|
|
|
6202
6202
|
exports.analyse = analyse;
|
|
6203
6203
|
var detectFile = (filepath, opts = {}) => new Promise((resolve, reject) => {
|
|
6204
6204
|
let fd;
|
|
6205
|
-
const
|
|
6205
|
+
const fs29 = (0, node_1.default)();
|
|
6206
6206
|
const handler = (err, buffer) => {
|
|
6207
6207
|
if (fd) {
|
|
6208
|
-
|
|
6208
|
+
fs29.closeSync(fd);
|
|
6209
6209
|
}
|
|
6210
6210
|
if (err) {
|
|
6211
6211
|
reject(err);
|
|
@@ -6217,9 +6217,9 @@ var require_lib2 = __commonJS({
|
|
|
6217
6217
|
};
|
|
6218
6218
|
const sampleSize = (opts === null || opts === void 0 ? void 0 : opts.sampleSize) || 0;
|
|
6219
6219
|
if (sampleSize > 0) {
|
|
6220
|
-
fd =
|
|
6220
|
+
fd = fs29.openSync(filepath, "r");
|
|
6221
6221
|
let sample = Buffer.allocUnsafe(sampleSize);
|
|
6222
|
-
|
|
6222
|
+
fs29.read(fd, sample, 0, sampleSize, opts.offset, (err, bytesRead) => {
|
|
6223
6223
|
if (err) {
|
|
6224
6224
|
handler(err, null);
|
|
6225
6225
|
} else {
|
|
@@ -6231,22 +6231,22 @@ var require_lib2 = __commonJS({
|
|
|
6231
6231
|
});
|
|
6232
6232
|
return;
|
|
6233
6233
|
}
|
|
6234
|
-
|
|
6234
|
+
fs29.readFile(filepath, handler);
|
|
6235
6235
|
});
|
|
6236
6236
|
exports.detectFile = detectFile;
|
|
6237
6237
|
var detectFileSync = (filepath, opts = {}) => {
|
|
6238
|
-
const
|
|
6238
|
+
const fs29 = (0, node_1.default)();
|
|
6239
6239
|
if (opts && opts.sampleSize) {
|
|
6240
|
-
const fd =
|
|
6240
|
+
const fd = fs29.openSync(filepath, "r");
|
|
6241
6241
|
let sample = Buffer.allocUnsafe(opts.sampleSize);
|
|
6242
|
-
const bytesRead =
|
|
6242
|
+
const bytesRead = fs29.readSync(fd, sample, 0, opts.sampleSize, opts.offset);
|
|
6243
6243
|
if (bytesRead < opts.sampleSize) {
|
|
6244
6244
|
sample = sample.subarray(0, bytesRead);
|
|
6245
6245
|
}
|
|
6246
|
-
|
|
6246
|
+
fs29.closeSync(fd);
|
|
6247
6247
|
return (0, exports.detect)(sample);
|
|
6248
6248
|
}
|
|
6249
|
-
return (0, exports.detect)(
|
|
6249
|
+
return (0, exports.detect)(fs29.readFileSync(filepath));
|
|
6250
6250
|
};
|
|
6251
6251
|
exports.detectFileSync = detectFileSync;
|
|
6252
6252
|
exports.default = {
|
|
@@ -10135,7 +10135,7 @@ var require_run_async = __commonJS({
|
|
|
10135
10135
|
});
|
|
10136
10136
|
|
|
10137
10137
|
// src/cli/index.ts
|
|
10138
|
-
var
|
|
10138
|
+
var import_dotenv2 = __toESM(require_main());
|
|
10139
10139
|
|
|
10140
10140
|
// node_modules/.pnpm/commander@15.0.0/node_modules/commander/lib/error.js
|
|
10141
10141
|
var CommanderError = class extends Error {
|
|
@@ -12264,9 +12264,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
12264
12264
|
args = args.slice();
|
|
12265
12265
|
const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
|
|
12266
12266
|
function findFile(baseDir, baseName) {
|
|
12267
|
-
const localBin =
|
|
12267
|
+
const localBin = path12.resolve(baseDir, baseName);
|
|
12268
12268
|
if (fs__default.existsSync(localBin)) return localBin;
|
|
12269
|
-
if (sourceExt.includes(
|
|
12269
|
+
if (sourceExt.includes(path12.extname(baseName))) return void 0;
|
|
12270
12270
|
const foundExt = sourceExt.find(
|
|
12271
12271
|
(ext2) => fs__default.existsSync(`${localBin}${ext2}`)
|
|
12272
12272
|
);
|
|
@@ -12284,17 +12284,17 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
12284
12284
|
} catch {
|
|
12285
12285
|
resolvedScriptPath = this._scriptPath;
|
|
12286
12286
|
}
|
|
12287
|
-
executableDir =
|
|
12288
|
-
|
|
12287
|
+
executableDir = path12.resolve(
|
|
12288
|
+
path12.dirname(resolvedScriptPath),
|
|
12289
12289
|
executableDir
|
|
12290
12290
|
);
|
|
12291
12291
|
}
|
|
12292
12292
|
if (executableDir) {
|
|
12293
12293
|
let localFile = findFile(executableDir, executableFile);
|
|
12294
12294
|
if (!localFile && !subcommand._executableFile && this._scriptPath) {
|
|
12295
|
-
const legacyName =
|
|
12295
|
+
const legacyName = path12.basename(
|
|
12296
12296
|
this._scriptPath,
|
|
12297
|
-
|
|
12297
|
+
path12.extname(this._scriptPath)
|
|
12298
12298
|
);
|
|
12299
12299
|
if (legacyName !== this._name) {
|
|
12300
12300
|
localFile = findFile(
|
|
@@ -12305,7 +12305,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
12305
12305
|
}
|
|
12306
12306
|
executableFile = localFile || executableFile;
|
|
12307
12307
|
}
|
|
12308
|
-
const launchWithNode = sourceExt.includes(
|
|
12308
|
+
const launchWithNode = sourceExt.includes(path12.extname(executableFile));
|
|
12309
12309
|
let proc;
|
|
12310
12310
|
if (process2.platform !== "win32") {
|
|
12311
12311
|
if (launchWithNode) {
|
|
@@ -13222,7 +13222,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
13222
13222
|
* @return {Command}
|
|
13223
13223
|
*/
|
|
13224
13224
|
nameFromFilename(filename) {
|
|
13225
|
-
this._name =
|
|
13225
|
+
this._name = path12.basename(filename, path12.extname(filename));
|
|
13226
13226
|
return this;
|
|
13227
13227
|
}
|
|
13228
13228
|
/**
|
|
@@ -13236,9 +13236,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
13236
13236
|
* @param {string} [path]
|
|
13237
13237
|
* @return {(string|null|Command)}
|
|
13238
13238
|
*/
|
|
13239
|
-
executableDir(
|
|
13240
|
-
if (
|
|
13241
|
-
this._executableDir =
|
|
13239
|
+
executableDir(path29) {
|
|
13240
|
+
if (path29 === void 0) return this._executableDir;
|
|
13241
|
+
this._executableDir = path29;
|
|
13242
13242
|
return this;
|
|
13243
13243
|
}
|
|
13244
13244
|
/**
|
|
@@ -18747,7 +18747,7 @@ function createPrompt(view) {
|
|
|
18747
18747
|
if (nextView === void 0) {
|
|
18748
18748
|
let callerFilename = callSites[1]?.getFileName();
|
|
18749
18749
|
if (callerFilename && !callerFilename.startsWith("file://")) {
|
|
18750
|
-
callerFilename =
|
|
18750
|
+
callerFilename = path12.resolve(callerFilename);
|
|
18751
18751
|
}
|
|
18752
18752
|
throw new Error(`Prompt functions must return a string.
|
|
18753
18753
|
at ${callerFilename}`);
|
|
@@ -19136,13 +19136,13 @@ var ExternalEditor = class {
|
|
|
19136
19136
|
}
|
|
19137
19137
|
createTempFile() {
|
|
19138
19138
|
try {
|
|
19139
|
-
const baseDir =
|
|
19140
|
-
this.tempDir = mkdtempSync(
|
|
19139
|
+
const baseDir = path12.resolve(this.fileOptions.dir ?? os.tmpdir());
|
|
19140
|
+
this.tempDir = mkdtempSync(path12.join(baseDir, "inquirer-editor-"));
|
|
19141
19141
|
const id = randomUUID();
|
|
19142
19142
|
const prefix = sanitizeAffix(this.fileOptions.prefix);
|
|
19143
19143
|
const postfix = sanitizeAffix(this.fileOptions.postfix);
|
|
19144
19144
|
const filename = `${prefix}${id}${postfix}`;
|
|
19145
|
-
this.tempFile =
|
|
19145
|
+
this.tempFile = path12.join(this.tempDir, filename);
|
|
19146
19146
|
const opt = { encoding: "utf8", flag: "wx" };
|
|
19147
19147
|
if (Object.prototype.hasOwnProperty.call(this.fileOptions, "mode")) {
|
|
19148
19148
|
opt.mode = this.fileOptions.mode;
|
|
@@ -20345,9 +20345,9 @@ function observableToAsyncIterable(source) {
|
|
|
20345
20345
|
|
|
20346
20346
|
// node_modules/.pnpm/inquirer@14.0.2_@types+node@26.2.0/node_modules/inquirer/dist/ui/prompt.js
|
|
20347
20347
|
var _ = {
|
|
20348
|
-
set: (obj,
|
|
20348
|
+
set: (obj, path29 = "", value) => {
|
|
20349
20349
|
let pointer = obj;
|
|
20350
|
-
|
|
20350
|
+
path29.split(".").forEach((key, index, arr) => {
|
|
20351
20351
|
if (key === "__proto__" || key === "constructor")
|
|
20352
20352
|
return;
|
|
20353
20353
|
if (index === arr.length - 1) {
|
|
@@ -20358,8 +20358,8 @@ var _ = {
|
|
|
20358
20358
|
pointer = pointer[key];
|
|
20359
20359
|
});
|
|
20360
20360
|
},
|
|
20361
|
-
get: (obj,
|
|
20362
|
-
const travel = (regexp) => String.prototype.split.call(
|
|
20361
|
+
get: (obj, path29 = "", defaultValue) => {
|
|
20362
|
+
const travel = (regexp) => String.prototype.split.call(path29, regexp).filter(Boolean).reduce(
|
|
20363
20363
|
// @ts-expect-error implicit any on res[key]
|
|
20364
20364
|
(res, key) => res == null ? res : res[key],
|
|
20365
20365
|
obj
|
|
@@ -20649,7 +20649,7 @@ async function scanCodebase(rootDir) {
|
|
|
20649
20649
|
for (const file of files) {
|
|
20650
20650
|
try {
|
|
20651
20651
|
const content = await fs3.readFile(file, "utf-8");
|
|
20652
|
-
const relPath =
|
|
20652
|
+
const relPath = path12.relative(rootDir, file);
|
|
20653
20653
|
const ast = parse(content, {
|
|
20654
20654
|
sourceType: "module",
|
|
20655
20655
|
plugins: ["jsx", "typescript"]
|
|
@@ -20698,7 +20698,7 @@ async function scanCodebase(rootDir) {
|
|
|
20698
20698
|
async function findSourceFiles(dir, files = []) {
|
|
20699
20699
|
const entries = await fs3.readdir(dir, { withFileTypes: true });
|
|
20700
20700
|
for (const entry of entries) {
|
|
20701
|
-
const fullPath =
|
|
20701
|
+
const fullPath = path12.join(dir, entry.name);
|
|
20702
20702
|
if (entry.isDirectory()) {
|
|
20703
20703
|
if (["node_modules", ".next", ".git", "dist", "build"].includes(entry.name)) {
|
|
20704
20704
|
continue;
|
|
@@ -20716,18 +20716,18 @@ function scanForForms(ast, content, filePath) {
|
|
|
20716
20716
|
const forms = [];
|
|
20717
20717
|
content.split("\n");
|
|
20718
20718
|
traverse(ast, {
|
|
20719
|
-
JSXElement(
|
|
20720
|
-
const opening =
|
|
20719
|
+
JSXElement(path29) {
|
|
20720
|
+
const opening = path29.node.openingElement;
|
|
20721
20721
|
if (isJSXIdentifier(opening.name) && opening.name.name === "form") {
|
|
20722
|
-
const fields = extractFieldsFromForm(
|
|
20722
|
+
const fields = extractFieldsFromForm(path29);
|
|
20723
20723
|
const hasOnSubmit = opening.attributes.some(
|
|
20724
20724
|
(attr) => isJSXAttribute(attr) && isJSXIdentifier(attr.name) && attr.name.name === "onSubmit"
|
|
20725
20725
|
);
|
|
20726
20726
|
if (hasOnSubmit && fields.length > 0) {
|
|
20727
|
-
const startLine =
|
|
20728
|
-
const endLine =
|
|
20727
|
+
const startLine = path29.node.loc?.start.line || 0;
|
|
20728
|
+
const endLine = path29.node.loc?.end.line || 0;
|
|
20729
20729
|
let componentName = "UnknownForm";
|
|
20730
|
-
let current =
|
|
20730
|
+
let current = path29.parentPath;
|
|
20731
20731
|
while (current) {
|
|
20732
20732
|
if (isFunctionDeclaration(current.node) && current.node.id) {
|
|
20733
20733
|
componentName = current.node.id.name;
|
|
@@ -20760,7 +20760,7 @@ function scanForForms(ast, content, filePath) {
|
|
|
20760
20760
|
}
|
|
20761
20761
|
if (isJSXIdentifier(opening.name) && opening.name.name === "Form") {
|
|
20762
20762
|
if (content.includes("Formik") || content.includes("formik")) {
|
|
20763
|
-
const fields = extractFieldsFromFormik(
|
|
20763
|
+
const fields = extractFieldsFromFormik(path29);
|
|
20764
20764
|
if (fields.length > 0) {
|
|
20765
20765
|
forms.push({
|
|
20766
20766
|
filePath,
|
|
@@ -20771,8 +20771,8 @@ function scanForForms(ast, content, filePath) {
|
|
|
20771
20771
|
submitsTo: null,
|
|
20772
20772
|
complexity: "moderate",
|
|
20773
20773
|
suggestedAction: "assisted",
|
|
20774
|
-
startLine:
|
|
20775
|
-
endLine:
|
|
20774
|
+
startLine: path29.node.loc?.start.line || 0,
|
|
20775
|
+
endLine: path29.node.loc?.end.line || 0
|
|
20776
20776
|
});
|
|
20777
20777
|
}
|
|
20778
20778
|
}
|
|
@@ -20790,8 +20790,8 @@ function extractFieldsFromForm(formPath) {
|
|
|
20790
20790
|
const radioGroups = /* @__PURE__ */ new Map();
|
|
20791
20791
|
const checkboxGroups = /* @__PURE__ */ new Map();
|
|
20792
20792
|
formPath.traverse({
|
|
20793
|
-
JSXElement(
|
|
20794
|
-
const opening =
|
|
20793
|
+
JSXElement(path29) {
|
|
20794
|
+
const opening = path29.node.openingElement;
|
|
20795
20795
|
const tagName = isJSXIdentifier(opening.name) ? opening.name.name : null;
|
|
20796
20796
|
if (["input", "textarea", "select"].includes(tagName || "")) {
|
|
20797
20797
|
const attrs = opening.attributes;
|
|
@@ -20838,7 +20838,7 @@ function extractFieldsFromForm(formPath) {
|
|
|
20838
20838
|
}
|
|
20839
20839
|
if (tagName === "select") {
|
|
20840
20840
|
const selectOptions = [];
|
|
20841
|
-
|
|
20841
|
+
path29.traverse({
|
|
20842
20842
|
JSXElement(optionPath) {
|
|
20843
20843
|
const optOpening = optionPath.node.openingElement;
|
|
20844
20844
|
const optTagName = isJSXIdentifier(optOpening.name) ? optOpening.name.name : null;
|
|
@@ -20913,8 +20913,8 @@ function extractFieldsFromForm(formPath) {
|
|
|
20913
20913
|
function extractFieldsFromFormik(formPath, content) {
|
|
20914
20914
|
const fields = [];
|
|
20915
20915
|
formPath.traverse({
|
|
20916
|
-
JSXElement(
|
|
20917
|
-
const opening =
|
|
20916
|
+
JSXElement(path29) {
|
|
20917
|
+
const opening = path29.node.openingElement;
|
|
20918
20918
|
const tagName = isJSXIdentifier(opening.name) ? opening.name.name : null;
|
|
20919
20919
|
if (tagName === "Field" || tagName === "FastField") {
|
|
20920
20920
|
const attrs = opening.attributes;
|
|
@@ -21033,11 +21033,11 @@ function scanForMetadata(ast, content, filePath) {
|
|
|
21033
21033
|
}
|
|
21034
21034
|
let hasHeadComponent = false;
|
|
21035
21035
|
traverse(ast, {
|
|
21036
|
-
JSXElement(
|
|
21037
|
-
const opening =
|
|
21036
|
+
JSXElement(path29) {
|
|
21037
|
+
const opening = path29.node.openingElement;
|
|
21038
21038
|
if (isJSXIdentifier(opening.name) && opening.name.name === "Head") {
|
|
21039
21039
|
hasHeadComponent = true;
|
|
21040
|
-
|
|
21040
|
+
path29.stop();
|
|
21041
21041
|
}
|
|
21042
21042
|
}
|
|
21043
21043
|
});
|
|
@@ -21072,8 +21072,8 @@ function scanForWidgets(ast, content, filePath) {
|
|
|
21072
21072
|
for (const { pattern, type } of widgetPatterns) {
|
|
21073
21073
|
if (pattern.test(content)) {
|
|
21074
21074
|
traverse(ast, {
|
|
21075
|
-
JSXElement(
|
|
21076
|
-
const opening =
|
|
21075
|
+
JSXElement(path29) {
|
|
21076
|
+
const opening = path29.node.openingElement;
|
|
21077
21077
|
if (isJSXIdentifier(opening.name) && (opening.name.name === "script" || opening.name.name === "Script")) {
|
|
21078
21078
|
const srcAttr = opening.attributes.find(
|
|
21079
21079
|
(attr) => isJSXAttribute(attr) && isJSXIdentifier(attr.name) && attr.name.name === "src"
|
|
@@ -21088,8 +21088,8 @@ function scanForWidgets(ast, content, filePath) {
|
|
|
21088
21088
|
filePath,
|
|
21089
21089
|
widgetType: type,
|
|
21090
21090
|
scriptTag: src,
|
|
21091
|
-
startLine:
|
|
21092
|
-
endLine:
|
|
21091
|
+
startLine: path29.node.loc?.start.line || 0,
|
|
21092
|
+
endLine: path29.node.loc?.end.line || 0
|
|
21093
21093
|
});
|
|
21094
21094
|
}
|
|
21095
21095
|
}
|
|
@@ -21163,7 +21163,7 @@ async function scanForSitemapFiles(rootDir) {
|
|
|
21163
21163
|
"next-sitemap.config.ts"
|
|
21164
21164
|
];
|
|
21165
21165
|
for (const configPath of configPaths) {
|
|
21166
|
-
const fullPath =
|
|
21166
|
+
const fullPath = path12.join(rootDir, configPath);
|
|
21167
21167
|
try {
|
|
21168
21168
|
await fs3.access(fullPath);
|
|
21169
21169
|
const content = await fs3.readFile(fullPath, "utf-8");
|
|
@@ -21181,7 +21181,7 @@ async function scanForSitemapFiles(rootDir) {
|
|
|
21181
21181
|
} catch {
|
|
21182
21182
|
}
|
|
21183
21183
|
}
|
|
21184
|
-
const staticSitemapPath =
|
|
21184
|
+
const staticSitemapPath = path12.join(rootDir, "public", "sitemap.xml");
|
|
21185
21185
|
try {
|
|
21186
21186
|
await fs3.access(staticSitemapPath);
|
|
21187
21187
|
const content = await fs3.readFile(staticSitemapPath, "utf-8");
|
|
@@ -21204,7 +21204,7 @@ async function scanForSitemapFiles(rootDir) {
|
|
|
21204
21204
|
"out/sitemap.xml"
|
|
21205
21205
|
];
|
|
21206
21206
|
for (const genPath of generatedPaths) {
|
|
21207
|
-
const fullPath =
|
|
21207
|
+
const fullPath = path12.join(rootDir, genPath);
|
|
21208
21208
|
try {
|
|
21209
21209
|
await fs3.access(fullPath);
|
|
21210
21210
|
} catch {
|
|
@@ -21228,8 +21228,8 @@ function scanForSchemas(ast, content, filePath) {
|
|
|
21228
21228
|
return schemas;
|
|
21229
21229
|
}
|
|
21230
21230
|
traverse(ast, {
|
|
21231
|
-
JSXElement(
|
|
21232
|
-
const opening =
|
|
21231
|
+
JSXElement(path29) {
|
|
21232
|
+
const opening = path29.node.openingElement;
|
|
21233
21233
|
if (isJSXIdentifier(opening.name) && (opening.name.name === "script" || opening.name.name === "Script")) {
|
|
21234
21234
|
const typeAttr = opening.attributes.find(
|
|
21235
21235
|
(attr) => isJSXAttribute(attr) && isJSXIdentifier(attr.name) && attr.name.name === "type"
|
|
@@ -21256,8 +21256,8 @@ function scanForSchemas(ast, content, filePath) {
|
|
|
21256
21256
|
filePath,
|
|
21257
21257
|
type: detectedType,
|
|
21258
21258
|
schemaType,
|
|
21259
|
-
startLine:
|
|
21260
|
-
endLine:
|
|
21259
|
+
startLine: path29.node.loc?.start.line || 0,
|
|
21260
|
+
endLine: path29.node.loc?.end.line || 0
|
|
21261
21261
|
});
|
|
21262
21262
|
}
|
|
21263
21263
|
}
|
|
@@ -21290,8 +21290,8 @@ function scanForFAQs(ast, content, filePath) {
|
|
|
21290
21290
|
/questions?\s*(?:and|&)?\s*answers?/i
|
|
21291
21291
|
];
|
|
21292
21292
|
traverse(ast, {
|
|
21293
|
-
JSXElement(
|
|
21294
|
-
const opening =
|
|
21293
|
+
JSXElement(path29) {
|
|
21294
|
+
const opening = path29.node.openingElement;
|
|
21295
21295
|
let tagName = "";
|
|
21296
21296
|
if (isJSXIdentifier(opening.name)) {
|
|
21297
21297
|
tagName = opening.name.name;
|
|
@@ -21304,8 +21304,8 @@ function scanForFAQs(ast, content, filePath) {
|
|
|
21304
21304
|
faqs.push({
|
|
21305
21305
|
filePath,
|
|
21306
21306
|
type: "details-summary",
|
|
21307
|
-
startLine:
|
|
21308
|
-
endLine:
|
|
21307
|
+
startLine: path29.node.loc?.start.line || 0,
|
|
21308
|
+
endLine: path29.node.loc?.end.line || 0,
|
|
21309
21309
|
hasSchema: content.includes("FAQPage") || content.includes("application/ld+json")
|
|
21310
21310
|
});
|
|
21311
21311
|
return;
|
|
@@ -21313,7 +21313,7 @@ function scanForFAQs(ast, content, filePath) {
|
|
|
21313
21313
|
for (const pattern of faqPatterns) {
|
|
21314
21314
|
if (pattern.test(tagName)) {
|
|
21315
21315
|
let itemCount = 0;
|
|
21316
|
-
|
|
21316
|
+
path29.traverse({
|
|
21317
21317
|
JSXElement(itemPath) {
|
|
21318
21318
|
const itemOpening = itemPath.node.openingElement;
|
|
21319
21319
|
if (isJSXIdentifier(itemOpening.name)) {
|
|
@@ -21329,8 +21329,8 @@ function scanForFAQs(ast, content, filePath) {
|
|
|
21329
21329
|
type: "accordion",
|
|
21330
21330
|
componentName: tagName,
|
|
21331
21331
|
itemCount: itemCount || void 0,
|
|
21332
|
-
startLine:
|
|
21333
|
-
endLine:
|
|
21332
|
+
startLine: path29.node.loc?.start.line || 0,
|
|
21333
|
+
endLine: path29.node.loc?.end.line || 0,
|
|
21334
21334
|
hasSchema: content.includes("FAQPage") || content.includes("application/ld+json")
|
|
21335
21335
|
});
|
|
21336
21336
|
return;
|
|
@@ -21453,8 +21453,8 @@ function scanForImages(ast, content, filePath) {
|
|
|
21453
21453
|
return images;
|
|
21454
21454
|
}
|
|
21455
21455
|
traverse(ast, {
|
|
21456
|
-
JSXElement(
|
|
21457
|
-
const opening =
|
|
21456
|
+
JSXElement(path29) {
|
|
21457
|
+
const opening = path29.node.openingElement;
|
|
21458
21458
|
if (!isJSXIdentifier(opening.name)) return;
|
|
21459
21459
|
const tagName = opening.name.name;
|
|
21460
21460
|
if (tagName === "img" || tagName === "Image") {
|
|
@@ -21482,8 +21482,8 @@ function scanForImages(ast, content, filePath) {
|
|
|
21482
21482
|
src: src || void 0,
|
|
21483
21483
|
alt: alt || void 0,
|
|
21484
21484
|
isLocal,
|
|
21485
|
-
startLine:
|
|
21486
|
-
endLine:
|
|
21485
|
+
startLine: path29.node.loc?.start.line || 0,
|
|
21486
|
+
endLine: path29.node.loc?.end.line || 0
|
|
21487
21487
|
});
|
|
21488
21488
|
}
|
|
21489
21489
|
}
|
|
@@ -21688,7 +21688,7 @@ async function migrateFiles(scanResults, options) {
|
|
|
21688
21688
|
}
|
|
21689
21689
|
async function migrateForm(form, options) {
|
|
21690
21690
|
const changes = [];
|
|
21691
|
-
const fullPath =
|
|
21691
|
+
const fullPath = path12.resolve(process.cwd(), form.filePath);
|
|
21692
21692
|
const formSlug = generateSlug(form.componentName);
|
|
21693
21693
|
let formId;
|
|
21694
21694
|
if (!options.dryRun) {
|
|
@@ -21827,7 +21827,7 @@ export default ${componentName}
|
|
|
21827
21827
|
`;
|
|
21828
21828
|
}
|
|
21829
21829
|
async function createFormInUptrade(form, slug, options) {
|
|
21830
|
-
const response = await fetch("https://api.sonor.io/forms
|
|
21830
|
+
const response = await fetch(`${options.apiUrl || "https://api.sonor.io"}/forms`, {
|
|
21831
21831
|
method: "POST",
|
|
21832
21832
|
headers: {
|
|
21833
21833
|
"Content-Type": "application/json",
|
|
@@ -21865,7 +21865,7 @@ async function migrateWidget(filePath, widget, options) {
|
|
|
21865
21865
|
changes.push("[DRY RUN] Sonor Engage chat would come from SiteKitLayout (engage is on by default)");
|
|
21866
21866
|
return { filePath, success: true, changes };
|
|
21867
21867
|
}
|
|
21868
|
-
const fullPath =
|
|
21868
|
+
const fullPath = path12.resolve(process.cwd(), filePath);
|
|
21869
21869
|
let content = await fs3.readFile(fullPath, "utf-8");
|
|
21870
21870
|
switch (widget.widgetType) {
|
|
21871
21871
|
case "intercom":
|
|
@@ -21902,15 +21902,15 @@ function matchBalancedBraces(content, startIndex) {
|
|
|
21902
21902
|
}
|
|
21903
21903
|
async function migrateMetadata(filePath, metadata, options) {
|
|
21904
21904
|
const changes = [];
|
|
21905
|
-
const fullPath =
|
|
21905
|
+
const fullPath = path12.resolve(process.cwd(), filePath);
|
|
21906
21906
|
let pagePath = filePath.replace(/^app\//, "/").replace(/^src\/app\//, "/").replace(/\/page\.(tsx?|jsx?)$/, "").replace(/\/layout\.(tsx?|jsx?)$/, "").replace(/\[([^\]]+)\]/g, ":$1");
|
|
21907
21907
|
if (pagePath === "") pagePath = "/";
|
|
21908
21908
|
let content = await fs3.readFile(fullPath, "utf-8");
|
|
21909
21909
|
const isTypeScript = filePath.endsWith(".tsx") || filePath.endsWith(".ts");
|
|
21910
21910
|
const ext2 = isTypeScript ? ".tsx" : ".jsx";
|
|
21911
21911
|
if (isClientComponent(content)) {
|
|
21912
|
-
const dir =
|
|
21913
|
-
const layoutPath =
|
|
21912
|
+
const dir = path12.dirname(fullPath);
|
|
21913
|
+
const layoutPath = path12.join(dir, `layout${ext2}`);
|
|
21914
21914
|
try {
|
|
21915
21915
|
await fs3.access(layoutPath);
|
|
21916
21916
|
const layoutContent = await fs3.readFile(layoutPath, "utf-8");
|
|
@@ -21933,7 +21933,7 @@ async function migrateMetadata(filePath, metadata, options) {
|
|
|
21933
21933
|
} catch (error2) {
|
|
21934
21934
|
changes.push(`Page metadata may already exist: ${pagePath}`);
|
|
21935
21935
|
}
|
|
21936
|
-
const dirName =
|
|
21936
|
+
const dirName = path12.basename(dir).replace(/^\[\.\.\.([^\]]+)\]$/, "$1").replace(/^\[([^\]]+)\]$/, "$1");
|
|
21937
21937
|
const layoutName = dirName.split("-").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join("") + "Layout";
|
|
21938
21938
|
const layoutCode = `import { getManagedMetadata, ManagedSchema } from '@sonordev/site-kit/seo'
|
|
21939
21939
|
|
|
@@ -22042,7 +22042,7 @@ export async function generateMetadata() {
|
|
|
22042
22042
|
return { filePath, success: true, changes };
|
|
22043
22043
|
}
|
|
22044
22044
|
async function createPageMetadata(pagePath, metadata, options) {
|
|
22045
|
-
const response = await fetch("https://api.sonor.io/seo/pages
|
|
22045
|
+
const response = await fetch(`${options.apiUrl || "https://api.sonor.io"}/seo/pages`, {
|
|
22046
22046
|
method: "POST",
|
|
22047
22047
|
headers: {
|
|
22048
22048
|
"Content-Type": "application/json",
|
|
@@ -22127,7 +22127,7 @@ async function createSchemaRecord(pagePath, schemaType, schemaJson, options) {
|
|
|
22127
22127
|
}
|
|
22128
22128
|
async function migrateSchema(filePath, schema, options) {
|
|
22129
22129
|
const changes = [];
|
|
22130
|
-
const fullPath =
|
|
22130
|
+
const fullPath = path12.resolve(process.cwd(), filePath);
|
|
22131
22131
|
let pagePath = filePath.replace(/^app\//, "/").replace(/^src\/app\//, "/").replace(/\/page\.(tsx?|jsx?)$/, "").replace(/\[([^\]]+)\]/g, ":$1");
|
|
22132
22132
|
if (pagePath === "") pagePath = "/";
|
|
22133
22133
|
let content = await fs3.readFile(fullPath, "utf-8");
|
|
@@ -22238,7 +22238,7 @@ async function createFAQRecord(pagePath, items, options) {
|
|
|
22238
22238
|
}
|
|
22239
22239
|
async function migrateFAQ(filePath, faq, options) {
|
|
22240
22240
|
const changes = [];
|
|
22241
|
-
const fullPath =
|
|
22241
|
+
const fullPath = path12.resolve(process.cwd(), filePath);
|
|
22242
22242
|
let pagePath = filePath.replace(/^app\//, "/").replace(/^src\/app\//, "/").replace(/\/page\.(tsx?|jsx?)$/, "").replace(/\[([^\]]+)\]/g, ":$1");
|
|
22243
22243
|
if (pagePath === "") pagePath = "/";
|
|
22244
22244
|
let content = await fs3.readFile(fullPath, "utf-8");
|
|
@@ -22306,7 +22306,7 @@ async function migrateFAQ(filePath, faq, options) {
|
|
|
22306
22306
|
}
|
|
22307
22307
|
async function migrateSitemap(filePath, sitemap, options) {
|
|
22308
22308
|
const changes = [];
|
|
22309
|
-
const fullPath =
|
|
22309
|
+
const fullPath = path12.resolve(process.cwd(), filePath);
|
|
22310
22310
|
if (options.dryRun) {
|
|
22311
22311
|
changes.push(`[DRY RUN] Would migrate ${sitemap.type} to Site-Kit sitemap`);
|
|
22312
22312
|
if (sitemap.type === "next-sitemap-config") {
|
|
@@ -22348,8 +22348,8 @@ async function migrateAnalytics(filePath, analytics, options) {
|
|
|
22348
22348
|
return { filePath, success: true, changes };
|
|
22349
22349
|
}
|
|
22350
22350
|
async function migrateFile(filePath, options) {
|
|
22351
|
-
const fullPath =
|
|
22352
|
-
const relPath =
|
|
22351
|
+
const fullPath = path12.resolve(filePath);
|
|
22352
|
+
const relPath = path12.relative(process.cwd(), fullPath);
|
|
22353
22353
|
const content = await fs3.readFile(fullPath, "utf-8");
|
|
22354
22354
|
const hasFormTag = content.includes("<form") || content.includes("onSubmit");
|
|
22355
22355
|
const hasWidget = /intercom|crisp|drift|hubspot|zendesk/i.test(content);
|
|
@@ -22366,26 +22366,26 @@ async function migrateFile(filePath, options) {
|
|
|
22366
22366
|
return migrateWidget(relPath, {
|
|
22367
22367
|
widgetType}, options);
|
|
22368
22368
|
}
|
|
22369
|
-
const { parse:
|
|
22370
|
-
const ast =
|
|
22369
|
+
const { parse: parse3 } = await import('../lib-R7IQ4ZHE.mjs');
|
|
22370
|
+
const ast = parse3(content, {
|
|
22371
22371
|
sourceType: "module",
|
|
22372
22372
|
plugins: ["jsx", "typescript"]
|
|
22373
22373
|
});
|
|
22374
22374
|
let componentName = "Form";
|
|
22375
22375
|
const traverse2 = (await import('../lib-RSDMEKDQ.mjs')).default;
|
|
22376
22376
|
traverse2(ast, {
|
|
22377
|
-
ExportNamedDeclaration(
|
|
22378
|
-
const decl =
|
|
22377
|
+
ExportNamedDeclaration(path29) {
|
|
22378
|
+
const decl = path29.node.declaration;
|
|
22379
22379
|
if (decl && decl.type === "FunctionDeclaration" && decl.id) {
|
|
22380
22380
|
componentName = decl.id.name;
|
|
22381
|
-
|
|
22381
|
+
path29.stop();
|
|
22382
22382
|
}
|
|
22383
22383
|
},
|
|
22384
|
-
ExportDefaultDeclaration(
|
|
22385
|
-
const decl =
|
|
22384
|
+
ExportDefaultDeclaration(path29) {
|
|
22385
|
+
const decl = path29.node.declaration;
|
|
22386
22386
|
if (decl && decl.type === "FunctionDeclaration" && decl.id) {
|
|
22387
22387
|
componentName = decl.id.name;
|
|
22388
|
-
|
|
22388
|
+
path29.stop();
|
|
22389
22389
|
}
|
|
22390
22390
|
}
|
|
22391
22391
|
});
|
|
@@ -22442,7 +22442,7 @@ function detectFormType(form) {
|
|
|
22442
22442
|
return "contact";
|
|
22443
22443
|
}
|
|
22444
22444
|
async function generateEnvFile(options) {
|
|
22445
|
-
const envPath =
|
|
22445
|
+
const envPath = path12.join(process.cwd(), ".env.local");
|
|
22446
22446
|
let existingContent = "";
|
|
22447
22447
|
try {
|
|
22448
22448
|
existingContent = await fs3.readFile(envPath, "utf-8");
|
|
@@ -22542,7 +22542,7 @@ async function findLayoutFile() {
|
|
|
22542
22542
|
"app/layout.jsx"
|
|
22543
22543
|
];
|
|
22544
22544
|
for (const relativePath of possiblePaths) {
|
|
22545
|
-
const fullPath =
|
|
22545
|
+
const fullPath = path12.join(process.cwd(), relativePath);
|
|
22546
22546
|
try {
|
|
22547
22547
|
await fs3.access(fullPath);
|
|
22548
22548
|
return fullPath;
|
|
@@ -22712,15 +22712,15 @@ var wslDefaultBrowser = async () => {
|
|
|
22712
22712
|
const { stdout } = await executePowerShell(command, { powerShellPath: psPath });
|
|
22713
22713
|
return stdout.trim();
|
|
22714
22714
|
};
|
|
22715
|
-
var convertWslPathToWindows = async (
|
|
22716
|
-
if (/^[a-z]+:\/\//i.test(
|
|
22717
|
-
return
|
|
22715
|
+
var convertWslPathToWindows = async (path29) => {
|
|
22716
|
+
if (/^[a-z]+:\/\//i.test(path29)) {
|
|
22717
|
+
return path29;
|
|
22718
22718
|
}
|
|
22719
22719
|
try {
|
|
22720
|
-
const { stdout } = await execFile2("wslpath", ["-aw",
|
|
22720
|
+
const { stdout } = await execFile2("wslpath", ["-aw", path29], { encoding: "utf8" });
|
|
22721
22721
|
return stdout.trim();
|
|
22722
22722
|
} catch {
|
|
22723
|
-
return
|
|
22723
|
+
return path29;
|
|
22724
22724
|
}
|
|
22725
22725
|
};
|
|
22726
22726
|
|
|
@@ -22840,8 +22840,8 @@ var is_in_ssh_default = isInSsh;
|
|
|
22840
22840
|
|
|
22841
22841
|
// node_modules/.pnpm/open@11.0.0/node_modules/open/index.js
|
|
22842
22842
|
var fallbackAttemptSymbol = /* @__PURE__ */ Symbol("fallbackAttempt");
|
|
22843
|
-
var __dirname2 = import.meta.url ?
|
|
22844
|
-
var localXdgOpenPath =
|
|
22843
|
+
var __dirname2 = import.meta.url ? path12.dirname(fileURLToPath(import.meta.url)) : "";
|
|
22844
|
+
var localXdgOpenPath = path12.join(__dirname2, "xdg-open");
|
|
22845
22845
|
var { platform, arch } = process2;
|
|
22846
22846
|
var tryEachApp = async (apps2, opener) => {
|
|
22847
22847
|
if (apps2.length === 0) {
|
|
@@ -23119,8 +23119,37 @@ defineLazyProperty(apps, "safari", () => detectPlatformBinary({
|
|
|
23119
23119
|
darwin: "Safari"
|
|
23120
23120
|
}));
|
|
23121
23121
|
var open_default = open;
|
|
23122
|
+
var SONOR_STATE_DIR = ".sonor";
|
|
23123
|
+
var IMAGE_MANIFEST = ".sonor-images.json";
|
|
23124
|
+
var LEGACY_IMAGE_MANIFEST = ".uptrade-images.json";
|
|
23125
|
+
var LEGACY_STATE_DIR = ".uptrade";
|
|
23126
|
+
function resolveStateReadPath(relativePath, root = process.cwd()) {
|
|
23127
|
+
return preferCurrent(path12.join(root, SONOR_STATE_DIR, relativePath), path12.join(root, LEGACY_STATE_DIR, relativePath));
|
|
23128
|
+
}
|
|
23129
|
+
function resolveImageManifestReadPath(root) {
|
|
23130
|
+
return preferCurrent(path12.join(root, IMAGE_MANIFEST), path12.join(root, LEGACY_IMAGE_MANIFEST));
|
|
23131
|
+
}
|
|
23132
|
+
function preferCurrent(current, legacy) {
|
|
23133
|
+
return existsSync(current) || !existsSync(legacy) ? current : legacy;
|
|
23134
|
+
}
|
|
23135
|
+
async function listLocalTemplates(root = process.cwd()) {
|
|
23136
|
+
const names = /* @__PURE__ */ new Set();
|
|
23137
|
+
for (const dir of [SONOR_STATE_DIR, LEGACY_STATE_DIR]) {
|
|
23138
|
+
try {
|
|
23139
|
+
const files = await fs3.readdir(path12.join(root, dir, "templates"));
|
|
23140
|
+
for (const file of files) if (file.endsWith(".json")) names.add(file);
|
|
23141
|
+
} catch (error2) {
|
|
23142
|
+
if (error2.code !== "ENOENT") throw error2;
|
|
23143
|
+
}
|
|
23144
|
+
}
|
|
23145
|
+
return [...names].sort();
|
|
23146
|
+
}
|
|
23147
|
+
|
|
23148
|
+
// src/cli/api/sonor.ts
|
|
23122
23149
|
var PORTAL_URL = "https://app.sonor.io";
|
|
23123
|
-
|
|
23150
|
+
function getSonorApiUrl() {
|
|
23151
|
+
return (process.env.SONOR_API_URL || "https://api.sonor.io").replace(/\/+$/, "");
|
|
23152
|
+
}
|
|
23124
23153
|
async function authenticateWithSonor() {
|
|
23125
23154
|
return new Promise((resolve, reject) => {
|
|
23126
23155
|
const server = http.createServer(async (req, res) => {
|
|
@@ -23147,7 +23176,7 @@ async function authenticateWithSonor() {
|
|
|
23147
23176
|
server.close();
|
|
23148
23177
|
return;
|
|
23149
23178
|
}
|
|
23150
|
-
const tokenResponse = await fetch(`${
|
|
23179
|
+
const tokenResponse = await fetch(`${getSonorApiUrl()}/auth/cli-token`, {
|
|
23151
23180
|
method: "POST",
|
|
23152
23181
|
headers: { "Content-Type": "application/json" },
|
|
23153
23182
|
body: JSON.stringify({ code, redirect_uri: `http://localhost:${port}/callback` })
|
|
@@ -23193,32 +23222,41 @@ async function authenticateWithSonor() {
|
|
|
23193
23222
|
}, 5 * 60 * 1e3);
|
|
23194
23223
|
});
|
|
23195
23224
|
}
|
|
23196
|
-
async function authenticateWithApiKey(apiKey) {
|
|
23197
|
-
|
|
23198
|
-
|
|
23199
|
-
|
|
23200
|
-
|
|
23201
|
-
|
|
23202
|
-
|
|
23203
|
-
|
|
23204
|
-
|
|
23205
|
-
|
|
23206
|
-
|
|
23207
|
-
|
|
23208
|
-
projectName: data.project?.name,
|
|
23209
|
-
orgId: data.organization?.id,
|
|
23210
|
-
orgName: data.organization?.name,
|
|
23211
|
-
isApiKey: true
|
|
23212
|
-
};
|
|
23213
|
-
}
|
|
23225
|
+
async function authenticateWithApiKey(apiKey, apiUrl = getSonorApiUrl()) {
|
|
23226
|
+
let response;
|
|
23227
|
+
try {
|
|
23228
|
+
response = await fetch(`${apiUrl}/api/public/seo/verify-api-key`, {
|
|
23229
|
+
headers: { "X-API-Key": apiKey },
|
|
23230
|
+
signal: AbortSignal.timeout(15e3)
|
|
23231
|
+
});
|
|
23232
|
+
} catch {
|
|
23233
|
+
throw new NetworkError("PROJECT_LOOKUP_FAILED", "Could not reach the Sonor API to resolve the project. Check SONOR_API_URL and your connection.");
|
|
23234
|
+
}
|
|
23235
|
+
if (!response.ok) {
|
|
23236
|
+
throw new NetworkError("PROJECT_LOOKUP_FAILED", `Sonor API verification failed (HTTP ${response.status}). Check SONOR_API_KEY and SONOR_API_URL.`);
|
|
23214
23237
|
}
|
|
23215
|
-
|
|
23216
|
-
|
|
23238
|
+
let data;
|
|
23239
|
+
try {
|
|
23240
|
+
data = await response.json();
|
|
23241
|
+
} catch {
|
|
23242
|
+
throw new NetworkError("INVALID_PROJECT_RESPONSE", "Sonor API returned an invalid project response.");
|
|
23243
|
+
}
|
|
23244
|
+
if (data?.valid !== true || typeof data.project?.id !== "string" || !/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(data.project.id)) {
|
|
23245
|
+
throw new NetworkError("INVALID_PROJECT_RESPONSE", "Sonor API did not return a valid full project UUID. Check SONOR_API_KEY.");
|
|
23217
23246
|
}
|
|
23218
|
-
|
|
23247
|
+
return {
|
|
23248
|
+
accessToken: apiKey,
|
|
23249
|
+
userId: "api-key-user",
|
|
23250
|
+
email: data.project.name ? `Project: ${data.project.name}` : "API Key verified",
|
|
23251
|
+
projectId: data.project.id,
|
|
23252
|
+
projectName: data.project.name,
|
|
23253
|
+
orgId: data.organization?.id,
|
|
23254
|
+
orgName: data.organization?.name,
|
|
23255
|
+
isApiKey: true
|
|
23256
|
+
};
|
|
23219
23257
|
}
|
|
23220
23258
|
async function fetchOrganizations(accessToken) {
|
|
23221
|
-
const response = await fetch(`${
|
|
23259
|
+
const response = await fetch(`${getSonorApiUrl()}/organizations`, {
|
|
23222
23260
|
headers: { "Authorization": `Bearer ${accessToken}` }
|
|
23223
23261
|
});
|
|
23224
23262
|
if (!response.ok) {
|
|
@@ -23227,7 +23265,7 @@ async function fetchOrganizations(accessToken) {
|
|
|
23227
23265
|
return response.json();
|
|
23228
23266
|
}
|
|
23229
23267
|
async function fetchProjects(accessToken, orgId) {
|
|
23230
|
-
const response = await fetch(`${
|
|
23268
|
+
const response = await fetch(`${getSonorApiUrl()}/organizations/${orgId}/projects`, {
|
|
23231
23269
|
headers: { "Authorization": `Bearer ${accessToken}` }
|
|
23232
23270
|
});
|
|
23233
23271
|
if (!response.ok) {
|
|
@@ -23236,7 +23274,7 @@ async function fetchProjects(accessToken, orgId) {
|
|
|
23236
23274
|
return response.json();
|
|
23237
23275
|
}
|
|
23238
23276
|
async function createProject(accessToken, orgId, data) {
|
|
23239
|
-
const response = await fetch(`${
|
|
23277
|
+
const response = await fetch(`${getSonorApiUrl()}/organizations/${orgId}/projects`, {
|
|
23240
23278
|
method: "POST",
|
|
23241
23279
|
headers: {
|
|
23242
23280
|
"Authorization": `Bearer ${accessToken}`,
|
|
@@ -23250,7 +23288,7 @@ async function createProject(accessToken, orgId, data) {
|
|
|
23250
23288
|
return response.json();
|
|
23251
23289
|
}
|
|
23252
23290
|
async function generateApiKey(accessToken, projectId) {
|
|
23253
|
-
const response = await fetch(`${
|
|
23291
|
+
const response = await fetch(`${getSonorApiUrl()}/projects/${projectId}/api-keys`, {
|
|
23254
23292
|
method: "POST",
|
|
23255
23293
|
headers: {
|
|
23256
23294
|
"Authorization": `Bearer ${accessToken}`,
|
|
@@ -23454,7 +23492,7 @@ function progress(ctx, line) {
|
|
|
23454
23492
|
// src/cli/commands/init.ts
|
|
23455
23493
|
async function checkNextJsProject(cwd) {
|
|
23456
23494
|
try {
|
|
23457
|
-
const pkg = JSON.parse(await fs3.readFile(
|
|
23495
|
+
const pkg = JSON.parse(await fs3.readFile(path12.join(cwd, "package.json"), "utf-8"));
|
|
23458
23496
|
return !!(pkg.dependencies?.next || pkg.devDependencies?.next);
|
|
23459
23497
|
} catch {
|
|
23460
23498
|
return false;
|
|
@@ -23534,7 +23572,7 @@ async function run(ctx, options) {
|
|
|
23534
23572
|
]);
|
|
23535
23573
|
if (chosen === "new") {
|
|
23536
23574
|
const answers = await dist_default14.prompt([
|
|
23537
|
-
{ type: "input", name: "name", message: "Project name:", default:
|
|
23575
|
+
{ type: "input", name: "name", message: "Project name:", default: path12.basename(ctx.cwd) },
|
|
23538
23576
|
{ type: "input", name: "domain", message: "Project domain (optional):" }
|
|
23539
23577
|
]);
|
|
23540
23578
|
const project = await createProject(auth.accessToken, orgId, { name: answers.name, domain: answers.domain || "" });
|
|
@@ -23589,7 +23627,7 @@ async function run(ctx, options) {
|
|
|
23589
23627
|
};
|
|
23590
23628
|
}
|
|
23591
23629
|
async function ensureSitemapPostbuild(ctx) {
|
|
23592
|
-
const pkgPath =
|
|
23630
|
+
const pkgPath = path12.join(ctx.cwd, "package.json");
|
|
23593
23631
|
try {
|
|
23594
23632
|
const pkg = JSON.parse(await fs3.readFile(pkgPath, "utf-8"));
|
|
23595
23633
|
if (!pkg.scripts) pkg.scripts = {};
|
|
@@ -23631,7 +23669,7 @@ async function scanCommand(options) {
|
|
|
23631
23669
|
console.log("");
|
|
23632
23670
|
console.log(source_default.bold(" Scanning codebase..."));
|
|
23633
23671
|
console.log("");
|
|
23634
|
-
const targetDir =
|
|
23672
|
+
const targetDir = path12.resolve(options.dir || ".");
|
|
23635
23673
|
const spinner = ora("Looking for forms, metadata, widgets, schemas, FAQs, analytics, and images...").start();
|
|
23636
23674
|
let scanResults;
|
|
23637
23675
|
try {
|
|
@@ -23809,6 +23847,48 @@ async function scanCommand(options) {
|
|
|
23809
23847
|
process.exit(1);
|
|
23810
23848
|
}
|
|
23811
23849
|
}
|
|
23850
|
+
|
|
23851
|
+
// src/cli/config.ts
|
|
23852
|
+
var import_dotenv = __toESM(require_main());
|
|
23853
|
+
async function loadConfig({ resolveProject = false, cwd = process.cwd() } = {}) {
|
|
23854
|
+
const envFile = await readOptionalFile(path12.join(cwd, ".env.local"));
|
|
23855
|
+
const env3 = { ...(0, import_dotenv.parse)(envFile || ""), ...process.env };
|
|
23856
|
+
const configPath = resolveStateReadPath("config.json", cwd);
|
|
23857
|
+
const saved = await readOptionalFile(configPath);
|
|
23858
|
+
let stored = {};
|
|
23859
|
+
if (saved !== void 0) {
|
|
23860
|
+
try {
|
|
23861
|
+
stored = JSON.parse(saved);
|
|
23862
|
+
if (!stored || typeof stored !== "object" || Array.isArray(stored)) throw new Error();
|
|
23863
|
+
} catch {
|
|
23864
|
+
throw new ConfigError("INVALID_CONFIG", `Invalid JSON config: ${configPath}. Fix or remove it, then set SONOR_API_KEY in .env.local.`);
|
|
23865
|
+
}
|
|
23866
|
+
}
|
|
23867
|
+
const apiKey = String(env3.SONOR_API_KEY || stored.apiKey || stored.api_key || "").trim();
|
|
23868
|
+
if (!apiKey) {
|
|
23869
|
+
throw new ConfigError("MISSING_API_KEY", "Set SONOR_API_KEY in .env.local or run `sonor-setup init` first.");
|
|
23870
|
+
}
|
|
23871
|
+
if (!/^sonor_[0-9a-f]{8}_.+$/i.test(apiKey)) {
|
|
23872
|
+
throw new ConfigError("INVALID_API_KEY", "SONOR_API_KEY must be a sonor_ key from app.sonor.io.");
|
|
23873
|
+
}
|
|
23874
|
+
const config2 = {
|
|
23875
|
+
apiKey,
|
|
23876
|
+
apiUrl: (env3.SONOR_API_URL || getSonorApiUrl()).replace(/\/+$/, ""),
|
|
23877
|
+
siteUrl: env3.NEXT_PUBLIC_SITE_URL || env3.SITE_URL || stored.siteUrl || stored.site_url,
|
|
23878
|
+
businessInfo: stored.businessInfo || stored.business_info
|
|
23879
|
+
};
|
|
23880
|
+
if (!resolveProject) return config2;
|
|
23881
|
+
const auth = await authenticateWithApiKey(apiKey, config2.apiUrl);
|
|
23882
|
+
return { ...config2, projectId: auth.projectId };
|
|
23883
|
+
}
|
|
23884
|
+
async function readOptionalFile(file) {
|
|
23885
|
+
try {
|
|
23886
|
+
return await fs3.readFile(file, "utf-8");
|
|
23887
|
+
} catch (error2) {
|
|
23888
|
+
if (error2.code === "ENOENT") return void 0;
|
|
23889
|
+
throw new ConfigError("CONFIG_READ_FAILED", `Could not read ${file}. Check file permissions.`);
|
|
23890
|
+
}
|
|
23891
|
+
}
|
|
23812
23892
|
var IMAGE_EXTENSIONS = [".jpg", ".jpeg", ".png", ".gif", ".webp", ".svg", ".ico", ".bmp", ".avif"];
|
|
23813
23893
|
var MIME_TYPES = {
|
|
23814
23894
|
".jpg": "image/jpeg",
|
|
@@ -23831,7 +23911,7 @@ function filePathToPagePath(filePath) {
|
|
|
23831
23911
|
}
|
|
23832
23912
|
if (p.startsWith("pages/") || p.startsWith("src/pages/")) {
|
|
23833
23913
|
p = p.replace(/^pages\//, "").replace(/^src\/pages\//, "");
|
|
23834
|
-
const base =
|
|
23914
|
+
const base = path12.basename(p, path12.extname(p));
|
|
23835
23915
|
return base === "index" ? "/" : "/" + base;
|
|
23836
23916
|
}
|
|
23837
23917
|
p = p.replace(/\.[^.]+$/, "").replace(/^\.\//, "").replace(/\\/g, "/");
|
|
@@ -23874,8 +23954,8 @@ async function imagesCommand(subcommand, options) {
|
|
|
23874
23954
|
}
|
|
23875
23955
|
}
|
|
23876
23956
|
async function scanImages(options) {
|
|
23877
|
-
const targetDir =
|
|
23878
|
-
const publicDir =
|
|
23957
|
+
const targetDir = path12.resolve(options.dir || ".");
|
|
23958
|
+
const publicDir = path12.join(targetDir, "public");
|
|
23879
23959
|
try {
|
|
23880
23960
|
await fs3.access(publicDir);
|
|
23881
23961
|
} catch {
|
|
@@ -23945,7 +24025,7 @@ async function uploadImages(options) {
|
|
|
23945
24025
|
console.log("");
|
|
23946
24026
|
process.exit(1);
|
|
23947
24027
|
}
|
|
23948
|
-
const targetDir =
|
|
24028
|
+
const targetDir = path12.resolve(options.dir || ".");
|
|
23949
24029
|
const spinner = ora("Scanning for images...").start();
|
|
23950
24030
|
const results = await scanPublicImages(targetDir);
|
|
23951
24031
|
spinner.stop();
|
|
@@ -23998,7 +24078,7 @@ async function uploadImages(options) {
|
|
|
23998
24078
|
const uploadSpinner = ora(`Uploading ${img.filename}...`).start();
|
|
23999
24079
|
try {
|
|
24000
24080
|
const result = await uploadImageToPortal(
|
|
24001
|
-
|
|
24081
|
+
path12.join(targetDir, img.filePath),
|
|
24002
24082
|
img,
|
|
24003
24083
|
{ apiUrl, apiKey, category: options.category }
|
|
24004
24084
|
);
|
|
@@ -24017,7 +24097,7 @@ async function uploadImages(options) {
|
|
|
24017
24097
|
}
|
|
24018
24098
|
console.log("");
|
|
24019
24099
|
if (uploaded.length > 0) {
|
|
24020
|
-
const manifestPath =
|
|
24100
|
+
const manifestPath = path12.join(targetDir, IMAGE_MANIFEST);
|
|
24021
24101
|
await fs3.writeFile(manifestPath, JSON.stringify({
|
|
24022
24102
|
uploaded,
|
|
24023
24103
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -24030,8 +24110,8 @@ async function uploadImages(options) {
|
|
|
24030
24110
|
console.log("");
|
|
24031
24111
|
}
|
|
24032
24112
|
async function migrateImages(options) {
|
|
24033
|
-
const targetDir =
|
|
24034
|
-
const manifestPath =
|
|
24113
|
+
const targetDir = path12.resolve(options.dir || ".");
|
|
24114
|
+
const manifestPath = resolveImageManifestReadPath(targetDir);
|
|
24035
24115
|
const apiUrl = process.env.SONOR_API_URL || "https://api.sonor.io";
|
|
24036
24116
|
const apiKey = process.env.SONOR_API_KEY || "";
|
|
24037
24117
|
if (!apiKey) {
|
|
@@ -24134,9 +24214,9 @@ async function migrateImages(options) {
|
|
|
24134
24214
|
let successCount = 0;
|
|
24135
24215
|
let failCount = 0;
|
|
24136
24216
|
for (const [filePath, fileMigrations] of byFile) {
|
|
24137
|
-
const fileSpinner = ora(`Migrating ${
|
|
24217
|
+
const fileSpinner = ora(`Migrating ${path12.basename(filePath)}...`).start();
|
|
24138
24218
|
try {
|
|
24139
|
-
await migrateFileImages(
|
|
24219
|
+
await migrateFileImages(path12.join(targetDir, filePath), fileMigrations);
|
|
24140
24220
|
successCount += fileMigrations.length;
|
|
24141
24221
|
fileSpinner.succeed(`Migrated: ${filePath} (${fileMigrations.length} images)`);
|
|
24142
24222
|
} catch (error2) {
|
|
@@ -24158,7 +24238,7 @@ async function migrateImages(options) {
|
|
|
24158
24238
|
console.log("");
|
|
24159
24239
|
}
|
|
24160
24240
|
async function uploadAndMigrate(options) {
|
|
24161
|
-
const targetDir =
|
|
24241
|
+
const targetDir = path12.resolve(options.dir || ".");
|
|
24162
24242
|
const apiUrl = process.env.SONOR_API_URL || "https://api.sonor.io";
|
|
24163
24243
|
const apiKey = process.env.SONOR_API_KEY || "";
|
|
24164
24244
|
if (!apiKey) {
|
|
@@ -24225,7 +24305,7 @@ async function uploadAndMigrate(options) {
|
|
|
24225
24305
|
const uploadSpinner = ora(`Uploading ${img.filename}...`).start();
|
|
24226
24306
|
try {
|
|
24227
24307
|
const result = await uploadImageToPortal(
|
|
24228
|
-
|
|
24308
|
+
path12.join(targetDir, img.filePath),
|
|
24229
24309
|
img,
|
|
24230
24310
|
{ apiUrl, apiKey, category: options.category }
|
|
24231
24311
|
);
|
|
@@ -24297,9 +24377,9 @@ async function uploadAndMigrate(options) {
|
|
|
24297
24377
|
let successCount = 0;
|
|
24298
24378
|
let failCount = 0;
|
|
24299
24379
|
for (const [filePath, fileMigrations] of byFile) {
|
|
24300
|
-
const fileSpinner = ora(`Migrating ${
|
|
24380
|
+
const fileSpinner = ora(`Migrating ${path12.basename(filePath)}...`).start();
|
|
24301
24381
|
try {
|
|
24302
|
-
await migrateFileImages(
|
|
24382
|
+
await migrateFileImages(path12.join(targetDir, filePath), fileMigrations);
|
|
24303
24383
|
successCount += fileMigrations.length;
|
|
24304
24384
|
fileSpinner.succeed(`Migrated: ${filePath} (${fileMigrations.length} images)`);
|
|
24305
24385
|
} catch (error2) {
|
|
@@ -24307,7 +24387,7 @@ async function uploadAndMigrate(options) {
|
|
|
24307
24387
|
fileSpinner.fail(`Failed: ${filePath} - ${error2.message}`);
|
|
24308
24388
|
}
|
|
24309
24389
|
}
|
|
24310
|
-
const manifestPath =
|
|
24390
|
+
const manifestPath = path12.join(targetDir, IMAGE_MANIFEST);
|
|
24311
24391
|
await fs3.writeFile(manifestPath, JSON.stringify({
|
|
24312
24392
|
uploaded,
|
|
24313
24393
|
criticalKeptLocal: criticalImages.map((i) => i.filename),
|
|
@@ -24334,8 +24414,8 @@ async function uploadAndMigrate(options) {
|
|
|
24334
24414
|
console.log("");
|
|
24335
24415
|
}
|
|
24336
24416
|
async function replaceWithCdnUrls(options) {
|
|
24337
|
-
const targetDir =
|
|
24338
|
-
const manifestPath =
|
|
24417
|
+
const targetDir = path12.resolve(options.dir || ".");
|
|
24418
|
+
const manifestPath = resolveImageManifestReadPath(targetDir);
|
|
24339
24419
|
let manifest;
|
|
24340
24420
|
try {
|
|
24341
24421
|
const content = await fs3.readFile(manifestPath, "utf-8");
|
|
@@ -24383,7 +24463,7 @@ async function replaceWithCdnUrls(options) {
|
|
|
24383
24463
|
if (!seenFileLines.has(key)) {
|
|
24384
24464
|
seenFileLines.add(key);
|
|
24385
24465
|
replacements2.push({
|
|
24386
|
-
file:
|
|
24466
|
+
file: path12.relative(targetDir, file),
|
|
24387
24467
|
localPath: pattern,
|
|
24388
24468
|
cdnUrl: img.publicUrl,
|
|
24389
24469
|
line: i + 1
|
|
@@ -24431,9 +24511,9 @@ async function replaceWithCdnUrls(options) {
|
|
|
24431
24511
|
let successCount = 0;
|
|
24432
24512
|
let failCount = 0;
|
|
24433
24513
|
for (const [filePath, fileReplacements] of byFile) {
|
|
24434
|
-
const fileSpinner = ora(`Updating ${
|
|
24514
|
+
const fileSpinner = ora(`Updating ${path12.basename(filePath)}...`).start();
|
|
24435
24515
|
try {
|
|
24436
|
-
const fullPath =
|
|
24516
|
+
const fullPath = path12.join(targetDir, filePath);
|
|
24437
24517
|
let content = await fs3.readFile(fullPath, "utf-8");
|
|
24438
24518
|
for (const r of fileReplacements) {
|
|
24439
24519
|
const escaped = r.localPath.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
@@ -24461,8 +24541,8 @@ async function replaceWithCdnUrls(options) {
|
|
|
24461
24541
|
console.log("");
|
|
24462
24542
|
}
|
|
24463
24543
|
async function refreshManifest(options) {
|
|
24464
|
-
const targetDir =
|
|
24465
|
-
const manifestPath =
|
|
24544
|
+
const targetDir = path12.resolve(options.dir || ".");
|
|
24545
|
+
const manifestPath = path12.join(targetDir, IMAGE_MANIFEST);
|
|
24466
24546
|
const apiUrl = process.env.SONOR_API_URL || "https://api.sonor.io";
|
|
24467
24547
|
const apiKey = process.env.SONOR_API_KEY || "";
|
|
24468
24548
|
if (!apiKey) {
|
|
@@ -24471,7 +24551,7 @@ async function refreshManifest(options) {
|
|
|
24471
24551
|
}
|
|
24472
24552
|
let manifest;
|
|
24473
24553
|
try {
|
|
24474
|
-
const content = await fs3.readFile(
|
|
24554
|
+
const content = await fs3.readFile(resolveImageManifestReadPath(targetDir), "utf-8");
|
|
24475
24555
|
manifest = JSON.parse(content);
|
|
24476
24556
|
} catch {
|
|
24477
24557
|
console.log(source_default.yellow(" \u26A0 No upload manifest found"));
|
|
@@ -24524,12 +24604,12 @@ async function refreshManifest(options) {
|
|
|
24524
24604
|
}
|
|
24525
24605
|
async function findDataFiles(rootDir) {
|
|
24526
24606
|
const files = [];
|
|
24527
|
-
const excludeFiles = [
|
|
24607
|
+
const excludeFiles = [IMAGE_MANIFEST, LEGACY_IMAGE_MANIFEST];
|
|
24528
24608
|
async function scan(dir) {
|
|
24529
24609
|
try {
|
|
24530
24610
|
const entries = await fs3.readdir(dir, { withFileTypes: true });
|
|
24531
24611
|
for (const entry of entries) {
|
|
24532
|
-
const fullPath =
|
|
24612
|
+
const fullPath = path12.join(dir, entry.name);
|
|
24533
24613
|
if (entry.isDirectory()) {
|
|
24534
24614
|
if (["node_modules", ".next", ".git", "dist", "build"].includes(entry.name)) {
|
|
24535
24615
|
continue;
|
|
@@ -24539,7 +24619,7 @@ async function findDataFiles(rootDir) {
|
|
|
24539
24619
|
if (excludeFiles.includes(entry.name)) {
|
|
24540
24620
|
continue;
|
|
24541
24621
|
}
|
|
24542
|
-
const ext2 =
|
|
24622
|
+
const ext2 = path12.extname(entry.name).toLowerCase();
|
|
24543
24623
|
if ([".js", ".ts", ".json", ".jsx", ".tsx", ".mjs", ".cjs"].includes(ext2)) {
|
|
24544
24624
|
files.push(fullPath);
|
|
24545
24625
|
}
|
|
@@ -24552,16 +24632,16 @@ async function findDataFiles(rootDir) {
|
|
|
24552
24632
|
return files;
|
|
24553
24633
|
}
|
|
24554
24634
|
async function scanPublicImages(rootDir) {
|
|
24555
|
-
const publicDir =
|
|
24635
|
+
const publicDir = path12.join(rootDir, "public");
|
|
24556
24636
|
const images = [];
|
|
24557
24637
|
let totalSize = 0;
|
|
24558
24638
|
let usageCount = 0;
|
|
24559
24639
|
const imageFiles = await findImagesRecursive(publicDir);
|
|
24560
24640
|
const sourceFiles = await findSourceFiles2(rootDir);
|
|
24561
24641
|
for (const imagePath of imageFiles) {
|
|
24562
|
-
const relPath =
|
|
24563
|
-
const filename =
|
|
24564
|
-
const ext2 =
|
|
24642
|
+
const relPath = path12.relative(rootDir, imagePath);
|
|
24643
|
+
const filename = path12.basename(imagePath);
|
|
24644
|
+
const ext2 = path12.extname(filename).toLowerCase();
|
|
24565
24645
|
const stat = await fs3.stat(imagePath);
|
|
24566
24646
|
const category = getCategoryFromPath(relPath);
|
|
24567
24647
|
const suggestedSlotId = generateSlotId(relPath);
|
|
@@ -24587,11 +24667,11 @@ async function findImagesRecursive(dir, files = []) {
|
|
|
24587
24667
|
try {
|
|
24588
24668
|
const entries = await fs3.readdir(dir, { withFileTypes: true });
|
|
24589
24669
|
for (const entry of entries) {
|
|
24590
|
-
const fullPath =
|
|
24670
|
+
const fullPath = path12.join(dir, entry.name);
|
|
24591
24671
|
if (entry.isDirectory()) {
|
|
24592
24672
|
await findImagesRecursive(fullPath, files);
|
|
24593
24673
|
} else if (entry.isFile()) {
|
|
24594
|
-
const ext2 =
|
|
24674
|
+
const ext2 = path12.extname(entry.name).toLowerCase();
|
|
24595
24675
|
if (IMAGE_EXTENSIONS.includes(ext2)) {
|
|
24596
24676
|
files.push(fullPath);
|
|
24597
24677
|
}
|
|
@@ -24604,7 +24684,7 @@ async function findImagesRecursive(dir, files = []) {
|
|
|
24604
24684
|
async function findSourceFiles2(dir, files = []) {
|
|
24605
24685
|
const entries = await fs3.readdir(dir, { withFileTypes: true });
|
|
24606
24686
|
for (const entry of entries) {
|
|
24607
|
-
const fullPath =
|
|
24687
|
+
const fullPath = path12.join(dir, entry.name);
|
|
24608
24688
|
if (entry.isDirectory()) {
|
|
24609
24689
|
if (["node_modules", ".next", ".git", "dist", "build", "public"].includes(entry.name)) {
|
|
24610
24690
|
continue;
|
|
@@ -24620,8 +24700,8 @@ async function findSourceFiles2(dir, files = []) {
|
|
|
24620
24700
|
}
|
|
24621
24701
|
async function findImageUsages(imagePath, sourceFiles, rootDir) {
|
|
24622
24702
|
const usages = [];
|
|
24623
|
-
const filename =
|
|
24624
|
-
const relPath =
|
|
24703
|
+
const filename = path12.basename(imagePath);
|
|
24704
|
+
const relPath = path12.relative(path12.join(rootDir, "public"), imagePath);
|
|
24625
24705
|
const patterns = [
|
|
24626
24706
|
`/${relPath}`,
|
|
24627
24707
|
// /images/hero.jpg
|
|
@@ -24643,7 +24723,7 @@ async function findImageUsages(imagePath, sourceFiles, rootDir) {
|
|
|
24643
24723
|
const elementType = detectElementType(line);
|
|
24644
24724
|
const canAutoMigrate = ["img", "Image"].includes(elementType);
|
|
24645
24725
|
usages.push({
|
|
24646
|
-
filePath:
|
|
24726
|
+
filePath: path12.relative(rootDir, sourceFile),
|
|
24647
24727
|
line: i + 1,
|
|
24648
24728
|
elementType,
|
|
24649
24729
|
altText: extractAltText(line),
|
|
@@ -24715,7 +24795,7 @@ function detectCriticalImage(filename, relPath, usages, fileSize) {
|
|
|
24715
24795
|
(u) => u.filePath.includes("layout.") || u.filePath.includes("/layout/")
|
|
24716
24796
|
);
|
|
24717
24797
|
const usedInCriticalComponent = usages.some((u) => {
|
|
24718
|
-
const fileName =
|
|
24798
|
+
const fileName = path12.basename(u.filePath).toLowerCase();
|
|
24719
24799
|
return fileName.includes("header") || fileName.includes("navbar") || fileName.includes("nav.") || fileName.includes("hero") || fileName.includes("footer");
|
|
24720
24800
|
});
|
|
24721
24801
|
const isSiteLogo = SITE_LOGO_PATTERNS.some((p) => p.test(filename));
|
|
@@ -24851,7 +24931,7 @@ async function uploadAndMigrateImages(scanResults, options) {
|
|
|
24851
24931
|
for (const img of scanResults.images) {
|
|
24852
24932
|
try {
|
|
24853
24933
|
const uploadResult = await uploadImageToPortal(
|
|
24854
|
-
|
|
24934
|
+
path12.join(rootDir, img.filePath),
|
|
24855
24935
|
img,
|
|
24856
24936
|
{
|
|
24857
24937
|
apiUrl: options.apiUrl,
|
|
@@ -24879,7 +24959,7 @@ async function uploadAndMigrateImages(scanResults, options) {
|
|
|
24879
24959
|
}
|
|
24880
24960
|
for (const [filePath, migrations] of byFile) {
|
|
24881
24961
|
try {
|
|
24882
|
-
await migrateFileImages(
|
|
24962
|
+
await migrateFileImages(path12.join(rootDir, filePath), migrations);
|
|
24883
24963
|
result.migrated += migrations.length;
|
|
24884
24964
|
} catch (error2) {
|
|
24885
24965
|
result.errors.push(`Migration failed for ${filePath}: ${error2.message}`);
|
|
@@ -24893,31 +24973,25 @@ async function migrateCommand(options) {
|
|
|
24893
24973
|
console.log("");
|
|
24894
24974
|
console.log(source_default.bold(" Site-Kit Migration"));
|
|
24895
24975
|
console.log("");
|
|
24896
|
-
const apiKey =
|
|
24897
|
-
const projectId = process.env.SONOR_PROJECT_ID;
|
|
24898
|
-
if (!apiKey || !projectId) {
|
|
24899
|
-
console.log(source_default.red(" \u2717 Missing environment variables"));
|
|
24900
|
-
console.log(source_default.gray(" Run `sonor-setup init` first to configure your project."));
|
|
24901
|
-
console.log("");
|
|
24902
|
-
process.exit(1);
|
|
24903
|
-
}
|
|
24976
|
+
const { apiKey, projectId, apiUrl } = await loadConfig({ resolveProject: true });
|
|
24904
24977
|
if (options.dryRun) {
|
|
24905
24978
|
console.log(source_default.yellow(" Running in dry-run mode - no files will be modified"));
|
|
24906
24979
|
console.log("");
|
|
24907
24980
|
}
|
|
24908
24981
|
if (options.file) {
|
|
24909
|
-
const filePath =
|
|
24982
|
+
const filePath = path12.resolve(options.file);
|
|
24910
24983
|
try {
|
|
24911
24984
|
await fs3.access(filePath);
|
|
24912
24985
|
} catch {
|
|
24913
24986
|
console.log(source_default.red(` \u2717 File not found: ${filePath}`));
|
|
24914
24987
|
process.exit(1);
|
|
24915
24988
|
}
|
|
24916
|
-
const spinner = ora(`Migrating ${
|
|
24989
|
+
const spinner = ora(`Migrating ${path12.basename(filePath)}...`).start();
|
|
24917
24990
|
try {
|
|
24918
24991
|
const result = await migrateFile(filePath, {
|
|
24919
24992
|
projectId,
|
|
24920
24993
|
apiKey,
|
|
24994
|
+
apiUrl,
|
|
24921
24995
|
dryRun: options.dryRun
|
|
24922
24996
|
});
|
|
24923
24997
|
if (result.success) {
|
|
@@ -24980,6 +25054,7 @@ async function migrateCommand(options) {
|
|
|
24980
25054
|
const results = await migrateFiles(scanResults, {
|
|
24981
25055
|
projectId,
|
|
24982
25056
|
apiKey,
|
|
25057
|
+
apiUrl,
|
|
24983
25058
|
dryRun: options.dryRun
|
|
24984
25059
|
});
|
|
24985
25060
|
const successful = results.filter((r) => r.success);
|
|
@@ -25009,10 +25084,9 @@ async function migrateCommand(options) {
|
|
|
25009
25084
|
process.exit(1);
|
|
25010
25085
|
}
|
|
25011
25086
|
console.log("");
|
|
25012
|
-
await handleImageMigration(options, apiKey);
|
|
25087
|
+
await handleImageMigration(options, apiKey, apiUrl);
|
|
25013
25088
|
}
|
|
25014
|
-
async function handleImageMigration(options, apiKey,
|
|
25015
|
-
const apiUrl = process.env.SONOR_API_URL || "https://api.sonor.io";
|
|
25089
|
+
async function handleImageMigration(options, apiKey, apiUrl) {
|
|
25016
25090
|
const imageScanSpinner = ora("Scanning for images...").start();
|
|
25017
25091
|
let imageResults;
|
|
25018
25092
|
try {
|
|
@@ -25076,17 +25150,11 @@ function formatBytes2(bytes) {
|
|
|
25076
25150
|
return `${parseFloat((bytes / Math.pow(k2, i)).toFixed(1))} ${sizes[i]}`;
|
|
25077
25151
|
}
|
|
25078
25152
|
var SKIP_PROPS = ["href", "src", "className", "style", "onClick", "ref", "key", "id", "target", "rel", "type", "name", "variant", "size", "icon"];
|
|
25079
|
-
var
|
|
25080
|
-
var TEMPLATES_DIR = ".uptrade/templates";
|
|
25153
|
+
var TEMPLATES_DIR = path12.join(SONOR_STATE_DIR, "templates");
|
|
25081
25154
|
async function locationsCommand(subcommand, arg, options) {
|
|
25082
25155
|
console.log("");
|
|
25083
25156
|
console.log(source_default.bold(" \u{1F4CD} Site-Kit Location Page Manager"));
|
|
25084
25157
|
console.log("");
|
|
25085
|
-
const config2 = await loadConfig();
|
|
25086
|
-
if (!config2?.projectId) {
|
|
25087
|
-
console.log(source_default.red(" \u2717 Not configured. Run `npx sonor-setup init` first."));
|
|
25088
|
-
return;
|
|
25089
|
-
}
|
|
25090
25158
|
switch (subcommand) {
|
|
25091
25159
|
case "template":
|
|
25092
25160
|
if (!arg) {
|
|
@@ -25094,6 +25162,7 @@ async function locationsCommand(subcommand, arg, options) {
|
|
|
25094
25162
|
console.log(source_default.gray(" Example: locations template ./app/services/plumbing/page.tsx"));
|
|
25095
25163
|
return;
|
|
25096
25164
|
}
|
|
25165
|
+
await loadConfig();
|
|
25097
25166
|
await templateCommand(arg, options);
|
|
25098
25167
|
break;
|
|
25099
25168
|
case "upload":
|
|
@@ -25101,17 +25170,17 @@ async function locationsCommand(subcommand, arg, options) {
|
|
|
25101
25170
|
console.log(source_default.red(" \u2717 Usage: locations upload --template <name>"));
|
|
25102
25171
|
return;
|
|
25103
25172
|
}
|
|
25104
|
-
await uploadCommand(options.template,
|
|
25173
|
+
await uploadCommand(options.template, await loadConfig({ resolveProject: true }));
|
|
25105
25174
|
break;
|
|
25106
25175
|
case "generate":
|
|
25107
25176
|
if (!options.template) {
|
|
25108
25177
|
console.log(source_default.red(' \u2717 Usage: locations generate --template <name> --locations "City, ST" ...'));
|
|
25109
25178
|
return;
|
|
25110
25179
|
}
|
|
25111
|
-
await generateCommand(options,
|
|
25180
|
+
await generateCommand(options, await loadConfig({ resolveProject: true }));
|
|
25112
25181
|
break;
|
|
25113
25182
|
case "list":
|
|
25114
|
-
await listCommand(
|
|
25183
|
+
await listCommand(await loadConfig({ resolveProject: true }));
|
|
25115
25184
|
break;
|
|
25116
25185
|
default:
|
|
25117
25186
|
console.log(source_default.yellow(" Available subcommands:"));
|
|
@@ -25123,10 +25192,10 @@ async function locationsCommand(subcommand, arg, options) {
|
|
|
25123
25192
|
console.log("");
|
|
25124
25193
|
}
|
|
25125
25194
|
}
|
|
25126
|
-
async function templateCommand(sourcePath, options
|
|
25195
|
+
async function templateCommand(sourcePath, options) {
|
|
25127
25196
|
const spinner = ora("Analyzing source page...").start();
|
|
25128
25197
|
try {
|
|
25129
|
-
const resolvedPath =
|
|
25198
|
+
const resolvedPath = path12.resolve(sourcePath);
|
|
25130
25199
|
if (!existsSync(resolvedPath)) {
|
|
25131
25200
|
spinner.fail(`File not found: ${sourcePath}`);
|
|
25132
25201
|
return;
|
|
@@ -25139,8 +25208,8 @@ async function templateCommand(sourcePath, options, config2) {
|
|
|
25139
25208
|
const slots = [];
|
|
25140
25209
|
const componentNames = [];
|
|
25141
25210
|
traverse(ast, {
|
|
25142
|
-
JSXElement(
|
|
25143
|
-
const openingElement =
|
|
25211
|
+
JSXElement(path29) {
|
|
25212
|
+
const openingElement = path29.node.openingElement;
|
|
25144
25213
|
if (isJSXIdentifier(openingElement.name)) {
|
|
25145
25214
|
const componentName = openingElement.name.name;
|
|
25146
25215
|
if (componentName[0] === componentName[0].toUpperCase()) {
|
|
@@ -25180,8 +25249,9 @@ async function templateCommand(sourcePath, options, config2) {
|
|
|
25180
25249
|
},
|
|
25181
25250
|
managed_components: ["schema", "faqs", "metadata"]
|
|
25182
25251
|
};
|
|
25183
|
-
|
|
25184
|
-
|
|
25252
|
+
const templatesDir = path12.join(process.cwd(), TEMPLATES_DIR);
|
|
25253
|
+
await fs3.mkdir(templatesDir, { recursive: true });
|
|
25254
|
+
const templatePath = path12.join(templatesDir, `${templateName}.json`);
|
|
25185
25255
|
await fs3.writeFile(templatePath, JSON.stringify(template, null, 2));
|
|
25186
25256
|
console.log("");
|
|
25187
25257
|
console.log(source_default.green(" \u2713 Template created:"), source_default.cyan(templatePath));
|
|
@@ -25260,7 +25330,7 @@ function inferGenerationHint(propName) {
|
|
|
25260
25330
|
return void 0;
|
|
25261
25331
|
}
|
|
25262
25332
|
function inferTemplateName(sourcePath) {
|
|
25263
|
-
const parts = sourcePath.split(
|
|
25333
|
+
const parts = sourcePath.split(path12.sep);
|
|
25264
25334
|
const pageIndex = parts.findIndex((p) => p === "page.tsx" || p === "page.jsx");
|
|
25265
25335
|
if (pageIndex > 0) {
|
|
25266
25336
|
return parts[pageIndex - 1];
|
|
@@ -25269,14 +25339,14 @@ function inferTemplateName(sourcePath) {
|
|
|
25269
25339
|
return filtered[filtered.length - 1] || "template";
|
|
25270
25340
|
}
|
|
25271
25341
|
function inferSourcePagePath(sourcePath) {
|
|
25272
|
-
const parts = sourcePath.split(
|
|
25342
|
+
const parts = sourcePath.split(path12.sep);
|
|
25273
25343
|
const appIndex = parts.findIndex((p) => p === "app" || p === "pages");
|
|
25274
25344
|
if (appIndex >= 0) {
|
|
25275
25345
|
const pathParts = parts.slice(appIndex + 1);
|
|
25276
25346
|
const filtered = pathParts.filter((p) => !["page.tsx", "page.jsx", "index.tsx", "index.jsx"].includes(p));
|
|
25277
25347
|
return "/" + filtered.join("/");
|
|
25278
25348
|
}
|
|
25279
|
-
return "/" +
|
|
25349
|
+
return "/" + path12.basename(sourcePath, path12.extname(sourcePath));
|
|
25280
25350
|
}
|
|
25281
25351
|
function toSnakeCase(str) {
|
|
25282
25352
|
return str.replace(/([A-Z])/g, "_$1").toLowerCase().replace(/^_/, "");
|
|
@@ -25288,22 +25358,22 @@ function truncate(str, maxLength) {
|
|
|
25288
25358
|
async function uploadCommand(templateName, config2) {
|
|
25289
25359
|
const spinner = ora("Uploading template to Portal...").start();
|
|
25290
25360
|
try {
|
|
25291
|
-
const templatePath =
|
|
25361
|
+
const templatePath = resolveStateReadPath(path12.join("templates", `${templateName}.json`));
|
|
25292
25362
|
if (!existsSync(templatePath)) {
|
|
25293
25363
|
spinner.fail(`Template not found: ${templatePath}`);
|
|
25294
25364
|
console.log(source_default.gray(` Run: npx sonor-setup locations template <page> --name ${templateName}`));
|
|
25295
25365
|
return;
|
|
25296
25366
|
}
|
|
25297
25367
|
const template = JSON.parse(readFileSync(templatePath, "utf-8"));
|
|
25298
|
-
const response = await fetch(`${
|
|
25368
|
+
const response = await fetch(`${config2.apiUrl}/seo/location-templates`, {
|
|
25299
25369
|
method: "POST",
|
|
25300
25370
|
headers: {
|
|
25301
25371
|
"Content-Type": "application/json",
|
|
25302
25372
|
"Authorization": `Bearer ${config2.apiKey}`
|
|
25303
25373
|
},
|
|
25304
25374
|
body: JSON.stringify({
|
|
25305
|
-
|
|
25306
|
-
|
|
25375
|
+
...template,
|
|
25376
|
+
project_id: config2.projectId
|
|
25307
25377
|
})
|
|
25308
25378
|
});
|
|
25309
25379
|
if (!response.ok) {
|
|
@@ -25311,11 +25381,11 @@ async function uploadCommand(templateName, config2) {
|
|
|
25311
25381
|
if (response.status === 409) {
|
|
25312
25382
|
spinner.text = "Template exists, updating...";
|
|
25313
25383
|
const existing = await fetch(
|
|
25314
|
-
`${
|
|
25384
|
+
`${config2.apiUrl}/seo/location-templates/by-name/${templateName}?project_id=${config2.projectId}`,
|
|
25315
25385
|
{ headers: { "Authorization": `Bearer ${config2.apiKey}` } }
|
|
25316
25386
|
);
|
|
25317
25387
|
const existingData = await existing.json();
|
|
25318
|
-
const updateResponse = await fetch(`${
|
|
25388
|
+
const updateResponse = await fetch(`${config2.apiUrl}/seo/location-templates/${existingData.id}`, {
|
|
25319
25389
|
method: "PUT",
|
|
25320
25390
|
headers: {
|
|
25321
25391
|
"Content-Type": "application/json",
|
|
@@ -25364,7 +25434,7 @@ async function generateCommand(options, config2) {
|
|
|
25364
25434
|
}
|
|
25365
25435
|
const spinner = ora(`Generating ${type || "service-location"} pages...`).start();
|
|
25366
25436
|
try {
|
|
25367
|
-
const response = await fetch(`${
|
|
25437
|
+
const response = await fetch(`${config2.apiUrl}/seo/location-pages/generate`, {
|
|
25368
25438
|
method: "POST",
|
|
25369
25439
|
headers: {
|
|
25370
25440
|
"Content-Type": "application/json",
|
|
@@ -25404,7 +25474,7 @@ async function listCommand(config2) {
|
|
|
25404
25474
|
const spinner = ora("Fetching templates...").start();
|
|
25405
25475
|
try {
|
|
25406
25476
|
const response = await fetch(
|
|
25407
|
-
`${
|
|
25477
|
+
`${config2.apiUrl}/seo/location-templates?project_id=${config2.projectId}`,
|
|
25408
25478
|
{ headers: { "Authorization": `Bearer ${config2.apiKey}` } }
|
|
25409
25479
|
);
|
|
25410
25480
|
if (!response.ok) {
|
|
@@ -25429,69 +25499,21 @@ async function listCommand(config2) {
|
|
|
25429
25499
|
});
|
|
25430
25500
|
}
|
|
25431
25501
|
console.log("");
|
|
25432
|
-
|
|
25433
|
-
|
|
25434
|
-
|
|
25435
|
-
|
|
25436
|
-
console.log(source_default.gray(
|
|
25437
|
-
|
|
25438
|
-
|
|
25439
|
-
});
|
|
25440
|
-
console.log("");
|
|
25441
|
-
}
|
|
25502
|
+
const localTemplates = await listLocalTemplates();
|
|
25503
|
+
if (localTemplates.length > 0) {
|
|
25504
|
+
console.log(source_default.gray(" Local (not uploaded):"));
|
|
25505
|
+
localTemplates.forEach((f) => {
|
|
25506
|
+
console.log(source_default.gray(` \u2022 ${f.replace(".json", "")}`));
|
|
25507
|
+
});
|
|
25508
|
+
console.log("");
|
|
25442
25509
|
}
|
|
25443
25510
|
} catch (error2) {
|
|
25444
25511
|
spinner.fail(`Failed to fetch templates: ${error2.message}`);
|
|
25445
25512
|
}
|
|
25446
25513
|
}
|
|
25447
|
-
async function loadConfig() {
|
|
25448
|
-
const configPath = path10.join(".uptrade", "config.json");
|
|
25449
|
-
if (existsSync(configPath)) {
|
|
25450
|
-
try {
|
|
25451
|
-
const config2 = JSON.parse(readFileSync(configPath, "utf-8"));
|
|
25452
|
-
return {
|
|
25453
|
-
projectId: config2.projectId || config2.project_id,
|
|
25454
|
-
apiKey: config2.apiKey || config2.api_key
|
|
25455
|
-
};
|
|
25456
|
-
} catch {
|
|
25457
|
-
return null;
|
|
25458
|
-
}
|
|
25459
|
-
}
|
|
25460
|
-
const projectId = process.env.SONOR_PROJECT_ID;
|
|
25461
|
-
const apiKey = process.env.SONOR_API_KEY;
|
|
25462
|
-
if (projectId && apiKey) {
|
|
25463
|
-
return { projectId, apiKey };
|
|
25464
|
-
}
|
|
25465
|
-
return null;
|
|
25466
|
-
}
|
|
25467
|
-
var API_URL3 = process.env.SONOR_API_URL || "https://api.sonor.io";
|
|
25468
|
-
async function loadConfig2() {
|
|
25469
|
-
const configPath = path10.join(".uptrade", "config.json");
|
|
25470
|
-
if (existsSync(configPath)) {
|
|
25471
|
-
try {
|
|
25472
|
-
const config2 = JSON.parse(readFileSync(configPath, "utf-8"));
|
|
25473
|
-
return {
|
|
25474
|
-
projectId: config2.projectId || config2.project_id,
|
|
25475
|
-
apiKey: config2.apiKey || config2.api_key
|
|
25476
|
-
};
|
|
25477
|
-
} catch {
|
|
25478
|
-
return null;
|
|
25479
|
-
}
|
|
25480
|
-
}
|
|
25481
|
-
const projectId = process.env.SONOR_PROJECT_ID;
|
|
25482
|
-
const apiKey = process.env.SONOR_API_KEY;
|
|
25483
|
-
if (projectId && apiKey) return { projectId, apiKey };
|
|
25484
|
-
return null;
|
|
25485
|
-
}
|
|
25486
25514
|
async function faqsCommand(subcommand, options) {
|
|
25487
25515
|
console.log("");
|
|
25488
|
-
const config2 = await
|
|
25489
|
-
if (!config2?.projectId || !config2?.apiKey) {
|
|
25490
|
-
console.log(source_default.red(" \u2717 Not configured. Run `npx sonor-setup init` first."));
|
|
25491
|
-
console.log(source_default.gray(" Set SONOR_API_KEY, or use .uptrade/config.json"));
|
|
25492
|
-
console.log("");
|
|
25493
|
-
return;
|
|
25494
|
-
}
|
|
25516
|
+
const config2 = await loadConfig({ resolveProject: true });
|
|
25495
25517
|
switch (subcommand) {
|
|
25496
25518
|
case "extract":
|
|
25497
25519
|
await extractCommand(options, config2);
|
|
@@ -25541,7 +25563,7 @@ async function extractCommand(options, config2) {
|
|
|
25541
25563
|
const faqContexts = [];
|
|
25542
25564
|
for (const faq of faqSections) {
|
|
25543
25565
|
try {
|
|
25544
|
-
const fullPath =
|
|
25566
|
+
const fullPath = path12.resolve(process.cwd(), faq.filePath);
|
|
25545
25567
|
const content = await fs3.readFile(fullPath, "utf-8");
|
|
25546
25568
|
let pagePath = faq.filePath.replace(/^app\//, "/").replace(/^src\/app\//, "/").replace(/\/page\.(tsx?|jsx?)$/, "").replace(/\[([^\]]+)\]/g, ":$1");
|
|
25547
25569
|
if (pagePath === "" || pagePath === "/page") pagePath = "/";
|
|
@@ -25556,7 +25578,7 @@ async function extractCommand(options, config2) {
|
|
|
25556
25578
|
if (importPath.startsWith("@/")) {
|
|
25557
25579
|
resolvedPath = importPath.replace("@/", "./");
|
|
25558
25580
|
} else if (importPath.startsWith(".")) {
|
|
25559
|
-
resolvedPath =
|
|
25581
|
+
resolvedPath = path12.resolve(path12.dirname(fullPath), importPath);
|
|
25560
25582
|
}
|
|
25561
25583
|
const extensions = ["", ".js", ".ts", ".jsx", ".tsx", ".json"];
|
|
25562
25584
|
for (const ext2 of extensions) {
|
|
@@ -25601,7 +25623,7 @@ async function extractCommand(options, config2) {
|
|
|
25601
25623
|
}
|
|
25602
25624
|
const extractSpinner = ora("Extracting FAQs via AI...").start();
|
|
25603
25625
|
try {
|
|
25604
|
-
const response = await fetch(`${
|
|
25626
|
+
const response = await fetch(`${config2.apiUrl}/seo/managed/faqs/extract`, {
|
|
25605
25627
|
method: "POST",
|
|
25606
25628
|
headers: {
|
|
25607
25629
|
"Content-Type": "application/json",
|
|
@@ -25636,7 +25658,7 @@ async function extractCommand(options, config2) {
|
|
|
25636
25658
|
let failed = 0;
|
|
25637
25659
|
for (const faq of extractedFaqs) {
|
|
25638
25660
|
try {
|
|
25639
|
-
const res = await fetch(`${
|
|
25661
|
+
const res = await fetch(`${config2.apiUrl}/seo/managed/faqs`, {
|
|
25640
25662
|
method: "POST",
|
|
25641
25663
|
headers: {
|
|
25642
25664
|
"Content-Type": "application/json",
|
|
@@ -25661,7 +25683,7 @@ async function extractCommand(options, config2) {
|
|
|
25661
25683
|
uploaded++;
|
|
25662
25684
|
console.log(source_default.green(` \u2713 ${faq.path}`) + source_default.gray(` (${faq.items.length} items)`));
|
|
25663
25685
|
} else if (res.status === 409 || res.status === 400) {
|
|
25664
|
-
const updateRes = await fetch(`${
|
|
25686
|
+
const updateRes = await fetch(`${config2.apiUrl}/seo/managed/faqs/by-path`, {
|
|
25665
25687
|
method: "PUT",
|
|
25666
25688
|
headers: {
|
|
25667
25689
|
"Content-Type": "application/json",
|
|
@@ -25748,7 +25770,7 @@ async function syncCommand(options, config2) {
|
|
|
25748
25770
|
const listSpinner = ora("Fetching existing FAQ sections from Portal...").start();
|
|
25749
25771
|
let existing = [];
|
|
25750
25772
|
try {
|
|
25751
|
-
const res = await fetch(`${
|
|
25773
|
+
const res = await fetch(`${config2.apiUrl}/seo/managed/faqs/project/${config2.projectId}`, {
|
|
25752
25774
|
headers: { Authorization: `Bearer ${config2.apiKey}` }
|
|
25753
25775
|
});
|
|
25754
25776
|
if (!res.ok) {
|
|
@@ -25777,7 +25799,7 @@ async function syncCommand(options, config2) {
|
|
|
25777
25799
|
let failed = 0;
|
|
25778
25800
|
for (const p of toCreate) {
|
|
25779
25801
|
try {
|
|
25780
|
-
const res = await fetch(`${
|
|
25802
|
+
const res = await fetch(`${config2.apiUrl}/seo/managed/faqs`, {
|
|
25781
25803
|
method: "POST",
|
|
25782
25804
|
headers: {
|
|
25783
25805
|
"Content-Type": "application/json",
|
|
@@ -25814,44 +25836,12 @@ async function syncCommand(options, config2) {
|
|
|
25814
25836
|
console.log(source_default.gray(" Add questions and answers there; they will appear on your site."));
|
|
25815
25837
|
console.log("");
|
|
25816
25838
|
}
|
|
25817
|
-
function getApiUrl() {
|
|
25818
|
-
return process.env.SONOR_API_URL || "https://api.sonor.io";
|
|
25819
|
-
}
|
|
25820
|
-
async function loadConfig3() {
|
|
25821
|
-
const configPath = path10.join(".uptrade", "config.json");
|
|
25822
|
-
if (existsSync(configPath)) {
|
|
25823
|
-
try {
|
|
25824
|
-
const config2 = JSON.parse(readFileSync(configPath, "utf-8"));
|
|
25825
|
-
return {
|
|
25826
|
-
projectId: config2.projectId || config2.project_id,
|
|
25827
|
-
apiKey: config2.apiKey || config2.api_key,
|
|
25828
|
-
siteUrl: config2.siteUrl || config2.site_url,
|
|
25829
|
-
businessInfo: config2.businessInfo || config2.business_info
|
|
25830
|
-
};
|
|
25831
|
-
} catch {
|
|
25832
|
-
return null;
|
|
25833
|
-
}
|
|
25834
|
-
}
|
|
25835
|
-
const projectId = process.env.SONOR_PROJECT_ID;
|
|
25836
|
-
const apiKey = process.env.SONOR_API_KEY;
|
|
25837
|
-
const siteUrl = process.env.NEXT_PUBLIC_SITE_URL || process.env.SITE_URL;
|
|
25838
|
-
if (projectId && apiKey) {
|
|
25839
|
-
return { projectId, apiKey, siteUrl };
|
|
25840
|
-
}
|
|
25841
|
-
return null;
|
|
25842
|
-
}
|
|
25843
25839
|
async function setupCommand(options) {
|
|
25844
25840
|
console.log("");
|
|
25845
25841
|
console.log(source_default.bold.blue(" \u{1F680} Signal-Enhanced SEO Setup"));
|
|
25846
25842
|
console.log(source_default.gray(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"));
|
|
25847
25843
|
console.log("");
|
|
25848
|
-
const config2 = await
|
|
25849
|
-
if (!config2?.projectId || !config2?.apiKey) {
|
|
25850
|
-
console.log(source_default.red(" \u2717 Not configured. Run `npx sonor-setup init` first."));
|
|
25851
|
-
console.log(source_default.gray(" Set SONOR_API_KEY"));
|
|
25852
|
-
console.log("");
|
|
25853
|
-
return;
|
|
25854
|
-
}
|
|
25844
|
+
const config2 = await loadConfig();
|
|
25855
25845
|
const capabilities = [];
|
|
25856
25846
|
if (options.faqsOnly) {
|
|
25857
25847
|
capabilities.push("extract_faqs");
|
|
@@ -25949,14 +25939,13 @@ async function setupCommand(options) {
|
|
|
25949
25939
|
const batch = batches[batchIndex];
|
|
25950
25940
|
const batchSpinner = ora(`Batch ${batchIndex + 1}/${batches.length}: Analyzing ${batch.length} pages...`).start();
|
|
25951
25941
|
try {
|
|
25952
|
-
const response = await fetch(`${
|
|
25942
|
+
const response = await fetch(`${config2.apiUrl}/api/public/seo/site-setup`, {
|
|
25953
25943
|
method: "POST",
|
|
25954
25944
|
headers: {
|
|
25955
25945
|
"Content-Type": "application/json",
|
|
25956
25946
|
"x-api-key": config2.apiKey
|
|
25957
25947
|
},
|
|
25958
25948
|
body: JSON.stringify({
|
|
25959
|
-
project_id: config2.projectId,
|
|
25960
25949
|
site_url: config2.siteUrl || "https://example.com",
|
|
25961
25950
|
// Only send business_info on first batch (for org schema)
|
|
25962
25951
|
business_info: batchIndex === 0 ? config2.businessInfo : void 0,
|
|
@@ -26048,10 +26037,10 @@ async function setupCommand(options) {
|
|
|
26048
26037
|
}
|
|
26049
26038
|
async function scanForPageFiles(rootDir) {
|
|
26050
26039
|
const pages = [];
|
|
26051
|
-
const appDir =
|
|
26052
|
-
const srcAppDir =
|
|
26053
|
-
const pagesDir =
|
|
26054
|
-
const srcPagesDir =
|
|
26040
|
+
const appDir = path12.join(rootDir, "app");
|
|
26041
|
+
const srcAppDir = path12.join(rootDir, "src", "app");
|
|
26042
|
+
const pagesDir = path12.join(rootDir, "pages");
|
|
26043
|
+
const srcPagesDir = path12.join(rootDir, "src", "pages");
|
|
26055
26044
|
const dirs = [appDir, srcAppDir, pagesDir, srcPagesDir];
|
|
26056
26045
|
for (const dir of dirs) {
|
|
26057
26046
|
if (existsSync(dir)) {
|
|
@@ -26063,7 +26052,7 @@ async function scanForPageFiles(rootDir) {
|
|
|
26063
26052
|
async function scanDirectory(dir, baseDir, pages) {
|
|
26064
26053
|
const entries = await fs3.readdir(dir, { withFileTypes: true });
|
|
26065
26054
|
for (const entry of entries) {
|
|
26066
|
-
const fullPath =
|
|
26055
|
+
const fullPath = path12.join(dir, entry.name);
|
|
26067
26056
|
if (entry.isDirectory()) {
|
|
26068
26057
|
if (entry.name.startsWith(".") || entry.name === "node_modules" || entry.name === "api") {
|
|
26069
26058
|
continue;
|
|
@@ -26074,8 +26063,8 @@ async function scanDirectory(dir, baseDir, pages) {
|
|
|
26074
26063
|
const isLegacyPage = baseDir.includes("/pages") && entry.name.match(/\.(tsx?|jsx?)$/) && !entry.name.startsWith("_");
|
|
26075
26064
|
if (isPage || isLegacyPage) {
|
|
26076
26065
|
const content = await fs3.readFile(fullPath, "utf-8");
|
|
26077
|
-
const relativePath =
|
|
26078
|
-
let pagePath = "/" +
|
|
26066
|
+
const relativePath = path12.relative(baseDir, fullPath);
|
|
26067
|
+
let pagePath = "/" + path12.dirname(relativePath).replace(/\\/g, "/").replace(/\/page$/, "");
|
|
26079
26068
|
pagePath = pagePath.replace(/\[([^\]]+)\]/g, ":$1").replace(/^\/\.$/, "/");
|
|
26080
26069
|
if (pagePath === "/.") pagePath = "/";
|
|
26081
26070
|
pages.push({
|
|
@@ -26095,10 +26084,10 @@ async function gatherImportedFiles(page, rootDir) {
|
|
|
26095
26084
|
if (importPath.toLowerCase().includes("faq") || importPath.includes("@/data") || importPath.includes("./data") || importPath.includes("../data") || importPath.includes("/constants") || importPath.includes("/content") || importPath.includes("practice-areas") || importPath.includes("subpages") || importPath.includes("pages-data")) {
|
|
26096
26085
|
let resolvedPath = importPath;
|
|
26097
26086
|
if (importPath.startsWith("@/")) {
|
|
26098
|
-
resolvedPath =
|
|
26087
|
+
resolvedPath = path12.join(rootDir, importPath.replace("@/", ""));
|
|
26099
26088
|
} else if (importPath.startsWith(".")) {
|
|
26100
|
-
const pageDir =
|
|
26101
|
-
resolvedPath =
|
|
26089
|
+
const pageDir = path12.dirname(path12.join(rootDir, "app", page.filePath));
|
|
26090
|
+
resolvedPath = path12.resolve(pageDir, importPath);
|
|
26102
26091
|
}
|
|
26103
26092
|
const extensions = ["", ".js", ".ts", ".jsx", ".tsx", ".json"];
|
|
26104
26093
|
for (const ext2 of extensions) {
|
|
@@ -26154,20 +26143,20 @@ async function expandDynamicRoutes(pages, rootDir) {
|
|
|
26154
26143
|
async function findDynamicRouteData(page, parentPath, rootDir) {
|
|
26155
26144
|
const results = [];
|
|
26156
26145
|
const dataFilePaths = [
|
|
26157
|
-
|
|
26158
|
-
|
|
26159
|
-
|
|
26160
|
-
|
|
26161
|
-
|
|
26162
|
-
|
|
26163
|
-
|
|
26164
|
-
|
|
26165
|
-
|
|
26166
|
-
|
|
26167
|
-
|
|
26168
|
-
|
|
26169
|
-
|
|
26170
|
-
|
|
26146
|
+
path12.join(rootDir, "data", "practice-areas.js"),
|
|
26147
|
+
path12.join(rootDir, "data", "practice-areas.ts"),
|
|
26148
|
+
path12.join(rootDir, "data", "personal-injury-pages.js"),
|
|
26149
|
+
path12.join(rootDir, "data", "personal-injury-pages.ts"),
|
|
26150
|
+
path12.join(rootDir, "data", "pages.js"),
|
|
26151
|
+
path12.join(rootDir, "data", "pages.ts"),
|
|
26152
|
+
path12.join(rootDir, "data", "content.js"),
|
|
26153
|
+
path12.join(rootDir, "data", "content.ts"),
|
|
26154
|
+
path12.join(rootDir, "data", "services.js"),
|
|
26155
|
+
path12.join(rootDir, "data", "services.ts"),
|
|
26156
|
+
path12.join(rootDir, "data", "subpages.js"),
|
|
26157
|
+
path12.join(rootDir, "data", "subpages.ts"),
|
|
26158
|
+
path12.join(rootDir, "src", "data", "practice-areas.js"),
|
|
26159
|
+
path12.join(rootDir, "src", "data", "practice-areas.ts")
|
|
26171
26160
|
];
|
|
26172
26161
|
const routeSegment = parentPath.replace(/^\//, "").split("/")[0];
|
|
26173
26162
|
const routeSegmentNormalized = routeSegment.replace(/-/g, "");
|
|
@@ -26259,7 +26248,7 @@ async function uploadFaqs(pages, config2) {
|
|
|
26259
26248
|
for (const page of pages) {
|
|
26260
26249
|
if (!page.faqs?.items?.length) continue;
|
|
26261
26250
|
try {
|
|
26262
|
-
const res = await fetch(`${
|
|
26251
|
+
const res = await fetch(`${config2.apiUrl}/api/public/seo/register-faq`, {
|
|
26263
26252
|
method: "POST",
|
|
26264
26253
|
headers: {
|
|
26265
26254
|
"Content-Type": "application/json",
|
|
@@ -26294,7 +26283,7 @@ async function uploadFaqs(pages, config2) {
|
|
|
26294
26283
|
async function uploadSchemas(pages, globalSchema, config2) {
|
|
26295
26284
|
if (globalSchema) {
|
|
26296
26285
|
try {
|
|
26297
|
-
const res = await fetch(`${
|
|
26286
|
+
const res = await fetch(`${config2.apiUrl}/api/public/seo/register-schema`, {
|
|
26298
26287
|
method: "POST",
|
|
26299
26288
|
headers: {
|
|
26300
26289
|
"Content-Type": "application/json",
|
|
@@ -26320,7 +26309,7 @@ async function uploadSchemas(pages, globalSchema, config2) {
|
|
|
26320
26309
|
if (!page.schemas?.length) continue;
|
|
26321
26310
|
for (const schema of page.schemas) {
|
|
26322
26311
|
try {
|
|
26323
|
-
const res = await fetch(`${
|
|
26312
|
+
const res = await fetch(`${config2.apiUrl}/api/public/seo/register-schema`, {
|
|
26324
26313
|
method: "POST",
|
|
26325
26314
|
headers: {
|
|
26326
26315
|
"Content-Type": "application/json",
|
|
@@ -26344,7 +26333,7 @@ async function uploadSchemas(pages, globalSchema, config2) {
|
|
|
26344
26333
|
}
|
|
26345
26334
|
}
|
|
26346
26335
|
}
|
|
26347
|
-
var APP_DIRS = ["app",
|
|
26336
|
+
var APP_DIRS = ["app", path12.join("src", "app")];
|
|
26348
26337
|
var CARD_FILE = /^(opengraph-image|twitter-image)\b.*\.(png|jpe?g|gif|webp)$/i;
|
|
26349
26338
|
function safeExists(p) {
|
|
26350
26339
|
try {
|
|
@@ -26364,19 +26353,19 @@ function findPageCards(cwd) {
|
|
|
26364
26353
|
}
|
|
26365
26354
|
for (const entry of entries) {
|
|
26366
26355
|
if (entry.name.startsWith(".") || entry.name === "node_modules") continue;
|
|
26367
|
-
const full =
|
|
26356
|
+
const full = path12.join(dir, entry.name);
|
|
26368
26357
|
if (entry.isDirectory()) walk(full);
|
|
26369
26358
|
else if (CARD_FILE.test(entry.name)) found.push(full);
|
|
26370
26359
|
}
|
|
26371
26360
|
};
|
|
26372
|
-
for (const rel of APP_DIRS) walk(
|
|
26361
|
+
for (const rel of APP_DIRS) walk(path12.join(cwd, rel));
|
|
26373
26362
|
return found;
|
|
26374
26363
|
}
|
|
26375
26364
|
function readOgWiring(cwd) {
|
|
26376
26365
|
const siteCard = ["public/og.png", "public/og.jpg", "public/opengraph.png"].some(
|
|
26377
|
-
(rel) => safeExists(
|
|
26366
|
+
(rel) => safeExists(path12.join(cwd, rel))
|
|
26378
26367
|
);
|
|
26379
|
-
const layoutPath = ["app/layout.tsx", "src/app/layout.tsx"].map((rel) =>
|
|
26368
|
+
const layoutPath = ["app/layout.tsx", "src/app/layout.tsx"].map((rel) => path12.join(cwd, rel)).find(safeExists);
|
|
26380
26369
|
let layout = "";
|
|
26381
26370
|
if (layoutPath) {
|
|
26382
26371
|
try {
|
|
@@ -26443,7 +26432,7 @@ var SSR_BAILOUT_FIX = `Keep the layout: ${LAYOUT_ALREADY_DEFERS}, so it is not t
|
|
|
26443
26432
|
var ANALYTICS_WRAPPER_FIX = `Remove the <AnalyticsProvider> wrapper: ${LAYOUT_ALREADY_DEFERS} (configure it with analytics={{ ... }}). Track custom events with trackEvent / trackConversion from @sonordev/site-kit/analytics, which need no provider, instead of useAnalytics(). ` + LEGACY_STOPGAP;
|
|
26444
26433
|
|
|
26445
26434
|
// src/cli/agent/checks.ts
|
|
26446
|
-
var
|
|
26435
|
+
var API_URL = process.env.SONOR_API_URL || "https://api.sonor.io";
|
|
26447
26436
|
async function readFileOrNull(p) {
|
|
26448
26437
|
try {
|
|
26449
26438
|
return await fs3.readFile(p, "utf-8");
|
|
@@ -26453,7 +26442,7 @@ async function readFileOrNull(p) {
|
|
|
26453
26442
|
}
|
|
26454
26443
|
async function findFirst(cwd, candidates) {
|
|
26455
26444
|
for (const rel of candidates) {
|
|
26456
|
-
const full =
|
|
26445
|
+
const full = path12.join(cwd, rel);
|
|
26457
26446
|
if (await readFileOrNull(full)) return full;
|
|
26458
26447
|
}
|
|
26459
26448
|
return null;
|
|
@@ -26505,7 +26494,7 @@ function checkApiKeyEnv() {
|
|
|
26505
26494
|
};
|
|
26506
26495
|
}
|
|
26507
26496
|
async function checkPackageInstalled(cwd) {
|
|
26508
|
-
const raw = await readFileOrNull(
|
|
26497
|
+
const raw = await readFileOrNull(path12.join(cwd, "package.json"));
|
|
26509
26498
|
if (!raw) {
|
|
26510
26499
|
return {
|
|
26511
26500
|
id: "package.installed",
|
|
@@ -26569,7 +26558,7 @@ async function checkSiteKitLayout(cwd) {
|
|
|
26569
26558
|
};
|
|
26570
26559
|
}
|
|
26571
26560
|
const content = await readFileOrNull(layoutPath) || "";
|
|
26572
|
-
const rel =
|
|
26561
|
+
const rel = path12.relative(cwd, layoutPath);
|
|
26573
26562
|
if (content.includes("SiteKitLayout")) {
|
|
26574
26563
|
return {
|
|
26575
26564
|
id: "layout.sitekit",
|
|
@@ -26625,7 +26614,7 @@ async function checkSitemap(cwd) {
|
|
|
26625
26614
|
};
|
|
26626
26615
|
}
|
|
26627
26616
|
async function checkPostbuildSitemap(cwd) {
|
|
26628
|
-
const raw = await readFileOrNull(
|
|
26617
|
+
const raw = await readFileOrNull(path12.join(cwd, "package.json"));
|
|
26629
26618
|
let pkg = {};
|
|
26630
26619
|
try {
|
|
26631
26620
|
pkg = raw ? JSON.parse(raw) : {};
|
|
@@ -26662,18 +26651,18 @@ async function checkPostbuildSitemap(cwd) {
|
|
|
26662
26651
|
async function checkApiReachable(timeoutMs = 5e3) {
|
|
26663
26652
|
const key = process.env.SONOR_API_KEY;
|
|
26664
26653
|
try {
|
|
26665
|
-
const res = await fetch(`${
|
|
26654
|
+
const res = await fetch(`${API_URL}/health`, {
|
|
26666
26655
|
headers: key ? { "x-api-key": key } : {},
|
|
26667
26656
|
signal: AbortSignal.timeout(timeoutMs)
|
|
26668
26657
|
});
|
|
26669
26658
|
if (res.ok) {
|
|
26670
|
-
return { id: "api.reachable", title: "Sonor API", level: "ok", message: `Reachable (${
|
|
26659
|
+
return { id: "api.reachable", title: "Sonor API", level: "ok", message: `Reachable (${API_URL})` };
|
|
26671
26660
|
}
|
|
26672
26661
|
return {
|
|
26673
26662
|
id: "api.reachable",
|
|
26674
26663
|
title: "Sonor API",
|
|
26675
26664
|
level: "warn",
|
|
26676
|
-
message: `HTTP ${res.status} from ${
|
|
26665
|
+
message: `HTTP ${res.status} from ${API_URL}`
|
|
26677
26666
|
};
|
|
26678
26667
|
} catch (err) {
|
|
26679
26668
|
return {
|
|
@@ -26698,7 +26687,7 @@ async function checkKeyValid(timeoutMs = 8e3) {
|
|
|
26698
26687
|
};
|
|
26699
26688
|
}
|
|
26700
26689
|
try {
|
|
26701
|
-
const res = await fetch(`${
|
|
26690
|
+
const res = await fetch(`${API_URL}/api/public/seo/verify-api-key`, {
|
|
26702
26691
|
headers: { "x-api-key": key },
|
|
26703
26692
|
signal: AbortSignal.timeout(timeoutMs)
|
|
26704
26693
|
});
|
|
@@ -26801,7 +26790,7 @@ async function checkClientAuth(timeoutMs = 8e3) {
|
|
|
26801
26790
|
}
|
|
26802
26791
|
const qs2 = host ? `?host=${encodeURIComponent(host)}` : "";
|
|
26803
26792
|
try {
|
|
26804
|
-
const res = await fetch(`${
|
|
26793
|
+
const res = await fetch(`${API_URL}/api/public/site-token/status${qs2}`, {
|
|
26805
26794
|
headers: { "x-api-key": key },
|
|
26806
26795
|
signal: AbortSignal.timeout(timeoutMs)
|
|
26807
26796
|
});
|
|
@@ -26946,7 +26935,7 @@ async function checkSsrRenderFromUrl(url, timeoutMs = 12e3) {
|
|
|
26946
26935
|
}
|
|
26947
26936
|
}
|
|
26948
26937
|
async function checkSsrRenderFromBuild(cwd) {
|
|
26949
|
-
const appDir =
|
|
26938
|
+
const appDir = path12.join(cwd, ".next", "server", "app");
|
|
26950
26939
|
let entries;
|
|
26951
26940
|
try {
|
|
26952
26941
|
entries = await fs3.readdir(appDir);
|
|
@@ -26969,7 +26958,7 @@ async function checkSsrRenderFromBuild(cwd) {
|
|
|
26969
26958
|
detail: "The root route may be fully dynamic. Pass --url to verify a running instance."
|
|
26970
26959
|
};
|
|
26971
26960
|
}
|
|
26972
|
-
const html = await readFileOrNull(
|
|
26961
|
+
const html = await readFileOrNull(path12.join(appDir, htmlName)) || "";
|
|
26973
26962
|
const { rendered, contentTags } = looksServerRendered(html);
|
|
26974
26963
|
if (rendered) {
|
|
26975
26964
|
return {
|
|
@@ -26992,7 +26981,7 @@ async function checkNetlifyMiddleware(cwd) {
|
|
|
26992
26981
|
const runtimeRe = /runtime\s*[:=]\s*['"](nodejs|edge)['"]/;
|
|
26993
26982
|
const proxyFiles = ["proxy.ts", "proxy.js", "src/proxy.ts", "src/proxy.js"];
|
|
26994
26983
|
for (const rel of proxyFiles) {
|
|
26995
|
-
const content = await readFileOrNull(
|
|
26984
|
+
const content = await readFileOrNull(path12.join(cwd, rel));
|
|
26996
26985
|
if (content === null) continue;
|
|
26997
26986
|
if (runtimeRe.test(content)) {
|
|
26998
26987
|
return {
|
|
@@ -27009,7 +26998,7 @@ async function checkNetlifyMiddleware(cwd) {
|
|
|
27009
26998
|
}
|
|
27010
26999
|
const middlewareFiles = ["middleware.ts", "middleware.js", "src/middleware.ts", "src/middleware.js"];
|
|
27011
27000
|
for (const rel of middlewareFiles) {
|
|
27012
|
-
const content = await readFileOrNull(
|
|
27001
|
+
const content = await readFileOrNull(path12.join(cwd, rel));
|
|
27013
27002
|
if (content === null) continue;
|
|
27014
27003
|
if (/runtime\s*[:=]\s*['"]nodejs['"]/.test(content)) {
|
|
27015
27004
|
return {
|
|
@@ -27036,7 +27025,7 @@ async function checkNetlifyMiddleware(cwd) {
|
|
|
27036
27025
|
}
|
|
27037
27026
|
async function checkImageDimsDrift(cwd) {
|
|
27038
27027
|
const scanRoots = ["app", "src/app", "components", "src/components"];
|
|
27039
|
-
const publicDir =
|
|
27028
|
+
const publicDir = path12.join(cwd, "public");
|
|
27040
27029
|
const files = [];
|
|
27041
27030
|
async function walk(dir, depth) {
|
|
27042
27031
|
if (depth > 4) return;
|
|
@@ -27048,19 +27037,19 @@ async function checkImageDimsDrift(cwd) {
|
|
|
27048
27037
|
}
|
|
27049
27038
|
for (const e of entries) {
|
|
27050
27039
|
if (e.name === "node_modules" || e.name.startsWith(".")) continue;
|
|
27051
|
-
const full =
|
|
27040
|
+
const full = path12.join(dir, e.name);
|
|
27052
27041
|
if (e.isDirectory()) await walk(full, depth + 1);
|
|
27053
27042
|
else if (/\.(tsx|jsx)$/.test(e.name)) files.push(full);
|
|
27054
27043
|
}
|
|
27055
27044
|
}
|
|
27056
|
-
for (const root of scanRoots) await walk(
|
|
27045
|
+
for (const root of scanRoots) await walk(path12.join(cwd, root), 0);
|
|
27057
27046
|
if (files.length === 0) {
|
|
27058
27047
|
return { id: "images.dims-drift", title: "Image dims vs SVG", level: "skip", message: "No component files found" };
|
|
27059
27048
|
}
|
|
27060
27049
|
const viewBoxCache = /* @__PURE__ */ new Map();
|
|
27061
27050
|
async function svgAspect(publicPath) {
|
|
27062
27051
|
if (viewBoxCache.has(publicPath)) return viewBoxCache.get(publicPath);
|
|
27063
|
-
const svg = await readFileOrNull(
|
|
27052
|
+
const svg = await readFileOrNull(path12.join(publicDir, publicPath.replace(/^\//, "")));
|
|
27064
27053
|
let aspect = null;
|
|
27065
27054
|
if (svg) {
|
|
27066
27055
|
const vb = svg.match(/viewBox="([\d.\s-]+)"/);
|
|
@@ -27087,7 +27076,7 @@ async function checkImageDimsDrift(cwd) {
|
|
|
27087
27076
|
const drift = Math.abs(declared - actual) / actual;
|
|
27088
27077
|
if (drift > 0.02) {
|
|
27089
27078
|
drifts.push(
|
|
27090
|
-
`${
|
|
27079
|
+
`${path12.relative(cwd, file)}: ${src} is ${actual.toFixed(2)}:1 but width/height declare ${declared.toFixed(2)}:1 (${Math.round(drift * 100)}% off)`
|
|
27091
27080
|
);
|
|
27092
27081
|
}
|
|
27093
27082
|
}
|
|
@@ -27203,8 +27192,8 @@ async function statusCommand(options) {
|
|
|
27203
27192
|
|
|
27204
27193
|
// src/og/pages.ts
|
|
27205
27194
|
var DYNAMIC = "*";
|
|
27206
|
-
function pathSegments(
|
|
27207
|
-
return
|
|
27195
|
+
function pathSegments(path29) {
|
|
27196
|
+
return path29.split("/").filter(Boolean);
|
|
27208
27197
|
}
|
|
27209
27198
|
function stripBrandSuffix(title, brand) {
|
|
27210
27199
|
const cleaned = title.replace(/\s*[|–—-]\s*[^|–—-]+$/, "").trim();
|
|
@@ -27212,13 +27201,13 @@ function stripBrandSuffix(title, brand) {
|
|
|
27212
27201
|
if (brand && cleaned.toLowerCase() === brand.toLowerCase()) return title.trim();
|
|
27213
27202
|
return cleaned;
|
|
27214
27203
|
}
|
|
27215
|
-
function titleFromPath(
|
|
27216
|
-
const last = pathSegments(
|
|
27204
|
+
function titleFromPath(path29) {
|
|
27205
|
+
const last = pathSegments(path29).filter((s) => s !== DYNAMIC).pop();
|
|
27217
27206
|
if (!last) return "Home";
|
|
27218
27207
|
return last.replace(/[-_]+/g, " ").replace(/\b\w/g, (c) => c.toUpperCase()).trim();
|
|
27219
27208
|
}
|
|
27220
|
-
function kickerFromPath(
|
|
27221
|
-
const parts = pathSegments(
|
|
27209
|
+
function kickerFromPath(path29, fallback) {
|
|
27210
|
+
const parts = pathSegments(path29);
|
|
27222
27211
|
const section = parts.includes(DYNAMIC) ? parts.filter((s) => s !== DYNAMIC) : parts.slice(0, -1);
|
|
27223
27212
|
if (!section.length) return fallback;
|
|
27224
27213
|
return section.join(" / ").replace(/[-_]+/g, " ");
|
|
@@ -27242,8 +27231,8 @@ function kickerIsRedundant(kicker, title) {
|
|
|
27242
27231
|
const titleWords = new Set(t.split(" "));
|
|
27243
27232
|
return k2.split(" ").every((w) => titleWords.has(w));
|
|
27244
27233
|
}
|
|
27245
|
-
function slugForPath(
|
|
27246
|
-
const segments = pathSegments(
|
|
27234
|
+
function slugForPath(path29) {
|
|
27235
|
+
const segments = pathSegments(path29);
|
|
27247
27236
|
if (!segments.length) return "home";
|
|
27248
27237
|
return segments.map((s) => s === DYNAMIC ? "any" : s).join("-").replace(/[^a-zA-Z0-9]+/g, "-").replace(/^-+|-+$/g, "").toLowerCase();
|
|
27249
27238
|
}
|
|
@@ -27297,10 +27286,10 @@ function findChrome() {
|
|
|
27297
27286
|
}
|
|
27298
27287
|
return null;
|
|
27299
27288
|
}
|
|
27300
|
-
async function
|
|
27289
|
+
async function loadConfig2(cwd) {
|
|
27301
27290
|
const candidates = ["og.config.ts", "og.config.mts", "og.config.mjs", "og.config.js"];
|
|
27302
27291
|
for (const rel of candidates) {
|
|
27303
|
-
const full =
|
|
27292
|
+
const full = path12.join(cwd, rel);
|
|
27304
27293
|
if (!existsSync(full)) continue;
|
|
27305
27294
|
try {
|
|
27306
27295
|
const mod = await import(
|
|
@@ -27325,7 +27314,7 @@ async function loadConfig4(cwd) {
|
|
|
27325
27314
|
return null;
|
|
27326
27315
|
}
|
|
27327
27316
|
async function seedConfig(cwd) {
|
|
27328
|
-
let name =
|
|
27317
|
+
let name = path12.basename(cwd).replace(/-nextjs$/, "").replace(/-/g, " ");
|
|
27329
27318
|
let accent = "#111111";
|
|
27330
27319
|
let logo;
|
|
27331
27320
|
try {
|
|
@@ -27338,7 +27327,7 @@ async function seedConfig(cwd) {
|
|
|
27338
27327
|
} catch {
|
|
27339
27328
|
}
|
|
27340
27329
|
for (const candidate of ["/logo-mark.svg", "/logo.svg", "/logohorizontal.svg"]) {
|
|
27341
|
-
if (existsSync(
|
|
27330
|
+
if (existsSync(path12.join(cwd, "public", candidate))) {
|
|
27342
27331
|
logo = candidate;
|
|
27343
27332
|
break;
|
|
27344
27333
|
}
|
|
@@ -27352,14 +27341,14 @@ async function seedConfig(cwd) {
|
|
|
27352
27341
|
}
|
|
27353
27342
|
function inlinePublicPaths(html, cwd) {
|
|
27354
27343
|
return html.replace(/src="(\/[^"]+)"/g, (_3, p) => {
|
|
27355
|
-
const full =
|
|
27344
|
+
const full = path12.join(cwd, "public", p);
|
|
27356
27345
|
return existsSync(full) ? `src="file://${full}"` : `src="${p}"`;
|
|
27357
27346
|
});
|
|
27358
27347
|
}
|
|
27359
27348
|
async function renderCard(config2, outPath, cwd, chrome, tmpSuffix) {
|
|
27360
|
-
const tmpHtml =
|
|
27349
|
+
const tmpHtml = path12.join(cwd, `.sonor-og-${tmpSuffix}.html`);
|
|
27361
27350
|
try {
|
|
27362
|
-
await fs3.mkdir(
|
|
27351
|
+
await fs3.mkdir(path12.dirname(outPath), { recursive: true });
|
|
27363
27352
|
await fs3.writeFile(tmpHtml, inlinePublicPaths(buildOgHtml(config2), cwd));
|
|
27364
27353
|
const { stdout } = await execFileAsync5(
|
|
27365
27354
|
chrome,
|
|
@@ -27394,7 +27383,7 @@ function parseReport(dom) {
|
|
|
27394
27383
|
}
|
|
27395
27384
|
async function compressCard(pngPath, cwd) {
|
|
27396
27385
|
try {
|
|
27397
|
-
const require_ = (await import('module')).createRequire(
|
|
27386
|
+
const require_ = (await import('module')).createRequire(path12.join(cwd, "package.json"));
|
|
27398
27387
|
const sharp = require_("sharp");
|
|
27399
27388
|
const jpgPath = pngPath.replace(/\.png$/, ".jpg");
|
|
27400
27389
|
await sharp(pngPath).jpeg({ quality: 84, mozjpeg: true }).toFile(jpgPath);
|
|
@@ -27411,13 +27400,13 @@ function discoverDynamicSegments(appDir) {
|
|
|
27411
27400
|
if (!entry.isDirectory()) continue;
|
|
27412
27401
|
if (entry.name.startsWith("_") || entry.name.startsWith(".")) continue;
|
|
27413
27402
|
if (entry.name === "api" || entry.name === "node_modules") continue;
|
|
27414
|
-
const full =
|
|
27403
|
+
const full = path12.join(dir, entry.name);
|
|
27415
27404
|
const isGroup = entry.name.startsWith("(") && entry.name.endsWith(")");
|
|
27416
27405
|
const isDynamic = entry.name.startsWith("[") && entry.name.endsWith("]");
|
|
27417
27406
|
const nextUrl = isGroup || isDynamic ? urlSegments : [...urlSegments, entry.name];
|
|
27418
27407
|
const nextPattern = isGroup ? pattern : [...pattern, isDynamic ? DYNAMIC : entry.name];
|
|
27419
27408
|
if (isDynamic) {
|
|
27420
|
-
const hasPage = ["tsx", "jsx", "ts", "js"].some((ext2) => existsSync(
|
|
27409
|
+
const hasPage = ["tsx", "jsx", "ts", "js"].some((ext2) => existsSync(path12.join(full, `page.${ext2}`)));
|
|
27421
27410
|
if (hasPage) {
|
|
27422
27411
|
found.push({ dir: full, path: `/${nextPattern.join("/")}`, parent: `/${urlSegments.join("/")}` });
|
|
27423
27412
|
}
|
|
@@ -27493,7 +27482,7 @@ async function runOg(options) {
|
|
|
27493
27482
|
errors: [{ code: "chrome_missing", message: "No Chrome or Chromium binary found", fix: "Install Chrome, or set SONOR_CHROME_PATH to its path." }]
|
|
27494
27483
|
};
|
|
27495
27484
|
}
|
|
27496
|
-
let config2 = await
|
|
27485
|
+
let config2 = await loadConfig2(cwd);
|
|
27497
27486
|
let seeded = false;
|
|
27498
27487
|
if (!config2) {
|
|
27499
27488
|
config2 = await seedConfig(cwd);
|
|
@@ -27501,7 +27490,7 @@ async function runOg(options) {
|
|
|
27501
27490
|
console.log(source_default.yellow(" ! No og.config.ts \u2014 generating a seed card from Sonor brand data."));
|
|
27502
27491
|
console.log(source_default.gray(" The site owns its theme: add og.config.ts (defineOgCard) with the real palette."));
|
|
27503
27492
|
}
|
|
27504
|
-
const outPath =
|
|
27493
|
+
const outPath = path12.resolve(cwd, options.out || "public/og.png");
|
|
27505
27494
|
let clean = true;
|
|
27506
27495
|
let cardKeyFix = null;
|
|
27507
27496
|
let pageCardsWritten = 0;
|
|
@@ -27511,8 +27500,8 @@ async function runOg(options) {
|
|
|
27511
27500
|
const report = await renderCard(config2, outPath, cwd, chrome, "site");
|
|
27512
27501
|
spinner.stop();
|
|
27513
27502
|
console.log(source_default.bold(` Site card${seeded ? source_default.gray(" (seed)") : ""}`));
|
|
27514
|
-
clean = reportCard(`${
|
|
27515
|
-
checks.push(cardCheck("site card",
|
|
27503
|
+
clean = reportCard(`${path12.relative(cwd, outPath)} \u2014 1200x630`, report) && clean;
|
|
27504
|
+
checks.push(cardCheck("site card", path12.relative(cwd, outPath), report));
|
|
27516
27505
|
} catch (err) {
|
|
27517
27506
|
const message = err instanceof Error ? err.message.split("\n")[0] : String(err);
|
|
27518
27507
|
spinner.fail(`Render failed: ${message}`);
|
|
@@ -27575,16 +27564,16 @@ async function runOg(options) {
|
|
|
27575
27564
|
const pageConfig = pageCardConfig(config2, route, brand);
|
|
27576
27565
|
const dir = route.dir ?? routeOutputDir(appDir, route.path);
|
|
27577
27566
|
for (const ext2 of ["png", "jpg", "jpeg"]) {
|
|
27578
|
-
await fs3.rm(
|
|
27567
|
+
await fs3.rm(path12.join(dir, `opengraph-image.${ext2}`), { force: true });
|
|
27579
27568
|
}
|
|
27580
|
-
const png =
|
|
27569
|
+
const png = path12.join(dir, "opengraph-image.png");
|
|
27581
27570
|
const report = await renderCard(pageConfig, png, cwd, chrome, `page-${i}`);
|
|
27582
27571
|
const file = await compressCard(png, cwd);
|
|
27583
27572
|
return { route, file, report };
|
|
27584
27573
|
});
|
|
27585
27574
|
for (const { route, file, report } of reports) {
|
|
27586
|
-
clean = reportCard(`${route.path} ${source_default.gray(
|
|
27587
|
-
checks.push(cardCheck(route.path,
|
|
27575
|
+
clean = reportCard(`${route.path} ${source_default.gray(path12.relative(cwd, file))}`, report) && clean;
|
|
27576
|
+
checks.push(cardCheck(route.path, path12.relative(cwd, file), report));
|
|
27588
27577
|
}
|
|
27589
27578
|
pageCardsWritten = reports.length;
|
|
27590
27579
|
const bytes = await totalBytes(reports.map((r) => r.file));
|
|
@@ -27595,13 +27584,13 @@ async function runOg(options) {
|
|
|
27595
27584
|
}
|
|
27596
27585
|
if (options.preview !== false) {
|
|
27597
27586
|
try {
|
|
27598
|
-
const require_ = (await import('module')).createRequire(
|
|
27587
|
+
const require_ = (await import('module')).createRequire(path12.join(cwd, "package.json"));
|
|
27599
27588
|
const sharp = require_("sharp");
|
|
27600
|
-
const previewPath =
|
|
27601
|
-
await fs3.mkdir(
|
|
27589
|
+
const previewPath = path12.join(cwd, ".sonor", "og-preview.png");
|
|
27590
|
+
await fs3.mkdir(path12.dirname(previewPath), { recursive: true });
|
|
27602
27591
|
await sharp(outPath).resize(300).toFile(previewPath);
|
|
27603
27592
|
console.log("");
|
|
27604
|
-
console.log(source_default.gray(` Thumbnail check: ${
|
|
27593
|
+
console.log(source_default.gray(` Thumbnail check: ${path12.relative(cwd, previewPath)} \u2014 if text is mush there, fix the card.`));
|
|
27605
27594
|
} catch {
|
|
27606
27595
|
console.log(source_default.gray(" (sharp not resolvable \u2014 skipped the 300px preview)"));
|
|
27607
27596
|
}
|
|
@@ -27660,15 +27649,15 @@ function routeOutputDir(appDir, urlPath) {
|
|
|
27660
27649
|
const segments = urlPath.split("/").filter(Boolean);
|
|
27661
27650
|
let dir = appDir;
|
|
27662
27651
|
for (const segment of segments) {
|
|
27663
|
-
const direct =
|
|
27652
|
+
const direct = path12.join(dir, segment);
|
|
27664
27653
|
if (existsSync(direct)) {
|
|
27665
27654
|
dir = direct;
|
|
27666
27655
|
continue;
|
|
27667
27656
|
}
|
|
27668
27657
|
const group = existsSync(dir) ? readdirSync(dir, { withFileTypes: true }).find(
|
|
27669
|
-
(e) => e.isDirectory() && e.name.startsWith("(") && e.name.endsWith(")") && existsSync(
|
|
27658
|
+
(e) => e.isDirectory() && e.name.startsWith("(") && e.name.endsWith(")") && existsSync(path12.join(dir, e.name, segment))
|
|
27670
27659
|
) : void 0;
|
|
27671
|
-
dir = group ?
|
|
27660
|
+
dir = group ? path12.join(dir, group.name, segment) : direct;
|
|
27672
27661
|
}
|
|
27673
27662
|
return dir;
|
|
27674
27663
|
}
|
|
@@ -27683,7 +27672,7 @@ async function totalBytes(files) {
|
|
|
27683
27672
|
return total;
|
|
27684
27673
|
}
|
|
27685
27674
|
async function siteDomain(cwd) {
|
|
27686
|
-
const envFile =
|
|
27675
|
+
const envFile = path12.join(cwd, ".env.local");
|
|
27687
27676
|
if (existsSync(envFile)) {
|
|
27688
27677
|
const env3 = await fs3.readFile(envFile, "utf-8").catch(() => "");
|
|
27689
27678
|
const url = env3.match(/^NEXT_PUBLIC_SITE_URL=(.+)$/m)?.[1]?.trim();
|
|
@@ -27808,14 +27797,14 @@ var hs = new RegExp(pe, "g");
|
|
|
27808
27797
|
var as = /\\\\/g;
|
|
27809
27798
|
var ls = /\\{/g;
|
|
27810
27799
|
var cs = /\\}/g;
|
|
27811
|
-
var
|
|
27800
|
+
var fs22 = /\\,/g;
|
|
27812
27801
|
var us = /\\./g;
|
|
27813
27802
|
var ds = 1e5;
|
|
27814
27803
|
function Ht(n5) {
|
|
27815
27804
|
return isNaN(n5) ? n5.charCodeAt(0) : parseInt(n5, 10);
|
|
27816
27805
|
}
|
|
27817
27806
|
function ps(n5) {
|
|
27818
|
-
return n5.replace(as, fe).replace(ls, ue).replace(cs, qt).replace(
|
|
27807
|
+
return n5.replace(as, fe).replace(ls, ue).replace(cs, qt).replace(fs22, de).replace(us, pe);
|
|
27819
27808
|
}
|
|
27820
27809
|
function ms(n5) {
|
|
27821
27810
|
return n5.replace(is, "\\").replace(rs, "{").replace(ns, "}").replace(os5, ",").replace(hs, ".");
|
|
@@ -30847,10 +30836,10 @@ function unifiedDiff(before, after, filePath, context = 2) {
|
|
|
30847
30836
|
return lines.join("\n");
|
|
30848
30837
|
}
|
|
30849
30838
|
function ext(filePath) {
|
|
30850
|
-
return
|
|
30839
|
+
return path12.extname(filePath).toLowerCase();
|
|
30851
30840
|
}
|
|
30852
30841
|
function basename(filePath) {
|
|
30853
|
-
return
|
|
30842
|
+
return path12.basename(filePath).toLowerCase();
|
|
30854
30843
|
}
|
|
30855
30844
|
var CODE_EXT = /* @__PURE__ */ new Set([".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"]);
|
|
30856
30845
|
var TEXT_EXT = /* @__PURE__ */ new Set([...CODE_EXT, ".css", ".scss", ".json", ".md", ".mdx"]);
|
|
@@ -31004,7 +30993,7 @@ var IGNORE = [
|
|
|
31004
30993
|
];
|
|
31005
30994
|
async function listFiles(cwd, onlyPath) {
|
|
31006
30995
|
if (onlyPath) {
|
|
31007
|
-
const rel =
|
|
30996
|
+
const rel = path12.isAbsolute(onlyPath) ? path12.relative(cwd, onlyPath) : onlyPath;
|
|
31008
30997
|
return [rel];
|
|
31009
30998
|
}
|
|
31010
30999
|
const matches = await Ze(SCAN_PATTERNS, { cwd, ignore: IGNORE, dot: true, nodir: true });
|
|
@@ -31016,7 +31005,7 @@ async function runCodemod(options) {
|
|
|
31016
31005
|
const files = await listFiles(cwd, onlyPath);
|
|
31017
31006
|
const changes = [];
|
|
31018
31007
|
for (const rel of files) {
|
|
31019
|
-
const full =
|
|
31008
|
+
const full = path12.join(cwd, rel);
|
|
31020
31009
|
let source;
|
|
31021
31010
|
try {
|
|
31022
31011
|
source = await fs3.readFile(full, "utf-8");
|
|
@@ -31165,9 +31154,9 @@ function findManifestPath() {
|
|
|
31165
31154
|
const baseDir = typeof __dirname !== "undefined" ? __dirname : process.cwd();
|
|
31166
31155
|
let dir = baseDir;
|
|
31167
31156
|
for (let i = 0; i < 8; i++) {
|
|
31168
|
-
const candidate =
|
|
31157
|
+
const candidate = path12.join(dir, "agent-manifest.json");
|
|
31169
31158
|
if (fs__default.existsSync(candidate)) return candidate;
|
|
31170
|
-
const parent =
|
|
31159
|
+
const parent = path12.dirname(dir);
|
|
31171
31160
|
if (parent === dir) break;
|
|
31172
31161
|
dir = parent;
|
|
31173
31162
|
}
|
|
@@ -31309,8 +31298,8 @@ async function syncPagesToPortal(apiUrl, apiKey, dryRun) {
|
|
|
31309
31298
|
}
|
|
31310
31299
|
function findAppDir() {
|
|
31311
31300
|
const candidates = [
|
|
31312
|
-
|
|
31313
|
-
|
|
31301
|
+
path12.join(process.cwd(), "app"),
|
|
31302
|
+
path12.join(process.cwd(), "src", "app")
|
|
31314
31303
|
];
|
|
31315
31304
|
for (const candidate of candidates) {
|
|
31316
31305
|
if (existsSync(candidate)) {
|
|
@@ -31320,7 +31309,7 @@ function findAppDir() {
|
|
|
31320
31309
|
return null;
|
|
31321
31310
|
}
|
|
31322
31311
|
function discoverPages(appDir, currentPath = "", pages = []) {
|
|
31323
|
-
const fullPath =
|
|
31312
|
+
const fullPath = path12.join(appDir, currentPath);
|
|
31324
31313
|
if (!existsSync(fullPath)) {
|
|
31325
31314
|
return pages;
|
|
31326
31315
|
}
|
|
@@ -31342,7 +31331,7 @@ function discoverPages(appDir, currentPath = "", pages = []) {
|
|
|
31342
31331
|
});
|
|
31343
31332
|
}
|
|
31344
31333
|
for (const entry of entries) {
|
|
31345
|
-
const entryPath =
|
|
31334
|
+
const entryPath = path12.join(fullPath, entry);
|
|
31346
31335
|
const stat = statSync(entryPath);
|
|
31347
31336
|
if (stat.isDirectory()) {
|
|
31348
31337
|
const folderName = entry.toLowerCase();
|
|
@@ -31355,21 +31344,21 @@ function discoverPages(appDir, currentPath = "", pages = []) {
|
|
|
31355
31344
|
if (entry.startsWith("_")) {
|
|
31356
31345
|
continue;
|
|
31357
31346
|
}
|
|
31358
|
-
discoverPages(appDir,
|
|
31347
|
+
discoverPages(appDir, path12.join(currentPath, entry), pages);
|
|
31359
31348
|
}
|
|
31360
31349
|
}
|
|
31361
31350
|
return pages;
|
|
31362
31351
|
}
|
|
31363
31352
|
function findNextBuildDir() {
|
|
31364
31353
|
const cwd = process.cwd();
|
|
31365
|
-
const candidate =
|
|
31354
|
+
const candidate = path12.join(cwd, ".next", "server", "app");
|
|
31366
31355
|
return existsSync(candidate) ? candidate : null;
|
|
31367
31356
|
}
|
|
31368
31357
|
function extractPageContent(buildDir, pagePath) {
|
|
31369
31358
|
const baseName = pagePath === "/" ? "index" : pagePath.replace(/^\//, "");
|
|
31370
31359
|
const htmlCandidates = [
|
|
31371
|
-
|
|
31372
|
-
|
|
31360
|
+
path12.join(buildDir, `${baseName}.html`),
|
|
31361
|
+
path12.join(buildDir, baseName, "index.html")
|
|
31373
31362
|
];
|
|
31374
31363
|
let html = null;
|
|
31375
31364
|
for (const candidate of htmlCandidates) {
|
|
@@ -31383,8 +31372,8 @@ function extractPageContent(buildDir, pagePath) {
|
|
|
31383
31372
|
}
|
|
31384
31373
|
}
|
|
31385
31374
|
const rscCandidates = [
|
|
31386
|
-
|
|
31387
|
-
|
|
31375
|
+
path12.join(buildDir, `${baseName}.rsc`),
|
|
31376
|
+
path12.join(buildDir, baseName, "index.rsc")
|
|
31388
31377
|
];
|
|
31389
31378
|
let rsc = null;
|
|
31390
31379
|
for (const candidate of rscCandidates) {
|
|
@@ -31495,7 +31484,7 @@ var BLOG_EXTENSIONS = [".mdx", ".md"];
|
|
|
31495
31484
|
function findBlogDir() {
|
|
31496
31485
|
const cwd = process.cwd();
|
|
31497
31486
|
for (const dir of BLOG_DIRS) {
|
|
31498
|
-
const full =
|
|
31487
|
+
const full = path12.join(cwd, dir);
|
|
31499
31488
|
if (existsSync(full)) return full;
|
|
31500
31489
|
}
|
|
31501
31490
|
return null;
|
|
@@ -31505,7 +31494,7 @@ async function discoverBlogPosts(dir) {
|
|
|
31505
31494
|
async function walk(currentDir) {
|
|
31506
31495
|
const entries = readdirSync(currentDir);
|
|
31507
31496
|
for (const entry of entries) {
|
|
31508
|
-
const fullPath =
|
|
31497
|
+
const fullPath = path12.join(currentDir, entry);
|
|
31509
31498
|
const stat = statSync(fullPath);
|
|
31510
31499
|
if (stat.isDirectory()) {
|
|
31511
31500
|
await walk(fullPath);
|
|
@@ -31522,7 +31511,7 @@ async function discoverBlogPosts(dir) {
|
|
|
31522
31511
|
date: frontmatter.date,
|
|
31523
31512
|
tags: frontmatter.tags,
|
|
31524
31513
|
author: frontmatter.author,
|
|
31525
|
-
filePath:
|
|
31514
|
+
filePath: path12.relative(process.cwd(), fullPath)
|
|
31526
31515
|
});
|
|
31527
31516
|
}
|
|
31528
31517
|
}
|
|
@@ -31555,7 +31544,7 @@ async function syncBlogToPortal(_apiUrl, _apiKey, _dryRun) {
|
|
|
31555
31544
|
}
|
|
31556
31545
|
const spinner = ora("Discovering blog posts...").start();
|
|
31557
31546
|
const posts = await discoverBlogPosts(blogDir);
|
|
31558
|
-
spinner.succeed(`Found ${posts.length} local markdown post(s) in ${
|
|
31547
|
+
spinner.succeed(`Found ${posts.length} local markdown post(s) in ${path12.relative(process.cwd(), blogDir)}`);
|
|
31559
31548
|
if (posts.length === 0) return;
|
|
31560
31549
|
for (const post of posts.slice(0, 10)) {
|
|
31561
31550
|
console.log(source_default.gray(` ${post.slug}: ${post.title || "(no title)"}`));
|
|
@@ -31572,11 +31561,11 @@ async function discoverSchemaUsage(appDir) {
|
|
|
31572
31561
|
async function walk(currentDir, currentPath = "") {
|
|
31573
31562
|
const entries = readdirSync(currentDir);
|
|
31574
31563
|
for (const entry of entries) {
|
|
31575
|
-
const fullPath =
|
|
31564
|
+
const fullPath = path12.join(currentDir, entry);
|
|
31576
31565
|
const stat = statSync(fullPath);
|
|
31577
31566
|
if (stat.isDirectory()) {
|
|
31578
31567
|
if (entry.startsWith(".") || entry === "node_modules") continue;
|
|
31579
|
-
await walk(fullPath,
|
|
31568
|
+
await walk(fullPath, path12.join(currentPath, entry));
|
|
31580
31569
|
continue;
|
|
31581
31570
|
}
|
|
31582
31571
|
if (!/\.(tsx?|jsx?)$/.test(entry)) continue;
|
|
@@ -31590,7 +31579,7 @@ async function discoverSchemaUsage(appDir) {
|
|
|
31590
31579
|
pagePath: pathMatch[1],
|
|
31591
31580
|
schemaTypes: ["managed"],
|
|
31592
31581
|
source: "ManagedSchema",
|
|
31593
|
-
filePath:
|
|
31582
|
+
filePath: path12.relative(process.cwd(), fullPath)
|
|
31594
31583
|
});
|
|
31595
31584
|
}
|
|
31596
31585
|
}
|
|
@@ -31608,7 +31597,7 @@ async function discoverSchemaUsage(appDir) {
|
|
|
31608
31597
|
pagePath,
|
|
31609
31598
|
schemaTypes: [...new Set(types)],
|
|
31610
31599
|
source: "json-ld",
|
|
31611
|
-
filePath:
|
|
31600
|
+
filePath: path12.relative(process.cwd(), fullPath)
|
|
31612
31601
|
});
|
|
31613
31602
|
}
|
|
31614
31603
|
}
|
|
@@ -31668,8 +31657,8 @@ async function apiRoutesCommand(options) {
|
|
|
31668
31657
|
console.log("");
|
|
31669
31658
|
process.exit(1);
|
|
31670
31659
|
}
|
|
31671
|
-
const routeDir =
|
|
31672
|
-
const routeFile =
|
|
31660
|
+
const routeDir = path12.join(appDir, "_uptrade", "api", "[...path]");
|
|
31661
|
+
const routeFile = path12.join(routeDir, "route.ts");
|
|
31673
31662
|
if (existsSync(routeFile) && !options.force) {
|
|
31674
31663
|
console.log(source_default.yellow(" \u26A0 API routes already exist"));
|
|
31675
31664
|
console.log(source_default.gray(` ${routeFile}`));
|
|
@@ -31706,8 +31695,8 @@ async function apiRoutesCommand(options) {
|
|
|
31706
31695
|
}
|
|
31707
31696
|
function findAppDir2() {
|
|
31708
31697
|
const candidates = [
|
|
31709
|
-
|
|
31710
|
-
|
|
31698
|
+
path12.join(process.cwd(), "app"),
|
|
31699
|
+
path12.join(process.cwd(), "src", "app")
|
|
31711
31700
|
];
|
|
31712
31701
|
for (const candidate of candidates) {
|
|
31713
31702
|
if (existsSync(candidate)) {
|
|
@@ -31820,12 +31809,12 @@ async function handleRequest(
|
|
|
31820
31809
|
`;
|
|
31821
31810
|
}
|
|
31822
31811
|
function detectPackageManager(cwd) {
|
|
31823
|
-
if (existsSync(
|
|
31824
|
-
if (existsSync(
|
|
31812
|
+
if (existsSync(path12.join(cwd, "pnpm-lock.yaml"))) return "pnpm";
|
|
31813
|
+
if (existsSync(path12.join(cwd, "yarn.lock"))) return "yarn";
|
|
31825
31814
|
return "npm";
|
|
31826
31815
|
}
|
|
31827
31816
|
async function run6(ctx, options) {
|
|
31828
|
-
if (!existsSync(
|
|
31817
|
+
if (!existsSync(path12.join(ctx.cwd, "package.json"))) {
|
|
31829
31818
|
throw new UsageError(
|
|
31830
31819
|
"NO_PACKAGE_JSON",
|
|
31831
31820
|
"No package.json found",
|
|
@@ -31870,12 +31859,12 @@ async function installCommand(options) {
|
|
|
31870
31859
|
await runCommand(ctx, (c) => run6(c, options), renderHuman4);
|
|
31871
31860
|
}
|
|
31872
31861
|
function detectPackageManager2(cwd) {
|
|
31873
|
-
if (existsSync(
|
|
31874
|
-
if (existsSync(
|
|
31862
|
+
if (existsSync(path12.join(cwd, "pnpm-lock.yaml"))) return "pnpm";
|
|
31863
|
+
if (existsSync(path12.join(cwd, "yarn.lock"))) return "yarn";
|
|
31875
31864
|
return "npm";
|
|
31876
31865
|
}
|
|
31877
31866
|
async function run7(ctx, options) {
|
|
31878
|
-
const pkgPath =
|
|
31867
|
+
const pkgPath = path12.join(ctx.cwd, "package.json");
|
|
31879
31868
|
if (!existsSync(pkgPath)) {
|
|
31880
31869
|
throw new UsageError("NO_PACKAGE_JSON", "No package.json found", "Run this from your project root.");
|
|
31881
31870
|
}
|
|
@@ -31937,7 +31926,7 @@ async function scaffoldCommand(options) {
|
|
|
31937
31926
|
}
|
|
31938
31927
|
const files = [
|
|
31939
31928
|
{
|
|
31940
|
-
path:
|
|
31929
|
+
path: path12.join(appDir, "sitemap.ts"),
|
|
31941
31930
|
label: "Sitemap",
|
|
31942
31931
|
content: `import { createSitemap } from '@sonordev/site-kit/sitemap'
|
|
31943
31932
|
|
|
@@ -31952,7 +31941,7 @@ export default createSitemap({
|
|
|
31952
31941
|
`
|
|
31953
31942
|
},
|
|
31954
31943
|
{
|
|
31955
|
-
path:
|
|
31944
|
+
path: path12.join(appDir, "robots.txt", "route.ts"),
|
|
31956
31945
|
label: "Robots.txt",
|
|
31957
31946
|
content: `import { createRobots } from '@sonordev/site-kit/robots'
|
|
31958
31947
|
|
|
@@ -31960,7 +31949,7 @@ export const GET = createRobots({})
|
|
|
31960
31949
|
`
|
|
31961
31950
|
},
|
|
31962
31951
|
{
|
|
31963
|
-
path:
|
|
31952
|
+
path: path12.join(appDir, "llms.txt", "route.ts"),
|
|
31964
31953
|
label: "llms.txt",
|
|
31965
31954
|
content: `import { createLLMsTxtHandler } from '@sonordev/site-kit/llms'
|
|
31966
31955
|
|
|
@@ -31968,7 +31957,7 @@ export const GET = createLLMsTxtHandler({ preferStatic: true })
|
|
|
31968
31957
|
`
|
|
31969
31958
|
},
|
|
31970
31959
|
{
|
|
31971
|
-
path:
|
|
31960
|
+
path: path12.join(appDir, "llms-full.txt", "route.ts"),
|
|
31972
31961
|
label: "llms-full.txt",
|
|
31973
31962
|
content: `import { createLLMsFullTxtHandler } from '@sonordev/site-kit/llms'
|
|
31974
31963
|
|
|
@@ -31979,7 +31968,7 @@ export const GET = createLLMsFullTxtHandler({ preferStatic: true })
|
|
|
31979
31968
|
if (!options.minimal) {
|
|
31980
31969
|
files.push(
|
|
31981
31970
|
{
|
|
31982
|
-
path:
|
|
31971
|
+
path: path12.join(cwd, "proxy.ts"),
|
|
31983
31972
|
label: "Proxy (security headers; redirects resolve at the 404 boundary)",
|
|
31984
31973
|
content: `import { createProxy } from '@sonordev/site-kit/proxy'
|
|
31985
31974
|
|
|
@@ -31999,7 +31988,7 @@ export const config = {
|
|
|
31999
31988
|
`
|
|
32000
31989
|
},
|
|
32001
31990
|
{
|
|
32002
|
-
path:
|
|
31991
|
+
path: path12.join(appDir, "manifest.webmanifest", "route.ts"),
|
|
32003
31992
|
label: "PWA Manifest",
|
|
32004
31993
|
content: `import { createManifest } from '@sonordev/site-kit/manifest'
|
|
32005
31994
|
|
|
@@ -32007,7 +31996,7 @@ export const GET = createManifest()
|
|
|
32007
31996
|
`
|
|
32008
31997
|
},
|
|
32009
31998
|
{
|
|
32010
|
-
path:
|
|
31999
|
+
path: path12.join(appDir, "not-found.tsx"),
|
|
32011
32000
|
label: "404 Page (resolves managed redirects)",
|
|
32012
32001
|
content: `import { redirect, permanentRedirect } from 'next/navigation'
|
|
32013
32002
|
import { resolveManagedRedirect } from '@sonordev/site-kit/redirects/not-found'
|
|
@@ -32047,7 +32036,7 @@ export default async function NotFound() {
|
|
|
32047
32036
|
`
|
|
32048
32037
|
},
|
|
32049
32038
|
{
|
|
32050
|
-
path:
|
|
32039
|
+
path: path12.join(appDir, "error.tsx"),
|
|
32051
32040
|
label: "Error Boundary",
|
|
32052
32041
|
content: `'use client'
|
|
32053
32042
|
|
|
@@ -32087,7 +32076,7 @@ export default function Error({
|
|
|
32087
32076
|
`
|
|
32088
32077
|
},
|
|
32089
32078
|
{
|
|
32090
|
-
path:
|
|
32079
|
+
path: path12.join(cwd, "og.config.ts"),
|
|
32091
32080
|
label: "OG card config (run: sonor-setup og)",
|
|
32092
32081
|
content: `import { defineOgCard } from '@sonordev/site-kit/og'
|
|
32093
32082
|
|
|
@@ -32116,7 +32105,7 @@ export default defineOgCard({
|
|
|
32116
32105
|
// .env.local, not .env.example: one real env file per project. The
|
|
32117
32106
|
// deployer copies these values into the host's env settings. Skipped
|
|
32118
32107
|
// when the file already exists, so real keys are never touched.
|
|
32119
|
-
path:
|
|
32108
|
+
path: path12.join(cwd, ".env.local"),
|
|
32120
32109
|
label: ".env.local",
|
|
32121
32110
|
content: `# ===================================
|
|
32122
32111
|
# @sonordev/site-kit \u2014 Environment Variables
|
|
@@ -32138,7 +32127,7 @@ SONOR_API_KEY=sonor_your-project-uuid_your-secret-key
|
|
|
32138
32127
|
if (options.dryRun) {
|
|
32139
32128
|
console.log(source_default.yellow(" [DRY RUN] Would create:"));
|
|
32140
32129
|
for (const f of files) {
|
|
32141
|
-
const rel =
|
|
32130
|
+
const rel = path12.relative(cwd, f.path);
|
|
32142
32131
|
const exists = existsSync(f.path);
|
|
32143
32132
|
console.log(
|
|
32144
32133
|
source_default.gray(` ${rel}`) + (exists ? source_default.yellow(" (exists, would skip)") : "")
|
|
@@ -32153,13 +32142,13 @@ SONOR_API_KEY=sonor_your-project-uuid_your-secret-key
|
|
|
32153
32142
|
for (const f of files) {
|
|
32154
32143
|
try {
|
|
32155
32144
|
if (existsSync(f.path) && !options.force) {
|
|
32156
|
-
spinner.warn(`Skipped (exists): ${
|
|
32145
|
+
spinner.warn(`Skipped (exists): ${path12.relative(cwd, f.path)}`);
|
|
32157
32146
|
skipped++;
|
|
32158
32147
|
continue;
|
|
32159
32148
|
}
|
|
32160
|
-
await fs3.mkdir(
|
|
32149
|
+
await fs3.mkdir(path12.dirname(f.path), { recursive: true });
|
|
32161
32150
|
await fs3.writeFile(f.path, f.content, "utf-8");
|
|
32162
|
-
spinner.succeed(`${f.label}: ${
|
|
32151
|
+
spinner.succeed(`${f.label}: ${path12.relative(cwd, f.path)}`);
|
|
32163
32152
|
created++;
|
|
32164
32153
|
} catch (err) {
|
|
32165
32154
|
spinner.fail(`Failed: ${f.path}`);
|
|
@@ -32208,8 +32197,8 @@ SONOR_API_KEY=sonor_your-project-uuid_your-secret-key
|
|
|
32208
32197
|
async function findAppDir3() {
|
|
32209
32198
|
const cwd = process.cwd();
|
|
32210
32199
|
const candidates = [
|
|
32211
|
-
|
|
32212
|
-
|
|
32200
|
+
path12.join(cwd, "app"),
|
|
32201
|
+
path12.join(cwd, "src", "app")
|
|
32213
32202
|
];
|
|
32214
32203
|
for (const dir of candidates) {
|
|
32215
32204
|
if (existsSync(dir)) return dir;
|
|
@@ -32233,17 +32222,17 @@ async function readIfExists(p) {
|
|
|
32233
32222
|
}
|
|
32234
32223
|
}
|
|
32235
32224
|
async function ensureLlmsRouteFiles(appDir, dryRun) {
|
|
32236
|
-
const llms =
|
|
32237
|
-
const llmsFull =
|
|
32225
|
+
const llms = path12.join(appDir, "llms.txt", "route.ts");
|
|
32226
|
+
const llmsFull = path12.join(appDir, "llms-full.txt", "route.ts");
|
|
32238
32227
|
let n5 = 0;
|
|
32239
32228
|
if (dryRun) return 0;
|
|
32240
32229
|
if (!existsSync(llms)) {
|
|
32241
|
-
await fs3.mkdir(
|
|
32230
|
+
await fs3.mkdir(path12.dirname(llms), { recursive: true });
|
|
32242
32231
|
await fs3.writeFile(llms, LLMS_ROUTE, "utf-8");
|
|
32243
32232
|
n5++;
|
|
32244
32233
|
}
|
|
32245
32234
|
if (!existsSync(llmsFull)) {
|
|
32246
|
-
await fs3.mkdir(
|
|
32235
|
+
await fs3.mkdir(path12.dirname(llmsFull), { recursive: true });
|
|
32247
32236
|
await fs3.writeFile(llmsFull, LLMS_FULL_ROUTE, "utf-8");
|
|
32248
32237
|
n5++;
|
|
32249
32238
|
}
|
|
@@ -32277,9 +32266,9 @@ async function geoCommand(options) {
|
|
|
32277
32266
|
console.log(source_default.red(" \u2717 No app directory (app/ or src/app/)"));
|
|
32278
32267
|
process.exit(1);
|
|
32279
32268
|
}
|
|
32280
|
-
const llms =
|
|
32281
|
-
const llmsFull =
|
|
32282
|
-
const sitemap =
|
|
32269
|
+
const llms = path12.join(appDir, "llms.txt", "route.ts");
|
|
32270
|
+
const llmsFull = path12.join(appDir, "llms-full.txt", "route.ts");
|
|
32271
|
+
const sitemap = path12.join(appDir, "sitemap.ts");
|
|
32283
32272
|
let allOk = true;
|
|
32284
32273
|
const row = (label, pass) => {
|
|
32285
32274
|
if (!pass) allOk = false;
|
|
@@ -32298,9 +32287,9 @@ async function geoCommand(options) {
|
|
|
32298
32287
|
row("sitemap.ts lists llms URLs", false);
|
|
32299
32288
|
}
|
|
32300
32289
|
const nextConfigs = [
|
|
32301
|
-
|
|
32302
|
-
|
|
32303
|
-
|
|
32290
|
+
path12.join(cwd, "next.config.ts"),
|
|
32291
|
+
path12.join(cwd, "next.config.mjs"),
|
|
32292
|
+
path12.join(cwd, "next.config.js")
|
|
32304
32293
|
];
|
|
32305
32294
|
let nextCfg = "";
|
|
32306
32295
|
for (const p of nextConfigs) {
|
|
@@ -32310,9 +32299,9 @@ async function geoCommand(options) {
|
|
|
32310
32299
|
}
|
|
32311
32300
|
}
|
|
32312
32301
|
const layoutCandidates = [
|
|
32313
|
-
|
|
32314
|
-
|
|
32315
|
-
|
|
32302
|
+
path12.join(appDir, "layout.tsx"),
|
|
32303
|
+
path12.join(appDir, "layout.jsx"),
|
|
32304
|
+
path12.join(appDir, "layout.js")
|
|
32316
32305
|
];
|
|
32317
32306
|
let layoutTxt = "";
|
|
32318
32307
|
for (const p of layoutCandidates) {
|
|
@@ -32372,8 +32361,8 @@ async function geoCommand(options) {
|
|
|
32372
32361
|
}
|
|
32373
32362
|
|
|
32374
32363
|
// src/cli/index.ts
|
|
32375
|
-
(0,
|
|
32376
|
-
(0,
|
|
32364
|
+
(0, import_dotenv2.config)({ path: ".env.local", quiet: true });
|
|
32365
|
+
(0, import_dotenv2.config)({ path: ".env", quiet: true });
|
|
32377
32366
|
var program2 = new Command();
|
|
32378
32367
|
program2.name("sonor-setup").description("Setup + verification toolchain for @sonordev/site-kit").version(SITE_KIT_VERSION);
|
|
32379
32368
|
withAgentFlags(
|