@velastack/patterns 0.12.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -2
- package/dist/chunks/{collections-DzwWwFUQ.js → collections-zEoRuILr.js} +2 -2
- package/dist/chunks/{collections-DzwWwFUQ.js.map → collections-zEoRuILr.js.map} +1 -1
- package/dist/chunks/constants-CUv536Rj.js +87 -0
- package/dist/chunks/constants-CUv536Rj.js.map +1 -0
- package/dist/chunks/{currency.server-CzHS7Svd.js → currency.server-DygAf6a1.js} +2 -2
- package/dist/chunks/{currency.server-CzHS7Svd.js.map → currency.server-DygAf6a1.js.map} +1 -1
- package/dist/chunks/{env-vars-CNH-ItSY.js → env-vars-XvAeH6u5.js} +3 -3
- package/dist/chunks/{env-vars-CNH-ItSY.js.map → env-vars-XvAeH6u5.js.map} +1 -1
- package/dist/chunks/{generate-D21dCU-o.js → generate-BtWZCvuO.js} +3 -3
- package/dist/chunks/{generate-D21dCU-o.js.map → generate-BtWZCvuO.js.map} +1 -1
- package/dist/chunks/{generate-BEc_h7OI.js → generate-Cbg-Z3sA.js} +2 -2
- package/dist/chunks/{generate-BEc_h7OI.js.map → generate-Cbg-Z3sA.js.map} +1 -1
- package/dist/chunks/{generate-DiwvSC9c.js → generate-Crdzw45a.js} +2 -2
- package/dist/chunks/{generate-DiwvSC9c.js.map → generate-Crdzw45a.js.map} +1 -1
- package/dist/chunks/{generate-C3OaUggX.js → generate-DgZhFNjO.js} +22 -22
- package/dist/chunks/generate-DgZhFNjO.js.map +1 -0
- package/dist/chunks/{generate-CtQcmjPM.js → generate-DjuhSibA.js} +84 -84
- package/dist/chunks/generate-DjuhSibA.js.map +1 -0
- package/dist/chunks/{generate.runtime-CaOO0281.js → generate.runtime-2GD2E1NK.js} +6 -6
- package/dist/chunks/{generate.runtime-CaOO0281.js.map → generate.runtime-2GD2E1NK.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CowdMKQs.js → generate.runtime-4TxcYKld.js} +3 -3
- package/dist/chunks/{generate.runtime-CowdMKQs.js.map → generate.runtime-4TxcYKld.js.map} +1 -1
- package/dist/chunks/{generate.runtime-B3yuIjJD.js → generate.runtime-7sU7RzIA.js} +2 -2
- package/dist/chunks/{generate.runtime-B3yuIjJD.js.map → generate.runtime-7sU7RzIA.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BBfiR_Le.js → generate.runtime-B-WOQsda.js} +3 -3
- package/dist/chunks/{generate.runtime-BBfiR_Le.js.map → generate.runtime-B-WOQsda.js.map} +1 -1
- package/dist/chunks/{generate.runtime-kEHEiLBL.js → generate.runtime-B2DI0x05.js} +2 -2
- package/dist/chunks/{generate.runtime-kEHEiLBL.js.map → generate.runtime-B2DI0x05.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BTHuPon9.js → generate.runtime-B8y_l-6N.js} +5 -5
- package/dist/chunks/{generate.runtime-BTHuPon9.js.map → generate.runtime-B8y_l-6N.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DbSRJF-C.js → generate.runtime-BEvi6bml.js} +3 -3
- package/dist/chunks/{generate.runtime-DbSRJF-C.js.map → generate.runtime-BEvi6bml.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CCE-9xQV.js → generate.runtime-BO1KyRcJ.js} +2 -2
- package/dist/chunks/{generate.runtime-CCE-9xQV.js.map → generate.runtime-BO1KyRcJ.js.map} +1 -1
- package/dist/chunks/{generate.runtime-D_HYO-mG.js → generate.runtime-BPVZsAL0.js} +4 -4
- package/dist/chunks/{generate.runtime-D_HYO-mG.js.map → generate.runtime-BPVZsAL0.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DVwha8lZ.js → generate.runtime-BfM3dX_R.js} +2 -2
- package/dist/chunks/{generate.runtime-DVwha8lZ.js.map → generate.runtime-BfM3dX_R.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CtFCayo8.js → generate.runtime-BfQlxsWK.js} +7 -7
- package/dist/chunks/{generate.runtime-CtFCayo8.js.map → generate.runtime-BfQlxsWK.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Drpy9sWO.js → generate.runtime-BsjcGBme.js} +2 -2
- package/dist/chunks/{generate.runtime-Drpy9sWO.js.map → generate.runtime-BsjcGBme.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DOv-bhM6.js → generate.runtime-ByC9kOl2.js} +2 -2
- package/dist/chunks/{generate.runtime-DOv-bhM6.js.map → generate.runtime-ByC9kOl2.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Dy9uuf7M.js → generate.runtime-C2pIioyZ.js} +6 -6
- package/dist/chunks/{generate.runtime-Dy9uuf7M.js.map → generate.runtime-C2pIioyZ.js.map} +1 -1
- package/dist/chunks/{generate.runtime--VeSxyIm.js → generate.runtime-C4hyve9h.js} +3 -3
- package/dist/chunks/{generate.runtime--VeSxyIm.js.map → generate.runtime-C4hyve9h.js.map} +1 -1
- package/dist/chunks/{generate.runtime-r9Ouwr5B.js → generate.runtime-C9yduilW.js} +3 -3
- package/dist/chunks/{generate.runtime-r9Ouwr5B.js.map → generate.runtime-C9yduilW.js.map} +1 -1
- package/dist/chunks/{generate.runtime-HkvT9gm6.js → generate.runtime-CEd3qCtW.js} +4 -4
- package/dist/chunks/{generate.runtime-HkvT9gm6.js.map → generate.runtime-CEd3qCtW.js.map} +1 -1
- package/dist/chunks/{generate.runtime-D34lCyet.js → generate.runtime-CHaE6Mm9.js} +3 -3
- package/dist/chunks/{generate.runtime-D34lCyet.js.map → generate.runtime-CHaE6Mm9.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DbMDlglD.js → generate.runtime-CXGiQWDK.js} +4 -4
- package/dist/chunks/{generate.runtime-DbMDlglD.js.map → generate.runtime-CXGiQWDK.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BK7x32md.js → generate.runtime-CvtSK0E1.js} +3 -3
- package/dist/chunks/{generate.runtime-BK7x32md.js.map → generate.runtime-CvtSK0E1.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CeoqgxiO.js → generate.runtime-DGmpjkRe.js} +4 -4
- package/dist/chunks/{generate.runtime-CeoqgxiO.js.map → generate.runtime-DGmpjkRe.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Brakd35X.js → generate.runtime-DI73x08q.js} +2 -2
- package/dist/chunks/{generate.runtime-Brakd35X.js.map → generate.runtime-DI73x08q.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Bx_CaBZD.js → generate.runtime-DIkM5xIB.js} +2 -2
- package/dist/chunks/{generate.runtime-Bx_CaBZD.js.map → generate.runtime-DIkM5xIB.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DlPeHx19.js → generate.runtime-DRZDjZqw.js} +2 -2
- package/dist/chunks/{generate.runtime-DlPeHx19.js.map → generate.runtime-DRZDjZqw.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DUBOC6AA.js → generate.runtime-DVUj1LJK.js} +3 -3
- package/dist/chunks/{generate.runtime-DUBOC6AA.js.map → generate.runtime-DVUj1LJK.js.map} +1 -1
- package/dist/chunks/{generate.runtime--yCjGZ6-.js → generate.runtime-Deg1Tz9u.js} +3 -3
- package/dist/chunks/{generate.runtime--yCjGZ6-.js.map → generate.runtime-Deg1Tz9u.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DOWDoe6B.js → generate.runtime-DqYYJXAz.js} +2 -2
- package/dist/chunks/{generate.runtime-DOWDoe6B.js.map → generate.runtime-DqYYJXAz.js.map} +1 -1
- package/dist/chunks/{generate.runtime-C8-mjcn8.js → generate.runtime-Du8puIJQ.js} +6 -6
- package/dist/chunks/{generate.runtime-C8-mjcn8.js.map → generate.runtime-Du8puIJQ.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DRuPb-67.js → generate.runtime-DzCVGruq.js} +2 -2
- package/dist/chunks/{generate.runtime-DRuPb-67.js.map → generate.runtime-DzCVGruq.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CAO_SpsA.js → generate.runtime-TKR-qAJM.js} +2 -2
- package/dist/chunks/{generate.runtime-CAO_SpsA.js.map → generate.runtime-TKR-qAJM.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CGJ_4VS_.js → generate.runtime-USnFqTbU.js} +4 -4
- package/dist/chunks/{generate.runtime-CGJ_4VS_.js.map → generate.runtime-USnFqTbU.js.map} +1 -1
- package/dist/chunks/{generate.runtime-sALBNh1T.js → generate.runtime-UrLaWKvN.js} +4 -4
- package/dist/chunks/{generate.runtime-sALBNh1T.js.map → generate.runtime-UrLaWKvN.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Ce2O5uWy.js → generate.runtime-bWGwyz2U.js} +3 -3
- package/dist/chunks/{generate.runtime-Ce2O5uWy.js.map → generate.runtime-bWGwyz2U.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BL62aRng.js → generate.runtime-g6qaIY3k.js} +6 -6
- package/dist/chunks/{generate.runtime-BL62aRng.js.map → generate.runtime-g6qaIY3k.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DroVnvQz.js → generate.runtime-s9ai7PxV.js} +4 -4
- package/dist/chunks/{generate.runtime-DroVnvQz.js.map → generate.runtime-s9ai7PxV.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CPDJolef.js → generate.runtime-taYl9Tg5.js} +4 -4
- package/dist/chunks/{generate.runtime-CPDJolef.js.map → generate.runtime-taYl9Tg5.js.map} +1 -1
- package/dist/chunks/{modify-file-DdXJCMHN.js → modify-file-D9U2LXEa.js} +2 -2
- package/dist/chunks/{modify-file-DdXJCMHN.js.map → modify-file-D9U2LXEa.js.map} +1 -1
- package/dist/chunks/{pocketbase-uOpghyT5.js → pocketbase-BTR3gI8o.js} +2 -2
- package/dist/chunks/{pocketbase-uOpghyT5.js.map → pocketbase-BTR3gI8o.js.map} +1 -1
- package/dist/chunks/{providers-ypCW70Mb.js → providers-CpRRQdMg.js} +2 -2
- package/dist/chunks/{providers-ypCW70Mb.js.map → providers-CpRRQdMg.js.map} +1 -1
- package/dist/chunks/{shared-DIDAkVts.js → shared-CAjLx_8Z.js} +2 -2
- package/dist/chunks/{shared-DIDAkVts.js.map → shared-CAjLx_8Z.js.map} +1 -1
- package/dist/chunks/{site-CVtsbO_S.js → site-D0IuWkAR.js} +2 -2
- package/dist/chunks/{site-CVtsbO_S.js.map → site-D0IuWkAR.js.map} +1 -1
- package/dist/chunks/table-core-BKBoEStB.js +127 -0
- package/dist/chunks/table-core-BKBoEStB.js.map +1 -0
- package/dist/chunks/{test-setup-B37g3TRn.js → test-setup-CbCXmPkE.js} +3 -3
- package/dist/chunks/{test-setup-B37g3TRn.js.map → test-setup-CbCXmPkE.js.map} +1 -1
- package/dist/chunks/{ui-Ct_9B91R.js → ui-B3Db8cQg.js} +3 -3
- package/dist/chunks/{ui-Ct_9B91R.js.map → ui-B3Db8cQg.js.map} +1 -1
- package/dist/chunks/{whatsapp-Dr29ohbb.js → whatsapp-Pya8Zi07.js} +2 -2
- package/dist/chunks/{whatsapp-Dr29ohbb.js.map → whatsapp-Pya8Zi07.js.map} +1 -1
- package/dist/chunks/{write-result-mtVbmDyQ.js → write-result-BWXq9RRn.js} +4 -4
- package/dist/chunks/{write-result-mtVbmDyQ.js.map → write-result-BWXq9RRn.js.map} +1 -1
- package/dist/index.d.ts +57 -17
- package/dist/index.js +1950 -1947
- package/dist/index.js.map +1 -1
- package/package.json +6 -3
- package/dist/chunks/constants-8cLxGOB0.js +0 -6
- package/dist/chunks/constants-8cLxGOB0.js.map +0 -1
- package/dist/chunks/generate-C3OaUggX.js.map +0 -1
- package/dist/chunks/generate-CtQcmjPM.js.map +0 -1
- package/dist/chunks/table-core-CUGp4Rf2.js +0 -127
- package/dist/chunks/table-core-CUGp4Rf2.js.map +0 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { r as e } from "./lib-specifier-Cngo1zF_.js";
|
|
2
2
|
import { n as t } from "./logger-CQONztPm.js";
|
|
3
|
-
import { n, t as r } from "./generate-
|
|
3
|
+
import { n, t as r } from "./generate-Crdzw45a.js";
|
|
4
4
|
import { n as i } from "./env-BugddEjd.js";
|
|
5
5
|
import { _ as a, n as o, u as s } from "./ts-morph-helpers-CHI9wAil.js";
|
|
6
|
-
import { r as c, t as l } from "./modify-file-
|
|
7
|
-
import { unmodifyEnvVarsFiles as u } from "./env-vars-
|
|
6
|
+
import { r as c, t as l } from "./modify-file-D9U2LXEa.js";
|
|
7
|
+
import { unmodifyEnvVarsFiles as u } from "./env-vars-XvAeH6u5.js";
|
|
8
8
|
import { t as d } from "./svelte-file-Dv5-bl79.js";
|
|
9
9
|
import f from "node:fs";
|
|
10
10
|
import p from "node:path";
|
|
@@ -62,4 +62,4 @@ async function g(e) {
|
|
|
62
62
|
//#endregion
|
|
63
63
|
export { g as generate };
|
|
64
64
|
|
|
65
|
-
//# sourceMappingURL=generate.runtime-
|
|
65
|
+
//# sourceMappingURL=generate.runtime-taYl9Tg5.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.runtime-
|
|
1
|
+
{"version":3,"file":"generate.runtime-taYl9Tg5.js","names":["libModule","getLogger","allEnvEdits","modifyEnvRemove","withInMemoryScript","ensureBlankLineAfterImports","removeImportByModuleSpecifier","modifyOutcomeToFile","envRevertOutcomeToFile","SvelteFile","fs","path","MODULE","unmodifyLayoutSvelte","layoutPath","original","file","out","source","sf","updated","generate","logger","options","modifies","deletes","pushResult","envVars","unmodifyEnvVarsFiles","allEnvNames","envPath","env"],"sources":["../../src/patterns/disable/analytics/modifies/layout.svelte.ts","../../src/patterns/disable/analytics/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport {\n ensureBlankLineAfterImports,\n removeImportByModuleSpecifier,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { libModule } from \"../../../../runtime/lib-specifier\";\n\nconst MODULE = \"components/analytics/analytics.svelte\";\n\n/**\n * Takes `<Analytics />` and its import back out of the root layout. The\n * element goes with its whole line, since enable-analytics put it on one of\n * its own. A layout without it, or no layout at all, is left alone.\n */\nexport function unmodifyLayoutSvelte(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(layoutPath, \"utf8\");\n if (!original.includes(MODULE) && !original.includes(\"<Analytics\")) {\n return { status: \"success\", changed: false };\n }\n\n const file = SvelteFile.fromPath(layoutPath);\n file.modifyScript((source) => {\n const { source: out } = withInMemoryScript(source, (sf) => {\n removeImportByModuleSpecifier(sf, libModule(MODULE));\n ensureBlankLineAfterImports(sf);\n });\n return out;\n });\n\n const updated = file\n .toString()\n .replace(/[ \\t]*<Analytics\\s*\\/>[ \\t]*\\r?\\n?/g, \"\");\n\n if (updated === original) {\n return { status: \"success\", changed: false };\n }\n fs.writeFileSync(layoutPath, updated, \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyEnvRemove } from \"../../../runtime/env\";\nimport {\n envRevertOutcomeToFile,\n modifyOutcomeToFile,\n} from \"../../../runtime/modify-file\";\nimport { allEnvEdits, allEnvNames } from \"./generate\";\nimport { unmodifyEnvVarsFiles } from \"../../../runtime/env-vars\";\nimport { unmodifyLayoutSvelte } from \"./modifies/layout.svelte\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n const deletes: File[] = [];\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Reverting src/routes/+layout.svelte\");\n const layoutPath = path.join(options.root, \"src\", \"routes\", \"+layout.svelte\");\n pushResult(modifyOutcomeToFile(layoutPath, unmodifyLayoutSvelte(layoutPath)));\n\n // Which provider was chosen is not recorded, so every one's variables go;\n // the file goes too when these were all it declared.\n logger.info(\"Removing analytics variables from src/env.ts\");\n const envVars = unmodifyEnvVarsFiles(options.root, allEnvNames());\n pushResult(envVars.modify);\n if (envVars.delete) deletes.push(envVars.delete);\n\n logger.info(\"Removing analytics variables from .env\");\n const envPath = path.join(options.root, \".env\");\n const env = envRevertOutcomeToFile(\n envPath,\n modifyEnvRemove(envPath, allEnvEdits()),\n );\n pushResult(env.modify);\n if (env.delete) deletes.push(env.delete);\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":";;;;;;;;;;;AAUA,IAAMY,IAAS;AAOf,SAAgBC,EAAqB,GAAmC;CACtE,IAAI,CAACH,EAAG,WAAWI,CAAU,GAC3B,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAMC,IAAWL,EAAG,aAAaI,GAAY,MAAM;CACnD,IAAI,CAACC,EAAS,SAASH,CAAM,KAAK,CAACG,EAAS,SAAS,YAAY,GAC/D,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAMC,IAAOP,EAAW,SAASK,CAAU;CAC3C,EAAK,cAAc,MAAW;EAC5B,IAAM,EAAE,QAAQG,MAAQb,EAAmBc,IAAS,MAAO;GAEzD,AADAZ,EAA8Ba,GAAInB,EAAUY,CAAM,CAAC,GACnDP,EAA4Bc,CAAE;EAChC,CAAC;EACD,OAAOF;CACT,CAAC;CAED,IAAMG,IAAUJ,EACb,SAAS,CAAC,CACV,QAAQ,uCAAuC,EAAE;CAMpD,OAJII,MAAYL,IACP;EAAE,QAAQ;EAAW,SAAS;CAAM,KAE7CL,EAAG,cAAcI,GAAYM,GAAS,MAAM,GACrC;EAAE,QAAQ;EAAW,SAAS;CAAK;AAC5C;;;ACjCA,eAAsBC,EAAS,GAAkB;CAC/C,IAAMC,IAASrB,EAAUsB,CAAO,GAC1BC,IAAmB,CAAC,GACpBC,IAAkB,CAAC,GACnBC,KAAc,MAAsB;EACxC,AAAIV,KAAMQ,EAAS,KAAKR,CAAI;CAC9B;CAEA,EAAO,KAAK,qCAAqC;CACjD,IAAMF,IAAaH,EAAK,KAAKY,EAAQ,MAAM,OAAO,UAAU,gBAAgB;CAK5E,AAJAG,EAAWnB,EAAoBO,GAAYD,EAAqBC,CAAU,CAAC,CAAC,GAI5EQ,EAAO,KAAK,8CAA8C;CAC1D,IAAMK,IAAUC,EAAqBL,EAAQ,MAAMM,EAAY,CAAC;CAIhE,AAHAH,EAAWC,EAAQ,MAAM,GACrBA,EAAQ,UAAQF,EAAQ,KAAKE,EAAQ,MAAM,GAE/CL,EAAO,KAAK,wCAAwC;CACpD,IAAMQ,IAAUnB,EAAK,KAAKY,EAAQ,MAAM,MAAM,GACxCQ,IAAMvB,EACVsB,GACA3B,EAAgB2B,GAAS5B,EAAY,CAAC,CACxC;CAIA,OAHAwB,EAAWK,EAAI,MAAM,GACjBA,EAAI,UAAQN,EAAQ,KAAKM,EAAI,MAAM,GAEhC;EACL,SAAS,CAAC;EACV;EACA;EACA,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,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-CAjLx_8Z.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-D9U2LXEa.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modify-file-
|
|
1
|
+
{"version":3,"file":"modify-file-D9U2LXEa.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"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as e } from "./rolldown-runtime-5HNE8Q1r.js";
|
|
2
|
-
import { i as t, s as n } from "./constants-
|
|
2
|
+
import { i as t, s as n } from "./constants-CUv536Rj.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";
|
|
@@ -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-BTR3gI8o.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pocketbase-uOpghyT5.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;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;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CACxE;CAAM;CAAM;AACd,CAAC;AAED,SAASC,EAAe,GAA+B;CACrD,OAAO,IAAI,SAAS,GAAS,MAAW;EACtC,IAAMC,IAASH,EAAI,aAAa;EAGhC,AAFAG,EAAO,MAAM,GACbA,EAAO,KAAK,SAASC,CAAM,GAC3BD,EAAO,OAAO,GAAGE,SAAY;GAC3B,IAAM,EAAE,YAASF,EAAO,QAAQ;GAChC,EAAO,YAAYG,EAAQC,CAAI,CAAC;EAClC,CAAC;CACH,CAAC;AACH;AAQA,eAAsBC,EAAS,GAA+B;CAC5D,SAAS;EACP,IAAMD,IAAO,MAAML,EAAeG,CAAI;EACtC,IAAI,CAACJ,EAAU,IAAIM,CAAI,GAAG,OAAOA;CACnC;AACF;AAIA,SAAgBE,EACd,GACA,GACA,IAAc,IACC;CACf,OAAO,IAAI,SAAS,GAAS,MAAW;EACtC,IAA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CAAI,GAC1B4C,IAAc;EAClB;EACA;EACA;EACAJ;EACA;EACAC;EACA;EACA,GAAGzC,EAAK,GAAGE;CACb,GAEM2C,KAAkB,MAAMC,EAAO,EAAE,OAAI,CAAC,EAAA,EAAI,QAAQ,OAClD,EAAE,YAAS,YAASC,EACxBF,GACA,WACAD,CACF;CAGA,AAAIC,MAAmB,SAAOG,EAAK,QAAQ,OAAO;CAMlD,IAAMC,IAAW,QAAQ,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
|
+
{"version":3,"file":"pocketbase-BTR3gI8o.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;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;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CACxE;CAAM;CAAM;AACd,CAAC;AAED,SAASC,EAAe,GAA+B;CACrD,OAAO,IAAI,SAAS,GAAS,MAAW;EACtC,IAAMC,IAASH,EAAI,aAAa;EAGhC,AAFAG,EAAO,MAAM,GACbA,EAAO,KAAK,SAASC,CAAM,GAC3BD,EAA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AI,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-XvAeH6u5.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-CpRRQdMg.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"providers-
|
|
1
|
+
{"version":3,"file":"providers-CpRRQdMg.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-BTR3gI8o.js").then((e) => e.r), { planCollectionDrops: r } = await import("./collections-zEoRuILr.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-CAjLx_8Z.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared-
|
|
1
|
+
{"version":3,"file":"shared-CAjLx_8Z.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-BTR3gI8o.js";
|
|
4
4
|
import r from "node:fs";
|
|
5
5
|
import i from "node:path";
|
|
6
6
|
//#region src/runtime/site.ts
|
|
@@ -146,4 +146,4 @@ async function b(n, i) {
|
|
|
146
146
|
//#endregion
|
|
147
147
|
export { d as a, p as i, y as n, s as o, f as r, a as s, b as t };
|
|
148
148
|
|
|
149
|
-
//# sourceMappingURL=site-
|
|
149
|
+
//# sourceMappingURL=site-D0IuWkAR.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"site-CVtsbO_S.js","names":["languageFromPath","getLogger","withPocketbase","fs","path","sitePath","root","BUSINESS_KEYS","siteModule","declared","business","lines","key","propertyLines","properties","quote","name","url","entry","i","ensureComma","value","SUPPORTED_CURRENCIES","normalizeCurrency","raw","code","normalizeCountry","normalizeCurrencies","entries","codes","home","SITE_OBJECT","withSiteProperty","match","source","body","siteBusiness","text","shape","list","currency","country","m","existingName","options","appName","pb","pkg","ensureSiteFile","file","ensureSiteBusiness","wanted","existing","added","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 * What a business declares about itself in `src/lib/site.ts`, next to the\n * app's name: the currency it prices in and is paid in, the country it is in\n * (prices format for it: `es-MX`, not `es`) and the other currencies it shows\n * prices in, as estimates. Every property is optional; a payments provider\n * asks for what it needs.\n */\nexport interface SiteBusiness {\n /** ISO 4217, e.g. `MXN`. */\n currency?: string;\n /** ISO 3166-1 alpha-2, e.g. `MX`. */\n country?: string;\n /** ISO 4217 codes the site also shows prices in; empty means the home currency only. */\n currencies?: string[];\n}\n\ntype BusinessKey = keyof SiteBusiness;\n\nconst BUSINESS_KEYS: BusinessKey[] = [\"currency\", \"country\", \"currencies\"];\n\n/**\n * `src/lib/site.ts` as the CLI templates ship it (`site.template.ts`), with\n * the placeholders filled in, plus whatever the business declares.\n */\nexport function siteModule(\n name: string,\n url = \"http://localhost:5173\",\n business: SiteBusiness | string = {},\n): string {\n // The old third argument was the currency alone.\n const declared: SiteBusiness =\n typeof business === \"string\" ? { currency: business } : business;\n const lines = BUSINESS_KEYS.filter((key) => declared[key] !== undefined).map(\n (key) => propertyLines(key, declared[key]!),\n );\n const properties = [\n `\\tname: ${quote(name)},`,\n `\\turl: ${quote(url)}`,\n ...lines.map((entry) => entry.join(\"\\n\")),\n ];\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 // Every property but the last ends in a comma.\n ...properties.map((entry, i) =>\n i < properties.length - 1 ? ensureComma(entry) : entry,\n ),\n \"};\",\n \"\",\n ].join(\"\\n\");\n}\n\nfunction ensureComma(entry: string): string {\n return entry.endsWith(\",\") ? entry : `${entry},`;\n}\n\n/** A property's lines: its doc comment, then `key: value` with no trailing comma. */\nfunction propertyLines(key: BusinessKey, value: string | string[]): string[] {\n switch (key) {\n case \"currency\":\n return [\n \"\\t/** ISO 4217: the currency the business prices in and is paid in. */\",\n `\\tcurrency: ${quote(value as string)}`,\n ];\n case \"country\":\n return [\n \"\\t/** ISO 3166-1: the country the business is in; prices format for it. */\",\n `\\tcountry: ${quote(value as string)}`,\n ];\n case \"currencies\":\n return [\n \"\\t/** Other currencies prices are shown in, as estimates at the day's rate. */\",\n `\\tcurrencies: [${(value as string[]).map(quote).join(\", \")}]`,\n ];\n }\n}\n\nconst SUPPORTED_CURRENCIES = (\n Intl as unknown as {\n supportedValuesOf: (key: \"currency\") => string[];\n }\n).supportedValuesOf(\"currency\");\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 return SUPPORTED_CURRENCIES.includes(code) ? code : null;\n}\n\n/** A two-letter ISO 3166-1 code, upper-cased; anything else is refused. */\nexport function normalizeCountry(raw: unknown): string | null {\n if (typeof raw !== \"string\") return null;\n const code = raw.trim().toUpperCase();\n if (!/^[A-Z]{2}$/.test(code)) return null;\n // `Intl.DisplayNames` knows every region; an unknown one comes back as is.\n const names = new Intl.DisplayNames([\"en\"], { type: \"region\" });\n return names.of(code) !== code ? code : null;\n}\n\n/**\n * A list of currency codes, from an array or a comma-separated string,\n * upper-cased and deduplicated; `null` when any entry is not a currency.\n * `home` is left out: the business's own currency is never a display one.\n */\nexport function normalizeCurrencies(\n raw: unknown,\n home?: string,\n): string[] | null {\n const entries = Array.isArray(raw)\n ? raw\n : typeof raw === \"string\"\n ? raw.split(/[,\\s]+/)\n : null;\n if (!entries) return null;\n const codes: string[] = [];\n for (const entry of entries) {\n if (entry === \"\" || entry === undefined) continue;\n const code = normalizeCurrency(entry);\n if (!code) return null;\n if (code !== home && !codes.includes(code)) codes.push(code);\n }\n return codes;\n}\n\nconst SITE_OBJECT = /export const site = \\{\\n([\\s\\S]*?)\\n\\};/;\n\n/**\n * `src/lib/site.ts` with `key` added as the object's last property, or\n * `null` when it already has one (a project's declaration is never changed\n * behind its back) or has no `export const site = { ... };` to add it to.\n */\nexport function withSiteProperty(\n source: string,\n key: BusinessKey,\n value: string | string[],\n): string | null {\n const match = SITE_OBJECT.exec(source);\n if (!match || new RegExp(`^\\\\s*${key}\\\\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${propertyLines(key, value).join(\"\\n\")}\\n};`,\n );\n}\n\n/** `withSiteProperty` for the currency, as the Phase 1.5 code called it. */\nexport function withSiteCurrency(\n source: string,\n currency: string,\n): string | null {\n return withSiteProperty(source, \"currency\", currency);\n}\n\n/** What `src/lib/site.ts` declares about the business, if anything. */\nexport function siteBusiness(root: string): SiteBusiness {\n let source: string;\n try {\n source = fs.readFileSync(sitePath(root), \"utf8\");\n } catch {\n return {};\n }\n const text = (key: string, shape: string) =>\n new RegExp(`^\\\\s*${key}\\\\s*:\\\\s*['\"](${shape})['\"]`, \"m\").exec(source)?.[1];\n const list = /^\\s*currencies\\s*:\\s*\\[([^\\]]*)\\]/m.exec(source)?.[1];\n const business: SiteBusiness = {};\n const currency = text(\"currency\", \"[A-Za-z]{3}\");\n if (currency) business.currency = currency;\n const country = text(\"country\", \"[A-Za-z]{2}\");\n if (country) business.country = country;\n if (list !== undefined) {\n business.currencies = [...list.matchAll(/['\"]([A-Za-z]{3})['\"]/g)].map(\n (m) => m[1],\n );\n }\n return business;\n}\n\n/** The currency `src/lib/site.ts` declares, if any. */\nexport function siteCurrency(root: string): string | null {\n return siteBusiness(root).currency ?? null;\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 what the business says about itself: create\n * the file with it, or add the properties an existing one lacks. A property\n * already there is kept, whatever `business` says; the result says what the\n * file declares after the call, and the file to write, if anything changed.\n */\nexport async function ensureSiteBusiness(\n options: Options,\n business: SiteBusiness,\n): Promise<{ file: File | null; business: SiteBusiness }> {\n const file = sitePath(options.root);\n const wanted = BUSINESS_KEYS.filter((key) => business[key] !== undefined);\n if (!fs.existsSync(file)) {\n if (wanted.length === 0) return { file: null, business: {} };\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, business),\n status: \"success\",\n },\n business,\n };\n }\n\n const existing = siteBusiness(options.root);\n let source = fs.readFileSync(file, \"utf8\");\n const added: string[] = [];\n for (const key of wanted) {\n if (existing[key] !== undefined) continue;\n const next = withSiteProperty(source, key, business[key]!);\n if (next === null) continue;\n source = next;\n added.push(key);\n (existing as Record<string, unknown>)[key] = business[key];\n }\n if (added.length === 0) return { file: null, business: existing };\n getLogger(options).info(`Adding ${added.join(\", \")} to src/lib/site.ts`);\n return {\n file: {\n path: file,\n language: languageFromPath(file),\n content: source,\n status: \"success\",\n },\n business: existing,\n };\n}\n\n/** `ensureSiteBusiness` for the currency alone, as the Phase 1.5 code called it. */\nexport async function ensureSiteCurrency(\n options: Options,\n currency: string,\n): Promise<{ file: File | null; currency: string }> {\n const { file, business } = await ensureSiteBusiness(options, { currency });\n return { file, currency: business.currency ?? currency };\n}\n"],"mappings":";;;;;;AAQA,SAAgBK,EAAS,GAAsB;CAC7C,OAAOD,EAAK,KAAKE,GAAM,OAAO,OAAO,SAAS;AAChD;AAoBA,IAAMC,IAA+B;CAAC;CAAY;CAAW;AAAY;AAMzE,SAAgBC,EACd,GACA,IAAM,yBACN,IAAkC,CAAC,GAC3B;CAER,IAAMC,IACJ,OAAOC,KAAa,WAAW,EAAE,UAAUA,EAAS,IAAIA,GACpDC,IAAQJ,EAAc,QAAQ,MAAQE,EAASG,OAAS,KAAA,CAAS,CAAC,CAAC,KACtE,MAAQC,EAAcD,GAAKH,EAASG,EAAK,CAC5C,GACME,IAAa;EACjB,WAAWC,EAAMC,CAAI,EAAE;EACvB,UAAUD,EAAME,CAAG;EACnB,GAAGN,EAAM,KAAK,MAAUO,EAAM,KAAK,IAAI,CAAC;CAC1C;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jD,EAAiBiD,CAAI;GAC/B,SAASzC,EAAW,MAAMmC,EAAaC,CAAO,GAAG,KAAA,GAAWlC,CAAQ;GACpE,QAAQ;EACV;EACA;CACF;CAGF,IAAM0C,IAAWhB,EAAaQ,EAAQ,IAAI,GACtCV,IAAS/B,EAAG,aAAa8C,GAAM,MAAM,GACnCI,IAAkB,CAAC;CACzB,KAAK,IAAMzC,KAAOuC,GAAQ;EACxB,IAAIC,EAASxC,OAAS,KAAA,GAAW;EACjC,IAAM0C,IAAOtB,EAAiBE,GAAQtB,GAAKF,EAASE,EAAK;EACzD,AAAI0C,MAAS,SACb,IAASA,GACTD,EAAM,KAAKzC,CAAG,GACd,EAAsCA,KAAOF,EAASE;CACxD;CAGA,OAFIyC,EAAM,WAAW,IAAU;EAAE,MAAM;EAAM,UAAUD;CAAS,KAChEnD,EAAU2C,CAAO,CAAC,CAAC,KAAK,UAAUS,EAAM,KAAK,IAAI,EAAE,oBAAoB,GAChE;EACL,MAAM;GACJ,MAAMJ;GACN,UAAUjD,EAAiBiD,CAAI;GAC/B,SAASf;GACT,QAAQ;EACV;EACA,UAAUkB;CACZ;AACF"}
|
|
1
|
+
{"version":3,"file":"site-D0IuWkAR.js","names":["languageFromPath","getLogger","withPocketbase","fs","path","sitePath","root","BUSINESS_KEYS","siteModule","declared","business","lines","key","propertyLines","properties","quote","name","url","entry","i","ensureComma","value","SUPPORTED_CURRENCIES","normalizeCurrency","raw","code","normalizeCountry","normalizeCurrencies","entries","codes","home","SITE_OBJECT","withSiteProperty","match","source","body","siteBusiness","text","shape","list","currency","country","m","existingName","options","appName","pb","pkg","ensureSiteFile","file","ensureSiteBusiness","wanted","existing","added","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 * What a business declares about itself in `src/lib/site.ts`, next to the\n * app's name: the currency it prices in and is paid in, the country it is in\n * (prices format for it: `es-MX`, not `es`) and the other currencies it shows\n * prices in, as estimates. Every property is optional; a payments provider\n * asks for what it needs.\n */\nexport interface SiteBusiness {\n /** ISO 4217, e.g. `MXN`. */\n currency?: string;\n /** ISO 3166-1 alpha-2, e.g. `MX`. */\n country?: string;\n /** ISO 4217 codes the site also shows prices in; empty means the home currency only. */\n currencies?: string[];\n}\n\ntype BusinessKey = keyof SiteBusiness;\n\nconst BUSINESS_KEYS: BusinessKey[] = [\"currency\", \"country\", \"currencies\"];\n\n/**\n * `src/lib/site.ts` as the CLI templates ship it (`site.template.ts`), with\n * the placeholders filled in, plus whatever the business declares.\n */\nexport function siteModule(\n name: string,\n url = \"http://localhost:5173\",\n business: SiteBusiness | string = {},\n): string {\n // The old third argument was the currency alone.\n const declared: SiteBusiness =\n typeof business === \"string\" ? { currency: business } : business;\n const lines = BUSINESS_KEYS.filter((key) => declared[key] !== undefined).map(\n (key) => propertyLines(key, declared[key]!),\n );\n const properties = [\n `\\tname: ${quote(name)},`,\n `\\turl: ${quote(url)}`,\n ...lines.map((entry) => entry.join(\"\\n\")),\n ];\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 // Every property but the last ends in a comma.\n ...properties.map((entry, i) =>\n i < properties.length - 1 ? ensureComma(entry) : entry,\n ),\n \"};\",\n \"\",\n ].join(\"\\n\");\n}\n\nfunction ensureComma(entry: string): string {\n return entry.endsWith(\",\") ? entry : `${entry},`;\n}\n\n/** A property's lines: its doc comment, then `key: value` with no trailing comma. */\nfunction propertyLines(key: BusinessKey, value: string | string[]): string[] {\n switch (key) {\n case \"currency\":\n return [\n \"\\t/** ISO 4217: the currency the business prices in and is paid in. */\",\n `\\tcurrency: ${quote(value as string)}`,\n ];\n case \"country\":\n return [\n \"\\t/** ISO 3166-1: the country the business is in; prices format for it. */\",\n `\\tcountry: ${quote(value as string)}`,\n ];\n case \"currencies\":\n return [\n \"\\t/** Other currencies prices are shown in, as estimates at the day's rate. */\",\n `\\tcurrencies: [${(value as string[]).map(quote).join(\", \")}]`,\n ];\n }\n}\n\nconst SUPPORTED_CURRENCIES = (\n Intl as unknown as {\n supportedValuesOf: (key: \"currency\") => string[];\n }\n).supportedValuesOf(\"currency\");\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 return SUPPORTED_CURRENCIES.includes(code) ? code : null;\n}\n\n/** A two-letter ISO 3166-1 code, upper-cased; anything else is refused. */\nexport function normalizeCountry(raw: unknown): string | null {\n if (typeof raw !== \"string\") return null;\n const code = raw.trim().toUpperCase();\n if (!/^[A-Z]{2}$/.test(code)) return null;\n // `Intl.DisplayNames` knows every region; an unknown one comes back as is.\n const names = new Intl.DisplayNames([\"en\"], { type: \"region\" });\n return names.of(code) !== code ? code : null;\n}\n\n/**\n * A list of currency codes, from an array or a comma-separated string,\n * upper-cased and deduplicated; `null` when any entry is not a currency.\n * `home` is left out: the business's own currency is never a display one.\n */\nexport function normalizeCurrencies(\n raw: unknown,\n home?: string,\n): string[] | null {\n const entries = Array.isArray(raw)\n ? raw\n : typeof raw === \"string\"\n ? raw.split(/[,\\s]+/)\n : null;\n if (!entries) return null;\n const codes: string[] = [];\n for (const entry of entries) {\n if (entry === \"\" || entry === undefined) continue;\n const code = normalizeCurrency(entry);\n if (!code) return null;\n if (code !== home && !codes.includes(code)) codes.push(code);\n }\n return codes;\n}\n\nconst SITE_OBJECT = /export const site = \\{\\n([\\s\\S]*?)\\n\\};/;\n\n/**\n * `src/lib/site.ts` with `key` added as the object's last property, or\n * `null` when it already has one (a project's declaration is never changed\n * behind its back) or has no `export const site = { ... };` to add it to.\n */\nexport function withSiteProperty(\n source: string,\n key: BusinessKey,\n value: string | string[],\n): string | null {\n const match = SITE_OBJECT.exec(source);\n if (!match || new RegExp(`^\\\\s*${key}\\\\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${propertyLines(key, value).join(\"\\n\")}\\n};`,\n );\n}\n\n/** `withSiteProperty` for the currency, as the Phase 1.5 code called it. */\nexport function withSiteCurrency(\n source: string,\n currency: string,\n): string | null {\n return withSiteProperty(source, \"currency\", currency);\n}\n\n/** What `src/lib/site.ts` declares about the business, if anything. */\nexport function siteBusiness(root: string): SiteBusiness {\n let source: string;\n try {\n source = fs.readFileSync(sitePath(root), \"utf8\");\n } catch {\n return {};\n }\n const text = (key: string, shape: string) =>\n new RegExp(`^\\\\s*${key}\\\\s*:\\\\s*['\"](${shape})['\"]`, \"m\").exec(source)?.[1];\n const list = /^\\s*currencies\\s*:\\s*\\[([^\\]]*)\\]/m.exec(source)?.[1];\n const business: SiteBusiness = {};\n const currency = text(\"currency\", \"[A-Za-z]{3}\");\n if (currency) business.currency = currency;\n const country = text(\"country\", \"[A-Za-z]{2}\");\n if (country) business.country = country;\n if (list !== undefined) {\n business.currencies = [...list.matchAll(/['\"]([A-Za-z]{3})['\"]/g)].map(\n (m) => m[1],\n );\n }\n return business;\n}\n\n/** The currency `src/lib/site.ts` declares, if any. */\nexport function siteCurrency(root: string): string | null {\n return siteBusiness(root).currency ?? null;\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 what the business says about itself: create\n * the file with it, or add the properties an existing one lacks. A property\n * already there is kept, whatever `business` says; the result says what the\n * file declares after the call, and the file to write, if anything changed.\n */\nexport async function ensureSiteBusiness(\n options: Options,\n business: SiteBusiness,\n): Promise<{ file: File | null; business: SiteBusiness }> {\n const file = sitePath(options.root);\n const wanted = BUSINESS_KEYS.filter((key) => business[key] !== undefined);\n if (!fs.existsSync(file)) {\n if (wanted.length === 0) return { file: null, business: {} };\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, business),\n status: \"success\",\n },\n business,\n };\n }\n\n const existing = siteBusiness(options.root);\n let source = fs.readFileSync(file, \"utf8\");\n const added: string[] = [];\n for (const key of wanted) {\n if (existing[key] !== undefined) continue;\n const next = withSiteProperty(source, key, business[key]!);\n if (next === null) continue;\n source = next;\n added.push(key);\n (existing as Record<string, unknown>)[key] = business[key];\n }\n if (added.length === 0) return { file: null, business: existing };\n getLogger(options).info(`Adding ${added.join(\", \")} to src/lib/site.ts`);\n return {\n file: {\n path: file,\n language: languageFromPath(file),\n content: source,\n status: \"success\",\n },\n business: existing,\n };\n}\n\n/** `ensureSiteBusiness` for the currency alone, as the Phase 1.5 code called it. */\nexport async function ensureSiteCurrency(\n options: Options,\n currency: string,\n): Promise<{ file: File | null; currency: string }> {\n const { file, business } = await ensureSiteBusiness(options, { currency });\n return { file, currency: business.currency ?? currency };\n}\n"],"mappings":";;;;;;AAQA,SAAgBK,EAAS,GAAsB;CAC7C,OAAOD,EAAK,KAAKE,GAAM,OAAO,OAAO,SAAS;AAChD;AAoBA,IAAMC,IAA+B;CAAC;CAAY;CAAW;AAAY;AAMzE,SAAgBC,EACd,GACA,IAAM,yBACN,IAAkC,CAAC,GAC3B;CAER,IAAMC,IACJ,OAAOC,KAAa,WAAW,EAAE,UAAUA,EAAS,IAAIA,GACpDC,IAAQJ,EAAc,QAAQ,MAAQE,EAASG,OAAS,KAAA,CAAS,CAAC,CAAC,KACtE,MAAQC,EAAcD,GAAKH,EAASG,EAAK,CAC5C,GACME,IAAa;EACjB,WAAWC,EAAMC,CAAI,EAAE;EACvB,UAAUD,EAAME,CAAG;EACnB,GAAGN,EAAM,KAAK,MAAUO,EAAM,KAAK,IAAI,CAAC;CAC1C;CACA,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAEA,GAAGJ,EAAW,KAAK,GAAO,MACxBK,IAAIL,EAAW,SAAS,IAAIM,EAA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AAM0C,IAAWhB,EAAaQ,EAAQ,IAAI,GACtCV,IAAS/B,EAAG,aAAa8C,GAAM,MAAM,GACnCI,IAAkB,CAAC;CACzB,KAAK,IAAMzC,KAAOuC,GAAQ;EACxB,IAAIC,EAASxC,OAAS,KAAA,GAAW;EACjC,IAAM0C,IAAOtB,EAAiBE,GAAQtB,GAAKF,EAASE,EAAK;EACzD,AAAI0C,MAAS,SACb,IAASA,GACTD,EAAM,KAAKzC,CAAG,GACd,EAAsCA,KAAOF,EAASE;CACxD;CAGA,OAFIyC,EAAM,WAAW,IAAU;EAAE,MAAM;EAAM,UAAUD;CAAS,KAChEnD,EAAU2C,CAAO,CAAC,CAAC,KAAK,UAAUS,EAAM,KAAK,IAAI,EAAE,oBAAoB,GAChE;EACL,MAAM;GACJ,MAAMJ;GACN,UAAUjD,EAAiBiD,CAAI;GAC/B,SAASf;GACT,QAAQ;EACV;EACA,UAAUkB;CACZ;AACF"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { n as e } from "./rolldown-runtime-5HNE8Q1r.js";
|
|
2
|
+
import { r as t, t as n } from "./errors-DR3gF_7a.js";
|
|
3
|
+
import { n as r } from "./lib-specifier-Cngo1zF_.js";
|
|
4
|
+
import { m as i, p as a } from "./constants-CUv536Rj.js";
|
|
5
|
+
import { existsSync as o, readFileSync as s } from "node:fs";
|
|
6
|
+
import c from "node:path";
|
|
7
|
+
var l = 1e4;
|
|
8
|
+
function u(e) {
|
|
9
|
+
return typeof e == "string" && e.length > 0 ? e : void 0;
|
|
10
|
+
}
|
|
11
|
+
function d(e) {
|
|
12
|
+
let t = {}, n = c.join(e, "components.json");
|
|
13
|
+
if (o(n)) try {
|
|
14
|
+
let e = JSON.parse(s(n, "utf8"));
|
|
15
|
+
e && typeof e == "object" && (t = e);
|
|
16
|
+
} catch {
|
|
17
|
+
t = {};
|
|
18
|
+
}
|
|
19
|
+
let r = {};
|
|
20
|
+
for (let [e, n] of Object.entries(t.aliases ?? {})) {
|
|
21
|
+
let t = u(n);
|
|
22
|
+
t && (r[e] = t);
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
style: u(t.style) ?? "nova",
|
|
26
|
+
registry: u(t.registry) ?? "https://shadcn-svelte.com/registry",
|
|
27
|
+
baseColor: u(t.tailwind?.baseColor),
|
|
28
|
+
iconLibrary: u(t.iconLibrary),
|
|
29
|
+
menuColor: u(t.menuColor),
|
|
30
|
+
menuAccent: u(t.menuAccent),
|
|
31
|
+
aliases: r,
|
|
32
|
+
cssPath: u(t.tailwind?.css) ?? "src/app.css"
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
var f = [
|
|
36
|
+
"src",
|
|
37
|
+
"lib",
|
|
38
|
+
"components",
|
|
39
|
+
"ui"
|
|
40
|
+
];
|
|
41
|
+
function p(e) {
|
|
42
|
+
let t = d(e).aliases.ui, n = t === void 0 ? null : r(t);
|
|
43
|
+
return n === null ? c.join(e, ...f) : c.join(e, "src", "lib", ...n.split("/").filter(Boolean));
|
|
44
|
+
}
|
|
45
|
+
function m(e, t) {
|
|
46
|
+
return `${e.replace(/\/+$/, "")}/styles/${encodeURIComponent(t)}/index.json`;
|
|
47
|
+
}
|
|
48
|
+
var h = /* @__PURE__ */ new WeakMap();
|
|
49
|
+
function g(e) {
|
|
50
|
+
if (!Array.isArray(e)) throw Error("the index is not a list");
|
|
51
|
+
let t = [];
|
|
52
|
+
for (let n of e) {
|
|
53
|
+
if (!n || typeof n != "object") continue;
|
|
54
|
+
let { name: e, type: r } = n;
|
|
55
|
+
typeof e == "string" && typeof r == "string" && t.push({
|
|
56
|
+
name: e,
|
|
57
|
+
type: r
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
return t;
|
|
61
|
+
}
|
|
62
|
+
async function _(e, n) {
|
|
63
|
+
let r;
|
|
64
|
+
try {
|
|
65
|
+
r = await n(e, { signal: AbortSignal.timeout(l) });
|
|
66
|
+
} catch (n) {
|
|
67
|
+
let r = n instanceof Error && n.name === "TimeoutError" ? `no answer within ${l / 1e3}s` : n instanceof Error ? n.message : String(n);
|
|
68
|
+
throw new t(e, r);
|
|
69
|
+
}
|
|
70
|
+
if (!r.ok) throw new t(e, `HTTP ${r.status}`);
|
|
71
|
+
try {
|
|
72
|
+
return g(await r.json());
|
|
73
|
+
} catch (n) {
|
|
74
|
+
throw new t(e, n instanceof Error ? n.message : String(n));
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
async function v(e, t = {}) {
|
|
78
|
+
let n = d(e), r = m(n.registry, t.style ?? n.style), i = t.runtime?.fetch ?? globalThis.fetch, a = h.get(i);
|
|
79
|
+
a || (a = /* @__PURE__ */ new Map(), h.set(i, a));
|
|
80
|
+
let o = a.get(r);
|
|
81
|
+
return o || (o = _(r, i).catch((e) => {
|
|
82
|
+
throw a.delete(r), e;
|
|
83
|
+
}), a.set(r, o)), o;
|
|
84
|
+
}
|
|
85
|
+
//#endregion
|
|
86
|
+
//#region src/runtime/table-core.ts
|
|
87
|
+
var y = /* @__PURE__ */ e({
|
|
88
|
+
TABLE_CORE_COMPONENTS: () => b,
|
|
89
|
+
assertTableCorePackage: () => E,
|
|
90
|
+
assertTableCoreV9: () => T,
|
|
91
|
+
declaredTableCoreMajor: () => S
|
|
92
|
+
}), b = [
|
|
93
|
+
"data-table",
|
|
94
|
+
"column-header",
|
|
95
|
+
"faceted-filter",
|
|
96
|
+
"pagination"
|
|
97
|
+
], x = "https://tanstack.com/table/latest/docs/framework/svelte/guide/migrating";
|
|
98
|
+
function S(e) {
|
|
99
|
+
let t = c.join(e, "package.json");
|
|
100
|
+
if (!o(t)) return;
|
|
101
|
+
let n = JSON.parse(s(t, "utf8")), r = (n.dependencies?.["@tanstack/table-core"] ?? n.devDependencies?.["@tanstack/table-core"])?.match(/^[\^~>=v\s]*(\d+)/)?.[1];
|
|
102
|
+
return r === void 0 ? void 0 : Number(r);
|
|
103
|
+
}
|
|
104
|
+
function C(e) {
|
|
105
|
+
let t = c.join(p(e), "data-table", "index.ts");
|
|
106
|
+
return o(t) && s(t, "utf8").includes("createSvelteTable");
|
|
107
|
+
}
|
|
108
|
+
function w() {
|
|
109
|
+
return `Nothing was changed. To upgrade:
|
|
110
|
+
1. Install ${a}: npm install ${a}\n 2. Replace the table helpers: vela ui add ${b.join(" ")} --overwrite\n 3. Move existing list pages to the v9 API (createTable, tableFeatures): ${x}\nThen run this again.`;
|
|
111
|
+
}
|
|
112
|
+
function T(e) {
|
|
113
|
+
let t = S(e), r = t !== void 0 && t < i;
|
|
114
|
+
if (!r && !C(e)) return;
|
|
115
|
+
let a = r ? `package.json pins @tanstack/table-core ${t}.x` : "its data-table helper is the v8 one (createSvelteTable)";
|
|
116
|
+
throw new n(`This project uses TanStack Table v8 (${a}), and scaffold list pages now need v${i}.\n\n` + w());
|
|
117
|
+
}
|
|
118
|
+
function E(e, t) {
|
|
119
|
+
let r = t.filter((e) => b.includes(e));
|
|
120
|
+
if (r.length === 0) return;
|
|
121
|
+
let o = S(e);
|
|
122
|
+
if (!(o === void 0 || o >= i)) throw new n(`${r.join(", ")} target${r.length === 1 ? "s" : ""} TanStack Table v${i}, and package.json pins @tanstack/table-core ${o}.x.\n\nNothing was changed. Install ${a} first (npm install ${a}), then run this again.`);
|
|
123
|
+
}
|
|
124
|
+
//#endregion
|
|
125
|
+
export { p as a, d as i, y as n, v as r, E as t };
|
|
126
|
+
|
|
127
|
+
//# sourceMappingURL=table-core-BKBoEStB.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-core-BKBoEStB.js","names":["__exportAll","RegistryUnavailableError","InvalidArgumentError","libAliasPath","TANSTACK_TABLE_CORE_MAJOR","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,IAAMO,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,I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,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-CUv536Rj.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-BWXq9RRn.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-CbCXmPkE.js.map
|