vercel 59.14.0 → 59.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/add-7XFD2OHW.js +8 -0
- package/dist/chunks/add-HZC7AUBY.js +8 -0
- package/dist/chunks/add-PYUNJZ6K.js +8 -0
- package/dist/chunks/build-EFKQ6BND.js +7 -0
- package/dist/chunks/chunk-2B2MN3U5.js +8 -0
- package/dist/chunks/chunk-2H77IRPI.js +9 -0
- package/dist/chunks/chunk-2I64AYHG.js +7 -0
- package/dist/chunks/chunk-2PPXY24N.js +20 -0
- package/dist/chunks/chunk-2S6PE6GB.js +7 -0
- package/dist/chunks/{chunk-PIMIVJYK.js → chunk-3FMJYJUR.js} +7 -32
- package/dist/chunks/chunk-3IAQUNQH.js +7 -0
- package/dist/chunks/chunk-3QHJYVCY.js +7 -0
- package/dist/chunks/chunk-3QT7VOE3.js +7 -0
- package/dist/chunks/chunk-3TXEXPUW.js +7 -0
- package/dist/chunks/chunk-4MZK6JT6.js +7 -0
- package/dist/chunks/chunk-4NE5IQ25.js +7 -0
- package/dist/chunks/chunk-4PNSSS3L.js +7 -0
- package/dist/chunks/chunk-4QX77CP7.js +7 -0
- package/dist/chunks/chunk-562OXD3F.js +21 -0
- package/dist/chunks/chunk-57GHYR4Y.js +25 -0
- package/dist/chunks/chunk-5QQNYN4N.js +7 -0
- package/dist/chunks/chunk-5XJNPXQK.js +7 -0
- package/dist/chunks/chunk-6L236MNA.js +7 -0
- package/dist/chunks/chunk-6PFC3KWQ.js +7 -0
- package/dist/chunks/chunk-6QKS6QK7.js +7 -0
- package/dist/chunks/chunk-6RIQPTJA.js +8 -0
- package/dist/chunks/chunk-6TAQ6OWD.js +13 -0
- package/dist/chunks/chunk-6YAADRQB.js +9 -0
- package/dist/chunks/chunk-75CPY75D.js +15 -0
- package/dist/chunks/chunk-7HL2RPUO.js +7 -0
- package/dist/chunks/chunk-7PNYOSDU.js +9 -0
- package/dist/chunks/chunk-7R5FEXZ5.js +7 -0
- package/dist/chunks/chunk-7RMCBXBB.js +62 -0
- package/dist/chunks/chunk-7RR7MIMT.js +7 -0
- package/dist/chunks/chunk-7T6TL3GQ.js +7 -0
- package/dist/chunks/chunk-ADUYPK2G.js +13 -0
- package/dist/chunks/chunk-AFPOIDM5.js +7 -0
- package/dist/chunks/chunk-AM46JVVN.js +7 -0
- package/dist/chunks/chunk-AUGK2HIT.js +18 -0
- package/dist/chunks/chunk-AVSPFBLM.js +7 -0
- package/dist/chunks/chunk-B4ATVYZW.js +7 -0
- package/dist/chunks/chunk-BATE73HA.js +9 -0
- package/dist/chunks/{chunk-64IF634X.js → chunk-BRK4OB4B.js} +1 -12
- package/dist/chunks/chunk-BVH2AEFE.js +7 -0
- package/dist/chunks/chunk-CGOVWHI3.js +45 -0
- package/dist/chunks/chunk-CN2QZO4U.js +7 -0
- package/dist/chunks/chunk-COQGD2EI.js +8 -0
- package/dist/chunks/chunk-CUAIEGNE.js +7 -0
- package/dist/chunks/chunk-CVKB54WW.js +7 -0
- package/dist/chunks/{chunk-A3NYPUKZ.js → chunk-CZSOZKHX.js} +1 -11
- package/dist/chunks/chunk-D3EHMP4U.js +24 -0
- package/dist/chunks/chunk-D4MW3RDW.js +7 -0
- package/dist/chunks/chunk-DFVNL5ML.js +7 -0
- package/dist/chunks/chunk-EE3FVJLV.js +16 -0
- package/dist/chunks/chunk-EGMJRU5P.js +28 -0
- package/dist/chunks/chunk-ENBTTYJR.js +7 -0
- package/dist/chunks/chunk-ENS6KX2F.js +7 -0
- package/dist/chunks/chunk-EOBD4ZEG.js +8 -0
- package/dist/chunks/chunk-EOCTK4EA.js +7 -0
- package/dist/chunks/chunk-EQ52F4LH.js +7 -0
- package/dist/chunks/chunk-ETV3C2CV.js +7 -0
- package/dist/chunks/chunk-EVZRQGNK.js +7 -0
- package/dist/chunks/chunk-F2ZWW2IO.js +8 -0
- package/dist/chunks/chunk-FAW6NBLQ.js +7 -0
- package/dist/chunks/chunk-FI772UVH.js +7 -0
- package/dist/chunks/chunk-FKCOBJFH.js +7 -0
- package/dist/chunks/chunk-G5FC5ZCO.js +9 -0
- package/dist/chunks/chunk-G6CTAHKY.js +39 -0
- package/dist/chunks/chunk-G7Y77DFH.js +7 -0
- package/dist/chunks/chunk-GHAY4PSD.js +7 -0
- package/dist/chunks/chunk-GHM7V3GG.js +7 -0
- package/dist/chunks/chunk-GRNTLNC7.js +7 -0
- package/dist/chunks/chunk-GTRGQIY2.js +10 -0
- package/dist/chunks/chunk-GU6VIFR5.js +7 -0
- package/dist/chunks/{constants-YMCRE6IG.js → chunk-GZNDA6SV.js} +2 -9
- package/dist/chunks/chunk-HBFPLBTX.js +10 -0
- package/dist/chunks/chunk-HEGJZJO7.js +7 -0
- package/dist/chunks/chunk-HSJ6AHWG.js +12 -0
- package/dist/chunks/chunk-HTC6KO2B.js +7 -0
- package/dist/chunks/chunk-HVUHCRZB.js +18 -0
- package/dist/chunks/chunk-HZZ5L472.js +7 -0
- package/dist/chunks/chunk-IVSSTHB6.js +7 -0
- package/dist/chunks/chunk-IVWPQYIH.js +7 -0
- package/dist/chunks/chunk-J3U3L45Y.js +7 -0
- package/dist/chunks/chunk-JAJW3P42.js +7 -0
- package/dist/chunks/chunk-JEIMW3CO.js +7 -0
- package/dist/chunks/chunk-JIYY3B4C.js +7 -0
- package/dist/chunks/chunk-JKTQV2QJ.js +7 -0
- package/dist/chunks/chunk-JTVVBRW7.js +7 -0
- package/dist/chunks/chunk-JYAUUIR4.js +7 -0
- package/dist/chunks/chunk-JZRMH5UA.js +7 -0
- package/dist/chunks/chunk-K2RAW5DI.js +10 -0
- package/dist/chunks/chunk-K3KJZLBD.js +7 -0
- package/dist/chunks/chunk-KK4AJES5.js +36 -0
- package/dist/chunks/chunk-KKS7XWEX.js +7 -0
- package/dist/chunks/chunk-KNEWCUWF.js +14 -0
- package/dist/chunks/chunk-KO733OJG.js +9 -0
- package/dist/chunks/chunk-L243RUIR.js +19 -0
- package/dist/chunks/chunk-L3JDEHCQ.js +7 -0
- package/dist/chunks/chunk-LDM3SQAU.js +13 -0
- package/dist/chunks/chunk-LNPMDXBJ.js +7 -0
- package/dist/chunks/chunk-M2W3HKV3.js +23 -0
- package/dist/chunks/chunk-M2XARQBF.js +9 -0
- package/dist/chunks/chunk-M5AV545M.js +7 -0
- package/dist/chunks/chunk-MAVRGZQP.js +7 -0
- package/dist/chunks/chunk-MBL6TXEJ.js +7 -0
- package/dist/chunks/chunk-MEAY2K5Z.js +11 -0
- package/dist/chunks/chunk-MY4MONOH.js +7 -0
- package/dist/chunks/chunk-N3N5UHIL.js +7 -0
- package/dist/chunks/chunk-N3ZZ7FHQ.js +7 -0
- package/dist/chunks/chunk-N6CNMMSZ.js +7 -0
- package/dist/chunks/chunk-NBVY237X.js +7 -0
- package/dist/chunks/chunk-NGNOUPWS.js +25 -0
- package/dist/chunks/chunk-NHTF332K.js +7 -0
- package/dist/chunks/chunk-NNP5NITU.js +15 -0
- package/dist/chunks/chunk-NS4FH2TY.js +11 -0
- package/dist/chunks/chunk-NUGLE4QY.js +11 -0
- package/dist/chunks/chunk-NWFHHUKZ.js +7 -0
- package/dist/chunks/chunk-O7G3CZ42.js +7 -0
- package/dist/chunks/chunk-OD6RZ3XZ.js +8 -0
- package/dist/chunks/chunk-OHDEHZLX.js +7 -0
- package/dist/chunks/chunk-OK3S6KFX.js +16 -0
- package/dist/chunks/chunk-OKZDOANA.js +23 -0
- package/dist/chunks/chunk-OSCCYU74.js +7 -0
- package/dist/chunks/chunk-OUHPDA7Q.js +7 -0
- package/dist/chunks/chunk-P2O5DOYE.js +7 -0
- package/dist/chunks/chunk-PHW54NU5.js +13 -0
- package/dist/chunks/chunk-PPCFQQSU.js +7 -0
- package/dist/chunks/chunk-QGIGNMII.js +8 -0
- package/dist/chunks/chunk-QGIQK47P.js +7 -0
- package/dist/chunks/chunk-QHJLRTVY.js +7 -0
- package/dist/chunks/{chunk-2473DUBR.js → chunk-QR7QPUFN.js} +1 -9
- package/dist/chunks/chunk-QTKJC2O5.js +7 -0
- package/dist/chunks/chunk-R2TGGVCT.js +19 -0
- package/dist/chunks/chunk-RAIBQIKB.js +7 -0
- package/dist/chunks/chunk-RCTYVKM5.js +16 -0
- package/dist/chunks/chunk-RKAUVPOQ.js +86 -0
- package/dist/chunks/chunk-S5CEIACD.js +7 -0
- package/dist/chunks/chunk-SGWVKRSR.js +8 -0
- package/dist/chunks/chunk-SOJCELXH.js +7 -0
- package/dist/chunks/chunk-SXUEGVWB.js +7 -0
- package/dist/chunks/{chunk-GGPE5377.js → chunk-T3GQAMBJ.js} +1 -9
- package/dist/chunks/chunk-T52FMXWC.js +7 -0
- package/dist/chunks/chunk-TG2RCYTH.js +7 -0
- package/dist/chunks/chunk-TJCIHDPZ.js +9 -0
- package/dist/chunks/chunk-TKBXN4H3.js +9 -0
- package/dist/chunks/chunk-TRTEXGVN.js +7 -0
- package/dist/chunks/chunk-U56NHYAH.js +7 -0
- package/dist/chunks/chunk-U7KCDTCH.js +12 -0
- package/dist/chunks/chunk-UETTIYUQ.js +8 -0
- package/dist/chunks/chunk-ULLWCOYC.js +7 -0
- package/dist/chunks/chunk-UXTHEQVJ.js +21 -0
- package/dist/chunks/chunk-VLZ47RWM.js +44 -0
- package/dist/chunks/chunk-WKZ6JSGZ.js +7 -0
- package/dist/chunks/chunk-WPS6JZF6.js +7 -0
- package/dist/chunks/chunk-WRILLB46.js +7 -0
- package/dist/chunks/chunk-WUZD4KBL.js +7 -0
- package/dist/chunks/chunk-XCJDGQO7.js +7 -0
- package/dist/chunks/{pkg-56KRLZ5K.js → chunk-XD2LZRBS.js} +1 -7
- package/dist/chunks/chunk-XFVGX5HG.js +7 -0
- package/dist/chunks/chunk-XHOGOH6N.js +7 -0
- package/dist/chunks/{update-route-version-E3V47KNI.js → chunk-XPXOV5UO.js} +1 -7
- package/dist/chunks/chunk-XQ73QIQ3.js +7 -0
- package/dist/chunks/chunk-XSVBYDYI.js +8 -0
- package/dist/chunks/chunk-YKZLKOOD.js +12 -0
- package/dist/chunks/chunk-YMVDWVMO.js +7 -0
- package/dist/chunks/chunk-YPTLSODC.js +7 -0
- package/dist/chunks/chunk-YV6CTDHR.js +7 -0
- package/dist/chunks/chunk-Z6Y55QJW.js +23 -0
- package/dist/chunks/chunk-ZDX75YNZ.js +7 -0
- package/dist/chunks/chunk-ZIPVX7LD.js +7 -0
- package/dist/chunks/chunk-ZKYS7EAB.js +7 -0
- package/dist/chunks/chunk-ZXE4XYIV.js +7 -0
- package/dist/chunks/chunk-ZZQRMRWD.js +20 -0
- package/dist/chunks/cjs-GOQHXIHX.js +54 -0
- package/dist/chunks/clear-5NQAVWIF.js +8 -0
- package/dist/chunks/compile-vercel-config-6J2XUFRK.js +7 -0
- package/dist/chunks/config-CKYRXZXL.js +7 -0
- package/dist/chunks/config-VNUY4RJ4.js +8 -0
- package/dist/chunks/connect-git-provider-GIU5WZ52.js +7 -0
- package/dist/chunks/constants-G4UYVLOF.js +7 -0
- package/dist/chunks/create-project-SRQGD4JY.js +7 -0
- package/dist/chunks/delete-GTXXCSKQ.js +10 -0
- package/dist/chunks/delete-HRJEO4MI.js +9 -0
- package/dist/chunks/detect-projects-2GNCZ4CS.js +7 -0
- package/dist/chunks/detect-services-GHILEGNU.js +7 -0
- package/dist/chunks/disable-RWCRVG5O.js +7 -0
- package/dist/chunks/discard-SHFIYCJU.js +14 -0
- package/dist/chunks/edit-DMO3NSO2.js +9 -0
- package/dist/chunks/edit-EVQI2RSS.js +8 -0
- package/dist/chunks/enable-AWDU6STD.js +7 -0
- package/dist/chunks/esm-7HVUFWMN.js +7 -0
- package/dist/chunks/esm-BZBEM7YA.js +7 -0
- package/dist/chunks/esm-CXICLFA3.js +9 -0
- package/dist/chunks/esm-HDEHVK7I.js +9 -0
- package/dist/chunks/esm-NQRLKALI.js +20 -0
- package/dist/chunks/esm-SZZI53W7.js +7 -0
- package/dist/chunks/esm-WGJFGCLK.js +7 -0
- package/dist/chunks/exec-4AISDHUV.js +16372 -0
- package/dist/chunks/export-IQKTA4RS.js +19 -0
- package/dist/chunks/fetch-proxy-AEAWC6MD.js +7 -0
- package/dist/chunks/future-E2FHKPJN.js +7 -0
- package/dist/chunks/generate-cert-for-deploy-VKOWC4PZ.js +7 -0
- package/dist/chunks/image-LDFYNOCA.js +7 -0
- package/dist/chunks/import-builders-P7CXSX2D.js +7 -0
- package/dist/chunks/inspect-3N47ODIH.js +15 -0
- package/dist/chunks/inspect-53SGDDAH.js +20 -0
- package/dist/chunks/inspect-5INZDUQS.js +19 -0
- package/dist/chunks/inspect-WMT2M335.js +9 -0
- package/dist/chunks/inspect-Y6BUCOUV.js +13 -0
- package/dist/chunks/list-BIAPHKFM.js +11 -0
- package/dist/chunks/list-DMOCRRSE.js +16 -0
- package/dist/chunks/list-K5J7OULR.js +10 -0
- package/dist/chunks/login-DEAEVUHM.js +7 -0
- package/dist/chunks/login-SRVNHI4Y.js +9 -0
- package/dist/chunks/logs-GK7CJBYY.js +7 -0
- package/dist/chunks/ls-7ZX6DCJW.js +12 -0
- package/dist/chunks/ls-AJWN5ZR4.js +12 -0
- package/dist/chunks/ls-BFJWCRLZ.js +12 -0
- package/dist/chunks/ls-KGIE6HCO.js +12 -0
- package/dist/chunks/ls-UVKTHBTE.js +8 -0
- package/dist/chunks/ls-WEG45IOC.js +8 -0
- package/dist/chunks/native-self-update-KOJVRMHR.js +7 -0
- package/dist/chunks/open-OEWPI5G6.js +7 -0
- package/dist/chunks/openapi-MO5HYMHR.js +7 -0
- package/dist/chunks/permissions-EPQBQFE3.js +7 -0
- package/dist/chunks/pkg-YFU67U7I.js +7 -0
- package/dist/chunks/prompt-missing-credentials-IUHLYSQU.js +7 -0
- package/dist/chunks/publish-JG7MEPWT.js +15 -0
- package/dist/chunks/pull-MRKXG6TO.js +7 -0
- package/dist/chunks/purchase-domain-if-available-O5ARXEZ5.js +7 -0
- package/dist/chunks/push-XOXJDFYO.js +7 -0
- package/dist/chunks/query-AL7C6WV2.js +12 -0
- package/dist/chunks/reauthenticate-SH4XR7NH.js +7 -0
- package/dist/chunks/reorder-5DMRFDBY.js +10 -0
- package/dist/chunks/reply-WSRNZWFD.js +9 -0
- package/dist/chunks/repo-info-to-url-SK3VX6UL.js +7 -0
- package/dist/chunks/resolve-YJUXQVOZ.js +12 -0
- package/dist/chunks/resolve-deployment-framework-preset-XF3NJIDS.js +7 -0
- package/dist/chunks/restore-QT3DBGKU.js +16 -0
- package/dist/chunks/rm-MHPIUEZ5.js +8 -0
- package/dist/chunks/rm-MVZFU6RG.js +8 -0
- package/dist/chunks/rm-PXR4J2US.js +8 -0
- package/dist/chunks/rm-WB2AIP3N.js +8 -0
- package/dist/chunks/rm-XRP6MRUT.js +8 -0
- package/dist/chunks/routes-5DERZV5M.js +7 -0
- package/dist/chunks/rule-inspect-TT3DRGCS.js +8 -0
- package/dist/chunks/rules-B5GW4KJH.js +7 -0
- package/dist/chunks/schema-JY5QTZOG.js +14 -0
- package/dist/chunks/schema-KCNKVFT3.js +44 -0
- package/dist/chunks/select-org-KSCYSESV.js +7 -0
- package/dist/chunks/set-7BANEWEL.js +7 -0
- package/dist/chunks/setup-and-link-ZAV3EFGC.js +7 -0
- package/dist/chunks/slugify-O5DBATYT.js +7 -0
- package/dist/chunks/stamp-OX4YO3KY.js +7 -0
- package/dist/chunks/tags-VZR66NUC.js +7 -0
- package/dist/chunks/types-LRXQEDYI.js +14 -0
- package/dist/chunks/update-RBFNNSWE.js +8 -0
- package/dist/chunks/update-route-version-XZAFPQJC.js +7 -0
- package/dist/chunks/utils-B5ZTMQKY.js +58 -0
- package/dist/chunks/vlt-builder-importer-YVCYYRVV.js +11 -0
- package/dist/commands/build/index.js +24 -4925
- package/dist/commands/deploy/index.js +43 -2875
- package/dist/commands/dev/index.js +56 -23857
- package/dist/commands/env/index.js +26 -3411
- package/dist/commands/link/index.js +4 -284
- package/dist/commands/list/index.js +6 -566
- package/dist/commands-bulk.js +1187 -87691
- package/dist/help.js +1 -8
- package/dist/index.js +19 -2591
- package/dist/version.mjs +1 -1
- package/package.json +50 -51
- package/dist/chunks/add-EQZRT4XL.js +0 -221
- package/dist/chunks/add-KMDROZC3.js +0 -196
- package/dist/chunks/add-QPJ3XMBV.js +0 -145
- package/dist/chunks/build-W4HPTAOB.js +0 -251
- package/dist/chunks/chunk-26CU4Q3C.js +0 -598
- package/dist/chunks/chunk-2HSQ7YUK.js +0 -93
- package/dist/chunks/chunk-2JIX6UMI.js +0 -4626
- package/dist/chunks/chunk-2LCFOK66.js +0 -1536
- package/dist/chunks/chunk-332LMJLZ.js +0 -16014
- package/dist/chunks/chunk-3HZLXCVL.js +0 -137
- package/dist/chunks/chunk-3VM7HWF6.js +0 -104
- package/dist/chunks/chunk-3ZE5CFVM.js +0 -346
- package/dist/chunks/chunk-4IALDGB7.js +0 -22
- package/dist/chunks/chunk-4KD5BYHB.js +0 -127
- package/dist/chunks/chunk-4TUMNBEE.js +0 -231
- package/dist/chunks/chunk-4WG2MYCI.js +0 -163
- package/dist/chunks/chunk-57RHXXXG.js +0 -150
- package/dist/chunks/chunk-5AJPMLDV.js +0 -28
- package/dist/chunks/chunk-5EIV6LPQ.js +0 -305
- package/dist/chunks/chunk-5NF5HOBJ.js +0 -1854
- package/dist/chunks/chunk-653QRQAD.js +0 -417
- package/dist/chunks/chunk-67CRVWDF.js +0 -81
- package/dist/chunks/chunk-6E6KPBXY.js +0 -43
- package/dist/chunks/chunk-75VENWDN.js +0 -1892
- package/dist/chunks/chunk-7MRDIPJY.js +0 -107
- package/dist/chunks/chunk-7NRNFV77.js +0 -875
- package/dist/chunks/chunk-7Q45OKWR.js +0 -149
- package/dist/chunks/chunk-AHU7WNL2.js +0 -24
- package/dist/chunks/chunk-AINIBIP4.js +0 -39
- package/dist/chunks/chunk-AJ5HUOWB.js +0 -14059
- package/dist/chunks/chunk-AKLTIZCU.js +0 -46
- package/dist/chunks/chunk-AQ6P3IGG.js +0 -49
- package/dist/chunks/chunk-B5NH7SLK.js +0 -324
- package/dist/chunks/chunk-B5XLQKHI.js +0 -849
- package/dist/chunks/chunk-BEQV3X2L.js +0 -86
- package/dist/chunks/chunk-CAHP7UGE.js +0 -79
- package/dist/chunks/chunk-CFDDM4TX.js +0 -13618
- package/dist/chunks/chunk-CJV7J7B5.js +0 -314
- package/dist/chunks/chunk-CV5YC2EN.js +0 -867
- package/dist/chunks/chunk-CXFY6A6W.js +0 -255
- package/dist/chunks/chunk-D5SMZXVO.js +0 -233
- package/dist/chunks/chunk-E336ZXPP.js +0 -43
- package/dist/chunks/chunk-EDMW7SBH.js +0 -246
- package/dist/chunks/chunk-EFYMIIER.js +0 -40
- package/dist/chunks/chunk-EKPSCRJZ.js +0 -26
- package/dist/chunks/chunk-EOZFDJSY.js +0 -18
- package/dist/chunks/chunk-EWBCSDTM.js +0 -1708
- package/dist/chunks/chunk-EZKW5YJ2.js +0 -177
- package/dist/chunks/chunk-F2QLCXCF.js +0 -2399
- package/dist/chunks/chunk-FGDKMNEN.js +0 -21
- package/dist/chunks/chunk-FRVG4OW3.js +0 -7438
- package/dist/chunks/chunk-FVF4UHDM.js +0 -1288
- package/dist/chunks/chunk-G5FBSUL4.js +0 -822
- package/dist/chunks/chunk-GDOUDU6O.js +0 -74
- package/dist/chunks/chunk-GGP5R3FU.js +0 -129
- package/dist/chunks/chunk-GVNCVKCI.js +0 -68
- package/dist/chunks/chunk-GY5I4AYD.js +0 -122
- package/dist/chunks/chunk-GZLPFESR.js +0 -48
- package/dist/chunks/chunk-HB4UKFDO.js +0 -1295
- package/dist/chunks/chunk-HD4DR3DA.js +0 -818
- package/dist/chunks/chunk-HKHXKSXQ.js +0 -152
- package/dist/chunks/chunk-HM24ZWQL.js +0 -174
- package/dist/chunks/chunk-HRXRELD3.js +0 -338
- package/dist/chunks/chunk-IB5L4LKZ.js +0 -1082
- package/dist/chunks/chunk-IIMSID24.js +0 -104
- package/dist/chunks/chunk-J7JKZM4T.js +0 -58
- package/dist/chunks/chunk-JC2O346E.js +0 -137
- package/dist/chunks/chunk-JSD4EZL3.js +0 -34
- package/dist/chunks/chunk-JZXJZX7O.js +0 -257
- package/dist/chunks/chunk-K3RED3VO.js +0 -566
- package/dist/chunks/chunk-KFWQ3EFH.js +0 -151
- package/dist/chunks/chunk-KW7BS25T.js +0 -466
- package/dist/chunks/chunk-KXDWXXJH.js +0 -70
- package/dist/chunks/chunk-LERVNZTD.js +0 -90
- package/dist/chunks/chunk-LYAAQDNS.js +0 -242
- package/dist/chunks/chunk-M5I6INNF.js +0 -61
- package/dist/chunks/chunk-N6HP5BLI.js +0 -18190
- package/dist/chunks/chunk-ND5CF2H3.js +0 -53
- package/dist/chunks/chunk-NFU4XJIR.js +0 -120
- package/dist/chunks/chunk-NW34PW6V.js +0 -1772
- package/dist/chunks/chunk-OAMU5QO6.js +0 -18
- package/dist/chunks/chunk-OCIZ6ZYA.js +0 -253
- package/dist/chunks/chunk-ORQZKIIB.js +0 -2914
- package/dist/chunks/chunk-P3SKP5WM.js +0 -27
- package/dist/chunks/chunk-P4QNYOFB.js +0 -96
- package/dist/chunks/chunk-P7VSBDR4.js +0 -827
- package/dist/chunks/chunk-PEC3CQSK.js +0 -90
- package/dist/chunks/chunk-PMSMUMUO.js +0 -30
- package/dist/chunks/chunk-PNGVSHR3.js +0 -40
- package/dist/chunks/chunk-POOO7W47.js +0 -916
- package/dist/chunks/chunk-PRWJUY5U.js +0 -848
- package/dist/chunks/chunk-Q2DGFCO7.js +0 -579
- package/dist/chunks/chunk-RBF2NPUP.js +0 -577
- package/dist/chunks/chunk-RBIFXFZX.js +0 -52
- package/dist/chunks/chunk-RDTRWLWB.js +0 -11441
- package/dist/chunks/chunk-RN6V5ODW.js +0 -114
- package/dist/chunks/chunk-RNSMTWA6.js +0 -122
- package/dist/chunks/chunk-RTJASENB.js +0 -59
- package/dist/chunks/chunk-RVBZ64EQ.js +0 -52
- package/dist/chunks/chunk-S7KYDPEM.js +0 -1564
- package/dist/chunks/chunk-SLPSPYVR.js +0 -334
- package/dist/chunks/chunk-SM3F3PYJ.js +0 -522
- package/dist/chunks/chunk-TO7QZGYK.js +0 -105
- package/dist/chunks/chunk-TSBUHSN7.js +0 -3495
- package/dist/chunks/chunk-TSFWMUCY.js +0 -506
- package/dist/chunks/chunk-TZ2YI2VH.js +0 -87
- package/dist/chunks/chunk-UG2WOB5L.js +0 -150
- package/dist/chunks/chunk-UNKHOYMF.js +0 -559
- package/dist/chunks/chunk-UOVWUSLG.js +0 -2099
- package/dist/chunks/chunk-V4RMJKQP.js +0 -36
- package/dist/chunks/chunk-VGIMO3ZK.js +0 -17
- package/dist/chunks/chunk-VGKSIKCC.js +0 -92
- package/dist/chunks/chunk-VP5Y3SZG.js +0 -106
- package/dist/chunks/chunk-VXYGCOKL.js +0 -28
- package/dist/chunks/chunk-W7FGI2GZ.js +0 -233
- package/dist/chunks/chunk-WGGABYO5.js +0 -31
- package/dist/chunks/chunk-XDGOOW3K.js +0 -60
- package/dist/chunks/chunk-XFF5TGRA.js +0 -303
- package/dist/chunks/chunk-XNIZGCN5.js +0 -58
- package/dist/chunks/chunk-XPJLPUKO.js +0 -117
- package/dist/chunks/chunk-XUAWTW4W.js +0 -467
- package/dist/chunks/chunk-YPQSDAEW.js +0 -29
- package/dist/chunks/chunk-YS76T533.js +0 -270
- package/dist/chunks/chunk-ZDU2NODC.js +0 -104
- package/dist/chunks/chunk-ZW6HETRE.js +0 -97
- package/dist/chunks/cjs-DV4RM7XU.js +0 -20743
- package/dist/chunks/clear-4IACMLFU.js +0 -141
- package/dist/chunks/compile-vercel-config-PQQ3OCLV.js +0 -33
- package/dist/chunks/config-BQQKMQBP.js +0 -168
- package/dist/chunks/config-OCPNHXQL.js +0 -127
- package/dist/chunks/delete-HRKIYPCO.js +0 -159
- package/dist/chunks/delete-P2UL3KTU.js +0 -226
- package/dist/chunks/detect-projects-ODNU4PK2.js +0 -18
- package/dist/chunks/detect-services-U7QGT7VO.js +0 -40
- package/dist/chunks/disable-3NYMICQ3.js +0 -198
- package/dist/chunks/discard-RNVEJUK3.js +0 -145
- package/dist/chunks/edit-63S2RQHR.js +0 -162
- package/dist/chunks/edit-CTENFZ7H.js +0 -647
- package/dist/chunks/enable-WILWXAHV.js +0 -204
- package/dist/chunks/exec-4IPHZ55G.js +0 -1291
- package/dist/chunks/export-YHGV3EPK.js +0 -177
- package/dist/chunks/fetch-proxy-R3JZNXBZ.js +0 -99
- package/dist/chunks/image-MWKS2YMB.js +0 -75
- package/dist/chunks/import-builders-H55X5VYD.js +0 -39
- package/dist/chunks/inspect-JTJMK6TO.js +0 -596
- package/dist/chunks/inspect-KBIPLMGR.js +0 -216
- package/dist/chunks/inspect-OP26FDBY.js +0 -171
- package/dist/chunks/inspect-SW4UMWTB.js +0 -175
- package/dist/chunks/inspect-WPLZPVBO.js +0 -145
- package/dist/chunks/list-HE7DWAWH.js +0 -387
- package/dist/chunks/list-OUG7WCT7.js +0 -404
- package/dist/chunks/list-QUSEURJZ.js +0 -426
- package/dist/chunks/login-MIIQJVF3.js +0 -233
- package/dist/chunks/ls-24N3DUK4.js +0 -183
- package/dist/chunks/ls-3Y7KEFKT.js +0 -175
- package/dist/chunks/ls-75F5HIJ5.js +0 -188
- package/dist/chunks/ls-REN6X2X5.js +0 -204
- package/dist/chunks/ls-W4STUDXK.js +0 -223
- package/dist/chunks/ls-Z4CTSD6C.js +0 -210
- package/dist/chunks/open-ARMCLPBK.js +0 -116
- package/dist/chunks/permissions-JKI67F62.js +0 -99
- package/dist/chunks/publish-SMSQ7OX2.js +0 -155
- package/dist/chunks/pull-4QZJZELD.js +0 -45
- package/dist/chunks/push-T6IYQY2J.js +0 -191
- package/dist/chunks/query-CP3JK5LW.js +0 -725
- package/dist/chunks/reorder-RAWKFGLV.js +0 -412
- package/dist/chunks/reply-235UHUD4.js +0 -176
- package/dist/chunks/resolve-5KCLN7QV.js +0 -237
- package/dist/chunks/resolve-deployment-framework-preset-NPE6RLV3.js +0 -36
- package/dist/chunks/restore-D24WAUAN.js +0 -252
- package/dist/chunks/rm-DBQDXSOC.js +0 -162
- package/dist/chunks/rm-G5INO77R.js +0 -148
- package/dist/chunks/rm-NLKSEKZ5.js +0 -195
- package/dist/chunks/rm-QV76CJA4.js +0 -322
- package/dist/chunks/rm-TZ4PDDUK.js +0 -147
- package/dist/chunks/routes-QVMBXOSX.js +0 -24
- package/dist/chunks/rule-inspect-76MC7I2D.js +0 -123
- package/dist/chunks/rules-IDUXVTPG.js +0 -89
- package/dist/chunks/schema-AV6BHGKY.js +0 -237
- package/dist/chunks/schema-QJVQTNB4.js +0 -381
- package/dist/chunks/set-L5NFQSCF.js +0 -250
- package/dist/chunks/setup-and-link-USSVDKCM.js +0 -65
- package/dist/chunks/stamp-AA7R3MZS.js +0 -16
- package/dist/chunks/tags-2NLUU4EC.js +0 -69
- package/dist/chunks/types-4GAJ7XQQ.js +0 -116
- package/dist/chunks/update-WGLBB65M.js +0 -224
- package/dist/chunks/vlt-builder-importer-USCFHWPL.js +0 -322
|
@@ -4,3422 +4,37 @@ import { dirname as __dirname_ } from 'node:path';
|
|
|
4
4
|
const require = __createRequire(import.meta.url);
|
|
5
5
|
const __filename = __fileURLToPath(import.meta.url);
|
|
6
6
|
const __dirname = __dirname_(__filename);
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
getCustomEnvironments,
|
|
10
|
-
readStandardInput,
|
|
11
|
-
require_dist as require_dist3
|
|
12
|
-
} from "../../chunks/chunk-XFF5TGRA.js";
|
|
13
|
-
import {
|
|
14
|
-
getInvalidSubcommand
|
|
15
|
-
} from "../../chunks/chunk-VGIMO3ZK.js";
|
|
16
|
-
import {
|
|
17
|
-
ellipsis
|
|
18
|
-
} from "../../chunks/chunk-OAMU5QO6.js";
|
|
19
|
-
import {
|
|
20
|
-
formatTable
|
|
21
|
-
} from "../../chunks/chunk-GVNCVKCI.js";
|
|
22
|
-
import "../../chunks/chunk-ND5CF2H3.js";
|
|
23
|
-
import {
|
|
24
|
-
isGuidanceEnabled,
|
|
25
|
-
suggestNextCommands
|
|
26
|
-
} from "../../chunks/chunk-AKLTIZCU.js";
|
|
27
|
-
import {
|
|
28
|
-
formatEnvironment
|
|
29
|
-
} from "../../chunks/chunk-EFYMIIER.js";
|
|
30
|
-
import {
|
|
31
|
-
validateLsArgs
|
|
32
|
-
} from "../../chunks/chunk-JSD4EZL3.js";
|
|
33
|
-
import {
|
|
34
|
-
validateJsonOutput
|
|
35
|
-
} from "../../chunks/chunk-KXDWXXJH.js";
|
|
36
|
-
import {
|
|
37
|
-
getSubcommand
|
|
38
|
-
} from "../../chunks/chunk-YPQSDAEW.js";
|
|
39
|
-
import {
|
|
40
|
-
getCommandAliases
|
|
41
|
-
} from "../../chunks/chunk-CFDDM4TX.js";
|
|
42
|
-
import "../../chunks/chunk-CJV7J7B5.js";
|
|
43
|
-
import "../../chunks/chunk-EZKW5YJ2.js";
|
|
44
|
-
import "../../chunks/chunk-NFU4XJIR.js";
|
|
45
|
-
import "../../chunks/chunk-3HZLXCVL.js";
|
|
46
|
-
import "../../chunks/chunk-7Q45OKWR.js";
|
|
47
|
-
import "../../chunks/chunk-GY5I4AYD.js";
|
|
48
|
-
import "../../chunks/chunk-4TUMNBEE.js";
|
|
49
|
-
import "../../chunks/chunk-POOO7W47.js";
|
|
50
|
-
import "../../chunks/chunk-SLPSPYVR.js";
|
|
51
|
-
import "../../chunks/chunk-HKHXKSXQ.js";
|
|
52
|
-
import "../../chunks/chunk-EDMW7SBH.js";
|
|
53
|
-
import "../../chunks/chunk-4KD5BYHB.js";
|
|
54
|
-
import "../../chunks/chunk-XDGOOW3K.js";
|
|
55
|
-
import "../../chunks/chunk-VP5Y3SZG.js";
|
|
56
|
-
import {
|
|
57
|
-
autoInstallVercelPlugin
|
|
58
|
-
} from "../../chunks/chunk-K3RED3VO.js";
|
|
59
|
-
import {
|
|
60
|
-
require_execa
|
|
61
|
-
} from "../../chunks/chunk-5NF5HOBJ.js";
|
|
62
|
-
import {
|
|
63
|
-
stamp_default
|
|
64
|
-
} from "../../chunks/chunk-64IF634X.js";
|
|
65
|
-
import "../../chunks/chunk-ZDU2NODC.js";
|
|
66
|
-
import "../../chunks/chunk-PEC3CQSK.js";
|
|
67
|
-
import "../../chunks/chunk-VXYGCOKL.js";
|
|
68
|
-
import {
|
|
69
|
-
require_ms
|
|
70
|
-
} from "../../chunks/chunk-GGP5R3FU.js";
|
|
71
|
-
import {
|
|
72
|
-
ENV_VISIBILITY_DEPRECATION_MESSAGE,
|
|
73
|
-
SENSITIVE_ENV_VALUE_PLACEHOLDER,
|
|
74
|
-
formatVisibilityLabel,
|
|
75
|
-
getApiPublicPrefix,
|
|
76
|
-
getEnvKeyWarnings,
|
|
77
|
-
getEnvRecords,
|
|
78
|
-
getFrameworkPublicPrefix,
|
|
79
|
-
getLocalSecretFallbackMessage,
|
|
80
|
-
getLocalSvelteKitPublicPrefixes,
|
|
81
|
-
getPublicPrefix,
|
|
82
|
-
getPublicPrefixSecretVisibilityError,
|
|
83
|
-
getUnavailableSecretValuesMessage,
|
|
84
|
-
isFlagsSecretNeedingSplit,
|
|
85
|
-
isSecretEnvVar,
|
|
86
|
-
looksLikeSecret,
|
|
87
|
-
looksLikeSecretValue,
|
|
88
|
-
normalizeStdinEnvValue,
|
|
89
|
-
pull,
|
|
90
|
-
pullEnvRecords,
|
|
91
|
-
removePublicPrefix,
|
|
92
|
-
resolveEnvVarTypeOption,
|
|
93
|
-
resolveEnvVarVisibility,
|
|
94
|
-
shouldConfirmRotationBeforeDelete,
|
|
95
|
-
validateEnvValue
|
|
96
|
-
} from "../../chunks/chunk-FVF4UHDM.js";
|
|
97
|
-
import {
|
|
98
|
-
resolveProjectContext
|
|
99
|
-
} from "../../chunks/chunk-RTJASENB.js";
|
|
100
|
-
import "../../chunks/chunk-FRVG4OW3.js";
|
|
101
|
-
import "../../chunks/chunk-6E6KPBXY.js";
|
|
102
|
-
import "../../chunks/chunk-JC2O346E.js";
|
|
103
|
-
import "../../chunks/chunk-67CRVWDF.js";
|
|
104
|
-
import "../../chunks/chunk-RNSMTWA6.js";
|
|
105
|
-
import "../../chunks/chunk-UG2WOB5L.js";
|
|
106
|
-
import {
|
|
107
|
-
addSubcommand,
|
|
108
|
-
envCommand,
|
|
109
|
-
envTargetChoices,
|
|
110
|
-
getEnvTargetPlaceholder,
|
|
111
|
-
isValidEnvTarget,
|
|
112
|
-
listSubcommand,
|
|
113
|
-
parseEnvTargetArg,
|
|
114
|
-
pullSubcommand,
|
|
115
|
-
removeSubcommand,
|
|
116
|
-
runSubcommand,
|
|
117
|
-
updateSubcommand
|
|
118
|
-
} from "../../chunks/chunk-XUAWTW4W.js";
|
|
119
|
-
import "../../chunks/chunk-JZXJZX7O.js";
|
|
120
|
-
import "../../chunks/chunk-HRXRELD3.js";
|
|
121
|
-
import {
|
|
122
|
-
STANDARD_ENVIRONMENTS,
|
|
123
|
-
formatProject
|
|
124
|
-
} from "../../chunks/chunk-PNGVSHR3.js";
|
|
125
|
-
import {
|
|
126
|
-
parseTarget
|
|
127
|
-
} from "../../chunks/chunk-RN6V5ODW.js";
|
|
128
|
-
import {
|
|
129
|
-
help
|
|
130
|
-
} from "../../chunks/chunk-YS76T533.js";
|
|
131
|
-
import {
|
|
132
|
-
TelemetryClient,
|
|
133
|
-
require_dist as require_dist2
|
|
134
|
-
} from "../../chunks/chunk-HB4UKFDO.js";
|
|
135
|
-
import "../../chunks/chunk-B5XLQKHI.js";
|
|
136
|
-
import "../../chunks/chunk-SM3F3PYJ.js";
|
|
137
|
-
import "../../chunks/chunk-XNIZGCN5.js";
|
|
138
|
-
import "../../chunks/chunk-NW34PW6V.js";
|
|
139
|
-
import {
|
|
140
|
-
printError
|
|
141
|
-
} from "../../chunks/chunk-3VM7HWF6.js";
|
|
142
|
-
import {
|
|
143
|
-
parseArguments
|
|
144
|
-
} from "../../chunks/chunk-57RHXXXG.js";
|
|
145
|
-
import "../../chunks/chunk-4IALDGB7.js";
|
|
146
|
-
import {
|
|
147
|
-
getTeamByIdOrSlug,
|
|
148
|
-
param,
|
|
149
|
-
printAlignedLabel
|
|
150
|
-
} from "../../chunks/chunk-AJ5HUOWB.js";
|
|
151
|
-
import "../../chunks/chunk-G5FBSUL4.js";
|
|
152
|
-
import {
|
|
153
|
-
buildCommandWithYes,
|
|
154
|
-
buildEnvAddCommandWithPreservedArgs,
|
|
155
|
-
buildEnvRmCommandWithPreservedArgs,
|
|
156
|
-
buildEnvUpdateCommandWithPreservedArgs,
|
|
157
|
-
getPreservedArgsForEnvAdd,
|
|
158
|
-
getPreservedArgsForEnvRm,
|
|
159
|
-
getPreservedArgsForEnvUpdate,
|
|
160
|
-
outputActionRequired,
|
|
161
|
-
outputAgentError,
|
|
162
|
-
quoteArg,
|
|
163
|
-
redactEnvValueArgs,
|
|
164
|
-
withGlobalFlags
|
|
165
|
-
} from "../../chunks/chunk-26CU4Q3C.js";
|
|
166
|
-
import "../../chunks/chunk-XPJLPUKO.js";
|
|
167
|
-
import {
|
|
168
|
-
isAPIError
|
|
169
|
-
} from "../../chunks/chunk-CV5YC2EN.js";
|
|
170
|
-
import {
|
|
171
|
-
getCommandName,
|
|
172
|
-
getCommandNamePlain,
|
|
173
|
-
getFlagsSpecification,
|
|
174
|
-
getGlobalFlagsFromArgs,
|
|
175
|
-
require_lib
|
|
176
|
-
} from "../../chunks/chunk-Q2DGFCO7.js";
|
|
177
|
-
import {
|
|
178
|
-
emoji,
|
|
179
|
-
output_manager_default,
|
|
180
|
-
prependEmoji
|
|
181
|
-
} from "../../chunks/chunk-2JIX6UMI.js";
|
|
182
|
-
import "../../chunks/chunk-P4QNYOFB.js";
|
|
183
|
-
import {
|
|
184
|
-
require_dist
|
|
185
|
-
} from "../../chunks/chunk-ZW6HETRE.js";
|
|
186
|
-
import {
|
|
187
|
-
require_source
|
|
188
|
-
} from "../../chunks/chunk-S7KYDPEM.js";
|
|
189
|
-
import {
|
|
190
|
-
__toESM
|
|
191
|
-
} from "../../chunks/chunk-TZ2YI2VH.js";
|
|
192
|
-
|
|
193
|
-
// src/commands/env/add.ts
|
|
194
|
-
var import_chalk = __toESM(require_source(), 1);
|
|
195
|
-
|
|
196
|
-
// src/util/env/add-env-record.ts
|
|
197
|
-
var import_constants = __toESM(require_dist2(), 1);
|
|
198
|
-
async function addEnvRecord(client, projectId, upsert, type, key, value, targets, gitBranch, visibility) {
|
|
199
|
-
const actionWord = upsert ? "Overriding" : "Adding";
|
|
200
|
-
output_manager_default.debug(
|
|
201
|
-
`${actionWord} ${type} Environment Variable ${key} to ${targets.length} targets`
|
|
202
|
-
);
|
|
203
|
-
const target = [];
|
|
204
|
-
const customEnvironmentIds = [];
|
|
205
|
-
for (const t of targets) {
|
|
206
|
-
const arr = import_constants.PROJECT_ENV_TARGET.includes(t) ? target : customEnvironmentIds;
|
|
207
|
-
arr.push(t);
|
|
208
|
-
}
|
|
209
|
-
const body = {
|
|
210
|
-
type,
|
|
211
|
-
key,
|
|
212
|
-
value,
|
|
213
|
-
target,
|
|
214
|
-
customEnvironmentIds: customEnvironmentIds.length > 0 ? customEnvironmentIds : void 0,
|
|
215
|
-
gitBranch: gitBranch || void 0,
|
|
216
|
-
...visibility !== void 0 ? { visibility } : {}
|
|
217
|
-
};
|
|
218
|
-
const args = upsert ? `?upsert=${upsert}` : "";
|
|
219
|
-
const url = `/v10/projects/${projectId}/env${args}`;
|
|
220
|
-
await client.fetch(url, {
|
|
221
|
-
method: "POST",
|
|
222
|
-
body
|
|
223
|
-
});
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
// src/util/env/known-error.ts
|
|
227
|
-
var import_error_utils = __toESM(require_dist(), 1);
|
|
228
|
-
var knownErrorsCodes = /* @__PURE__ */ new Set([
|
|
229
|
-
"BAD_REQUEST",
|
|
230
|
-
"ENV_ALREADY_EXISTS",
|
|
231
|
-
"ENV_CONFLICT",
|
|
232
|
-
"EXISTING_KEY_AND_TARGET",
|
|
233
|
-
"FORBIDDEN",
|
|
234
|
-
"ID_NOT_FOUND",
|
|
235
|
-
"INVALID_KEY",
|
|
236
|
-
"INVALID_VALUE",
|
|
237
|
-
"KEY_INVALID_CHARACTERS",
|
|
238
|
-
"KEY_INVALID_LENGTH",
|
|
239
|
-
"KEY_RESERVED",
|
|
240
|
-
"RESERVED_ENV_VARIABLE",
|
|
241
|
-
"MAX_ENVS_EXCEEDED",
|
|
242
|
-
"MISSING_ID",
|
|
243
|
-
"MISSING_KEY",
|
|
244
|
-
"MISSING_TARGET",
|
|
245
|
-
"MISSING_VALUE",
|
|
246
|
-
"NOT_AUTHORIZED",
|
|
247
|
-
"NOT_DECRYPTABLE",
|
|
248
|
-
"SYSTEM_ENV_WITH_VALUE",
|
|
249
|
-
"TEAM_NOT_FOUND",
|
|
250
|
-
"TOO_MANY_IDS",
|
|
251
|
-
"TOO_MANY_KEYS",
|
|
252
|
-
"UNKNOWN_ERROR",
|
|
253
|
-
"VALUE_INVALID_LENGTH",
|
|
254
|
-
"VALUE_INVALID_TYPE"
|
|
255
|
-
]);
|
|
256
|
-
function isKnownError(error) {
|
|
257
|
-
const code = (0, import_error_utils.isErrnoException)(error) ? error.code : null;
|
|
258
|
-
if (!code)
|
|
259
|
-
return false;
|
|
260
|
-
return knownErrorsCodes.has(code.toUpperCase());
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
// src/util/telemetry/commands/env/add.ts
|
|
264
|
-
var EnvAddTelemetryClient = class extends TelemetryClient {
|
|
265
|
-
trackCliArgumentName(name) {
|
|
266
|
-
if (name) {
|
|
267
|
-
this.trackCliArgument({
|
|
268
|
-
arg: "name",
|
|
269
|
-
value: this.redactedValue
|
|
270
|
-
});
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
trackCliArgumentEnvironment(environment) {
|
|
274
|
-
if (environment) {
|
|
275
|
-
const allStandard = environment.split(",").map((t) => t.trim()).every((t) => STANDARD_ENVIRONMENTS.includes(t));
|
|
276
|
-
this.trackCliArgument({
|
|
277
|
-
arg: "environment",
|
|
278
|
-
value: allStandard ? environment : this.redactedValue
|
|
279
|
-
});
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
trackCliArgumentGitBranch(gitBranch) {
|
|
283
|
-
if (gitBranch) {
|
|
284
|
-
this.trackCliArgument({
|
|
285
|
-
arg: "git-branch",
|
|
286
|
-
value: this.redactedValue
|
|
287
|
-
});
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
trackCliOptionGitBranch(gitBranch) {
|
|
291
|
-
if (gitBranch) {
|
|
292
|
-
this.trackCliOption({
|
|
293
|
-
option: "git-branch",
|
|
294
|
-
value: this.redactedValue
|
|
295
|
-
});
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
trackCliOptionValue(value) {
|
|
299
|
-
if (value) {
|
|
300
|
-
this.trackCliOption({
|
|
301
|
-
option: "value",
|
|
302
|
-
value: this.redactedValue
|
|
303
|
-
});
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
trackCliOptionVisibility(visibility) {
|
|
307
|
-
if (visibility) {
|
|
308
|
-
const validVisibilities = ["config", "secret"];
|
|
309
|
-
this.trackCliOption({
|
|
310
|
-
option: "visibility",
|
|
311
|
-
value: validVisibilities.includes(visibility) ? visibility : this.redactedValue
|
|
312
|
-
});
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
trackCliOptionType(type) {
|
|
316
|
-
if (type) {
|
|
317
|
-
const validTypes = ["config", "secret"];
|
|
318
|
-
this.trackCliOption({
|
|
319
|
-
option: "type",
|
|
320
|
-
value: validTypes.includes(type) ? type : this.redactedValue
|
|
321
|
-
});
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
trackCliFlagSensitive(sensitive) {
|
|
325
|
-
if (sensitive) {
|
|
326
|
-
this.trackCliFlag("sensitive");
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
trackCliFlagNoSensitive(noSensitive) {
|
|
330
|
-
if (noSensitive) {
|
|
331
|
-
this.trackCliFlag("no-sensitive");
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
trackCliFlagForce(force) {
|
|
335
|
-
if (force) {
|
|
336
|
-
this.trackCliFlag("force");
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
trackCliFlagGuidance(guidance) {
|
|
340
|
-
if (guidance) {
|
|
341
|
-
this.trackCliFlag("guidance");
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
trackCliFlagYes(yes) {
|
|
345
|
-
if (yes) {
|
|
346
|
-
this.trackCliFlag("yes");
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
};
|
|
350
|
-
|
|
351
|
-
// src/commands/env/add.ts
|
|
352
|
-
import { determineAgent } from "@vercel/detect-agent";
|
|
353
|
-
|
|
354
|
-
// src/util/env/secret-storage-guidance.ts
|
|
355
|
-
function includesDevelopment(targets) {
|
|
356
|
-
return targets.length === 0 || targets.includes("development");
|
|
357
|
-
}
|
|
358
|
-
function getProductionSecretPolicyErrorKind(message) {
|
|
359
|
-
if (/production secrets?.*different value|different value.*production secrets?/i.test(
|
|
360
|
-
message
|
|
361
|
-
)) {
|
|
362
|
-
return "different-values";
|
|
363
|
-
}
|
|
364
|
-
if (/production secrets?.*(?:own environment group|separat)|(?:own environment group|separat).*production secrets?/i.test(
|
|
365
|
-
message
|
|
366
|
-
)) {
|
|
367
|
-
return "separate-environments";
|
|
368
|
-
}
|
|
369
|
-
return null;
|
|
370
|
-
}
|
|
371
|
-
function getProductionSecretPolicyRecovery(kind) {
|
|
372
|
-
return kind === "different-values" ? "Use different Secret values for Production and non-Production." : "Create separate Production and non-Production variables with different values.";
|
|
373
|
-
}
|
|
374
|
-
function getSecretStorageChoice(targets, recommendedReason) {
|
|
375
|
-
const availability = includesDevelopment(targets) ? "hidden in the dashboard; Development values can be pulled" : "hidden in the dashboard and unavailable to pulls";
|
|
376
|
-
const recommendation = recommendedReason ? `; recommended ${recommendedReason}` : "";
|
|
377
|
-
return `Secret (${availability}${recommendation})`;
|
|
378
|
-
}
|
|
379
|
-
function getDefaultSecretStorageGuidance(targets) {
|
|
380
|
-
if (includesDevelopment(targets)) {
|
|
381
|
-
return "Stored as Secret by default. This value is hidden in the dashboard; Development values can be pulled. Use `--type config` for other values you need to read later.";
|
|
382
|
-
}
|
|
383
|
-
return "Stored as Secret by default. This value is hidden in the dashboard and unavailable to pulls; use `--type config` for values you need to read later.";
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
// src/commands/env/add.ts
|
|
387
|
-
function looksLikeCredentialName(key, publicPrefix = getPublicPrefix(key)) {
|
|
388
|
-
return looksLikeSecret(publicPrefix ? key.slice(publicPrefix.length) : key);
|
|
389
|
-
}
|
|
390
|
-
function filterEnvChoicesForSensitivity(choices, opts) {
|
|
391
|
-
if (opts.policyOn) {
|
|
392
|
-
return choices.filter((c) => c.value === "development");
|
|
393
|
-
}
|
|
394
|
-
return choices;
|
|
395
|
-
}
|
|
396
|
-
function getTargetCompatibilityError(envTargets, isSensitive, policyOn) {
|
|
397
|
-
const hasSensitiveCapable = envTargets.some((t) => t !== "development");
|
|
398
|
-
if (!isSensitive && policyOn && hasSensitiveCapable) {
|
|
399
|
-
return `Your team requires sensitive Environment Variables for Production and Preview. To add a non-sensitive value, target the Development Environment only. Run ${getCommandName(
|
|
400
|
-
"env add"
|
|
401
|
-
)} with the development target instead.`;
|
|
402
|
-
}
|
|
403
|
-
return null;
|
|
404
|
-
}
|
|
405
|
-
function resolveFinalType(envTargets, isSensitive, opts) {
|
|
406
|
-
const hasDevelopment = envTargets.includes("development");
|
|
407
|
-
if (hasDevelopment && !isSensitive) {
|
|
408
|
-
return "encrypted";
|
|
409
|
-
}
|
|
410
|
-
if (opts.forceEncrypted && !opts.policyOn) {
|
|
411
|
-
return "encrypted";
|
|
412
|
-
}
|
|
413
|
-
if (isSensitive || opts.forceSensitive || opts.policyOn) {
|
|
414
|
-
return "sensitive";
|
|
415
|
-
}
|
|
416
|
-
return "encrypted";
|
|
417
|
-
}
|
|
418
|
-
function fillEnvAddTemplate(template, opts) {
|
|
419
|
-
const targetPlaceholder = getEnvTargetPlaceholder();
|
|
420
|
-
return template.replace(/<name>/g, opts.envName ? quoteArg(opts.envName) : "<name>").split(targetPlaceholder).join(opts.envTargetArg ? quoteArg(opts.envTargetArg) : targetPlaceholder).replace(
|
|
421
|
-
/<git-branch>/g,
|
|
422
|
-
opts.envGitBranch ? quoteArg(opts.envGitBranch) : "<git-branch>"
|
|
423
|
-
).replace(
|
|
424
|
-
/<gitbranch>/g,
|
|
425
|
-
opts.envGitBranch ? quoteArg(opts.envGitBranch) : "<gitbranch>"
|
|
426
|
-
).replace(/<value>/g, "<value>");
|
|
427
|
-
}
|
|
428
|
-
function multiTargetSuggestion(argv, envName, targets, addNoSensitive) {
|
|
429
|
-
const flag = addNoSensitive ? " --no-sensitive" : "";
|
|
430
|
-
return {
|
|
431
|
-
command: buildEnvAddCommandWithPreservedArgs(
|
|
432
|
-
argv,
|
|
433
|
-
`env add ${envName} ${targets.join(",")} --value "<value>"${flag} --yes`
|
|
434
|
-
),
|
|
435
|
-
when: addNoSensitive ? "Add one non-sensitive variable to all listed environments" : "Add one variable to multiple environments"
|
|
436
|
-
};
|
|
437
|
-
}
|
|
438
|
-
function filterSensitiveMultiTargetSuggestionTargets(targets, _opts) {
|
|
439
|
-
return targets;
|
|
440
|
-
}
|
|
441
|
-
function projectLabel(link) {
|
|
442
|
-
return `${link.org.slug}/${link.project.name}`;
|
|
443
|
-
}
|
|
444
|
-
function formatEnvironmentTarget(target, customEnvironments) {
|
|
445
|
-
const standardTarget = envTargetChoices.find(
|
|
446
|
-
(choice) => choice.value === target
|
|
447
|
-
);
|
|
448
|
-
if (standardTarget) {
|
|
449
|
-
return standardTarget.name;
|
|
450
|
-
}
|
|
451
|
-
const customEnvironment = customEnvironments.find(
|
|
452
|
-
(env) => env.id === target || env.slug === target
|
|
453
|
-
);
|
|
454
|
-
return customEnvironment?.slug ?? target;
|
|
455
|
-
}
|
|
456
|
-
function formatEnvironmentTargets(envTargets, customEnvironments) {
|
|
457
|
-
return envTargets.map((target) => formatEnvironmentTarget(target, customEnvironments)).join(", ");
|
|
458
|
-
}
|
|
459
|
-
function printEnvAddResult(link, envName, envTargets, envGitBranch, customEnvironments, finalType, force, visibility) {
|
|
460
|
-
output_manager_default.print("\n");
|
|
461
|
-
printAlignedLabel(force ? "Overrode" : "Added", envName, { gutter: "\u2713" });
|
|
462
|
-
printAlignedLabel("Project", projectLabel(link));
|
|
463
|
-
printAlignedLabel(
|
|
464
|
-
"Environments",
|
|
465
|
-
formatEnvironmentTargets(envTargets, customEnvironments)
|
|
466
|
-
);
|
|
467
|
-
if (envGitBranch) {
|
|
468
|
-
printAlignedLabel("Branch", envGitBranch);
|
|
469
|
-
}
|
|
470
|
-
const visibilityLabel = formatVisibilityLabel(visibility, finalType);
|
|
471
|
-
if (visibilityLabel) {
|
|
472
|
-
printAlignedLabel("Type", visibilityLabel);
|
|
473
|
-
}
|
|
474
|
-
}
|
|
475
|
-
function printEnvAddWarning(message) {
|
|
476
|
-
output_manager_default.print(`${import_chalk.default.yellow("!")} ${message}
|
|
477
|
-
`);
|
|
478
|
-
}
|
|
479
|
-
function promptEnvValue(client, opts) {
|
|
480
|
-
return client.input.text({
|
|
481
|
-
message: `Value?`,
|
|
482
|
-
...opts.isSensitive ? { transformer: (value) => "*".repeat(value.length) } : {}
|
|
483
|
-
});
|
|
484
|
-
}
|
|
485
|
-
function buildHumanEnvAddCommand(argv, commandTemplate) {
|
|
486
|
-
const globalFlags = getGlobalFlagsFromArgs(argv.slice(2), {
|
|
487
|
-
preserveProject: true
|
|
488
|
-
}).filter((flag) => !flag.startsWith("--non-interactive"));
|
|
489
|
-
const suffix = globalFlags.length > 0 ? ` ${globalFlags.map(quoteArg).join(" ")}` : "";
|
|
490
|
-
return getCommandNamePlain(`${commandTemplate}${suffix}`);
|
|
491
|
-
}
|
|
492
|
-
async function add(client, argv) {
|
|
493
|
-
let parsedArgs;
|
|
494
|
-
const flagsSpecification = getFlagsSpecification(addSubcommand.options);
|
|
495
|
-
try {
|
|
496
|
-
parsedArgs = parseArguments(argv, flagsSpecification);
|
|
497
|
-
} catch (err) {
|
|
498
|
-
if (client.nonInteractive) {
|
|
499
|
-
outputAgentError(
|
|
500
|
-
client,
|
|
501
|
-
{
|
|
502
|
-
status: "error",
|
|
503
|
-
reason: "invalid_arguments",
|
|
504
|
-
message: err instanceof Error ? err.message : String(err)
|
|
505
|
-
},
|
|
506
|
-
1
|
|
507
|
-
);
|
|
508
|
-
}
|
|
509
|
-
printError(err);
|
|
510
|
-
return 1;
|
|
511
|
-
}
|
|
512
|
-
const { args, flags: opts } = parsedArgs;
|
|
513
|
-
const stdInput = await readStandardInput(client.stdin);
|
|
514
|
-
const valueFromFlag = typeof opts["--value"] === "string" ? opts["--value"] : void 0;
|
|
515
|
-
let [envName, envTargetArg] = args;
|
|
516
|
-
const positionalGitBranch = args[2];
|
|
517
|
-
const optionGitBranch = typeof opts["--git-branch"] === "string" ? opts["--git-branch"] : void 0;
|
|
518
|
-
let envGitBranch = optionGitBranch ?? positionalGitBranch;
|
|
519
|
-
const forceSensitive = Boolean(opts["--sensitive"]);
|
|
520
|
-
const forceEncrypted = Boolean(opts["--no-sensitive"]);
|
|
521
|
-
const typeOption = resolveEnvVarTypeOption({
|
|
522
|
-
type: typeof opts["--type"] === "string" ? opts["--type"] : void 0,
|
|
523
|
-
visibility: typeof opts["--visibility"] === "string" ? opts["--visibility"] : void 0
|
|
524
|
-
});
|
|
525
|
-
let explicitType = typeOption.explicitVisibility;
|
|
526
|
-
let typeSource = explicitType || forceSensitive || forceEncrypted ? "argv" : void 0;
|
|
527
|
-
const telemetryClient = new EnvAddTelemetryClient({
|
|
528
|
-
opts: {
|
|
529
|
-
store: client.telemetryEventStore
|
|
530
|
-
}
|
|
531
|
-
});
|
|
532
|
-
telemetryClient.trackCliArgumentName(envName);
|
|
533
|
-
telemetryClient.trackCliArgumentEnvironment(envTargetArg);
|
|
534
|
-
telemetryClient.trackCliArgumentGitBranch(positionalGitBranch);
|
|
535
|
-
telemetryClient.trackCliOptionGitBranch(optionGitBranch);
|
|
536
|
-
telemetryClient.trackCliOptionValue(
|
|
537
|
-
valueFromFlag === void 0 ? void 0 : "<redacted>"
|
|
538
|
-
);
|
|
539
|
-
telemetryClient.trackCliFlagSensitive(opts["--sensitive"]);
|
|
540
|
-
telemetryClient.trackCliFlagNoSensitive(opts["--no-sensitive"]);
|
|
541
|
-
telemetryClient.trackCliFlagForce(opts["--force"]);
|
|
542
|
-
telemetryClient.trackCliFlagGuidance(opts["--guidance"]);
|
|
543
|
-
telemetryClient.trackCliFlagYes(opts["--yes"]);
|
|
544
|
-
telemetryClient.trackCliOptionType(
|
|
545
|
-
typeof opts["--type"] === "string" ? opts["--type"] : void 0
|
|
546
|
-
);
|
|
547
|
-
telemetryClient.trackCliOptionVisibility(
|
|
548
|
-
typeof opts["--visibility"] === "string" ? opts["--visibility"] : void 0
|
|
549
|
-
);
|
|
550
|
-
telemetryClient.trackCliOptionProject(opts["--project"]);
|
|
551
|
-
if (typeOption.error) {
|
|
552
|
-
if (client.nonInteractive) {
|
|
553
|
-
outputAgentError(
|
|
554
|
-
client,
|
|
555
|
-
{
|
|
556
|
-
status: "error",
|
|
557
|
-
reason: typeOption.errorReason ?? "invalid_type",
|
|
558
|
-
message: typeOption.error
|
|
559
|
-
},
|
|
560
|
-
1
|
|
561
|
-
);
|
|
562
|
-
}
|
|
563
|
-
output_manager_default.fatal(typeOption.error);
|
|
564
|
-
return 1;
|
|
565
|
-
}
|
|
566
|
-
if (typeOption.usedDeprecatedVisibility) {
|
|
567
|
-
printEnvAddWarning(ENV_VISIBILITY_DEPRECATION_MESSAGE);
|
|
568
|
-
}
|
|
569
|
-
const typeConflictMessage = forceSensitive ? forceEncrypted ? "`--sensitive` and `--no-sensitive` cannot be used together. Pick one." : explicitType === "config" ? "`--type config` cannot be used with `--sensitive`. Pick one." : null : forceEncrypted && explicitType === "secret" ? "`--type secret` cannot be used with `--no-sensitive`. Pick one." : null;
|
|
570
|
-
if (typeConflictMessage) {
|
|
571
|
-
if (client.nonInteractive) {
|
|
572
|
-
outputAgentError(
|
|
573
|
-
client,
|
|
574
|
-
{
|
|
575
|
-
status: "error",
|
|
576
|
-
reason: "conflicting_type_flags",
|
|
577
|
-
message: typeConflictMessage
|
|
578
|
-
},
|
|
579
|
-
1
|
|
580
|
-
);
|
|
581
|
-
}
|
|
582
|
-
output_manager_default.fatal(typeConflictMessage);
|
|
583
|
-
return 1;
|
|
584
|
-
}
|
|
585
|
-
if (positionalGitBranch && optionGitBranch) {
|
|
586
|
-
output_manager_default.error(
|
|
587
|
-
"Git branch was provided twice. Use either `--git-branch <git-branch>` or the legacy third argument."
|
|
588
|
-
);
|
|
589
|
-
return 1;
|
|
590
|
-
}
|
|
591
|
-
if (args.length > 3) {
|
|
592
|
-
output_manager_default.error(
|
|
593
|
-
`Invalid number of arguments. Usage: ${getCommandName(
|
|
594
|
-
`env add <name> ${getEnvTargetPlaceholder()} --git-branch <git-branch>`
|
|
595
|
-
)}`
|
|
596
|
-
);
|
|
597
|
-
return 1;
|
|
598
|
-
}
|
|
599
|
-
if (stdInput && (!envName || !envTargetArg)) {
|
|
600
|
-
output_manager_default.error(
|
|
601
|
-
`Invalid number of arguments. Usage: ${getCommandName(
|
|
602
|
-
`env add <name> <target> --git-branch <git-branch> < <file>`
|
|
603
|
-
)}`
|
|
604
|
-
);
|
|
605
|
-
return 1;
|
|
606
|
-
}
|
|
607
|
-
let envTargets = envTargetArg ? parseEnvTargetArg(envTargetArg) : [];
|
|
608
|
-
let resolvedLink;
|
|
609
|
-
if (client.nonInteractive) {
|
|
610
|
-
const link2 = await resolveProjectContext({
|
|
611
|
-
client,
|
|
612
|
-
projectNameOrId: opts["--project"]
|
|
613
|
-
});
|
|
614
|
-
if (link2.status === "error") {
|
|
615
|
-
return link2.exitCode;
|
|
616
|
-
}
|
|
617
|
-
if (link2.status === "not_linked") {
|
|
618
|
-
const preserved = getPreservedArgsForEnvAdd(client.argv);
|
|
619
|
-
const linkPreserved = preserved.filter((a, i) => {
|
|
620
|
-
if (a === "--value")
|
|
621
|
-
return false;
|
|
622
|
-
if (a.startsWith("--value="))
|
|
623
|
-
return false;
|
|
624
|
-
if (i > 0 && preserved[i - 1] === "--value")
|
|
625
|
-
return false;
|
|
626
|
-
return true;
|
|
627
|
-
});
|
|
628
|
-
const linkArgv = [
|
|
629
|
-
...client.argv.slice(0, 2),
|
|
630
|
-
"link",
|
|
631
|
-
"--scope",
|
|
632
|
-
"<scope>",
|
|
633
|
-
...linkPreserved
|
|
634
|
-
];
|
|
635
|
-
let envAddRetryArgv = redactEnvValueArgs(client.argv);
|
|
636
|
-
if (envTargetArg === "preview" && envGitBranch === void 0) {
|
|
637
|
-
const argvArgs = client.argv.slice(2);
|
|
638
|
-
const addIdx = argvArgs.indexOf("add");
|
|
639
|
-
if (addIdx !== -1) {
|
|
640
|
-
let pos = addIdx + 1;
|
|
641
|
-
let positionals = 0;
|
|
642
|
-
while (pos < argvArgs.length && positionals < 3 && !argvArgs[pos].startsWith("-")) {
|
|
643
|
-
positionals++;
|
|
644
|
-
pos++;
|
|
645
|
-
}
|
|
646
|
-
const insertAt = 2 + pos;
|
|
647
|
-
envAddRetryArgv = redactEnvValueArgs([
|
|
648
|
-
...client.argv.slice(0, insertAt),
|
|
649
|
-
"<gitbranch>",
|
|
650
|
-
...client.argv.slice(insertAt)
|
|
651
|
-
]);
|
|
652
|
-
}
|
|
653
|
-
}
|
|
654
|
-
outputAgentError(
|
|
655
|
-
client,
|
|
656
|
-
{
|
|
657
|
-
status: "error",
|
|
658
|
-
reason: "not_linked",
|
|
659
|
-
message: `Your codebase isn't linked to a project on Vercel. Run \`${getCommandNamePlain(
|
|
660
|
-
"link"
|
|
661
|
-
)}\` to begin. Use \`--yes\` for non-interactive mode; use \`--scope\` or \`--project\` to specify a team or project. Then run your \`env add\` command.`,
|
|
662
|
-
next: [
|
|
663
|
-
{ command: buildCommandWithYes(linkArgv) },
|
|
664
|
-
{ command: buildCommandWithYes(envAddRetryArgv) }
|
|
665
|
-
]
|
|
666
|
-
},
|
|
667
|
-
1
|
|
668
|
-
);
|
|
669
|
-
}
|
|
670
|
-
if (link2.status !== "linked")
|
|
671
|
-
return 1;
|
|
672
|
-
resolvedLink = link2;
|
|
673
|
-
const { project: project2 } = link2;
|
|
674
|
-
const org = link2.org;
|
|
675
|
-
client.config.currentTeam = org.type === "team" ? org.id : void 0;
|
|
676
|
-
const [{ envs: envs2 }, customEnvironments2] = await Promise.all([
|
|
677
|
-
getEnvRecords(client, project2.id, "vercel-cli:env:add"),
|
|
678
|
-
getCustomEnvironments(client, project2.id)
|
|
679
|
-
]);
|
|
680
|
-
const matchingEnvs2 = envs2.filter((r) => r.key === envName);
|
|
681
|
-
const existingTargets2 = /* @__PURE__ */ new Set();
|
|
682
|
-
const existingCustomEnvs2 = /* @__PURE__ */ new Set();
|
|
683
|
-
for (const env of matchingEnvs2) {
|
|
684
|
-
if (typeof env.target === "string") {
|
|
685
|
-
existingTargets2.add(env.target);
|
|
686
|
-
} else if (Array.isArray(env.target)) {
|
|
687
|
-
for (const target of env.target) {
|
|
688
|
-
existingTargets2.add(target);
|
|
689
|
-
}
|
|
690
|
-
}
|
|
691
|
-
if (env.customEnvironmentIds) {
|
|
692
|
-
for (const customEnvId of env.customEnvironmentIds) {
|
|
693
|
-
existingCustomEnvs2.add(customEnvId);
|
|
694
|
-
}
|
|
695
|
-
}
|
|
696
|
-
}
|
|
697
|
-
const choices2 = [
|
|
698
|
-
...envTargetChoices.filter((c) => !existingTargets2.has(c.value)),
|
|
699
|
-
...customEnvironments2.filter((c) => !existingCustomEnvs2.has(c.id)).map((c) => ({
|
|
700
|
-
name: c.slug,
|
|
701
|
-
value: c.id
|
|
702
|
-
}))
|
|
703
|
-
];
|
|
704
|
-
const missing = [];
|
|
705
|
-
if (!envName)
|
|
706
|
-
missing.push("missing_name");
|
|
707
|
-
if (valueFromFlag === void 0 && !stdInput)
|
|
708
|
-
missing.push("missing_value");
|
|
709
|
-
if (!envTargetArg && choices2.length > 0)
|
|
710
|
-
missing.push("missing_environment");
|
|
711
|
-
if (envTargetArg === "preview" && envGitBranch === void 0 && !(client.nonInteractive && args.length === 2)) {
|
|
712
|
-
missing.push("git_branch_required");
|
|
713
|
-
}
|
|
714
|
-
if (missing.length > 0) {
|
|
715
|
-
const parts = missing.map((m) => {
|
|
716
|
-
if (m === "missing_name")
|
|
717
|
-
return "variable name";
|
|
718
|
-
if (m === "missing_value")
|
|
719
|
-
return "--value or stdin";
|
|
720
|
-
if (m === "missing_environment")
|
|
721
|
-
return "environment (production, preview, development, or a comma-separated list)";
|
|
722
|
-
if (m === "git_branch_required")
|
|
723
|
-
return "`--git-branch <git-branch>` for Preview, or omit for all Preview branches";
|
|
724
|
-
return m;
|
|
725
|
-
});
|
|
726
|
-
const fullTemplate = `env add <name> ${getEnvTargetPlaceholder()} --value "<value>" --yes`;
|
|
727
|
-
const filledTemplate = fillEnvAddTemplate(fullTemplate, {
|
|
728
|
-
envName,
|
|
729
|
-
envTargetArg,
|
|
730
|
-
envGitBranch
|
|
731
|
-
});
|
|
732
|
-
const next = [];
|
|
733
|
-
const onlyGitBranchMissing = missing.length === 1 && missing[0] === "git_branch_required";
|
|
734
|
-
if (!onlyGitBranchMissing) {
|
|
735
|
-
next.push({
|
|
736
|
-
command: buildEnvAddCommandWithPreservedArgs(
|
|
737
|
-
client.argv,
|
|
738
|
-
filledTemplate
|
|
739
|
-
)
|
|
740
|
-
});
|
|
741
|
-
}
|
|
742
|
-
if (missing.includes("git_branch_required") && envName && (valueFromFlag !== void 0 || stdInput)) {
|
|
743
|
-
const branchSpecific = fillEnvAddTemplate(
|
|
744
|
-
'env add <name> preview --git-branch <git-branch> --value "<value>" --yes',
|
|
745
|
-
{ envName, envTargetArg: "preview" }
|
|
746
|
-
);
|
|
747
|
-
const branchAll = fillEnvAddTemplate(
|
|
748
|
-
'env add <name> preview --value "<value>" --yes',
|
|
749
|
-
{ envName, envTargetArg: "preview" }
|
|
750
|
-
);
|
|
751
|
-
next.push(
|
|
752
|
-
{
|
|
753
|
-
command: buildEnvAddCommandWithPreservedArgs(
|
|
754
|
-
client.argv,
|
|
755
|
-
branchSpecific
|
|
756
|
-
),
|
|
757
|
-
when: "Add to a specific Git branch"
|
|
758
|
-
},
|
|
759
|
-
{
|
|
760
|
-
command: buildEnvAddCommandWithPreservedArgs(
|
|
761
|
-
client.argv,
|
|
762
|
-
branchAll
|
|
763
|
-
),
|
|
764
|
-
when: "Add to all Preview branches"
|
|
765
|
-
}
|
|
766
|
-
);
|
|
767
|
-
}
|
|
768
|
-
if (missing.includes("missing_environment")) {
|
|
769
|
-
const standardAvailable = choices2.map((c) => c.value).filter((v) => isValidEnvTarget(v));
|
|
770
|
-
const multiTargets = filterSensitiveMultiTargetSuggestionTargets(
|
|
771
|
-
standardAvailable,
|
|
772
|
-
{
|
|
773
|
-
forceSensitive: Boolean(opts["--sensitive"]),
|
|
774
|
-
policyOn: false
|
|
775
|
-
}
|
|
776
|
-
);
|
|
777
|
-
if (multiTargets.length > 1) {
|
|
778
|
-
next.push(
|
|
779
|
-
multiTargetSuggestion(
|
|
780
|
-
client.argv,
|
|
781
|
-
envName || "<name>",
|
|
782
|
-
multiTargets,
|
|
783
|
-
multiTargets.includes("development") && !opts["--no-sensitive"]
|
|
784
|
-
)
|
|
785
|
-
);
|
|
786
|
-
}
|
|
787
|
-
}
|
|
788
|
-
outputActionRequired(
|
|
789
|
-
client,
|
|
790
|
-
{
|
|
791
|
-
status: "action_required",
|
|
792
|
-
reason: "missing_requirements",
|
|
793
|
-
missing,
|
|
794
|
-
message: `Provide all required inputs for non-interactive mode: ${parts.join("; ")}. Example: \`${filledTemplate}\``,
|
|
795
|
-
next
|
|
796
|
-
},
|
|
797
|
-
1
|
|
798
|
-
);
|
|
799
|
-
}
|
|
800
|
-
}
|
|
801
|
-
if (!envName) {
|
|
802
|
-
envName = await client.input.text({
|
|
803
|
-
message: `Name?`,
|
|
804
|
-
validate: (val) => val ? true : "Name cannot be empty"
|
|
805
|
-
});
|
|
806
|
-
}
|
|
807
|
-
if (!resolvedLink) {
|
|
808
|
-
const link2 = await resolveProjectContext({
|
|
809
|
-
client,
|
|
810
|
-
projectNameOrId: opts["--project"]
|
|
811
|
-
});
|
|
812
|
-
if (link2.status === "error") {
|
|
813
|
-
return link2.exitCode;
|
|
814
|
-
} else if (link2.status === "not_linked") {
|
|
815
|
-
if (client.nonInteractive) {
|
|
816
|
-
const preserved = getPreservedArgsForEnvAdd(client.argv);
|
|
817
|
-
const linkPreserved = preserved.filter((a, i) => {
|
|
818
|
-
if (a === "--value")
|
|
819
|
-
return false;
|
|
820
|
-
if (a.startsWith("--value="))
|
|
821
|
-
return false;
|
|
822
|
-
if (i > 0 && preserved[i - 1] === "--value")
|
|
823
|
-
return false;
|
|
824
|
-
return true;
|
|
825
|
-
});
|
|
826
|
-
const linkArgv = [
|
|
827
|
-
...client.argv.slice(0, 2),
|
|
828
|
-
"link",
|
|
829
|
-
"--scope",
|
|
830
|
-
"<scope>",
|
|
831
|
-
...linkPreserved
|
|
832
|
-
];
|
|
833
|
-
outputAgentError(
|
|
834
|
-
client,
|
|
835
|
-
{
|
|
836
|
-
status: "error",
|
|
837
|
-
reason: "not_linked",
|
|
838
|
-
message: `Your codebase isn't linked to a project on Vercel. Run ${getCommandNamePlain(
|
|
839
|
-
"link"
|
|
840
|
-
)} to begin. Use --yes for non-interactive; use --scope or --project to specify team or project. Then run your env add command.`,
|
|
841
|
-
next: [
|
|
842
|
-
{ command: buildCommandWithYes(linkArgv) },
|
|
843
|
-
{ command: buildCommandWithYes(redactEnvValueArgs(client.argv)) }
|
|
844
|
-
]
|
|
845
|
-
},
|
|
846
|
-
1
|
|
847
|
-
);
|
|
848
|
-
} else {
|
|
849
|
-
output_manager_default.error(
|
|
850
|
-
`Your codebase isn\u2019t linked to a project on Vercel. Run ${getCommandName(
|
|
851
|
-
"link"
|
|
852
|
-
)} to begin.`
|
|
853
|
-
);
|
|
854
|
-
}
|
|
855
|
-
return 1;
|
|
856
|
-
}
|
|
857
|
-
resolvedLink = link2;
|
|
858
|
-
}
|
|
859
|
-
const link = resolvedLink;
|
|
860
|
-
client.config.currentTeam = link.org.type === "team" ? link.org.id : void 0;
|
|
861
|
-
const { project } = link;
|
|
862
|
-
if (explicitType === "secret" || forceSensitive) {
|
|
863
|
-
const publicPrefixError = getPublicPrefixSecretVisibilityError(envName, {
|
|
864
|
-
visibility: explicitType === "secret" ? "secret" : void 0,
|
|
865
|
-
type: "sensitive",
|
|
866
|
-
context: "add"
|
|
867
|
-
});
|
|
868
|
-
if (publicPrefixError) {
|
|
869
|
-
if (client.nonInteractive) {
|
|
870
|
-
outputAgentError(
|
|
871
|
-
client,
|
|
872
|
-
{
|
|
873
|
-
status: "error",
|
|
874
|
-
reason: "invalid_type",
|
|
875
|
-
message: publicPrefixError
|
|
876
|
-
},
|
|
877
|
-
1
|
|
878
|
-
);
|
|
879
|
-
}
|
|
880
|
-
output_manager_default.fatal(publicPrefixError);
|
|
881
|
-
return 1;
|
|
882
|
-
}
|
|
883
|
-
}
|
|
884
|
-
let keyAccepted = false;
|
|
885
|
-
while (!keyAccepted) {
|
|
886
|
-
const apiPublicPrefix2 = getApiPublicPrefix(envName);
|
|
887
|
-
const frameworkPublicPrefix = getFrameworkPublicPrefix(
|
|
888
|
-
project.framework,
|
|
889
|
-
envName
|
|
890
|
-
);
|
|
891
|
-
const globallyKnownPrefix = getPublicPrefix(envName);
|
|
892
|
-
const deferFrameworkSecretError = frameworkPublicPrefix !== null && (explicitType === "secret" || forceSensitive);
|
|
893
|
-
const keyWarnings = deferFrameworkSecretError || globallyKnownPrefix !== null && apiPublicPrefix2 === null && frameworkPublicPrefix === null ? [] : getEnvKeyWarnings(envName);
|
|
894
|
-
const sensitiveWarning = keyWarnings.find((w) => w.requiresConfirmation);
|
|
895
|
-
if (!sensitiveWarning) {
|
|
896
|
-
for (const warning of keyWarnings) {
|
|
897
|
-
printEnvAddWarning(warning.message);
|
|
898
|
-
}
|
|
899
|
-
keyAccepted = true;
|
|
900
|
-
break;
|
|
901
|
-
}
|
|
902
|
-
const nameWithoutPrefix = removePublicPrefix(envName);
|
|
903
|
-
const publicPrefix = getPublicPrefix(envName);
|
|
904
|
-
if (typeSource === "argv") {
|
|
905
|
-
for (const warning of keyWarnings) {
|
|
906
|
-
printEnvAddWarning(warning.message);
|
|
907
|
-
}
|
|
908
|
-
keyAccepted = true;
|
|
909
|
-
break;
|
|
910
|
-
}
|
|
911
|
-
const privateCommand = buildEnvAddCommandWithPreservedArgs(
|
|
912
|
-
client.argv,
|
|
913
|
-
`env add ${nameWithoutPrefix} ${envTargetArg ?? getEnvTargetPlaceholder()} --type secret --value "<value>" --yes`
|
|
914
|
-
);
|
|
915
|
-
const publicCommand = buildEnvAddCommandWithPreservedArgs(
|
|
916
|
-
client.argv,
|
|
917
|
-
`env add ${envName} ${envTargetArg ?? getEnvTargetPlaceholder()} --type config --value "<value>" --yes`
|
|
918
|
-
);
|
|
919
|
-
const humanTargetArg = envTargetArg ? ` ${envTargetArg}` : "";
|
|
920
|
-
const privateHumanCommand = buildHumanEnvAddCommand(
|
|
921
|
-
client.argv,
|
|
922
|
-
`env add ${nameWithoutPrefix}${humanTargetArg} --type secret`
|
|
923
|
-
);
|
|
924
|
-
const publicHumanCommand = buildHumanEnvAddCommand(
|
|
925
|
-
client.argv,
|
|
926
|
-
`env add ${envName}${humanTargetArg} --type config`
|
|
927
|
-
);
|
|
928
|
-
const message = `\`${envName}\` looks like a credential, and \`${publicPrefix}\` exposes its value to anyone visiting your site. Choose explicitly: rename to \`${nameWithoutPrefix}\` with \`--type secret\` to keep it private, or keep the name with \`--type config\` to expose it.`;
|
|
929
|
-
if (client.nonInteractive || opts["--yes"] || !!stdInput) {
|
|
930
|
-
if (client.nonInteractive) {
|
|
931
|
-
outputActionRequired(client, {
|
|
932
|
-
status: "action_required",
|
|
933
|
-
reason: "public_prefix_requires_type",
|
|
934
|
-
message,
|
|
935
|
-
choices: [
|
|
936
|
-
{
|
|
937
|
-
id: "private",
|
|
938
|
-
name: `Keep private: rename to ${nameWithoutPrefix} and use Secret`
|
|
939
|
-
},
|
|
940
|
-
{
|
|
941
|
-
id: "public",
|
|
942
|
-
name: `Expose publicly: keep ${envName} as Config`
|
|
943
|
-
}
|
|
944
|
-
],
|
|
945
|
-
next: [
|
|
946
|
-
{
|
|
947
|
-
command: privateCommand,
|
|
948
|
-
when: "Keep it private; replace <value> before running"
|
|
949
|
-
},
|
|
950
|
-
{
|
|
951
|
-
command: publicCommand,
|
|
952
|
-
when: "Expose it publicly; replace <value> before running"
|
|
953
|
-
}
|
|
954
|
-
]
|
|
955
|
-
});
|
|
956
|
-
}
|
|
957
|
-
output_manager_default.fatal(message);
|
|
958
|
-
output_manager_default.print(` Keep it private:
|
|
7
|
+
import{CHECKBOX_INSTRUCTIONS,getCustomEnvironments,readStandardInput,require_dist as require_dist3}from"../../chunks/chunk-COQGD2EI.js";import{getInvalidSubcommand}from"../../chunks/chunk-TG2RCYTH.js";import{ellipsis}from"../../chunks/chunk-ZDX75YNZ.js";import{formatTable}from"../../chunks/chunk-NUGLE4QY.js";import"../../chunks/chunk-MBL6TXEJ.js";import{isGuidanceEnabled,suggestNextCommands}from"../../chunks/chunk-6YAADRQB.js";import{formatEnvironment}from"../../chunks/chunk-4QX77CP7.js";import{validateLsArgs}from"../../chunks/chunk-3TXEXPUW.js";import{validateJsonOutput}from"../../chunks/chunk-D4MW3RDW.js";import{getSubcommand}from"../../chunks/chunk-ETV3C2CV.js";import{getCommandAliases}from"../../chunks/chunk-BATE73HA.js";import"../../chunks/chunk-3QT7VOE3.js";import"../../chunks/chunk-O7G3CZ42.js";import"../../chunks/chunk-N3N5UHIL.js";import"../../chunks/chunk-YMVDWVMO.js";import"../../chunks/chunk-M5AV545M.js";import"../../chunks/chunk-IVWPQYIH.js";import"../../chunks/chunk-3QHJYVCY.js";import"../../chunks/chunk-NBVY237X.js";import"../../chunks/chunk-WUZD4KBL.js";import"../../chunks/chunk-MEAY2K5Z.js";import"../../chunks/chunk-EQ52F4LH.js";import"../../chunks/chunk-7R5FEXZ5.js";import"../../chunks/chunk-FKCOBJFH.js";import"../../chunks/chunk-CVKB54WW.js";import"../../chunks/chunk-JKTQV2QJ.js";import"../../chunks/chunk-JEIMW3CO.js";import"../../chunks/chunk-ZKYS7EAB.js";import{autoInstallVercelPlugin}from"../../chunks/chunk-TJCIHDPZ.js";import{require_execa}from"../../chunks/chunk-HBFPLBTX.js";import{stamp_default}from"../../chunks/chunk-XPXOV5UO.js";import"../../chunks/chunk-2I64AYHG.js";import"../../chunks/chunk-SOJCELXH.js";import"../../chunks/chunk-JZRMH5UA.js";import{require_ms}from"../../chunks/chunk-QTKJC2O5.js";import{ENV_VISIBILITY_DEPRECATION_MESSAGE,SENSITIVE_ENV_VALUE_PLACEHOLDER,formatVisibilityLabel,getApiPublicPrefix,getEnvKeyWarnings,getEnvRecords,getFrameworkPublicPrefix,getLocalSecretFallbackMessage,getLocalSvelteKitPublicPrefixes,getPublicPrefix,getPublicPrefixSecretVisibilityError,getUnavailableSecretValuesMessage,isFlagsSecretNeedingSplit,isSecretEnvVar,looksLikeSecret,looksLikeSecretValue,normalizeStdinEnvValue,pull,pullEnvRecords,removePublicPrefix,resolveEnvVarTypeOption,resolveEnvVarVisibility,shouldConfirmRotationBeforeDelete,validateEnvValue}from"../../chunks/chunk-OKZDOANA.js";import{resolveProjectContext}from"../../chunks/chunk-ENS6KX2F.js";import"../../chunks/chunk-L243RUIR.js";import"../../chunks/chunk-ULLWCOYC.js";import"../../chunks/chunk-KK4AJES5.js";import"../../chunks/chunk-N6CNMMSZ.js";import"../../chunks/chunk-CN2QZO4U.js";import"../../chunks/chunk-HZZ5L472.js";import"../../chunks/chunk-LDM3SQAU.js";import"../../chunks/chunk-ENBTTYJR.js";import"../../chunks/chunk-XQ73QIQ3.js";import{addSubcommand,envCommand,envTargetChoices,getEnvTargetPlaceholder,isValidEnvTarget,listSubcommand,parseEnvTargetArg,pullSubcommand,removeSubcommand,runSubcommand,updateSubcommand}from"../../chunks/chunk-K3KJZLBD.js";import{param}from"../../chunks/chunk-SXUEGVWB.js";import{STANDARD_ENVIRONMENTS,formatProject}from"../../chunks/chunk-YV6CTDHR.js";import{help}from"../../chunks/chunk-2B2MN3U5.js";import"../../chunks/chunk-6TAQ6OWD.js";import{parseTarget}from"../../chunks/chunk-GRNTLNC7.js";import"../../chunks/chunk-G7Y77DFH.js";import"../../chunks/chunk-JYAUUIR4.js";import"../../chunks/chunk-WPS6JZF6.js";import{buildCommandWithYes,buildEnvAddCommandWithPreservedArgs,buildEnvRmCommandWithPreservedArgs,buildEnvUpdateCommandWithPreservedArgs,getPreservedArgsForEnvAdd,getPreservedArgsForEnvRm,getPreservedArgsForEnvUpdate,outputActionRequired,outputAgentError,quoteArg,redactEnvValueArgs,withGlobalFlags}from"../../chunks/chunk-NS4FH2TY.js";import"../../chunks/chunk-5QQNYN4N.js";import{TelemetryClient,require_dist as require_dist2}from"../../chunks/chunk-57GHYR4Y.js";import"../../chunks/chunk-RCTYVKM5.js";import{parseArguments}from"../../chunks/chunk-HTC6KO2B.js";import"../../chunks/chunk-5XJNPXQK.js";import{printError}from"../../chunks/chunk-LNPMDXBJ.js";import"../../chunks/chunk-MY4MONOH.js";import"../../chunks/chunk-7T6TL3GQ.js";import"../../chunks/chunk-BRK4OB4B.js";import"../../chunks/chunk-VLZ47RWM.js";import"../../chunks/chunk-F2ZWW2IO.js";import"../../chunks/chunk-B4ATVYZW.js";import"../../chunks/chunk-PPCFQQSU.js";import"../../chunks/chunk-OSCCYU74.js";import{getFlagsSpecification,getGlobalFlagsFromArgs}from"../../chunks/chunk-JAJW3P42.js";import{printAlignedLabel}from"../../chunks/chunk-XSVBYDYI.js";import{getTeamByIdOrSlug}from"../../chunks/chunk-EVZRQGNK.js";import{isAPIError}from"../../chunks/chunk-R2TGGVCT.js";import{getCommandName,getCommandNamePlain,require_lib}from"../../chunks/chunk-FI772UVH.js";import"../../chunks/chunk-XFVGX5HG.js";import{emoji,output_manager_default,prependEmoji}from"../../chunks/chunk-Z6Y55QJW.js";import{require_dist}from"../../chunks/chunk-QGIQK47P.js";import"../../chunks/chunk-AVSPFBLM.js";import"../../chunks/chunk-XCJDGQO7.js";import"../../chunks/chunk-YPTLSODC.js";import"../../chunks/chunk-7HL2RPUO.js";import{require_source}from"../../chunks/chunk-U7KCDTCH.js";import"../../chunks/chunk-N3ZZ7FHQ.js";import"../../chunks/chunk-GU6VIFR5.js";import{__toESM}from"../../chunks/chunk-6L236MNA.js";var import_chalk=__toESM(require_source(),1);var import_constants=__toESM(require_dist2(),1);async function addEnvRecord(client,projectId,upsert,type,key,value,targets,gitBranch,visibility){let actionWord=upsert?"Overriding":"Adding";output_manager_default.debug(`${actionWord} ${type} Environment Variable ${key} to ${targets.length} targets`);let target=[],customEnvironmentIds=[];for(let t of targets)(import_constants.PROJECT_ENV_TARGET.includes(t)?target:customEnvironmentIds).push(t);let body={type,key,value,target,customEnvironmentIds:customEnvironmentIds.length>0?customEnvironmentIds:void 0,gitBranch:gitBranch||void 0,...visibility!==void 0?{visibility}:{}},args=upsert?`?upsert=${upsert}`:"",url=`/v10/projects/${projectId}/env${args}`;await client.fetch(url,{method:"POST",body})}var import_error_utils=__toESM(require_dist(),1),knownErrorsCodes=new Set(["BAD_REQUEST","ENV_ALREADY_EXISTS","ENV_CONFLICT","EXISTING_KEY_AND_TARGET","FORBIDDEN","ID_NOT_FOUND","INVALID_KEY","INVALID_VALUE","KEY_INVALID_CHARACTERS","KEY_INVALID_LENGTH","KEY_RESERVED","RESERVED_ENV_VARIABLE","MAX_ENVS_EXCEEDED","MISSING_ID","MISSING_KEY","MISSING_TARGET","MISSING_VALUE","NOT_AUTHORIZED","NOT_DECRYPTABLE","SYSTEM_ENV_WITH_VALUE","TEAM_NOT_FOUND","TOO_MANY_IDS","TOO_MANY_KEYS","UNKNOWN_ERROR","VALUE_INVALID_LENGTH","VALUE_INVALID_TYPE"]);function isKnownError(error){let code=(0,import_error_utils.isErrnoException)(error)?error.code:null;return code?knownErrorsCodes.has(code.toUpperCase()):!1}var EnvAddTelemetryClient=class extends TelemetryClient{trackCliArgumentName(name){name&&this.trackCliArgument({arg:"name",value:this.redactedValue})}trackCliArgumentEnvironment(environment){if(environment){let allStandard=environment.split(",").map(t=>t.trim()).every(t=>STANDARD_ENVIRONMENTS.includes(t));this.trackCliArgument({arg:"environment",value:allStandard?environment:this.redactedValue})}}trackCliArgumentGitBranch(gitBranch){gitBranch&&this.trackCliArgument({arg:"git-branch",value:this.redactedValue})}trackCliOptionGitBranch(gitBranch){gitBranch&&this.trackCliOption({option:"git-branch",value:this.redactedValue})}trackCliOptionValue(value){value&&this.trackCliOption({option:"value",value:this.redactedValue})}trackCliOptionVisibility(visibility){if(visibility){let validVisibilities=["config","secret"];this.trackCliOption({option:"visibility",value:validVisibilities.includes(visibility)?visibility:this.redactedValue})}}trackCliOptionType(type){if(type){let validTypes=["config","secret"];this.trackCliOption({option:"type",value:validTypes.includes(type)?type:this.redactedValue})}}trackCliFlagSensitive(sensitive){sensitive&&this.trackCliFlag("sensitive")}trackCliFlagNoSensitive(noSensitive){noSensitive&&this.trackCliFlag("no-sensitive")}trackCliFlagForce(force){force&&this.trackCliFlag("force")}trackCliFlagGuidance(guidance){guidance&&this.trackCliFlag("guidance")}trackCliFlagYes(yes){yes&&this.trackCliFlag("yes")}};import{determineAgent}from"@vercel/detect-agent";function includesDevelopment(targets){return targets.length===0||targets.includes("development")}function getProductionSecretPolicyErrorKind(message){return/production secrets?.*different value|different value.*production secrets?/i.test(message)?"different-values":/production secrets?.*(?:own environment group|separat)|(?:own environment group|separat).*production secrets?/i.test(message)?"separate-environments":null}function getProductionSecretPolicyRecovery(kind){return kind==="different-values"?"Use different Secret values for Production and non-Production.":"Create separate Production and non-Production variables with different values."}function getSecretStorageChoice(targets,recommendedReason){let availability=includesDevelopment(targets)?"hidden in the dashboard; Development values can be pulled":"hidden in the dashboard and unavailable to pulls",recommendation=recommendedReason?`; recommended ${recommendedReason}`:"";return`Secret (${availability}${recommendation})`}function getDefaultSecretStorageGuidance(targets){return includesDevelopment(targets)?"Stored as Secret by default. This value is hidden in the dashboard; Development values can be pulled. Use `--type config` for other values you need to read later.":"Stored as Secret by default. This value is hidden in the dashboard and unavailable to pulls; use `--type config` for values you need to read later."}function looksLikeCredentialName(key,publicPrefix=getPublicPrefix(key)){return looksLikeSecret(publicPrefix?key.slice(publicPrefix.length):key)}function filterEnvChoicesForSensitivity(choices,opts){return opts.policyOn?choices.filter(c=>c.value==="development"):choices}function getTargetCompatibilityError(envTargets,isSensitive,policyOn){let hasSensitiveCapable=envTargets.some(t=>t!=="development");return!isSensitive&&policyOn&&hasSensitiveCapable?`Your team requires sensitive Environment Variables for Production and Preview. To add a non-sensitive value, target the Development Environment only. Run ${getCommandName("env add")} with the development target instead.`:null}function resolveFinalType(envTargets,isSensitive,opts){return envTargets.includes("development")&&!isSensitive||opts.forceEncrypted&&!opts.policyOn?"encrypted":isSensitive||opts.forceSensitive||opts.policyOn?"sensitive":"encrypted"}function fillEnvAddTemplate(template,opts){let targetPlaceholder=getEnvTargetPlaceholder();return template.replace(/<name>/g,opts.envName?quoteArg(opts.envName):"<name>").split(targetPlaceholder).join(opts.envTargetArg?quoteArg(opts.envTargetArg):targetPlaceholder).replace(/<git-branch>/g,opts.envGitBranch?quoteArg(opts.envGitBranch):"<git-branch>").replace(/<gitbranch>/g,opts.envGitBranch?quoteArg(opts.envGitBranch):"<gitbranch>").replace(/<value>/g,"<value>")}function multiTargetSuggestion(argv,envName,targets,addNoSensitive){let flag=addNoSensitive?" --no-sensitive":"";return{command:buildEnvAddCommandWithPreservedArgs(argv,`env add ${envName} ${targets.join(",")} --value "<value>"${flag} --yes`),when:addNoSensitive?"Add one non-sensitive variable to all listed environments":"Add one variable to multiple environments"}}function filterSensitiveMultiTargetSuggestionTargets(targets,_opts){return targets}function projectLabel(link){return`${link.org.slug}/${link.project.name}`}function formatEnvironmentTarget(target,customEnvironments){let standardTarget=envTargetChoices.find(choice=>choice.value===target);return standardTarget?standardTarget.name:customEnvironments.find(env=>env.id===target||env.slug===target)?.slug??target}function formatEnvironmentTargets(envTargets,customEnvironments){return envTargets.map(target=>formatEnvironmentTarget(target,customEnvironments)).join(", ")}function printEnvAddResult(link,envName,envTargets,envGitBranch,customEnvironments,finalType,force,visibility){output_manager_default.print(`
|
|
8
|
+
`),printAlignedLabel(force?"Overrode":"Added",envName,{gutter:"\u2713"}),printAlignedLabel("Project",projectLabel(link)),printAlignedLabel("Environments",formatEnvironmentTargets(envTargets,customEnvironments)),envGitBranch&&printAlignedLabel("Branch",envGitBranch);let visibilityLabel=formatVisibilityLabel(visibility,finalType);visibilityLabel&&printAlignedLabel("Type",visibilityLabel)}function printEnvAddWarning(message){output_manager_default.print(`${import_chalk.default.yellow("!")} ${message}
|
|
9
|
+
`)}function promptEnvValue(client,opts){return client.input.text({message:"Value?",...opts.isSensitive?{transformer:value=>"*".repeat(value.length)}:{}})}function buildHumanEnvAddCommand(argv,commandTemplate){let globalFlags=getGlobalFlagsFromArgs(argv.slice(2),{preserveProject:!0}).filter(flag=>!flag.startsWith("--non-interactive")),suffix=globalFlags.length>0?` ${globalFlags.map(quoteArg).join(" ")}`:"";return getCommandNamePlain(`${commandTemplate}${suffix}`)}async function add(client,argv){let parsedArgs,flagsSpecification=getFlagsSpecification(addSubcommand.options);try{parsedArgs=parseArguments(argv,flagsSpecification)}catch(err){return client.nonInteractive&&outputAgentError(client,{status:"error",reason:"invalid_arguments",message:err instanceof Error?err.message:String(err)},1),printError(err),1}let{args,flags:opts}=parsedArgs,stdInput=await readStandardInput(client.stdin),valueFromFlag=typeof opts["--value"]=="string"?opts["--value"]:void 0,[envName,envTargetArg]=args,positionalGitBranch=args[2],optionGitBranch=typeof opts["--git-branch"]=="string"?opts["--git-branch"]:void 0,envGitBranch=optionGitBranch??positionalGitBranch,forceSensitive=!!opts["--sensitive"],forceEncrypted=!!opts["--no-sensitive"],typeOption=resolveEnvVarTypeOption({type:typeof opts["--type"]=="string"?opts["--type"]:void 0,visibility:typeof opts["--visibility"]=="string"?opts["--visibility"]:void 0}),explicitType=typeOption.explicitVisibility,typeSource=explicitType||forceSensitive||forceEncrypted?"argv":void 0,telemetryClient=new EnvAddTelemetryClient({opts:{store:client.telemetryEventStore}});if(telemetryClient.trackCliArgumentName(envName),telemetryClient.trackCliArgumentEnvironment(envTargetArg),telemetryClient.trackCliArgumentGitBranch(positionalGitBranch),telemetryClient.trackCliOptionGitBranch(optionGitBranch),telemetryClient.trackCliOptionValue(valueFromFlag===void 0?void 0:"<redacted>"),telemetryClient.trackCliFlagSensitive(opts["--sensitive"]),telemetryClient.trackCliFlagNoSensitive(opts["--no-sensitive"]),telemetryClient.trackCliFlagForce(opts["--force"]),telemetryClient.trackCliFlagGuidance(opts["--guidance"]),telemetryClient.trackCliFlagYes(opts["--yes"]),telemetryClient.trackCliOptionType(typeof opts["--type"]=="string"?opts["--type"]:void 0),telemetryClient.trackCliOptionVisibility(typeof opts["--visibility"]=="string"?opts["--visibility"]:void 0),telemetryClient.trackCliOptionProject(opts["--project"]),typeOption.error)return client.nonInteractive&&outputAgentError(client,{status:"error",reason:typeOption.errorReason??"invalid_type",message:typeOption.error},1),output_manager_default.fatal(typeOption.error),1;typeOption.usedDeprecatedVisibility&&printEnvAddWarning(ENV_VISIBILITY_DEPRECATION_MESSAGE);let typeConflictMessage=forceSensitive?forceEncrypted?"`--sensitive` and `--no-sensitive` cannot be used together. Pick one.":explicitType==="config"?"`--type config` cannot be used with `--sensitive`. Pick one.":null:forceEncrypted&&explicitType==="secret"?"`--type secret` cannot be used with `--no-sensitive`. Pick one.":null;if(typeConflictMessage)return client.nonInteractive&&outputAgentError(client,{status:"error",reason:"conflicting_type_flags",message:typeConflictMessage},1),output_manager_default.fatal(typeConflictMessage),1;if(positionalGitBranch&&optionGitBranch)return output_manager_default.error("Git branch was provided twice. Use either `--git-branch <git-branch>` or the legacy third argument."),1;if(args.length>3)return output_manager_default.error(`Invalid number of arguments. Usage: ${getCommandName(`env add <name> ${getEnvTargetPlaceholder()} --git-branch <git-branch>`)}`),1;if(stdInput&&(!envName||!envTargetArg))return output_manager_default.error(`Invalid number of arguments. Usage: ${getCommandName("env add <name> <target> --git-branch <git-branch> < <file>")}`),1;let envTargets=envTargetArg?parseEnvTargetArg(envTargetArg):[],resolvedLink;if(client.nonInteractive){let link2=await resolveProjectContext({client,projectNameOrId:opts["--project"]});if(link2.status==="error")return link2.exitCode;if(link2.status==="not_linked"){let preserved=getPreservedArgsForEnvAdd(client.argv),linkPreserved=preserved.filter((a,i)=>!(a==="--value"||a.startsWith("--value=")||i>0&&preserved[i-1]==="--value")),linkArgv=[...client.argv.slice(0,2),"link","--scope","<scope>",...linkPreserved],envAddRetryArgv=redactEnvValueArgs(client.argv);if(envTargetArg==="preview"&&envGitBranch===void 0){let argvArgs=client.argv.slice(2),addIdx=argvArgs.indexOf("add");if(addIdx!==-1){let pos=addIdx+1,positionals=0;for(;pos<argvArgs.length&&positionals<3&&!argvArgs[pos].startsWith("-");)positionals++,pos++;let insertAt=2+pos;envAddRetryArgv=redactEnvValueArgs([...client.argv.slice(0,insertAt),"<gitbranch>",...client.argv.slice(insertAt)])}}outputAgentError(client,{status:"error",reason:"not_linked",message:`Your codebase isn't linked to a project on Vercel. Run \`${getCommandNamePlain("link")}\` to begin. Use \`--yes\` for non-interactive mode; use \`--scope\` or \`--project\` to specify a team or project. Then run your \`env add\` command.`,next:[{command:buildCommandWithYes(linkArgv)},{command:buildCommandWithYes(envAddRetryArgv)}]},1)}if(link2.status!=="linked")return 1;resolvedLink=link2;let{project:project2}=link2,org=link2.org;client.config.currentTeam=org.type==="team"?org.id:void 0;let[{envs:envs2},customEnvironments2]=await Promise.all([getEnvRecords(client,project2.id,"vercel-cli:env:add"),getCustomEnvironments(client,project2.id)]),matchingEnvs2=envs2.filter(r=>r.key===envName),existingTargets2=new Set,existingCustomEnvs2=new Set;for(let env of matchingEnvs2){if(typeof env.target=="string")existingTargets2.add(env.target);else if(Array.isArray(env.target))for(let target of env.target)existingTargets2.add(target);if(env.customEnvironmentIds)for(let customEnvId of env.customEnvironmentIds)existingCustomEnvs2.add(customEnvId)}let choices2=[...envTargetChoices.filter(c=>!existingTargets2.has(c.value)),...customEnvironments2.filter(c=>!existingCustomEnvs2.has(c.id)).map(c=>({name:c.slug,value:c.id}))],missing=[];if(envName||missing.push("missing_name"),valueFromFlag===void 0&&!stdInput&&missing.push("missing_value"),!envTargetArg&&choices2.length>0&&missing.push("missing_environment"),envTargetArg==="preview"&&envGitBranch===void 0&&!(client.nonInteractive&&args.length===2)&&missing.push("git_branch_required"),missing.length>0){let parts=missing.map(m=>m==="missing_name"?"variable name":m==="missing_value"?"--value or stdin":m==="missing_environment"?"environment (production, preview, development, or a comma-separated list)":m==="git_branch_required"?"`--git-branch <git-branch>` for Preview, or omit for all Preview branches":m),fullTemplate=`env add <name> ${getEnvTargetPlaceholder()} --value "<value>" --yes`,filledTemplate=fillEnvAddTemplate(fullTemplate,{envName,envTargetArg,envGitBranch}),next=[];if(missing.length===1&&missing[0]==="git_branch_required"||next.push({command:buildEnvAddCommandWithPreservedArgs(client.argv,filledTemplate)}),missing.includes("git_branch_required")&&envName&&(valueFromFlag!==void 0||stdInput)){let branchSpecific=fillEnvAddTemplate('env add <name> preview --git-branch <git-branch> --value "<value>" --yes',{envName,envTargetArg:"preview"}),branchAll=fillEnvAddTemplate('env add <name> preview --value "<value>" --yes',{envName,envTargetArg:"preview"});next.push({command:buildEnvAddCommandWithPreservedArgs(client.argv,branchSpecific),when:"Add to a specific Git branch"},{command:buildEnvAddCommandWithPreservedArgs(client.argv,branchAll),when:"Add to all Preview branches"})}if(missing.includes("missing_environment")){let standardAvailable=choices2.map(c=>c.value).filter(v=>isValidEnvTarget(v)),multiTargets=filterSensitiveMultiTargetSuggestionTargets(standardAvailable,{forceSensitive:!!opts["--sensitive"],policyOn:!1});multiTargets.length>1&&next.push(multiTargetSuggestion(client.argv,envName||"<name>",multiTargets,multiTargets.includes("development")&&!opts["--no-sensitive"]))}outputActionRequired(client,{status:"action_required",reason:"missing_requirements",missing,message:`Provide all required inputs for non-interactive mode: ${parts.join("; ")}. Example: \`${filledTemplate}\``,next},1)}}if(envName||(envName=await client.input.text({message:"Name?",validate:val=>val?!0:"Name cannot be empty"})),!resolvedLink){let link2=await resolveProjectContext({client,projectNameOrId:opts["--project"]});if(link2.status==="error")return link2.exitCode;if(link2.status==="not_linked"){if(client.nonInteractive){let preserved=getPreservedArgsForEnvAdd(client.argv),linkPreserved=preserved.filter((a,i)=>!(a==="--value"||a.startsWith("--value=")||i>0&&preserved[i-1]==="--value")),linkArgv=[...client.argv.slice(0,2),"link","--scope","<scope>",...linkPreserved];outputAgentError(client,{status:"error",reason:"not_linked",message:`Your codebase isn't linked to a project on Vercel. Run ${getCommandNamePlain("link")} to begin. Use --yes for non-interactive; use --scope or --project to specify team or project. Then run your env add command.`,next:[{command:buildCommandWithYes(linkArgv)},{command:buildCommandWithYes(redactEnvValueArgs(client.argv))}]},1)}else output_manager_default.error(`Your codebase isn\u2019t linked to a project on Vercel. Run ${getCommandName("link")} to begin.`);return 1}resolvedLink=link2}let link=resolvedLink;client.config.currentTeam=link.org.type==="team"?link.org.id:void 0;let{project}=link;if(explicitType==="secret"||forceSensitive){let publicPrefixError=getPublicPrefixSecretVisibilityError(envName,{visibility:explicitType==="secret"?"secret":void 0,type:"sensitive",context:"add"});if(publicPrefixError)return client.nonInteractive&&outputAgentError(client,{status:"error",reason:"invalid_type",message:publicPrefixError},1),output_manager_default.fatal(publicPrefixError),1}let keyAccepted=!1;for(;!keyAccepted;){let apiPublicPrefix2=getApiPublicPrefix(envName),frameworkPublicPrefix=getFrameworkPublicPrefix(project.framework,envName),globallyKnownPrefix=getPublicPrefix(envName),keyWarnings=frameworkPublicPrefix!==null&&(explicitType==="secret"||forceSensitive)||globallyKnownPrefix!==null&&apiPublicPrefix2===null&&frameworkPublicPrefix===null?[]:getEnvKeyWarnings(envName);if(!keyWarnings.find(w=>w.requiresConfirmation)){for(let warning of keyWarnings)printEnvAddWarning(warning.message);keyAccepted=!0;break}let nameWithoutPrefix=removePublicPrefix(envName),publicPrefix=getPublicPrefix(envName);if(typeSource==="argv"){for(let warning of keyWarnings)printEnvAddWarning(warning.message);keyAccepted=!0;break}let privateCommand=buildEnvAddCommandWithPreservedArgs(client.argv,`env add ${nameWithoutPrefix} ${envTargetArg??getEnvTargetPlaceholder()} --type secret --value "<value>" --yes`),publicCommand=buildEnvAddCommandWithPreservedArgs(client.argv,`env add ${envName} ${envTargetArg??getEnvTargetPlaceholder()} --type config --value "<value>" --yes`),humanTargetArg=envTargetArg?` ${envTargetArg}`:"",privateHumanCommand=buildHumanEnvAddCommand(client.argv,`env add ${nameWithoutPrefix}${humanTargetArg} --type secret`),publicHumanCommand=buildHumanEnvAddCommand(client.argv,`env add ${envName}${humanTargetArg} --type config`),message=`\`${envName}\` looks like a credential, and \`${publicPrefix}\` exposes its value to anyone visiting your site. Choose explicitly: rename to \`${nameWithoutPrefix}\` with \`--type secret\` to keep it private, or keep the name with \`--type config\` to expose it.`;if(client.nonInteractive||opts["--yes"]||stdInput)return client.nonInteractive&&outputActionRequired(client,{status:"action_required",reason:"public_prefix_requires_type",message,choices:[{id:"private",name:`Keep private: rename to ${nameWithoutPrefix} and use Secret`},{id:"public",name:`Expose publicly: keep ${envName} as Config`}],next:[{command:privateCommand,when:"Keep it private; replace <value> before running"},{command:publicCommand,when:"Expose it publicly; replace <value> before running"}]}),output_manager_default.fatal(message),output_manager_default.print(` Keep it private:
|
|
959
10
|
${privateHumanCommand}
|
|
960
|
-
`)
|
|
961
|
-
output_manager_default.print(` Expose it publicly:
|
|
11
|
+
`),output_manager_default.print(` Expose it publicly:
|
|
962
12
|
${publicHumanCommand}
|
|
963
|
-
`);
|
|
964
|
-
|
|
965
|
-
}
|
|
966
|
-
for (const warning of keyWarnings) {
|
|
967
|
-
printEnvAddWarning(warning.message);
|
|
968
|
-
}
|
|
969
|
-
const action = await client.input.select({
|
|
970
|
-
message: "How should this variable be stored?",
|
|
971
|
-
choices: [
|
|
972
|
-
{
|
|
973
|
-
name: `Keep private: rename to ${nameWithoutPrefix} and use Secret`,
|
|
974
|
-
value: "p"
|
|
975
|
-
},
|
|
976
|
-
{
|
|
977
|
-
name: `Expose to anyone visiting your site: keep ${envName} as Config`,
|
|
978
|
-
value: "c"
|
|
979
|
-
},
|
|
980
|
-
{ name: "Enter a different name", value: "r" }
|
|
981
|
-
]
|
|
982
|
-
});
|
|
983
|
-
if (action === "p") {
|
|
984
|
-
envName = nameWithoutPrefix;
|
|
985
|
-
explicitType = "secret";
|
|
986
|
-
typeSource = "prompt";
|
|
987
|
-
output_manager_default.log(`Renamed to ${envName}`);
|
|
988
|
-
} else if (action === "c") {
|
|
989
|
-
explicitType = "config";
|
|
990
|
-
typeSource = "prompt";
|
|
991
|
-
keyAccepted = true;
|
|
992
|
-
} else {
|
|
993
|
-
envName = await client.input.text({
|
|
994
|
-
message: `Name?`,
|
|
995
|
-
validate: (val) => val ? true : "Name cannot be empty"
|
|
996
|
-
});
|
|
997
|
-
}
|
|
998
|
-
}
|
|
999
|
-
let customSveltePublicPrefix;
|
|
1000
|
-
const apiPublicPrefix = getApiPublicPrefix(envName);
|
|
1001
|
-
const matchingFrameworkPublicPrefix = getFrameworkPublicPrefix(
|
|
1002
|
-
project.framework,
|
|
1003
|
-
envName
|
|
1004
|
-
);
|
|
1005
|
-
if (matchingFrameworkPublicPrefix !== null && (explicitType === "secret" || forceSensitive)) {
|
|
1006
|
-
const message = `\`${matchingFrameworkPublicPrefix}\` exposes this value to anyone visiting your site, so \`${envName}\` cannot be kept private as a Secret. Rename the variable without the framework's public prefix to keep it private, or use \`--type config\` only if the value is safe to expose.`;
|
|
1007
|
-
if (client.nonInteractive) {
|
|
1008
|
-
outputAgentError(
|
|
1009
|
-
client,
|
|
1010
|
-
{ status: "error", reason: "invalid_type", message },
|
|
1011
|
-
1
|
|
1012
|
-
);
|
|
1013
|
-
}
|
|
1014
|
-
output_manager_default.fatal(message);
|
|
1015
|
-
return 1;
|
|
1016
|
-
}
|
|
1017
|
-
if (project.framework === "sveltekit" || project.framework === "sveltekit-1" || project.framework === "sveltekit-2") {
|
|
1018
|
-
const localPublicPrefixes = await getLocalSvelteKitPublicPrefixes(
|
|
1019
|
-
link.repoRoot ?? client.cwd,
|
|
1020
|
-
project.rootDirectory
|
|
1021
|
-
);
|
|
1022
|
-
const matchingLocalPrefix = localPublicPrefixes?.find(
|
|
1023
|
-
(prefix) => envName.startsWith(prefix)
|
|
1024
|
-
);
|
|
1025
|
-
if (matchingLocalPrefix !== void 0 && apiPublicPrefix === null && matchingFrameworkPublicPrefix === null) {
|
|
1026
|
-
customSveltePublicPrefix = matchingLocalPrefix;
|
|
1027
|
-
}
|
|
1028
|
-
}
|
|
1029
|
-
if (customSveltePublicPrefix !== void 0 && (explicitType === "secret" || forceSensitive)) {
|
|
1030
|
-
const message = customSveltePublicPrefix === "" ? "This SvelteKit project uses an empty `publicPrefix`, so every Environment Variable is exposed to the browser and cannot be kept private as a Secret. Change the SvelteKit `publicPrefix`, or use `--type config` only if the value is safe to expose." : `\`${customSveltePublicPrefix}\` exposes this value to anyone visiting your site, so \`${envName}\` cannot be kept private as a Secret. Rename the variable without the configured public prefix, or use \`--type config\` only if the value is safe to expose.`;
|
|
1031
|
-
if (client.nonInteractive) {
|
|
1032
|
-
outputAgentError(
|
|
1033
|
-
client,
|
|
1034
|
-
{ status: "error", reason: "invalid_type", message },
|
|
1035
|
-
1
|
|
1036
|
-
);
|
|
1037
|
-
}
|
|
1038
|
-
output_manager_default.fatal(message);
|
|
1039
|
-
return 1;
|
|
1040
|
-
}
|
|
1041
|
-
if (customSveltePublicPrefix !== void 0) {
|
|
1042
|
-
printEnvAddWarning(
|
|
1043
|
-
customSveltePublicPrefix === "" ? "This SvelteKit project uses an empty `publicPrefix`, so every Environment Variable is exposed to the browser." : `\`${customSveltePublicPrefix}\` variables are exposed to the browser by this SvelteKit project.`
|
|
1044
|
-
);
|
|
1045
|
-
}
|
|
1046
|
-
const skipConfirm = opts["--yes"] || !!stdInput || valueFromFlag !== void 0;
|
|
1047
|
-
const [{ envs }, customEnvironments] = await Promise.all([
|
|
1048
|
-
getEnvRecords(client, project.id, "vercel-cli:env:add"),
|
|
1049
|
-
getCustomEnvironments(client, project.id)
|
|
1050
|
-
]);
|
|
1051
|
-
if (envTargets.length > 0) {
|
|
1052
|
-
const resolved = [];
|
|
1053
|
-
const invalid = [];
|
|
1054
|
-
for (const target of envTargets) {
|
|
1055
|
-
if (isValidEnvTarget(target)) {
|
|
1056
|
-
resolved.push(target);
|
|
1057
|
-
continue;
|
|
1058
|
-
}
|
|
1059
|
-
const custom = customEnvironments.find(
|
|
1060
|
-
(c) => c.id === target || c.slug === target
|
|
1061
|
-
);
|
|
1062
|
-
if (custom) {
|
|
1063
|
-
resolved.push(custom.id);
|
|
1064
|
-
} else {
|
|
1065
|
-
invalid.push(target);
|
|
1066
|
-
}
|
|
1067
|
-
}
|
|
1068
|
-
if (invalid.length > 0) {
|
|
1069
|
-
const valid = [
|
|
1070
|
-
...envTargetChoices.map((c) => c.value),
|
|
1071
|
-
...customEnvironments.map((c) => c.slug)
|
|
1072
|
-
];
|
|
1073
|
-
const message = `Invalid environment: ${invalid.join(
|
|
1074
|
-
", "
|
|
1075
|
-
)}. Valid environments: ${valid.join(
|
|
1076
|
-
", "
|
|
1077
|
-
)}. Separate multiple environments with commas.`;
|
|
1078
|
-
if (client.nonInteractive) {
|
|
1079
|
-
outputAgentError(
|
|
1080
|
-
client,
|
|
1081
|
-
{ status: "error", reason: "invalid_environment", message },
|
|
1082
|
-
1
|
|
1083
|
-
);
|
|
1084
|
-
}
|
|
1085
|
-
output_manager_default.error(message);
|
|
1086
|
-
return 1;
|
|
1087
|
-
}
|
|
1088
|
-
envTargets = resolved;
|
|
1089
|
-
}
|
|
1090
|
-
if (envGitBranch && envTargets.length > 1) {
|
|
1091
|
-
const message = "A Git branch can only be set when Preview is the only selected environment.";
|
|
1092
|
-
if (client.nonInteractive) {
|
|
1093
|
-
outputAgentError(
|
|
1094
|
-
client,
|
|
1095
|
-
{ status: "error", reason: "branch_requires_preview_only", message },
|
|
1096
|
-
1
|
|
1097
|
-
);
|
|
1098
|
-
}
|
|
1099
|
-
output_manager_default.error(message);
|
|
1100
|
-
return 1;
|
|
1101
|
-
}
|
|
1102
|
-
const matchingEnvs = envs.filter((r) => r.key === envName);
|
|
1103
|
-
const existingTargets = /* @__PURE__ */ new Set();
|
|
1104
|
-
const existingCustomEnvs = /* @__PURE__ */ new Set();
|
|
1105
|
-
for (const env of matchingEnvs) {
|
|
1106
|
-
if (typeof env.target === "string") {
|
|
1107
|
-
existingTargets.add(env.target);
|
|
1108
|
-
} else if (Array.isArray(env.target)) {
|
|
1109
|
-
for (const target of env.target) {
|
|
1110
|
-
existingTargets.add(target);
|
|
1111
|
-
}
|
|
1112
|
-
}
|
|
1113
|
-
if (env.customEnvironmentIds) {
|
|
1114
|
-
for (const customEnvId of env.customEnvironmentIds) {
|
|
1115
|
-
existingCustomEnvs.add(customEnvId);
|
|
1116
|
-
}
|
|
1117
|
-
}
|
|
1118
|
-
}
|
|
1119
|
-
const choices = [
|
|
1120
|
-
...envTargetChoices.filter((c) => !existingTargets.has(c.value)).map((c) => ({ name: c.name, value: c.value })),
|
|
1121
|
-
...customEnvironments.filter((c) => !existingCustomEnvs.has(c.id)).map((c) => ({ name: c.slug, value: c.id }))
|
|
1122
|
-
];
|
|
1123
|
-
if (!envGitBranch && choices.length === 0 && !opts["--force"]) {
|
|
1124
|
-
const projectFlag = opts["--project"] ? ` --project ${opts["--project"]}` : "";
|
|
1125
|
-
output_manager_default.error(
|
|
1126
|
-
`The variable ${param(
|
|
1127
|
-
envName
|
|
1128
|
-
)} has already been added to all Environments. To remove, run ${getCommandName(
|
|
1129
|
-
`env rm ${envName}${projectFlag}`
|
|
1130
|
-
)}.`
|
|
1131
|
-
);
|
|
1132
|
-
return 1;
|
|
1133
|
-
}
|
|
1134
|
-
const policyOn = false;
|
|
1135
|
-
let teamSensitivePolicyOn = false;
|
|
1136
|
-
let disjunctiveProductionSecretPolicyOn = false;
|
|
1137
|
-
if (link.org.type === "team") {
|
|
1138
|
-
try {
|
|
1139
|
-
const team = await getTeamByIdOrSlug(client, link.org.id);
|
|
1140
|
-
teamSensitivePolicyOn = team?.sensitiveEnvironmentVariablePolicy === "on";
|
|
1141
|
-
disjunctiveProductionSecretPolicyOn = team?.disjunctiveProductionSecretPolicy === "on";
|
|
1142
|
-
} catch {
|
|
1143
|
-
}
|
|
1144
|
-
}
|
|
1145
|
-
const userWasExplicit = forceSensitive || forceEncrypted || !!explicitType;
|
|
1146
|
-
const skipSensitivePrompt = userWasExplicit || client.nonInteractive || skipConfirm;
|
|
1147
|
-
const isDevelopmentOnlyTarget = envTargets.length === 1 && envTargets[0] === "development";
|
|
1148
|
-
let isSensitive;
|
|
1149
|
-
if (forceSensitive) {
|
|
1150
|
-
isSensitive = true;
|
|
1151
|
-
} else if (forceEncrypted) {
|
|
1152
|
-
isSensitive = false;
|
|
1153
|
-
} else if (explicitType) {
|
|
1154
|
-
isSensitive = explicitType === "secret";
|
|
1155
|
-
} else if (apiPublicPrefix || matchingFrameworkPublicPrefix || customSveltePublicPrefix !== void 0) {
|
|
1156
|
-
isSensitive = false;
|
|
1157
|
-
explicitType = "config";
|
|
1158
|
-
typeSource = "inferred";
|
|
1159
|
-
} else if (isDevelopmentOnlyTarget) {
|
|
1160
|
-
isSensitive = false;
|
|
1161
|
-
typeSource = "inferred";
|
|
1162
|
-
} else if (skipSensitivePrompt) {
|
|
1163
|
-
isSensitive = true;
|
|
1164
|
-
typeSource = "default";
|
|
1165
|
-
} else {
|
|
1166
|
-
const selectedType = await client.input.select({
|
|
1167
|
-
message: "Environment Variable type?",
|
|
1168
|
-
choices: [
|
|
1169
|
-
{
|
|
1170
|
-
name: getSecretStorageChoice(
|
|
1171
|
-
envTargets,
|
|
1172
|
-
looksLikeCredentialName(envName) ? "because this name looks like a credential" : void 0
|
|
1173
|
-
),
|
|
1174
|
-
value: "secret"
|
|
1175
|
-
},
|
|
1176
|
-
{ name: "Config (can be revealed after saving)", value: "config" }
|
|
1177
|
-
]
|
|
1178
|
-
});
|
|
1179
|
-
isSensitive = selectedType === "secret";
|
|
1180
|
-
explicitType = selectedType;
|
|
1181
|
-
typeSource = "prompt";
|
|
1182
|
-
}
|
|
1183
|
-
if (envTargets.length > 0) {
|
|
1184
|
-
const compatibilityError = getTargetCompatibilityError(
|
|
1185
|
-
envTargets,
|
|
1186
|
-
isSensitive,
|
|
1187
|
-
policyOn
|
|
1188
|
-
);
|
|
1189
|
-
if (compatibilityError) {
|
|
1190
|
-
if (client.nonInteractive) {
|
|
1191
|
-
const next = [
|
|
1192
|
-
{
|
|
1193
|
-
command: buildEnvAddCommandWithPreservedArgs(
|
|
1194
|
-
client.argv,
|
|
1195
|
-
`env add ${envName} development --value "<value>" --yes`
|
|
1196
|
-
),
|
|
1197
|
-
when: "Add as non-sensitive to Development only"
|
|
1198
|
-
}
|
|
1199
|
-
];
|
|
1200
|
-
outputAgentError(
|
|
1201
|
-
client,
|
|
1202
|
-
{
|
|
1203
|
-
status: "error",
|
|
1204
|
-
reason: "non_sensitive_not_allowed_on_production_preview",
|
|
1205
|
-
message: compatibilityError,
|
|
1206
|
-
next
|
|
1207
|
-
},
|
|
1208
|
-
1
|
|
1209
|
-
);
|
|
1210
|
-
}
|
|
1211
|
-
output_manager_default.error(compatibilityError);
|
|
1212
|
-
return 1;
|
|
1213
|
-
}
|
|
1214
|
-
}
|
|
1215
|
-
const envChoices = filterEnvChoicesForSensitivity(choices, {
|
|
1216
|
-
isSensitive,
|
|
1217
|
-
policyOn
|
|
1218
|
-
});
|
|
1219
|
-
if (policyOn && isSensitive) {
|
|
1220
|
-
for (const choice of envChoices) {
|
|
1221
|
-
if (choice.value === "production" || choice.value === "preview") {
|
|
1222
|
-
choice.checked = true;
|
|
1223
|
-
}
|
|
1224
|
-
}
|
|
1225
|
-
} else if (envChoices.length === 1) {
|
|
1226
|
-
envChoices[0].checked = true;
|
|
1227
|
-
}
|
|
1228
|
-
if (!envGitBranch && envChoices.length === 0 && envTargets.length === 0 && !opts["--force"]) {
|
|
1229
|
-
output_manager_default.error(
|
|
1230
|
-
`No Environments are available for this variable with the selected sensitivity. Your team requires sensitive Environment Variables for Production and Preview.`
|
|
1231
|
-
);
|
|
1232
|
-
return 1;
|
|
1233
|
-
}
|
|
1234
|
-
let envValue;
|
|
1235
|
-
if (stdInput) {
|
|
1236
|
-
const normalizedStdinValue = normalizeStdinEnvValue(stdInput);
|
|
1237
|
-
envValue = normalizedStdinValue.value;
|
|
1238
|
-
if (normalizedStdinValue.strippedTrailingNewline) {
|
|
1239
|
-
output_manager_default.log("Removed trailing newline from stdin input");
|
|
1240
|
-
}
|
|
1241
|
-
} else if (valueFromFlag !== void 0) {
|
|
1242
|
-
envValue = valueFromFlag;
|
|
1243
|
-
} else {
|
|
1244
|
-
if (client.nonInteractive) {
|
|
1245
|
-
outputActionRequired(client, {
|
|
1246
|
-
status: "action_required",
|
|
1247
|
-
reason: "missing_value",
|
|
1248
|
-
message: 'In non-interactive mode provide the value via --value or stdin. Example: vercel env add <name> <environment> --value "<value>" --yes',
|
|
1249
|
-
next: [
|
|
1250
|
-
{
|
|
1251
|
-
command: buildEnvAddCommandWithPreservedArgs(
|
|
1252
|
-
client.argv,
|
|
1253
|
-
`env add <name> ${getEnvTargetPlaceholder()} --value "<value>" --yes`
|
|
1254
|
-
)
|
|
1255
|
-
}
|
|
1256
|
-
]
|
|
1257
|
-
});
|
|
1258
|
-
}
|
|
1259
|
-
envValue = await promptEnvValue(client, { isSensitive });
|
|
1260
|
-
}
|
|
1261
|
-
let { finalValue } = await validateEnvValue({
|
|
1262
|
-
envName,
|
|
1263
|
-
initialValue: envValue,
|
|
1264
|
-
skipConfirm,
|
|
1265
|
-
promptForValue: () => promptEnvValue(client, { isSensitive }),
|
|
1266
|
-
selectAction: (choices2) => client.input.select({ message: "Value?", choices: choices2 }),
|
|
1267
|
-
showWarning: (msg) => printEnvAddWarning(msg),
|
|
1268
|
-
showLog: (msg) => output_manager_default.log(msg)
|
|
1269
|
-
});
|
|
1270
|
-
while (envTargets.length === 0) {
|
|
1271
|
-
if (client.nonInteractive && envChoices.length > 0) {
|
|
1272
|
-
const standardAvailable = choices.map((c) => c.value).filter((v) => isValidEnvTarget(v));
|
|
1273
|
-
const multiTargets = filterSensitiveMultiTargetSuggestionTargets(
|
|
1274
|
-
standardAvailable,
|
|
1275
|
-
{
|
|
1276
|
-
forceSensitive,
|
|
1277
|
-
policyOn
|
|
1278
|
-
}
|
|
1279
|
-
);
|
|
1280
|
-
const next = [];
|
|
1281
|
-
if (multiTargets.length > 1) {
|
|
1282
|
-
next.push(
|
|
1283
|
-
multiTargetSuggestion(
|
|
1284
|
-
client.argv,
|
|
1285
|
-
envName,
|
|
1286
|
-
multiTargets,
|
|
1287
|
-
multiTargets.includes("development") && !forceEncrypted
|
|
1288
|
-
)
|
|
1289
|
-
);
|
|
1290
|
-
}
|
|
1291
|
-
next.push(
|
|
1292
|
-
...envChoices.slice(0, 5).map((c) => ({
|
|
1293
|
-
command: buildEnvAddCommandWithPreservedArgs(
|
|
1294
|
-
client.argv,
|
|
1295
|
-
`env add ${envName} ${c.value} --value "<value>" --yes`
|
|
1296
|
-
)
|
|
1297
|
-
}))
|
|
1298
|
-
);
|
|
1299
|
-
outputActionRequired(client, {
|
|
1300
|
-
status: "action_required",
|
|
1301
|
-
reason: "missing_environment",
|
|
1302
|
-
message: `Specify one or more environments (comma-separated). Add as argument or use: ${buildEnvAddCommandWithPreservedArgs(
|
|
1303
|
-
client.argv,
|
|
1304
|
-
`env add ${envName} <environment>[,<environment>] --value "<value>" --yes`
|
|
1305
|
-
)}`,
|
|
1306
|
-
choices: envChoices.map((c) => ({
|
|
1307
|
-
id: c.value,
|
|
1308
|
-
name: typeof c.name === "string" ? c.name : c.value
|
|
1309
|
-
})),
|
|
1310
|
-
next
|
|
1311
|
-
});
|
|
1312
|
-
}
|
|
1313
|
-
envTargets = await client.input.checkbox({
|
|
1314
|
-
message: `Environments?`,
|
|
1315
|
-
instructions: CHECKBOX_INSTRUCTIONS,
|
|
1316
|
-
choices: envChoices
|
|
1317
|
-
});
|
|
1318
|
-
if (envTargets.length === 0) {
|
|
1319
|
-
output_manager_default.error("Please select at least one Environment");
|
|
1320
|
-
}
|
|
1321
|
-
}
|
|
1322
|
-
const postSelectionError = getTargetCompatibilityError(
|
|
1323
|
-
envTargets,
|
|
1324
|
-
isSensitive,
|
|
1325
|
-
policyOn
|
|
1326
|
-
);
|
|
1327
|
-
if (postSelectionError) {
|
|
1328
|
-
output_manager_default.error(postSelectionError);
|
|
1329
|
-
return 1;
|
|
1330
|
-
}
|
|
1331
|
-
if (envGitBranch === void 0 && envTargets.length === 1 && envTargets[0] === "preview" && !opts["--yes"] && !(client.nonInteractive && args.length === 2)) {
|
|
1332
|
-
if (client.nonInteractive) {
|
|
1333
|
-
outputActionRequired(
|
|
1334
|
-
client,
|
|
1335
|
-
{
|
|
1336
|
-
status: "action_required",
|
|
1337
|
-
reason: "git_branch_required",
|
|
1338
|
-
message: `Add ${envName} to which Git branch for Preview? Pass branch as third argument, or omit for all Preview branches.`,
|
|
1339
|
-
next: [
|
|
1340
|
-
{
|
|
1341
|
-
command: buildEnvAddCommandWithPreservedArgs(
|
|
1342
|
-
client.argv,
|
|
1343
|
-
`env add ${envName} preview --git-branch <git-branch> --value "<value>" --yes`
|
|
1344
|
-
),
|
|
1345
|
-
when: "Add to a specific Git branch"
|
|
1346
|
-
},
|
|
1347
|
-
{
|
|
1348
|
-
command: buildEnvAddCommandWithPreservedArgs(
|
|
1349
|
-
client.argv,
|
|
1350
|
-
`env add ${envName} preview --value "<value>" --yes`
|
|
1351
|
-
),
|
|
1352
|
-
when: "Add to all Preview branches"
|
|
1353
|
-
}
|
|
1354
|
-
]
|
|
1355
|
-
},
|
|
1356
|
-
1
|
|
1357
|
-
);
|
|
1358
|
-
} else {
|
|
1359
|
-
output_manager_default.print(
|
|
1360
|
-
` ${import_chalk.default.dim("Leave empty to apply to all Preview branches.")}
|
|
1361
|
-
`
|
|
1362
|
-
);
|
|
1363
|
-
envGitBranch = await client.input.text({
|
|
1364
|
-
message: `Git branch?`
|
|
1365
|
-
});
|
|
1366
|
-
}
|
|
1367
|
-
}
|
|
1368
|
-
const hasDevelopment = envTargets.includes("development");
|
|
1369
|
-
let finalType = resolveFinalType(envTargets, isSensitive, {
|
|
1370
|
-
forceSensitive,
|
|
1371
|
-
forceEncrypted,
|
|
1372
|
-
policyOn
|
|
1373
|
-
});
|
|
1374
|
-
if (policyOn && !hasDevelopment) {
|
|
1375
|
-
if (forceEncrypted) {
|
|
1376
|
-
printEnvAddWarning(
|
|
1377
|
-
`--no-sensitive is ignored: your team enforces sensitive Environment Variables for Production and Preview.`
|
|
1378
|
-
);
|
|
1379
|
-
finalType = "sensitive";
|
|
1380
|
-
}
|
|
1381
|
-
}
|
|
1382
|
-
while (finalType === "encrypted" && (looksLikeCredentialName(envName, customSveltePublicPrefix) || looksLikeSecretValue(finalValue))) {
|
|
1383
|
-
printEnvAddWarning(
|
|
1384
|
-
"This name or value looks like a credential. Config values can be revealed after saving."
|
|
1385
|
-
);
|
|
1386
|
-
const publicPrefix = getApiPublicPrefix(envName) ?? getFrameworkPublicPrefix(project.framework, envName) ?? customSveltePublicPrefix;
|
|
1387
|
-
if (publicPrefix !== void 0 && typeSource === "inferred") {
|
|
1388
|
-
const privateName = envName.slice(publicPrefix.length);
|
|
1389
|
-
const privateCommand = buildEnvAddCommandWithPreservedArgs(
|
|
1390
|
-
client.argv,
|
|
1391
|
-
`env add ${privateName} ${envTargets.join(
|
|
1392
|
-
","
|
|
1393
|
-
)} --type secret --value "<value>" --yes`
|
|
1394
|
-
);
|
|
1395
|
-
const publicCommand = buildEnvAddCommandWithPreservedArgs(
|
|
1396
|
-
client.argv,
|
|
1397
|
-
`env add ${envName} ${envTargets.join(
|
|
1398
|
-
","
|
|
1399
|
-
)} --type config --value "<value>" --yes`
|
|
1400
|
-
);
|
|
1401
|
-
const privateHumanCommand = buildHumanEnvAddCommand(
|
|
1402
|
-
client.argv,
|
|
1403
|
-
`env add ${privateName} ${envTargets.join(",")} --type secret`
|
|
1404
|
-
);
|
|
1405
|
-
const publicHumanCommand = buildHumanEnvAddCommand(
|
|
1406
|
-
client.argv,
|
|
1407
|
-
`env add ${envName} ${envTargets.join(",")} --type config`
|
|
1408
|
-
);
|
|
1409
|
-
const message = publicPrefix === "" ? `\`${envName}\` looks like a credential, and this SvelteKit project exposes every Environment Variable to the browser. Change the SvelteKit \`publicPrefix\` to keep it private, or use \`--type config\` only if the value is safe to expose.` : `\`${envName}\` looks like a credential, and \`${publicPrefix}\` exposes its value to anyone visiting your site. Choose explicitly: rename to \`${privateName}\` with \`--type secret\` to keep it private, or keep the name with \`--type config\` to expose it.`;
|
|
1410
|
-
if (client.nonInteractive) {
|
|
1411
|
-
outputActionRequired(client, {
|
|
1412
|
-
status: "action_required",
|
|
1413
|
-
reason: "public_prefix_requires_type",
|
|
1414
|
-
message,
|
|
1415
|
-
next: [
|
|
1416
|
-
...publicPrefix === "" ? [] : [
|
|
1417
|
-
{
|
|
1418
|
-
command: privateCommand,
|
|
1419
|
-
when: "Keep it private; replace <value> before running"
|
|
1420
|
-
}
|
|
1421
|
-
],
|
|
1422
|
-
{
|
|
1423
|
-
command: publicCommand,
|
|
1424
|
-
when: "Expose it publicly; replace <value> before running"
|
|
1425
|
-
}
|
|
1426
|
-
]
|
|
1427
|
-
});
|
|
1428
|
-
}
|
|
1429
|
-
if (opts["--yes"]) {
|
|
1430
|
-
output_manager_default.fatal(message);
|
|
1431
|
-
if (publicPrefix !== "") {
|
|
1432
|
-
output_manager_default.print(` Keep it private:
|
|
13
|
+
`),1;for(let warning of keyWarnings)printEnvAddWarning(warning.message);let action=await client.input.select({message:"How should this variable be stored?",choices:[{name:`Keep private: rename to ${nameWithoutPrefix} and use Secret`,value:"p"},{name:`Expose to anyone visiting your site: keep ${envName} as Config`,value:"c"},{name:"Enter a different name",value:"r"}]});action==="p"?(envName=nameWithoutPrefix,explicitType="secret",typeSource="prompt",output_manager_default.log(`Renamed to ${envName}`)):action==="c"?(explicitType="config",typeSource="prompt",keyAccepted=!0):envName=await client.input.text({message:"Name?",validate:val=>val?!0:"Name cannot be empty"})}let customSveltePublicPrefix,apiPublicPrefix=getApiPublicPrefix(envName),matchingFrameworkPublicPrefix=getFrameworkPublicPrefix(project.framework,envName);if(matchingFrameworkPublicPrefix!==null&&(explicitType==="secret"||forceSensitive)){let message=`\`${matchingFrameworkPublicPrefix}\` exposes this value to anyone visiting your site, so \`${envName}\` cannot be kept private as a Secret. Rename the variable without the framework's public prefix to keep it private, or use \`--type config\` only if the value is safe to expose.`;return client.nonInteractive&&outputAgentError(client,{status:"error",reason:"invalid_type",message},1),output_manager_default.fatal(message),1}if(project.framework==="sveltekit"||project.framework==="sveltekit-1"||project.framework==="sveltekit-2"){let matchingLocalPrefix=(await getLocalSvelteKitPublicPrefixes(link.repoRoot??client.cwd,project.rootDirectory))?.find(prefix=>envName.startsWith(prefix));matchingLocalPrefix!==void 0&&apiPublicPrefix===null&&matchingFrameworkPublicPrefix===null&&(customSveltePublicPrefix=matchingLocalPrefix)}if(customSveltePublicPrefix!==void 0&&(explicitType==="secret"||forceSensitive)){let message=customSveltePublicPrefix===""?"This SvelteKit project uses an empty `publicPrefix`, so every Environment Variable is exposed to the browser and cannot be kept private as a Secret. Change the SvelteKit `publicPrefix`, or use `--type config` only if the value is safe to expose.":`\`${customSveltePublicPrefix}\` exposes this value to anyone visiting your site, so \`${envName}\` cannot be kept private as a Secret. Rename the variable without the configured public prefix, or use \`--type config\` only if the value is safe to expose.`;return client.nonInteractive&&outputAgentError(client,{status:"error",reason:"invalid_type",message},1),output_manager_default.fatal(message),1}customSveltePublicPrefix!==void 0&&printEnvAddWarning(customSveltePublicPrefix===""?"This SvelteKit project uses an empty `publicPrefix`, so every Environment Variable is exposed to the browser.":`\`${customSveltePublicPrefix}\` variables are exposed to the browser by this SvelteKit project.`);let skipConfirm=opts["--yes"]||!!stdInput||valueFromFlag!==void 0,[{envs},customEnvironments]=await Promise.all([getEnvRecords(client,project.id,"vercel-cli:env:add"),getCustomEnvironments(client,project.id)]);if(envTargets.length>0){let resolved=[],invalid=[];for(let target of envTargets){if(isValidEnvTarget(target)){resolved.push(target);continue}let custom=customEnvironments.find(c=>c.id===target||c.slug===target);custom?resolved.push(custom.id):invalid.push(target)}if(invalid.length>0){let valid=[...envTargetChoices.map(c=>c.value),...customEnvironments.map(c=>c.slug)],message=`Invalid environment: ${invalid.join(", ")}. Valid environments: ${valid.join(", ")}. Separate multiple environments with commas.`;return client.nonInteractive&&outputAgentError(client,{status:"error",reason:"invalid_environment",message},1),output_manager_default.error(message),1}envTargets=resolved}if(envGitBranch&&envTargets.length>1){let message="A Git branch can only be set when Preview is the only selected environment.";return client.nonInteractive&&outputAgentError(client,{status:"error",reason:"branch_requires_preview_only",message},1),output_manager_default.error(message),1}let matchingEnvs=envs.filter(r=>r.key===envName),existingTargets=new Set,existingCustomEnvs=new Set;for(let env of matchingEnvs){if(typeof env.target=="string")existingTargets.add(env.target);else if(Array.isArray(env.target))for(let target of env.target)existingTargets.add(target);if(env.customEnvironmentIds)for(let customEnvId of env.customEnvironmentIds)existingCustomEnvs.add(customEnvId)}let choices=[...envTargetChoices.filter(c=>!existingTargets.has(c.value)).map(c=>({name:c.name,value:c.value})),...customEnvironments.filter(c=>!existingCustomEnvs.has(c.id)).map(c=>({name:c.slug,value:c.id}))];if(!envGitBranch&&choices.length===0&&!opts["--force"]){let projectFlag=opts["--project"]?` --project ${opts["--project"]}`:"";return output_manager_default.error(`The variable ${param(envName)} has already been added to all Environments. To remove, run ${getCommandName(`env rm ${envName}${projectFlag}`)}.`),1}let policyOn=!1,teamSensitivePolicyOn=!1,disjunctiveProductionSecretPolicyOn=!1;if(link.org.type==="team")try{let team=await getTeamByIdOrSlug(client,link.org.id);teamSensitivePolicyOn=team?.sensitiveEnvironmentVariablePolicy==="on",disjunctiveProductionSecretPolicyOn=team?.disjunctiveProductionSecretPolicy==="on"}catch{}let skipSensitivePrompt=forceSensitive||forceEncrypted||!!explicitType||client.nonInteractive||skipConfirm,isDevelopmentOnlyTarget=envTargets.length===1&&envTargets[0]==="development",isSensitive;if(forceSensitive)isSensitive=!0;else if(forceEncrypted)isSensitive=!1;else if(explicitType)isSensitive=explicitType==="secret";else if(apiPublicPrefix||matchingFrameworkPublicPrefix||customSveltePublicPrefix!==void 0)isSensitive=!1,explicitType="config",typeSource="inferred";else if(isDevelopmentOnlyTarget)isSensitive=!1,typeSource="inferred";else if(skipSensitivePrompt)isSensitive=!0,typeSource="default";else{let selectedType=await client.input.select({message:"Environment Variable type?",choices:[{name:getSecretStorageChoice(envTargets,looksLikeCredentialName(envName)?"because this name looks like a credential":void 0),value:"secret"},{name:"Config (can be revealed after saving)",value:"config"}]});isSensitive=selectedType==="secret",explicitType=selectedType,typeSource="prompt"}if(envTargets.length>0){let compatibilityError=getTargetCompatibilityError(envTargets,isSensitive,policyOn);if(compatibilityError){if(client.nonInteractive){let next=[{command:buildEnvAddCommandWithPreservedArgs(client.argv,`env add ${envName} development --value "<value>" --yes`),when:"Add as non-sensitive to Development only"}];outputAgentError(client,{status:"error",reason:"non_sensitive_not_allowed_on_production_preview",message:compatibilityError,next},1)}return output_manager_default.error(compatibilityError),1}}let envChoices=filterEnvChoicesForSensitivity(choices,{isSensitive,policyOn});if(policyOn&&isSensitive)for(let choice of envChoices)(choice.value==="production"||choice.value==="preview")&&(choice.checked=!0);else envChoices.length===1&&(envChoices[0].checked=!0);if(!envGitBranch&&envChoices.length===0&&envTargets.length===0&&!opts["--force"])return output_manager_default.error("No Environments are available for this variable with the selected sensitivity. Your team requires sensitive Environment Variables for Production and Preview."),1;let envValue;if(stdInput){let normalizedStdinValue=normalizeStdinEnvValue(stdInput);envValue=normalizedStdinValue.value,normalizedStdinValue.strippedTrailingNewline&&output_manager_default.log("Removed trailing newline from stdin input")}else valueFromFlag!==void 0?envValue=valueFromFlag:(client.nonInteractive&&outputActionRequired(client,{status:"action_required",reason:"missing_value",message:'In non-interactive mode provide the value via --value or stdin. Example: vercel env add <name> <environment> --value "<value>" --yes',next:[{command:buildEnvAddCommandWithPreservedArgs(client.argv,`env add <name> ${getEnvTargetPlaceholder()} --value "<value>" --yes`)}]}),envValue=await promptEnvValue(client,{isSensitive}));let{finalValue}=await validateEnvValue({envName,initialValue:envValue,skipConfirm,promptForValue:()=>promptEnvValue(client,{isSensitive}),selectAction:choices2=>client.input.select({message:"Value?",choices:choices2}),showWarning:msg=>printEnvAddWarning(msg),showLog:msg=>output_manager_default.log(msg)});for(;envTargets.length===0;){if(client.nonInteractive&&envChoices.length>0){let standardAvailable=choices.map(c=>c.value).filter(v=>isValidEnvTarget(v)),multiTargets=filterSensitiveMultiTargetSuggestionTargets(standardAvailable,{forceSensitive,policyOn}),next=[];multiTargets.length>1&&next.push(multiTargetSuggestion(client.argv,envName,multiTargets,multiTargets.includes("development")&&!forceEncrypted)),next.push(...envChoices.slice(0,5).map(c=>({command:buildEnvAddCommandWithPreservedArgs(client.argv,`env add ${envName} ${c.value} --value "<value>" --yes`)}))),outputActionRequired(client,{status:"action_required",reason:"missing_environment",message:`Specify one or more environments (comma-separated). Add as argument or use: ${buildEnvAddCommandWithPreservedArgs(client.argv,`env add ${envName} <environment>[,<environment>] --value "<value>" --yes`)}`,choices:envChoices.map(c=>({id:c.value,name:typeof c.name=="string"?c.name:c.value})),next})}envTargets=await client.input.checkbox({message:"Environments?",instructions:CHECKBOX_INSTRUCTIONS,choices:envChoices}),envTargets.length===0&&output_manager_default.error("Please select at least one Environment")}let postSelectionError=getTargetCompatibilityError(envTargets,isSensitive,policyOn);if(postSelectionError)return output_manager_default.error(postSelectionError),1;envGitBranch===void 0&&envTargets.length===1&&envTargets[0]==="preview"&&!opts["--yes"]&&!(client.nonInteractive&&args.length===2)&&(client.nonInteractive?outputActionRequired(client,{status:"action_required",reason:"git_branch_required",message:`Add ${envName} to which Git branch for Preview? Pass branch as third argument, or omit for all Preview branches.`,next:[{command:buildEnvAddCommandWithPreservedArgs(client.argv,`env add ${envName} preview --git-branch <git-branch> --value "<value>" --yes`),when:"Add to a specific Git branch"},{command:buildEnvAddCommandWithPreservedArgs(client.argv,`env add ${envName} preview --value "<value>" --yes`),when:"Add to all Preview branches"}]},1):(output_manager_default.print(` ${import_chalk.default.dim("Leave empty to apply to all Preview branches.")}
|
|
14
|
+
`),envGitBranch=await client.input.text({message:"Git branch?"})));let hasDevelopment=envTargets.includes("development"),finalType=resolveFinalType(envTargets,isSensitive,{forceSensitive,forceEncrypted,policyOn});for(policyOn&&!hasDevelopment&&forceEncrypted&&(printEnvAddWarning("--no-sensitive is ignored: your team enforces sensitive Environment Variables for Production and Preview."),finalType="sensitive");finalType==="encrypted"&&(looksLikeCredentialName(envName,customSveltePublicPrefix)||looksLikeSecretValue(finalValue));){printEnvAddWarning("This name or value looks like a credential. Config values can be revealed after saving.");let publicPrefix=getApiPublicPrefix(envName)??getFrameworkPublicPrefix(project.framework,envName)??customSveltePublicPrefix;if(publicPrefix!==void 0&&typeSource==="inferred"){let privateName=envName.slice(publicPrefix.length),privateCommand=buildEnvAddCommandWithPreservedArgs(client.argv,`env add ${privateName} ${envTargets.join(",")} --type secret --value "<value>" --yes`),publicCommand=buildEnvAddCommandWithPreservedArgs(client.argv,`env add ${envName} ${envTargets.join(",")} --type config --value "<value>" --yes`),privateHumanCommand=buildHumanEnvAddCommand(client.argv,`env add ${privateName} ${envTargets.join(",")} --type secret`),publicHumanCommand=buildHumanEnvAddCommand(client.argv,`env add ${envName} ${envTargets.join(",")} --type config`),message=publicPrefix===""?`\`${envName}\` looks like a credential, and this SvelteKit project exposes every Environment Variable to the browser. Change the SvelteKit \`publicPrefix\` to keep it private, or use \`--type config\` only if the value is safe to expose.`:`\`${envName}\` looks like a credential, and \`${publicPrefix}\` exposes its value to anyone visiting your site. Choose explicitly: rename to \`${privateName}\` with \`--type secret\` to keep it private, or keep the name with \`--type config\` to expose it.`;if(client.nonInteractive&&outputActionRequired(client,{status:"action_required",reason:"public_prefix_requires_type",message,next:[...publicPrefix===""?[]:[{command:privateCommand,when:"Keep it private; replace <value> before running"}],{command:publicCommand,when:"Expose it publicly; replace <value> before running"}]}),opts["--yes"])return output_manager_default.fatal(message),publicPrefix!==""&&output_manager_default.print(` Keep it private:
|
|
1433
15
|
${privateHumanCommand}
|
|
1434
|
-
`)
|
|
1435
|
-
}
|
|
1436
|
-
output_manager_default.print(` Expose it publicly:
|
|
16
|
+
`),output_manager_default.print(` Expose it publicly:
|
|
1437
17
|
${publicHumanCommand}
|
|
1438
|
-
`);
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
name: `Keep private: rename to ${privateName} and use Secret`,
|
|
1447
|
-
value: "private"
|
|
1448
|
-
}
|
|
1449
|
-
],
|
|
1450
|
-
{
|
|
1451
|
-
name: `Expose to anyone visiting your site: keep ${envName} as Config`,
|
|
1452
|
-
value: "public"
|
|
1453
|
-
},
|
|
1454
|
-
{ name: "Enter a different value", value: "reenter" }
|
|
1455
|
-
]
|
|
1456
|
-
});
|
|
1457
|
-
if (selectedAction === "private") {
|
|
1458
|
-
envName = privateName;
|
|
1459
|
-
finalType = "sensitive";
|
|
1460
|
-
explicitType = "secret";
|
|
1461
|
-
typeSource = "prompt";
|
|
1462
|
-
output_manager_default.log(`Renamed to ${envName}`);
|
|
1463
|
-
break;
|
|
1464
|
-
}
|
|
1465
|
-
if (selectedAction === "reenter") {
|
|
1466
|
-
const reenteredValue = await promptEnvValue(client, {
|
|
1467
|
-
isSensitive: false
|
|
1468
|
-
});
|
|
1469
|
-
const validated = await validateEnvValue({
|
|
1470
|
-
envName,
|
|
1471
|
-
initialValue: reenteredValue,
|
|
1472
|
-
skipConfirm: false,
|
|
1473
|
-
promptForValue: () => promptEnvValue(client, { isSensitive: false }),
|
|
1474
|
-
selectAction: (choices2) => client.input.select({ message: "Value?", choices: choices2 }),
|
|
1475
|
-
showWarning: (msg) => printEnvAddWarning(msg),
|
|
1476
|
-
showLog: (msg) => output_manager_default.log(msg)
|
|
1477
|
-
});
|
|
1478
|
-
finalValue = validated.finalValue;
|
|
1479
|
-
continue;
|
|
1480
|
-
}
|
|
1481
|
-
} else if (typeSource !== "argv" && typeSource !== "prompt" && !opts["--yes"] && !client.nonInteractive) {
|
|
1482
|
-
const selectedType = await client.input.select({
|
|
1483
|
-
message: "Store this value as?",
|
|
1484
|
-
choices: [
|
|
1485
|
-
{
|
|
1486
|
-
name: getSecretStorageChoice(envTargets, "for this value"),
|
|
1487
|
-
value: "secret"
|
|
1488
|
-
},
|
|
1489
|
-
{
|
|
1490
|
-
name: "Config (can be revealed after saving)",
|
|
1491
|
-
value: "config"
|
|
1492
|
-
}
|
|
1493
|
-
]
|
|
1494
|
-
});
|
|
1495
|
-
if (selectedType === "secret") {
|
|
1496
|
-
finalType = "sensitive";
|
|
1497
|
-
explicitType = "secret";
|
|
1498
|
-
typeSource = "prompt";
|
|
1499
|
-
}
|
|
1500
|
-
}
|
|
1501
|
-
break;
|
|
1502
|
-
}
|
|
1503
|
-
if (finalType === "sensitive" && customSveltePublicPrefix !== void 0 && envName.startsWith(customSveltePublicPrefix)) {
|
|
1504
|
-
printEnvAddWarning(
|
|
1505
|
-
"This SvelteKit project exposes this variable to the browser; the Secret type does not prevent that. Rename the variable without the configured public prefix to keep it private."
|
|
1506
|
-
);
|
|
1507
|
-
}
|
|
1508
|
-
if (isFlagsSecretNeedingSplit({
|
|
1509
|
-
key: envName,
|
|
1510
|
-
type: finalType,
|
|
1511
|
-
targets: envTargets.filter(isValidEnvTarget),
|
|
1512
|
-
customEnvironmentIds: envTargets.filter(
|
|
1513
|
-
(target) => !isValidEnvTarget(target)
|
|
1514
|
-
)
|
|
1515
|
-
})) {
|
|
1516
|
-
printEnvAddWarning(
|
|
1517
|
-
"FLAGS_SECRET should use a separate value for each environment so Development overrides cannot affect Preview or Production."
|
|
1518
|
-
);
|
|
1519
|
-
}
|
|
1520
|
-
const hasProduction = envTargets.includes("production");
|
|
1521
|
-
const hasNonProduction = envTargets.some((target) => target !== "production");
|
|
1522
|
-
if (finalType === "sensitive" && disjunctiveProductionSecretPolicyOn && hasProduction && hasNonProduction) {
|
|
1523
|
-
const message = "Your team requires Production and non-Production Secrets to be stored separately with different values. Run one command for Production and another for the remaining environments.";
|
|
1524
|
-
if (client.nonInteractive) {
|
|
1525
|
-
outputAgentError(
|
|
1526
|
-
client,
|
|
1527
|
-
{
|
|
1528
|
-
status: "error",
|
|
1529
|
-
reason: "production_secret_must_be_separate",
|
|
1530
|
-
message,
|
|
1531
|
-
next: [
|
|
1532
|
-
{
|
|
1533
|
-
command: buildEnvAddCommandWithPreservedArgs(
|
|
1534
|
-
client.argv,
|
|
1535
|
-
`env add ${envName} production --type secret --value "<production-value>" --yes`
|
|
1536
|
-
),
|
|
1537
|
-
when: "Set the Production Secret"
|
|
1538
|
-
},
|
|
1539
|
-
{
|
|
1540
|
-
command: buildEnvAddCommandWithPreservedArgs(
|
|
1541
|
-
client.argv,
|
|
1542
|
-
`env add ${envName} ${envTargets.filter((target) => target !== "production").join(
|
|
1543
|
-
","
|
|
1544
|
-
)} --type secret --value "<non-production-value>" --yes`
|
|
1545
|
-
),
|
|
1546
|
-
when: "Set the non-Production Secret"
|
|
1547
|
-
}
|
|
1548
|
-
]
|
|
1549
|
-
},
|
|
1550
|
-
1
|
|
1551
|
-
);
|
|
1552
|
-
}
|
|
1553
|
-
output_manager_default.fatal(message);
|
|
1554
|
-
return 1;
|
|
1555
|
-
}
|
|
1556
|
-
const upsert = opts["--force"] ? "true" : "";
|
|
1557
|
-
const { visibility, error: visibilityError } = resolveEnvVarVisibility({
|
|
1558
|
-
explicitVisibility: explicitType,
|
|
1559
|
-
explicitOptionSource: typeOption.source,
|
|
1560
|
-
type: finalType,
|
|
1561
|
-
key: envName,
|
|
1562
|
-
envTargets,
|
|
1563
|
-
teamSensitivePolicyOn,
|
|
1564
|
-
context: "add"
|
|
1565
|
-
});
|
|
1566
|
-
if (visibilityError) {
|
|
1567
|
-
if (client.nonInteractive) {
|
|
1568
|
-
outputAgentError(
|
|
1569
|
-
client,
|
|
1570
|
-
{
|
|
1571
|
-
status: "error",
|
|
1572
|
-
reason: "invalid_type",
|
|
1573
|
-
message: visibilityError
|
|
1574
|
-
},
|
|
1575
|
-
1
|
|
1576
|
-
);
|
|
1577
|
-
}
|
|
1578
|
-
output_manager_default.fatal(visibilityError);
|
|
1579
|
-
return 1;
|
|
1580
|
-
}
|
|
1581
|
-
try {
|
|
1582
|
-
output_manager_default.spinner("Saving\u2026");
|
|
1583
|
-
await addEnvRecord(
|
|
1584
|
-
client,
|
|
1585
|
-
project.id,
|
|
1586
|
-
upsert,
|
|
1587
|
-
finalType,
|
|
1588
|
-
envName,
|
|
1589
|
-
finalValue,
|
|
1590
|
-
envTargets,
|
|
1591
|
-
envGitBranch,
|
|
1592
|
-
visibility
|
|
1593
|
-
);
|
|
1594
|
-
} catch (err) {
|
|
1595
|
-
if (client.nonInteractive && isAPIError(err)) {
|
|
1596
|
-
const productionSecretPolicyError = getProductionSecretPolicyErrorKind(
|
|
1597
|
-
err.serverMessage
|
|
1598
|
-
);
|
|
1599
|
-
const reason = productionSecretPolicyError ? productionSecretPolicyError === "different-values" ? "production_secret_requires_different_value" : "production_secret_must_be_separate" : err.slug || (err.serverMessage?.toLowerCase().includes("branch") ? "branch_not_found" : "api_error");
|
|
1600
|
-
outputAgentError(
|
|
1601
|
-
client,
|
|
1602
|
-
{
|
|
1603
|
-
status: "error",
|
|
1604
|
-
reason,
|
|
1605
|
-
message: productionSecretPolicyError ? `${err.serverMessage} ${getProductionSecretPolicyRecovery(
|
|
1606
|
-
productionSecretPolicyError
|
|
1607
|
-
)}` : err.serverMessage
|
|
1608
|
-
},
|
|
1609
|
-
1
|
|
1610
|
-
);
|
|
1611
|
-
}
|
|
1612
|
-
if (isAPIError(err) && isKnownError(err)) {
|
|
1613
|
-
output_manager_default.error(err.serverMessage);
|
|
1614
|
-
return 1;
|
|
1615
|
-
}
|
|
1616
|
-
throw err;
|
|
1617
|
-
}
|
|
1618
|
-
printEnvAddResult(
|
|
1619
|
-
link,
|
|
1620
|
-
envName,
|
|
1621
|
-
envTargets,
|
|
1622
|
-
envGitBranch,
|
|
1623
|
-
customEnvironments,
|
|
1624
|
-
finalType,
|
|
1625
|
-
Boolean(opts["--force"]),
|
|
1626
|
-
visibility
|
|
1627
|
-
);
|
|
1628
|
-
if (typeSource === "default") {
|
|
1629
|
-
output_manager_default.print(
|
|
1630
|
-
` ${import_chalk.default.dim(getDefaultSecretStorageGuidance(envTargets))}
|
|
1631
|
-
`
|
|
1632
|
-
);
|
|
1633
|
-
}
|
|
1634
|
-
const { isAgent } = await determineAgent();
|
|
1635
|
-
const guidanceMode = isGuidanceEnabled(
|
|
1636
|
-
client,
|
|
1637
|
-
parsedArgs.flags["--guidance"],
|
|
1638
|
-
isAgent
|
|
1639
|
-
);
|
|
1640
|
-
if (guidanceMode) {
|
|
1641
|
-
suggestNextCommands([
|
|
1642
|
-
{
|
|
1643
|
-
description: "List Environment Variables",
|
|
1644
|
-
command: withGlobalFlags(client, "env ls", { preserveProject: true })
|
|
1645
|
-
},
|
|
1646
|
-
{
|
|
1647
|
-
description: "Pull Development Environment Variables into .env.local",
|
|
1648
|
-
command: withGlobalFlags(client, "env pull", {
|
|
1649
|
-
preserveProject: true
|
|
1650
|
-
})
|
|
1651
|
-
}
|
|
1652
|
-
]);
|
|
1653
|
-
}
|
|
1654
|
-
return 0;
|
|
1655
|
-
}
|
|
1656
|
-
|
|
1657
|
-
// src/commands/env/ls.ts
|
|
1658
|
-
var import_chalk2 = __toESM(require_source(), 1);
|
|
1659
|
-
var import_ms = __toESM(require_ms(), 1);
|
|
1660
|
-
|
|
1661
|
-
// src/util/env/format-environments.ts
|
|
1662
|
-
var import_title = __toESM(require_lib(), 1);
|
|
1663
|
-
function formatEnvironments(link, env, customEnvironments) {
|
|
1664
|
-
const defaultTargets = (Array.isArray(env.target) ? env.target : [env.target || ""]).map((t) => {
|
|
1665
|
-
return formatEnvironment(link.org.slug, link.project.name, {
|
|
1666
|
-
id: t,
|
|
1667
|
-
slug: (0, import_title.default)(t)
|
|
1668
|
-
});
|
|
1669
|
-
});
|
|
1670
|
-
const customTargets = env.customEnvironmentIds ? env.customEnvironmentIds.map((id) => customEnvironments.find((e) => e.id === id)).filter(Boolean).map((e) => formatEnvironment(link.org.slug, link.project.name, e)) : [];
|
|
1671
|
-
const targetsString = [...defaultTargets, ...customTargets].join(", ");
|
|
1672
|
-
return env.gitBranch ? `${targetsString} (${env.gitBranch})` : targetsString;
|
|
1673
|
-
}
|
|
1674
|
-
|
|
1675
|
-
// src/util/telemetry/commands/env/ls.ts
|
|
1676
|
-
var EnvLsTelemetryClient = class extends TelemetryClient {
|
|
1677
|
-
trackCliArgumentEnvironment(environment) {
|
|
1678
|
-
if (environment) {
|
|
1679
|
-
this.trackCliArgument({
|
|
1680
|
-
arg: "environment",
|
|
1681
|
-
value: STANDARD_ENVIRONMENTS.includes(
|
|
1682
|
-
environment
|
|
1683
|
-
) ? environment : this.redactedValue
|
|
1684
|
-
});
|
|
1685
|
-
}
|
|
1686
|
-
}
|
|
1687
|
-
trackCliArgumentGitBranch(gitBranch) {
|
|
1688
|
-
if (gitBranch) {
|
|
1689
|
-
this.trackCliArgument({
|
|
1690
|
-
arg: "git-branch",
|
|
1691
|
-
value: this.redactedValue
|
|
1692
|
-
});
|
|
1693
|
-
}
|
|
1694
|
-
}
|
|
1695
|
-
trackCliFlagGuidance(guidance) {
|
|
1696
|
-
if (guidance) {
|
|
1697
|
-
this.trackCliFlag("guidance");
|
|
1698
|
-
}
|
|
1699
|
-
}
|
|
1700
|
-
trackCliFlagJson(json) {
|
|
1701
|
-
if (json) {
|
|
1702
|
-
this.trackCliFlag("json");
|
|
1703
|
-
}
|
|
1704
|
-
}
|
|
1705
|
-
};
|
|
1706
|
-
|
|
1707
|
-
// src/commands/env/ls.ts
|
|
1708
|
-
import { determineAgent as determineAgent2 } from "@vercel/detect-agent";
|
|
1709
|
-
async function ls(client, argv) {
|
|
1710
|
-
const telemetryClient = new EnvLsTelemetryClient({
|
|
1711
|
-
opts: {
|
|
1712
|
-
store: client.telemetryEventStore
|
|
1713
|
-
}
|
|
1714
|
-
});
|
|
1715
|
-
let parsedArgs;
|
|
1716
|
-
const flagsSpecification = getFlagsSpecification(listSubcommand.options);
|
|
1717
|
-
try {
|
|
1718
|
-
parsedArgs = parseArguments(argv, flagsSpecification);
|
|
1719
|
-
} catch (err) {
|
|
1720
|
-
printError(err);
|
|
1721
|
-
return 1;
|
|
1722
|
-
}
|
|
1723
|
-
const { args, flags } = parsedArgs;
|
|
1724
|
-
const validationResult = validateLsArgs({
|
|
1725
|
-
commandName: "env ls",
|
|
1726
|
-
args,
|
|
1727
|
-
maxArgs: 2,
|
|
1728
|
-
exitCode: 1,
|
|
1729
|
-
usageString: getCommandName(
|
|
1730
|
-
`env ls ${getEnvTargetPlaceholder()} <gitbranch>`
|
|
1731
|
-
)
|
|
1732
|
-
});
|
|
1733
|
-
if (validationResult !== 0) {
|
|
1734
|
-
return validationResult;
|
|
1735
|
-
}
|
|
1736
|
-
const [envTarget, envGitBranch] = args;
|
|
1737
|
-
const formatResult = validateJsonOutput(flags);
|
|
1738
|
-
if (!formatResult.valid) {
|
|
1739
|
-
output_manager_default.error(formatResult.error);
|
|
1740
|
-
return 1;
|
|
1741
|
-
}
|
|
1742
|
-
const asJson = formatResult.jsonOutput;
|
|
1743
|
-
telemetryClient.trackCliArgumentEnvironment(envTarget);
|
|
1744
|
-
telemetryClient.trackCliArgumentGitBranch(envGitBranch);
|
|
1745
|
-
telemetryClient.trackCliFlagGuidance(flags["--guidance"]);
|
|
1746
|
-
telemetryClient.trackCliOptionFormat(flags["--format"]);
|
|
1747
|
-
const projectName = flags["--project"];
|
|
1748
|
-
telemetryClient.trackCliOptionProject(projectName);
|
|
1749
|
-
const link = await resolveProjectContext({
|
|
1750
|
-
client,
|
|
1751
|
-
projectNameOrId: projectName,
|
|
1752
|
-
commandName: "env ls"
|
|
1753
|
-
});
|
|
1754
|
-
if (link.status === "error") {
|
|
1755
|
-
return link.exitCode;
|
|
1756
|
-
} else if (link.status === "not_linked") {
|
|
1757
|
-
output_manager_default.error(
|
|
1758
|
-
`Your codebase isn\u2019t linked to a project on Vercel. Pass --project <name>, or ${client.nonInteractive ? `run ${getCommandName("link --yes --team <team-id> --project <project-id>")} to link non-interactively.` : `run ${getCommandName("link")} to begin.`}`
|
|
1759
|
-
);
|
|
1760
|
-
return 1;
|
|
1761
|
-
}
|
|
1762
|
-
client.config.currentTeam = link.org.type === "team" ? link.org.id : void 0;
|
|
1763
|
-
const { project, org } = link;
|
|
1764
|
-
const lsStamp = stamp_default();
|
|
1765
|
-
const [envsResult, customEnvs] = await Promise.all([
|
|
1766
|
-
getEnvRecords(client, project.id, "vercel-cli:env:ls", {
|
|
1767
|
-
target: envTarget,
|
|
1768
|
-
gitBranch: envGitBranch
|
|
1769
|
-
}),
|
|
1770
|
-
getCustomEnvironments(client, project.id)
|
|
1771
|
-
]);
|
|
1772
|
-
const { envs } = envsResult;
|
|
1773
|
-
const projectSlugLink = formatProject(org.slug, project.name);
|
|
1774
|
-
if (asJson) {
|
|
1775
|
-
output_manager_default.stopSpinner();
|
|
1776
|
-
const jsonOutput = {
|
|
1777
|
-
envs: envs.map((env) => ({
|
|
1778
|
-
key: env.key,
|
|
1779
|
-
value: isSecretEnvVar(env) ? void 0 : env.value,
|
|
1780
|
-
type: env.type,
|
|
1781
|
-
visibility: env.visibility,
|
|
1782
|
-
target: env.target,
|
|
1783
|
-
gitBranch: env.gitBranch,
|
|
1784
|
-
configurationId: env.configurationId,
|
|
1785
|
-
createdAt: env.createdAt,
|
|
1786
|
-
updatedAt: env.updatedAt
|
|
1787
|
-
}))
|
|
1788
|
-
};
|
|
1789
|
-
client.stdout.write(`${JSON.stringify(jsonOutput, null, 2)}
|
|
1790
|
-
`);
|
|
1791
|
-
} else if (envs.length === 0) {
|
|
1792
|
-
output_manager_default.log(
|
|
1793
|
-
`No Environment Variables found for ${projectSlugLink} ${import_chalk2.default.gray(lsStamp())}`
|
|
1794
|
-
);
|
|
1795
|
-
} else {
|
|
1796
|
-
output_manager_default.log(
|
|
1797
|
-
`Environment Variables found for ${projectSlugLink} ${import_chalk2.default.gray(lsStamp())}`
|
|
1798
|
-
);
|
|
1799
|
-
client.stdout.write(`${getTable(link, envs, customEnvs)}
|
|
1800
|
-
`);
|
|
1801
|
-
}
|
|
1802
|
-
if (!asJson) {
|
|
1803
|
-
const { isAgent } = await determineAgent2();
|
|
1804
|
-
const guidanceMode = isGuidanceEnabled(
|
|
1805
|
-
client,
|
|
1806
|
-
parsedArgs.flags["--guidance"],
|
|
1807
|
-
isAgent
|
|
1808
|
-
);
|
|
1809
|
-
if (guidanceMode) {
|
|
1810
|
-
suggestNextCommands([
|
|
1811
|
-
{
|
|
1812
|
-
description: "Add an Environment Variable",
|
|
1813
|
-
command: withGlobalFlags(client, "env add", {
|
|
1814
|
-
preserveProject: true
|
|
1815
|
-
})
|
|
1816
|
-
},
|
|
1817
|
-
{
|
|
1818
|
-
description: "Remove an Environment Variable",
|
|
1819
|
-
command: withGlobalFlags(client, "env rm", {
|
|
1820
|
-
preserveProject: true
|
|
1821
|
-
})
|
|
1822
|
-
},
|
|
1823
|
-
{
|
|
1824
|
-
description: "Pull Development Environment Variables into .env.local",
|
|
1825
|
-
command: withGlobalFlags(client, "env pull", {
|
|
1826
|
-
preserveProject: true
|
|
1827
|
-
})
|
|
1828
|
-
}
|
|
1829
|
-
]);
|
|
1830
|
-
}
|
|
1831
|
-
}
|
|
1832
|
-
return 0;
|
|
1833
|
-
}
|
|
1834
|
-
function getTable(link, records, customEnvironments) {
|
|
1835
|
-
const label = records.some((env) => env.gitBranch) ? "environments (git branch)" : "environments";
|
|
1836
|
-
return formatTable(
|
|
1837
|
-
["name", "value", "type", label, "created"],
|
|
1838
|
-
["l", "l", "l", "l", "l"],
|
|
1839
|
-
[
|
|
1840
|
-
{
|
|
1841
|
-
name: "",
|
|
1842
|
-
rows: records.map((row) => getRow(link, row, customEnvironments))
|
|
1843
|
-
}
|
|
1844
|
-
]
|
|
1845
|
-
);
|
|
1846
|
-
}
|
|
1847
|
-
function getRow(link, env, customEnvironments) {
|
|
1848
|
-
let value;
|
|
1849
|
-
if (isSecretEnvVar(env)) {
|
|
1850
|
-
value = import_chalk2.default.gray.italic("Hidden");
|
|
1851
|
-
} else if (env.type === "system") {
|
|
1852
|
-
value = import_chalk2.default.gray.italic(env.value);
|
|
1853
|
-
} else {
|
|
1854
|
-
const singleLineValue = env.value.replace(/\s/g, " ");
|
|
1855
|
-
value = import_chalk2.default.gray(ellipsis(singleLineValue, 19));
|
|
1856
|
-
}
|
|
1857
|
-
const now = Date.now();
|
|
1858
|
-
return [
|
|
1859
|
-
import_chalk2.default.bold(env.key),
|
|
1860
|
-
value,
|
|
1861
|
-
getEnvironmentVariableTypeLabel(env),
|
|
1862
|
-
formatEnvironments(link, env, customEnvironments),
|
|
1863
|
-
env.createdAt ? `${(0, import_ms.default)(now - env.createdAt)} ago` : ""
|
|
1864
|
-
];
|
|
1865
|
-
}
|
|
1866
|
-
function getEnvironmentVariableTypeLabel(env) {
|
|
1867
|
-
if (isSecretEnvVar(env)) {
|
|
1868
|
-
return "Secret";
|
|
1869
|
-
}
|
|
1870
|
-
if (env.type === "system") {
|
|
1871
|
-
return "System";
|
|
1872
|
-
}
|
|
1873
|
-
return "Config";
|
|
1874
|
-
}
|
|
1875
|
-
|
|
1876
|
-
// src/commands/env/rm.ts
|
|
1877
|
-
var import_chalk3 = __toESM(require_source(), 1);
|
|
1878
|
-
|
|
1879
|
-
// src/util/env/remove-env-record.ts
|
|
1880
|
-
async function removeEnvRecord(client, projectId, env) {
|
|
1881
|
-
output_manager_default.debug(`Removing Environment Variable ${env.key}`);
|
|
1882
|
-
const url = `/v10/projects/${projectId}/env/${env.id}`;
|
|
1883
|
-
await client.fetch(url, {
|
|
1884
|
-
method: "DELETE"
|
|
1885
|
-
});
|
|
1886
|
-
}
|
|
1887
|
-
|
|
1888
|
-
// src/util/telemetry/commands/env/rm.ts
|
|
1889
|
-
var EnvRmTelemetryClient = class extends TelemetryClient {
|
|
1890
|
-
trackCliArgumentName(name) {
|
|
1891
|
-
if (name) {
|
|
1892
|
-
this.trackCliArgument({
|
|
1893
|
-
arg: "name",
|
|
1894
|
-
value: this.redactedValue
|
|
1895
|
-
});
|
|
1896
|
-
}
|
|
1897
|
-
}
|
|
1898
|
-
trackCliArgumentEnvironment(environment) {
|
|
1899
|
-
if (environment) {
|
|
1900
|
-
this.trackCliArgument({
|
|
1901
|
-
arg: "environment",
|
|
1902
|
-
value: STANDARD_ENVIRONMENTS.includes(
|
|
1903
|
-
environment
|
|
1904
|
-
) ? environment : this.redactedValue
|
|
1905
|
-
});
|
|
1906
|
-
}
|
|
1907
|
-
}
|
|
1908
|
-
trackCliArgumentGitBranch(gitBranch) {
|
|
1909
|
-
if (gitBranch) {
|
|
1910
|
-
this.trackCliArgument({
|
|
1911
|
-
arg: "git-branch",
|
|
1912
|
-
value: this.redactedValue
|
|
1913
|
-
});
|
|
1914
|
-
}
|
|
1915
|
-
}
|
|
1916
|
-
trackCliFlagYes(yes) {
|
|
1917
|
-
if (yes) {
|
|
1918
|
-
this.trackCliFlag("yes");
|
|
1919
|
-
}
|
|
1920
|
-
}
|
|
1921
|
-
};
|
|
1922
|
-
|
|
1923
|
-
// src/commands/env/rm.ts
|
|
1924
|
-
function printEnvRmWarning(message) {
|
|
1925
|
-
output_manager_default.print(`${import_chalk3.default.yellow("!")} ${message}
|
|
1926
|
-
`);
|
|
1927
|
-
}
|
|
1928
|
-
async function rm(client, argv) {
|
|
1929
|
-
const telemetryClient = new EnvRmTelemetryClient({
|
|
1930
|
-
opts: {
|
|
1931
|
-
store: client.telemetryEventStore
|
|
1932
|
-
}
|
|
1933
|
-
});
|
|
1934
|
-
let parsedArgs;
|
|
1935
|
-
const flagsSpecification = getFlagsSpecification(removeSubcommand.options);
|
|
1936
|
-
try {
|
|
1937
|
-
parsedArgs = parseArguments(argv, flagsSpecification);
|
|
1938
|
-
} catch (err) {
|
|
1939
|
-
if (client.nonInteractive) {
|
|
1940
|
-
outputAgentError(
|
|
1941
|
-
client,
|
|
1942
|
-
{
|
|
1943
|
-
status: "error",
|
|
1944
|
-
reason: "invalid_arguments",
|
|
1945
|
-
message: err instanceof Error ? err.message : String(err)
|
|
1946
|
-
},
|
|
1947
|
-
1
|
|
1948
|
-
);
|
|
1949
|
-
}
|
|
1950
|
-
printError(err);
|
|
1951
|
-
return 1;
|
|
1952
|
-
}
|
|
1953
|
-
const { args, flags: opts } = parsedArgs;
|
|
1954
|
-
if (args.length > 3) {
|
|
1955
|
-
if (client.nonInteractive) {
|
|
1956
|
-
outputAgentError(
|
|
1957
|
-
client,
|
|
1958
|
-
{
|
|
1959
|
-
status: "error",
|
|
1960
|
-
reason: "invalid_arguments",
|
|
1961
|
-
message: `Invalid number of arguments. Usage: \`${getCommandNamePlain(
|
|
1962
|
-
`env rm <name> ${getEnvTargetPlaceholder()} <gitbranch>`
|
|
1963
|
-
)}\``
|
|
1964
|
-
},
|
|
1965
|
-
1
|
|
1966
|
-
);
|
|
1967
|
-
}
|
|
1968
|
-
output_manager_default.error(
|
|
1969
|
-
`Invalid number of arguments. Usage: ${getCommandName(
|
|
1970
|
-
`env rm <name> ${getEnvTargetPlaceholder()} <gitbranch>`
|
|
1971
|
-
)}`
|
|
1972
|
-
);
|
|
1973
|
-
return 1;
|
|
1974
|
-
}
|
|
1975
|
-
let [envName, envTarget, envGitBranch] = args;
|
|
1976
|
-
telemetryClient.trackCliArgumentName(envName);
|
|
1977
|
-
telemetryClient.trackCliArgumentEnvironment(envTarget);
|
|
1978
|
-
telemetryClient.trackCliArgumentGitBranch(envGitBranch);
|
|
1979
|
-
telemetryClient.trackCliFlagYes(opts["--yes"]);
|
|
1980
|
-
telemetryClient.trackCliOptionProject(opts["--project"]);
|
|
1981
|
-
const link = await resolveProjectContext({
|
|
1982
|
-
client,
|
|
1983
|
-
projectNameOrId: opts["--project"]
|
|
1984
|
-
});
|
|
1985
|
-
if (link.status === "error") {
|
|
1986
|
-
return link.exitCode;
|
|
1987
|
-
} else if (link.status === "not_linked") {
|
|
1988
|
-
if (client.nonInteractive) {
|
|
1989
|
-
const preserved = getPreservedArgsForEnvRm(client.argv).filter(
|
|
1990
|
-
(a) => a !== "--yes" && a !== "-y"
|
|
1991
|
-
);
|
|
1992
|
-
const linkArgv = [
|
|
1993
|
-
...client.argv.slice(0, 2),
|
|
1994
|
-
"link",
|
|
1995
|
-
"--scope",
|
|
1996
|
-
"<scope>",
|
|
1997
|
-
...preserved
|
|
1998
|
-
];
|
|
1999
|
-
outputAgentError(
|
|
2000
|
-
client,
|
|
2001
|
-
{
|
|
2002
|
-
status: "error",
|
|
2003
|
-
reason: "not_linked",
|
|
2004
|
-
message: `Your codebase isn't linked to a project on Vercel. Run \`${getCommandNamePlain(
|
|
2005
|
-
"link"
|
|
2006
|
-
)}\` to begin. Use \`--yes\` for non-interactive; use \`--scope\` or \`--project\` to specify team or project.`,
|
|
2007
|
-
next: [
|
|
2008
|
-
{ command: buildCommandWithYes(linkArgv) },
|
|
2009
|
-
{ command: buildCommandWithYes(client.argv) }
|
|
2010
|
-
]
|
|
2011
|
-
},
|
|
2012
|
-
1
|
|
2013
|
-
);
|
|
2014
|
-
} else {
|
|
2015
|
-
output_manager_default.error(
|
|
2016
|
-
`Your codebase isn\u2019t linked to a project on Vercel. Run ${getCommandName(
|
|
2017
|
-
"link"
|
|
2018
|
-
)} to begin.`
|
|
2019
|
-
);
|
|
2020
|
-
}
|
|
2021
|
-
return 1;
|
|
2022
|
-
}
|
|
2023
|
-
client.config.currentTeam = link.org.type === "team" ? link.org.id : void 0;
|
|
2024
|
-
const { project } = link;
|
|
2025
|
-
if (!envName) {
|
|
2026
|
-
if (client.nonInteractive) {
|
|
2027
|
-
outputActionRequired(
|
|
2028
|
-
client,
|
|
2029
|
-
{
|
|
2030
|
-
status: "action_required",
|
|
2031
|
-
reason: "missing_name",
|
|
2032
|
-
message: "Provide the variable name as an argument. Example: `vercel env rm <name> --yes`",
|
|
2033
|
-
next: [
|
|
2034
|
-
{
|
|
2035
|
-
command: buildEnvRmCommandWithPreservedArgs(
|
|
2036
|
-
client.argv,
|
|
2037
|
-
`env rm <name> ${getEnvTargetPlaceholder()} --yes`
|
|
2038
|
-
)
|
|
2039
|
-
}
|
|
2040
|
-
]
|
|
2041
|
-
},
|
|
2042
|
-
1
|
|
2043
|
-
);
|
|
2044
|
-
}
|
|
2045
|
-
envName = await client.input.text({
|
|
2046
|
-
message: "What's the name of the variable?",
|
|
2047
|
-
validate: (val) => val ? true : "Name cannot be empty"
|
|
2048
|
-
});
|
|
2049
|
-
}
|
|
2050
|
-
const [result, customEnvironments] = await Promise.all([
|
|
2051
|
-
getEnvRecords(client, project.id, "vercel-cli:env:rm", {
|
|
2052
|
-
target: envTarget,
|
|
2053
|
-
gitBranch: envGitBranch
|
|
2054
|
-
}),
|
|
2055
|
-
getCustomEnvironments(client, project.id)
|
|
2056
|
-
]);
|
|
2057
|
-
let envs = result.envs.filter((env2) => env2.key === envName);
|
|
2058
|
-
if (envs.length === 0) {
|
|
2059
|
-
if (client.nonInteractive) {
|
|
2060
|
-
outputAgentError(
|
|
2061
|
-
client,
|
|
2062
|
-
{
|
|
2063
|
-
status: "error",
|
|
2064
|
-
reason: "env_not_found",
|
|
2065
|
-
message: `Environment Variable ${envName} was not found.`
|
|
2066
|
-
},
|
|
2067
|
-
1
|
|
2068
|
-
);
|
|
2069
|
-
}
|
|
2070
|
-
output_manager_default.error(`Environment Variable was not found.
|
|
2071
|
-
`);
|
|
2072
|
-
return 1;
|
|
2073
|
-
}
|
|
2074
|
-
while (envs.length > 1) {
|
|
2075
|
-
if (client.nonInteractive) {
|
|
2076
|
-
outputActionRequired(
|
|
2077
|
-
client,
|
|
2078
|
-
{
|
|
2079
|
-
status: "action_required",
|
|
2080
|
-
reason: "multiple_envs",
|
|
2081
|
-
message: `Multiple Environment Variables match ${envName}. Specify target and/or branch to remove one.`,
|
|
2082
|
-
next: [
|
|
2083
|
-
{
|
|
2084
|
-
command: buildEnvRmCommandWithPreservedArgs(
|
|
2085
|
-
client.argv,
|
|
2086
|
-
`env rm ${envName} ${getEnvTargetPlaceholder()} --yes`
|
|
2087
|
-
)
|
|
2088
|
-
}
|
|
2089
|
-
]
|
|
2090
|
-
},
|
|
2091
|
-
1
|
|
2092
|
-
);
|
|
2093
|
-
}
|
|
2094
|
-
const id = await client.input.select({
|
|
2095
|
-
message: `Remove ${envName} from which Environments?`,
|
|
2096
|
-
choices: envs.map((env2) => ({
|
|
2097
|
-
value: env2.id,
|
|
2098
|
-
name: formatEnvironments(link, env2, customEnvironments)
|
|
2099
|
-
}))
|
|
2100
|
-
});
|
|
2101
|
-
if (!id) {
|
|
2102
|
-
output_manager_default.error("Please select at least one Environment Variable to remove");
|
|
2103
|
-
}
|
|
2104
|
-
envs = envs.filter((env2) => env2.id === id);
|
|
2105
|
-
}
|
|
2106
|
-
const env = envs[0];
|
|
2107
|
-
const shouldWarnAboutRotation = shouldConfirmRotationBeforeDelete({
|
|
2108
|
-
key: env.key,
|
|
2109
|
-
type: env.type,
|
|
2110
|
-
hasPublicPrefix: getPublicPrefix(env.key) !== null
|
|
2111
|
-
});
|
|
2112
|
-
const rotationWarning = "Removing this variable from Vercel does not revoke the credential. Rotate or disable it at its provider.";
|
|
2113
|
-
if (shouldWarnAboutRotation) {
|
|
2114
|
-
printEnvRmWarning(rotationWarning);
|
|
2115
|
-
}
|
|
2116
|
-
const skipConfirmation = opts["--yes"];
|
|
2117
|
-
if (!skipConfirmation) {
|
|
2118
|
-
if (client.nonInteractive) {
|
|
2119
|
-
outputActionRequired(
|
|
2120
|
-
client,
|
|
2121
|
-
{
|
|
2122
|
-
status: "action_required",
|
|
2123
|
-
reason: "confirmation_required",
|
|
2124
|
-
message: `Removing Environment Variable ${env.key}. ${shouldWarnAboutRotation ? `${rotationWarning} ` : ""}Use --yes to confirm.`,
|
|
2125
|
-
next: [{ command: buildCommandWithYes(client.argv) }]
|
|
2126
|
-
},
|
|
2127
|
-
1
|
|
2128
|
-
);
|
|
2129
|
-
}
|
|
2130
|
-
if (!await client.input.confirm(
|
|
2131
|
-
`Remove ${param(env.key)} from ${formatEnvironments(
|
|
2132
|
-
link,
|
|
2133
|
-
env,
|
|
2134
|
-
customEnvironments
|
|
2135
|
-
)} in Project ${import_chalk3.default.bold(project.name)}?`,
|
|
2136
|
-
false
|
|
2137
|
-
)) {
|
|
2138
|
-
output_manager_default.log("Canceled");
|
|
2139
|
-
return 0;
|
|
2140
|
-
}
|
|
2141
|
-
}
|
|
2142
|
-
const rmStamp = stamp_default();
|
|
2143
|
-
try {
|
|
2144
|
-
output_manager_default.spinner("Removing");
|
|
2145
|
-
await removeEnvRecord(client, project.id, env);
|
|
2146
|
-
} catch (err) {
|
|
2147
|
-
if (client.nonInteractive && isAPIError(err)) {
|
|
2148
|
-
const reason = err.slug || (err.serverMessage?.toLowerCase().includes("branch") ? "branch_not_found" : "api_error");
|
|
2149
|
-
outputAgentError(
|
|
2150
|
-
client,
|
|
2151
|
-
{
|
|
2152
|
-
status: "error",
|
|
2153
|
-
reason,
|
|
2154
|
-
message: err.serverMessage
|
|
2155
|
-
},
|
|
2156
|
-
1
|
|
2157
|
-
);
|
|
2158
|
-
}
|
|
2159
|
-
if (isAPIError(err) && isKnownError(err)) {
|
|
2160
|
-
output_manager_default.error(err.serverMessage);
|
|
2161
|
-
return 1;
|
|
2162
|
-
}
|
|
2163
|
-
throw err;
|
|
2164
|
-
}
|
|
2165
|
-
output_manager_default.print(
|
|
2166
|
-
`${prependEmoji(
|
|
2167
|
-
`Removed Environment Variable ${import_chalk3.default.gray(rmStamp())}`,
|
|
2168
|
-
emoji("success")
|
|
2169
|
-
)}
|
|
2170
|
-
`
|
|
2171
|
-
);
|
|
2172
|
-
return 0;
|
|
2173
|
-
}
|
|
2174
|
-
|
|
2175
|
-
// src/commands/env/run.ts
|
|
2176
|
-
var import_env = __toESM(require_dist3(), 1);
|
|
2177
|
-
var import_chalk4 = __toESM(require_source(), 1);
|
|
2178
|
-
var import_execa = __toESM(require_execa(), 1);
|
|
2179
|
-
function printEnvRunWarning(message) {
|
|
2180
|
-
output_manager_default.print(`${import_chalk4.default.yellow("!")} ${message}
|
|
2181
|
-
`);
|
|
2182
|
-
}
|
|
2183
|
-
function omitUnavailableSecretPlaceholders(localEnv, secretKeys) {
|
|
2184
|
-
const safeLocalEnv = { ...localEnv };
|
|
2185
|
-
for (const key of secretKeys) {
|
|
2186
|
-
if (safeLocalEnv[key] === SENSITIVE_ENV_VALUE_PLACEHOLDER) {
|
|
2187
|
-
delete safeLocalEnv[key];
|
|
2188
|
-
}
|
|
2189
|
-
}
|
|
2190
|
-
return safeLocalEnv;
|
|
2191
|
-
}
|
|
2192
|
-
function parseRunArgs(argv) {
|
|
2193
|
-
const argvIndex = argv.indexOf("--");
|
|
2194
|
-
const hasDoubleDash = argvIndex !== -1;
|
|
2195
|
-
const vercelArgs = hasDoubleDash ? argv.slice(2, argvIndex) : argv.slice(2);
|
|
2196
|
-
const userCommand = hasDoubleDash ? argv.slice(argvIndex + 1) : [];
|
|
2197
|
-
return { vercelArgs, userCommand };
|
|
2198
|
-
}
|
|
2199
|
-
function needsHelpForRun(client) {
|
|
2200
|
-
const { vercelArgs } = parseRunArgs(client.argv);
|
|
2201
|
-
const flagsSpecification = getFlagsSpecification(runSubcommand.options);
|
|
2202
|
-
try {
|
|
2203
|
-
const parsedArgs = parseArguments(vercelArgs, flagsSpecification);
|
|
2204
|
-
return Boolean(parsedArgs.flags["--help"]);
|
|
2205
|
-
} catch {
|
|
2206
|
-
return false;
|
|
2207
|
-
}
|
|
2208
|
-
}
|
|
2209
|
-
async function run(client, telemetry) {
|
|
2210
|
-
const { vercelArgs, userCommand } = parseRunArgs(client.argv);
|
|
2211
|
-
let parsedArgs;
|
|
2212
|
-
const flagsSpecification = getFlagsSpecification(runSubcommand.options);
|
|
2213
|
-
try {
|
|
2214
|
-
parsedArgs = parseArguments(vercelArgs, flagsSpecification);
|
|
2215
|
-
} catch (error) {
|
|
2216
|
-
printError(error);
|
|
2217
|
-
return 1;
|
|
2218
|
-
}
|
|
2219
|
-
if (userCommand.length === 0) {
|
|
2220
|
-
outputActionRequired(
|
|
2221
|
-
client,
|
|
2222
|
-
{
|
|
2223
|
-
status: "action_required",
|
|
2224
|
-
reason: "missing_command",
|
|
2225
|
-
message: "No command provided. Use `--` to separate Vercel flags from your command.",
|
|
2226
|
-
next: [{ command: getCommandNamePlain("env run -- <command>") }]
|
|
2227
|
-
},
|
|
2228
|
-
1
|
|
2229
|
-
);
|
|
2230
|
-
output_manager_default.error(
|
|
2231
|
-
`No command provided. Use \`--\` to separate vercel flags from your command.`
|
|
2232
|
-
);
|
|
2233
|
-
return 1;
|
|
2234
|
-
}
|
|
2235
|
-
const projectName = parsedArgs.flags["--project"];
|
|
2236
|
-
telemetry.trackCliOptionProject(projectName);
|
|
2237
|
-
const link = await resolveProjectContext({
|
|
2238
|
-
client,
|
|
2239
|
-
projectNameOrId: projectName
|
|
2240
|
-
});
|
|
2241
|
-
if (link.status === "error") {
|
|
2242
|
-
return link.exitCode;
|
|
2243
|
-
} else if (link.status === "not_linked") {
|
|
2244
|
-
outputActionRequired(
|
|
2245
|
-
client,
|
|
2246
|
-
{
|
|
2247
|
-
status: "action_required",
|
|
2248
|
-
reason: "not_linked",
|
|
2249
|
-
message: "Your codebase isn't linked to a project on Vercel. Run `vercel link`, then retry this command.",
|
|
2250
|
-
next: [{ command: getCommandNamePlain("link") }]
|
|
2251
|
-
},
|
|
2252
|
-
1
|
|
2253
|
-
);
|
|
2254
|
-
output_manager_default.error(
|
|
2255
|
-
`Your codebase isn't linked to a project on Vercel. Run ${getCommandName(
|
|
2256
|
-
"link"
|
|
2257
|
-
)} to begin.`
|
|
2258
|
-
);
|
|
2259
|
-
return 1;
|
|
2260
|
-
}
|
|
2261
|
-
client.config.currentTeam = link.org.type === "team" ? link.org.id : void 0;
|
|
2262
|
-
const environment = parseTarget({
|
|
2263
|
-
flagName: "environment",
|
|
2264
|
-
flags: parsedArgs.flags
|
|
2265
|
-
}) || "development";
|
|
2266
|
-
const gitBranch = parsedArgs.flags["--git-branch"];
|
|
2267
|
-
output_manager_default.spinner(`Downloading \`${environment}\` environment variables`);
|
|
2268
|
-
const records = await pullEnvRecords(
|
|
2269
|
-
client,
|
|
2270
|
-
link.project.id,
|
|
2271
|
-
"vercel-cli:env:run",
|
|
2272
|
-
{
|
|
2273
|
-
target: environment,
|
|
2274
|
-
gitBranch
|
|
2275
|
-
}
|
|
2276
|
-
);
|
|
2277
|
-
output_manager_default.stopSpinner();
|
|
2278
|
-
output_manager_default.debug(
|
|
2279
|
-
`Running command with ${Object.keys(records.env).length} environment variables`
|
|
2280
|
-
);
|
|
2281
|
-
let localEnv = {};
|
|
2282
|
-
try {
|
|
2283
|
-
localEnv = (0, import_env.loadEnvConfig)(client.cwd, true).combinedEnv;
|
|
2284
|
-
} catch (err) {
|
|
2285
|
-
output_manager_default.debug(`Failed to load local env files: ${err}`);
|
|
2286
|
-
}
|
|
2287
|
-
const localPlaceholderKeys = Object.entries(localEnv).filter(([, value]) => value === SENSITIVE_ENV_VALUE_PLACEHOLDER).map(([key]) => key);
|
|
2288
|
-
const safeLocalEnv = omitUnavailableSecretPlaceholders(
|
|
2289
|
-
localEnv,
|
|
2290
|
-
localPlaceholderKeys
|
|
2291
|
-
);
|
|
2292
|
-
const processPlaceholderKeys = Object.keys(records.env).filter(
|
|
2293
|
-
(key) => process.env[key] === SENSITIVE_ENV_VALUE_PLACEHOLDER
|
|
2294
|
-
);
|
|
2295
|
-
const safeProcessEnv = omitUnavailableSecretPlaceholders(
|
|
2296
|
-
process.env,
|
|
2297
|
-
processPlaceholderKeys
|
|
2298
|
-
);
|
|
2299
|
-
const unavailableCandidateKeys = new Set(
|
|
2300
|
-
Object.entries(records.env).filter(
|
|
2301
|
-
([key, value]) => !value && !safeLocalEnv[key] && !safeProcessEnv[key]
|
|
2302
|
-
).map(([key]) => key)
|
|
2303
|
-
);
|
|
2304
|
-
if (unavailableCandidateKeys.size > 0) {
|
|
2305
|
-
try {
|
|
2306
|
-
const { envs } = await getEnvRecords(
|
|
2307
|
-
client,
|
|
2308
|
-
link.project.id,
|
|
2309
|
-
"vercel-cli:env:run",
|
|
2310
|
-
{ target: environment, gitBranch }
|
|
2311
|
-
);
|
|
2312
|
-
const unavailableSecretKeys = envs.filter(
|
|
2313
|
-
(env) => isSecretEnvVar(env) && unavailableCandidateKeys.has(env.key)
|
|
2314
|
-
);
|
|
2315
|
-
if (unavailableSecretKeys.length > 0) {
|
|
2316
|
-
printEnvRunWarning(
|
|
2317
|
-
`${getUnavailableSecretValuesMessage(
|
|
2318
|
-
environment,
|
|
2319
|
-
unavailableSecretKeys.length
|
|
2320
|
-
)}${getLocalSecretFallbackMessage(unavailableSecretKeys.length)}`
|
|
2321
|
-
);
|
|
2322
|
-
}
|
|
2323
|
-
} catch {
|
|
2324
|
-
}
|
|
2325
|
-
}
|
|
2326
|
-
try {
|
|
2327
|
-
const result = await (0, import_execa.default)(userCommand[0], userCommand.slice(1), {
|
|
2328
|
-
cwd: client.cwd,
|
|
2329
|
-
stdio: "inherit",
|
|
2330
|
-
reject: false,
|
|
2331
|
-
env: {
|
|
2332
|
-
...records.env,
|
|
2333
|
-
...safeLocalEnv,
|
|
2334
|
-
...safeProcessEnv
|
|
2335
|
-
}
|
|
2336
|
-
});
|
|
2337
|
-
if (result instanceof Error && typeof result.exitCode !== "number") {
|
|
2338
|
-
output_manager_default.prettyError(result);
|
|
2339
|
-
return 1;
|
|
2340
|
-
}
|
|
2341
|
-
return result.exitCode;
|
|
2342
|
-
} catch (err) {
|
|
2343
|
-
output_manager_default.prettyError(err);
|
|
2344
|
-
return 1;
|
|
2345
|
-
}
|
|
2346
|
-
}
|
|
2347
|
-
|
|
2348
|
-
// src/commands/env/update.ts
|
|
2349
|
-
var import_chalk5 = __toESM(require_source(), 1);
|
|
2350
|
-
|
|
2351
|
-
// src/util/env/update-env-record.ts
|
|
2352
|
-
var import_constants3 = __toESM(require_dist2(), 1);
|
|
2353
|
-
async function updateEnvRecord(client, projectId, envId, type, key, value, targets, gitBranch, visibility) {
|
|
2354
|
-
output_manager_default.debug(
|
|
2355
|
-
`Updating ${type} Environment Variable ${key} in ${targets.length} targets`
|
|
2356
|
-
);
|
|
2357
|
-
const target = [];
|
|
2358
|
-
const customEnvironmentIds = [];
|
|
2359
|
-
for (const t of targets) {
|
|
2360
|
-
const arr = import_constants3.PROJECT_ENV_TARGET.includes(t) ? target : customEnvironmentIds;
|
|
2361
|
-
arr.push(t);
|
|
2362
|
-
}
|
|
2363
|
-
const body = {
|
|
2364
|
-
type,
|
|
2365
|
-
value,
|
|
2366
|
-
target,
|
|
2367
|
-
customEnvironmentIds: customEnvironmentIds.length > 0 ? customEnvironmentIds : void 0,
|
|
2368
|
-
gitBranch: gitBranch || void 0,
|
|
2369
|
-
...visibility !== void 0 ? { visibility } : {}
|
|
2370
|
-
};
|
|
2371
|
-
if (key) {
|
|
2372
|
-
body.key = key;
|
|
2373
|
-
}
|
|
2374
|
-
const url = `/v10/projects/${projectId}/env/${envId}`;
|
|
2375
|
-
await client.fetch(url, {
|
|
2376
|
-
method: "PATCH",
|
|
2377
|
-
body
|
|
2378
|
-
});
|
|
2379
|
-
}
|
|
2380
|
-
|
|
2381
|
-
// src/util/telemetry/commands/env/update.ts
|
|
2382
|
-
var EnvUpdateTelemetryClient = class extends TelemetryClient {
|
|
2383
|
-
trackCliArgumentName(name) {
|
|
2384
|
-
if (name) {
|
|
2385
|
-
this.trackCliArgument({
|
|
2386
|
-
arg: "name",
|
|
2387
|
-
value: this.redactedValue
|
|
2388
|
-
});
|
|
2389
|
-
}
|
|
2390
|
-
}
|
|
2391
|
-
trackCliArgumentEnvironment(environment) {
|
|
2392
|
-
if (environment) {
|
|
2393
|
-
this.trackCliArgument({
|
|
2394
|
-
arg: "environment",
|
|
2395
|
-
value: STANDARD_ENVIRONMENTS.includes(
|
|
2396
|
-
environment
|
|
2397
|
-
) ? environment : this.redactedValue
|
|
2398
|
-
});
|
|
2399
|
-
}
|
|
2400
|
-
}
|
|
2401
|
-
trackCliArgumentGitBranch(gitBranch) {
|
|
2402
|
-
if (gitBranch) {
|
|
2403
|
-
this.trackCliArgument({
|
|
2404
|
-
arg: "git-branch",
|
|
2405
|
-
value: this.redactedValue
|
|
2406
|
-
});
|
|
2407
|
-
}
|
|
2408
|
-
}
|
|
2409
|
-
trackCliFlagSensitive(sensitive) {
|
|
2410
|
-
if (sensitive) {
|
|
2411
|
-
this.trackCliFlag("sensitive");
|
|
2412
|
-
}
|
|
2413
|
-
}
|
|
2414
|
-
trackCliFlagYes(yes) {
|
|
2415
|
-
if (yes) {
|
|
2416
|
-
this.trackCliFlag("yes");
|
|
2417
|
-
}
|
|
2418
|
-
}
|
|
2419
|
-
trackCliOptionValue(value) {
|
|
2420
|
-
if (value) {
|
|
2421
|
-
this.trackCliOption({
|
|
2422
|
-
option: "value",
|
|
2423
|
-
value: this.redactedValue
|
|
2424
|
-
});
|
|
2425
|
-
}
|
|
2426
|
-
}
|
|
2427
|
-
trackCliOptionVisibility(visibility) {
|
|
2428
|
-
if (visibility) {
|
|
2429
|
-
const validVisibilities = ["config", "secret"];
|
|
2430
|
-
this.trackCliOption({
|
|
2431
|
-
option: "visibility",
|
|
2432
|
-
value: validVisibilities.includes(visibility) ? visibility : this.redactedValue
|
|
2433
|
-
});
|
|
2434
|
-
}
|
|
2435
|
-
}
|
|
2436
|
-
trackCliOptionType(type) {
|
|
2437
|
-
if (type) {
|
|
2438
|
-
const validTypes = ["config", "secret"];
|
|
2439
|
-
this.trackCliOption({
|
|
2440
|
-
option: "type",
|
|
2441
|
-
value: validTypes.includes(type) ? type : this.redactedValue
|
|
2442
|
-
});
|
|
2443
|
-
}
|
|
2444
|
-
}
|
|
2445
|
-
};
|
|
2446
|
-
|
|
2447
|
-
// src/commands/env/update.ts
|
|
2448
|
-
function looksLikeCredentialName2(key, publicPrefix = getPublicPrefix(key)) {
|
|
2449
|
-
return looksLikeSecret(publicPrefix ? key.slice(publicPrefix.length) : key);
|
|
2450
|
-
}
|
|
2451
|
-
function printEnvUpdateWarning(message) {
|
|
2452
|
-
output_manager_default.print(`${import_chalk5.default.yellow("!")} ${message}
|
|
2453
|
-
`);
|
|
2454
|
-
}
|
|
2455
|
-
function omitEnvValueArgs(argv) {
|
|
2456
|
-
const out = [];
|
|
2457
|
-
for (let i = 0; i < argv.length; i++) {
|
|
2458
|
-
if (argv[i] === "--value") {
|
|
2459
|
-
i++;
|
|
2460
|
-
continue;
|
|
2461
|
-
}
|
|
2462
|
-
if (argv[i].startsWith("--value="))
|
|
2463
|
-
continue;
|
|
2464
|
-
out.push(argv[i]);
|
|
2465
|
-
}
|
|
2466
|
-
return out;
|
|
2467
|
-
}
|
|
2468
|
-
function formatTargetArg(targets, customEnvironments) {
|
|
2469
|
-
return targets.map(
|
|
2470
|
-
(target) => customEnvironments.find(
|
|
2471
|
-
(environment) => environment.id === target || environment.slug === target
|
|
2472
|
-
)?.slug ?? target
|
|
2473
|
-
).join(",");
|
|
2474
|
-
}
|
|
2475
|
-
function promptEnvUpdateValue(client, envName, isSecret) {
|
|
2476
|
-
return client.input.text({
|
|
2477
|
-
message: `What's the new value of ${envName}?`,
|
|
2478
|
-
...isSecret ? { transformer: (value) => "*".repeat(value.length) } : {}
|
|
2479
|
-
});
|
|
2480
|
-
}
|
|
2481
|
-
async function update(client, argv) {
|
|
2482
|
-
let parsedArgs;
|
|
2483
|
-
const flagsSpecification = getFlagsSpecification(updateSubcommand.options);
|
|
2484
|
-
try {
|
|
2485
|
-
parsedArgs = parseArguments(argv, flagsSpecification);
|
|
2486
|
-
} catch (err) {
|
|
2487
|
-
if (client.nonInteractive) {
|
|
2488
|
-
outputAgentError(
|
|
2489
|
-
client,
|
|
2490
|
-
{
|
|
2491
|
-
status: "error",
|
|
2492
|
-
reason: "invalid_arguments",
|
|
2493
|
-
message: err instanceof Error ? err.message : String(err)
|
|
2494
|
-
},
|
|
2495
|
-
1
|
|
2496
|
-
);
|
|
2497
|
-
}
|
|
2498
|
-
printError(err);
|
|
2499
|
-
return 1;
|
|
2500
|
-
}
|
|
2501
|
-
const { args, flags: opts } = parsedArgs;
|
|
2502
|
-
const valueFromFlag = typeof opts["--value"] === "string" ? opts["--value"] : void 0;
|
|
2503
|
-
const stdInput = await readStandardInput(client.stdin);
|
|
2504
|
-
let [envName, envTargetArg, envGitBranch] = args;
|
|
2505
|
-
const typeOption = resolveEnvVarTypeOption({
|
|
2506
|
-
type: typeof opts["--type"] === "string" ? opts["--type"] : void 0,
|
|
2507
|
-
visibility: typeof opts["--visibility"] === "string" ? opts["--visibility"] : void 0
|
|
2508
|
-
});
|
|
2509
|
-
let explicitType = typeOption.explicitVisibility;
|
|
2510
|
-
const typeWasExplicit = explicitType !== void 0 || Boolean(opts["--sensitive"]);
|
|
2511
|
-
const telemetryClient = new EnvUpdateTelemetryClient({
|
|
2512
|
-
opts: {
|
|
2513
|
-
store: client.telemetryEventStore
|
|
2514
|
-
}
|
|
2515
|
-
});
|
|
2516
|
-
telemetryClient.trackCliArgumentName(envName);
|
|
2517
|
-
telemetryClient.trackCliArgumentEnvironment(envTargetArg);
|
|
2518
|
-
telemetryClient.trackCliArgumentGitBranch(envGitBranch);
|
|
2519
|
-
telemetryClient.trackCliFlagSensitive(opts["--sensitive"]);
|
|
2520
|
-
telemetryClient.trackCliFlagYes(opts["--yes"]);
|
|
2521
|
-
telemetryClient.trackCliOptionValue(
|
|
2522
|
-
valueFromFlag === void 0 ? void 0 : "<redacted>"
|
|
2523
|
-
);
|
|
2524
|
-
telemetryClient.trackCliOptionType(
|
|
2525
|
-
typeof opts["--type"] === "string" ? opts["--type"] : void 0
|
|
2526
|
-
);
|
|
2527
|
-
telemetryClient.trackCliOptionVisibility(
|
|
2528
|
-
typeof opts["--visibility"] === "string" ? opts["--visibility"] : void 0
|
|
2529
|
-
);
|
|
2530
|
-
if (typeOption.error) {
|
|
2531
|
-
if (client.nonInteractive) {
|
|
2532
|
-
outputAgentError(
|
|
2533
|
-
client,
|
|
2534
|
-
{
|
|
2535
|
-
status: "error",
|
|
2536
|
-
reason: typeOption.errorReason ?? "invalid_type",
|
|
2537
|
-
message: typeOption.error
|
|
2538
|
-
},
|
|
2539
|
-
1
|
|
2540
|
-
);
|
|
2541
|
-
}
|
|
2542
|
-
output_manager_default.fatal(typeOption.error);
|
|
2543
|
-
return 1;
|
|
2544
|
-
}
|
|
2545
|
-
if (typeOption.usedDeprecatedVisibility) {
|
|
2546
|
-
printEnvUpdateWarning(ENV_VISIBILITY_DEPRECATION_MESSAGE);
|
|
2547
|
-
}
|
|
2548
|
-
if (explicitType === "config" && opts["--sensitive"]) {
|
|
2549
|
-
const message = "`--type config` cannot be used with `--sensitive`. Pick one.";
|
|
2550
|
-
if (client.nonInteractive) {
|
|
2551
|
-
outputAgentError(
|
|
2552
|
-
client,
|
|
2553
|
-
{
|
|
2554
|
-
status: "error",
|
|
2555
|
-
reason: "conflicting_type_flags",
|
|
2556
|
-
message
|
|
2557
|
-
},
|
|
2558
|
-
1
|
|
2559
|
-
);
|
|
2560
|
-
}
|
|
2561
|
-
output_manager_default.fatal(message);
|
|
2562
|
-
return 1;
|
|
2563
|
-
}
|
|
2564
|
-
if (args.length > 3) {
|
|
2565
|
-
if (client.nonInteractive) {
|
|
2566
|
-
outputAgentError(
|
|
2567
|
-
client,
|
|
2568
|
-
{
|
|
2569
|
-
status: "error",
|
|
2570
|
-
reason: "invalid_arguments",
|
|
2571
|
-
message: `Invalid number of arguments. Usage: \`${getCommandNamePlain(
|
|
2572
|
-
`env update <name> ${getEnvTargetPlaceholder()} <gitbranch>`
|
|
2573
|
-
)}\``
|
|
2574
|
-
},
|
|
2575
|
-
1
|
|
2576
|
-
);
|
|
2577
|
-
}
|
|
2578
|
-
output_manager_default.error(
|
|
2579
|
-
`Invalid number of arguments. Usage: ${getCommandName(
|
|
2580
|
-
`env update <name> ${getEnvTargetPlaceholder()} <gitbranch>`
|
|
2581
|
-
)}`
|
|
2582
|
-
);
|
|
2583
|
-
return 1;
|
|
2584
|
-
}
|
|
2585
|
-
if (stdInput && (!envName || !envTargetArg)) {
|
|
2586
|
-
output_manager_default.error(
|
|
2587
|
-
`Invalid number of arguments. Usage: ${getCommandName(
|
|
2588
|
-
`env update <name> <target> <gitbranch> < <file>`
|
|
2589
|
-
)}`
|
|
2590
|
-
);
|
|
2591
|
-
return 1;
|
|
2592
|
-
}
|
|
2593
|
-
if (client.nonInteractive) {
|
|
2594
|
-
const missing = [];
|
|
2595
|
-
if (!envName)
|
|
2596
|
-
missing.push("missing_name");
|
|
2597
|
-
if (!stdInput && valueFromFlag === void 0)
|
|
2598
|
-
missing.push("missing_value");
|
|
2599
|
-
if (missing.length > 0) {
|
|
2600
|
-
const parts = missing.map(
|
|
2601
|
-
(m) => m === "missing_name" ? "name" : "--value or stdin"
|
|
2602
|
-
);
|
|
2603
|
-
const targetPart = envTargetArg || getEnvTargetPlaceholder();
|
|
2604
|
-
const branchPart = envTargetArg === "preview" || envTargetArg === "development" ? " <gitbranch>" : "";
|
|
2605
|
-
const template = `env update ${envName || "<name>"} ${targetPart}${branchPart} --value <value> --yes`;
|
|
2606
|
-
outputActionRequired(
|
|
2607
|
-
client,
|
|
2608
|
-
{
|
|
2609
|
-
status: "action_required",
|
|
2610
|
-
reason: "missing_requirements",
|
|
2611
|
-
missing,
|
|
2612
|
-
message: `Provide all required inputs for non-interactive mode: ${parts.join("; ")}. Example: ${getCommandNamePlain(template)}`,
|
|
2613
|
-
next: [
|
|
2614
|
-
{
|
|
2615
|
-
command: buildEnvUpdateCommandWithPreservedArgs(
|
|
2616
|
-
client.argv,
|
|
2617
|
-
template
|
|
2618
|
-
)
|
|
2619
|
-
}
|
|
2620
|
-
]
|
|
2621
|
-
},
|
|
2622
|
-
1
|
|
2623
|
-
);
|
|
2624
|
-
}
|
|
2625
|
-
}
|
|
2626
|
-
const envTargets = [];
|
|
2627
|
-
if (envTargetArg) {
|
|
2628
|
-
envTargets.push(envTargetArg);
|
|
2629
|
-
}
|
|
2630
|
-
if (!envName) {
|
|
2631
|
-
if (client.nonInteractive) {
|
|
2632
|
-
outputActionRequired(
|
|
2633
|
-
client,
|
|
2634
|
-
{
|
|
2635
|
-
status: "action_required",
|
|
2636
|
-
reason: "missing_name",
|
|
2637
|
-
message: "Provide the variable name as an argument. Example: vercel env update <name>",
|
|
2638
|
-
next: [
|
|
2639
|
-
{
|
|
2640
|
-
command: buildEnvUpdateCommandWithPreservedArgs(
|
|
2641
|
-
client.argv,
|
|
2642
|
-
`env update <name> ${getEnvTargetPlaceholder()} --value <value> --yes`
|
|
2643
|
-
)
|
|
2644
|
-
}
|
|
2645
|
-
]
|
|
2646
|
-
},
|
|
2647
|
-
1
|
|
2648
|
-
);
|
|
2649
|
-
} else {
|
|
2650
|
-
envName = await client.input.text({
|
|
2651
|
-
message: `What's the name of the variable to update?`,
|
|
2652
|
-
validate: (val) => val ? true : "Name cannot be empty"
|
|
2653
|
-
});
|
|
2654
|
-
}
|
|
2655
|
-
}
|
|
2656
|
-
telemetryClient.trackCliOptionProject(opts["--project"]);
|
|
2657
|
-
const link = await resolveProjectContext({
|
|
2658
|
-
client,
|
|
2659
|
-
projectNameOrId: opts["--project"]
|
|
2660
|
-
});
|
|
2661
|
-
if (link.status === "error") {
|
|
2662
|
-
return link.exitCode;
|
|
2663
|
-
} else if (link.status === "not_linked") {
|
|
2664
|
-
if (client.nonInteractive) {
|
|
2665
|
-
const preserved = omitEnvValueArgs(
|
|
2666
|
-
getPreservedArgsForEnvUpdate(client.argv)
|
|
2667
|
-
).filter((a) => a !== "--yes" && a !== "-y");
|
|
2668
|
-
const linkArgv = [
|
|
2669
|
-
...client.argv.slice(0, 2),
|
|
2670
|
-
"link",
|
|
2671
|
-
"--scope",
|
|
2672
|
-
"<scope>",
|
|
2673
|
-
...preserved
|
|
2674
|
-
];
|
|
2675
|
-
outputAgentError(
|
|
2676
|
-
client,
|
|
2677
|
-
{
|
|
2678
|
-
status: "error",
|
|
2679
|
-
reason: "not_linked",
|
|
2680
|
-
message: `Your codebase isn't linked to a project on Vercel. Run ${getCommandNamePlain(
|
|
2681
|
-
"link"
|
|
2682
|
-
)} to begin. Use --yes for non-interactive; use --scope or --project to specify team or project.`,
|
|
2683
|
-
next: [
|
|
2684
|
-
{ command: buildCommandWithYes(linkArgv) },
|
|
2685
|
-
{
|
|
2686
|
-
command: buildCommandWithYes(redactEnvValueArgs(client.argv))
|
|
2687
|
-
}
|
|
2688
|
-
]
|
|
2689
|
-
},
|
|
2690
|
-
1
|
|
2691
|
-
);
|
|
2692
|
-
}
|
|
2693
|
-
output_manager_default.error(
|
|
2694
|
-
`Your codebase isn't linked to a project on Vercel. Run ${getCommandName(
|
|
2695
|
-
"link"
|
|
2696
|
-
)} to begin.`
|
|
2697
|
-
);
|
|
2698
|
-
return 1;
|
|
2699
|
-
}
|
|
2700
|
-
client.config.currentTeam = link.org.type === "team" ? link.org.id : void 0;
|
|
2701
|
-
const { project } = link;
|
|
2702
|
-
const [{ envs }, customEnvironments] = await Promise.all([
|
|
2703
|
-
getEnvRecords(client, project.id, "vercel-cli:env:update"),
|
|
2704
|
-
getCustomEnvironments(client, project.id)
|
|
2705
|
-
]);
|
|
2706
|
-
const customEnvironment = customEnvironments.find(
|
|
2707
|
-
({ slug, id }) => slug === envTargetArg || id === envTargetArg
|
|
2708
|
-
);
|
|
2709
|
-
const normalizedEnvTargetArg = customEnvironment?.id || envTargetArg;
|
|
2710
|
-
const matchingEnvs = envs.filter((r) => r.key === envName);
|
|
2711
|
-
if (matchingEnvs.length === 0) {
|
|
2712
|
-
const listFlags = getGlobalFlagsFromArgs(client.argv.slice(2), {
|
|
2713
|
-
preserveProject: true
|
|
2714
|
-
});
|
|
2715
|
-
const listArgs = `env ls ${listFlags.join(" ")}`.trim();
|
|
2716
|
-
if (client.nonInteractive) {
|
|
2717
|
-
outputAgentError(
|
|
2718
|
-
client,
|
|
2719
|
-
{
|
|
2720
|
-
status: "error",
|
|
2721
|
-
reason: "env_not_found",
|
|
2722
|
-
message: `The variable ${envName} was not found. Run ${getCommandNamePlain(listArgs)} to see all available Environment Variables.`
|
|
2723
|
-
},
|
|
2724
|
-
1
|
|
2725
|
-
);
|
|
2726
|
-
}
|
|
2727
|
-
output_manager_default.error(
|
|
2728
|
-
`The variable ${param(envName)} was not found. Run ${getCommandName(listArgs)} to see all available Environment Variables.`
|
|
2729
|
-
);
|
|
2730
|
-
return 1;
|
|
2731
|
-
}
|
|
2732
|
-
let selectedEnv;
|
|
2733
|
-
if (envTargetArg || envGitBranch) {
|
|
2734
|
-
const filteredEnvs = matchingEnvs.filter((env) => {
|
|
2735
|
-
const matchesTarget = !normalizedEnvTargetArg || (Array.isArray(env.target) ? env.target.includes(normalizedEnvTargetArg) : env.target === normalizedEnvTargetArg) || env.customEnvironmentIds && env.customEnvironmentIds.includes(normalizedEnvTargetArg);
|
|
2736
|
-
const matchesGitBranch = !envGitBranch || env.gitBranch === envGitBranch;
|
|
2737
|
-
return matchesTarget && matchesGitBranch;
|
|
2738
|
-
});
|
|
2739
|
-
if (filteredEnvs.length === 0) {
|
|
2740
|
-
if (client.nonInteractive) {
|
|
2741
|
-
outputAgentError(
|
|
2742
|
-
client,
|
|
2743
|
-
{
|
|
2744
|
-
status: "error",
|
|
2745
|
-
reason: "env_not_found",
|
|
2746
|
-
message: `No Environment Variable ${envName} found matching the specified target/branch.`
|
|
2747
|
-
},
|
|
2748
|
-
1
|
|
2749
|
-
);
|
|
2750
|
-
}
|
|
2751
|
-
output_manager_default.error(
|
|
2752
|
-
`No Environment Variable ${param(envName)} found matching the specified criteria.`
|
|
2753
|
-
);
|
|
2754
|
-
return 1;
|
|
2755
|
-
}
|
|
2756
|
-
if (filteredEnvs.length === 1) {
|
|
2757
|
-
selectedEnv = filteredEnvs[0];
|
|
2758
|
-
} else {
|
|
2759
|
-
if (client.nonInteractive) {
|
|
2760
|
-
outputActionRequired(
|
|
2761
|
-
client,
|
|
2762
|
-
{
|
|
2763
|
-
status: "action_required",
|
|
2764
|
-
reason: "multiple_envs",
|
|
2765
|
-
message: `Multiple Environment Variables match ${envName}. Specify target and/or branch to update one.`,
|
|
2766
|
-
next: [
|
|
2767
|
-
{
|
|
2768
|
-
command: buildEnvUpdateCommandWithPreservedArgs(
|
|
2769
|
-
client.argv,
|
|
2770
|
-
`env update ${envName} ${getEnvTargetPlaceholder()} <gitbranch> --value "<value>" --yes`
|
|
2771
|
-
)
|
|
2772
|
-
}
|
|
2773
|
-
]
|
|
2774
|
-
},
|
|
2775
|
-
1
|
|
2776
|
-
);
|
|
2777
|
-
}
|
|
2778
|
-
const choices = filteredEnvs.map((env, index) => {
|
|
2779
|
-
const targets2 = formatEnvironments(link, env, customEnvironments);
|
|
2780
|
-
return {
|
|
2781
|
-
name: targets2,
|
|
2782
|
-
value: index
|
|
2783
|
-
};
|
|
2784
|
-
});
|
|
2785
|
-
const selectedIndex = await client.input.select({
|
|
2786
|
-
message: `Multiple Environment Variables found for ${param(envName)}. Which one do you want to update?`,
|
|
2787
|
-
choices
|
|
2788
|
-
});
|
|
2789
|
-
selectedEnv = filteredEnvs[selectedIndex];
|
|
2790
|
-
}
|
|
2791
|
-
} else if (matchingEnvs.length === 1) {
|
|
2792
|
-
selectedEnv = matchingEnvs[0];
|
|
2793
|
-
} else {
|
|
2794
|
-
if (client.nonInteractive) {
|
|
2795
|
-
outputActionRequired(
|
|
2796
|
-
client,
|
|
2797
|
-
{
|
|
2798
|
-
status: "action_required",
|
|
2799
|
-
reason: "multiple_envs",
|
|
2800
|
-
message: `Multiple Environment Variables match ${envName}. Specify target and/or branch to update one.`,
|
|
2801
|
-
next: [
|
|
2802
|
-
{
|
|
2803
|
-
command: buildEnvUpdateCommandWithPreservedArgs(
|
|
2804
|
-
client.argv,
|
|
2805
|
-
`env update ${envName} ${getEnvTargetPlaceholder()} <gitbranch> --value "<value>" --yes`
|
|
2806
|
-
)
|
|
2807
|
-
}
|
|
2808
|
-
]
|
|
2809
|
-
},
|
|
2810
|
-
1
|
|
2811
|
-
);
|
|
2812
|
-
}
|
|
2813
|
-
const choices = matchingEnvs.map((env, index) => {
|
|
2814
|
-
const targets2 = formatEnvironments(link, env, customEnvironments);
|
|
2815
|
-
return {
|
|
2816
|
-
name: targets2,
|
|
2817
|
-
value: index
|
|
2818
|
-
};
|
|
2819
|
-
});
|
|
2820
|
-
const selectedIndex = await client.input.select({
|
|
2821
|
-
message: `Multiple Environment Variables found for ${param(envName)}. Which one do you want to update?`,
|
|
2822
|
-
choices
|
|
2823
|
-
});
|
|
2824
|
-
selectedEnv = matchingEnvs[selectedIndex];
|
|
2825
|
-
}
|
|
2826
|
-
let customSveltePublicPrefix;
|
|
2827
|
-
const apiPublicPrefix = getApiPublicPrefix(envName);
|
|
2828
|
-
const frameworkPublicPrefix = getFrameworkPublicPrefix(
|
|
2829
|
-
project.framework,
|
|
2830
|
-
envName
|
|
2831
|
-
);
|
|
2832
|
-
if (project.framework === "sveltekit" || project.framework === "sveltekit-1" || project.framework === "sveltekit-2") {
|
|
2833
|
-
const localPublicPrefixes = await getLocalSvelteKitPublicPrefixes(
|
|
2834
|
-
link.repoRoot ?? client.cwd,
|
|
2835
|
-
project.rootDirectory
|
|
2836
|
-
);
|
|
2837
|
-
const matchingLocalPrefix = localPublicPrefixes?.find(
|
|
2838
|
-
(prefix) => envName.startsWith(prefix)
|
|
2839
|
-
);
|
|
2840
|
-
if (matchingLocalPrefix !== void 0 && apiPublicPrefix === null && frameworkPublicPrefix === null) {
|
|
2841
|
-
customSveltePublicPrefix = matchingLocalPrefix;
|
|
2842
|
-
}
|
|
2843
|
-
}
|
|
2844
|
-
const targets = Array.isArray(selectedEnv.target) ? selectedEnv.target : [selectedEnv.target].filter(
|
|
2845
|
-
(r) => Boolean(r)
|
|
2846
|
-
);
|
|
2847
|
-
const allTargets = [...targets, ...selectedEnv.customEnvironmentIds || []];
|
|
2848
|
-
const selectedEnvIsSecret = isSecretEnvVar(selectedEnv);
|
|
2849
|
-
if (explicitType === "config" && selectedEnvIsSecret) {
|
|
2850
|
-
const removeTargetArg = envTargetArg || targets[0] || allTargets[0] || getEnvTargetPlaceholder();
|
|
2851
|
-
const addTargetArg = formatTargetArg(allTargets, customEnvironments) || removeTargetArg;
|
|
2852
|
-
const removeBranchArg = selectedEnv.gitBranch ? ` ${quoteArg(selectedEnv.gitBranch)}` : "";
|
|
2853
|
-
const addBranchArg = selectedEnv.gitBranch ? ` --git-branch ${quoteArg(selectedEnv.gitBranch)}` : "";
|
|
2854
|
-
const globalFlags = getGlobalFlagsFromArgs(client.argv.slice(2), {
|
|
2855
|
-
preserveProject: true
|
|
2856
|
-
});
|
|
2857
|
-
const humanGlobalFlags = globalFlags.filter(
|
|
2858
|
-
(flag) => !flag.startsWith("--non-interactive")
|
|
2859
|
-
);
|
|
2860
|
-
const globalSuffix = globalFlags.length > 0 ? ` ${globalFlags.map(quoteArg).join(" ")}` : "";
|
|
2861
|
-
const humanGlobalSuffix = humanGlobalFlags.length > 0 ? ` ${humanGlobalFlags.map(quoteArg).join(" ")}` : "";
|
|
2862
|
-
const removeCommand = getCommandNamePlain(
|
|
2863
|
-
`env rm ${envName} ${removeTargetArg}${removeBranchArg} --yes${globalSuffix}`
|
|
2864
|
-
);
|
|
2865
|
-
const addCommand = getCommandNamePlain(
|
|
2866
|
-
`env add ${envName} ${addTargetArg}${addBranchArg} --type config --value "<value>" --yes${globalSuffix}`
|
|
2867
|
-
);
|
|
2868
|
-
const removeHumanCommand = getCommandNamePlain(
|
|
2869
|
-
`env rm ${envName} ${removeTargetArg}${removeBranchArg}${humanGlobalSuffix}`
|
|
2870
|
-
);
|
|
2871
|
-
const addHumanCommand = getCommandNamePlain(
|
|
2872
|
-
`env add ${envName} ${addTargetArg}${addBranchArg} --type config${humanGlobalSuffix}`
|
|
2873
|
-
);
|
|
2874
|
-
const message = "A Secret cannot be changed to Config. To store this value as Config, remove the variable and add it again with `--type config`.";
|
|
2875
|
-
if (client.nonInteractive) {
|
|
2876
|
-
outputAgentError(
|
|
2877
|
-
client,
|
|
2878
|
-
{
|
|
2879
|
-
status: "error",
|
|
2880
|
-
reason: "secret_cannot_become_config",
|
|
2881
|
-
message,
|
|
2882
|
-
next: [
|
|
2883
|
-
{
|
|
2884
|
-
command: removeCommand,
|
|
2885
|
-
when: "Remove the Secret from all of its environments"
|
|
2886
|
-
},
|
|
2887
|
-
{
|
|
2888
|
-
command: addCommand,
|
|
2889
|
-
when: "Add it again as Config; replace <value> before running"
|
|
2890
|
-
}
|
|
2891
|
-
]
|
|
2892
|
-
},
|
|
2893
|
-
1
|
|
2894
|
-
);
|
|
2895
|
-
}
|
|
2896
|
-
output_manager_default.fatal(
|
|
2897
|
-
`A Secret cannot be changed to Config. Remove the variable, then add it again as Config. ${param(envName)} will be unavailable to new builds between these commands.`
|
|
2898
|
-
);
|
|
2899
|
-
output_manager_default.print(` Remove:
|
|
18
|
+
`),1;let selectedAction=await client.input.select({message:"How should this variable be stored?",choices:[...publicPrefix===""?[]:[{name:`Keep private: rename to ${privateName} and use Secret`,value:"private"}],{name:`Expose to anyone visiting your site: keep ${envName} as Config`,value:"public"},{name:"Enter a different value",value:"reenter"}]});if(selectedAction==="private"){envName=privateName,finalType="sensitive",explicitType="secret",typeSource="prompt",output_manager_default.log(`Renamed to ${envName}`);break}if(selectedAction==="reenter"){let reenteredValue=await promptEnvValue(client,{isSensitive:!1});finalValue=(await validateEnvValue({envName,initialValue:reenteredValue,skipConfirm:!1,promptForValue:()=>promptEnvValue(client,{isSensitive:!1}),selectAction:choices2=>client.input.select({message:"Value?",choices:choices2}),showWarning:msg=>printEnvAddWarning(msg),showLog:msg=>output_manager_default.log(msg)})).finalValue;continue}}else typeSource!=="argv"&&typeSource!=="prompt"&&!opts["--yes"]&&!client.nonInteractive&&await client.input.select({message:"Store this value as?",choices:[{name:getSecretStorageChoice(envTargets,"for this value"),value:"secret"},{name:"Config (can be revealed after saving)",value:"config"}]})==="secret"&&(finalType="sensitive",explicitType="secret",typeSource="prompt");break}finalType==="sensitive"&&customSveltePublicPrefix!==void 0&&envName.startsWith(customSveltePublicPrefix)&&printEnvAddWarning("This SvelteKit project exposes this variable to the browser; the Secret type does not prevent that. Rename the variable without the configured public prefix to keep it private."),isFlagsSecretNeedingSplit({key:envName,type:finalType,targets:envTargets.filter(isValidEnvTarget),customEnvironmentIds:envTargets.filter(target=>!isValidEnvTarget(target))})&&printEnvAddWarning("FLAGS_SECRET should use a separate value for each environment so Development overrides cannot affect Preview or Production.");let hasProduction=envTargets.includes("production"),hasNonProduction=envTargets.some(target=>target!=="production");if(finalType==="sensitive"&&disjunctiveProductionSecretPolicyOn&&hasProduction&&hasNonProduction){let message="Your team requires Production and non-Production Secrets to be stored separately with different values. Run one command for Production and another for the remaining environments.";return client.nonInteractive&&outputAgentError(client,{status:"error",reason:"production_secret_must_be_separate",message,next:[{command:buildEnvAddCommandWithPreservedArgs(client.argv,`env add ${envName} production --type secret --value "<production-value>" --yes`),when:"Set the Production Secret"},{command:buildEnvAddCommandWithPreservedArgs(client.argv,`env add ${envName} ${envTargets.filter(target=>target!=="production").join(",")} --type secret --value "<non-production-value>" --yes`),when:"Set the non-Production Secret"}]},1),output_manager_default.fatal(message),1}let upsert=opts["--force"]?"true":"",{visibility,error:visibilityError}=resolveEnvVarVisibility({explicitVisibility:explicitType,explicitOptionSource:typeOption.source,type:finalType,key:envName,envTargets,teamSensitivePolicyOn,context:"add"});if(visibilityError)return client.nonInteractive&&outputAgentError(client,{status:"error",reason:"invalid_type",message:visibilityError},1),output_manager_default.fatal(visibilityError),1;try{output_manager_default.spinner("Saving\u2026"),await addEnvRecord(client,project.id,upsert,finalType,envName,finalValue,envTargets,envGitBranch,visibility)}catch(err){if(client.nonInteractive&&isAPIError(err)){let productionSecretPolicyError=getProductionSecretPolicyErrorKind(err.serverMessage),reason=productionSecretPolicyError?productionSecretPolicyError==="different-values"?"production_secret_requires_different_value":"production_secret_must_be_separate":err.slug||(err.serverMessage?.toLowerCase().includes("branch")?"branch_not_found":"api_error");outputAgentError(client,{status:"error",reason,message:productionSecretPolicyError?`${err.serverMessage} ${getProductionSecretPolicyRecovery(productionSecretPolicyError)}`:err.serverMessage},1)}if(isAPIError(err)&&isKnownError(err))return output_manager_default.error(err.serverMessage),1;throw err}printEnvAddResult(link,envName,envTargets,envGitBranch,customEnvironments,finalType,!!opts["--force"],visibility),typeSource==="default"&&output_manager_default.print(` ${import_chalk.default.dim(getDefaultSecretStorageGuidance(envTargets))}
|
|
19
|
+
`);let{isAgent}=await determineAgent();return isGuidanceEnabled(client,parsedArgs.flags["--guidance"],isAgent)&&suggestNextCommands([{description:"List Environment Variables",command:withGlobalFlags(client,"env ls",{preserveProject:!0})},{description:"Pull Development Environment Variables into .env.local",command:withGlobalFlags(client,"env pull",{preserveProject:!0})}]),0}var import_chalk2=__toESM(require_source(),1),import_ms=__toESM(require_ms(),1);var import_title=__toESM(require_lib(),1);function formatEnvironments(link,env,customEnvironments){let defaultTargets=(Array.isArray(env.target)?env.target:[env.target||""]).map(t=>formatEnvironment(link.org.slug,link.project.name,{id:t,slug:(0,import_title.default)(t)})),customTargets=env.customEnvironmentIds?env.customEnvironmentIds.map(id=>customEnvironments.find(e=>e.id===id)).filter(Boolean).map(e=>formatEnvironment(link.org.slug,link.project.name,e)):[],targetsString=[...defaultTargets,...customTargets].join(", ");return env.gitBranch?`${targetsString} (${env.gitBranch})`:targetsString}var EnvLsTelemetryClient=class extends TelemetryClient{trackCliArgumentEnvironment(environment){environment&&this.trackCliArgument({arg:"environment",value:STANDARD_ENVIRONMENTS.includes(environment)?environment:this.redactedValue})}trackCliArgumentGitBranch(gitBranch){gitBranch&&this.trackCliArgument({arg:"git-branch",value:this.redactedValue})}trackCliFlagGuidance(guidance){guidance&&this.trackCliFlag("guidance")}trackCliFlagJson(json){json&&this.trackCliFlag("json")}};import{determineAgent as determineAgent2}from"@vercel/detect-agent";async function ls(client,argv){let telemetryClient=new EnvLsTelemetryClient({opts:{store:client.telemetryEventStore}}),parsedArgs,flagsSpecification=getFlagsSpecification(listSubcommand.options);try{parsedArgs=parseArguments(argv,flagsSpecification)}catch(err){return printError(err),1}let{args,flags}=parsedArgs,validationResult=validateLsArgs({commandName:"env ls",args,maxArgs:2,exitCode:1,usageString:getCommandName(`env ls ${getEnvTargetPlaceholder()} <gitbranch>`)});if(validationResult!==0)return validationResult;let[envTarget,envGitBranch]=args,formatResult=validateJsonOutput(flags);if(!formatResult.valid)return output_manager_default.error(formatResult.error),1;let asJson=formatResult.jsonOutput;telemetryClient.trackCliArgumentEnvironment(envTarget),telemetryClient.trackCliArgumentGitBranch(envGitBranch),telemetryClient.trackCliFlagGuidance(flags["--guidance"]),telemetryClient.trackCliOptionFormat(flags["--format"]);let projectName=flags["--project"];telemetryClient.trackCliOptionProject(projectName);let link=await resolveProjectContext({client,projectNameOrId:projectName,commandName:"env ls"});if(link.status==="error")return link.exitCode;if(link.status==="not_linked")return output_manager_default.error(`Your codebase isn\u2019t linked to a project on Vercel. Pass --project <name>, or ${client.nonInteractive?`run ${getCommandName("link --yes --team <team-id> --project <project-id>")} to link non-interactively.`:`run ${getCommandName("link")} to begin.`}`),1;client.config.currentTeam=link.org.type==="team"?link.org.id:void 0;let{project,org}=link,lsStamp=stamp_default(),[envsResult,customEnvs]=await Promise.all([getEnvRecords(client,project.id,"vercel-cli:env:ls",{target:envTarget,gitBranch:envGitBranch}),getCustomEnvironments(client,project.id)]),{envs}=envsResult,projectSlugLink=formatProject(org.slug,project.name);if(asJson){output_manager_default.stopSpinner();let jsonOutput={envs:envs.map(env=>({key:env.key,value:isSecretEnvVar(env)?void 0:env.value,type:env.type,visibility:env.visibility,target:env.target,gitBranch:env.gitBranch,configurationId:env.configurationId,createdAt:env.createdAt,updatedAt:env.updatedAt}))};client.stdout.write(`${JSON.stringify(jsonOutput,null,2)}
|
|
20
|
+
`)}else envs.length===0?output_manager_default.log(`No Environment Variables found for ${projectSlugLink} ${import_chalk2.default.gray(lsStamp())}`):(output_manager_default.log(`Environment Variables found for ${projectSlugLink} ${import_chalk2.default.gray(lsStamp())}`),client.stdout.write(`${getTable(link,envs,customEnvs)}
|
|
21
|
+
`));if(!asJson){let{isAgent}=await determineAgent2();isGuidanceEnabled(client,parsedArgs.flags["--guidance"],isAgent)&&suggestNextCommands([{description:"Add an Environment Variable",command:withGlobalFlags(client,"env add",{preserveProject:!0})},{description:"Remove an Environment Variable",command:withGlobalFlags(client,"env rm",{preserveProject:!0})},{description:"Pull Development Environment Variables into .env.local",command:withGlobalFlags(client,"env pull",{preserveProject:!0})}])}return 0}function getTable(link,records,customEnvironments){let label=records.some(env=>env.gitBranch)?"environments (git branch)":"environments";return formatTable(["name","value","type",label,"created"],["l","l","l","l","l"],[{name:"",rows:records.map(row=>getRow(link,row,customEnvironments))}])}function getRow(link,env,customEnvironments){let value;if(isSecretEnvVar(env))value=import_chalk2.default.gray.italic("Hidden");else if(env.type==="system")value=import_chalk2.default.gray.italic(env.value);else{let singleLineValue=env.value.replace(/\s/g," ");value=import_chalk2.default.gray(ellipsis(singleLineValue,19))}let now=Date.now();return[import_chalk2.default.bold(env.key),value,getEnvironmentVariableTypeLabel(env),formatEnvironments(link,env,customEnvironments),env.createdAt?`${(0,import_ms.default)(now-env.createdAt)} ago`:""]}function getEnvironmentVariableTypeLabel(env){return isSecretEnvVar(env)?"Secret":env.type==="system"?"System":"Config"}var import_chalk3=__toESM(require_source(),1);async function removeEnvRecord(client,projectId,env){output_manager_default.debug(`Removing Environment Variable ${env.key}`);let url=`/v10/projects/${projectId}/env/${env.id}`;await client.fetch(url,{method:"DELETE"})}var EnvRmTelemetryClient=class extends TelemetryClient{trackCliArgumentName(name){name&&this.trackCliArgument({arg:"name",value:this.redactedValue})}trackCliArgumentEnvironment(environment){environment&&this.trackCliArgument({arg:"environment",value:STANDARD_ENVIRONMENTS.includes(environment)?environment:this.redactedValue})}trackCliArgumentGitBranch(gitBranch){gitBranch&&this.trackCliArgument({arg:"git-branch",value:this.redactedValue})}trackCliFlagYes(yes){yes&&this.trackCliFlag("yes")}};function printEnvRmWarning(message){output_manager_default.print(`${import_chalk3.default.yellow("!")} ${message}
|
|
22
|
+
`)}async function rm(client,argv){let telemetryClient=new EnvRmTelemetryClient({opts:{store:client.telemetryEventStore}}),parsedArgs,flagsSpecification=getFlagsSpecification(removeSubcommand.options);try{parsedArgs=parseArguments(argv,flagsSpecification)}catch(err){return client.nonInteractive&&outputAgentError(client,{status:"error",reason:"invalid_arguments",message:err instanceof Error?err.message:String(err)},1),printError(err),1}let{args,flags:opts}=parsedArgs;if(args.length>3)return client.nonInteractive&&outputAgentError(client,{status:"error",reason:"invalid_arguments",message:`Invalid number of arguments. Usage: \`${getCommandNamePlain(`env rm <name> ${getEnvTargetPlaceholder()} <gitbranch>`)}\``},1),output_manager_default.error(`Invalid number of arguments. Usage: ${getCommandName(`env rm <name> ${getEnvTargetPlaceholder()} <gitbranch>`)}`),1;let[envName,envTarget,envGitBranch]=args;telemetryClient.trackCliArgumentName(envName),telemetryClient.trackCliArgumentEnvironment(envTarget),telemetryClient.trackCliArgumentGitBranch(envGitBranch),telemetryClient.trackCliFlagYes(opts["--yes"]),telemetryClient.trackCliOptionProject(opts["--project"]);let link=await resolveProjectContext({client,projectNameOrId:opts["--project"]});if(link.status==="error")return link.exitCode;if(link.status==="not_linked"){if(client.nonInteractive){let preserved=getPreservedArgsForEnvRm(client.argv).filter(a=>a!=="--yes"&&a!=="-y"),linkArgv=[...client.argv.slice(0,2),"link","--scope","<scope>",...preserved];outputAgentError(client,{status:"error",reason:"not_linked",message:`Your codebase isn't linked to a project on Vercel. Run \`${getCommandNamePlain("link")}\` to begin. Use \`--yes\` for non-interactive; use \`--scope\` or \`--project\` to specify team or project.`,next:[{command:buildCommandWithYes(linkArgv)},{command:buildCommandWithYes(client.argv)}]},1)}else output_manager_default.error(`Your codebase isn\u2019t linked to a project on Vercel. Run ${getCommandName("link")} to begin.`);return 1}client.config.currentTeam=link.org.type==="team"?link.org.id:void 0;let{project}=link;envName||(client.nonInteractive&&outputActionRequired(client,{status:"action_required",reason:"missing_name",message:"Provide the variable name as an argument. Example: `vercel env rm <name> --yes`",next:[{command:buildEnvRmCommandWithPreservedArgs(client.argv,`env rm <name> ${getEnvTargetPlaceholder()} --yes`)}]},1),envName=await client.input.text({message:"What's the name of the variable?",validate:val=>val?!0:"Name cannot be empty"}));let[result,customEnvironments]=await Promise.all([getEnvRecords(client,project.id,"vercel-cli:env:rm",{target:envTarget,gitBranch:envGitBranch}),getCustomEnvironments(client,project.id)]),envs=result.envs.filter(env2=>env2.key===envName);if(envs.length===0)return client.nonInteractive&&outputAgentError(client,{status:"error",reason:"env_not_found",message:`Environment Variable ${envName} was not found.`},1),output_manager_default.error(`Environment Variable was not found.
|
|
23
|
+
`),1;for(;envs.length>1;){client.nonInteractive&&outputActionRequired(client,{status:"action_required",reason:"multiple_envs",message:`Multiple Environment Variables match ${envName}. Specify target and/or branch to remove one.`,next:[{command:buildEnvRmCommandWithPreservedArgs(client.argv,`env rm ${envName} ${getEnvTargetPlaceholder()} --yes`)}]},1);let id=await client.input.select({message:`Remove ${envName} from which Environments?`,choices:envs.map(env2=>({value:env2.id,name:formatEnvironments(link,env2,customEnvironments)}))});id||output_manager_default.error("Please select at least one Environment Variable to remove"),envs=envs.filter(env2=>env2.id===id)}let env=envs[0],shouldWarnAboutRotation=shouldConfirmRotationBeforeDelete({key:env.key,type:env.type,hasPublicPrefix:getPublicPrefix(env.key)!==null}),rotationWarning="Removing this variable from Vercel does not revoke the credential. Rotate or disable it at its provider.";if(shouldWarnAboutRotation&&printEnvRmWarning(rotationWarning),!opts["--yes"]&&(client.nonInteractive&&outputActionRequired(client,{status:"action_required",reason:"confirmation_required",message:`Removing Environment Variable ${env.key}. ${shouldWarnAboutRotation?`${rotationWarning} `:""}Use --yes to confirm.`,next:[{command:buildCommandWithYes(client.argv)}]},1),!await client.input.confirm(`Remove ${param(env.key)} from ${formatEnvironments(link,env,customEnvironments)} in Project ${import_chalk3.default.bold(project.name)}?`,!1)))return output_manager_default.log("Canceled"),0;let rmStamp=stamp_default();try{output_manager_default.spinner("Removing"),await removeEnvRecord(client,project.id,env)}catch(err){if(client.nonInteractive&&isAPIError(err)){let reason=err.slug||(err.serverMessage?.toLowerCase().includes("branch")?"branch_not_found":"api_error");outputAgentError(client,{status:"error",reason,message:err.serverMessage},1)}if(isAPIError(err)&&isKnownError(err))return output_manager_default.error(err.serverMessage),1;throw err}return output_manager_default.print(`${prependEmoji(`Removed Environment Variable ${import_chalk3.default.gray(rmStamp())}`,emoji("success"))}
|
|
24
|
+
`),0}var import_env=__toESM(require_dist3(),1),import_chalk4=__toESM(require_source(),1),import_execa=__toESM(require_execa(),1);function printEnvRunWarning(message){output_manager_default.print(`${import_chalk4.default.yellow("!")} ${message}
|
|
25
|
+
`)}function omitUnavailableSecretPlaceholders(localEnv,secretKeys){let safeLocalEnv={...localEnv};for(let key of secretKeys)safeLocalEnv[key]===SENSITIVE_ENV_VALUE_PLACEHOLDER&&delete safeLocalEnv[key];return safeLocalEnv}function parseRunArgs(argv){let argvIndex=argv.indexOf("--"),hasDoubleDash=argvIndex!==-1,vercelArgs=hasDoubleDash?argv.slice(2,argvIndex):argv.slice(2),userCommand=hasDoubleDash?argv.slice(argvIndex+1):[];return{vercelArgs,userCommand}}function needsHelpForRun(client){let{vercelArgs}=parseRunArgs(client.argv),flagsSpecification=getFlagsSpecification(runSubcommand.options);try{return!!parseArguments(vercelArgs,flagsSpecification).flags["--help"]}catch{return!1}}async function run(client,telemetry){let{vercelArgs,userCommand}=parseRunArgs(client.argv),parsedArgs,flagsSpecification=getFlagsSpecification(runSubcommand.options);try{parsedArgs=parseArguments(vercelArgs,flagsSpecification)}catch(error){return printError(error),1}if(userCommand.length===0)return outputActionRequired(client,{status:"action_required",reason:"missing_command",message:"No command provided. Use `--` to separate Vercel flags from your command.",next:[{command:getCommandNamePlain("env run -- <command>")}]},1),output_manager_default.error("No command provided. Use `--` to separate vercel flags from your command."),1;let projectName=parsedArgs.flags["--project"];telemetry.trackCliOptionProject(projectName);let link=await resolveProjectContext({client,projectNameOrId:projectName});if(link.status==="error")return link.exitCode;if(link.status==="not_linked")return outputActionRequired(client,{status:"action_required",reason:"not_linked",message:"Your codebase isn't linked to a project on Vercel. Run `vercel link`, then retry this command.",next:[{command:getCommandNamePlain("link")}]},1),output_manager_default.error(`Your codebase isn't linked to a project on Vercel. Run ${getCommandName("link")} to begin.`),1;client.config.currentTeam=link.org.type==="team"?link.org.id:void 0;let environment=parseTarget({flagName:"environment",flags:parsedArgs.flags})||"development",gitBranch=parsedArgs.flags["--git-branch"];output_manager_default.spinner(`Downloading \`${environment}\` environment variables`);let records=await pullEnvRecords(client,link.project.id,"vercel-cli:env:run",{target:environment,gitBranch});output_manager_default.stopSpinner(),output_manager_default.debug(`Running command with ${Object.keys(records.env).length} environment variables`);let localEnv={};try{localEnv=(0,import_env.loadEnvConfig)(client.cwd,!0).combinedEnv}catch(err){output_manager_default.debug(`Failed to load local env files: ${err}`)}let localPlaceholderKeys=Object.entries(localEnv).filter(([,value])=>value===SENSITIVE_ENV_VALUE_PLACEHOLDER).map(([key])=>key),safeLocalEnv=omitUnavailableSecretPlaceholders(localEnv,localPlaceholderKeys),processPlaceholderKeys=Object.keys(records.env).filter(key=>process.env[key]===SENSITIVE_ENV_VALUE_PLACEHOLDER),safeProcessEnv=omitUnavailableSecretPlaceholders(process.env,processPlaceholderKeys),unavailableCandidateKeys=new Set(Object.entries(records.env).filter(([key,value])=>!value&&!safeLocalEnv[key]&&!safeProcessEnv[key]).map(([key])=>key));if(unavailableCandidateKeys.size>0)try{let{envs}=await getEnvRecords(client,link.project.id,"vercel-cli:env:run",{target:environment,gitBranch}),unavailableSecretKeys=envs.filter(env=>isSecretEnvVar(env)&&unavailableCandidateKeys.has(env.key));unavailableSecretKeys.length>0&&printEnvRunWarning(`${getUnavailableSecretValuesMessage(environment,unavailableSecretKeys.length)}${getLocalSecretFallbackMessage(unavailableSecretKeys.length)}`)}catch{}try{let result=await(0,import_execa.default)(userCommand[0],userCommand.slice(1),{cwd:client.cwd,stdio:"inherit",reject:!1,env:{...records.env,...safeLocalEnv,...safeProcessEnv}});return result instanceof Error&&typeof result.exitCode!="number"?(output_manager_default.prettyError(result),1):result.exitCode}catch(err){return output_manager_default.prettyError(err),1}}var import_chalk5=__toESM(require_source(),1);var import_constants3=__toESM(require_dist2(),1);async function updateEnvRecord(client,projectId,envId,type,key,value,targets,gitBranch,visibility){output_manager_default.debug(`Updating ${type} Environment Variable ${key} in ${targets.length} targets`);let target=[],customEnvironmentIds=[];for(let t of targets)(import_constants3.PROJECT_ENV_TARGET.includes(t)?target:customEnvironmentIds).push(t);let body={type,value,target,customEnvironmentIds:customEnvironmentIds.length>0?customEnvironmentIds:void 0,gitBranch:gitBranch||void 0,...visibility!==void 0?{visibility}:{}};key&&(body.key=key);let url=`/v10/projects/${projectId}/env/${envId}`;await client.fetch(url,{method:"PATCH",body})}var EnvUpdateTelemetryClient=class extends TelemetryClient{trackCliArgumentName(name){name&&this.trackCliArgument({arg:"name",value:this.redactedValue})}trackCliArgumentEnvironment(environment){environment&&this.trackCliArgument({arg:"environment",value:STANDARD_ENVIRONMENTS.includes(environment)?environment:this.redactedValue})}trackCliArgumentGitBranch(gitBranch){gitBranch&&this.trackCliArgument({arg:"git-branch",value:this.redactedValue})}trackCliFlagSensitive(sensitive){sensitive&&this.trackCliFlag("sensitive")}trackCliFlagYes(yes){yes&&this.trackCliFlag("yes")}trackCliOptionValue(value){value&&this.trackCliOption({option:"value",value:this.redactedValue})}trackCliOptionVisibility(visibility){if(visibility){let validVisibilities=["config","secret"];this.trackCliOption({option:"visibility",value:validVisibilities.includes(visibility)?visibility:this.redactedValue})}}trackCliOptionType(type){if(type){let validTypes=["config","secret"];this.trackCliOption({option:"type",value:validTypes.includes(type)?type:this.redactedValue})}}};function looksLikeCredentialName2(key,publicPrefix=getPublicPrefix(key)){return looksLikeSecret(publicPrefix?key.slice(publicPrefix.length):key)}function printEnvUpdateWarning(message){output_manager_default.print(`${import_chalk5.default.yellow("!")} ${message}
|
|
26
|
+
`)}function omitEnvValueArgs(argv){let out=[];for(let i=0;i<argv.length;i++){if(argv[i]==="--value"){i++;continue}argv[i].startsWith("--value=")||out.push(argv[i])}return out}function formatTargetArg(targets,customEnvironments){return targets.map(target=>customEnvironments.find(environment=>environment.id===target||environment.slug===target)?.slug??target).join(",")}function promptEnvUpdateValue(client,envName,isSecret){return client.input.text({message:`What's the new value of ${envName}?`,...isSecret?{transformer:value=>"*".repeat(value.length)}:{}})}async function update(client,argv){let parsedArgs,flagsSpecification=getFlagsSpecification(updateSubcommand.options);try{parsedArgs=parseArguments(argv,flagsSpecification)}catch(err){return client.nonInteractive&&outputAgentError(client,{status:"error",reason:"invalid_arguments",message:err instanceof Error?err.message:String(err)},1),printError(err),1}let{args,flags:opts}=parsedArgs,valueFromFlag=typeof opts["--value"]=="string"?opts["--value"]:void 0,stdInput=await readStandardInput(client.stdin),[envName,envTargetArg,envGitBranch]=args,typeOption=resolveEnvVarTypeOption({type:typeof opts["--type"]=="string"?opts["--type"]:void 0,visibility:typeof opts["--visibility"]=="string"?opts["--visibility"]:void 0}),explicitType=typeOption.explicitVisibility,typeWasExplicit=explicitType!==void 0||!!opts["--sensitive"],telemetryClient=new EnvUpdateTelemetryClient({opts:{store:client.telemetryEventStore}});if(telemetryClient.trackCliArgumentName(envName),telemetryClient.trackCliArgumentEnvironment(envTargetArg),telemetryClient.trackCliArgumentGitBranch(envGitBranch),telemetryClient.trackCliFlagSensitive(opts["--sensitive"]),telemetryClient.trackCliFlagYes(opts["--yes"]),telemetryClient.trackCliOptionValue(valueFromFlag===void 0?void 0:"<redacted>"),telemetryClient.trackCliOptionType(typeof opts["--type"]=="string"?opts["--type"]:void 0),telemetryClient.trackCliOptionVisibility(typeof opts["--visibility"]=="string"?opts["--visibility"]:void 0),typeOption.error)return client.nonInteractive&&outputAgentError(client,{status:"error",reason:typeOption.errorReason??"invalid_type",message:typeOption.error},1),output_manager_default.fatal(typeOption.error),1;if(typeOption.usedDeprecatedVisibility&&printEnvUpdateWarning(ENV_VISIBILITY_DEPRECATION_MESSAGE),explicitType==="config"&&opts["--sensitive"]){let message="`--type config` cannot be used with `--sensitive`. Pick one.";return client.nonInteractive&&outputAgentError(client,{status:"error",reason:"conflicting_type_flags",message},1),output_manager_default.fatal(message),1}if(args.length>3)return client.nonInteractive&&outputAgentError(client,{status:"error",reason:"invalid_arguments",message:`Invalid number of arguments. Usage: \`${getCommandNamePlain(`env update <name> ${getEnvTargetPlaceholder()} <gitbranch>`)}\``},1),output_manager_default.error(`Invalid number of arguments. Usage: ${getCommandName(`env update <name> ${getEnvTargetPlaceholder()} <gitbranch>`)}`),1;if(stdInput&&(!envName||!envTargetArg))return output_manager_default.error(`Invalid number of arguments. Usage: ${getCommandName("env update <name> <target> <gitbranch> < <file>")}`),1;if(client.nonInteractive){let missing=[];if(envName||missing.push("missing_name"),!stdInput&&valueFromFlag===void 0&&missing.push("missing_value"),missing.length>0){let parts=missing.map(m=>m==="missing_name"?"name":"--value or stdin"),targetPart=envTargetArg||getEnvTargetPlaceholder(),template=`env update ${envName||"<name>"} ${targetPart}${envTargetArg==="preview"||envTargetArg==="development"?" <gitbranch>":""} --value <value> --yes`;outputActionRequired(client,{status:"action_required",reason:"missing_requirements",missing,message:`Provide all required inputs for non-interactive mode: ${parts.join("; ")}. Example: ${getCommandNamePlain(template)}`,next:[{command:buildEnvUpdateCommandWithPreservedArgs(client.argv,template)}]},1)}}envTargetArg&&[].push(envTargetArg),envName||(client.nonInteractive?outputActionRequired(client,{status:"action_required",reason:"missing_name",message:"Provide the variable name as an argument. Example: vercel env update <name>",next:[{command:buildEnvUpdateCommandWithPreservedArgs(client.argv,`env update <name> ${getEnvTargetPlaceholder()} --value <value> --yes`)}]},1):envName=await client.input.text({message:"What's the name of the variable to update?",validate:val=>val?!0:"Name cannot be empty"})),telemetryClient.trackCliOptionProject(opts["--project"]);let link=await resolveProjectContext({client,projectNameOrId:opts["--project"]});if(link.status==="error")return link.exitCode;if(link.status==="not_linked"){if(client.nonInteractive){let preserved=omitEnvValueArgs(getPreservedArgsForEnvUpdate(client.argv)).filter(a=>a!=="--yes"&&a!=="-y"),linkArgv=[...client.argv.slice(0,2),"link","--scope","<scope>",...preserved];outputAgentError(client,{status:"error",reason:"not_linked",message:`Your codebase isn't linked to a project on Vercel. Run ${getCommandNamePlain("link")} to begin. Use --yes for non-interactive; use --scope or --project to specify team or project.`,next:[{command:buildCommandWithYes(linkArgv)},{command:buildCommandWithYes(redactEnvValueArgs(client.argv))}]},1)}return output_manager_default.error(`Your codebase isn't linked to a project on Vercel. Run ${getCommandName("link")} to begin.`),1}client.config.currentTeam=link.org.type==="team"?link.org.id:void 0;let{project}=link,[{envs},customEnvironments]=await Promise.all([getEnvRecords(client,project.id,"vercel-cli:env:update"),getCustomEnvironments(client,project.id)]),normalizedEnvTargetArg=customEnvironments.find(({slug,id})=>slug===envTargetArg||id===envTargetArg)?.id||envTargetArg,matchingEnvs=envs.filter(r=>r.key===envName);if(matchingEnvs.length===0){let listArgs=`env ls ${getGlobalFlagsFromArgs(client.argv.slice(2),{preserveProject:!0}).join(" ")}`.trim();return client.nonInteractive&&outputAgentError(client,{status:"error",reason:"env_not_found",message:`The variable ${envName} was not found. Run ${getCommandNamePlain(listArgs)} to see all available Environment Variables.`},1),output_manager_default.error(`The variable ${param(envName)} was not found. Run ${getCommandName(listArgs)} to see all available Environment Variables.`),1}let selectedEnv;if(envTargetArg||envGitBranch){let filteredEnvs=matchingEnvs.filter(env=>{let matchesTarget=!normalizedEnvTargetArg||(Array.isArray(env.target)?env.target.includes(normalizedEnvTargetArg):env.target===normalizedEnvTargetArg)||env.customEnvironmentIds&&env.customEnvironmentIds.includes(normalizedEnvTargetArg),matchesGitBranch=!envGitBranch||env.gitBranch===envGitBranch;return matchesTarget&&matchesGitBranch});if(filteredEnvs.length===0)return client.nonInteractive&&outputAgentError(client,{status:"error",reason:"env_not_found",message:`No Environment Variable ${envName} found matching the specified target/branch.`},1),output_manager_default.error(`No Environment Variable ${param(envName)} found matching the specified criteria.`),1;if(filteredEnvs.length===1)selectedEnv=filteredEnvs[0];else{client.nonInteractive&&outputActionRequired(client,{status:"action_required",reason:"multiple_envs",message:`Multiple Environment Variables match ${envName}. Specify target and/or branch to update one.`,next:[{command:buildEnvUpdateCommandWithPreservedArgs(client.argv,`env update ${envName} ${getEnvTargetPlaceholder()} <gitbranch> --value "<value>" --yes`)}]},1);let choices=filteredEnvs.map((env,index)=>({name:formatEnvironments(link,env,customEnvironments),value:index})),selectedIndex=await client.input.select({message:`Multiple Environment Variables found for ${param(envName)}. Which one do you want to update?`,choices});selectedEnv=filteredEnvs[selectedIndex]}}else if(matchingEnvs.length===1)selectedEnv=matchingEnvs[0];else{client.nonInteractive&&outputActionRequired(client,{status:"action_required",reason:"multiple_envs",message:`Multiple Environment Variables match ${envName}. Specify target and/or branch to update one.`,next:[{command:buildEnvUpdateCommandWithPreservedArgs(client.argv,`env update ${envName} ${getEnvTargetPlaceholder()} <gitbranch> --value "<value>" --yes`)}]},1);let choices=matchingEnvs.map((env,index)=>({name:formatEnvironments(link,env,customEnvironments),value:index})),selectedIndex=await client.input.select({message:`Multiple Environment Variables found for ${param(envName)}. Which one do you want to update?`,choices});selectedEnv=matchingEnvs[selectedIndex]}let customSveltePublicPrefix,apiPublicPrefix=getApiPublicPrefix(envName),frameworkPublicPrefix=getFrameworkPublicPrefix(project.framework,envName);if(project.framework==="sveltekit"||project.framework==="sveltekit-1"||project.framework==="sveltekit-2"){let matchingLocalPrefix=(await getLocalSvelteKitPublicPrefixes(link.repoRoot??client.cwd,project.rootDirectory))?.find(prefix=>envName.startsWith(prefix));matchingLocalPrefix!==void 0&&apiPublicPrefix===null&&frameworkPublicPrefix===null&&(customSveltePublicPrefix=matchingLocalPrefix)}let targets=Array.isArray(selectedEnv.target)?selectedEnv.target:[selectedEnv.target].filter(r=>!!r),allTargets=[...targets,...selectedEnv.customEnvironmentIds||[]],selectedEnvIsSecret=isSecretEnvVar(selectedEnv);if(explicitType==="config"&&selectedEnvIsSecret){let removeTargetArg=envTargetArg||targets[0]||allTargets[0]||getEnvTargetPlaceholder(),addTargetArg=formatTargetArg(allTargets,customEnvironments)||removeTargetArg,removeBranchArg=selectedEnv.gitBranch?` ${quoteArg(selectedEnv.gitBranch)}`:"",addBranchArg=selectedEnv.gitBranch?` --git-branch ${quoteArg(selectedEnv.gitBranch)}`:"",globalFlags=getGlobalFlagsFromArgs(client.argv.slice(2),{preserveProject:!0}),humanGlobalFlags=globalFlags.filter(flag=>!flag.startsWith("--non-interactive")),globalSuffix=globalFlags.length>0?` ${globalFlags.map(quoteArg).join(" ")}`:"",humanGlobalSuffix=humanGlobalFlags.length>0?` ${humanGlobalFlags.map(quoteArg).join(" ")}`:"",removeCommand=getCommandNamePlain(`env rm ${envName} ${removeTargetArg}${removeBranchArg} --yes${globalSuffix}`),addCommand=getCommandNamePlain(`env add ${envName} ${addTargetArg}${addBranchArg} --type config --value "<value>" --yes${globalSuffix}`),removeHumanCommand=getCommandNamePlain(`env rm ${envName} ${removeTargetArg}${removeBranchArg}${humanGlobalSuffix}`),addHumanCommand=getCommandNamePlain(`env add ${envName} ${addTargetArg}${addBranchArg} --type config${humanGlobalSuffix}`),message="A Secret cannot be changed to Config. To store this value as Config, remove the variable and add it again with `--type config`.";return client.nonInteractive&&outputAgentError(client,{status:"error",reason:"secret_cannot_become_config",message,next:[{command:removeCommand,when:"Remove the Secret from all of its environments"},{command:addCommand,when:"Add it again as Config; replace <value> before running"}]},1),output_manager_default.fatal(`A Secret cannot be changed to Config. Remove the variable, then add it again as Config. ${param(envName)} will be unavailable to new builds between these commands.`),output_manager_default.print(` Remove:
|
|
2900
27
|
${removeHumanCommand}
|
|
2901
|
-
`)
|
|
2902
|
-
output_manager_default.print(
|
|
2903
|
-
` Add as Config (prompts for the value):
|
|
28
|
+
`),output_manager_default.print(` Add as Config (prompts for the value):
|
|
2904
29
|
${addHumanCommand}
|
|
2905
|
-
`
|
|
2906
|
-
);
|
|
2907
|
-
return 1;
|
|
2908
|
-
}
|
|
2909
|
-
if (explicitType === "secret" || opts["--sensitive"]) {
|
|
2910
|
-
const knownPublicPrefix = apiPublicPrefix ?? frameworkPublicPrefix;
|
|
2911
|
-
const publicPrefix = knownPublicPrefix ?? customSveltePublicPrefix;
|
|
2912
|
-
const apiPublicPrefixError = apiPublicPrefix ? getPublicPrefixSecretVisibilityError(envName, {
|
|
2913
|
-
visibility: explicitType === "secret" ? "secret" : void 0,
|
|
2914
|
-
type: "sensitive",
|
|
2915
|
-
context: "update"
|
|
2916
|
-
}) : null;
|
|
2917
|
-
const publicPrefixError = apiPublicPrefixError ? apiPublicPrefixError : knownPublicPrefix ? `\`${knownPublicPrefix}\` exposes this value to anyone visiting your site, so \`${envName}\` cannot be kept private as a Secret. Add a new Secret without the public prefix, then remove this Config.` : customSveltePublicPrefix === "" ? "This SvelteKit project uses an empty `publicPrefix`, so every Environment Variable is exposed to the browser and cannot be kept private as a Secret. Change the SvelteKit `publicPrefix`, or keep this variable as Config only if the value is safe to expose." : customSveltePublicPrefix !== void 0 ? `\`${customSveltePublicPrefix}\` exposes this value to anyone visiting your site, so \`${envName}\` cannot be kept private as a Secret. Add a new Secret without the configured public prefix, then remove this Config.` : null;
|
|
2918
|
-
if (publicPrefixError) {
|
|
2919
|
-
const privateName = publicPrefix === void 0 ? envName : envName.slice(publicPrefix.length);
|
|
2920
|
-
const removeTargetArg = envTargetArg || targets[0] || allTargets[0] || getEnvTargetPlaceholder();
|
|
2921
|
-
const addTargetArg = formatTargetArg(allTargets, customEnvironments) || removeTargetArg;
|
|
2922
|
-
const removeBranchArg = selectedEnv.gitBranch ? ` ${quoteArg(selectedEnv.gitBranch)}` : "";
|
|
2923
|
-
const addBranchArg = selectedEnv.gitBranch ? ` --git-branch ${quoteArg(selectedEnv.gitBranch)}` : "";
|
|
2924
|
-
const globalFlags = getGlobalFlagsFromArgs(client.argv.slice(2), {
|
|
2925
|
-
preserveProject: true
|
|
2926
|
-
});
|
|
2927
|
-
const humanGlobalFlags = globalFlags.filter(
|
|
2928
|
-
(flag) => !flag.startsWith("--non-interactive")
|
|
2929
|
-
);
|
|
2930
|
-
const globalSuffix = globalFlags.length > 0 ? ` ${globalFlags.map(quoteArg).join(" ")}` : "";
|
|
2931
|
-
const humanGlobalSuffix = humanGlobalFlags.length > 0 ? ` ${humanGlobalFlags.map(quoteArg).join(" ")}` : "";
|
|
2932
|
-
const addCommand = publicPrefix === "" ? void 0 : getCommandNamePlain(
|
|
2933
|
-
`env add ${privateName} ${addTargetArg}${addBranchArg} --type secret --value "<value>" --yes${globalSuffix}`
|
|
2934
|
-
);
|
|
2935
|
-
const removeCommand = getCommandNamePlain(
|
|
2936
|
-
`env rm ${envName} ${removeTargetArg}${removeBranchArg} --yes${globalSuffix}`
|
|
2937
|
-
);
|
|
2938
|
-
const addHumanCommand = publicPrefix === "" ? void 0 : getCommandNamePlain(
|
|
2939
|
-
`env add ${privateName} ${addTargetArg}${addBranchArg} --type secret${humanGlobalSuffix}`
|
|
2940
|
-
);
|
|
2941
|
-
const removeHumanCommand = getCommandNamePlain(
|
|
2942
|
-
`env rm ${envName} ${removeTargetArg}${removeBranchArg}${humanGlobalSuffix}`
|
|
2943
|
-
);
|
|
2944
|
-
if (client.nonInteractive) {
|
|
2945
|
-
outputAgentError(
|
|
2946
|
-
client,
|
|
2947
|
-
{
|
|
2948
|
-
status: "error",
|
|
2949
|
-
reason: "invalid_type",
|
|
2950
|
-
message: publicPrefixError,
|
|
2951
|
-
next: addCommand ? [
|
|
2952
|
-
{
|
|
2953
|
-
command: addCommand,
|
|
2954
|
-
when: "Add the private Secret; replace <value> before running"
|
|
2955
|
-
},
|
|
2956
|
-
{
|
|
2957
|
-
command: removeCommand,
|
|
2958
|
-
when: "Remove the public Config after the Secret is available"
|
|
2959
|
-
}
|
|
2960
|
-
] : []
|
|
2961
|
-
},
|
|
2962
|
-
1
|
|
2963
|
-
);
|
|
2964
|
-
}
|
|
2965
|
-
output_manager_default.fatal(publicPrefixError);
|
|
2966
|
-
if (addHumanCommand) {
|
|
2967
|
-
output_manager_default.print(
|
|
2968
|
-
` Add the private Secret (prompts for the value):
|
|
30
|
+
`),1}if(explicitType==="secret"||opts["--sensitive"]){let knownPublicPrefix=apiPublicPrefix??frameworkPublicPrefix,publicPrefix=knownPublicPrefix??customSveltePublicPrefix,apiPublicPrefixError=apiPublicPrefix?getPublicPrefixSecretVisibilityError(envName,{visibility:explicitType==="secret"?"secret":void 0,type:"sensitive",context:"update"}):null,publicPrefixError=apiPublicPrefixError||(knownPublicPrefix?`\`${knownPublicPrefix}\` exposes this value to anyone visiting your site, so \`${envName}\` cannot be kept private as a Secret. Add a new Secret without the public prefix, then remove this Config.`:customSveltePublicPrefix===""?"This SvelteKit project uses an empty `publicPrefix`, so every Environment Variable is exposed to the browser and cannot be kept private as a Secret. Change the SvelteKit `publicPrefix`, or keep this variable as Config only if the value is safe to expose.":customSveltePublicPrefix!==void 0?`\`${customSveltePublicPrefix}\` exposes this value to anyone visiting your site, so \`${envName}\` cannot be kept private as a Secret. Add a new Secret without the configured public prefix, then remove this Config.`:null);if(publicPrefixError){let privateName=publicPrefix===void 0?envName:envName.slice(publicPrefix.length),removeTargetArg=envTargetArg||targets[0]||allTargets[0]||getEnvTargetPlaceholder(),addTargetArg=formatTargetArg(allTargets,customEnvironments)||removeTargetArg,removeBranchArg=selectedEnv.gitBranch?` ${quoteArg(selectedEnv.gitBranch)}`:"",addBranchArg=selectedEnv.gitBranch?` --git-branch ${quoteArg(selectedEnv.gitBranch)}`:"",globalFlags=getGlobalFlagsFromArgs(client.argv.slice(2),{preserveProject:!0}),humanGlobalFlags=globalFlags.filter(flag=>!flag.startsWith("--non-interactive")),globalSuffix=globalFlags.length>0?` ${globalFlags.map(quoteArg).join(" ")}`:"",humanGlobalSuffix=humanGlobalFlags.length>0?` ${humanGlobalFlags.map(quoteArg).join(" ")}`:"",addCommand=publicPrefix===""?void 0:getCommandNamePlain(`env add ${privateName} ${addTargetArg}${addBranchArg} --type secret --value "<value>" --yes${globalSuffix}`),removeCommand=getCommandNamePlain(`env rm ${envName} ${removeTargetArg}${removeBranchArg} --yes${globalSuffix}`),addHumanCommand=publicPrefix===""?void 0:getCommandNamePlain(`env add ${privateName} ${addTargetArg}${addBranchArg} --type secret${humanGlobalSuffix}`),removeHumanCommand=getCommandNamePlain(`env rm ${envName} ${removeTargetArg}${removeBranchArg}${humanGlobalSuffix}`);return client.nonInteractive&&outputAgentError(client,{status:"error",reason:"invalid_type",message:publicPrefixError,next:addCommand?[{command:addCommand,when:"Add the private Secret; replace <value> before running"},{command:removeCommand,when:"Remove the public Config after the Secret is available"}]:[]},1),output_manager_default.fatal(publicPrefixError),addHumanCommand&&(output_manager_default.print(` Add the private Secret (prompts for the value):
|
|
2969
31
|
${addHumanCommand}
|
|
2970
|
-
`
|
|
2971
|
-
);
|
|
2972
|
-
output_manager_default.print(
|
|
2973
|
-
` Remove the public Config:
|
|
32
|
+
`),output_manager_default.print(` Remove the public Config:
|
|
2974
33
|
${removeHumanCommand}
|
|
2975
|
-
`
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
printEnvUpdateWarning(
|
|
2983
|
-
customSveltePublicPrefix === "" ? "This SvelteKit project uses an empty `publicPrefix`, so every Environment Variable is exposed to the browser." : `\`${customSveltePublicPrefix}\` variables are exposed to the browser by this SvelteKit project.`
|
|
2984
|
-
);
|
|
2985
|
-
}
|
|
2986
|
-
let teamSensitivePolicyOn = false;
|
|
2987
|
-
let disjunctiveProductionSecretPolicyOn = false;
|
|
2988
|
-
if (link.org.type === "team") {
|
|
2989
|
-
try {
|
|
2990
|
-
const team = await getTeamByIdOrSlug(client, link.org.id);
|
|
2991
|
-
teamSensitivePolicyOn = team?.sensitiveEnvironmentVariablePolicy === "on";
|
|
2992
|
-
disjunctiveProductionSecretPolicyOn = team?.disjunctiveProductionSecretPolicy === "on";
|
|
2993
|
-
} catch {
|
|
2994
|
-
}
|
|
2995
|
-
}
|
|
2996
|
-
let envValue;
|
|
2997
|
-
const shouldMaskValue = Boolean(opts["--sensitive"]) || explicitType === "secret" || explicitType === void 0 && selectedEnvIsSecret;
|
|
2998
|
-
if (stdInput) {
|
|
2999
|
-
const normalizedStdinValue = normalizeStdinEnvValue(stdInput);
|
|
3000
|
-
envValue = normalizedStdinValue.value;
|
|
3001
|
-
if (normalizedStdinValue.strippedTrailingNewline) {
|
|
3002
|
-
output_manager_default.log("Removed trailing newline from stdin input");
|
|
3003
|
-
}
|
|
3004
|
-
} else if (valueFromFlag !== void 0) {
|
|
3005
|
-
envValue = valueFromFlag;
|
|
3006
|
-
} else {
|
|
3007
|
-
if (client.nonInteractive) {
|
|
3008
|
-
const branchPart = envTargetArg === "preview" || envTargetArg === "development" ? " <gitbranch>" : "";
|
|
3009
|
-
const targetPart = envTargetArg || getEnvTargetPlaceholder();
|
|
3010
|
-
outputActionRequired(
|
|
3011
|
-
client,
|
|
3012
|
-
{
|
|
3013
|
-
status: "action_required",
|
|
3014
|
-
reason: "missing_value",
|
|
3015
|
-
message: 'In non-interactive mode, provide the new value with `--value` or stdin. Example: `vercel env update <name> <environment> --value "<value>" --yes`',
|
|
3016
|
-
next: [
|
|
3017
|
-
{
|
|
3018
|
-
command: buildEnvUpdateCommandWithPreservedArgs(
|
|
3019
|
-
client.argv,
|
|
3020
|
-
`env update ${envName} ${targetPart}${branchPart} --value <value> --yes`
|
|
3021
|
-
)
|
|
3022
|
-
}
|
|
3023
|
-
]
|
|
3024
|
-
},
|
|
3025
|
-
1
|
|
3026
|
-
);
|
|
3027
|
-
}
|
|
3028
|
-
envValue = await promptEnvUpdateValue(client, envName, shouldMaskValue);
|
|
3029
|
-
}
|
|
3030
|
-
const skipConfirm = opts["--yes"] || !!stdInput || valueFromFlag !== void 0;
|
|
3031
|
-
const { finalValue } = await validateEnvValue({
|
|
3032
|
-
envName,
|
|
3033
|
-
initialValue: envValue,
|
|
3034
|
-
skipConfirm,
|
|
3035
|
-
promptForValue: () => promptEnvUpdateValue(client, envName, shouldMaskValue),
|
|
3036
|
-
selectAction: (choices) => client.input.select({ message: "How to proceed?", choices }),
|
|
3037
|
-
showWarning: printEnvUpdateWarning,
|
|
3038
|
-
showLog: (msg) => output_manager_default.log(msg)
|
|
3039
|
-
});
|
|
3040
|
-
let type = opts["--sensitive"] || explicitType === "secret" ? "sensitive" : explicitType === "config" ? "encrypted" : selectedEnv.type;
|
|
3041
|
-
const isFinalSecret = () => type === "sensitive" || explicitType === void 0 && selectedEnvIsSecret;
|
|
3042
|
-
if (!isFinalSecret() && (type === "plain" || type === "encrypted") && (looksLikeCredentialName2(envName, customSveltePublicPrefix) || looksLikeSecretValue(finalValue))) {
|
|
3043
|
-
printEnvUpdateWarning(
|
|
3044
|
-
"This name or value looks like a credential. Config values can be revealed after saving."
|
|
3045
|
-
);
|
|
3046
|
-
const publicPrefix = apiPublicPrefix ?? frameworkPublicPrefix ?? customSveltePublicPrefix;
|
|
3047
|
-
if (publicPrefix !== null && publicPrefix !== void 0) {
|
|
3048
|
-
printEnvUpdateWarning(
|
|
3049
|
-
publicPrefix === "" ? "This SvelteKit project exposes every Environment Variable to the browser. Keep Config only if the value is safe to expose." : `\`${publicPrefix}\` exposes this value to anyone visiting your site. Keep Config only if the value is safe to expose.`
|
|
3050
|
-
);
|
|
3051
|
-
if (!typeWasExplicit && (opts["--yes"] || client.nonInteractive)) {
|
|
3052
|
-
const message = publicPrefix === "" ? "This SvelteKit project exposes every Environment Variable to the browser. To keep this value private, change the configured public prefix before storing it as Secret. If the value is safe to expose, rerun with `--type config`." : `\`${publicPrefix}\` exposes \`${envName}\` to anyone visiting your site. To keep this value private, add \`${envName.slice(
|
|
3053
|
-
publicPrefix.length
|
|
3054
|
-
)}\` as Secret, then remove \`${envName}\`. If the value is safe to expose, rerun with \`--type config\`.`;
|
|
3055
|
-
if (client.nonInteractive) {
|
|
3056
|
-
outputAgentError(
|
|
3057
|
-
client,
|
|
3058
|
-
{
|
|
3059
|
-
status: "error",
|
|
3060
|
-
reason: "unsafe_public_config",
|
|
3061
|
-
message
|
|
3062
|
-
},
|
|
3063
|
-
1
|
|
3064
|
-
);
|
|
3065
|
-
}
|
|
3066
|
-
output_manager_default.fatal(message);
|
|
3067
|
-
return 1;
|
|
3068
|
-
}
|
|
3069
|
-
if (publicPrefix !== "" && !typeWasExplicit && !opts["--yes"] && !client.nonInteractive) {
|
|
3070
|
-
const privateName = envName.slice(publicPrefix.length);
|
|
3071
|
-
const removeTargetArg = envTargetArg || targets[0] || allTargets[0] || getEnvTargetPlaceholder();
|
|
3072
|
-
const addTargetArg = formatTargetArg(allTargets, customEnvironments) || removeTargetArg;
|
|
3073
|
-
const removeBranchArg = selectedEnv.gitBranch ? ` ${quoteArg(selectedEnv.gitBranch)}` : "";
|
|
3074
|
-
const addBranchArg = selectedEnv.gitBranch ? ` --git-branch ${quoteArg(selectedEnv.gitBranch)}` : "";
|
|
3075
|
-
const humanGlobalFlags = getGlobalFlagsFromArgs(client.argv.slice(2), {
|
|
3076
|
-
preserveProject: true
|
|
3077
|
-
}).filter((flag) => !flag.startsWith("--non-interactive"));
|
|
3078
|
-
const humanGlobalSuffix = humanGlobalFlags.length > 0 ? ` ${humanGlobalFlags.map(quoteArg).join(" ")}` : "";
|
|
3079
|
-
const addPrivateCommand = getCommandNamePlain(
|
|
3080
|
-
`env add ${privateName} ${addTargetArg}${addBranchArg} --type secret${humanGlobalSuffix}`
|
|
3081
|
-
);
|
|
3082
|
-
const removePublicCommand = getCommandNamePlain(
|
|
3083
|
-
`env rm ${envName} ${removeTargetArg}${removeBranchArg}${humanGlobalSuffix}`
|
|
3084
|
-
);
|
|
3085
|
-
const selectedAction = await client.input.select({
|
|
3086
|
-
message: "How should this variable be stored?",
|
|
3087
|
-
choices: [
|
|
3088
|
-
{
|
|
3089
|
-
name: `Keep private: add ${privateName} as Secret, then remove ${envName}`,
|
|
3090
|
-
value: "private"
|
|
3091
|
-
},
|
|
3092
|
-
{
|
|
3093
|
-
name: `Expose to anyone visiting your site: keep ${envName} as Config`,
|
|
3094
|
-
value: "config"
|
|
3095
|
-
}
|
|
3096
|
-
]
|
|
3097
|
-
});
|
|
3098
|
-
if (selectedAction === "private") {
|
|
3099
|
-
output_manager_default.print(" Add the private Secret (prompts for the value):\n");
|
|
3100
|
-
output_manager_default.print(` ${addPrivateCommand}
|
|
3101
|
-
`);
|
|
3102
|
-
output_manager_default.print(" Remove the public Config:\n");
|
|
3103
|
-
output_manager_default.print(` ${removePublicCommand}
|
|
3104
|
-
`);
|
|
3105
|
-
return 1;
|
|
3106
|
-
}
|
|
3107
|
-
}
|
|
3108
|
-
} else if (!typeWasExplicit && !opts["--yes"] && !client.nonInteractive) {
|
|
3109
|
-
const selectedType = await client.input.select({
|
|
3110
|
-
message: "Store this value as?",
|
|
3111
|
-
choices: [
|
|
3112
|
-
{
|
|
3113
|
-
name: getSecretStorageChoice(targets, "for this value"),
|
|
3114
|
-
value: "secret"
|
|
3115
|
-
},
|
|
3116
|
-
{
|
|
3117
|
-
name: "Config (can be revealed after saving)",
|
|
3118
|
-
value: "config"
|
|
3119
|
-
}
|
|
3120
|
-
]
|
|
3121
|
-
});
|
|
3122
|
-
if (selectedType === "secret") {
|
|
3123
|
-
type = "sensitive";
|
|
3124
|
-
explicitType = "secret";
|
|
3125
|
-
}
|
|
3126
|
-
} else if (!typeWasExplicit) {
|
|
3127
|
-
printEnvUpdateWarning("Re-run with `--type secret` to protect it.");
|
|
3128
|
-
}
|
|
3129
|
-
}
|
|
3130
|
-
if (isFinalSecret() && !selectedEnvIsSecret) {
|
|
3131
|
-
printEnvUpdateWarning(
|
|
3132
|
-
"The previous value was readable as Config and may have been exposed. If this variable still holds the same credential, rotate it at its provider and update this variable again."
|
|
3133
|
-
);
|
|
3134
|
-
}
|
|
3135
|
-
const finalPublicPrefix = apiPublicPrefix ?? frameworkPublicPrefix ?? customSveltePublicPrefix;
|
|
3136
|
-
if (isFinalSecret() && finalPublicPrefix !== null && finalPublicPrefix !== void 0) {
|
|
3137
|
-
printEnvUpdateWarning(
|
|
3138
|
-
finalPublicPrefix === "" ? "This SvelteKit project exposes every Environment Variable to the browser; the Secret type does not prevent that. Change the configured public prefix to keep values private." : `\`${finalPublicPrefix}\` exposes this variable to the browser; the Secret type does not prevent that. Rename the variable without the public prefix to keep it private.`
|
|
3139
|
-
);
|
|
3140
|
-
}
|
|
3141
|
-
if (isFinalSecret() && disjunctiveProductionSecretPolicyOn && targets.includes("production") && allTargets.some((target) => target !== "production")) {
|
|
3142
|
-
const message = "Your team requires Production and non-Production Secrets to be stored separately with different values. Create separate variables with different values before converting this one.";
|
|
3143
|
-
if (client.nonInteractive) {
|
|
3144
|
-
outputAgentError(
|
|
3145
|
-
client,
|
|
3146
|
-
{
|
|
3147
|
-
status: "error",
|
|
3148
|
-
reason: "production_secret_must_be_separate",
|
|
3149
|
-
message
|
|
3150
|
-
},
|
|
3151
|
-
1
|
|
3152
|
-
);
|
|
3153
|
-
}
|
|
3154
|
-
output_manager_default.fatal(message);
|
|
3155
|
-
return 1;
|
|
3156
|
-
}
|
|
3157
|
-
const preserveExistingVisibility = explicitType === void 0 && selectedEnv.visibility === "secret" && type !== "sensitive";
|
|
3158
|
-
const { visibility: resolvedVisibility, error: visibilityError } = resolveEnvVarVisibility({
|
|
3159
|
-
explicitVisibility: typeOption.source ? explicitType : void 0,
|
|
3160
|
-
explicitOptionSource: typeOption.source,
|
|
3161
|
-
type,
|
|
3162
|
-
key: envName,
|
|
3163
|
-
envTargets: allTargets,
|
|
3164
|
-
teamSensitivePolicyOn,
|
|
3165
|
-
context: "update"
|
|
3166
|
-
});
|
|
3167
|
-
const visibility = preserveExistingVisibility ? void 0 : resolvedVisibility;
|
|
3168
|
-
const displayVisibility = preserveExistingVisibility ? selectedEnv.visibility : visibility;
|
|
3169
|
-
if (visibilityError) {
|
|
3170
|
-
if (client.nonInteractive) {
|
|
3171
|
-
outputAgentError(
|
|
3172
|
-
client,
|
|
3173
|
-
{
|
|
3174
|
-
status: "error",
|
|
3175
|
-
reason: "invalid_type",
|
|
3176
|
-
message: visibilityError
|
|
3177
|
-
},
|
|
3178
|
-
1
|
|
3179
|
-
);
|
|
3180
|
-
}
|
|
3181
|
-
output_manager_default.fatal(visibilityError);
|
|
3182
|
-
return 1;
|
|
3183
|
-
}
|
|
3184
|
-
if (!opts["--yes"]) {
|
|
3185
|
-
const visibilityLabel2 = formatVisibilityLabel(displayVisibility, type);
|
|
3186
|
-
if (client.nonInteractive) {
|
|
3187
|
-
outputActionRequired(
|
|
3188
|
-
client,
|
|
3189
|
-
{
|
|
3190
|
-
status: "action_required",
|
|
3191
|
-
reason: "confirmation_required",
|
|
3192
|
-
message: `Update ${envName} as ${visibilityLabel2} in ${formatEnvironments(
|
|
3193
|
-
link,
|
|
3194
|
-
selectedEnv,
|
|
3195
|
-
customEnvironments
|
|
3196
|
-
)}? Use --yes to confirm.`,
|
|
3197
|
-
next: [
|
|
3198
|
-
{
|
|
3199
|
-
command: buildCommandWithYes(redactEnvValueArgs(client.argv))
|
|
3200
|
-
}
|
|
3201
|
-
]
|
|
3202
|
-
},
|
|
3203
|
-
1
|
|
3204
|
-
);
|
|
3205
|
-
}
|
|
3206
|
-
output_manager_default.print("\n");
|
|
3207
|
-
printAlignedLabel("Project", `${link.org.slug}/${project.name}`);
|
|
3208
|
-
printAlignedLabel(
|
|
3209
|
-
"Environments",
|
|
3210
|
-
formatEnvironments(link, selectedEnv, customEnvironments)
|
|
3211
|
-
);
|
|
3212
|
-
if (visibilityLabel2) {
|
|
3213
|
-
printAlignedLabel("Type", visibilityLabel2);
|
|
3214
|
-
}
|
|
3215
|
-
const confirmed = await client.input.confirm(
|
|
3216
|
-
"Update this Environment Variable?",
|
|
3217
|
-
false
|
|
3218
|
-
);
|
|
3219
|
-
if (!confirmed) {
|
|
3220
|
-
output_manager_default.log("Canceled");
|
|
3221
|
-
return 0;
|
|
3222
|
-
}
|
|
3223
|
-
}
|
|
3224
|
-
try {
|
|
3225
|
-
output_manager_default.spinner("Updating");
|
|
3226
|
-
const keyToUpdate = isFinalSecret() ? void 0 : envName;
|
|
3227
|
-
await updateEnvRecord(
|
|
3228
|
-
client,
|
|
3229
|
-
project.id,
|
|
3230
|
-
selectedEnv.id,
|
|
3231
|
-
type,
|
|
3232
|
-
keyToUpdate,
|
|
3233
|
-
finalValue,
|
|
3234
|
-
allTargets,
|
|
3235
|
-
selectedEnv.gitBranch || "",
|
|
3236
|
-
visibility
|
|
3237
|
-
);
|
|
3238
|
-
} catch (err) {
|
|
3239
|
-
if (client.nonInteractive && isAPIError(err)) {
|
|
3240
|
-
const productionSecretPolicyError = getProductionSecretPolicyErrorKind(
|
|
3241
|
-
err.serverMessage
|
|
3242
|
-
);
|
|
3243
|
-
const reason = productionSecretPolicyError ? productionSecretPolicyError === "different-values" ? "production_secret_requires_different_value" : "production_secret_must_be_separate" : err.slug || (err.serverMessage?.toLowerCase().includes("branch") ? "branch_not_found" : "api_error");
|
|
3244
|
-
outputAgentError(
|
|
3245
|
-
client,
|
|
3246
|
-
{
|
|
3247
|
-
status: "error",
|
|
3248
|
-
reason,
|
|
3249
|
-
message: productionSecretPolicyError ? `${err.serverMessage} ${getProductionSecretPolicyRecovery(
|
|
3250
|
-
productionSecretPolicyError
|
|
3251
|
-
)}` : err.serverMessage
|
|
3252
|
-
},
|
|
3253
|
-
1
|
|
3254
|
-
);
|
|
3255
|
-
}
|
|
3256
|
-
if (isAPIError(err) && isKnownError(err)) {
|
|
3257
|
-
output_manager_default.error(err.serverMessage);
|
|
3258
|
-
return 1;
|
|
3259
|
-
}
|
|
3260
|
-
throw err;
|
|
3261
|
-
}
|
|
3262
|
-
output_manager_default.print("\n");
|
|
3263
|
-
printAlignedLabel("Updated", envName, { gutter: "\u2713" });
|
|
3264
|
-
printAlignedLabel("Project", `${link.org.slug}/${project.name}`);
|
|
3265
|
-
printAlignedLabel(
|
|
3266
|
-
"Environments",
|
|
3267
|
-
formatEnvironments(link, selectedEnv, customEnvironments)
|
|
3268
|
-
);
|
|
3269
|
-
const visibilityLabel = formatVisibilityLabel(displayVisibility, type);
|
|
3270
|
-
if (visibilityLabel) {
|
|
3271
|
-
printAlignedLabel("Type", visibilityLabel);
|
|
3272
|
-
}
|
|
3273
|
-
return 0;
|
|
3274
|
-
}
|
|
3275
|
-
|
|
3276
|
-
// src/util/telemetry/commands/env/index.ts
|
|
3277
|
-
var EnvTelemetryClient = class extends TelemetryClient {
|
|
3278
|
-
trackCliSubcommandList(actual) {
|
|
3279
|
-
this.trackCliSubcommand({
|
|
3280
|
-
subcommand: "ls",
|
|
3281
|
-
value: actual
|
|
3282
|
-
});
|
|
3283
|
-
}
|
|
3284
|
-
trackCliSubcommandAdd(actual) {
|
|
3285
|
-
this.trackCliSubcommand({
|
|
3286
|
-
subcommand: "add",
|
|
3287
|
-
value: actual
|
|
3288
|
-
});
|
|
3289
|
-
}
|
|
3290
|
-
trackCliSubcommandRemove(actual) {
|
|
3291
|
-
this.trackCliSubcommand({
|
|
3292
|
-
subcommand: "rm",
|
|
3293
|
-
value: actual
|
|
3294
|
-
});
|
|
3295
|
-
}
|
|
3296
|
-
trackCliSubcommandPull(actual) {
|
|
3297
|
-
this.trackCliSubcommand({
|
|
3298
|
-
subcommand: "pull",
|
|
3299
|
-
value: actual
|
|
3300
|
-
});
|
|
3301
|
-
}
|
|
3302
|
-
trackCliSubcommandRun(actual) {
|
|
3303
|
-
this.trackCliSubcommand({
|
|
3304
|
-
subcommand: "run",
|
|
3305
|
-
value: actual
|
|
3306
|
-
});
|
|
3307
|
-
}
|
|
3308
|
-
trackCliSubcommandUpdate(actual) {
|
|
3309
|
-
this.trackCliSubcommand({
|
|
3310
|
-
subcommand: "update",
|
|
3311
|
-
value: actual
|
|
3312
|
-
});
|
|
3313
|
-
}
|
|
3314
|
-
};
|
|
3315
|
-
|
|
3316
|
-
// src/commands/env/index.ts
|
|
3317
|
-
var COMMAND_CONFIG = {
|
|
3318
|
-
ls: getCommandAliases(listSubcommand),
|
|
3319
|
-
add: getCommandAliases(addSubcommand),
|
|
3320
|
-
rm: getCommandAliases(removeSubcommand),
|
|
3321
|
-
pull: getCommandAliases(pullSubcommand),
|
|
3322
|
-
run: getCommandAliases(runSubcommand),
|
|
3323
|
-
update: getCommandAliases(updateSubcommand)
|
|
3324
|
-
};
|
|
3325
|
-
async function main(client) {
|
|
3326
|
-
const telemetry = new EnvTelemetryClient({
|
|
3327
|
-
opts: {
|
|
3328
|
-
store: client.telemetryEventStore
|
|
3329
|
-
}
|
|
3330
|
-
});
|
|
3331
|
-
let parsedArgs;
|
|
3332
|
-
const flagsSpecification = getFlagsSpecification(envCommand.options);
|
|
3333
|
-
try {
|
|
3334
|
-
parsedArgs = parseArguments(client.argv.slice(2), flagsSpecification, {
|
|
3335
|
-
permissive: true
|
|
3336
|
-
});
|
|
3337
|
-
} catch (err) {
|
|
3338
|
-
printError(err);
|
|
3339
|
-
return 1;
|
|
3340
|
-
}
|
|
3341
|
-
const subArgs = parsedArgs.args.slice(1);
|
|
3342
|
-
const { subcommand, args, subcommandOriginal } = getSubcommand(
|
|
3343
|
-
subArgs,
|
|
3344
|
-
COMMAND_CONFIG
|
|
3345
|
-
);
|
|
3346
|
-
const needHelp = parsedArgs.flags["--help"];
|
|
3347
|
-
if (!subcommand && needHelp) {
|
|
3348
|
-
telemetry.trackCliFlagHelp("env", subcommand);
|
|
3349
|
-
output_manager_default.print(help(envCommand, { columns: client.stderr.columns }));
|
|
3350
|
-
return 2;
|
|
3351
|
-
}
|
|
3352
|
-
function printHelp(command) {
|
|
3353
|
-
output_manager_default.print(
|
|
3354
|
-
help(command, { parent: envCommand, columns: client.stderr.columns })
|
|
3355
|
-
);
|
|
3356
|
-
}
|
|
3357
|
-
let exitCode;
|
|
3358
|
-
switch (subcommand) {
|
|
3359
|
-
case "ls":
|
|
3360
|
-
if (needHelp) {
|
|
3361
|
-
telemetry.trackCliFlagHelp("env", subcommandOriginal);
|
|
3362
|
-
printHelp(listSubcommand);
|
|
3363
|
-
return 2;
|
|
3364
|
-
}
|
|
3365
|
-
telemetry.trackCliSubcommandList(subcommandOriginal);
|
|
3366
|
-
exitCode = await ls(client, args);
|
|
3367
|
-
break;
|
|
3368
|
-
case "add":
|
|
3369
|
-
if (needHelp) {
|
|
3370
|
-
telemetry.trackCliFlagHelp("env", subcommandOriginal);
|
|
3371
|
-
printHelp(addSubcommand);
|
|
3372
|
-
return 2;
|
|
3373
|
-
}
|
|
3374
|
-
telemetry.trackCliSubcommandAdd(subcommandOriginal);
|
|
3375
|
-
exitCode = await add(client, args);
|
|
3376
|
-
break;
|
|
3377
|
-
case "rm":
|
|
3378
|
-
if (needHelp) {
|
|
3379
|
-
telemetry.trackCliFlagHelp("env", subcommandOriginal);
|
|
3380
|
-
printHelp(removeSubcommand);
|
|
3381
|
-
return 2;
|
|
3382
|
-
}
|
|
3383
|
-
telemetry.trackCliSubcommandRemove(subcommandOriginal);
|
|
3384
|
-
exitCode = await rm(client, args);
|
|
3385
|
-
break;
|
|
3386
|
-
case "pull":
|
|
3387
|
-
if (needHelp) {
|
|
3388
|
-
telemetry.trackCliFlagHelp("env", subcommandOriginal);
|
|
3389
|
-
printHelp(pullSubcommand);
|
|
3390
|
-
return 2;
|
|
3391
|
-
}
|
|
3392
|
-
telemetry.trackCliSubcommandPull(subcommandOriginal);
|
|
3393
|
-
exitCode = await pull(client, args);
|
|
3394
|
-
break;
|
|
3395
|
-
case "run":
|
|
3396
|
-
if (needsHelpForRun(client)) {
|
|
3397
|
-
telemetry.trackCliFlagHelp("env", subcommandOriginal);
|
|
3398
|
-
printHelp(runSubcommand);
|
|
3399
|
-
return 2;
|
|
3400
|
-
}
|
|
3401
|
-
telemetry.trackCliSubcommandRun(subcommandOriginal);
|
|
3402
|
-
exitCode = await run(client, telemetry);
|
|
3403
|
-
break;
|
|
3404
|
-
case "update":
|
|
3405
|
-
if (needHelp) {
|
|
3406
|
-
telemetry.trackCliFlagHelp("env", subcommandOriginal);
|
|
3407
|
-
printHelp(updateSubcommand);
|
|
3408
|
-
return 2;
|
|
3409
|
-
}
|
|
3410
|
-
telemetry.trackCliSubcommandUpdate(subcommandOriginal);
|
|
3411
|
-
exitCode = await update(client, args);
|
|
3412
|
-
break;
|
|
3413
|
-
default:
|
|
3414
|
-
output_manager_default.error(getInvalidSubcommand(COMMAND_CONFIG));
|
|
3415
|
-
output_manager_default.print(help(envCommand, { columns: client.stderr.columns }));
|
|
3416
|
-
return 2;
|
|
3417
|
-
}
|
|
3418
|
-
if (exitCode === 0) {
|
|
3419
|
-
await autoInstallVercelPlugin(client);
|
|
3420
|
-
}
|
|
3421
|
-
return exitCode;
|
|
3422
|
-
}
|
|
3423
|
-
export {
|
|
3424
|
-
main as default
|
|
3425
|
-
};
|
|
34
|
+
`)),1}}customSveltePublicPrefix!==void 0&&printEnvUpdateWarning(customSveltePublicPrefix===""?"This SvelteKit project uses an empty `publicPrefix`, so every Environment Variable is exposed to the browser.":`\`${customSveltePublicPrefix}\` variables are exposed to the browser by this SvelteKit project.`);let teamSensitivePolicyOn=!1,disjunctiveProductionSecretPolicyOn=!1;if(link.org.type==="team")try{let team=await getTeamByIdOrSlug(client,link.org.id);teamSensitivePolicyOn=team?.sensitiveEnvironmentVariablePolicy==="on",disjunctiveProductionSecretPolicyOn=team?.disjunctiveProductionSecretPolicy==="on"}catch{}let envValue,shouldMaskValue=!!opts["--sensitive"]||explicitType==="secret"||explicitType===void 0&&selectedEnvIsSecret;if(stdInput){let normalizedStdinValue=normalizeStdinEnvValue(stdInput);envValue=normalizedStdinValue.value,normalizedStdinValue.strippedTrailingNewline&&output_manager_default.log("Removed trailing newline from stdin input")}else if(valueFromFlag!==void 0)envValue=valueFromFlag;else{if(client.nonInteractive){let branchPart=envTargetArg==="preview"||envTargetArg==="development"?" <gitbranch>":"",targetPart=envTargetArg||getEnvTargetPlaceholder();outputActionRequired(client,{status:"action_required",reason:"missing_value",message:'In non-interactive mode, provide the new value with `--value` or stdin. Example: `vercel env update <name> <environment> --value "<value>" --yes`',next:[{command:buildEnvUpdateCommandWithPreservedArgs(client.argv,`env update ${envName} ${targetPart}${branchPart} --value <value> --yes`)}]},1)}envValue=await promptEnvUpdateValue(client,envName,shouldMaskValue)}let skipConfirm=opts["--yes"]||!!stdInput||valueFromFlag!==void 0,{finalValue}=await validateEnvValue({envName,initialValue:envValue,skipConfirm,promptForValue:()=>promptEnvUpdateValue(client,envName,shouldMaskValue),selectAction:choices=>client.input.select({message:"How to proceed?",choices}),showWarning:printEnvUpdateWarning,showLog:msg=>output_manager_default.log(msg)}),type=opts["--sensitive"]||explicitType==="secret"?"sensitive":explicitType==="config"?"encrypted":selectedEnv.type,isFinalSecret=()=>type==="sensitive"||explicitType===void 0&&selectedEnvIsSecret;if(!isFinalSecret()&&(type==="plain"||type==="encrypted")&&(looksLikeCredentialName2(envName,customSveltePublicPrefix)||looksLikeSecretValue(finalValue))){printEnvUpdateWarning("This name or value looks like a credential. Config values can be revealed after saving.");let publicPrefix=apiPublicPrefix??frameworkPublicPrefix??customSveltePublicPrefix;if(publicPrefix!=null){if(printEnvUpdateWarning(publicPrefix===""?"This SvelteKit project exposes every Environment Variable to the browser. Keep Config only if the value is safe to expose.":`\`${publicPrefix}\` exposes this value to anyone visiting your site. Keep Config only if the value is safe to expose.`),!typeWasExplicit&&(opts["--yes"]||client.nonInteractive)){let message=publicPrefix===""?"This SvelteKit project exposes every Environment Variable to the browser. To keep this value private, change the configured public prefix before storing it as Secret. If the value is safe to expose, rerun with `--type config`.":`\`${publicPrefix}\` exposes \`${envName}\` to anyone visiting your site. To keep this value private, add \`${envName.slice(publicPrefix.length)}\` as Secret, then remove \`${envName}\`. If the value is safe to expose, rerun with \`--type config\`.`;return client.nonInteractive&&outputAgentError(client,{status:"error",reason:"unsafe_public_config",message},1),output_manager_default.fatal(message),1}if(publicPrefix!==""&&!typeWasExplicit&&!opts["--yes"]&&!client.nonInteractive){let privateName=envName.slice(publicPrefix.length),removeTargetArg=envTargetArg||targets[0]||allTargets[0]||getEnvTargetPlaceholder(),addTargetArg=formatTargetArg(allTargets,customEnvironments)||removeTargetArg,removeBranchArg=selectedEnv.gitBranch?` ${quoteArg(selectedEnv.gitBranch)}`:"",addBranchArg=selectedEnv.gitBranch?` --git-branch ${quoteArg(selectedEnv.gitBranch)}`:"",humanGlobalFlags=getGlobalFlagsFromArgs(client.argv.slice(2),{preserveProject:!0}).filter(flag=>!flag.startsWith("--non-interactive")),humanGlobalSuffix=humanGlobalFlags.length>0?` ${humanGlobalFlags.map(quoteArg).join(" ")}`:"",addPrivateCommand=getCommandNamePlain(`env add ${privateName} ${addTargetArg}${addBranchArg} --type secret${humanGlobalSuffix}`),removePublicCommand=getCommandNamePlain(`env rm ${envName} ${removeTargetArg}${removeBranchArg}${humanGlobalSuffix}`);if(await client.input.select({message:"How should this variable be stored?",choices:[{name:`Keep private: add ${privateName} as Secret, then remove ${envName}`,value:"private"},{name:`Expose to anyone visiting your site: keep ${envName} as Config`,value:"config"}]})==="private")return output_manager_default.print(` Add the private Secret (prompts for the value):
|
|
35
|
+
`),output_manager_default.print(` ${addPrivateCommand}
|
|
36
|
+
`),output_manager_default.print(` Remove the public Config:
|
|
37
|
+
`),output_manager_default.print(` ${removePublicCommand}
|
|
38
|
+
`),1}}else!typeWasExplicit&&!opts["--yes"]&&!client.nonInteractive?await client.input.select({message:"Store this value as?",choices:[{name:getSecretStorageChoice(targets,"for this value"),value:"secret"},{name:"Config (can be revealed after saving)",value:"config"}]})==="secret"&&(type="sensitive",explicitType="secret"):typeWasExplicit||printEnvUpdateWarning("Re-run with `--type secret` to protect it.")}isFinalSecret()&&!selectedEnvIsSecret&&printEnvUpdateWarning("The previous value was readable as Config and may have been exposed. If this variable still holds the same credential, rotate it at its provider and update this variable again.");let finalPublicPrefix=apiPublicPrefix??frameworkPublicPrefix??customSveltePublicPrefix;if(isFinalSecret()&&finalPublicPrefix!==null&&finalPublicPrefix!==void 0&&printEnvUpdateWarning(finalPublicPrefix===""?"This SvelteKit project exposes every Environment Variable to the browser; the Secret type does not prevent that. Change the configured public prefix to keep values private.":`\`${finalPublicPrefix}\` exposes this variable to the browser; the Secret type does not prevent that. Rename the variable without the public prefix to keep it private.`),isFinalSecret()&&disjunctiveProductionSecretPolicyOn&&targets.includes("production")&&allTargets.some(target=>target!=="production")){let message="Your team requires Production and non-Production Secrets to be stored separately with different values. Create separate variables with different values before converting this one.";return client.nonInteractive&&outputAgentError(client,{status:"error",reason:"production_secret_must_be_separate",message},1),output_manager_default.fatal(message),1}let preserveExistingVisibility=explicitType===void 0&&selectedEnv.visibility==="secret"&&type!=="sensitive",{visibility:resolvedVisibility,error:visibilityError}=resolveEnvVarVisibility({explicitVisibility:typeOption.source?explicitType:void 0,explicitOptionSource:typeOption.source,type,key:envName,envTargets:allTargets,teamSensitivePolicyOn,context:"update"}),visibility=preserveExistingVisibility?void 0:resolvedVisibility,displayVisibility=preserveExistingVisibility?selectedEnv.visibility:visibility;if(visibilityError)return client.nonInteractive&&outputAgentError(client,{status:"error",reason:"invalid_type",message:visibilityError},1),output_manager_default.fatal(visibilityError),1;if(!opts["--yes"]){let visibilityLabel2=formatVisibilityLabel(displayVisibility,type);if(client.nonInteractive&&outputActionRequired(client,{status:"action_required",reason:"confirmation_required",message:`Update ${envName} as ${visibilityLabel2} in ${formatEnvironments(link,selectedEnv,customEnvironments)}? Use --yes to confirm.`,next:[{command:buildCommandWithYes(redactEnvValueArgs(client.argv))}]},1),output_manager_default.print(`
|
|
39
|
+
`),printAlignedLabel("Project",`${link.org.slug}/${project.name}`),printAlignedLabel("Environments",formatEnvironments(link,selectedEnv,customEnvironments)),visibilityLabel2&&printAlignedLabel("Type",visibilityLabel2),!await client.input.confirm("Update this Environment Variable?",!1))return output_manager_default.log("Canceled"),0}try{output_manager_default.spinner("Updating");let keyToUpdate=isFinalSecret()?void 0:envName;await updateEnvRecord(client,project.id,selectedEnv.id,type,keyToUpdate,finalValue,allTargets,selectedEnv.gitBranch||"",visibility)}catch(err){if(client.nonInteractive&&isAPIError(err)){let productionSecretPolicyError=getProductionSecretPolicyErrorKind(err.serverMessage),reason=productionSecretPolicyError?productionSecretPolicyError==="different-values"?"production_secret_requires_different_value":"production_secret_must_be_separate":err.slug||(err.serverMessage?.toLowerCase().includes("branch")?"branch_not_found":"api_error");outputAgentError(client,{status:"error",reason,message:productionSecretPolicyError?`${err.serverMessage} ${getProductionSecretPolicyRecovery(productionSecretPolicyError)}`:err.serverMessage},1)}if(isAPIError(err)&&isKnownError(err))return output_manager_default.error(err.serverMessage),1;throw err}output_manager_default.print(`
|
|
40
|
+
`),printAlignedLabel("Updated",envName,{gutter:"\u2713"}),printAlignedLabel("Project",`${link.org.slug}/${project.name}`),printAlignedLabel("Environments",formatEnvironments(link,selectedEnv,customEnvironments));let visibilityLabel=formatVisibilityLabel(displayVisibility,type);return visibilityLabel&&printAlignedLabel("Type",visibilityLabel),0}var EnvTelemetryClient=class extends TelemetryClient{trackCliSubcommandList(actual){this.trackCliSubcommand({subcommand:"ls",value:actual})}trackCliSubcommandAdd(actual){this.trackCliSubcommand({subcommand:"add",value:actual})}trackCliSubcommandRemove(actual){this.trackCliSubcommand({subcommand:"rm",value:actual})}trackCliSubcommandPull(actual){this.trackCliSubcommand({subcommand:"pull",value:actual})}trackCliSubcommandRun(actual){this.trackCliSubcommand({subcommand:"run",value:actual})}trackCliSubcommandUpdate(actual){this.trackCliSubcommand({subcommand:"update",value:actual})}};var COMMAND_CONFIG={ls:getCommandAliases(listSubcommand),add:getCommandAliases(addSubcommand),rm:getCommandAliases(removeSubcommand),pull:getCommandAliases(pullSubcommand),run:getCommandAliases(runSubcommand),update:getCommandAliases(updateSubcommand)};async function main(client){let telemetry=new EnvTelemetryClient({opts:{store:client.telemetryEventStore}}),parsedArgs,flagsSpecification=getFlagsSpecification(envCommand.options);try{parsedArgs=parseArguments(client.argv.slice(2),flagsSpecification,{permissive:!0})}catch(err){return printError(err),1}let subArgs=parsedArgs.args.slice(1),{subcommand,args,subcommandOriginal}=getSubcommand(subArgs,COMMAND_CONFIG),needHelp=parsedArgs.flags["--help"];if(!subcommand&&needHelp)return telemetry.trackCliFlagHelp("env",subcommand),output_manager_default.print(help(envCommand,{columns:client.stderr.columns})),2;function printHelp(command){output_manager_default.print(help(command,{parent:envCommand,columns:client.stderr.columns}))}let exitCode;switch(subcommand){case"ls":if(needHelp)return telemetry.trackCliFlagHelp("env",subcommandOriginal),printHelp(listSubcommand),2;telemetry.trackCliSubcommandList(subcommandOriginal),exitCode=await ls(client,args);break;case"add":if(needHelp)return telemetry.trackCliFlagHelp("env",subcommandOriginal),printHelp(addSubcommand),2;telemetry.trackCliSubcommandAdd(subcommandOriginal),exitCode=await add(client,args);break;case"rm":if(needHelp)return telemetry.trackCliFlagHelp("env",subcommandOriginal),printHelp(removeSubcommand),2;telemetry.trackCliSubcommandRemove(subcommandOriginal),exitCode=await rm(client,args);break;case"pull":if(needHelp)return telemetry.trackCliFlagHelp("env",subcommandOriginal),printHelp(pullSubcommand),2;telemetry.trackCliSubcommandPull(subcommandOriginal),exitCode=await pull(client,args);break;case"run":if(needsHelpForRun(client))return telemetry.trackCliFlagHelp("env",subcommandOriginal),printHelp(runSubcommand),2;telemetry.trackCliSubcommandRun(subcommandOriginal),exitCode=await run(client,telemetry);break;case"update":if(needHelp)return telemetry.trackCliFlagHelp("env",subcommandOriginal),printHelp(updateSubcommand),2;telemetry.trackCliSubcommandUpdate(subcommandOriginal),exitCode=await update(client,args);break;default:return output_manager_default.error(getInvalidSubcommand(COMMAND_CONFIG)),output_manager_default.print(help(envCommand,{columns:client.stderr.columns})),2}return exitCode===0&&await autoInstallVercelPlugin(client),exitCode}export{main as default};
|