@velastack/patterns 0.7.0 → 0.7.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/README.md +4 -3
- package/dist/chunks/{_layout-Bsx3eNrC.js → _layout-DQhSAhfF.js} +2 -2
- package/dist/chunks/{_layout-Bsx3eNrC.js.map → _layout-DQhSAhfF.js.map} +1 -1
- package/dist/chunks/{collections-DrUG8ngq.js → collections-BYcVyY9O.js} +2 -2
- package/dist/chunks/{collections-DrUG8ngq.js.map → collections-BYcVyY9O.js.map} +1 -1
- package/dist/chunks/constants-Bdx8mp7v.js +6 -0
- package/dist/chunks/constants-Bdx8mp7v.js.map +1 -0
- package/dist/chunks/{env-vars-CdarYsrc.js → env-vars-0hvKe55u.js} +3 -3
- package/dist/chunks/{env-vars-CdarYsrc.js.map → env-vars-0hvKe55u.js.map} +1 -1
- package/dist/chunks/{generate-BxOzEdc_.js → generate-BOQA-Flq.js} +2 -2
- package/dist/chunks/{generate-BxOzEdc_.js.map → generate-BOQA-Flq.js.map} +1 -1
- package/dist/chunks/{generate-27CjLiGW.js → generate-CNabcEBx.js} +2 -2
- package/dist/chunks/{generate-27CjLiGW.js.map → generate-CNabcEBx.js.map} +1 -1
- package/dist/chunks/{generate-DdLwP0E7.js → generate-CO88bEvs.js} +2 -2
- package/dist/chunks/{generate-DdLwP0E7.js.map → generate-CO88bEvs.js.map} +1 -1
- package/dist/chunks/{generate-BFcy2wrS.js → generate-Df7t5Nbk.js} +3 -3
- package/dist/chunks/{generate-BFcy2wrS.js.map → generate-Df7t5Nbk.js.map} +1 -1
- package/dist/chunks/{generate-Cqwa8kD9.js → generate-DoHn_xJZ.js} +2 -2
- package/dist/chunks/{generate-Cqwa8kD9.js.map → generate-DoHn_xJZ.js.map} +1 -1
- package/dist/chunks/{generate-D3mSFPdT.js → generate-l2JZTRKb.js} +2 -2
- package/dist/chunks/{generate-D3mSFPdT.js.map → generate-l2JZTRKb.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DMTAocSE.js → generate.runtime-1ldXcpiD.js} +3 -3
- package/dist/chunks/{generate.runtime-DMTAocSE.js.map → generate.runtime-1ldXcpiD.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DIeAeOJg.js → generate.runtime-B53OTMcE.js} +4 -4
- package/dist/chunks/{generate.runtime-DIeAeOJg.js.map → generate.runtime-B53OTMcE.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BJxM7FNA.js → generate.runtime-B84ymwlD.js} +4 -4
- package/dist/chunks/{generate.runtime-BJxM7FNA.js.map → generate.runtime-B84ymwlD.js.map} +1 -1
- package/dist/chunks/{generate.runtime-9KuMcI5r.js → generate.runtime-BOl3LpPB.js} +3 -3
- package/dist/chunks/{generate.runtime-9KuMcI5r.js.map → generate.runtime-BOl3LpPB.js.map} +1 -1
- package/dist/chunks/{generate.runtime-NxuWvkKt.js → generate.runtime-BP31tAcD.js} +4 -4
- package/dist/chunks/{generate.runtime-NxuWvkKt.js.map → generate.runtime-BP31tAcD.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DlLwmjGF.js → generate.runtime-BoYwV0nt.js} +3 -3
- package/dist/chunks/{generate.runtime-DlLwmjGF.js.map → generate.runtime-BoYwV0nt.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CIZO2XO9.js → generate.runtime-BqCbJ-No.js} +3 -3
- package/dist/chunks/{generate.runtime-CIZO2XO9.js.map → generate.runtime-BqCbJ-No.js.map} +1 -1
- package/dist/chunks/{generate.runtime-ww3-1FWf.js → generate.runtime-Bvjj3zn0.js} +3 -3
- package/dist/chunks/{generate.runtime-ww3-1FWf.js.map → generate.runtime-Bvjj3zn0.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CK0MTeqc.js → generate.runtime-ByPcr9vJ.js} +3 -3
- package/dist/chunks/{generate.runtime-CK0MTeqc.js.map → generate.runtime-ByPcr9vJ.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CMO-Skpk.js → generate.runtime-C4LUUuq7.js} +3 -3
- package/dist/chunks/{generate.runtime-CMO-Skpk.js.map → generate.runtime-C4LUUuq7.js.map} +1 -1
- package/dist/chunks/{generate.runtime-B10-KA87.js → generate.runtime-CGjDfO1P.js} +4 -4
- package/dist/chunks/{generate.runtime-B10-KA87.js.map → generate.runtime-CGjDfO1P.js.map} +1 -1
- package/dist/chunks/{generate.runtime-dFTOU_KE.js → generate.runtime-CHQ_MQJQ.js} +4 -4
- package/dist/chunks/{generate.runtime-dFTOU_KE.js.map → generate.runtime-CHQ_MQJQ.js.map} +1 -1
- package/dist/chunks/{generate.runtime-D5HxAups.js → generate.runtime-CHS5lyHL.js} +6 -6
- package/dist/chunks/{generate.runtime-D5HxAups.js.map → generate.runtime-CHS5lyHL.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BdghkfNp.js → generate.runtime-CHUCMVa2.js} +2 -2
- package/dist/chunks/{generate.runtime-BdghkfNp.js.map → generate.runtime-CHUCMVa2.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DtCaz98N.js → generate.runtime-CVWCUn52.js} +4 -4
- package/dist/chunks/{generate.runtime-DtCaz98N.js.map → generate.runtime-CVWCUn52.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CbT-EbQT.js → generate.runtime-Cv3unKap.js} +3 -3
- package/dist/chunks/{generate.runtime-CbT-EbQT.js.map → generate.runtime-Cv3unKap.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CVDb-yLt.js → generate.runtime-D677SB4v.js} +2 -2
- package/dist/chunks/{generate.runtime-CVDb-yLt.js.map → generate.runtime-D677SB4v.js.map} +1 -1
- package/dist/chunks/{generate.runtime-B_tWu-Bw.js → generate.runtime-DERcpgc-.js} +4 -4
- package/dist/chunks/{generate.runtime-B_tWu-Bw.js.map → generate.runtime-DERcpgc-.js.map} +1 -1
- package/dist/chunks/{generate.runtime-HSZD935T.js → generate.runtime-DJ5uF6EN.js} +2 -2
- package/dist/chunks/{generate.runtime-HSZD935T.js.map → generate.runtime-DJ5uF6EN.js.map} +1 -1
- package/dist/chunks/{generate.runtime-D6vhkGs8.js → generate.runtime-Dfz53sSK.js} +3 -3
- package/dist/chunks/{generate.runtime-D6vhkGs8.js.map → generate.runtime-Dfz53sSK.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BGuXHl5o.js → generate.runtime-DiqfbDfk.js} +2 -2
- package/dist/chunks/{generate.runtime-BGuXHl5o.js.map → generate.runtime-DiqfbDfk.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CEexT8cJ.js → generate.runtime-Dq6yS7tN.js} +5 -5
- package/dist/chunks/{generate.runtime-CEexT8cJ.js.map → generate.runtime-Dq6yS7tN.js.map} +1 -1
- package/dist/chunks/{generate.runtime-tGKorg85.js → generate.runtime-T7JLE4Wc.js} +3 -3
- package/dist/chunks/{generate.runtime-tGKorg85.js.map → generate.runtime-T7JLE4Wc.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CbOMXQSo.js → generate.runtime-WPq7bHRA.js} +2 -2
- package/dist/chunks/{generate.runtime-CbOMXQSo.js.map → generate.runtime-WPq7bHRA.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Cxr15Y5H.js → generate.runtime-WeDv05E2.js} +6 -6
- package/dist/chunks/{generate.runtime-Cxr15Y5H.js.map → generate.runtime-WeDv05E2.js.map} +1 -1
- package/dist/chunks/{generate.runtime-B8-GLMkk.js → generate.runtime-aKNvrk3M.js} +7 -7
- package/dist/chunks/{generate.runtime-B8-GLMkk.js.map → generate.runtime-aKNvrk3M.js.map} +1 -1
- package/dist/chunks/{generate.runtime-si5Za61F.js → generate.runtime-e_BkDyP0.js} +2 -2
- package/dist/chunks/{generate.runtime-si5Za61F.js.map → generate.runtime-e_BkDyP0.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Blb6QPZn.js → generate.runtime-gZ4wfYBP.js} +6 -6
- package/dist/chunks/{generate.runtime-Blb6QPZn.js.map → generate.runtime-gZ4wfYBP.js.map} +1 -1
- package/dist/chunks/{generate.runtime-m0m43lkL.js → generate.runtime-oUJUQRdg.js} +6 -6
- package/dist/chunks/{generate.runtime-m0m43lkL.js.map → generate.runtime-oUJUQRdg.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BWRtyQeD.js → generate.runtime-q17D7QUT.js} +3 -3
- package/dist/chunks/{generate.runtime-BWRtyQeD.js.map → generate.runtime-q17D7QUT.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CyTxBcX3.js → generate.runtime-rLlDp4R6.js} +4 -4
- package/dist/chunks/{generate.runtime-CyTxBcX3.js.map → generate.runtime-rLlDp4R6.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Nnk5E8Pi.js → generate.runtime-zr6uIHCd.js} +2 -2
- package/dist/chunks/{generate.runtime-Nnk5E8Pi.js.map → generate.runtime-zr6uIHCd.js.map} +1 -1
- package/dist/chunks/{modify-file-COBp4eCh.js → modify-file-B4uJzOEj.js} +2 -2
- package/dist/chunks/{modify-file-COBp4eCh.js.map → modify-file-B4uJzOEj.js.map} +1 -1
- package/dist/chunks/{package-imports-Dx05A-4S.js → package-imports-B9Asv3ZH.js} +2 -2
- package/dist/chunks/{package-imports-Dx05A-4S.js.map → package-imports-B9Asv3ZH.js.map} +1 -1
- package/dist/chunks/{pocketbase-DL02rq73.js → pocketbase-BtN-wL8f.js} +6 -6
- package/dist/chunks/{pocketbase-DL02rq73.js.map → pocketbase-BtN-wL8f.js.map} +1 -1
- package/dist/chunks/{providers-CAehyySB.js → providers-DRwJnSzb.js} +2 -2
- package/dist/chunks/{providers-CAehyySB.js.map → providers-DRwJnSzb.js.map} +1 -1
- package/dist/chunks/{shared-C_Fr8wph.js → shared-BbxLil4g.js} +2 -2
- package/dist/chunks/{shared-C_Fr8wph.js.map → shared-BbxLil4g.js.map} +1 -1
- package/dist/chunks/{site-BoujshKo.js → site-Dw2KIRJu.js} +2 -2
- package/dist/chunks/{site-BoujshKo.js.map → site-Dw2KIRJu.js.map} +1 -1
- package/dist/chunks/{table-core-BPv_RYgD.js → table-core-BHFT-uMX.js} +2 -2
- package/dist/chunks/{table-core-BPv_RYgD.js.map → table-core-BHFT-uMX.js.map} +1 -1
- package/dist/chunks/{test-setup-pYUIfWb2.js → test-setup-BVJwm22s.js} +3 -3
- package/dist/chunks/{test-setup-pYUIfWb2.js.map → test-setup-BVJwm22s.js.map} +1 -1
- package/dist/chunks/{ui-B2yn8c_-.js → ui-gG8i_Mzk.js} +3 -3
- package/dist/chunks/{ui-B2yn8c_-.js.map → ui-gG8i_Mzk.js.map} +1 -1
- package/dist/chunks/{whatsapp-5qJ_xCV1.js → whatsapp-DbjOxHaZ.js} +2 -2
- package/dist/chunks/{whatsapp-5qJ_xCV1.js.map → whatsapp-DbjOxHaZ.js.map} +1 -1
- package/dist/chunks/write-result-DcqMefuP.js +499 -0
- package/dist/chunks/write-result-DcqMefuP.js.map +1 -0
- package/dist/index.d.ts +11 -18
- package/dist/index.js +2135 -2135
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunks/constants-iej3WkEa.js +0 -6
- package/dist/chunks/constants-iej3WkEa.js.map +0 -1
- package/dist/chunks/write-result-Bn4bnrBI.js +0 -481
- package/dist/chunks/write-result-Bn4bnrBI.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.runtime-
|
|
1
|
+
{"version":3,"file":"generate.runtime-zr6uIHCd.js","names":["getLogger","formatLikeSource","modifyOutcomeToFile","fs","path","unmodifyHooksServer","hooksServerPath","originalSource","sourceFile","Project","callExpr","SyntaxKind","ce","args","firstArg","optionsObj","apiProp","generate","logger","options","modifies","file"],"sources":["../../src/patterns/disable/api/modifies/hooks.server.ts","../../src/patterns/disable/api/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { Project, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { formatLikeSource } from \"../../../../runtime/ts-morph-helpers\";\n\nexport function unmodifyHooksServer(hooksServerPath: string): ModifyOutcome {\n if (!fs.existsSync(hooksServerPath)) {\n return { status: \"success\", changed: false };\n }\n\n const originalSource = fs.readFileSync(hooksServerPath, \"utf8\");\n const project = new Project();\n const sourceFile = project.addSourceFileAtPath(hooksServerPath);\n\n const callExpr = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .find((ce) => ce.getExpression().getText() === \"handlePocketbase\");\n\n if (!callExpr) {\n return { status: \"success\", changed: false };\n }\n\n const args = callExpr.getArguments();\n if (args.length === 0) {\n return { status: \"success\", changed: false };\n }\n\n const firstArg = args[0];\n if (firstArg.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n return { status: \"success\", changed: false };\n }\n\n const optionsObj = firstArg.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);\n const apiProp = optionsObj.getProperty(\"api\");\n if (!apiProp) {\n return { status: \"success\", changed: false };\n }\n\n apiProp.remove();\n\n if (optionsObj.getProperties().length === 0) {\n callExpr.removeArgument(0);\n }\n\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\n };\n}\n","import path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { unmodifyHooksServer } from \"./modifies/hooks.server\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n\n logger.info(\"Reverting hooks.server.ts\");\n const hooksServerPath = path.join(options.root, \"src\", \"hooks.server.ts\");\n const file = modifyOutcomeToFile(\n hooksServerPath,\n unmodifyHooksServer(hooksServerPath),\n );\n if (file) modifies.push(file);\n\n return {\n creates: [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;;;AAKA,SAAgBK,EAAoB,GAAwC;CAC1E,IAAI,CAACF,EAAG,WAAWG,CAAe,GAChC,OAAO;EAA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AiB,CAAC;CACpB;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { n as e } from "./rolldown-runtime-5HNE8Q1r.js";
|
|
2
2
|
import { a as t } from "./util-BLYliuUK.js";
|
|
3
|
-
import { n } from "./shared-
|
|
3
|
+
import { n } from "./shared-BbxLil4g.js";
|
|
4
4
|
import { _ as r, s as i } from "./ts-morph-helpers-CHI9wAil.js";
|
|
5
5
|
import a from "node:fs";
|
|
6
6
|
import o from "node:path";
|
|
@@ -50,4 +50,4 @@ function d(e, t) {
|
|
|
50
50
|
//#endregion
|
|
51
51
|
export { l as a, s as i, d as n, c as r, u as t };
|
|
52
52
|
|
|
53
|
-
//# sourceMappingURL=modify-file-
|
|
53
|
+
//# sourceMappingURL=modify-file-B4uJzOEj.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modify-file-
|
|
1
|
+
{"version":3,"file":"modify-file-B4uJzOEj.js","names":["__exportAll","languageFromPath","withInMemoryScript","isEffectivelyEmpty","fs","path","modify_file_exports","envRevertOutcomeToFile","keepMissing","modifyOutcomeToFile","revertOutcomeToFile","language","filePath","outcome","toDeleteEntry","envPath","creates","root","file"],"sources":["../../src/runtime/modify-file.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { File, ModifyOutcome } from \"../core/types\";\nimport { languageFromPath } from \"../core/util\";\nimport { toDeleteEntry } from \"../patterns/destroy/shared\";\nimport { isEffectivelyEmpty, withInMemoryScript } from \"./ts-morph-helpers\";\n\nexport function modifyOutcomeToFile(\n filePath: string,\n outcome: ModifyOutcome,\n): File | null {\n const language = languageFromPath(filePath);\n\n if (outcome.status === \"success\") {\n if (!outcome.changed) return null;\n return {\n path: filePath,\n language,\n content: fs.readFileSync(filePath, \"utf8\"),\n status: \"success\",\n };\n }\n\n const content =\n outcome.status === \"failed\" && fs.existsSync(filePath)\n ? fs.readFileSync(filePath, \"utf8\")\n : \"\";\n\n return {\n path: filePath,\n language,\n content,\n status: outcome.status,\n message: outcome.message,\n };\n}\n\n/**\n * `modifyOutcomeToFile` for a revert that may have taken out everything the\n * file held: a script left with no statements, only comments and whitespace,\n * is reported as a delete. For hooks files a pattern created, or that ended\n * up holding nothing but what patterns put there.\n */\nexport function revertOutcomeToFile(\n filePath: string,\n outcome: ModifyOutcome,\n): { modify: File | null; delete: File | null } {\n if (\n outcome.status === \"success\" &&\n outcome.changed &&\n fs.existsSync(filePath) &&\n withInMemoryScript(fs.readFileSync(filePath, \"utf8\"), isEffectivelyEmpty)\n .result\n ) {\n return { modify: null, delete: toDeleteEntry(filePath) };\n }\n return { modify: modifyOutcomeToFile(filePath, outcome), delete: null };\n}\n\n/**\n * `modifyOutcomeToFile` for a `.env` revert: a file the revert left empty is\n * reported as a delete. The enable pattern most likely created it, and an\n * empty `.env` holds nothing worth keeping.\n */\nexport function envRevertOutcomeToFile(\n envPath: string,\n outcome: ModifyOutcome,\n): { modify: File | null; delete: File | null } {\n if (\n outcome.status === \"success\" &&\n outcome.changed &&\n fs.existsSync(envPath) &&\n fs.readFileSync(envPath, \"utf8\").trim() === \"\"\n ) {\n return { modify: null, delete: toDeleteEntry(envPath) };\n }\n return { modify: modifyOutcomeToFile(envPath, outcome), delete: null };\n}\n\n/**\n * Drop any create that already exists on disk.\n *\n * `writeResult` overwrites an existing create whose content differs and\n * reports it as a modify, which would mean a re-run silently resetting a\n * developer's edits, or a create clobbering a file other patterns have\n * already written to. The file is theirs once it exists; a pattern that has\n * something to add to it does so with a modifier.\n */\nexport function keepMissing(creates: File[], root: string): File[] {\n return creates.filter((file) => !fs.existsSync(path.join(root, file.path)));\n}\n"],"mappings":";;;;;;;;;;;;;AAOA,SAAgBS,EACd,GACA,GACa;CACb,IAAME,IAAWV,EAAiBW,CAAQ;CAiB1C,OAfIC,EAAQ,WAAW,YAChBA,EAAQ,UACN;EACL,MAAMD;EACN;EACA,SAASR,EAAG,aAAaQ,GAAU,MAAM;EACzC,QAAQ;CACV,IAN6B,OAcxB;EACL,MAAMA;EACN;EACA,SAPAC,EAAQ,WAAW,YAAYT,EAAG,WAAWQ,CAAQ,IACjDR,EAAG,aAAaQ,GAAU,MAAM,IAChC;EAMJ,QAAQC,EAAQ;EAChB,SAASA,EAAQ;CACnB;AACF;AAQA,SAAgBH,EACd,GACA,GAC8C;CAU9C,OAREG,EAAQ,WAAW,aACnBA,EAAQ,WACRT,EAAG,WAAWQ,CAAQ,KACtBV,EAAmBE,EAAG,aAAaQ,GAAU,MAAM,GAAGT,CAAkB,CAAC,CACtE,SAEI;EAAE,QAAQ;EAAM,QAAQW,EAAcF,CAAQ;CAAE,IAElD;EAAE,QAAQH,EAAoBG,GAAUC,CAAO;EAAG,QAAQ;CAAK;AACxE;AAOA,SAAgBN,EACd,GACA,GAC8C;CAS9C,OAPEM,EAAQ,WAAW,aACnBA,EAAQ,WACRT,EAAG,WAAWW,CAAO,KACrBX,EAAG,aAAaW,GAAS,MAAM,CAAC,CAAC,KAAK,MAAM,KAErC;EAAE,QAAQ;EAAM,QAAQD,EAAcC,CAAO;CAAE,IAEjD;EAAE,QAAQN,EAAoBM,GAASF,CAAO;EAAG,QAAQ;CAAK;AACvE;AAWA,SAAgBL,EAAY,GAAiB,GAAsB;CACjE,OAAOQ,EAAQ,QAAQ,MAAS,CAACZ,EAAG,WAAWC,EAAK,KAAKY,GAAMC,EAAK,IAAI,CAAC,CAAC;AAC5E"}
|
|
@@ -168,6 +168,6 @@ function f(e, t, n, r) {
|
|
|
168
168
|
return a;
|
|
169
169
|
}
|
|
170
170
|
//#endregion
|
|
171
|
-
export {
|
|
171
|
+
export { r as n, u as r, l as t };
|
|
172
172
|
|
|
173
|
-
//# sourceMappingURL=package-imports-
|
|
173
|
+
//# sourceMappingURL=package-imports-B9Asv3ZH.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package-imports-Dx05A-4S.js","names":["__exportAll","fs","path","package_imports_exports","ensurePackageImports","ensurePackageOverrides","removePackageImports","isObject","value","readPackage","filePath","root","text","pkg","indent","eol","trailing","writePackage","next","file","insertKey","anchor","after","name","key","existing","finish","outcome","conflicts","field","line","current","entries","imports","keys","expected","_","rest","overrides","merged","mergeOverrides","out","target","wanted","source","have","where","trail"],"sources":["../../src/runtime/package-imports.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { ModifyOutcome } from \"../core/types\";\n\n/**\n * Edits to the project's `package.json` that npm has no command for: the\n * `imports` map SvelteKit 3 resolves `#lib` (and `#locales`) through, and\n * `overrides`. The file is rewritten with the indentation and trailing\n * newline it had, and a key that already holds a different value is never\n * overwritten: it is the project's, and the outcome says what to change.\n */\n\nexport interface PackageJsonEditResult {\n filePath: string;\n outcome: ModifyOutcome;\n}\n\ntype Json = string | number | boolean | null | Json[] | { [key: string]: Json };\ntype JsonObject = { [key: string]: Json };\n\n/** An `overrides` value: a version, or nested overrides (npm's `\".\"` is the package itself). */\nexport type OverrideValue = string | { [key: string]: OverrideValue };\n\ninterface PackageFile {\n filePath: string;\n text: string;\n pkg: JsonObject;\n indent: string;\n eol: string;\n trailing: string;\n}\n\nfunction isObject(value: unknown): value is JsonObject {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction readPackage(root: string): PackageFile | PackageJsonEditResult {\n const filePath = path.join(root, \"package.json\");\n if (!fs.existsSync(filePath)) {\n return {\n filePath,\n outcome: { status: \"not-found\", message: \"No package.json to edit.\" },\n };\n }\n const text = fs.readFileSync(filePath, \"utf8\");\n let pkg: unknown;\n try {\n pkg = JSON.parse(text);\n } catch {\n return {\n filePath,\n outcome: { status: \"failed\", message: \"package.json is not valid JSON.\" },\n };\n }\n if (!isObject(pkg)) {\n return {\n filePath,\n outcome: { status: \"failed\", message: \"package.json is not an object.\" },\n };\n }\n const indent = text.match(/^[{[][^\\S\\n]*\\r?\\n([\\t ]+)\\S/)?.[1] ?? \"\\t\";\n const eol = text.includes(\"\\r\\n\") ? \"\\r\\n\" : \"\\n\";\n const trailing = text.match(/(\\r?\\n)*$/)?.[0] ?? \"\";\n return { filePath, text, pkg, indent, eol, trailing };\n}\n\nfunction writePackage(file: PackageFile): ModifyOutcome {\n const body = JSON.stringify(file.pkg, null, file.indent).replace(\n /\\n/g,\n file.eol,\n );\n const next = body + file.trailing;\n if (next === file.text) return { status: \"success\", changed: false };\n fs.writeFileSync(file.filePath, next, \"utf8\");\n return { status: \"success\", changed: true };\n}\n\n/**\n * Add `key` to `pkg` right after the first of `after` it has, else at the end.\n * JSON object key order is insertion order, so this rebuilds the object.\n */\nfunction insertKey(\n pkg: JsonObject,\n key: string,\n value: Json,\n after: string[],\n): JsonObject {\n const anchor = after.find((name) => name in pkg);\n if (!anchor) return { ...pkg, [key]: value };\n const next: JsonObject = {};\n for (const [name, existing] of Object.entries(pkg)) {\n next[name] = existing;\n if (name === anchor) next[key] = value;\n }\n return next;\n}\n\nfunction finish(\n file: PackageFile,\n conflicts: string[],\n field: string,\n): PackageJsonEditResult {\n const outcome = writePackage(file);\n if (conflicts.length === 0) return { filePath: file.filePath, outcome };\n return {\n filePath: file.filePath,\n outcome: {\n status: \"failed\",\n message: [\n `package.json \\`${field}\\` already has a different value for:`,\n ...conflicts.map((line) => ` ${line}`),\n \"Change these by hand if vela's value is the one you want.\",\n ].join(\"\\n\"),\n },\n };\n}\n\n/**\n * Add the subpath `imports` (`{ \"#lib/*\": \"./src/lib/*\" }`) that are missing.\n * Creates `imports` after `type` when the project has none.\n */\nexport function ensurePackageImports(\n root: string,\n entries: Record<string, string>,\n): PackageJsonEditResult {\n const file = readPackage(root);\n if (!(\"pkg\" in file)) return file;\n\n const current = file.pkg.imports;\n if (current !== undefined && !isObject(current)) {\n return {\n filePath: file.filePath,\n outcome: {\n status: \"failed\",\n message: [\n \"package.json `imports` is not an object. Add these entries to it by hand:\",\n ...Object.entries(entries).map(\n ([key, value]) =>\n ` ${JSON.stringify(key)}: ${JSON.stringify(value)}`,\n ),\n ].join(\"\\n\"),\n },\n };\n }\n\n const imports: JsonObject = { ...(current ?? {}) };\n const conflicts: string[] = [];\n for (const [key, value] of Object.entries(entries)) {\n if (!(key in imports)) {\n imports[key] = value;\n } else if (imports[key] !== value) {\n conflicts.push(\n `${JSON.stringify(key)}: ${JSON.stringify(imports[key])} (vela uses ${JSON.stringify(value)})`,\n );\n }\n }\n file.pkg =\n current === undefined\n ? Object.keys(imports).length > 0\n ? insertKey(file.pkg, \"imports\", imports, [\"type\", \"version\", \"name\"])\n : file.pkg\n : { ...file.pkg, imports };\n return finish(file, conflicts, \"imports\");\n}\n\n/**\n * Remove subpath `imports` keys. With `expected`, a key is removed only while\n * it still maps to the value vela wrote, so one the developer repointed stays.\n * An `imports` left empty is removed too.\n */\nexport function removePackageImports(\n root: string,\n keys: string[],\n expected?: Record<string, string>,\n): PackageJsonEditResult {\n const file = readPackage(root);\n if (!(\"pkg\" in file)) {\n // Nothing to revert in a project without a package.json.\n return file.outcome.status === \"not-found\"\n ? {\n filePath: file.filePath,\n outcome: { status: \"success\", changed: false },\n }\n : file;\n }\n const current = file.pkg.imports;\n if (!isObject(current)) {\n return {\n filePath: file.filePath,\n outcome: { status: \"success\", changed: false },\n };\n }\n const imports: JsonObject = { ...current };\n for (const key of keys) {\n if (!(key in imports)) continue;\n if (expected && key in expected && imports[key] !== expected[key]) continue;\n delete imports[key];\n }\n if (Object.keys(imports).length === 0) {\n const { imports: _, ...rest } = file.pkg;\n file.pkg = rest;\n } else {\n file.pkg = { ...file.pkg, imports };\n }\n return { filePath: file.filePath, outcome: writePackage(file) };\n}\n\n/**\n * Deep-merge `overrides` into package.json's `overrides`, created at the end\n * when missing. A version already there that differs is left as it is and\n * reported. A package overridden with a bare version that now needs nested\n * overrides keeps that version as npm's `\".\"`.\n */\nexport function ensurePackageOverrides(\n root: string,\n overrides: Record<string, OverrideValue>,\n): PackageJsonEditResult {\n const file = readPackage(root);\n if (!(\"pkg\" in file)) return file;\n\n const current = file.pkg.overrides;\n if (current !== undefined && !isObject(current)) {\n return {\n filePath: file.filePath,\n outcome: {\n status: \"failed\",\n message: `package.json \\`overrides\\` is not an object. Add this to it by hand:\\n${JSON.stringify(overrides, null, 2)}`,\n },\n };\n }\n const conflicts: string[] = [];\n const merged = mergeOverrides(current ?? {}, overrides, [], conflicts);\n file.pkg = { ...file.pkg, overrides: merged };\n return finish(file, conflicts, \"overrides\");\n}\n\nfunction mergeOverrides(\n target: JsonObject,\n source: Record<string, OverrideValue>,\n trail: string[],\n conflicts: string[],\n): JsonObject {\n const out: JsonObject = { ...target };\n for (const [key, wanted] of Object.entries(source)) {\n const have = out[key];\n const where = [...trail, key].join(\" > \");\n if (have === undefined) {\n out[key] = wanted as Json;\n } else if (typeof wanted === \"string\") {\n if (have === wanted) continue;\n if (isObject(have) && have[\".\"] === wanted) continue;\n conflicts.push(\n `${where}: ${JSON.stringify(have)} (vela uses ${JSON.stringify(wanted)})`,\n );\n } else if (isObject(have)) {\n out[key] = mergeOverrides(have, wanted, [...trail, key], conflicts);\n } else if (typeof have === \"string\") {\n out[key] = mergeOverrides(\n { \".\": have },\n wanted,\n [...trail, key],\n conflicts,\n );\n } else {\n conflicts.push(\n `${where}: ${JSON.stringify(have)} (vela uses ${JSON.stringify(wanted)})`,\n );\n }\n }\n return out;\n}\n"],"mappings":";;;;;;;;;AAgCA,SAASO,EAAS,GAAqC;CACrD,OAAO,OAAOC,KAAU,cAAYA,KAAkB,CAAC,MAAM,QAAQA,CAAK;AAC5E;AAEA,SAASC,EAAY,GAAmD;CACtE,IAAMC,IAAWR,EAAK,KAAKS,GAAM,cAAc;CAC/C,IAAI,CAACV,EAAG,WAAWS,CAAQ,GACzB,OAAO;EACL;EACA,SAAS;GAAE,QAAQ;GAAa,SAAS;EAA2B;CACtE;CAEF,IAAME,IAAOX,EAAG,aAAaS,GAAU,MAAM,GACzCG;CACJ,IAAI;EACF,IAAM,KAAK,MAAMD,CAAI;CACvB,QAAQ;EACN,OAAO;GACL;GACA,SAAS;IAAE,QAAQ;IAAU,SAAS;GA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ACXsB,IAAQ,CAAC,GAAGC,GAAOvB,CAAG,CAAC,CAAC,KAAK,KAAK;EACxC,IAAIqB,MAAS,KAAA,GACX,EAAIrB,KAAOmB;OACN,IAAI,OAAOA,KAAW,UAAU;GAErC,IADIE,MAASF,KACTpC,EAASsC,CAAI,KAAKA,EAAK,SAASF,GAAQ;GAC5C,EAAU,KACR,GAAGG,EAAM,IAAI,KAAK,UAAUD,CAAI,EAAE,cAAc,KAAK,UAAUF,CAAM,EAAE,EACzE;EACF,OAAO,AAAIpC,EAASsC,CAAI,IACtB,EAAIrB,KAAOgB,EAAeK,GAAMF,GAAQ,CAAC,GAAGI,GAAOvB,CAAG,GAAGI,CAAS,IACzD,OAAOiB,KAAS,WACzB,EAAIrB,KAAOgB,EACT,EAAE,KAAKK,EAAK,GACZF,GACA,CAAC,GAAGI,GAAOvB,CAAG,GACdI,CACF,IAEAA,EAAU,KACR,GAAGkB,EAAM,IAAI,KAAK,UAAUD,CAAI,EAAE,cAAc,KAAK,UAAUF,CAAM,EAAE,EACzE;CAEJ;CACA,OAAOF;AACT"}
|
|
1
|
+
{"version":3,"file":"package-imports-B9Asv3ZH.js","names":["__exportAll","fs","path","package_imports_exports","ensurePackageImports","ensurePackageOverrides","removePackageImports","isObject","value","readPackage","filePath","root","text","pkg","indent","eol","trailing","writePackage","next","file","insertKey","anchor","after","name","key","existing","finish","outcome","conflicts","field","line","current","entries","imports","keys","expected","_","rest","overrides","merged","mergeOverrides","out","target","wanted","source","have","where","trail"],"sources":["../../src/runtime/package-imports.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { ModifyOutcome } from \"../core/types\";\n\n/**\n * Edits to the project's `package.json` that npm has no command for: the\n * `imports` map SvelteKit 3 resolves `#lib` (and `#locales`) through, and\n * `overrides`. The file is rewritten with the indentation and trailing\n * newline it had, and a key that already holds a different value is never\n * overwritten: it is the project's, and the outcome says what to change.\n */\n\nexport interface PackageJsonEditResult {\n filePath: string;\n outcome: ModifyOutcome;\n}\n\ntype Json = string | number | boolean | null | Json[] | { [key: string]: Json };\ntype JsonObject = { [key: string]: Json };\n\n/** An `overrides` value: a version, or nested overrides (npm's `\".\"` is the package itself). */\nexport type OverrideValue = string | { [key: string]: OverrideValue };\n\ninterface PackageFile {\n filePath: string;\n text: string;\n pkg: JsonObject;\n indent: string;\n eol: string;\n trailing: string;\n}\n\nfunction isObject(value: unknown): value is JsonObject {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction readPackage(root: string): PackageFile | PackageJsonEditResult {\n const filePath = path.join(root, \"package.json\");\n if (!fs.existsSync(filePath)) {\n return {\n filePath,\n outcome: { status: \"not-found\", message: \"No package.json to edit.\" },\n };\n }\n const text = fs.readFileSync(filePath, \"utf8\");\n let pkg: unknown;\n try {\n pkg = JSON.parse(text);\n } catch {\n return {\n filePath,\n outcome: { status: \"failed\", message: \"package.json is not valid JSON.\" },\n };\n }\n if (!isObject(pkg)) {\n return {\n filePath,\n outcome: { status: \"failed\", message: \"package.json is not an object.\" },\n };\n }\n const indent = text.match(/^[{[][^\\S\\n]*\\r?\\n([\\t ]+)\\S/)?.[1] ?? \"\\t\";\n const eol = text.includes(\"\\r\\n\") ? \"\\r\\n\" : \"\\n\";\n const trailing = text.match(/(\\r?\\n)*$/)?.[0] ?? \"\";\n return { filePath, text, pkg, indent, eol, trailing };\n}\n\nfunction writePackage(file: PackageFile): ModifyOutcome {\n const body = JSON.stringify(file.pkg, null, file.indent).replace(\n /\\n/g,\n file.eol,\n );\n const next = body + file.trailing;\n if (next === file.text) return { status: \"success\", changed: false };\n fs.writeFileSync(file.filePath, next, \"utf8\");\n return { status: \"success\", changed: true };\n}\n\n/**\n * Add `key` to `pkg` right after the first of `after` it has, else at the end.\n * JSON object key order is insertion order, so this rebuilds the object.\n */\nfunction insertKey(\n pkg: JsonObject,\n key: string,\n value: Json,\n after: string[],\n): JsonObject {\n const anchor = after.find((name) => name in pkg);\n if (!anchor) return { ...pkg, [key]: value };\n const next: JsonObject = {};\n for (const [name, existing] of Object.entries(pkg)) {\n next[name] = existing;\n if (name === anchor) next[key] = value;\n }\n return next;\n}\n\nfunction finish(\n file: PackageFile,\n conflicts: string[],\n field: string,\n): PackageJsonEditResult {\n const outcome = writePackage(file);\n if (conflicts.length === 0) return { filePath: file.filePath, outcome };\n return {\n filePath: file.filePath,\n outcome: {\n status: \"failed\",\n message: [\n `package.json \\`${field}\\` already has a different value for:`,\n ...conflicts.map((line) => ` ${line}`),\n \"Change these by hand if vela's value is the one you want.\",\n ].join(\"\\n\"),\n },\n };\n}\n\n/**\n * Add the subpath `imports` (`{ \"#lib/*\": \"./src/lib/*\" }`) that are missing.\n * Creates `imports` after `type` when the project has none.\n */\nexport function ensurePackageImports(\n root: string,\n entries: Record<string, string>,\n): PackageJsonEditResult {\n const file = readPackage(root);\n if (!(\"pkg\" in file)) return file;\n\n const current = file.pkg.imports;\n if (current !== undefined && !isObject(current)) {\n return {\n filePath: file.filePath,\n outcome: {\n status: \"failed\",\n message: [\n \"package.json `imports` is not an object. Add these entries to it by hand:\",\n ...Object.entries(entries).map(\n ([key, value]) =>\n ` ${JSON.stringify(key)}: ${JSON.stringify(value)}`,\n ),\n ].join(\"\\n\"),\n },\n };\n }\n\n const imports: JsonObject = { ...(current ?? {}) };\n const conflicts: string[] = [];\n for (const [key, value] of Object.entries(entries)) {\n if (!(key in imports)) {\n imports[key] = value;\n } else if (imports[key] !== value) {\n conflicts.push(\n `${JSON.stringify(key)}: ${JSON.stringify(imports[key])} (vela uses ${JSON.stringify(value)})`,\n );\n }\n }\n file.pkg =\n current === undefined\n ? Object.keys(imports).length > 0\n ? insertKey(file.pkg, \"imports\", imports, [\"type\", \"version\", \"name\"])\n : file.pkg\n : { ...file.pkg, imports };\n return finish(file, conflicts, \"imports\");\n}\n\n/**\n * Remove subpath `imports` keys. With `expected`, a key is removed only while\n * it still maps to the value vela wrote, so one the developer repointed stays.\n * An `imports` left empty is removed too.\n */\nexport function removePackageImports(\n root: string,\n keys: string[],\n expected?: Record<string, string>,\n): PackageJsonEditResult {\n const file = readPackage(root);\n if (!(\"pkg\" in file)) {\n // Nothing to revert in a project without a package.json.\n return file.outcome.status === \"not-found\"\n ? {\n filePath: file.filePath,\n outcome: { status: \"success\", changed: false },\n }\n : file;\n }\n const current = file.pkg.imports;\n if (!isObject(current)) {\n return {\n filePath: file.filePath,\n outcome: { status: \"success\", changed: false },\n };\n }\n const imports: JsonObject = { ...current };\n for (const key of keys) {\n if (!(key in imports)) continue;\n if (expected && key in expected && imports[key] !== expected[key]) continue;\n delete imports[key];\n }\n if (Object.keys(imports).length === 0) {\n const { imports: _, ...rest } = file.pkg;\n file.pkg = rest;\n } else {\n file.pkg = { ...file.pkg, imports };\n }\n return { filePath: file.filePath, outcome: writePackage(file) };\n}\n\n/**\n * Deep-merge `overrides` into package.json's `overrides`, created at the end\n * when missing. A version already there that differs is left as it is and\n * reported. A package overridden with a bare version that now needs nested\n * overrides keeps that version as npm's `\".\"`.\n */\nexport function ensurePackageOverrides(\n root: string,\n overrides: Record<string, OverrideValue>,\n): PackageJsonEditResult {\n const file = readPackage(root);\n if (!(\"pkg\" in file)) return file;\n\n const current = file.pkg.overrides;\n if (current !== undefined && !isObject(current)) {\n return {\n filePath: file.filePath,\n outcome: {\n status: \"failed\",\n message: `package.json \\`overrides\\` is not an object. Add this to it by hand:\\n${JSON.stringify(overrides, null, 2)}`,\n },\n };\n }\n const conflicts: string[] = [];\n const merged = mergeOverrides(current ?? {}, overrides, [], conflicts);\n file.pkg = { ...file.pkg, overrides: merged };\n return finish(file, conflicts, \"overrides\");\n}\n\nfunction mergeOverrides(\n target: JsonObject,\n source: Record<string, OverrideValue>,\n trail: string[],\n conflicts: string[],\n): JsonObject {\n const out: JsonObject = { ...target };\n for (const [key, wanted] of Object.entries(source)) {\n const have = out[key];\n const where = [...trail, key].join(\" > \");\n if (have === undefined) {\n out[key] = wanted as Json;\n } else if (typeof wanted === \"string\") {\n if (have === wanted) continue;\n if (isObject(have) && have[\".\"] === wanted) continue;\n conflicts.push(\n `${where}: ${JSON.stringify(have)} (vela uses ${JSON.stringify(wanted)})`,\n );\n } else if (isObject(have)) {\n out[key] = mergeOverrides(have, wanted, [...trail, key], conflicts);\n } else if (typeof have === \"string\") {\n out[key] = mergeOverrides(\n { \".\": have },\n wanted,\n [...trail, key],\n conflicts,\n );\n } else {\n conflicts.push(\n `${where}: ${JSON.stringify(have)} (vela uses ${JSON.stringify(wanted)})`,\n );\n }\n }\n return out;\n}\n"],"mappings":";;;;;;;;;AAgCA,SAASO,EAAS,GAAqC;CACrD,OAAO,OAAOC,KAAU,cAAYA,KAAkB,CAAC,MAAM,QAAQA,CAAK;AAC5E;AAEA,SAASC,EAAY,GAAmD;CACtE,IAAMC,IAAWR,EAAK,KAAKS,GAAM,cAAc;CAC/C,IAAI,CAACV,EAAG,WAAWS,CAAQ,GACzB,OAAO;EACL;EACA,SAAS;GAAE,QAAQ;GAAa,SAAS;EAA2B;CACtE;CAEF,IAAME,IAAOX,EAAG,aAAaS,GAAU,MAAM,GACzCG;CACJ,IAAI;EACF,IAAM,KAAK,MAAMD,CAAI;CACvB,QAAQ;EACN,OAAO;GACL;GACA,SAAS;IAAE,QAAQ;IAAU,SAAS;GAAkC;EAC1E;CACF;CACA,IAAI,CAACL,EAASM,CAAG,GACf,OAAO;EACL;EACA,SAAS;GAAE,QAAQ;GAAU,SAAS;EAAiC;CACzE;CAEF,IAAMC,IAASF,EAAK,MAAM,8BAA8B,CAAC,GAAG,MAAM,KAC5DG,IAAMH,EAAK,SAAS,MAAM,IAAI,SAAS,MACvCI,IAAWJ,EAAK,MAAM,WAAW,CAAC,GAAG,MAAM;CACjD,OAAO;EAAE;EAAU;EAAM;EAAK;EAAQ;EAAK;CAAS;AACtD;AAEA,SAASK,EAAa,GAAkC;CAKtD,IAAMC,IAJO,KAAK,UAAUC,EAAK,KAAK,MAAMA,EAAK,MAAM,CAAC,CAAC,QACvD,OACAA,EAAK,GAEM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EAAIrB,KAAOgB,EACT,EAAE,KAAKK,EAAK,GACZF,GACA,CAAC,GAAGI,GAAOvB,CAAG,GACdI,CACF,IAEAA,EAAU,KACR,GAAGkB,EAAM,IAAI,KAAK,UAAUD,CAAI,EAAE,cAAc,KAAK,UAAUF,CAAM,EAAE,EACzE;CAEJ;CACA,OAAOF;AACT"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as e } from "./rolldown-runtime-5HNE8Q1r.js";
|
|
2
|
-
import {
|
|
2
|
+
import { i as t, s as n } from "./constants-Bdx8mp7v.js";
|
|
3
3
|
import { existsSync as r, readFileSync as i, readdirSync as a } from "node:fs";
|
|
4
4
|
import o from "node:path";
|
|
5
5
|
import s from "pocketbase";
|
|
@@ -157,9 +157,9 @@ var v = /* @__PURE__ */ e({
|
|
|
157
157
|
function b() {
|
|
158
158
|
return new Promise((e) => setTimeout(e, y));
|
|
159
159
|
}
|
|
160
|
-
function x(e,
|
|
161
|
-
let i = `${
|
|
162
|
-
if (s) return o.join(r.root,
|
|
160
|
+
function x(e, t, r) {
|
|
161
|
+
let i = `${t}_${e}.js`, s = a(o.join(r.root, n)).filter((e) => e.endsWith(i)).sort().pop();
|
|
162
|
+
if (s) return o.join(r.root, n, s);
|
|
163
163
|
}
|
|
164
164
|
function S(e) {
|
|
165
165
|
let t = o.join(e, "node_modules", ".vite", "_pocketbase_metadata.json");
|
|
@@ -176,7 +176,7 @@ async function C(e, t, n) {
|
|
|
176
176
|
if (!r) throw Error("Failed to authenticate with PocketBase. Check your superuser credentials.");
|
|
177
177
|
}
|
|
178
178
|
async function w(e, i) {
|
|
179
|
-
let a = o.join(e,
|
|
179
|
+
let a = o.join(e, t), d = o.join(e, n), f = "localhost";
|
|
180
180
|
if (!r(a)) throw Error("PocketBase data directory does not exist");
|
|
181
181
|
let p = S(e);
|
|
182
182
|
if (p && p.pocketbaseUrl) {
|
|
@@ -224,4 +224,4 @@ function T(e, t) {
|
|
|
224
224
|
//#endregion
|
|
225
225
|
export { w as i, b as n, v as r, x as t };
|
|
226
226
|
|
|
227
|
-
//# sourceMappingURL=pocketbase-
|
|
227
|
+
//# sourceMappingURL=pocketbase-BtN-wL8f.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pocketbase-DL02rq73.js","names":["__exportAll","MIGRATIONS_DIR","DATA_DIR","path","PocketBase","spawn","net","BAD_PORTS","osAssignedPort","server","reject","host","resolve","port","freePort","waitForPort","attempts","tryConnect","socket","maxAttempts","describeFetchError","error","cause","waitForHealth","lastFailure","tryHealth","response","url","pocketbase_exports","authWithRetries","getMigrationFile","getPocketbaseMetadata","migrationDelay","withPocketbase","MIGRATION_DELAY_MS","ending","action","collectionName","migrationFile","readdirSync","options","file","metadataPath","cwd","existsSync","readFileSync","authSuccess","attempt","pb","email","password","dir","migrationsDir","metadata","fn","commandArgs","packageManager","detect","resolveCommand","args","detached","serverProcess","command","exited","signal","code","stopProcessTree","child"],"sources":["../../src/runtime/net.ts","../../src/runtime/pocketbase.ts"],"sourcesContent":["import net from \"node:net\";\n\n/**\n * Ports the Fetch spec tells clients to refuse outright\n * (https://fetch.spec.whatwg.org/#port-blocking). Node's `fetch` enforces the\n * list, so a server bound to one of them is unreachable from `waitForHealth`\n * and the PocketBase SDK alike: the request fails with cause \"bad port\"\n * before a connection is even attempted. 10080 sat inside the 10000–19999\n * range ports used to be drawn from, and cost a CI run a 30-second health\n * timeout whenever the draw landed on it.\n */\nexport const BAD_PORTS: ReadonlySet<number> = new Set([\n 1, 7, 9, 11, 13, 15, 17, 19, 20, 21, 22, 23, 25, 37, 42, 43, 53, 69, 77, 79,\n 87, 95, 101, 102, 103, 104, 109, 110, 111, 113, 115, 117, 119, 123, 135, 137,\n 139, 143, 161, 179, 389, 427, 465, 512, 513, 514, 515, 526, 530, 531, 532,\n 540, 548, 554, 556, 563, 587, 601, 636, 989, 990, 993, 995, 1719, 1720, 1723,\n 2049, 3659, 4045, 4190, 5060, 5061, 6000, 6566, 6665, 6666, 6667, 6668, 6669,\n 6679, 6697, 10080,\n]);\n\nfunction osAssignedPort(host: string): Promise<number> {\n return new Promise((resolve, reject) => {\n const server = net.createServer();\n server.unref();\n server.once(\"error\", reject);\n server.listen(0, host, () => {\n const { port } = server.address() as net.AddressInfo;\n server.close(() => resolve(port));\n });\n });\n}\n\n/**\n * A port nothing is listening on right now, taken from the OS's ephemeral\n * range so it neither collides with whatever else the machine runs nor hits\n * `BAD_PORTS`. The port is released again before this resolves, so the\n * caller's server has to bind it promptly.\n */\nexport async function freePort(host: string): Promise<number> {\n for (;;) {\n const port = await osAssignedPort(host);\n if (!BAD_PORTS.has(port)) return port;\n }\n}\n\n// Wait for the port to be available. A cold `npx pocketbase-server` on a CI\n// runner can take well over the five seconds the old default allowed.\nexport function waitForPort(\n port: number,\n host: string,\n maxAttempts = 60,\n): Promise<void> {\n return new Promise((resolve, reject) => {\n let attempts = 0;\n\n const tryConnect = () => {\n attempts++;\n\n const socket = new net.Socket();\n\n const onError = () => {\n socket.destroy();\n\n if (attempts === maxAttempts) {\n reject(\n new Error(`Timed out waiting for port ${port} to be available`),\n );\n return;\n }\n\n setTimeout(tryConnect, 500);\n };\n\n socket.once(\"error\", onError);\n\n socket.connect(port, host, () => {\n socket.destroy();\n resolve();\n });\n };\n\n tryConnect();\n });\n}\n\n/**\n * `fetch` wraps the interesting part in `cause`: an errno error for a\n * connection that was refused, or a bare string such as \"bad port\" for a\n * request undici declined to make.\n */\nfunction describeFetchError(error: unknown): string {\n if (!(error instanceof Error)) return String(error);\n const { cause } = error as Error & { cause?: unknown };\n if (cause instanceof Error) {\n const code = (cause as NodeJS.ErrnoException).code;\n return code || cause.message || error.message;\n }\n if (cause !== undefined) return String(cause);\n return error.message;\n}\n\n// Wait for the health check to be successful\nexport function waitForHealth(url: string, maxAttempts = 60): Promise<void> {\n return new Promise((resolve, reject) => {\n let attempts = 0;\n let lastFailure = \"no attempt made\";\n\n const tryHealth = async () => {\n attempts++;\n\n try {\n const response = await fetch(`${url}/api/health`);\n if (response.status === 200) {\n resolve();\n return;\n }\n lastFailure = `HTTP ${response.status}`;\n } catch (error) {\n lastFailure = describeFetchError(error);\n }\n\n if (attempts === maxAttempts) {\n reject(\n new Error(\n `Timed out waiting for health check at ${url}/api/health (last attempt: ${lastFailure})`,\n ),\n );\n return;\n }\n\n setTimeout(tryHealth, 500);\n };\n\n tryHealth();\n });\n}\n","import { existsSync, readdirSync, readFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport PocketBase from \"pocketbase\";\nimport { detect } from \"package-manager-detector\";\nimport { resolveCommand } from \"package-manager-detector/commands\";\nimport spawn from \"cross-spawn\";\nimport { freePort, waitForPort, waitForHealth } from \"./net\";\nimport type { Options } from \"../core/types\";\nimport { DATA_DIR, MIGRATIONS_DIR } from \"../core/constants\";\n\n/**\n * PocketBase names migration files with a 1-second-resolution Unix timestamp\n * (e.g. `1776099881_created_users.js`). Two schema operations issued in the\n * same wall-clock second produce files that sort alphabetically by their\n * action/collection suffix — which reverses the intended order whenever a\n * later migration depends on an earlier one. Wait out the full second between\n * migration-producing calls so the timestamps stay distinct.\n */\nconst MIGRATION_DELAY_MS = 1100;\n\nexport function migrationDelay(): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, MIGRATION_DELAY_MS));\n}\n\nexport function getMigrationFile(\n collectionName: string,\n action: \"created\" | \"deleted\" | \"updated\",\n options: Options,\n): string | undefined {\n const ending = `${action}_${collectionName}.js`;\n\n // find last file with ending in migrations dir\n const migrationFiles = readdirSync(\n path.join(options.root, MIGRATIONS_DIR),\n ).filter((file) => file.endsWith(ending));\n\n const migrationFile = migrationFiles.sort().pop();\n\n if (!migrationFile) {\n return undefined;\n }\n\n return path.join(options.root, MIGRATIONS_DIR, migrationFile);\n}\n\nexport function getPocketbaseMetadata(cwd: string): {\n pocketbaseUrl: string;\n vitePort: number;\n} | null {\n const metadataPath = path.join(\n cwd,\n \"node_modules\",\n \".vite\",\n \"_pocketbase_metadata.json\",\n );\n if (existsSync(metadataPath)) {\n return JSON.parse(readFileSync(metadataPath, \"utf8\"));\n }\n return null;\n}\n\nexport async function authWithRetries(\n pb: PocketBase,\n email: string,\n password: string,\n) {\n // Retry authentication up to 3 times with 100ms backoff\n let authSuccess = false;\n for (let attempt = 1; attempt <= 3; attempt++) {\n try {\n await pb.collection(\"_superusers\").authWithPassword(email, password);\n authSuccess = true;\n break;\n } catch {\n if (attempt < 3) {\n await new Promise((resolve) => setTimeout(resolve, 100));\n }\n }\n }\n\n if (!authSuccess) {\n throw new Error(\n \"Failed to authenticate with PocketBase. Check your superuser credentials.\",\n );\n }\n}\n\nexport async function withPocketbase(\n cwd: string,\n fn: (pb: PocketBase) => Promise<void>,\n) {\n const dir = path.join(cwd, DATA_DIR);\n const migrationsDir = path.join(cwd, MIGRATIONS_DIR);\n const host = \"localhost\";\n\n if (!existsSync(dir)) {\n throw new Error(\"PocketBase data directory does not exist\");\n }\n\n // First check if the server is already running by reading node_modules/.vite/_pocketbase_metadata.json\n const metadata = getPocketbaseMetadata(cwd);\n if (metadata) {\n if (metadata.pocketbaseUrl) {\n const pb = new PocketBase(metadata.pocketbaseUrl);\n await authWithRetries(\n pb,\n process.env.POCKETBASE_SUPERUSER_EMAIL!,\n process.env.POCKETBASE_SUPERUSER_PASSWORD!,\n );\n await fn(pb);\n return;\n }\n }\n\n const port = await freePort(host);\n const commandArgs = [\n \"pocketbase-server\",\n \"serve\",\n \"--dir\",\n dir,\n \"--migrationsDir\",\n migrationsDir,\n \"--http\",\n `${host}:${port}`,\n ];\n\n const packageManager = (await detect({ cwd }))?.name ?? \"npm\";\n const { command, args } = resolveCommand(\n packageManager,\n \"execute\",\n commandArgs,\n )!;\n\n // adding --yes as the first parameter helps avoiding the \"Need to install the following packages:\" message\n if (packageManager === \"npm\") args.unshift(\"--yes\");\n\n // Start the PocketBase server process. The package manager wrapper (`npx`)\n // spawns the real binary as a grandchild; put the tree in its own process\n // group so it can be killed as a whole, otherwise `pocketbase serve` outlives\n // us and keeps the data directory open.\n const detached = process.platform !== \"win32\";\n const serverProcess = spawn(command, args, {\n cwd,\n stdio: \"ignore\",\n detached,\n });\n\n // A wrapper that dies before the server listens (missing binary, bad\n // arguments) would otherwise only surface as a port timeout a minute later.\n const exited = new Promise<never>((_, reject) => {\n serverProcess.once(\"exit\", (code, signal) => {\n reject(\n new Error(\n `pocketbase-server exited before listening on ${host}:${port} (${signal ?? `code ${code}`})`,\n ),\n );\n });\n serverProcess.once(\"error\", reject);\n });\n\n try {\n // Wait for the server to be ready\n await Promise.race([\n (async () => {\n await waitForPort(port, host);\n await waitForHealth(`http://${host}:${port}`);\n })(),\n exited,\n ]);\n\n const pb = new PocketBase(`http://${host}:${port}`);\n await authWithRetries(\n pb,\n process.env.POCKETBASE_SUPERUSER_EMAIL!,\n process.env.POCKETBASE_SUPERUSER_PASSWORD!,\n );\n await fn(pb);\n } finally {\n // Ensure we always clean up the process tree\n stopProcessTree(serverProcess, detached);\n }\n}\n\nfunction stopProcessTree(\n child: ReturnType<typeof spawn>,\n detached: boolean,\n): void {\n if (detached && child.pid) {\n try {\n process.kill(-child.pid, \"SIGTERM\");\n return;\n } catch {\n // Group already gone or unsupported; fall through to the plain kill.\n }\n }\n child.kill();\n}\n"],"mappings":";;;;;;;;;;AAWA,IAAaO,oBAAiC,IAAI,IAAI;CACpD;CAAG;CAAG;CAAG;CAAI;CAAI;CAAI;CAAI;CAAI;CAAI;CAAI;CAAI;CAAI;CAAI;CAAI;CAAI;CAAI;CAAI;CAAI;CAAI;CACzE;CAAI;CAAI;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;CACzE;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;CACtE;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;CAAM;CAAM;CACxE;CAAM;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ChB,YAAY;GAEX,AADA,MAAMK,EAAYF,GAAMF,CAAI,GAC5B,MAAMY,EAAc,UAAUZ,EAAK,GAAGE,GAAM;EAC9C,EAAA,CAAG,GACHkD,CACF,CAAC;EAED,IAAMf,IAAK,IAAI5C,EAAW,UAAUO,EAAK,GAAGE,GAAM;EAMlD,AALA,MAAMgB,EACJmB,GACA,QAAQ,IAAI,4BACZ,QAAQ,IAAI,6BACd,GACA,MAAMM,EAAGN,CAAE;CACb,UAAU;EAER,EAAgBa,GAAeD,CAAQ;CACzC;AACF;AAEA,SAASM,EACP,GACA,GACM;CACN,IAAIN,KAAYO,EAAM,KACpB,IAAI;EACF,QAAQ,KAAK,CAACA,EAAM,KAAK,SAAS;EAClC;CACF,QAAQ,CAER;CAEF,EAAM,KAAK;AACb"}
|
|
1
|
+
{"version":3,"file":"pocketbase-BtN-wL8f.js","names":["__exportAll","DATA_DIR","MIGRATIONS_DIR","path","PocketBase","spawn","net","BAD_PORTS","osAssignedPort","server","reject","host","resolve","port","freePort","waitForPort","attempts","tryConnect","socket","maxAttempts","describeFetchError","error","cause","waitForHealth","lastFailure","tryHealth","response","url","pocketbase_exports","authWithRetries","getMigrationFile","getPocketbaseMetadata","migrationDelay","withPocketbase","MIGRATION_DELAY_MS","ending","action","collectionName","migrationFile","readdirSync","options","file","metadataPath","cwd","existsSync","readFileSync","authSuccess","attempt","pb","email","password","dir","migrationsDir","metadata","fn","commandArgs","packageManager","detect","resolveCommand","args","detached","serverProcess","command","exited","signal","code","stopProcessTree","child"],"sources":["../../src/runtime/net.ts","../../src/runtime/pocketbase.ts"],"sourcesContent":["import net from \"node:net\";\n\n/**\n * Ports the Fetch spec tells clients to refuse outright\n * (https://fetch.spec.whatwg.org/#port-blocking). Node's `fetch` enforces the\n * list, so a server bound to one of them is unreachable from `waitForHealth`\n * and the PocketBase SDK alike: the request fails with cause \"bad port\"\n * before a connection is even attempted. 10080 sat inside the 10000–19999\n * range ports used to be drawn from, and cost a CI run a 30-second health\n * timeout whenever the draw landed on it.\n */\nexport const BAD_PORTS: ReadonlySet<number> = new Set([\n 1, 7, 9, 11, 13, 15, 17, 19, 20, 21, 22, 23, 25, 37, 42, 43, 53, 69, 77, 79,\n 87, 95, 101, 102, 103, 104, 109, 110, 111, 113, 115, 117, 119, 123, 135, 137,\n 139, 143, 161, 179, 389, 427, 465, 512, 513, 514, 515, 526, 530, 531, 532,\n 540, 548, 554, 556, 563, 587, 601, 636, 989, 990, 993, 995, 1719, 1720, 1723,\n 2049, 3659, 4045, 4190, 5060, 5061, 6000, 6566, 6665, 6666, 6667, 6668, 6669,\n 6679, 6697, 10080,\n]);\n\nfunction osAssignedPort(host: string): Promise<number> {\n return new Promise((resolve, reject) => {\n const server = net.createServer();\n server.unref();\n server.once(\"error\", reject);\n server.listen(0, host, () => {\n const { port } = server.address() as net.AddressInfo;\n server.close(() => resolve(port));\n });\n });\n}\n\n/**\n * A port nothing is listening on right now, taken from the OS's ephemeral\n * range so it neither collides with whatever else the machine runs nor hits\n * `BAD_PORTS`. The port is released again before this resolves, so the\n * caller's server has to bind it promptly.\n */\nexport async function freePort(host: string): Promise<number> {\n for (;;) {\n const port = await osAssignedPort(host);\n if (!BAD_PORTS.has(port)) return port;\n }\n}\n\n// Wait for the port to be available. A cold `npx pocketbase-server` on a CI\n// runner can take well over the five seconds the old default allowed.\nexport function waitForPort(\n port: number,\n host: string,\n maxAttempts = 60,\n): Promise<void> {\n return new Promise((resolve, reject) => {\n let attempts = 0;\n\n const tryConnect = () => {\n attempts++;\n\n const socket = new net.Socket();\n\n const onError = () => {\n socket.destroy();\n\n if (attempts === maxAttempts) {\n reject(\n new Error(`Timed out waiting for port ${port} to be available`),\n );\n return;\n }\n\n setTimeout(tryConnect, 500);\n };\n\n socket.once(\"error\", onError);\n\n socket.connect(port, host, () => {\n socket.destroy();\n resolve();\n });\n };\n\n tryConnect();\n });\n}\n\n/**\n * `fetch` wraps the interesting part in `cause`: an errno error for a\n * connection that was refused, or a bare string such as \"bad port\" for a\n * request undici declined to make.\n */\nfunction describeFetchError(error: unknown): string {\n if (!(error instanceof Error)) return String(error);\n const { cause } = error as Error & { cause?: unknown };\n if (cause instanceof Error) {\n const code = (cause as NodeJS.ErrnoException).code;\n return code || cause.message || error.message;\n }\n if (cause !== undefined) return String(cause);\n return error.message;\n}\n\n// Wait for the health check to be successful\nexport function waitForHealth(url: string, maxAttempts = 60): Promise<void> {\n return new Promise((resolve, reject) => {\n let attempts = 0;\n let lastFailure = \"no attempt made\";\n\n const tryHealth = async () => {\n attempts++;\n\n try {\n const response = await fetch(`${url}/api/health`);\n if (response.status === 200) {\n resolve();\n return;\n }\n lastFailure = `HTTP ${response.status}`;\n } catch (error) {\n lastFailure = describeFetchError(error);\n }\n\n if (attempts === maxAttempts) {\n reject(\n new Error(\n `Timed out waiting for health check at ${url}/api/health (last attempt: ${lastFailure})`,\n ),\n );\n return;\n }\n\n setTimeout(tryHealth, 500);\n };\n\n tryHealth();\n });\n}\n","import { existsSync, readdirSync, readFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport PocketBase from \"pocketbase\";\nimport { detect } from \"package-manager-detector\";\nimport { resolveCommand } from \"package-manager-detector/commands\";\nimport spawn from \"cross-spawn\";\nimport { freePort, waitForPort, waitForHealth } from \"./net\";\nimport type { Options } from \"../core/types\";\nimport { DATA_DIR, MIGRATIONS_DIR } from \"../core/constants\";\n\n/**\n * PocketBase names migration files with a 1-second-resolution Unix timestamp\n * (e.g. `1776099881_created_users.js`). Two schema operations issued in the\n * same wall-clock second produce files that sort alphabetically by their\n * action/collection suffix — which reverses the intended order whenever a\n * later migration depends on an earlier one. Wait out the full second between\n * migration-producing calls so the timestamps stay distinct.\n */\nconst MIGRATION_DELAY_MS = 1100;\n\nexport function migrationDelay(): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, MIGRATION_DELAY_MS));\n}\n\nexport function getMigrationFile(\n collectionName: string,\n action: \"created\" | \"deleted\" | \"updated\",\n options: Options,\n): string | undefined {\n const ending = `${action}_${collectionName}.js`;\n\n // find last file with ending in migrations dir\n const migrationFiles = readdirSync(\n path.join(options.root, MIGRATIONS_DIR),\n ).filter((file) => file.endsWith(ending));\n\n const migrationFile = migrationFiles.sort().pop();\n\n if (!migrationFile) {\n return undefined;\n }\n\n return path.join(options.root, MIGRATIONS_DIR, migrationFile);\n}\n\nexport function getPocketbaseMetadata(cwd: string): {\n pocketbaseUrl: string;\n vitePort: number;\n} | null {\n const metadataPath = path.join(\n cwd,\n \"node_modules\",\n \".vite\",\n \"_pocketbase_metadata.json\",\n );\n if (existsSync(metadataPath)) {\n return JSON.parse(readFileSync(metadataPath, \"utf8\"));\n }\n return null;\n}\n\nexport async function authWithRetries(\n pb: PocketBase,\n email: string,\n password: string,\n) {\n // Retry authentication up to 3 times with 100ms backoff\n let authSuccess = false;\n for (let attempt = 1; attempt <= 3; attempt++) {\n try {\n await pb.collection(\"_superusers\").authWithPassword(email, password);\n authSuccess = true;\n break;\n } catch {\n if (attempt < 3) {\n await new Promise((resolve) => setTimeout(resolve, 100));\n }\n }\n }\n\n if (!authSuccess) {\n throw new Error(\n \"Failed to authenticate with PocketBase. Check your superuser credentials.\",\n );\n }\n}\n\nexport async function withPocketbase(\n cwd: string,\n fn: (pb: PocketBase) => Promise<void>,\n) {\n const dir = path.join(cwd, DATA_DIR);\n const migrationsDir = path.join(cwd, MIGRATIONS_DIR);\n const host = \"localhost\";\n\n if (!existsSync(dir)) {\n throw new Error(\"PocketBase data directory does not exist\");\n }\n\n // First check if the server is already running by reading node_modules/.vite/_pocketbase_metadata.json\n const metadata = getPocketbaseMetadata(cwd);\n if (metadata) {\n if (metadata.pocketbaseUrl) {\n const pb = new PocketBase(metadata.pocketbaseUrl);\n await authWithRetries(\n pb,\n process.env.POCKETBASE_SUPERUSER_EMAIL!,\n process.env.POCKETBASE_SUPERUSER_PASSWORD!,\n );\n await fn(pb);\n return;\n }\n }\n\n const port = await freePort(host);\n const commandArgs = [\n \"pocketbase-server\",\n \"serve\",\n \"--dir\",\n dir,\n \"--migrationsDir\",\n migrationsDir,\n \"--http\",\n `${host}:${port}`,\n ];\n\n const packageManager = (await detect({ cwd }))?.name ?? \"npm\";\n const { command, args } = resolveCommand(\n packageManager,\n \"execute\",\n commandArgs,\n )!;\n\n // adding --yes as the first parameter helps avoiding the \"Need to install the following packages:\" message\n if (packageManager === \"npm\") args.unshift(\"--yes\");\n\n // Start the PocketBase server process. The package manager wrapper (`npx`)\n // spawns the real binary as a grandchild; put the tree in its own process\n // group so it can be killed as a whole, otherwise `pocketbase serve` outlives\n // us and keeps the data directory open.\n const detached = process.platform !== \"win32\";\n const serverProcess = spawn(command, args, {\n cwd,\n stdio: \"ignore\",\n detached,\n });\n\n // A wrapper that dies before the server listens (missing binary, bad\n // arguments) would otherwise only surface as a port timeout a minute later.\n const exited = new Promise<never>((_, reject) => {\n serverProcess.once(\"exit\", (code, signal) => {\n reject(\n new Error(\n `pocketbase-server exited before listening on ${host}:${port} (${signal ?? `code ${code}`})`,\n ),\n );\n });\n serverProcess.once(\"error\", reject);\n });\n\n try {\n // Wait for the server to be ready\n await Promise.race([\n (async () => {\n await waitForPort(port, host);\n await waitForHealth(`http://${host}:${port}`);\n })(),\n exited,\n ]);\n\n const pb = new PocketBase(`http://${host}:${port}`);\n await authWithRetries(\n pb,\n process.env.POCKETBASE_SUPERUSER_EMAIL!,\n process.env.POCKETBASE_SUPERUSER_PASSWORD!,\n );\n await fn(pb);\n } finally {\n // Ensure we always clean up the process tree\n stopProcessTree(serverProcess, detached);\n }\n}\n\nfunction stopProcessTree(\n child: ReturnType<typeof spawn>,\n detached: boolean,\n): void {\n if (detached && child.pid) {\n try {\n process.kill(-child.pid, \"SIGTERM\");\n return;\n } catch {\n // Group already gone or unsupported; fall through to the plain kill.\n }\n }\n child.kill();\n}\n"],"mappings":";;;;;;;;;;AAWA,IAAaO,oBAAiC,IAAI,IAAI;CACpD;CAAG;CAAG;CAAG;CAAI;CAAI;CAAI;CAAI;CAAI;CAA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AQ,aAAa,SAChCC,IAAgBxD,EAAMyD,GAASH,GAAM;EACzC;EACA,OAAO;EACP;CACF,CAAC,GAIKI,IAAS,IAAI,SAAgB,GAAG,MAAW;EAQ/C,AAPAF,EAAc,KAAK,SAAS,GAAM,MAAW;GAC3C,EACE,gBAAI,MACF,gDAAgDlD,EAAK,GAAGE,EAAK,IAAImD,KAAU,QAAQC,IAAO,EAC5F,CACF;EACF,CAAC,GACDJ,EAAc,KAAK,SAASnD,CAAM;CACpC,CAAC;CAED,IAAI;EAEF,MAAM,QAAQ,KAAK,EAChB,YAAY;GAEX,AADA,MAAMK,EAAYF,GAAMF,CAAI,GAC5B,MAAMY,EAAc,UAAUZ,EAAK,GAAGE,GAAM;EAC9C,EAAA,CAAG,GACHkD,CACF,CAAC;EAED,IAAMf,IAAK,IAAI5C,EAAW,UAAUO,EAAK,GAAGE,GAAM;EAMlD,AALA,MAAMgB,EACJmB,GACA,QAAQ,IAAI,4BACZ,QAAQ,IAAI,6BACd,GACA,MAAMM,EAAGN,CAAE;CACb,UAAU;EAER,EAAgBa,GAAeD,CAAQ;CACzC;AACF;AAEA,SAASM,EACP,GACA,GACM;CACN,IAAIN,KAAYO,EAAM,KACpB,IAAI;EACF,QAAQ,KAAK,CAACA,EAAM,KAAK,SAAS;EAClC;CACF,QAAQ,CAER;CAEF,EAAM,KAAK;AACb"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as e, s as t } from "./providers-CL9kQ4hp.js";
|
|
2
|
-
import { readEnvVarNames as n } from "./env-vars-
|
|
2
|
+
import { readEnvVarNames as n } from "./env-vars-0hvKe55u.js";
|
|
3
3
|
import r from "node:fs";
|
|
4
4
|
import i from "node:path";
|
|
5
5
|
//#region src/runtime/providers.ts
|
|
@@ -35,4 +35,4 @@ function s(e) {
|
|
|
35
35
|
//#endregion
|
|
36
36
|
export { a as detectProviders };
|
|
37
37
|
|
|
38
|
-
//# sourceMappingURL=providers-
|
|
38
|
+
//# sourceMappingURL=providers-DRwJnSzb.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"providers-
|
|
1
|
+
{"version":3,"file":"providers-DRwJnSzb.js","names":["capabilityName","providerMarkers","fs","path","detectProviders","detected","present","markerProbe","root","pattern","patterns","ids","provider","capability","envNames","dependencies","marker","readEnvVarNames","readDependencies","file","pkg"],"sources":["../../src/runtime/providers.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { capabilityName, providerMarkers } from \"../core/providers\";\nimport type { DetectedProviders, Pattern, ProviderMarker } from \"../core/types\";\nimport { readEnvVarNames } from \"./env-vars\";\n\ntype DetectablePattern = Pick<\n Pattern,\n \"slug\" | \"providers\" | \"inheritsProvider\"\n>;\n\n/**\n * The provider in use for each capability, read from what the providers left\n * in the project. Nothing records the choice, so this is the only way to know\n * it. A pattern that inherits its provider is skipped: its files say nothing\n * the capability it is built on doesn't already.\n *\n * The registry is passed in rather than imported, so this module and the\n * package entry don't import each other.\n */\nexport function detectProviders(\n root: string,\n patterns: readonly DetectablePattern[],\n): DetectedProviders {\n const detected: DetectedProviders = { providers: {}, ambiguous: [] };\n const present = markerProbe(root);\n\n for (const pattern of patterns) {\n if (!pattern.providers?.length || pattern.inheritsProvider) continue;\n const ids = pattern.providers\n .filter((provider) => providerMarkers(provider).some(present))\n .map((provider) => provider.id);\n\n const capability = capabilityName(pattern.slug);\n if (ids.length === 1) detected.providers[capability] = ids[0];\n if (ids.length > 1) detected.ambiguous.push({ capability, ids });\n }\n\n return detected;\n}\n\n/** Checks one marker against the project; `src/env.ts` and `package.json` are read once. */\nfunction markerProbe(root: string): (marker: ProviderMarker) => boolean {\n let envNames: Set<string> | undefined;\n let dependencies: Set<string> | undefined;\n\n return (marker) => {\n if (\"env\" in marker) {\n envNames ??= readEnvVarNames(root);\n return envNames.has(marker.env);\n }\n if (\"path\" in marker) {\n return fs.existsSync(path.join(root, marker.path));\n }\n dependencies ??= readDependencies(root);\n return dependencies.has(marker.dependency);\n };\n}\n\nfunction readDependencies(root: string): Set<string> {\n const file = path.join(root, \"package.json\");\n if (!fs.existsSync(file)) return new Set();\n try {\n const pkg = JSON.parse(fs.readFileSync(file, \"utf8\")) as {\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n };\n return new Set([\n ...Object.keys(pkg.dependencies ?? {}),\n ...Object.keys(pkg.devDependencies ?? {}),\n ]);\n } catch {\n return new Set();\n }\n}\n"],"mappings":";;;;;AAoBA,SAAgBI,EACd,GACA,GACmB;CACnB,IAAMC,IAA8B;EAAE,WAAW,CAAC;EAAG,WAAW,CAAC;CAAE,GAC7DC,IAAUC,EAAYC,CAAI;CAEhC,KAAK,IAAMC,KAAWC,GAAU;EAC9B,IAAI,CAACD,EAAQ,WAAW,UAAUA,EAAQ,kBAAkB;EAC5D,IAAME,IAAMF,EAAQ,UACjB,QAAQ,MAAaR,EAAgBW,CAAQ,CAAC,CAAC,KAAKN,CAAO,CAAC,CAAC,CAC7D,KAAK,MAAaM,EAAS,EAAE,GAE1BC,IAAab,EAAeS,EAAQ,IAAI;EAE9C,AADIE,EAAI,WAAW,MAAG,EAAS,UAAUE,KAAcF,EAAI,KACvDA,EAAI,SAAS,KAAGN,EAAS,UAAU,KAAK;GAAE;GAAY;EAAI,CAAC;CACjE;CAEA,OAAOA;AACT;AAGA,SAASE,EAAY,GAAmD;CACtE,IAAIO,GACAC;CAEJ,QAAQ,MACF,SAASC,KACX,MAAaC,EAAgBT,CAAI,GAC1BM,EAAS,IAAIE,EAAO,GAAG,KAE5B,UAAUA,IACLd,EAAG,WAAWC,EAAK,KAAKK,GAAMQ,EAAO,IAAI,CAAC,KAEnD,MAAiBE,EAAiBV,CAAI,GAC/BO,EAAa,IAAIC,EAAO,UAAU;AAE7C;AAEA,SAASE,EAAiB,GAA2B;CACnD,IAAMC,IAAOhB,EAAK,KAAKK,GAAM,cAAc;CAC3C,IAAI,CAACN,EAAG,WAAWiB,CAAI,GAAG,uBAAO,IAAI,IAAI;CACzC,IAAI;EACF,IAAMC,IAAM,KAAK,MAAMlB,EAAG,aAAaiB,GAAM,MAAM,CAAC;EAIpD,uBAAO,IAAI,IAAI,CACb,GAAG,OAAO,KAAKC,EAAI,gBAAgB,CAAC,CAAC,GACrC,GAAG,OAAO,KAAKA,EAAI,mBAAmB,CAAC,CAAC,CAC1C,CAAC;CACH,QAAQ;EACN,uBAAO,IAAI,IAAI;CACjB;AACF"}
|
|
@@ -15,7 +15,7 @@ async function n(e, t) {
|
|
|
15
15
|
exists: !0,
|
|
16
16
|
rowCount: 0
|
|
17
17
|
}));
|
|
18
|
-
let { withPocketbase: n } = await import("./pocketbase-
|
|
18
|
+
let { withPocketbase: n } = await import("./pocketbase-BtN-wL8f.js").then((e) => e.r), { planCollectionDrops: r } = await import("./collections-BYcVyY9O.js").then((e) => e.n), i = [];
|
|
19
19
|
return await n(t.root, async (t) => {
|
|
20
20
|
let n = await r(t, e);
|
|
21
21
|
i.push(...n);
|
|
@@ -24,4 +24,4 @@ async function n(e, t) {
|
|
|
24
24
|
//#endregion
|
|
25
25
|
export { t as n, n as t };
|
|
26
26
|
|
|
27
|
-
//# sourceMappingURL=shared-
|
|
27
|
+
//# sourceMappingURL=shared-BbxLil4g.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared-
|
|
1
|
+
{"version":3,"file":"shared-BbxLil4g.js","names":["languageFromPath","toDeleteEntry","path","planDropsForCollections","collectionNames","options","n","drops","withPocketbase","plans","planCollectionDrops","pb"],"sources":["../../src/patterns/destroy/shared.ts"],"sourcesContent":["import type { CollectionDropSpec, File, Options } from \"../../core/types\";\nimport { languageFromPath } from \"../../core/util\";\n\nexport function toDeleteEntry(path: string): File {\n return {\n path,\n language: languageFromPath(path),\n content: \"\",\n status: \"success\",\n };\n}\n\n/**\n * Build `CollectionDropSpec` entries for each collection name, with live row\n * counts from PocketBase when `env === \"runtime\"`. In preview mode, returns\n * `{ exists: true, rowCount: 0 }` placeholders.\n */\nexport async function planDropsForCollections(\n collectionNames: string[],\n options: Options,\n): Promise<CollectionDropSpec[]> {\n if (collectionNames.length === 0) return [];\n\n if (options.env !== \"runtime\") {\n return collectionNames.map((name) => ({\n name,\n exists: true,\n rowCount: 0,\n }));\n }\n\n const { withPocketbase } = await import(\"../../runtime/pocketbase\");\n const { planCollectionDrops } = await import(\"../../runtime/collections\");\n const drops: CollectionDropSpec[] = [];\n await withPocketbase(options.root, async (pb) => {\n const plans = await planCollectionDrops(pb, collectionNames);\n drops.push(...plans);\n });\n return drops;\n}\n"],"mappings":";;AAGA,SAAgBC,EAAc,GAAoB;CAChD,OAAO;EACL;EACA,UAAUD,EAAiBE,CAAI;EAC/B,SAAS;EACT,QAAQ;CACV;AACF;AAOA,eAAsBC,EACpB,GACA,GAC+B;CAC/B,IAAIC,EAAgB,WAAW,GAAG,OAAO,CAAC;CAE1C,IAAIC,EAAQ,QAAQ,WAClB,OAAOD,EAAgB,KAAK,OAAU;EACpC;EACA,QAAQ;EACR,UAAU;CACZ,EAAE;CAGJ,IAAM,EAAE,sBAAmB,MAAM,OAAO,2BAAA,CAAA,MAAA,MAAAE,EAAA,CAAA,GAClC,EAAE,2BAAwB,MAAM,OAAO,4BAAA,CAAA,MAAA,MAAAA,EAAA,CAAA,GACvCC,IAA8B,CAAC;CAKrC,OAJA,MAAMC,EAAeH,EAAQ,MAAM,OAAO,MAAO;EAC/C,IAAMI,IAAQ,MAAMC,EAAoBC,GAAIP,CAAe;EAC3D,EAAM,KAAK,GAAGK,CAAK;CACrB,CAAC,GACMF;AACT"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as e } from "./util-BLYliuUK.js";
|
|
2
2
|
import { n as t } from "./logger-CQONztPm.js";
|
|
3
|
-
import { i as n } from "./pocketbase-
|
|
3
|
+
import { i as n } from "./pocketbase-BtN-wL8f.js";
|
|
4
4
|
import r from "node:fs";
|
|
5
5
|
import i from "node:path";
|
|
6
6
|
//#region src/runtime/site.ts
|
|
@@ -105,4 +105,4 @@ async function h(n, i) {
|
|
|
105
105
|
//#endregion
|
|
106
106
|
export { o as a, d as i, m as n, a as o, c as r, h as t };
|
|
107
107
|
|
|
108
|
-
//# sourceMappingURL=site-
|
|
108
|
+
//# sourceMappingURL=site-Dw2KIRJu.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"site-
|
|
1
|
+
{"version":3,"file":"site-Dw2KIRJu.js","names":["intl","languageFromPath","getLogger","withPocketbase","fs","path","sitePath","root","siteModule","quote","name","currency","url","currencyLines","normalizeCurrency","raw","code","SITE_OBJECT","withSiteCurrency","match","source","body","siteCurrency","value","existingName","options","appName","pb","pkg","ensureSiteFile","file","ensureSiteCurrency","existing","next"],"sources":["../../src/runtime/site.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { File, Options } from \"../core/types\";\nimport { getLogger } from \"../core/logger\";\nimport { languageFromPath } from \"../core/util\";\nimport { withPocketbase } from \"./pocketbase\";\n\n/** Where every VelaStack app keeps its name and public URL. */\nexport function sitePath(root: string): string {\n return path.join(root, \"src\", \"lib\", \"site.ts\");\n}\n\n/**\n * `src/lib/site.ts` as the CLI templates ship it (`site.template.ts`), with\n * the placeholders filled in, plus the business's currency when one is given.\n */\nexport function siteModule(\n name: string,\n url = \"http://localhost:5173\",\n currency?: string,\n): string {\n return [\n \"/**\",\n \" * Site-wide metadata, and the one place the app's name and public URL live.\",\n \" *\",\n \" * Set `url` to where the site is deployed: canonical links, Open Graph images\",\n \" * and feeds are built from it, including in prerendered pages. With a backend,\",\n \" * `vela dev` and `vela deploy` copy `name` into PocketBase's application name\",\n \" * for the emails it sends, so change it here rather than in the admin panel.\",\n \" */\",\n \"export const site = {\",\n `\\tname: ${quote(name)},`,\n currency\n ? [`\\turl: ${quote(url)},`, ...currencyLines(currency)].join(\"\\n\")\n : `\\turl: ${quote(url)}`,\n \"};\",\n \"\",\n ].join(\"\\n\");\n}\n\n/** The `currency` property, with what it means; no trailing comma, as the last property. */\nfunction currencyLines(currency: string): string[] {\n return [\n \"\\t/** ISO 4217: the currency the business prices in and is paid in. */\",\n `\\tcurrency: ${quote(currency)}`,\n ];\n}\n\n/** A three-letter code `Intl` knows, upper-cased; anything else is refused. */\nexport function normalizeCurrency(raw: unknown): string | null {\n if (typeof raw !== \"string\") return null;\n const code = raw.trim().toUpperCase();\n if (!/^[A-Z]{3}$/.test(code)) return null;\n // Any well-formed code formats, so ask for the list of real ones. Node has\n // had it since 18; the repo's ES2020 lib types just don't declare it.\n const intl = Intl as unknown as {\n supportedValuesOf: (key: \"currency\") => string[];\n };\n return intl.supportedValuesOf(\"currency\").includes(code) ? code : null;\n}\n\nconst SITE_OBJECT = /export const site = \\{\\n([\\s\\S]*?)\\n\\};/;\n\n/**\n * `src/lib/site.ts` with `currency` added as the object's last property,\n * or `null` when it already has one (a project's currency is never changed\n * behind its back) or has no `export const site = { ... };` to add it to.\n */\nexport function withSiteCurrency(\n source: string,\n currency: string,\n): string | null {\n const match = SITE_OBJECT.exec(source);\n if (!match || /^\\s*currency\\s*:/m.test(match[1])) return null;\n const body = match[1].replace(/,?\\s*$/, \",\");\n return source.replace(\n match[0],\n `export const site = {\\n${body}\\n${currencyLines(currency).join(\"\\n\")}\\n};`,\n );\n}\n\n/** The currency `src/lib/site.ts` declares, if any. */\nexport function siteCurrency(root: string): string | null {\n try {\n const source = fs.readFileSync(sitePath(root), \"utf8\");\n return (\n /^\\s*currency\\s*:\\s*['\"]([A-Za-z]{3})['\"]/m.exec(source)?.[1] ?? null\n );\n } catch {\n return null;\n }\n}\n\n/** Single-quoted, as the templates write their strings. */\nfunction quote(value: string): string {\n return `'${value.replace(/\\\\/g, \"\\\\\\\\\").replace(/'/g, \"\\\\'\")}'`;\n}\n\n/**\n * The name a project created before `site.ts` existed already goes by.\n *\n * Those projects kept it in PocketBase's settings, so that is asked first; the\n * package name is the fallback for a project without a backend, or one whose\n * database can't be reached.\n */\nasync function existingName(options: Options): Promise<string> {\n if (options.features.backend) {\n try {\n let appName: unknown;\n await withPocketbase(options.root, async (pb) => {\n const settings = (await pb.settings.getAll()) as {\n meta?: { appName?: unknown };\n };\n appName = settings.meta?.appName;\n });\n if (typeof appName === \"string\" && appName.trim()) return appName;\n } catch {\n // No database to ask; fall through to package.json.\n }\n }\n\n try {\n const pkg = JSON.parse(\n fs.readFileSync(path.join(options.root, \"package.json\"), \"utf8\"),\n ) as { name?: unknown };\n if (typeof pkg.name === \"string\" && pkg.name.trim()) return pkg.name;\n } catch {\n // No package.json to name the site after; the placeholder stands.\n }\n return \"My App\";\n}\n\n/**\n * Create `src/lib/site.ts` for a pattern whose files import `#lib/site.js`, when\n * the project doesn't have one yet. Every template ships it; projects created\n * before that read the app name from `locals.meta` instead.\n *\n * Returns null when the file exists, so an existing one is never overwritten.\n */\nexport async function ensureSiteFile(options: Options): Promise<File | null> {\n const file = sitePath(options.root);\n if (fs.existsSync(file)) return null;\n\n getLogger(options).info(\"Creating src/lib/site.ts\");\n return {\n path: file,\n language: languageFromPath(file),\n content: siteModule(await existingName(options)),\n status: \"success\",\n };\n}\n\n/**\n * Make `src/lib/site.ts` declare the business's currency: create the file\n * with it, or add it to an existing one that has none. An existing currency\n * is kept, whatever `currency` says; the result says which it was.\n */\nexport async function ensureSiteCurrency(\n options: Options,\n currency: string,\n): Promise<{ file: File | null; currency: string }> {\n const file = sitePath(options.root);\n if (!fs.existsSync(file)) {\n getLogger(options).info(\"Creating src/lib/site.ts\");\n return {\n file: {\n path: file,\n language: languageFromPath(file),\n content: siteModule(await existingName(options), undefined, currency),\n status: \"success\",\n },\n currency,\n };\n }\n const existing = siteCurrency(options.root);\n if (existing) return { file: null, currency: existing };\n const next = withSiteCurrency(fs.readFileSync(file, \"utf8\"), currency);\n if (next === null) return { file: null, currency };\n getLogger(options).info(`Adding currency ${currency} to src/lib/site.ts`);\n return {\n file: {\n path: file,\n language: languageFromPath(file),\n content: next,\n status: \"success\",\n },\n currency,\n };\n}\n"],"mappings":";;;;;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,GAAU,OAAO;EAAE,MAAM;EAAM,UAAUA;CAAS;CACtD,IAAMC,IAAOf,EAAiBd,EAAG,aAAa0B,GAAM,MAAM,GAAGnB,CAAQ;CAGrE,OAFIsB,MAAS,OAAa;EAAE,MAAM;EAAM;CAAS,KACjD/B,EAAUuB,CAAO,CAAC,CAAC,KAAK,mBAAmBd,EAAS,oBAAoB,GACjE;EACL,MAAM;GACJ,MAAMmB;GACN,UAAU7B,EAAiB6B,CAAI;GAC/B,SAASG;GACT,QAAQ;EACV;EACA;CACF;AACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { n as e } from "./rolldown-runtime-5HNE8Q1r.js";
|
|
2
2
|
import { r as t, t as n } from "./errors-DR3gF_7a.js";
|
|
3
3
|
import { n as r } from "./lib-specifier-Cngo1zF_.js";
|
|
4
|
-
import {
|
|
4
|
+
import { f as i } from "./constants-Bdx8mp7v.js";
|
|
5
5
|
import { existsSync as a, readFileSync as o } from "node:fs";
|
|
6
6
|
import s from "node:path";
|
|
7
7
|
var c = 1e4;
|
|
@@ -124,4 +124,4 @@ function T(e, t) {
|
|
|
124
124
|
//#endregion
|
|
125
125
|
export { f as a, u as i, v as n, _ as r, T as t };
|
|
126
126
|
|
|
127
|
-
//# sourceMappingURL=table-core-
|
|
127
|
+
//# sourceMappingURL=table-core-BHFT-uMX.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-core-BPv_RYgD.js","names":["__exportAll","RegistryUnavailableError","InvalidArgumentError","libAliasPath","TANSTACK_TABLE_CORE","path","REGISTRY_TIMEOUT_MS","optionalString","value","readComponentsConfig","raw","configPath","root","existsSync","parsed","readFileSync","aliases","key","alias","DEFAULT_UI_DIR","resolveUiDir","rel","registryIndexUrl","registry","style","indexCache","parseIndex","body","items","entry","name","type","requestIndex","response","fetchImpl","url","error","reason","fetchRegistryIndex","config","options","cache","pending","table_core_exports","TABLE_CORE_COMPONENTS","assertTableCorePackage","assertTableCoreV9","declaredTableCoreMajor","MIGRATION_GUIDE","packageJsonPath","pkg","major","hasV8DataTable","index","upgradeSteps","outdatedPackage","found","tableComponents","components","component"],"sources":["../../src/runtime/registry.ts","../../src/runtime/table-core.ts"],"sourcesContent":["import { existsSync, readFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport type { RegistryItem, WriteResultRuntime } from \"../core/types\";\nimport { RegistryUnavailableError } from \"../core/errors\";\nimport { libAliasPath } from \"./lib-specifier\";\n\n/**\n * shadcn-svelte's schema defaults. A `components.json` that names no `style`\n * resolves to `nova` (not `vega`, whatever `getRegistryUrl`'s fallback says),\n * which is why the CLI's templates write the key explicitly.\n */\nexport const DEFAULT_STYLE = \"nova\";\nexport const DEFAULT_REGISTRY = \"https://shadcn-svelte.com/registry\";\nexport const DEFAULT_CSS_PATH = \"src/app.css\";\n\nconst REGISTRY_TIMEOUT_MS = 10_000;\n\nexport interface ComponentsConfig {\n style: string;\n registry: string;\n baseColor?: string;\n iconLibrary?: string;\n menuColor?: string;\n menuAccent?: string;\n aliases: Record<string, string>;\n /** `tailwind.css`: the global stylesheet, relative to the root. */\n cssPath: string;\n}\n\ninterface RawComponentsConfig {\n style?: unknown;\n registry?: unknown;\n iconLibrary?: unknown;\n menuColor?: unknown;\n menuAccent?: unknown;\n tailwind?: { css?: unknown; baseColor?: unknown };\n aliases?: Record<string, unknown>;\n}\n\nfunction optionalString(value: unknown): string | undefined {\n return typeof value === \"string\" && value.length > 0 ? value : undefined;\n}\n\n/**\n * The project's `components.json` with the schema defaults filled in. A\n * missing or unreadable file behaves like an empty one, so callers can still\n * compute paths and the existence checks here agree with shadcn's own.\n */\nexport function readComponentsConfig(root: string): ComponentsConfig {\n let raw: RawComponentsConfig = {};\n const configPath = path.join(root, \"components.json\");\n if (existsSync(configPath)) {\n try {\n const parsed: unknown = JSON.parse(readFileSync(configPath, \"utf8\"));\n if (parsed && typeof parsed === \"object\") {\n raw = parsed as RawComponentsConfig;\n }\n } catch {\n raw = {};\n }\n }\n\n const aliases: Record<string, string> = {};\n for (const [key, value] of Object.entries(raw.aliases ?? {})) {\n const alias = optionalString(value);\n if (alias) aliases[key] = alias;\n }\n\n return {\n style: optionalString(raw.style) ?? DEFAULT_STYLE,\n registry: optionalString(raw.registry) ?? DEFAULT_REGISTRY,\n baseColor: optionalString(raw.tailwind?.baseColor),\n iconLibrary: optionalString(raw.iconLibrary),\n menuColor: optionalString(raw.menuColor),\n menuAccent: optionalString(raw.menuAccent),\n aliases,\n cssPath: optionalString(raw.tailwind?.css) ?? DEFAULT_CSS_PATH,\n };\n}\n\nconst DEFAULT_UI_DIR = [\"src\", \"lib\", \"components\", \"ui\"];\n\n/**\n * Where shadcn-svelte writes items: `components.json` `aliases.ui`, resolved\n * under `src/lib` for `#lib/...`, or the alias a project from before\n * SvelteKit 3 still has.\n * Anything else (a custom alias, a missing or unreadable config) falls back\n * to the default so the existence check here and shadcn's own target agree\n * for every project the CLI creates.\n */\nexport function resolveUiDir(root: string): string {\n const alias = readComponentsConfig(root).aliases.ui;\n const rel = alias === undefined ? null : libAliasPath(alias);\n if (rel === null) {\n return path.join(root, ...DEFAULT_UI_DIR);\n }\n return path.join(root, \"src\", \"lib\", ...rel.split(\"/\").filter(Boolean));\n}\n\n/** `${registry}/styles/${style}/index.json`: the items one style offers. */\nexport function registryIndexUrl(registry: string, style: string): string {\n return `${registry.replace(/\\/+$/, \"\")}/styles/${encodeURIComponent(style)}/index.json`;\n}\n\n/**\n * One request per registry URL per process, keyed on the fetch implementation\n * so an injected test double never sees another test's answer and the real\n * `fetch` shares its answer across a style switch and the installs it runs.\n */\nconst indexCache = new WeakMap<\n typeof fetch,\n Map<string, Promise<RegistryItem[]>>\n>();\n\nfunction parseIndex(body: unknown): RegistryItem[] {\n if (!Array.isArray(body)) {\n throw new Error(\"the index is not a list\");\n }\n const items: RegistryItem[] = [];\n for (const entry of body) {\n if (!entry || typeof entry !== \"object\") continue;\n const { name, type } = entry as { name?: unknown; type?: unknown };\n if (typeof name === \"string\" && typeof type === \"string\") {\n items.push({ name, type });\n }\n }\n return items;\n}\n\nasync function requestIndex(\n url: string,\n fetchImpl: typeof fetch,\n): Promise<RegistryItem[]> {\n let response: Response;\n try {\n response = await fetchImpl(url, {\n signal: AbortSignal.timeout(REGISTRY_TIMEOUT_MS),\n });\n } catch (error) {\n const reason =\n error instanceof Error && error.name === \"TimeoutError\"\n ? `no answer within ${REGISTRY_TIMEOUT_MS / 1000}s`\n : error instanceof Error\n ? error.message\n : String(error);\n throw new RegistryUnavailableError(url, reason);\n }\n if (!response.ok) {\n throw new RegistryUnavailableError(url, `HTTP ${response.status}`);\n }\n try {\n return parseIndex(await response.json());\n } catch (error) {\n throw new RegistryUnavailableError(\n url,\n error instanceof Error ? error.message : String(error),\n );\n }\n}\n\n/**\n * The items the project's registry offers for a style: the configured one by\n * default, or `options.style` to look at the style a project is about to\n * switch to. Throws `RegistryUnavailableError` when the index cannot be read.\n */\nexport async function fetchRegistryIndex(\n root: string,\n options: { style?: string; runtime?: WriteResultRuntime } = {},\n): Promise<RegistryItem[]> {\n const config = readComponentsConfig(root);\n const url = registryIndexUrl(config.registry, options.style ?? config.style);\n const fetchImpl = options.runtime?.fetch ?? globalThis.fetch;\n\n let cache = indexCache.get(fetchImpl);\n if (!cache) {\n cache = new Map();\n indexCache.set(fetchImpl, cache);\n }\n let pending = cache.get(url);\n if (!pending) {\n pending = requestIndex(url, fetchImpl).catch((error: unknown) => {\n // A failed read is not worth remembering: the next command may be online.\n cache.delete(url);\n throw error;\n });\n cache.set(url, pending);\n }\n return pending;\n}\n","import { existsSync, readFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport {\n TANSTACK_TABLE_CORE,\n TANSTACK_TABLE_CORE_MAJOR,\n} from \"../core/constants\";\nimport { InvalidArgumentError } from \"../core/errors\";\nimport { resolveUiDir } from \"./registry\";\n\n/** The components this package ships that are built on `@tanstack/table-core`. */\nexport const TABLE_CORE_COMPONENTS = [\n \"data-table\",\n \"column-header\",\n \"faceted-filter\",\n \"pagination\",\n];\n\nconst MIGRATION_GUIDE =\n \"https://tanstack.com/table/latest/docs/framework/svelte/guide/migrating\";\n\n/**\n * The major of the `@tanstack/table-core` range `package.json` declares, when\n * it names one (`^8.21.3` is 8; `latest` or `workspace:*` is undefined).\n */\nexport function declaredTableCoreMajor(root: string): number | undefined {\n const packageJsonPath = path.join(root, \"package.json\");\n if (!existsSync(packageJsonPath)) return undefined;\n const pkg = JSON.parse(readFileSync(packageJsonPath, \"utf8\")) as {\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n };\n const range =\n pkg.dependencies?.[\"@tanstack/table-core\"] ??\n pkg.devDependencies?.[\"@tanstack/table-core\"];\n const major = range?.match(/^[\\^~>=v\\s]*(\\d+)/)?.[1];\n return major === undefined ? undefined : Number(major);\n}\n\n/** Whether the project's `data-table` helper is the v8 one (`createSvelteTable`). */\nfunction hasV8DataTable(root: string): boolean {\n const index = path.join(resolveUiDir(root), \"data-table\", \"index.ts\");\n return (\n existsSync(index) &&\n readFileSync(index, \"utf8\").includes(\"createSvelteTable\")\n );\n}\n\nfunction upgradeSteps(): string {\n return (\n \"Nothing was changed. To upgrade:\\n\" +\n ` 1. Install ${TANSTACK_TABLE_CORE}: npm install ${TANSTACK_TABLE_CORE}\\n` +\n ` 2. Replace the table helpers: vela ui add ${TABLE_CORE_COMPONENTS.join(\" \")} --overwrite\\n` +\n ` 3. Move existing list pages to the v9 API (createTable, tableFeatures): ${MIGRATION_GUIDE}\\n` +\n \"Then run this again.\"\n );\n}\n\n/**\n * Refuses a project still on TanStack Table v8, before anything is written.\n *\n * The scaffold list pages and the table helpers target v9. A project set up\n * before that has `@tanstack/table-core@^8` and v8 helpers; the package is\n * never upgraded by `installPackages` (it is already present) and the helpers\n * are never replaced (they already exist), so a new page would not compile,\n * and upgrading in place would break the list pages already there.\n */\nexport function assertTableCoreV9(root: string): void {\n const major = declaredTableCoreMajor(root);\n const outdatedPackage =\n major !== undefined && major < TANSTACK_TABLE_CORE_MAJOR;\n if (!outdatedPackage && !hasV8DataTable(root)) return;\n\n const found = outdatedPackage\n ? `package.json pins @tanstack/table-core ${major}.x`\n : \"its data-table helper is the v8 one (createSvelteTable)\";\n throw new InvalidArgumentError(\n `This project uses TanStack Table v8 (${found}), and scaffold list pages now need v${TANSTACK_TABLE_CORE_MAJOR}.\\n\\n` +\n upgradeSteps(),\n );\n}\n\n/**\n * Refuses to add v9 table helpers next to a v8 `@tanstack/table-core`, which\n * `installPackages` would leave in place.\n */\nexport function assertTableCorePackage(\n root: string,\n components: string[],\n): void {\n const tableComponents = components.filter((component) =>\n TABLE_CORE_COMPONENTS.includes(component),\n );\n if (tableComponents.length === 0) return;\n const major = declaredTableCoreMajor(root);\n if (major === undefined || major >= TANSTACK_TABLE_CORE_MAJOR) return;\n\n throw new InvalidArgumentError(\n `${tableComponents.join(\", \")} target${tableComponents.length === 1 ? \"s\" : \"\"} TanStack Table v${TANSTACK_TABLE_CORE_MAJOR}, and package.json pins @tanstack/table-core ${major}.x.\\n\\n` +\n `Nothing was changed. Install ${TANSTACK_TABLE_CORE} first (npm install ${TANSTACK_TABLE_CORE}), then run this again.`,\n );\n}\n"],"mappings":";;;;;;AAeA,IAAMM,IAAsB;AAwB5B,SAASC,EAAe,GAAoC;CAC1D,OAAO,OAAOC,KAAU,YAAYA,EAAM,SAAS,IAAIA,IAAQ,KAAA;AACjE;AAOA,SAAgBC,EAAqB,GAAgC;CACnE,IAAIC,IAA2B,CAAC,GAC1BC,IAAaN,EAAK,KAAKO,GAAM,iBAAiB;CACpD,IAAIC,EAAWF,CAAU,GACvB,IAAI;EACF,IAAMG,IAAkB,KAAK,MAAMC,EAAaJ,GAAY,MAAM,CAAC;EACnE,AAAIG,KAAU,OAAOA,KAAW,aAC9B,IAAMA;CAEV,QAAQ;EACN,IAAM,CAAC;CACT;CAGF,IAAME,IAAkC,CAAC;CACzC,KAAK,IAAM,CAACC,GAAKT,MAAU,OAAO,QAAQE,EAAI,WAAW,CAAC,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C,IAAMC,IAAM,KAAK,MAAMnC,EAAakC,GAAiB,MAAM,CAAC,GAOtDE,KAFJD,EAAI,eAAe,2BACnBA,EAAI,kBAAkB,wBAAA,EACH,MAAM,mBAAmB,CAAC,GAAG;CAClD,OAAOC,MAAU,KAAA,IAAY,KAAA,IAAY,OAAOA,CAAK;AACvD;AAGA,SAASC,EAAe,GAAuB;CAC7C,IAAMC,IAAQhD,EAAK,KAAKe,EAAaR,CAAI,GAAG,cAAc,UAAU;CACpE,OACEC,EAAWwC,CAAK,KAChBtC,EAAasC,GAAO,MAAM,CAAC,CAAC,SAAS,mBAAmB;AAE5D;AAEA,SAASC,IAAuB;CAC9B,OACE;eACgBlD,EAAoB,iBAAiBA,EAAoB,uDACnBwC,EAAsB,KAAK,GAAG,EAAE,0FACTI,EAAgB;AAGjG;AAWA,SAAgBF,EAAkB,GAAoB;CACpD,IAAMK,IAAQJ,EAAuBnC,CAAI,GACnC2C,IACJJ,MAAU,KAAA,KAAaA,IAAA;CACzB,IAAI,CAACI,KAAmB,CAACH,EAAexC,CAAI,GAAG;CAE/C,IAAM4C,IAAQD,IACV,0CAA0CJ,EAAM,MAChD;CACJ,MAAM,IAAIjD,EACR,wCAAwCsD,EAAM,+CAC5CF,EAAa,CACjB;AACF;AAMA,SAAgBT,EACd,GACA,GACM;CACN,IAAMY,IAAkBC,EAAW,QAAQ,MACzCd,EAAsB,SAASe,CAAS,CAC1C;CACA,IAAIF,EAAgB,WAAW,GAAG;CAClC,IAAMN,IAAQJ,EAAuBnC,CAAI;CACzC,IAAI,QAAU,KAAA,KAAauC,KAAA,IAE3B,MAAM,IAAIjD,EACR,GAAGuD,EAAgB,KAAK,IAAI,EAAE,SAASA,EAAgB,WAAW,IAAI,MAAM,GAAG,iEAA4FN,EAAM,sCAC/I/C,EAAoB,sBAAsBA,EAAoB,wBAClG;AACF"}
|
|
1
|
+
{"version":3,"file":"table-core-BHFT-uMX.js","names":["__exportAll","RegistryUnavailableError","InvalidArgumentError","libAliasPath","TANSTACK_TABLE_CORE","path","REGISTRY_TIMEOUT_MS","optionalString","value","readComponentsConfig","raw","configPath","root","existsSync","parsed","readFileSync","aliases","key","alias","DEFAULT_UI_DIR","resolveUiDir","rel","registryIndexUrl","registry","style","indexCache","parseIndex","body","items","entry","name","type","requestIndex","response","fetchImpl","url","error","reason","fetchRegistryIndex","config","options","cache","pending","table_core_exports","TABLE_CORE_COMPONENTS","assertTableCorePackage","assertTableCoreV9","declaredTableCoreMajor","MIGRATION_GUIDE","packageJsonPath","pkg","major","hasV8DataTable","index","upgradeSteps","outdatedPackage","found","tableComponents","components","component"],"sources":["../../src/runtime/registry.ts","../../src/runtime/table-core.ts"],"sourcesContent":["import { existsSync, readFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport type { RegistryItem, WriteResultRuntime } from \"../core/types\";\nimport { RegistryUnavailableError } from \"../core/errors\";\nimport { libAliasPath } from \"./lib-specifier\";\n\n/**\n * shadcn-svelte's schema defaults. A `components.json` that names no `style`\n * resolves to `nova` (not `vega`, whatever `getRegistryUrl`'s fallback says),\n * which is why the CLI's templates write the key explicitly.\n */\nexport const DEFAULT_STYLE = \"nova\";\nexport const DEFAULT_REGISTRY = \"https://shadcn-svelte.com/registry\";\nexport const DEFAULT_CSS_PATH = \"src/app.css\";\n\nconst REGISTRY_TIMEOUT_MS = 10_000;\n\nexport interface ComponentsConfig {\n style: string;\n registry: string;\n baseColor?: string;\n iconLibrary?: string;\n menuColor?: string;\n menuAccent?: string;\n aliases: Record<string, string>;\n /** `tailwind.css`: the global stylesheet, relative to the root. */\n cssPath: string;\n}\n\ninterface RawComponentsConfig {\n style?: unknown;\n registry?: unknown;\n iconLibrary?: unknown;\n menuColor?: unknown;\n menuAccent?: unknown;\n tailwind?: { css?: unknown; baseColor?: unknown };\n aliases?: Record<string, unknown>;\n}\n\nfunction optionalString(value: unknown): string | undefined {\n return typeof value === \"string\" && value.length > 0 ? value : undefined;\n}\n\n/**\n * The project's `components.json` with the schema defaults filled in. A\n * missing or unreadable file behaves like an empty one, so callers can still\n * compute paths and the existence checks here agree with shadcn's own.\n */\nexport function readComponentsConfig(root: string): ComponentsConfig {\n let raw: RawComponentsConfig = {};\n const configPath = path.join(root, \"components.json\");\n if (existsSync(configPath)) {\n try {\n const parsed: unknown = JSON.parse(readFileSync(configPath, \"utf8\"));\n if (parsed && typeof parsed === \"object\") {\n raw = parsed as RawComponentsConfig;\n }\n } catch {\n raw = {};\n }\n }\n\n const aliases: Record<string, string> = {};\n for (const [key, value] of Object.entries(raw.aliases ?? {})) {\n const alias = optionalString(value);\n if (alias) aliases[key] = alias;\n }\n\n return {\n style: optionalString(raw.style) ?? DEFAULT_STYLE,\n registry: optionalString(raw.registry) ?? DEFAULT_REGISTRY,\n baseColor: optionalString(raw.tailwind?.baseColor),\n iconLibrary: optionalString(raw.iconLibrary),\n menuColor: optionalString(raw.menuColor),\n menuAccent: optionalString(raw.menuAccent),\n aliases,\n cssPath: optionalString(raw.tailwind?.css) ?? DEFAULT_CSS_PATH,\n };\n}\n\nconst DEFAULT_UI_DIR = [\"src\", \"lib\", \"components\", \"ui\"];\n\n/**\n * Where shadcn-svelte writes items: `components.json` `aliases.ui`, resolved\n * under `src/lib` for `#lib/...`, or the alias a project from before\n * SvelteKit 3 still has.\n * Anything else (a custom alias, a missing or unreadable config) falls back\n * to the default so the existence check here and shadcn's own target agree\n * for every project the CLI creates.\n */\nexport function resolveUiDir(root: string): string {\n const alias = readComponentsConfig(root).aliases.ui;\n const rel = alias === undefined ? null : libAliasPath(alias);\n if (rel === null) {\n return path.join(root, ...DEFAULT_UI_DIR);\n }\n return path.join(root, \"src\", \"lib\", ...rel.split(\"/\").filter(Boolean));\n}\n\n/** `${registry}/styles/${style}/index.json`: the items one style offers. */\nexport function registryIndexUrl(registry: string, style: string): string {\n return `${registry.replace(/\\/+$/, \"\")}/styles/${encodeURIComponent(style)}/index.json`;\n}\n\n/**\n * One request per registry URL per process, keyed on the fetch implementation\n * so an injected test double never sees another test's answer and the real\n * `fetch` shares its answer across a style switch and the installs it runs.\n */\nconst indexCache = new WeakMap<\n typeof fetch,\n Map<string, Promise<RegistryItem[]>>\n>();\n\nfunction parseIndex(body: unknown): RegistryItem[] {\n if (!Array.isArray(body)) {\n throw new Error(\"the index is not a list\");\n }\n const items: RegistryItem[] = [];\n for (const entry of body) {\n if (!entry || typeof entry !== \"object\") continue;\n const { name, type } = entry as { name?: unknown; type?: unknown };\n if (typeof name === \"string\" && typeof type === \"string\") {\n items.push({ name, type });\n }\n }\n return items;\n}\n\nasync function requestIndex(\n url: string,\n fetchImpl: typeof fetch,\n): Promise<RegistryItem[]> {\n let response: Response;\n try {\n response = await fetchImpl(url, {\n signal: AbortSignal.timeout(REGISTRY_TIMEOUT_MS),\n });\n } catch (error) {\n const reason =\n error instanceof Error && error.name === \"TimeoutError\"\n ? `no answer within ${REGISTRY_TIMEOUT_MS / 1000}s`\n : error instanceof Error\n ? error.message\n : String(error);\n throw new RegistryUnavailableError(url, reason);\n }\n if (!response.ok) {\n throw new RegistryUnavailableError(url, `HTTP ${response.status}`);\n }\n try {\n return parseIndex(await response.json());\n } catch (error) {\n throw new RegistryUnavailableError(\n url,\n error instanceof Error ? error.message : String(error),\n );\n }\n}\n\n/**\n * The items the project's registry offers for a style: the configured one by\n * default, or `options.style` to look at the style a project is about to\n * switch to. Throws `RegistryUnavailableError` when the index cannot be read.\n */\nexport async function fetchRegistryIndex(\n root: string,\n options: { style?: string; runtime?: WriteResultRuntime } = {},\n): Promise<RegistryItem[]> {\n const config = readComponentsConfig(root);\n const url = registryIndexUrl(config.registry, options.style ?? config.style);\n const fetchImpl = options.runtime?.fetch ?? globalThis.fetch;\n\n let cache = indexCache.get(fetchImpl);\n if (!cache) {\n cache = new Map();\n indexCache.set(fetchImpl, cache);\n }\n let pending = cache.get(url);\n if (!pending) {\n pending = requestIndex(url, fetchImpl).catch((error: unknown) => {\n // A failed read is not worth remembering: the next command may be online.\n cache.delete(url);\n throw error;\n });\n cache.set(url, pending);\n }\n return pending;\n}\n","import { existsSync, readFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport {\n TANSTACK_TABLE_CORE,\n TANSTACK_TABLE_CORE_MAJOR,\n} from \"../core/constants\";\nimport { InvalidArgumentError } from \"../core/errors\";\nimport { resolveUiDir } from \"./registry\";\n\n/** The components this package ships that are built on `@tanstack/table-core`. */\nexport const TABLE_CORE_COMPONENTS = [\n \"data-table\",\n \"column-header\",\n \"faceted-filter\",\n \"pagination\",\n];\n\nconst MIGRATION_GUIDE =\n \"https://tanstack.com/table/latest/docs/framework/svelte/guide/migrating\";\n\n/**\n * The major of the `@tanstack/table-core` range `package.json` declares, when\n * it names one (`^8.21.3` is 8; `latest` or `workspace:*` is undefined).\n */\nexport function declaredTableCoreMajor(root: string): number | undefined {\n const packageJsonPath = path.join(root, \"package.json\");\n if (!existsSync(packageJsonPath)) return undefined;\n const pkg = JSON.parse(readFileSync(packageJsonPath, \"utf8\")) as {\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n };\n const range =\n pkg.dependencies?.[\"@tanstack/table-core\"] ??\n pkg.devDependencies?.[\"@tanstack/table-core\"];\n const major = range?.match(/^[\\^~>=v\\s]*(\\d+)/)?.[1];\n return major === undefined ? undefined : Number(major);\n}\n\n/** Whether the project's `data-table` helper is the v8 one (`createSvelteTable`). */\nfunction hasV8DataTable(root: string): boolean {\n const index = path.join(resolveUiDir(root), \"data-table\", \"index.ts\");\n return (\n existsSync(index) &&\n readFileSync(index, \"utf8\").includes(\"createSvelteTable\")\n );\n}\n\nfunction upgradeSteps(): string {\n return (\n \"Nothing was changed. To upgrade:\\n\" +\n ` 1. Install ${TANSTACK_TABLE_CORE}: npm install ${TANSTACK_TABLE_CORE}\\n` +\n ` 2. Replace the table helpers: vela ui add ${TABLE_CORE_COMPONENTS.join(\" \")} --overwrite\\n` +\n ` 3. Move existing list pages to the v9 API (createTable, tableFeatures): ${MIGRATION_GUIDE}\\n` +\n \"Then run this again.\"\n );\n}\n\n/**\n * Refuses a project still on TanStack Table v8, before anything is written.\n *\n * The scaffold list pages and the table helpers target v9. A project set up\n * before that has `@tanstack/table-core@^8` and v8 helpers; the package is\n * never upgraded by `installPackages` (it is already present) and the helpers\n * are never replaced (they already exist), so a new page would not compile,\n * and upgrading in place would break the list pages already there.\n */\nexport function assertTableCoreV9(root: string): void {\n const major = declaredTableCoreMajor(root);\n const outdatedPackage =\n major !== undefined && major < TANSTACK_TABLE_CORE_MAJOR;\n if (!outdatedPackage && !hasV8DataTable(root)) return;\n\n const found = outdatedPackage\n ? `package.json pins @tanstack/table-core ${major}.x`\n : \"its data-table helper is the v8 one (createSvelteTable)\";\n throw new InvalidArgumentError(\n `This project uses TanStack Table v8 (${found}), and scaffold list pages now need v${TANSTACK_TABLE_CORE_MAJOR}.\\n\\n` +\n upgradeSteps(),\n );\n}\n\n/**\n * Refuses to add v9 table helpers next to a v8 `@tanstack/table-core`, which\n * `installPackages` would leave in place.\n */\nexport function assertTableCorePackage(\n root: string,\n components: string[],\n): void {\n const tableComponents = components.filter((component) =>\n TABLE_CORE_COMPONENTS.includes(component),\n );\n if (tableComponents.length === 0) return;\n const major = declaredTableCoreMajor(root);\n if (major === undefined || major >= TANSTACK_TABLE_CORE_MAJOR) return;\n\n throw new InvalidArgumentError(\n `${tableComponents.join(\", \")} target${tableComponents.length === 1 ? \"s\" : \"\"} TanStack Table v${TANSTACK_TABLE_CORE_MAJOR}, and package.json pins @tanstack/table-core ${major}.x.\\n\\n` +\n `Nothing was changed. Install ${TANSTACK_TABLE_CORE} first (npm install ${TANSTACK_TABLE_CORE}), then run this again.`,\n );\n}\n"],"mappings":";;;;;;AAeA,IAAMM,IAAsB;AAwB5B,SAASC,EAAe,GAAoC;CAC1D,OAAO,OAAOC,KAAU,YAAYA,EAAM,SAAS,IAAIA,IAAQ,KAAA;AACjE;AAOA,SAAgBC,EAAqB,GAAgC;CACnE,IAAIC,IAA2B,CAAC,GAC1BC,IAAaN,EAAK,KAAK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C,CAAI;CACzC,IAAI,QAAU,KAAA,KAAauC,KAAA,IAE3B,MAAM,IAAIjD,EACR,GAAGuD,EAAgB,KAAK,IAAI,EAAE,SAASA,EAAgB,WAAW,IAAI,MAAM,GAAG,iEAA4FN,EAAM,sCAC/I/C,EAAoB,sBAAsBA,EAAoB,wBAClG;AACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { n as e, t } from "./constants-
|
|
1
|
+
import { n as e, t } from "./constants-Bdx8mp7v.js";
|
|
2
2
|
import { t as n } from "./dedent-Gq6Krl4n.js";
|
|
3
3
|
import { o as r, s as i } from "./config-target-BgyFkbFL.js";
|
|
4
|
-
import { c as a } from "./write-result-
|
|
4
|
+
import { c as a } from "./write-result-DcqMefuP.js";
|
|
5
5
|
import o from "node:fs";
|
|
6
6
|
import s from "node:path";
|
|
7
7
|
import { SyntaxKind as c } from "ts-morph";
|
|
@@ -176,4 +176,4 @@ function O(e) {
|
|
|
176
176
|
//#endregion
|
|
177
177
|
export { O as a, g as c, D as i, _ as l, S as n, b as o, E as r, x as s, w as t };
|
|
178
178
|
|
|
179
|
-
//# sourceMappingURL=test-setup-
|
|
179
|
+
//# sourceMappingURL=test-setup-BVJwm22s.js.map
|