@xano/sdk 1.0.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/CHANGELOG.md +788 -0
- package/LICENSE +21 -0
- package/README.md +541 -0
- package/dist/.build-fingerprint +1 -0
- package/dist/agent-file-refresh-ZEMK33AX.js +38 -0
- package/dist/answer-shape-K67TAAPY.js +33 -0
- package/dist/backend-dir-2U53CIAL.js +39 -0
- package/dist/backend-slot-7QXW2QYC.js +28 -0
- package/dist/bin.d.ts +1 -0
- package/dist/bin.js +255 -0
- package/dist/branch-NCRNWQBQ.js +61 -0
- package/dist/branch-commands-ACIRCEQJ.js +79 -0
- package/dist/bundle.d.ts +223 -0
- package/dist/bundle.js +153 -0
- package/dist/capture-WAXPD7DR.js +41 -0
- package/dist/chunk-27GWNP2I.js +23 -0
- package/dist/chunk-2CMJZDCL.js +177 -0
- package/dist/chunk-2EZ3ZJZZ.js +302 -0
- package/dist/chunk-2GNFDZA2.js +390 -0
- package/dist/chunk-2MNLRIOX.js +11 -0
- package/dist/chunk-2TFRR6JV.js +104 -0
- package/dist/chunk-2ZUEE4EK.js +408 -0
- package/dist/chunk-36JUQZVQ.js +22 -0
- package/dist/chunk-3DRXWLJ5.js +83 -0
- package/dist/chunk-3JDU4VRL.js +137 -0
- package/dist/chunk-3KZCLN4Z.js +241 -0
- package/dist/chunk-3LDULPRE.js +168 -0
- package/dist/chunk-3M4LFYNQ.js +111 -0
- package/dist/chunk-3XI5CTUE.js +22 -0
- package/dist/chunk-3YW23UFH.js +50 -0
- package/dist/chunk-45UIT5T2.js +862 -0
- package/dist/chunk-4BW2SG2N.js +46 -0
- package/dist/chunk-4KHEMC32.js +79 -0
- package/dist/chunk-4POWHT2K.js +321 -0
- package/dist/chunk-4Q2GN7NW.js +192 -0
- package/dist/chunk-5A2PLKZB.js +70 -0
- package/dist/chunk-5FBYXK5P.js +159 -0
- package/dist/chunk-5HVXPTU4.js +323 -0
- package/dist/chunk-5QU2P5CA.js +304 -0
- package/dist/chunk-5V5XU32D.js +191 -0
- package/dist/chunk-5ZSO4T2G.js +10 -0
- package/dist/chunk-622HUCZT.js +10 -0
- package/dist/chunk-65HWOMGV.js +177 -0
- package/dist/chunk-6ELFRN3P.js +365 -0
- package/dist/chunk-6HO3NCSJ.js +1055 -0
- package/dist/chunk-6IUMKYWI.js +457 -0
- package/dist/chunk-6KEB3C3U.js +65 -0
- package/dist/chunk-6MR5TI5V.js +987 -0
- package/dist/chunk-6NNTNXN7.js +157 -0
- package/dist/chunk-6PBR37LN.js +97 -0
- package/dist/chunk-6QXLMMT3.js +155 -0
- package/dist/chunk-6ZGJCBZS.js +224 -0
- package/dist/chunk-73IVBKMA.js +250 -0
- package/dist/chunk-7G3CTU7I.js +286 -0
- package/dist/chunk-A3UDOZB6.js +222 -0
- package/dist/chunk-A6E77GDW.js +85 -0
- package/dist/chunk-AHJWCYQO.js +660 -0
- package/dist/chunk-AKNCFVKZ.js +36 -0
- package/dist/chunk-AM4FKL4J.js +237 -0
- package/dist/chunk-AN6BL47T.js +26 -0
- package/dist/chunk-AOSYVMUS.js +147 -0
- package/dist/chunk-APWXY5SL.js +182 -0
- package/dist/chunk-AWEIIR2U.js +218 -0
- package/dist/chunk-AWQ7BQTQ.js +73 -0
- package/dist/chunk-BAUZOWGX.js +393 -0
- package/dist/chunk-BHACRS6R.js +940 -0
- package/dist/chunk-BWPNT55T.js +680 -0
- package/dist/chunk-C6RIMRU4.js +187 -0
- package/dist/chunk-CGVQZXYG.js +263 -0
- package/dist/chunk-CIMQZRRE.js +162 -0
- package/dist/chunk-CJHQKJU4.js +113 -0
- package/dist/chunk-CTMO46PK.js +1897 -0
- package/dist/chunk-D53J55C5.js +106 -0
- package/dist/chunk-D7VGG3WS.js +90 -0
- package/dist/chunk-DAD3ONIS.js +245 -0
- package/dist/chunk-DGWHAVRG.js +162 -0
- package/dist/chunk-DX4QR4B2.js +483 -0
- package/dist/chunk-EHP3WPEG.js +21 -0
- package/dist/chunk-ELP2HMXC.js +432 -0
- package/dist/chunk-ERVIASGL.js +21 -0
- package/dist/chunk-ET4Y4XCB.js +865 -0
- package/dist/chunk-ETO6LGLD.js +4750 -0
- package/dist/chunk-EUUUMY7J.js +24 -0
- package/dist/chunk-FQJ2TTHP.js +218 -0
- package/dist/chunk-FQOF7E2E.js +133 -0
- package/dist/chunk-FWD7AL6N.js +21 -0
- package/dist/chunk-FXFV3KU6.js +138 -0
- package/dist/chunk-FXRQOWTE.js +171 -0
- package/dist/chunk-G554NZNI.js +210 -0
- package/dist/chunk-GSGDWJB5.js +13 -0
- package/dist/chunk-H2V3N23D.js +66 -0
- package/dist/chunk-H5C7MBCR.js +159 -0
- package/dist/chunk-HHN734BU.js +371 -0
- package/dist/chunk-HRVBLCVJ.js +243 -0
- package/dist/chunk-HVRUQXGD.js +1264 -0
- package/dist/chunk-I4F5TCJH.js +130 -0
- package/dist/chunk-IDOTCMDV.js +57 -0
- package/dist/chunk-IGOLHKWF.js +427 -0
- package/dist/chunk-JGE7CAWB.js +148 -0
- package/dist/chunk-JTUKLCXS.js +92 -0
- package/dist/chunk-JZGVVJSI.js +66 -0
- package/dist/chunk-K4WX6UUU.js +923 -0
- package/dist/chunk-K5BBGTYZ.js +217 -0
- package/dist/chunk-K6RXBGUB.js +427 -0
- package/dist/chunk-KTSDSD36.js +165 -0
- package/dist/chunk-L5JYN3NM.js +1038 -0
- package/dist/chunk-LIEOKXKD.js +354 -0
- package/dist/chunk-LLNZGEFK.js +51 -0
- package/dist/chunk-LPECSJ2J.js +55 -0
- package/dist/chunk-LQCMKAJ7.js +413 -0
- package/dist/chunk-LRN4ZJCQ.js +1145 -0
- package/dist/chunk-MJ4ZVHKN.js +17 -0
- package/dist/chunk-MXHSQOC4.js +3061 -0
- package/dist/chunk-N5GKCWE5.js +367 -0
- package/dist/chunk-NA3PXMEF.js +10 -0
- package/dist/chunk-NAQDMEHV.js +76 -0
- package/dist/chunk-NWKXM5RD.js +109 -0
- package/dist/chunk-NZOWWHU5.js +196 -0
- package/dist/chunk-OHX6MIUZ.js +184 -0
- package/dist/chunk-OOXWYAA4.js +15 -0
- package/dist/chunk-OPHB5ORL.js +1990 -0
- package/dist/chunk-OXA6PSZT.js +1725 -0
- package/dist/chunk-P2HAGF6H.js +73 -0
- package/dist/chunk-PTHVMXZI.js +3036 -0
- package/dist/chunk-PZ5AY32C.js +10 -0
- package/dist/chunk-Q325JKYB.js +189 -0
- package/dist/chunk-Q7DGTQ5G.js +255 -0
- package/dist/chunk-QCNYHBL7.js +601 -0
- package/dist/chunk-QO6BVGS5.js +145 -0
- package/dist/chunk-QXTKSOFI.js +76 -0
- package/dist/chunk-ROY4YAEQ.js +66 -0
- package/dist/chunk-RTJRZFFY.js +447 -0
- package/dist/chunk-SAVJUS2X.js +128 -0
- package/dist/chunk-SFLHVCKX.js +173 -0
- package/dist/chunk-STSFNCY4.js +127 -0
- package/dist/chunk-SWBF2LTK.js +170 -0
- package/dist/chunk-T5KELPAR.js +109 -0
- package/dist/chunk-TFFGOFVZ.js +1481 -0
- package/dist/chunk-TLHIFK4M.js +256 -0
- package/dist/chunk-TLQE7ZN3.js +156 -0
- package/dist/chunk-TPHWJ7UG.js +1981 -0
- package/dist/chunk-TRJCALW3.js +291 -0
- package/dist/chunk-TTEIYD5P.js +133 -0
- package/dist/chunk-U64O2MXY.js +407 -0
- package/dist/chunk-UCQ2VUTG.js +630 -0
- package/dist/chunk-UTI5G6OJ.js +44 -0
- package/dist/chunk-UVHDMMIP.js +188 -0
- package/dist/chunk-UZ6QQWJT.js +120 -0
- package/dist/chunk-VAX3UZOY.js +686 -0
- package/dist/chunk-W3HBUKFO.js +57 -0
- package/dist/chunk-WKQLGKCL.js +2823 -0
- package/dist/chunk-WQFNASK4.js +560 -0
- package/dist/chunk-WRBKLYSJ.js +224 -0
- package/dist/chunk-WTPZRR4I.js +17 -0
- package/dist/chunk-WZDJ2LLX.js +2385 -0
- package/dist/chunk-X2NL4KUO.js +14 -0
- package/dist/chunk-X4DVXBFY.js +38 -0
- package/dist/chunk-X677DMZM.js +7050 -0
- package/dist/chunk-XBKMWY7F.js +612 -0
- package/dist/chunk-XNCP4KYO.js +78 -0
- package/dist/chunk-XVBGLISP.js +35 -0
- package/dist/chunk-XW6KISBB.js +1192 -0
- package/dist/chunk-YGZHHAAB.js +8156 -0
- package/dist/chunk-YHEFQUQB.js +186 -0
- package/dist/chunk-YLDALTWZ.js +653 -0
- package/dist/chunk-YU4HSQW7.js +229 -0
- package/dist/chunk-ZDPP6RKB.js +27 -0
- package/dist/chunk-ZFDZKNGG.js +194 -0
- package/dist/chunk-ZIY7RNUT.js +49 -0
- package/dist/chunk-ZYJP6BOO.js +30 -0
- package/dist/cli.d.ts +1111 -0
- package/dist/cli.js +165 -0
- package/dist/codegen-command-VR2GWR6C.js +173 -0
- package/dist/codegen.d.ts +115 -0
- package/dist/codegen.js +19 -0
- package/dist/commands-GJMJ4XYZ.js +76 -0
- package/dist/completion-ZQLO6PB6.js +738 -0
- package/dist/config-MBYGCAFK.js +136 -0
- package/dist/deploy-command-JVZPWHMK.js +180 -0
- package/dist/deploy-source-3W45CXMP.js +81 -0
- package/dist/dev-env-sync-HN44K4D5.js +188 -0
- package/dist/diagnostics-UEAAHWVF.js +30 -0
- package/dist/display-name-hint-ABBPVQIR.js +46 -0
- package/dist/emit-CyhBDxli.d.ts +7007 -0
- package/dist/env-example-refresh-ET5HMMDW.js +126 -0
- package/dist/env-pull-command-TNMNB3CV.js +323 -0
- package/dist/env-target-O4HRKTGZ.js +40 -0
- package/dist/env-var-command-ZIRDCAZA.js +427 -0
- package/dist/ephemeral-P7F3PMAD.js +54 -0
- package/dist/ephemeral-command-CLJJKOFT.js +592 -0
- package/dist/ephemeral-state-PYCBSOGX.js +61 -0
- package/dist/file-lock-PT74GWYW.js +10 -0
- package/dist/generate-command-AYEOLA26.js +510 -0
- package/dist/gitignore-3SJ3WNRG.js +51 -0
- package/dist/guards-4EBNCZDC.js +162 -0
- package/dist/hosted-file-PSHJB3HX.js +28 -0
- package/dist/impersonate-command-5JAS3WSV.js +152 -0
- package/dist/import-EQSFU6JC.js +19 -0
- package/dist/index.d.ts +5470 -0
- package/dist/index.js +371 -0
- package/dist/init-command-X2FR4UAK.js +125 -0
- package/dist/init-modules-RY7UHAOL.js +50 -0
- package/dist/init-web-M4YZSZK6.js +42 -0
- package/dist/internal.d.ts +179 -0
- package/dist/internal.js +2634 -0
- package/dist/io-RC56QSN5.js +26 -0
- package/dist/keep-data-merge-7MPLVAVI.js +1119 -0
- package/dist/lambda-config-reconcile-OUZ4OYAB.js +116 -0
- package/dist/landed-753YLJ5H.js +40 -0
- package/dist/landing-record-SU52SKXU.js +61 -0
- package/dist/live-diff-YONW2VI3.js +65 -0
- package/dist/local-engine-choice-CH5X3W7E.js +79 -0
- package/dist/local-engine-command-Z3OL7VOD.js +766 -0
- package/dist/local-engine-config-5U3SC434.js +39 -0
- package/dist/local-engine-deploy-PCQ4SNPB.js +39 -0
- package/dist/local-engine-process-EHTE5LLU.js +63 -0
- package/dist/local-engine-state-A4FTRFAF.js +32 -0
- package/dist/local-engine-update-check-6L645VBL.js +162 -0
- package/dist/lock-MRRHW5GS.js +87 -0
- package/dist/lock-commands-2QG25HL7.js +963 -0
- package/dist/login-command-QPYRWOXZ.js +538 -0
- package/dist/logout-command-WOIQLDP6.js +56 -0
- package/dist/loop-ALIZLOSX.js +191 -0
- package/dist/marketplace-command-K5YL42NO.js +977 -0
- package/dist/marketplace-resolve-LY32JES5.js +40 -0
- package/dist/meta-client-YXGPW53C.js +244 -0
- package/dist/module-manifest-JFGHU2TC.js +38 -0
- package/dist/near-key.d.ts +13 -0
- package/dist/near-key.js +8 -0
- package/dist/node.d.ts +95 -0
- package/dist/node.js +969 -0
- package/dist/operation-outcome-TZSESNC7.js +51 -0
- package/dist/output-target-AL3I44GG.js +47 -0
- package/dist/package-manager-PRAHUSCN.js +34 -0
- package/dist/plan-disclosure-6G4MLZKD.js +114 -0
- package/dist/plugin-contributions-WRNY5ABG.js +28 -0
- package/dist/plugin-prompt-4VA3B4FF.js +20 -0
- package/dist/plugin-questions-JTSYA74Q.js +24 -0
- package/dist/plugin.d.ts +396 -0
- package/dist/plugin.js +1 -0
- package/dist/preflight-command-2T5Z36MI.js +321 -0
- package/dist/profile-command-AH3PIM4X.js +800 -0
- package/dist/profile-pointer-GRWJU3YD.js +31 -0
- package/dist/profile-select-74TRDEPD.js +23 -0
- package/dist/project-dependency-KSH63ODT.js +35 -0
- package/dist/project-sdk-REPPOIBD.js +24 -0
- package/dist/promote-command-PCWT5N6S.js +140 -0
- package/dist/prompt-II3F3LND.js +27 -0
- package/dist/publish-command-TTDUUJI5.js +414 -0
- package/dist/pull-command-VBO7C4S3.js +161 -0
- package/dist/pull-superseded-GJWLG7XO.js +20 -0
- package/dist/release-command-N4ZPKMHR.js +146 -0
- package/dist/release-ns-command-3KFDMZ6G.js +1745 -0
- package/dist/response-HlXahv4K.d.ts +925 -0
- package/dist/retry-command-AS5EVREX.js +34 -0
- package/dist/routes-manifest-SNWUVBT6.js +43 -0
- package/dist/runtime-XETHVF33.js +14 -0
- package/dist/scaffold.d.ts +1911 -0
- package/dist/scaffold.js +107 -0
- package/dist/secrets-file-LVZD6IIM.js +56 -0
- package/dist/secrets-fill-command-TTCPSVXN.js +218 -0
- package/dist/seed-VU7C3QYS.js +46 -0
- package/dist/sent-writes-N7X4OVXT.js +22 -0
- package/dist/source-resolve-S2XA3XZF.js +83 -0
- package/dist/static-host-B2Y6AG3W.js +352 -0
- package/dist/status-command-RUDXTF7I.js +554 -0
- package/dist/store-6VNCD4D7.js +20 -0
- package/dist/store-ARM6VMO5.js +98 -0
- package/dist/store-DuYfzKlW.d.ts +3144 -0
- package/dist/suggest-6FOOYKHG.js +12 -0
- package/dist/sveltekit.d.ts +154 -0
- package/dist/sveltekit.js +109 -0
- package/dist/sync-contributions-UCEROO26.js +415 -0
- package/dist/table-ENAVMITR.js +42 -0
- package/dist/tables-command-GUPXXSB5.js +156 -0
- package/dist/tenant-IIHPOHGP.js +42 -0
- package/dist/tenant-command-D5HGI2X4.js +965 -0
- package/dist/test-command-TIKZMDPZ.js +476 -0
- package/dist/tests-BGGIOK3L.js +26 -0
- package/dist/token-NICJUTMT.js +72 -0
- package/dist/toolchain-hooks-GHKLUJOH.js +96 -0
- package/dist/toolchain-modules-5EAZUONB.js +24 -0
- package/dist/tracked-backend-EIBUMDZA.js +80 -0
- package/dist/update-check-2W2NLDTC.js +136 -0
- package/dist/upgrade-command-QHNFWM7O.js +531 -0
- package/dist/verify-rollout-DRCK5TDD.js +61 -0
- package/dist/whoami-command-STGINTXH.js +51 -0
- package/dist/workspace-2CLHU2LK.js +93 -0
- package/dist/workspace-binding-56PIIPCP.js +54 -0
- package/dist/workspace-command-JEXQETJD.js +535 -0
- package/dist/workspace-env-F2RFMSC5.js +70 -0
- package/dist/workspace-export-OJSH2HIW.js +21 -0
- package/dist/writable-VA7OISSK.js +25 -0
- package/dist/xano-ICFUSPFR.js +42 -0
- package/dist/xanosdk-import-GN42TO2B.js +56 -0
- package/dist/xanosdk-project-S6DXJONQ.js +41 -0
- package/dist/xdo-CxDr2Q1C.d.ts +1371 -0
- package/guides/README.md +33 -0
- package/guides/authoring.md +921 -0
- package/guides/cli.md +401 -0
- package/guides/codegen.md +177 -0
- package/guides/codes.md +404 -0
- package/guides/coverage.md +74 -0
- package/guides/deploying.md +1525 -0
- package/guides/environment.md +400 -0
- package/guides/marketplace.md +415 -0
- package/guides/module-contract.md +558 -0
- package/guides/object-kinds.md +433 -0
- package/guides/project-structure.md +43 -0
- package/guides/scaffold.md +351 -0
- package/guides/typed-frontend.md +242 -0
- package/llms/client.md +63 -0
- package/llms/errors.md +56 -0
- package/llms/fields.md +176 -0
- package/llms/filters.md +183 -0
- package/llms/kinds-agent-mcp.md +30 -0
- package/llms/kinds-core.md +100 -0
- package/llms/kinds-knowledge.md +20 -0
- package/llms/kinds-realtime.md +76 -0
- package/llms/lambda.md +94 -0
- package/llms/legacy.md +44 -0
- package/llms/lock.md +40 -0
- package/llms/object-kinds.md +34 -0
- package/llms/statements-calls.md +62 -0
- package/llms/statements-catalog.md +320 -0
- package/llms/statements-data.md +66 -0
- package/llms/statements-runtime.md +68 -0
- package/llms/tests.md +59 -0
- package/llms/toolchain.md +16 -0
- package/llms/triggers.md +36 -0
- package/llms/values.md +29 -0
- package/llms-full.txt +2085 -0
- package/llms.txt +493 -0
- package/manifest.json +11224 -0
- package/package.json +162 -0
- package/types/lambda-globals.d.ts +129 -0
|
@@ -0,0 +1,977 @@
|
|
|
1
|
+
import {
|
|
2
|
+
assertProjectDir
|
|
3
|
+
} from "./chunk-3XI5CTUE.js";
|
|
4
|
+
import {
|
|
5
|
+
callsImportedAtTop,
|
|
6
|
+
registerState,
|
|
7
|
+
registerWrappers,
|
|
8
|
+
withoutComments
|
|
9
|
+
} from "./chunk-5HVXPTU4.js";
|
|
10
|
+
import {
|
|
11
|
+
canPrompt
|
|
12
|
+
} from "./chunk-IDOTCMDV.js";
|
|
13
|
+
import "./chunk-65HWOMGV.js";
|
|
14
|
+
import {
|
|
15
|
+
isProjectDir
|
|
16
|
+
} from "./chunk-6NNTNXN7.js";
|
|
17
|
+
import {
|
|
18
|
+
retryCommand
|
|
19
|
+
} from "./chunk-T5KELPAR.js";
|
|
20
|
+
import "./chunk-622HUCZT.js";
|
|
21
|
+
import "./chunk-NAQDMEHV.js";
|
|
22
|
+
import {
|
|
23
|
+
backendDirIn
|
|
24
|
+
} from "./chunk-5A2PLKZB.js";
|
|
25
|
+
import "./chunk-AHJWCYQO.js";
|
|
26
|
+
import "./chunk-DX4QR4B2.js";
|
|
27
|
+
import {
|
|
28
|
+
addDependency,
|
|
29
|
+
refusePlugAndPlay,
|
|
30
|
+
removeDependency
|
|
31
|
+
} from "./chunk-6QXLMMT3.js";
|
|
32
|
+
import {
|
|
33
|
+
condenseNpmError
|
|
34
|
+
} from "./chunk-ZFDZKNGG.js";
|
|
35
|
+
import "./chunk-FWD7AL6N.js";
|
|
36
|
+
import {
|
|
37
|
+
MarketplaceModuleNotFoundError,
|
|
38
|
+
ModuleNotFoundError,
|
|
39
|
+
fetchCatalogue,
|
|
40
|
+
fetchModule,
|
|
41
|
+
isLocalSpecifier,
|
|
42
|
+
nearPackage,
|
|
43
|
+
notInMarketplaceError,
|
|
44
|
+
resolveMarketplaceSpec,
|
|
45
|
+
resolveMarketplaceSpecs,
|
|
46
|
+
resolveProjectModuleListing,
|
|
47
|
+
searchCatalogue,
|
|
48
|
+
unlistedModuleError
|
|
49
|
+
} from "./chunk-2GNFDZA2.js";
|
|
50
|
+
import {
|
|
51
|
+
declaredDependencies,
|
|
52
|
+
readProjectManifest,
|
|
53
|
+
readToolchainBlock
|
|
54
|
+
} from "./chunk-JTUKLCXS.js";
|
|
55
|
+
import "./chunk-4KHEMC32.js";
|
|
56
|
+
import "./chunk-ROY4YAEQ.js";
|
|
57
|
+
import {
|
|
58
|
+
addCommandFor,
|
|
59
|
+
installCommandFor,
|
|
60
|
+
removeArgs,
|
|
61
|
+
removeCommandFor
|
|
62
|
+
} from "./chunk-WRBKLYSJ.js";
|
|
63
|
+
import {
|
|
64
|
+
localPackageName,
|
|
65
|
+
localPathOf,
|
|
66
|
+
moduleKind,
|
|
67
|
+
packageNameOf,
|
|
68
|
+
readInstalledManifestState
|
|
69
|
+
} from "./chunk-3LDULPRE.js";
|
|
70
|
+
import "./chunk-XW6KISBB.js";
|
|
71
|
+
import "./chunk-AWQ7BQTQ.js";
|
|
72
|
+
import "./chunk-EUUUMY7J.js";
|
|
73
|
+
import "./chunk-YLDALTWZ.js";
|
|
74
|
+
import "./chunk-5FBYXK5P.js";
|
|
75
|
+
import "./chunk-LLNZGEFK.js";
|
|
76
|
+
import "./chunk-QXTKSOFI.js";
|
|
77
|
+
import "./chunk-X2NL4KUO.js";
|
|
78
|
+
import "./chunk-UCQ2VUTG.js";
|
|
79
|
+
import "./chunk-DGWHAVRG.js";
|
|
80
|
+
import {
|
|
81
|
+
UsageError,
|
|
82
|
+
blank,
|
|
83
|
+
detail,
|
|
84
|
+
formatFields,
|
|
85
|
+
indentBlock,
|
|
86
|
+
info,
|
|
87
|
+
installedCliAt,
|
|
88
|
+
isMachineOutput,
|
|
89
|
+
missingArgument,
|
|
90
|
+
printHuman,
|
|
91
|
+
relForwardSlash,
|
|
92
|
+
safeText,
|
|
93
|
+
spellProjectCli,
|
|
94
|
+
spinner,
|
|
95
|
+
stdoutStyle,
|
|
96
|
+
style,
|
|
97
|
+
success,
|
|
98
|
+
terminalText,
|
|
99
|
+
unknownFlag,
|
|
100
|
+
warn,
|
|
101
|
+
writeJson
|
|
102
|
+
} from "./chunk-PTHVMXZI.js";
|
|
103
|
+
import "./chunk-UTI5G6OJ.js";
|
|
104
|
+
import "./chunk-2EZ3ZJZZ.js";
|
|
105
|
+
import "./chunk-5ZSO4T2G.js";
|
|
106
|
+
import "./chunk-TFFGOFVZ.js";
|
|
107
|
+
import "./chunk-VAX3UZOY.js";
|
|
108
|
+
import "./chunk-OHX6MIUZ.js";
|
|
109
|
+
import "./chunk-36JUQZVQ.js";
|
|
110
|
+
import "./chunk-PZ5AY32C.js";
|
|
111
|
+
|
|
112
|
+
// src/emit/marketplace-command.ts
|
|
113
|
+
import { existsSync, readdirSync, readFileSync, statSync } from "fs";
|
|
114
|
+
import { dirname, join, resolve } from "path";
|
|
115
|
+
function resolvePackage(args, verb = "install") {
|
|
116
|
+
const typed = args.positionals[0];
|
|
117
|
+
const pkg = typed === void 0 ? typed : /^(?:(?:@[^/\s]+\/)?[^@/\s]+@)?npm:(.+)$/i.exec(typed)?.[1] ?? typed;
|
|
118
|
+
if (pkg === void 0 || pkg === "") {
|
|
119
|
+
throw missingArgument("package", { command: "marketplace", subcommand: verb });
|
|
120
|
+
}
|
|
121
|
+
if (verb !== "details" && !pkg.startsWith("-") && packageNameOf(pkg) === "@xano/sdk") {
|
|
122
|
+
throw new UsageError(
|
|
123
|
+
`\`xanosdk marketplace ${verb}\` manages modules, and @xano/sdk is the SDK this project is built on, not a module` + (verb === "remove" ? ` \u2014 the backend cannot load without it.` : `.`) + ` To move it to the latest release, run \`xanosdk upgrade\`.`
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
if (pkg.startsWith("-")) {
|
|
127
|
+
throw new UsageError(
|
|
128
|
+
verb === "details" ? `\`xanosdk marketplace details\`: "${pkg}" starts with a dash, so it is a mistyped flag, not a package.` : `\`xanosdk marketplace ${verb}\`: "${pkg}" starts with a dash, so npm would read it as a flag, not a package.`,
|
|
129
|
+
{ helpFor: { command: "marketplace", subcommand: verb } }
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
return pkg;
|
|
133
|
+
}
|
|
134
|
+
function openVerb(args, verb) {
|
|
135
|
+
refusePromptFlag(args, verb);
|
|
136
|
+
const pkg = resolvePackage(args, verb);
|
|
137
|
+
const dir = process.cwd();
|
|
138
|
+
assertProjectDir(dir, {
|
|
139
|
+
what: `\`xanosdk marketplace ${verb}\` runs inside a Xano SDK project`,
|
|
140
|
+
remedy: "cd into your project first, or run `xanosdk init` to create one."
|
|
141
|
+
});
|
|
142
|
+
if (verb !== "remove") refuseOutsideXanoSdkProject(dir, verb);
|
|
143
|
+
refusePlugAndPlay(dir, retryCommand(args, { command: `marketplace ${verb}` }).command);
|
|
144
|
+
return { pkg, dir };
|
|
145
|
+
}
|
|
146
|
+
function refuseOutsideXanoSdkProject(dir, verb) {
|
|
147
|
+
if (isProjectDir(dir)) return;
|
|
148
|
+
throw new UsageError(
|
|
149
|
+
`\`xanosdk marketplace ${verb}\` wires a module into a Xano SDK project, and ${dir} is not one \u2014 it has no backend entry (\`xano/index.ts\`) and no \`.xano/\` from an earlier deploy.
|
|
150
|
+
cd into your project first, or run \`xanosdk init\` to create one.`
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
async function refuseCommaList(spec) {
|
|
154
|
+
if (isLocalSpecifier(spec) || !spec.includes(",")) return;
|
|
155
|
+
const names = [...new Set(spec.split(",").map((s) => s.trim()).filter((s) => s !== ""))];
|
|
156
|
+
if (names.length < 2) return;
|
|
157
|
+
const pkgs = await resolveMarketplaceSpecs(names, "xanosdk marketplace install").catch((err) => {
|
|
158
|
+
if (!(err instanceof MarketplaceModuleNotFoundError) || err.corrected === void 0) throw err;
|
|
159
|
+
const fixed = new MarketplaceModuleNotFoundError(
|
|
160
|
+
`${err.message} It installs one module at a time: run ${err.corrected.map((p) => `\`xanosdk marketplace install ${p}\``).join(", then ")}.`,
|
|
161
|
+
err.suggestions ?? (err.suggestion === void 0 ? [] : [err.suggestion])
|
|
162
|
+
);
|
|
163
|
+
throw fixed;
|
|
164
|
+
});
|
|
165
|
+
throw new UsageError(
|
|
166
|
+
`\`xanosdk marketplace install\` installs one module at a time, and "${spec}" names ${pkgs.length}. Run ${pkgs.map((p) => `\`xanosdk marketplace install ${p}\``).join(", then ")}.`,
|
|
167
|
+
{ hintFor: { command: "marketplace", subcommand: "install" } }
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
async function runMarketplaceInstallCommand(args) {
|
|
171
|
+
const opened = openVerb(args, "install");
|
|
172
|
+
const dir = opened.dir;
|
|
173
|
+
await refuseCommaList(opened.pkg);
|
|
174
|
+
const pkg = await resolveMarketplaceSpec(opened.pkg, "xanosdk marketplace install");
|
|
175
|
+
const name = localPackageName(pkg, dir) ?? packageNameOf(pkg);
|
|
176
|
+
const projectManifest = readProjectManifest(dir);
|
|
177
|
+
const added = projectManifest === null || !isDependency(projectManifest, name);
|
|
178
|
+
const sameSource = pkg === name || sameLocalSource(dir, pkg, projectManifest, name);
|
|
179
|
+
const alreadyInstalled = !added && sameSource && readInstalledManifestState(dir, name).kind !== "absent";
|
|
180
|
+
if (alreadyInstalled) await refuseUnclaimedFlags(args, dir, "install");
|
|
181
|
+
const installed = alreadyInstalled ? null : await install(pkg, dir, "install", retryCommand(args, { command: "marketplace install" }).command);
|
|
182
|
+
if (!alreadyInstalled) await refuseUnclaimedFlags(args, dir, "install", added ? { undo: name } : {});
|
|
183
|
+
await assertInstalledSdkPeer(name, dir, { undo: added, verb: "install" });
|
|
184
|
+
if (!alreadyInstalled) blank();
|
|
185
|
+
const shown = pkg === name ? pkg : `${name} (${pkg})`;
|
|
186
|
+
if (alreadyInstalled) info(`${shown} is already installed \u2014 npm was not run.`);
|
|
187
|
+
else success(`Installed ${shown}.`);
|
|
188
|
+
const { syncContributions } = await import("./sync-contributions-UCEROO26.js");
|
|
189
|
+
const sync = await syncContributions(dir, {
|
|
190
|
+
apply: true,
|
|
191
|
+
ask: "unanswered",
|
|
192
|
+
host: "install",
|
|
193
|
+
json: args.json,
|
|
194
|
+
unknownFlags: args.unknownFlags
|
|
195
|
+
});
|
|
196
|
+
await reportNextStep(dir, name);
|
|
197
|
+
reportSync(sync, args.json);
|
|
198
|
+
if (isMachineOutput(args)) {
|
|
199
|
+
writeJson({
|
|
200
|
+
installed: pkg,
|
|
201
|
+
alreadyInstalled,
|
|
202
|
+
legacyPeerDeps: installed !== null && installed.peerConflict !== null,
|
|
203
|
+
modules: sync.modules,
|
|
204
|
+
unconfigured: sync.unconfigured,
|
|
205
|
+
written: sync.written,
|
|
206
|
+
changed: sync.changed
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
function sameLocalSource(dir, spec, manifest, name) {
|
|
211
|
+
const path = localPathOf(spec);
|
|
212
|
+
if (path === void 0 || manifest === null) return false;
|
|
213
|
+
for (const block of ["dependencies", "devDependencies", "optionalDependencies"]) {
|
|
214
|
+
const range = manifest[block]?.[name];
|
|
215
|
+
if (typeof range === "string" && range.startsWith("file:")) return resolve(dir, range.slice(5)) === resolve(dir, path);
|
|
216
|
+
}
|
|
217
|
+
return false;
|
|
218
|
+
}
|
|
219
|
+
async function runMarketplaceReinstallCommand(args) {
|
|
220
|
+
const opened = openVerb(args, "reinstall");
|
|
221
|
+
const dir = opened.dir;
|
|
222
|
+
const { pkg, listing } = await resolveProjectModuleListing(opened.pkg, dir);
|
|
223
|
+
if (listing === "unlisted") throw await unlistedModuleError("xanosdk marketplace reinstall", pkg);
|
|
224
|
+
assertDependency(dir, pkg, listing);
|
|
225
|
+
const onDisk = classifyInstalled(dir, pkg);
|
|
226
|
+
if (onDisk === "workspace" || onDisk === "ordinary") refuseNotReaskable(dir, pkg, onDisk);
|
|
227
|
+
if (onDisk !== "absent") await refuseUnclaimedFlags(args, dir, "reinstall", { enable: pkg });
|
|
228
|
+
await install(pkg, dir, "reinstall", retryCommand(args, { command: "marketplace reinstall" }).command);
|
|
229
|
+
if (onDisk === "absent") await refuseUnclaimedFlags(args, dir, "reinstall", { enable: pkg });
|
|
230
|
+
await assertInstalledSdkPeer(pkg, dir, { undo: false, verb: "reinstall" });
|
|
231
|
+
const declared = await assertReaskable(dir, pkg);
|
|
232
|
+
blank();
|
|
233
|
+
success(`Reinstalled ${pkg}.`);
|
|
234
|
+
const disabled = announceReEnable(pkg, declared.config);
|
|
235
|
+
await reportMissingInverse(pkg, declared);
|
|
236
|
+
const { syncContributions } = await import("./sync-contributions-UCEROO26.js");
|
|
237
|
+
const sync = await syncContributions(dir, {
|
|
238
|
+
apply: true,
|
|
239
|
+
ask: "package",
|
|
240
|
+
pkg,
|
|
241
|
+
host: "reinstall",
|
|
242
|
+
// The re-enabling, as a pending change rather than a write already made.
|
|
243
|
+
// Discovery folds it in before deciding what to import, so the flag and
|
|
244
|
+
// everything the re-ask settles land in the reconciler's ONE write — and a
|
|
245
|
+
// refusal leaves the module exactly as switched off as it was.
|
|
246
|
+
...disabled ? { enable: [pkg] } : {},
|
|
247
|
+
json: args.json,
|
|
248
|
+
// The same obligation `install` carries: the parser deferred the check on
|
|
249
|
+
// this verb, it did not cancel it. Whatever no question of this module's
|
|
250
|
+
// claims is refused by name, naming `marketplace reinstall`.
|
|
251
|
+
unknownFlags: args.unknownFlags
|
|
252
|
+
});
|
|
253
|
+
reportSync(sync, args.json);
|
|
254
|
+
if (isMachineOutput(args)) {
|
|
255
|
+
const mod = sync.modules.find((m) => m.pkg === pkg);
|
|
256
|
+
writeJson({
|
|
257
|
+
reinstalled: pkg,
|
|
258
|
+
modules: sync.modules,
|
|
259
|
+
unconfigured: sync.unconfigured,
|
|
260
|
+
written: sync.written,
|
|
261
|
+
changed: sync.changed,
|
|
262
|
+
...mod?.sources === void 0 ? {} : { sources: mod.sources },
|
|
263
|
+
// Hoisted alongside `sources` for the same reason it is: this verb is
|
|
264
|
+
// ABOUT one package, so its caller should not have to find it in the
|
|
265
|
+
// table. Names the flag that answers each question, which a caller
|
|
266
|
+
// cannot derive from the ids `sources` is keyed by.
|
|
267
|
+
...mod?.flags === void 0 ? {} : { flags: mod.flags }
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
async function refuseUnclaimedFlags(args, dir, verb, opts = {}) {
|
|
272
|
+
if (args.unknownFlags.length === 0) return;
|
|
273
|
+
const { undo, enable } = opts;
|
|
274
|
+
const [{ discoverToolchainPlugins }, { questionSets, flagFor, hostHelpTarget }] = await Promise.all([
|
|
275
|
+
import("./toolchain-modules-5EAZUONB.js"),
|
|
276
|
+
import("./plugin-questions-JTSYA74Q.js")
|
|
277
|
+
]);
|
|
278
|
+
let flags;
|
|
279
|
+
try {
|
|
280
|
+
const { loaded } = await discoverToolchainPlugins(dir, {
|
|
281
|
+
frozen: false,
|
|
282
|
+
configuring: true,
|
|
283
|
+
...enable === void 0 ? {} : { configOverride: { [enable]: { enabled: true } } }
|
|
284
|
+
});
|
|
285
|
+
flags = questionSets(loaded).flatMap((set) => set.questions.map(flagFor));
|
|
286
|
+
} catch {
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
const claimable = (arg) => {
|
|
290
|
+
if (!arg.startsWith("--")) return false;
|
|
291
|
+
const name = arg.slice(2).split("=", 1)[0];
|
|
292
|
+
return flags.some((f) => name === f || name === `no-${f}`);
|
|
293
|
+
};
|
|
294
|
+
const unclaimed = args.unknownFlags.filter((arg) => !claimable(arg));
|
|
295
|
+
if (unclaimed.length === 0) return;
|
|
296
|
+
let undone = false;
|
|
297
|
+
if (undo !== void 0) {
|
|
298
|
+
try {
|
|
299
|
+
await uninstall(undo, dir);
|
|
300
|
+
undone = true;
|
|
301
|
+
} catch {
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
const err = unknownFlag(unclaimed, hostHelpTarget(verb), flags);
|
|
305
|
+
if (undo !== void 0) {
|
|
306
|
+
err.message += undone ? `
|
|
307
|
+
${undo} was uninstalled again, so this project is exactly as it was.` : `
|
|
308
|
+
${undo} is still installed: run \`xanosdk marketplace remove ${undo}\` to drop it.`;
|
|
309
|
+
}
|
|
310
|
+
throw err;
|
|
311
|
+
}
|
|
312
|
+
function isDependency(manifest, pkg) {
|
|
313
|
+
return declaredDependencies(manifest).includes(pkg);
|
|
314
|
+
}
|
|
315
|
+
function inProject(dir, pkg) {
|
|
316
|
+
const manifest = readProjectManifest(dir);
|
|
317
|
+
return manifest !== null && isDependency(manifest, pkg) || pkg in readToolchainBlock(dir, manifest);
|
|
318
|
+
}
|
|
319
|
+
function installedModules(dir) {
|
|
320
|
+
const manifest = readProjectManifest(dir);
|
|
321
|
+
const modules = (manifest === null ? [] : declaredDependencies(manifest)).filter((pkg) => {
|
|
322
|
+
const state = readInstalledManifestState(dir, pkg);
|
|
323
|
+
const field = state.kind === "ok" ? state.manifest["xanosdk"] : void 0;
|
|
324
|
+
return typeof field === "object" && field !== null;
|
|
325
|
+
});
|
|
326
|
+
return [.../* @__PURE__ */ new Set([...modules, ...Object.keys(readToolchainBlock(dir, manifest))])];
|
|
327
|
+
}
|
|
328
|
+
function classifyInstalled(dir, pkg) {
|
|
329
|
+
const state = readInstalledManifestState(dir, pkg);
|
|
330
|
+
if (state.kind !== "ok") return "absent";
|
|
331
|
+
const field = state.manifest["xanosdk"];
|
|
332
|
+
if (typeof field !== "object" || field === null) return "ordinary";
|
|
333
|
+
try {
|
|
334
|
+
return moduleKind(pkg, state.manifest);
|
|
335
|
+
} catch (error) {
|
|
336
|
+
warn(
|
|
337
|
+
`${pkg} does not declare a module kind we recognize, so it is read as an ordinary package.`,
|
|
338
|
+
"module.kind-unknown",
|
|
339
|
+
[error instanceof Error ? error.message : String(error)]
|
|
340
|
+
);
|
|
341
|
+
return "ordinary";
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
function hasXanoSdkField(dir, pkg) {
|
|
345
|
+
const state = readInstalledManifestState(dir, pkg);
|
|
346
|
+
return state.kind === "ok" && typeof state.manifest["xanosdk"] === "object" && state.manifest["xanosdk"] !== null;
|
|
347
|
+
}
|
|
348
|
+
function refusal(message, next) {
|
|
349
|
+
return new UsageError(`${message} ${next}`);
|
|
350
|
+
}
|
|
351
|
+
function assertDependency(dir, pkg, listing) {
|
|
352
|
+
const manifest = readProjectManifest(dir);
|
|
353
|
+
if (manifest !== null && isDependency(manifest, pkg)) return;
|
|
354
|
+
throw refusal(
|
|
355
|
+
`\`xanosdk marketplace reinstall\`: ${pkg} is not a dependency of this project, so there are no settings to re-ask.`,
|
|
356
|
+
// `install` is the next step only for a name it would install — a module
|
|
357
|
+
// the catalogue lists. Anything else it refuses too (exit 8).
|
|
358
|
+
listing === "catalogue" || listing === "project" ? `Run \`xanosdk marketplace install ${pkg}\` to add it.` : `Check the name \u2014 \`xanosdk marketplace list\` shows what is published.`
|
|
359
|
+
);
|
|
360
|
+
}
|
|
361
|
+
async function assertReaskable(dir, pkg) {
|
|
362
|
+
const { declaredToolchainPlugins } = await import("./toolchain-modules-5EAZUONB.js");
|
|
363
|
+
const declared = declaredToolchainPlugins(dir).find((d) => d.pkg === pkg);
|
|
364
|
+
if (declared !== void 0 && declared.unreadable === void 0) return declared;
|
|
365
|
+
const installed = classifyInstalled(dir, pkg);
|
|
366
|
+
if (installed === "absent") {
|
|
367
|
+
throw refusal(
|
|
368
|
+
`\`xanosdk marketplace reinstall\`: ${pkg} is a dependency but is not installed, so its questions cannot be read.`,
|
|
369
|
+
`Run \`${installCommandFor(dir)}\` to restore node_modules, then re-run this command.`
|
|
370
|
+
);
|
|
371
|
+
}
|
|
372
|
+
return refuseNotReaskable(dir, pkg, installed === "workspace" ? "workspace" : "ordinary");
|
|
373
|
+
}
|
|
374
|
+
function refuseNotReaskable(dir, pkg, installed) {
|
|
375
|
+
const workspace = installed === "workspace";
|
|
376
|
+
const importers = workspace ? backendImporters(dir, pkg) : [];
|
|
377
|
+
throw refusal(
|
|
378
|
+
workspace ? `\`xanosdk marketplace reinstall\`: ${pkg} is a workspace module, not a toolchain module \u2014 it contributes no project settings to re-ask.` : `\`xanosdk marketplace reinstall\`: ${pkg} is an ordinary npm package, not a Xano SDK toolchain module, so it has no questions to re-ask.`,
|
|
379
|
+
!workspace ? `Run \`${addCommandFor(dir, pkg)}\` to update it.` : importers.length > 0 ? `It is already imported in ${importers.join(", ")}; run \`${addCommandFor(dir, pkg)}\` to update it.` : `Import it in \`xano/index.ts\` and register it onto your workspace.`
|
|
380
|
+
);
|
|
381
|
+
}
|
|
382
|
+
function announceReEnable(pkg, config) {
|
|
383
|
+
if (config?.["enabled"] !== false) return false;
|
|
384
|
+
warn(
|
|
385
|
+
`${pkg} is switched off in this project (\`"enabled": false\`).`,
|
|
386
|
+
"module.disabled",
|
|
387
|
+
[
|
|
388
|
+
`Re-enabling it, because re-asking a module its questions is asking whether you want it. Answer no to its enabling question to switch it straight back off.`
|
|
389
|
+
]
|
|
390
|
+
);
|
|
391
|
+
return true;
|
|
392
|
+
}
|
|
393
|
+
async function reportMissingInverse(pkg, declared) {
|
|
394
|
+
if (declared.pluginFile === null) return;
|
|
395
|
+
if (declared.config === null || Object.keys(declared.config).length === 0) return;
|
|
396
|
+
const { loadFile } = await import("./module-manifest-JFGHU2TC.js");
|
|
397
|
+
const loaded = await loadFile(declared.pluginFile);
|
|
398
|
+
if (loaded.kind !== "loaded") return;
|
|
399
|
+
const plugin = loaded.exports["default"];
|
|
400
|
+
if (typeof plugin !== "object" || plugin === null) return;
|
|
401
|
+
const shape = plugin;
|
|
402
|
+
if ((shape.questions?.length ?? 0) === 0) return;
|
|
403
|
+
if (typeof shape.answersFromConfig === "function") return;
|
|
404
|
+
detail(
|
|
405
|
+
`${pkg} does not map its stored settings back to answers, so the questions below start from the defaults it ships rather than from this project's current settings.`
|
|
406
|
+
);
|
|
407
|
+
}
|
|
408
|
+
async function runMarketplaceRemoveCommand(args) {
|
|
409
|
+
const opened = openVerb(args, "remove");
|
|
410
|
+
const dir = opened.dir;
|
|
411
|
+
const { pkg, listing } = await resolveProjectModuleListing(opened.pkg, dir);
|
|
412
|
+
if (listing === "catalogue" || listing === "unlisted" || listing === "unknown" && !inProject(dir, pkg)) {
|
|
413
|
+
success(`${pkg} is not installed in this project \u2014 nothing to remove.`);
|
|
414
|
+
const near = nearPackage(opened.pkg, installedModules(dir));
|
|
415
|
+
if (near !== void 0) {
|
|
416
|
+
detail(
|
|
417
|
+
`Did you mean \`${near.hit}\`${near.pkg === near.hit ? "" : ` (${near.pkg})`}? It is installed: \`xanosdk marketplace remove ${near.hit}\`.`
|
|
418
|
+
);
|
|
419
|
+
}
|
|
420
|
+
const followUp2 = await afterWorkspaceModuleRemoved(dir);
|
|
421
|
+
if (isMachineOutput(args)) {
|
|
422
|
+
writeJson({
|
|
423
|
+
removed: pkg,
|
|
424
|
+
alreadyGone: true,
|
|
425
|
+
droppedConfig: false,
|
|
426
|
+
modules: [],
|
|
427
|
+
unconfigured: [],
|
|
428
|
+
written: [],
|
|
429
|
+
changed: followUp2.routes === "written",
|
|
430
|
+
routes: followUp2.routes,
|
|
431
|
+
lockOrphans: followUp2.lockOrphans,
|
|
432
|
+
...near === void 0 ? {} : { suggestion: near.hit }
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
const target = await assertRemovable(dir, pkg, args.json === true ? " --json" : "");
|
|
438
|
+
if (target.dependency) {
|
|
439
|
+
await uninstall(pkg, dir, retryCommand(args, { command: "marketplace remove" }).command);
|
|
440
|
+
blank();
|
|
441
|
+
success(`Uninstalled ${pkg}.`);
|
|
442
|
+
} else {
|
|
443
|
+
blank();
|
|
444
|
+
warn(
|
|
445
|
+
`${pkg} is no longer a dependency, but this project still records settings for it.`,
|
|
446
|
+
"module.stale-settings",
|
|
447
|
+
[`Nothing to uninstall \u2014 dropping what was left behind, which nothing else reports.`]
|
|
448
|
+
);
|
|
449
|
+
}
|
|
450
|
+
const { syncContributions } = await import("./sync-contributions-UCEROO26.js");
|
|
451
|
+
const sync = await syncContributions(dir, {
|
|
452
|
+
apply: true,
|
|
453
|
+
ask: "none",
|
|
454
|
+
host: "remove",
|
|
455
|
+
json: args.json
|
|
456
|
+
});
|
|
457
|
+
reportSync(sync, args.json);
|
|
458
|
+
if (!sync.removed.includes(pkg) && !target.workspace) {
|
|
459
|
+
detail(`No settings or file lines were recorded for ${pkg}, so there was nothing else to drop.`);
|
|
460
|
+
}
|
|
461
|
+
const followUp = await afterWorkspaceModuleRemoved(dir);
|
|
462
|
+
if (isMachineOutput(args)) {
|
|
463
|
+
writeJson({
|
|
464
|
+
removed: pkg,
|
|
465
|
+
alreadyGone: false,
|
|
466
|
+
droppedConfig: sync.removed.includes(pkg),
|
|
467
|
+
modules: sync.modules,
|
|
468
|
+
unconfigured: sync.unconfigured,
|
|
469
|
+
written: sync.written,
|
|
470
|
+
// `npm uninstall` rewrote package.json even when the reconcile had nothing to do.
|
|
471
|
+
changed: sync.changed || target.dependency || followUp.routes === "written",
|
|
472
|
+
routes: followUp.routes,
|
|
473
|
+
lockOrphans: followUp.lockOrphans
|
|
474
|
+
});
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
async function afterWorkspaceModuleRemoved(dir) {
|
|
478
|
+
const backend = backendDirIn(dir);
|
|
479
|
+
const entry = join(backend, "index.ts");
|
|
480
|
+
const rel = relForwardSlash(dir, backend) || ".";
|
|
481
|
+
if (!existsSync(entry)) return { routes: "absent", lockOrphans: 0 };
|
|
482
|
+
const routesFile = join(backend, "routes.gen.ts");
|
|
483
|
+
try {
|
|
484
|
+
const { refreshRouteManifest } = await import("./cli.js");
|
|
485
|
+
const { manifest, lockOrphans } = await refreshRouteManifest(entry, routesFile);
|
|
486
|
+
if (manifest === "written") info(`Regenerated ${rel}/routes.gen.ts without the removed module's endpoints.`);
|
|
487
|
+
if (manifest === "skipped") {
|
|
488
|
+
warn(`${rel}/routes.gen.ts could not be regenerated here \u2014 run \`npm run xano:routes\` and commit it.`, "routes.not-written");
|
|
489
|
+
}
|
|
490
|
+
if (lockOrphans > 0) {
|
|
491
|
+
warn(
|
|
492
|
+
`${rel}/xano.lock still pins ${lockOrphans} ${lockOrphans === 1 ? "entry" : "entries"} the workspace no longer exports (the removed module's objects). Once they are gone for good: \`xanosdk lock prune ./${rel}/index.ts --yes\`.`,
|
|
493
|
+
"lock.module-orphans"
|
|
494
|
+
);
|
|
495
|
+
}
|
|
496
|
+
return { routes: manifest, lockOrphans };
|
|
497
|
+
} catch (err) {
|
|
498
|
+
warn(
|
|
499
|
+
`Could not load ${rel}/index.ts to update what the module left behind (${err instanceof Error ? err.message.split("\n")[0] : String(err)}). Run \`npm run xano:routes\` and \`xanosdk lock prune ./${rel}/index.ts --yes\` once it loads.`,
|
|
500
|
+
"module.load-failed"
|
|
501
|
+
);
|
|
502
|
+
return { routes: "skipped", lockOrphans: 0 };
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
async function assertRemovable(dir, pkg, outputFlag = "") {
|
|
506
|
+
const manifest = readProjectManifest(dir);
|
|
507
|
+
const dependency = manifest !== null && isDependency(manifest, pkg);
|
|
508
|
+
const configured = pkg in readToolchainBlock(dir, manifest);
|
|
509
|
+
if (!dependency && !configured) {
|
|
510
|
+
throw refusal(
|
|
511
|
+
`\`xanosdk marketplace remove\`: ${pkg} is not a dependency of this project and this project records no settings for it, so there is nothing to remove.`,
|
|
512
|
+
`Check the name \u2014 \`xanosdk marketplace list\` shows what is published.`
|
|
513
|
+
);
|
|
514
|
+
}
|
|
515
|
+
const { declaredToolchainPlugins } = await import("./toolchain-modules-5EAZUONB.js");
|
|
516
|
+
const declared = declaredToolchainPlugins(dir).find((d) => d.pkg === pkg);
|
|
517
|
+
if (declared?.config?.["enabled"] === false) {
|
|
518
|
+
throw refusal(
|
|
519
|
+
`\`xanosdk marketplace remove\`: ${pkg} is switched off in this project (\`"enabled": false\`), which is not the same as removed \u2014 it is still installed and still in dependencies.`,
|
|
520
|
+
`Run \`xanosdk marketplace reinstall ${pkg}\` to switch it back on if you still want it, or delete its entry from this project's package.json "xanosdk" block and re-run this command to drop it for good.`
|
|
521
|
+
);
|
|
522
|
+
}
|
|
523
|
+
if (declared !== void 0 || !dependency) return { dependency };
|
|
524
|
+
const installed = classifyInstalled(dir, pkg);
|
|
525
|
+
if (installed === "absent") {
|
|
526
|
+
throw refusal(
|
|
527
|
+
`\`xanosdk marketplace remove\`: ${pkg} is a dependency but is not installed, so there is no way to tell whether it contributed anything to remove.`,
|
|
528
|
+
`Run \`${removeCommandFor(dir, pkg)}\` \u2014 this project records no Xano SDK settings for it.`
|
|
529
|
+
);
|
|
530
|
+
}
|
|
531
|
+
if (installed === "workspace") {
|
|
532
|
+
const importers2 = backendImporters(dir, pkg);
|
|
533
|
+
if (importers2.length > 0) {
|
|
534
|
+
throw refusal(
|
|
535
|
+
`\`xanosdk marketplace remove\`: ${pkg} is a workspace module your backend still imports (${importers2.join(", ")}), so uninstalling it would break the next export.`,
|
|
536
|
+
`Drop its import and registration from ${importers2.length === 1 ? "that file" : "those files"}, then re-run \`xanosdk marketplace remove ${pkg}${outputFlag}\`.`
|
|
537
|
+
);
|
|
538
|
+
}
|
|
539
|
+
return { dependency, workspace: true };
|
|
540
|
+
}
|
|
541
|
+
const importers = backendImporters(dir, pkg);
|
|
542
|
+
throw refusal(
|
|
543
|
+
`\`xanosdk marketplace remove\`: ${pkg} is an ordinary npm package, not a Xano SDK module, so it contributed nothing this command would reconcile` + (importers.length > 0 ? ` \u2014 but your backend imports it (${importers.join(", ")}).` : `.`),
|
|
544
|
+
importers.length > 0 ? `Drop its import and registration from ${importers.length === 1 ? "that file" : "those files"}, then run \`${removeCommandFor(dir, pkg)}\`.` : `Run \`${removeCommandFor(dir, pkg)}\`.`
|
|
545
|
+
);
|
|
546
|
+
}
|
|
547
|
+
var SOURCE_FILE = /\.(?:[cm]?[jt]s|tsx|jsx)$/;
|
|
548
|
+
function backendSources(dir) {
|
|
549
|
+
const found = [];
|
|
550
|
+
const walk = (at) => {
|
|
551
|
+
let entries;
|
|
552
|
+
try {
|
|
553
|
+
entries = readdirSync(at, { withFileTypes: true });
|
|
554
|
+
} catch {
|
|
555
|
+
return;
|
|
556
|
+
}
|
|
557
|
+
for (const entry of entries) {
|
|
558
|
+
if (entry.name === "node_modules" || entry.name.startsWith(".")) continue;
|
|
559
|
+
const full = join(at, entry.name);
|
|
560
|
+
if (entry.isDirectory()) walk(full);
|
|
561
|
+
else if (entry.isFile() && SOURCE_FILE.test(entry.name)) {
|
|
562
|
+
try {
|
|
563
|
+
found.push({ rel: relForwardSlash(dir, full), code: withoutComments(readFileSync(full, "utf8")) });
|
|
564
|
+
} catch {
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
};
|
|
569
|
+
walk(backendDirIn(dir));
|
|
570
|
+
return found.sort((a, b) => a.rel < b.rel ? -1 : a.rel > b.rel ? 1 : 0);
|
|
571
|
+
}
|
|
572
|
+
function specifierOf(pkg) {
|
|
573
|
+
const escaped = pkg.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
574
|
+
return new RegExp(`["'\`]${escaped}(?:/[^"'\`]*)?["'\`]`);
|
|
575
|
+
}
|
|
576
|
+
function backendImporters(dir, pkg) {
|
|
577
|
+
const specifier = specifierOf(pkg);
|
|
578
|
+
return backendSources(dir).filter((file) => specifier.test(file.code)).map((file) => file.rel);
|
|
579
|
+
}
|
|
580
|
+
function relativeSpecifiers(code) {
|
|
581
|
+
const found = [];
|
|
582
|
+
const valueCode = code.replace(/(?<![\w$.])(?:import|export)\s+type\s+(?!from\b)[^;]*?\bfrom\s*(["'`])[^"'`\n]*\1/g, "");
|
|
583
|
+
for (const m of valueCode.matchAll(/(?:\bfrom|\bimport\s*\(?|\brequire\s*\()\s*(["'`])(\.{1,2}\/[^"'`\n]*)\1/g)) found.push(m[2]);
|
|
584
|
+
return found;
|
|
585
|
+
}
|
|
586
|
+
function resolveRelative(from, specifier) {
|
|
587
|
+
const base = resolve(dirname(from), specifier);
|
|
588
|
+
const twin = base.replace(/\.([cm]?)js(x?)$/, ".$1ts$2");
|
|
589
|
+
const exts = [".ts", ".tsx", ".mts", ".cts", ".js", ".jsx", ".mjs", ".cjs"];
|
|
590
|
+
const candidates = [base, twin, ...exts.map((e) => base + e), ...exts.map((e) => join(base, `index${e}`))];
|
|
591
|
+
for (const candidate of candidates) {
|
|
592
|
+
if (candidate.split(/[\\/]/).includes("node_modules")) continue;
|
|
593
|
+
try {
|
|
594
|
+
if (statSync(candidate).isFile() && SOURCE_FILE.test(candidate)) return candidate;
|
|
595
|
+
} catch {
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
return void 0;
|
|
599
|
+
}
|
|
600
|
+
function reachableSources(dir) {
|
|
601
|
+
const entry = join(backendDirIn(dir), "index.ts");
|
|
602
|
+
if (!existsSync(entry)) return void 0;
|
|
603
|
+
const found = [];
|
|
604
|
+
const seen = /* @__PURE__ */ new Set();
|
|
605
|
+
const queue = [entry];
|
|
606
|
+
while (queue.length > 0) {
|
|
607
|
+
const file = queue.shift();
|
|
608
|
+
if (seen.has(file)) continue;
|
|
609
|
+
seen.add(file);
|
|
610
|
+
let code;
|
|
611
|
+
try {
|
|
612
|
+
code = withoutComments(readFileSync(file, "utf8"));
|
|
613
|
+
} catch {
|
|
614
|
+
continue;
|
|
615
|
+
}
|
|
616
|
+
found.push({ rel: relForwardSlash(dir, file), code });
|
|
617
|
+
for (const specifier of relativeSpecifiers(code)) {
|
|
618
|
+
const next = resolveRelative(file, specifier);
|
|
619
|
+
if (next !== void 0) queue.push(next);
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
return found;
|
|
623
|
+
}
|
|
624
|
+
function backendRegistration(dir, pkg, register) {
|
|
625
|
+
const registrars = [];
|
|
626
|
+
const unknown = [];
|
|
627
|
+
const files = reachableSources(dir) ?? backendSources(dir);
|
|
628
|
+
for (const file of files) {
|
|
629
|
+
const state = registerState(file.code, pkg, register);
|
|
630
|
+
if (state === "yes") registrars.push(file.rel);
|
|
631
|
+
else if (state === "unknown") {
|
|
632
|
+
const wrappers = registerWrappers(file.code, pkg, register);
|
|
633
|
+
const called = wrappers.length > 0 && files.some((other) => other !== file && callsImportedAtTop(other.code, wrappers));
|
|
634
|
+
(called ? registrars : unknown).push(file.rel);
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
return { registrars, unknown };
|
|
638
|
+
}
|
|
639
|
+
async function uninstall(pkg, dir, rerun) {
|
|
640
|
+
const spin = spinner(`Uninstalling ${style.bold(pkg)}`);
|
|
641
|
+
let result;
|
|
642
|
+
try {
|
|
643
|
+
result = await removeDependency(dir, pkg, rerun);
|
|
644
|
+
} finally {
|
|
645
|
+
spin.stop();
|
|
646
|
+
}
|
|
647
|
+
const { manager } = result.site;
|
|
648
|
+
const verb = removeArgs(manager, pkg)[0];
|
|
649
|
+
if (result.status === 0 && !result.stillListed) return;
|
|
650
|
+
process.stderr.write(terminalText(result.output.trimEnd()) + "\n");
|
|
651
|
+
throw new Error(
|
|
652
|
+
(result.status === 0 ? `${manager} ${verb} ${pkg} exited 0, but this project's package.json still lists ${pkg}. ` : `${manager} ${verb} ${pkg} failed (exit ${result.status}). `) + `Nothing was reconciled: ${pkg} is still a dependency, so this project's settings and file lines for it are exactly as they were. Fix what ${manager} reported and re-run \`xanosdk marketplace remove ${pkg}\`.`
|
|
653
|
+
);
|
|
654
|
+
}
|
|
655
|
+
async function assertInstalledSdkPeer(pkg, dir, opts) {
|
|
656
|
+
const [{ sdkPeerSkew }, { readVersion }, { readInstalledManifest }] = await Promise.all([
|
|
657
|
+
import("./toolchain-modules-5EAZUONB.js"),
|
|
658
|
+
import("./cli.js"),
|
|
659
|
+
import("./module-manifest-JFGHU2TC.js")
|
|
660
|
+
]);
|
|
661
|
+
const manifest = readInstalledManifest(dir, pkg);
|
|
662
|
+
if (manifest === null) return;
|
|
663
|
+
const undo = async () => {
|
|
664
|
+
if (!opts.undo) return false;
|
|
665
|
+
try {
|
|
666
|
+
await uninstall(pkg, dir);
|
|
667
|
+
return true;
|
|
668
|
+
} catch {
|
|
669
|
+
return false;
|
|
670
|
+
}
|
|
671
|
+
};
|
|
672
|
+
const retired = retiredSdkNamed(manifest);
|
|
673
|
+
if (retired !== void 0) {
|
|
674
|
+
const version = typeof manifest["version"] === "string" ? `@${manifest["version"]}` : "";
|
|
675
|
+
const undone2 = await undo();
|
|
676
|
+
throw refusal(
|
|
677
|
+
`${pkg}${version} is built for the retired \`${retired}\`, not \`@xano/sdk\` \u2014 it cannot load in this project.`,
|
|
678
|
+
undone2 ? `It was uninstalled again, so this project is exactly as it was. Install the version built for this SDK with \`xanosdk marketplace install ${pkg}\`.` : `${pkg}${version} is still installed and still a dependency, so every command that loads the backend fails until it is replaced. Install the version built for this SDK over it with \`xanosdk marketplace install ${pkg}@latest\`.`
|
|
679
|
+
);
|
|
680
|
+
}
|
|
681
|
+
const sdkVersion = readVersion();
|
|
682
|
+
const range = sdkPeerSkew(manifest, sdkVersion);
|
|
683
|
+
if (range === null) return;
|
|
684
|
+
const undone = await undo();
|
|
685
|
+
throw refusal(
|
|
686
|
+
`${pkg} requires \`@xano/sdk\` ${range}, and this is ${sdkVersion} \u2014 its hooks were built against a contract this SDK does not have, so it would register and apply nothing.`,
|
|
687
|
+
undone ? `It was uninstalled again, so this project is exactly as it was. Upgrade with \`${addCommandFor(dir, "@xano/sdk@latest")}\` and re-run this command, or install a ${pkg} built for this SDK.` : `${pkg} is still installed and still a dependency, and every command that loads modules will refuse it until this is settled. Upgrade with \`${addCommandFor(dir, "@xano/sdk@latest")}\`, or run \`xanosdk marketplace remove ${pkg}\` to drop it and its settings together.`
|
|
688
|
+
);
|
|
689
|
+
}
|
|
690
|
+
var RETIRED_SDK_PACKAGES = ["@xanosdk/core", "@xanosdk/sdk"];
|
|
691
|
+
function retiredSdkNamed(manifest) {
|
|
692
|
+
return RETIRED_SDK_PACKAGES.find(
|
|
693
|
+
(retired) => ["dependencies", "peerDependencies", "optionalDependencies"].some((field) => {
|
|
694
|
+
const deps = manifest[field];
|
|
695
|
+
return typeof deps === "object" && deps !== null && Object.prototype.hasOwnProperty.call(deps, retired);
|
|
696
|
+
})
|
|
697
|
+
);
|
|
698
|
+
}
|
|
699
|
+
async function install(pkg, dir, verb, rerun) {
|
|
700
|
+
const spin = spinner(`Installing ${style.bold(pkg)}`);
|
|
701
|
+
let result;
|
|
702
|
+
try {
|
|
703
|
+
result = await addDependency(dir, pkg, {
|
|
704
|
+
rerun,
|
|
705
|
+
onLink: (member) => spin.update(`Linking ${member} into the npm workspace`),
|
|
706
|
+
onRetry: () => spin.update(`Installing ${pkg} (retrying with --legacy-peer-deps)`)
|
|
707
|
+
});
|
|
708
|
+
} finally {
|
|
709
|
+
spin.stop();
|
|
710
|
+
}
|
|
711
|
+
if (result.status !== 0) {
|
|
712
|
+
if (result.peerConflict !== null) {
|
|
713
|
+
warn(
|
|
714
|
+
result.retried ? `${pkg} declares a peer range this project does not satisfy; --legacy-peer-deps did not resolve it either.` : `${pkg} declares a peer range this project does not satisfy, and the install ran out of time before --legacy-peer-deps could be tried.`,
|
|
715
|
+
"module.peer-unresolved"
|
|
716
|
+
);
|
|
717
|
+
process.stderr.write(terminalText(result.peerConflict.trimEnd()) + "\n");
|
|
718
|
+
}
|
|
719
|
+
process.stderr.write(terminalText(result.output.trimEnd()) + "\n");
|
|
720
|
+
throw new Error(`${addCommandFor(dir, pkg)} failed (exit ${result.status}).`);
|
|
721
|
+
}
|
|
722
|
+
if (result.recorded === void 0 || result.landed === void 0 && verb === "install") {
|
|
723
|
+
process.stderr.write(terminalText(result.output.trimEnd()) + "\n");
|
|
724
|
+
throw new Error(
|
|
725
|
+
`${addCommandFor(dir, pkg)} exited 0, but ` + (result.recorded === void 0 ? `this project's package.json does not list ${pkg}` : `${result.recorded} does not resolve from this project`) + ` \u2014 nothing was installed.`
|
|
726
|
+
);
|
|
727
|
+
}
|
|
728
|
+
if (result.peerConflict !== null) {
|
|
729
|
+
const refused = condenseNpmError(result.peerConflict);
|
|
730
|
+
warn(
|
|
731
|
+
`${pkg} declares a peer range this project does not satisfy \u2014 installed with --legacy-peer-deps.`,
|
|
732
|
+
"module.legacy-peer-deps",
|
|
733
|
+
["npm refused the tree it would otherwise have installed:", ...refused !== "" ? [refused] : []]
|
|
734
|
+
);
|
|
735
|
+
}
|
|
736
|
+
return result;
|
|
737
|
+
}
|
|
738
|
+
function reportSync(sync, json) {
|
|
739
|
+
const configured = sync.modules.filter((m) => m.action === "configured");
|
|
740
|
+
if (configured.length > 0 && !canPrompt({ json })) {
|
|
741
|
+
detail(
|
|
742
|
+
json === true ? `--json: nothing was prompted, so each setting is this project's stored value or the module's declared default.` : `Not a terminal, so nothing was prompted \u2014 each setting is this project's stored value or the module's declared default.`
|
|
743
|
+
);
|
|
744
|
+
}
|
|
745
|
+
for (const mod of sync.modules) {
|
|
746
|
+
if (mod.action === "configured") detail(`Configured ${mod.pkg}.`);
|
|
747
|
+
if (mod.action === "removed") detail(`Dropped the settings for ${mod.pkg}, which is no longer a dependency.`);
|
|
748
|
+
}
|
|
749
|
+
for (const pkg of sync.unconfigured) {
|
|
750
|
+
warn(`${pkg} was left unconfigured, so it runs on its own defaults.`, "module.unconfigured");
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
async function reportNextStep(dir, spec) {
|
|
754
|
+
const pkg = packageNameOf(spec);
|
|
755
|
+
const kind = classifyInstalled(dir, pkg);
|
|
756
|
+
if (kind === "absent") return;
|
|
757
|
+
if (kind === "ordinary" && hasXanoSdkField(dir, pkg)) return;
|
|
758
|
+
if (kind === "toolchain") {
|
|
759
|
+
detail(
|
|
760
|
+
`Extends the CLI (nothing to register). Configured in this project's package.json "xanosdk" block.`
|
|
761
|
+
);
|
|
762
|
+
return;
|
|
763
|
+
}
|
|
764
|
+
const { inProject: inProject2, partitionRegistrations, readRegistration, renderImports, renderRegisterCall } = await import("./init-modules-RY7UHAOL.js");
|
|
765
|
+
const registration = await readRegistration(dir, pkg);
|
|
766
|
+
if (kind === "ordinary" && !("register" in registration)) return;
|
|
767
|
+
if (!("register" in registration)) {
|
|
768
|
+
const specifier = specifierOf(pkg);
|
|
769
|
+
const importers = (reachableSources(dir) ?? backendSources(dir)).filter((f) => specifier.test(f.code)).map((f) => f.rel);
|
|
770
|
+
detail(
|
|
771
|
+
importers.length > 0 ? `Already imported in ${importers.join(", ")} \u2014 nothing else to wire.` : `Import it in your backend (\`xano/index.ts\`) and register it onto your workspace.`
|
|
772
|
+
);
|
|
773
|
+
return;
|
|
774
|
+
}
|
|
775
|
+
const { registrars, unknown } = backendRegistration(dir, pkg, registration.register);
|
|
776
|
+
if (registrars.length > 0) {
|
|
777
|
+
detail(`Already registered in ${registrars.join(", ")} \u2014 nothing else to wire.`);
|
|
778
|
+
return;
|
|
779
|
+
}
|
|
780
|
+
const entry = join(backendDirIn(dir), "index.ts");
|
|
781
|
+
const entryRel = relForwardSlash(dir, entry);
|
|
782
|
+
if (unknown.length > 0) {
|
|
783
|
+
detail(
|
|
784
|
+
`Could not tell whether ${pkg} is registered: ${unknown.join(", ")} reaches it in a way this check cannot follow. Check ${entryRel} \u2014 it is wired when \`${registration.register}(\u2026)\` runs once on your workspace.`
|
|
785
|
+
);
|
|
786
|
+
return;
|
|
787
|
+
}
|
|
788
|
+
const manifest = readProjectManifest(dir);
|
|
789
|
+
const present = new Set(manifest === null ? [] : declaredDependencies(manifest));
|
|
790
|
+
const cli = `${inProject2(dir)}${installedCliAt(dir)}`;
|
|
791
|
+
const missing = [
|
|
792
|
+
...new Set(
|
|
793
|
+
Object.values(registration.options).filter((ref) => "package" in ref && !present.has(ref.package)).map((ref) => ref.package)
|
|
794
|
+
)
|
|
795
|
+
];
|
|
796
|
+
const { unwired } = partitionRegistrations([registration], present);
|
|
797
|
+
if (unwired.length > 0 && (missing.length === 0 || unwired[0].options === void 0)) {
|
|
798
|
+
detail(`Not registered yet \u2014 import it in your backend (\`xano/index.ts\`) and register it onto your workspace; ${spellProjectCli(unwired[0].reason, installedCliAt(dir)).replace(/`npx /g, `\`${inProject2(dir)}npx `)}.`);
|
|
799
|
+
return;
|
|
800
|
+
}
|
|
801
|
+
const first = missing.length === 0 ? "" : ` First add ${missing.join(", ")}, which it takes an option from: ${missing.map((p) => `\`${cli} marketplace install ${p}\``).join(", then ")}, wired as that prints.
|
|
802
|
+
`;
|
|
803
|
+
const app = workspaceBinding(entry);
|
|
804
|
+
const call = renderRegisterCall(registration.register, registration.options, app);
|
|
805
|
+
const lines = [
|
|
806
|
+
...renderImports([registration]),
|
|
807
|
+
registration.binding === null ? call : `const ${registration.binding} = ${call}`
|
|
808
|
+
];
|
|
809
|
+
const refresh = hasRoutesScript(dir) ? `${cli} export ./${entryRel} --out /dev/null && npm run xano:routes` : `${cli} export ./${entryRel} --out /dev/null`;
|
|
810
|
+
detail(
|
|
811
|
+
`Not registered yet.
|
|
812
|
+
${first} Add to ${entryRel}:
|
|
813
|
+
${lines.map((line) => ` ${line}`).join("\n")}
|
|
814
|
+
Then run \`${refresh}\` to bring xano.lock and the route manifest up to date.`
|
|
815
|
+
);
|
|
816
|
+
}
|
|
817
|
+
function workspaceBinding(entry) {
|
|
818
|
+
try {
|
|
819
|
+
const code = withoutComments(readFileSync(entry, "utf8"));
|
|
820
|
+
const bound = /\b(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=\s*workspace\s*\(/.exec(code);
|
|
821
|
+
if (bound !== null) return bound[1];
|
|
822
|
+
} catch {
|
|
823
|
+
}
|
|
824
|
+
return "app";
|
|
825
|
+
}
|
|
826
|
+
function hasRoutesScript(dir) {
|
|
827
|
+
const scripts = readProjectManifest(dir)?.["scripts"];
|
|
828
|
+
return typeof scripts === "object" && scripts !== null && typeof scripts["xano:routes"] === "string";
|
|
829
|
+
}
|
|
830
|
+
function refusePromptFlag(args, verb) {
|
|
831
|
+
if (!args.prompt) return;
|
|
832
|
+
throw new UsageError(
|
|
833
|
+
`\`xanosdk marketplace ${verb}\`: --prompt belongs to \`marketplace details <package>\`, which is the verb that has an agent prompt to print.`,
|
|
834
|
+
{ helpFor: { command: "marketplace", subcommand: verb } }
|
|
835
|
+
);
|
|
836
|
+
}
|
|
837
|
+
function tagLine(tags) {
|
|
838
|
+
return tags.length > 0 ? tags.join(" \xB7 ") : void 0;
|
|
839
|
+
}
|
|
840
|
+
function renderRow(row) {
|
|
841
|
+
const s = stdoutStyle();
|
|
842
|
+
const name = row.npm_package ?? row.slug ?? "(unnamed)";
|
|
843
|
+
const title = row.title !== void 0 ? ` ${s.dim(safeText(row.title))}` : "";
|
|
844
|
+
const lines = [` ${s.bold(s.cyan(safeText(name)))}${title}`];
|
|
845
|
+
if (row.tagline !== void 0) lines.push(` ${safeText(row.tagline)}`);
|
|
846
|
+
const tags = tagLine(row.tags);
|
|
847
|
+
if (tags !== void 0) lines.push(` ${s.dim(safeText(tags))}`);
|
|
848
|
+
if (row.docs_url !== void 0) lines.push(` ${s.dim(safeText(row.docs_url))}`);
|
|
849
|
+
return lines.join("\n");
|
|
850
|
+
}
|
|
851
|
+
function writeRows(args, rows, empty, extra = {}) {
|
|
852
|
+
if (isMachineOutput(args)) {
|
|
853
|
+
writeJson({ ...extra, modules: rows });
|
|
854
|
+
return;
|
|
855
|
+
}
|
|
856
|
+
const s = stdoutStyle();
|
|
857
|
+
if (rows.length === 0) {
|
|
858
|
+
printHuman(`${empty}
|
|
859
|
+
`);
|
|
860
|
+
return;
|
|
861
|
+
}
|
|
862
|
+
const count = `${rows.length} add-on${rows.length === 1 ? "" : "s"}`;
|
|
863
|
+
printHuman(
|
|
864
|
+
`
|
|
865
|
+
${s.dim(count)}
|
|
866
|
+
|
|
867
|
+
` + rows.map(renderRow).join("\n\n") + `
|
|
868
|
+
|
|
869
|
+
${s.dim("xanosdk marketplace details <package> for what a module installs")}
|
|
870
|
+
`
|
|
871
|
+
);
|
|
872
|
+
}
|
|
873
|
+
async function runMarketplaceListCommand(args) {
|
|
874
|
+
refusePromptFlag(args, "list");
|
|
875
|
+
writeRows(args, await fetchCatalogue(), "No add-ons are published yet.");
|
|
876
|
+
}
|
|
877
|
+
async function runMarketplaceSearchCommand(args) {
|
|
878
|
+
refusePromptFlag(args, "search");
|
|
879
|
+
const query = args.positionals[0];
|
|
880
|
+
if (query === void 0 || query === "") {
|
|
881
|
+
throw missingArgument("string", { command: "marketplace", subcommand: "search" });
|
|
882
|
+
}
|
|
883
|
+
const q = args.positionals.join(" ");
|
|
884
|
+
writeRows(
|
|
885
|
+
args,
|
|
886
|
+
await searchCatalogue(q),
|
|
887
|
+
`Nothing matched "${q}". Run \`xanosdk marketplace list\` to see everything.`,
|
|
888
|
+
{ query: q }
|
|
889
|
+
);
|
|
890
|
+
}
|
|
891
|
+
function renderModule(mod) {
|
|
892
|
+
const s = stdoutStyle();
|
|
893
|
+
const out = [];
|
|
894
|
+
const name = mod.npm_package ?? mod.slug ?? "(unnamed)";
|
|
895
|
+
out.push(`
|
|
896
|
+
${s.bold(s.cyan(safeText(mod.title ?? name)))}`);
|
|
897
|
+
if (mod.tagline !== void 0) out.push(` ${safeText(mod.tagline)}`);
|
|
898
|
+
if (mod.description !== void 0) {
|
|
899
|
+
out.push("");
|
|
900
|
+
out.push(s.dim(indentBlock(mod.description, " ")));
|
|
901
|
+
}
|
|
902
|
+
out.push("");
|
|
903
|
+
const fields = [["Package", s.bold(name)]];
|
|
904
|
+
const tags = tagLine(mod.tags);
|
|
905
|
+
if (tags !== void 0) fields.push(["Tags", s.dim(tags)]);
|
|
906
|
+
if (mod.docs_url !== void 0) fields.push(["Docs", mod.docs_url]);
|
|
907
|
+
if (mod.repo_url !== void 0) fields.push(["Repo", mod.repo_url]);
|
|
908
|
+
out.push(formatFields(fields).trimEnd());
|
|
909
|
+
if (mod.includes.length > 0) {
|
|
910
|
+
out.push(`
|
|
911
|
+
${s.bold("Installs")}`);
|
|
912
|
+
const width = Math.max(...mod.includes.map((i) => (i.kind ?? "").length));
|
|
913
|
+
for (const item of mod.includes) {
|
|
914
|
+
const kind = s.dim((item.kind ?? "").padEnd(width));
|
|
915
|
+
const summary = item.summary !== void 0 ? s.dim(` \u2014 ${item.summary}`) : "";
|
|
916
|
+
out.push(` ${kind} ${item.name ?? ""}${summary}`);
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
if (mod.requirements.length > 0) {
|
|
920
|
+
out.push(`
|
|
921
|
+
${s.bold("You supply")}`);
|
|
922
|
+
for (const req of mod.requirements) out.push(` \u2022 ${req}`);
|
|
923
|
+
}
|
|
924
|
+
if (mod.register_snippet !== void 0) {
|
|
925
|
+
out.push(`
|
|
926
|
+
${s.bold("Register it")}`);
|
|
927
|
+
out.push(s.dim(indentBlock(mod.register_snippet, " ")));
|
|
928
|
+
}
|
|
929
|
+
if (mod.npm_package !== void 0) {
|
|
930
|
+
out.push(`
|
|
931
|
+
${s.bold(s.green(`xanosdk marketplace install ${mod.npm_package}`))}`);
|
|
932
|
+
}
|
|
933
|
+
if (mod.agent_prompt !== void 0) {
|
|
934
|
+
out.push(
|
|
935
|
+
` ${s.dim(`xanosdk marketplace details ${name} --prompt to hand the wiring to a coding agent`)}`
|
|
936
|
+
);
|
|
937
|
+
}
|
|
938
|
+
return out.join("\n") + "\n";
|
|
939
|
+
}
|
|
940
|
+
async function runMarketplaceDetailsCommand(args) {
|
|
941
|
+
const pkg = resolvePackage(args, "details");
|
|
942
|
+
let mod;
|
|
943
|
+
try {
|
|
944
|
+
mod = await fetchModule(pkg);
|
|
945
|
+
} catch (err) {
|
|
946
|
+
if (err instanceof ModuleNotFoundError) {
|
|
947
|
+
throw await notInMarketplaceError("xanosdk marketplace details", pkg);
|
|
948
|
+
}
|
|
949
|
+
throw err;
|
|
950
|
+
}
|
|
951
|
+
if (mod.deleted === true) {
|
|
952
|
+
warn(`${mod.npm_package ?? pkg} has been removed from the marketplace.`, "module.removed-from-marketplace");
|
|
953
|
+
}
|
|
954
|
+
if (args.prompt) {
|
|
955
|
+
if (mod.agent_prompt === void 0) {
|
|
956
|
+
throw new Error(
|
|
957
|
+
`${mod.npm_package ?? pkg} publishes no agent prompt. Run \`xanosdk marketplace details ${pkg}\` for its registration snippet instead.`
|
|
958
|
+
);
|
|
959
|
+
}
|
|
960
|
+
process.stdout.write(mod.agent_prompt + "\n");
|
|
961
|
+
return;
|
|
962
|
+
}
|
|
963
|
+
if (isMachineOutput(args)) {
|
|
964
|
+
writeJson(mod);
|
|
965
|
+
return;
|
|
966
|
+
}
|
|
967
|
+
printHuman(renderModule(mod));
|
|
968
|
+
}
|
|
969
|
+
export {
|
|
970
|
+
runMarketplaceDetailsCommand,
|
|
971
|
+
runMarketplaceInstallCommand,
|
|
972
|
+
runMarketplaceListCommand,
|
|
973
|
+
runMarketplaceReinstallCommand,
|
|
974
|
+
runMarketplaceRemoveCommand,
|
|
975
|
+
runMarketplaceSearchCommand
|
|
976
|
+
};
|
|
977
|
+
//# sourceMappingURL=marketplace-command-K5YL42NO.js.map
|