@velastack/patterns 0.4.0 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{_layout-kkgN0IF7.js → _layout-D-FzWqn0.js} +2 -2
- package/dist/chunks/_layout-D-FzWqn0.js.map +1 -0
- package/dist/chunks/_page-C7kGoW7_.js +6 -0
- package/dist/chunks/_page-C7kGoW7_.js.map +1 -0
- package/dist/chunks/_page-e_I-fdSR.js +6 -0
- package/dist/chunks/_page-e_I-fdSR.js.map +1 -0
- package/dist/chunks/auth-pages-B52ei-4z.js +291 -0
- package/dist/chunks/auth-pages-B52ei-4z.js.map +1 -0
- package/dist/chunks/{collections-Dz2fvKnz.js → collections-zzZ_HQxB.js} +2 -2
- package/dist/chunks/collections-zzZ_HQxB.js.map +1 -0
- package/dist/chunks/{compose-handle-D_Rz3Fzo.js → compose-handle-BDlZ7Pif.js} +2 -2
- package/dist/chunks/compose-handle-BDlZ7Pif.js.map +1 -0
- package/dist/chunks/{config-target-Dx3w6WSk.js → config-target-rHgjaA8u.js} +2 -2
- package/dist/chunks/config-target-rHgjaA8u.js.map +1 -0
- package/dist/chunks/{constants-BjyMU5s8.js → constants-Rq8SCXwH.js} +2 -2
- package/dist/chunks/constants-Rq8SCXwH.js.map +1 -0
- package/dist/chunks/dedent-Gq6Krl4n.js.map +1 -1
- package/dist/chunks/dispatch-D4TN9pdW.js +6 -0
- package/dist/chunks/dispatch-D4TN9pdW.js.map +1 -0
- package/dist/chunks/env-BPfk1VAw.js.map +1 -1
- package/dist/chunks/{env-vars-C1NUX-bf.js → env-vars-CcE6ODqC.js} +4 -4
- package/dist/chunks/env-vars-CcE6ODqC.js.map +1 -0
- package/dist/chunks/env-vars-Cr4lbMD_.js.map +1 -1
- package/dist/chunks/env-vars-De0Xs0L2.js.map +1 -1
- package/dist/chunks/env-vars-file-B_6esJW3.js.map +1 -1
- package/dist/chunks/env-vars-mnRA0hOe.js.map +1 -1
- package/dist/chunks/env.preview-uMRKT5Pc.js.map +1 -1
- package/dist/chunks/errors-DR3gF_7a.js.map +1 -1
- package/dist/chunks/{format-result-DZ8De8KY.js → format-result-BVoLVknk.js} +2 -2
- package/dist/chunks/format-result-BVoLVknk.js.map +1 -0
- package/dist/chunks/{generate-DeaBlnK6.js → generate-B6Odfk5f.js} +2 -2
- package/dist/chunks/generate-B6Odfk5f.js.map +1 -0
- package/dist/chunks/{generate-WMJo3QGZ.js → generate-Bg0E3eWm.js} +2 -2
- package/dist/chunks/generate-Bg0E3eWm.js.map +1 -0
- package/dist/chunks/{generate-Gcc8iRkZ.js → generate-CFqpRi9D.js} +3 -3
- package/dist/chunks/generate-CFqpRi9D.js.map +1 -0
- package/dist/chunks/{generate-BW3l5Fxw.js → generate-CZGHByV3.js} +2 -2
- package/dist/chunks/generate-CZGHByV3.js.map +1 -0
- package/dist/chunks/generate-DetW_gbr.js.map +1 -1
- package/dist/chunks/{generate.runtime-IlBCcXvv.js → generate.runtime-5rIc-RNL.js} +7 -7
- package/dist/chunks/generate.runtime-5rIc-RNL.js.map +1 -0
- package/dist/chunks/{generate.runtime-CA7Ofjlx.js → generate.runtime-BK3mR0Rj.js} +93 -141
- package/dist/chunks/generate.runtime-BK3mR0Rj.js.map +1 -0
- package/dist/chunks/{generate.runtime-cwvAoKoH.js → generate.runtime-BpMN5Uq-.js} +3 -3
- package/dist/chunks/generate.runtime-BpMN5Uq-.js.map +1 -0
- package/dist/chunks/{generate.runtime-DD51OSuL.js → generate.runtime-CAn1qIQ_.js} +4 -4
- package/dist/chunks/generate.runtime-CAn1qIQ_.js.map +1 -0
- package/dist/chunks/{generate.runtime-CuNhY5hn.js → generate.runtime-CEqLgLT9.js} +16 -11
- package/dist/chunks/generate.runtime-CEqLgLT9.js.map +1 -0
- package/dist/chunks/{generate.runtime-B1jVAnDI.js → generate.runtime-CK10Mum5.js} +8 -8
- package/dist/chunks/generate.runtime-CK10Mum5.js.map +1 -0
- package/dist/chunks/{generate.runtime-DqD3PW-W.js → generate.runtime-CZ46nkSL.js} +3 -3
- package/dist/chunks/generate.runtime-CZ46nkSL.js.map +1 -0
- package/dist/chunks/{generate.runtime-CslAvllQ.js → generate.runtime-CbE9RHcf.js} +5 -5
- package/dist/chunks/generate.runtime-CbE9RHcf.js.map +1 -0
- package/dist/chunks/{generate.runtime-CCr1lvo4.js → generate.runtime-CpMKXBkn.js} +7 -7
- package/dist/chunks/generate.runtime-CpMKXBkn.js.map +1 -0
- package/dist/chunks/{generate.runtime-6FXJM8hT.js → generate.runtime-CqncBFNg.js} +5 -5
- package/dist/chunks/generate.runtime-CqncBFNg.js.map +1 -0
- package/dist/chunks/generate.runtime-DG2z6kqH.js +68 -0
- package/dist/chunks/generate.runtime-DG2z6kqH.js.map +1 -0
- package/dist/chunks/{generate.runtime-C6bSvGMb.js → generate.runtime-DHHlYfTD.js} +6 -6
- package/dist/chunks/generate.runtime-DHHlYfTD.js.map +1 -0
- package/dist/chunks/generate.runtime-DJ9MVVPC.js +325 -0
- package/dist/chunks/generate.runtime-DJ9MVVPC.js.map +1 -0
- package/dist/chunks/{generate.runtime-CnPraLKv.js → generate.runtime-DVB7uuht.js} +4 -4
- package/dist/chunks/generate.runtime-DVB7uuht.js.map +1 -0
- package/dist/chunks/{generate.runtime-kvxmTlQb.js → generate.runtime-Db0HZyj3.js} +3 -3
- package/dist/chunks/{generate.runtime-kvxmTlQb.js.map → generate.runtime-Db0HZyj3.js.map} +1 -1
- package/dist/chunks/{generate.runtime-D_sQOeQa.js → generate.runtime-Djas9UNy.js} +6 -6
- package/dist/chunks/generate.runtime-Djas9UNy.js.map +1 -0
- package/dist/chunks/{generate.runtime-Ce_rwzNa.js → generate.runtime-Dl6OQ7pe.js} +4 -4
- package/dist/chunks/generate.runtime-Dl6OQ7pe.js.map +1 -0
- package/dist/chunks/{generate.runtime-1-91UmM8.js → generate.runtime-DoZJHtZh.js} +4 -4
- package/dist/chunks/generate.runtime-DoZJHtZh.js.map +1 -0
- package/dist/chunks/generate.runtime-Dp7SsCQG.js +42 -0
- package/dist/chunks/generate.runtime-Dp7SsCQG.js.map +1 -0
- package/dist/chunks/{generate.runtime-C8zJRNYG.js → generate.runtime-E-zoeSKW.js} +5 -5
- package/dist/chunks/generate.runtime-E-zoeSKW.js.map +1 -0
- package/dist/chunks/{generate.runtime-pVLzzpUM.js → generate.runtime-EQnytCFL.js} +40 -40
- package/dist/chunks/generate.runtime-EQnytCFL.js.map +1 -0
- package/dist/chunks/generate.runtime-IWEhGhWY.js +218 -0
- package/dist/chunks/generate.runtime-IWEhGhWY.js.map +1 -0
- package/dist/chunks/{generate.runtime-CYagyR5c.js → generate.runtime-a3R4hqFy.js} +6 -6
- package/dist/chunks/generate.runtime-a3R4hqFy.js.map +1 -0
- package/dist/chunks/{generate.runtime-zJpEufTc.js → generate.runtime-aQnBmH8D.js} +9 -9
- package/dist/chunks/generate.runtime-aQnBmH8D.js.map +1 -0
- package/dist/chunks/{generate.runtime-Dtgw9IQO.js → generate.runtime-axm9wcQv.js} +5 -5
- package/dist/chunks/generate.runtime-axm9wcQv.js.map +1 -0
- package/dist/chunks/{generate.runtime-DHBRyMAq.js → generate.runtime-hTKzxH2M.js} +5 -5
- package/dist/chunks/generate.runtime-hTKzxH2M.js.map +1 -0
- package/dist/chunks/{generate.runtime-BA3tDKnn.js → generate.runtime-kciwaXxh.js} +5 -5
- package/dist/chunks/generate.runtime-kciwaXxh.js.map +1 -0
- package/dist/chunks/{generate.runtime-B_UVGa3q.js → generate.runtime-koQxLywh.js} +5 -5
- package/dist/chunks/generate.runtime-koQxLywh.js.map +1 -0
- package/dist/chunks/{generate.runtime-BXkZob1O.js → generate.runtime-rs1ZOIET.js} +6 -6
- package/dist/chunks/{generate.runtime-BXkZob1O.js.map → generate.runtime-rs1ZOIET.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DV3WmZtb.js → generate.runtime-uLUiPgqx.js} +6 -6
- package/dist/chunks/generate.runtime-uLUiPgqx.js.map +1 -0
- package/dist/chunks/lib-specifier-Cngo1zF_.js.map +1 -1
- package/dist/chunks/logger-CQONztPm.js.map +1 -1
- package/dist/chunks/{modify-file-BlDeeurK.js → modify-file-DK-tCH9k.js} +3 -3
- package/dist/chunks/modify-file-DK-tCH9k.js.map +1 -0
- package/dist/chunks/modify-nav-user-BLyrW2sK.js +71 -0
- package/dist/chunks/modify-nav-user-BLyrW2sK.js.map +1 -0
- package/dist/chunks/{modify-svelte-config-remote-p0TfVzxm.js → modify-svelte-config-remote-DhuRX4FI.js} +2 -2
- package/dist/chunks/modify-svelte-config-remote-DhuRX4FI.js.map +1 -0
- package/dist/chunks/modify-user-signup-BbqTiUuA.js +54 -0
- package/dist/chunks/modify-user-signup-BbqTiUuA.js.map +1 -0
- package/dist/chunks/modify-utils-Cw-on_cL.js.map +1 -1
- package/dist/chunks/package-imports-Bbw3iMPg.js.map +1 -1
- package/dist/chunks/pocketbase-C5GS-Dh5.js.map +1 -1
- package/dist/chunks/{pocketbase-Dry6ry17.js → pocketbase-CgwbH1gI.js} +2 -2
- package/dist/chunks/pocketbase-CgwbH1gI.js.map +1 -0
- package/dist/chunks/pocketbase-DpudAAmd.js.map +1 -1
- package/dist/chunks/providers-BHR6-XZ7.js.map +1 -1
- package/dist/chunks/{shared-CZC4d7Uj.js → shared-Cc_ns5-y.js} +2 -2
- package/dist/chunks/shared-Cc_ns5-y.js.map +1 -0
- package/dist/chunks/{site-BwCA18Sv.js → site-lj0CDdQ1.js} +2 -2
- package/dist/chunks/site-lj0CDdQ1.js.map +1 -0
- package/dist/chunks/svelte-file-B3RfgVdt.js.map +1 -1
- package/dist/chunks/{table-core-AjBpYi-y.js → table-core-DhDqT03G.js} +2 -2
- package/dist/chunks/table-core-DhDqT03G.js.map +1 -0
- package/dist/chunks/{taggedTemplateLiteral-Dx0fjWiw.js → taggedTemplateLiteral-CswN2AAa.js} +1 -1
- package/dist/chunks/{test-setup-DEmWd9Ul.js → test-setup-B9fQ5L_-.js} +5 -5
- package/dist/chunks/test-setup-B9fQ5L_-.js.map +1 -0
- package/dist/chunks/{ts-morph-helpers-CDW4lhox.js → ts-morph-helpers-Bepc-Es2.js} +27 -23
- package/dist/chunks/ts-morph-helpers-Bepc-Es2.js.map +1 -0
- package/dist/chunks/{ui-X698F10c.js → ui-CuCsupFq.js} +3 -3
- package/dist/chunks/ui-CuCsupFq.js.map +1 -0
- package/dist/chunks/ui-DD4NltyN.js.map +1 -1
- package/dist/chunks/{unmodify-load-CyGzC1Hu.js → unmodify-load-Bl5vXQiL.js} +2 -2
- package/dist/chunks/unmodify-load-Bl5vXQiL.js.map +1 -0
- package/dist/chunks/util-BLYliuUK.js.map +1 -1
- package/dist/chunks/whatsapp-CguKGTtw.js +105 -0
- package/dist/chunks/whatsapp-CguKGTtw.js.map +1 -0
- package/dist/chunks/{write-result-B68lvI57.js → write-result-DiZsCS_y.js} +5 -5
- package/dist/chunks/write-result-DiZsCS_y.js.map +1 -0
- package/dist/index.d.ts +133 -1
- package/dist/index.js +2240 -2005
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/chunks/_layout-kkgN0IF7.js.map +0 -1
- package/dist/chunks/collections-Dz2fvKnz.js.map +0 -1
- package/dist/chunks/compose-handle-D_Rz3Fzo.js.map +0 -1
- package/dist/chunks/config-target-Dx3w6WSk.js.map +0 -1
- package/dist/chunks/constants-BjyMU5s8.js.map +0 -1
- package/dist/chunks/dispatch-CXOXPLFk.js +0 -6
- package/dist/chunks/dispatch-CXOXPLFk.js.map +0 -1
- package/dist/chunks/env-vars-C1NUX-bf.js.map +0 -1
- package/dist/chunks/format-result-DZ8De8KY.js.map +0 -1
- package/dist/chunks/generate-BW3l5Fxw.js.map +0 -1
- package/dist/chunks/generate-DeaBlnK6.js.map +0 -1
- package/dist/chunks/generate-Gcc8iRkZ.js.map +0 -1
- package/dist/chunks/generate-WMJo3QGZ.js.map +0 -1
- package/dist/chunks/generate.runtime-1-91UmM8.js.map +0 -1
- package/dist/chunks/generate.runtime-6FXJM8hT.js.map +0 -1
- package/dist/chunks/generate.runtime-B1jVAnDI.js.map +0 -1
- package/dist/chunks/generate.runtime-BA3tDKnn.js.map +0 -1
- package/dist/chunks/generate.runtime-BO778G0r.js +0 -188
- package/dist/chunks/generate.runtime-BO778G0r.js.map +0 -1
- package/dist/chunks/generate.runtime-B_UVGa3q.js.map +0 -1
- package/dist/chunks/generate.runtime-C6bSvGMb.js.map +0 -1
- package/dist/chunks/generate.runtime-C8zJRNYG.js.map +0 -1
- package/dist/chunks/generate.runtime-CA7Ofjlx.js.map +0 -1
- package/dist/chunks/generate.runtime-CCr1lvo4.js.map +0 -1
- package/dist/chunks/generate.runtime-CYagyR5c.js.map +0 -1
- package/dist/chunks/generate.runtime-Ce_rwzNa.js.map +0 -1
- package/dist/chunks/generate.runtime-CexC1Oky.js +0 -269
- package/dist/chunks/generate.runtime-CexC1Oky.js.map +0 -1
- package/dist/chunks/generate.runtime-CnPraLKv.js.map +0 -1
- package/dist/chunks/generate.runtime-CslAvllQ.js.map +0 -1
- package/dist/chunks/generate.runtime-CuNhY5hn.js.map +0 -1
- package/dist/chunks/generate.runtime-DD51OSuL.js.map +0 -1
- package/dist/chunks/generate.runtime-DHBRyMAq.js.map +0 -1
- package/dist/chunks/generate.runtime-DV3WmZtb.js.map +0 -1
- package/dist/chunks/generate.runtime-D_sQOeQa.js.map +0 -1
- package/dist/chunks/generate.runtime-DqD3PW-W.js.map +0 -1
- package/dist/chunks/generate.runtime-Dtgw9IQO.js.map +0 -1
- package/dist/chunks/generate.runtime-IlBCcXvv.js.map +0 -1
- package/dist/chunks/generate.runtime-cwvAoKoH.js.map +0 -1
- package/dist/chunks/generate.runtime-pVLzzpUM.js.map +0 -1
- package/dist/chunks/generate.runtime-zJpEufTc.js.map +0 -1
- package/dist/chunks/modify-file-BlDeeurK.js.map +0 -1
- package/dist/chunks/modify-svelte-config-remote-p0TfVzxm.js.map +0 -1
- package/dist/chunks/nav-user-BRIHOOpG.js +0 -6
- package/dist/chunks/nav-user-BRIHOOpG.js.map +0 -1
- package/dist/chunks/pocketbase-Dry6ry17.js.map +0 -1
- package/dist/chunks/shared-CZC4d7Uj.js.map +0 -1
- package/dist/chunks/site-BwCA18Sv.js.map +0 -1
- package/dist/chunks/table-core-AjBpYi-y.js.map +0 -1
- package/dist/chunks/test-setup-DEmWd9Ul.js.map +0 -1
- package/dist/chunks/ts-morph-helpers-CDW4lhox.js.map +0 -1
- package/dist/chunks/ui-X698F10c.js.map +0 -1
- package/dist/chunks/unmodify-load-CyGzC1Hu.js.map +0 -1
- package/dist/chunks/write-result-B68lvI57.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.runtime-Djas9UNy.js","names":["languageFromPath","BACKEND_ENV_VARS","pruneUnusedImports","ensureNamedImport","ensureBlankLineAfterImports","formatLikeSource","replaceHandle","modifySvelteConfig","modifyTestSetup","WITH_BACKEND","modifyGitignore","hasVitestConfig","VITEST_CONFIG","fs","path","POCKETBASE_TYPES","VITEST_CONFIGS","ext","modifyTsconfigBackend","filePath","root","original","vitestConfig","name","wanted","config","entry","include","normalize","has","existing","next","insertAfter","index","after","i","indent","POCKETBASE_ENV_NAMES","POCKETBASE_HANDLE","FAILURE_HINT","modifyHooksServerBackend","hooksServerPath","sourceFile","Project","QuoteKind","composed","statement","Node","doc","generate","logger","getLogger","options","modifies","creates","create","adapter","svelteConfigFile","modifyOutcomeToFile","hooksServerFile","envVars","modifyEnvVarsFiles","gitignorePath","gitignoreFile","testSetupPath","testSetupFile","tsconfigPath","tsconfigFile"],"sources":["../../src/patterns/enable/backend/modifies/tsconfig.ts","../../src/patterns/enable/backend/modifies/hooks.server.ts","../../src/patterns/enable/backend/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\n/** Where `vela sync` writes PocketBase's generated types (`Schemas`, the typed client). */\nexport const POCKETBASE_TYPES = \".svelte-kit/types/pocketbase/*.d.ts\";\n\nconst VITEST_CONFIGS = [\"ts\", \"mts\", \"js\", \"mjs\"].map(\n (ext) => `vitest.config.${ext}`,\n);\n\n/**\n * SvelteKit 3's `$app/tsconfig` lists no files: the project's own `include`\n * decides what is type-checked, and `sv create` writes `[\"src\",\n * \"vite.config.ts\"]`. A backend adds three things that have to be in it, as\n * they are in vela's minimal template: `test` (the server-test context that\n * every `server.test.ts` reads), the vitest config, and PocketBase's generated\n * types, without which `Schemas` is missing from `@velastack/pocketbase`.\n *\n * Entries already there stay, in their order. A tsconfig with no `include`\n * checks everything already; one that is not plain JSON (comments) is left\n * alone with the entries to add.\n */\nexport function modifyTsconfigBackend(root: string): ModifyOutcome {\n const filePath = path.join(root, \"tsconfig.json\");\n if (!fs.existsSync(filePath)) {\n return { status: \"success\", changed: false };\n }\n const original = fs.readFileSync(filePath, \"utf8\");\n const vitestConfig =\n VITEST_CONFIGS.find((name) => fs.existsSync(path.join(root, name))) ??\n \"vitest.config.ts\";\n const wanted = [\"test\", vitestConfig, POCKETBASE_TYPES];\n\n let config: Record<string, unknown>;\n try {\n config = JSON.parse(original) as Record<string, unknown>;\n } catch {\n return {\n status: \"failed\",\n message: `Add these to the \"include\" array of tsconfig.json: ${wanted\n .map((entry) => JSON.stringify(entry))\n .join(\", \")}`,\n };\n }\n const include = config.include;\n if (include === undefined) {\n return { status: \"success\", changed: false };\n }\n if (!Array.isArray(include)) {\n return {\n status: \"failed\",\n message: `tsconfig.json \"include\" is not an array; it needs ${wanted.join(\", \")}`,\n };\n }\n\n const normalize = (entry: unknown) =>\n typeof entry === \"string\" ? entry.replace(/^\\.\\//, \"\") : entry;\n const has = (entry: string) =>\n include.some((existing) => normalize(existing) === entry);\n const next = [...include] as unknown[];\n const insertAfter = (entry: string, after: (e: unknown) => boolean) => {\n if (has(entry)) return;\n let index = -1;\n next.forEach((e, i) => {\n if (after(e)) index = i;\n });\n next.splice(index === -1 ? next.length : index + 1, 0, entry);\n };\n insertAfter(\"test\", (e) => normalize(e) === \"src\");\n insertAfter(vitestConfig, (e) =>\n /^vite\\.config\\.[cm]?[jt]s$/.test(String(normalize(e))),\n );\n insertAfter(POCKETBASE_TYPES, () => false);\n\n if (next.length === include.length) {\n return { status: \"success\", changed: false };\n }\n config.include = next;\n const indent = original.match(/^\\{\\s*\\n([\\t ]+)/)?.[1] ?? \"\\t\";\n fs.writeFileSync(filePath, `${JSON.stringify(config, null, indent)}\\n`);\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { Node, Project, QuoteKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { replaceHandle } from \"../../../../runtime/compose-handle\";\nimport {\n ensureBlankLineAfterImports,\n ensureNamedImport,\n pruneUnusedImports,\n formatLikeSource,\n} from \"../../../../runtime/ts-morph-helpers\";\n\n/** The variables the handle reads, imported from `$app/env/private`. */\nexport const POCKETBASE_ENV_NAMES = [\n \"POCKETBASE_URL\",\n \"POCKETBASE_SUPERUSER_EMAIL\",\n \"POCKETBASE_SUPERUSER_PASSWORD\",\n] as const;\n\n/** The handle `creates/src/hooks.server.ts` exports, for a file that already exists. */\nexport const POCKETBASE_HANDLE = dedent`\n handlePocketbase({\n \tpocketbaseUrl: POCKETBASE_URL,\n \tsuperuserEmail: POCKETBASE_SUPERUSER_EMAIL,\n \tsuperuserPassword: POCKETBASE_SUPERUSER_PASSWORD\n })\n`;\n\nconst FAILURE_HINT = dedent`\n Add the PocketBase handle to the exported handle in src/hooks.server.ts:\n\n import { sequence } from '@sveltejs/kit/hooks';\n import {\n \tPOCKETBASE_URL,\n \tPOCKETBASE_SUPERUSER_EMAIL,\n \tPOCKETBASE_SUPERUSER_PASSWORD\n } from '$app/env/private';\n import { handlePocketbase } from '@velastack/pocketbase';\n\n export const handle = sequence(\n \t/* your existing handle */,\n \t${POCKETBASE_HANDLE.replace(/\\n/g, \"\\n\\t\")}\n );\n`;\n\n/**\n * Compose the PocketBase handle into a `hooks.server.ts` the project already\n * has, instead of the create overwriting it: a static site's, or one i18n or\n * content negotiation wrote. It takes `handleStatic()`'s place, since\n * `handlePocketbase` does what that did and more; otherwise it goes last, so\n * the handles already there keep running first.\n */\nexport function modifyHooksServerBackend(\n hooksServerPath: string,\n): ModifyOutcome {\n if (!fs.existsSync(hooksServerPath)) {\n // The create writes it.\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(hooksServerPath, \"utf8\");\n const project = new Project({\n compilerOptions: { allowJs: true },\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(hooksServerPath);\n\n const composed = replaceHandle(sourceFile, \"handleStatic\", {\n expression: POCKETBASE_HANDLE,\n name: \"handlePocketbase\",\n position: \"last\",\n });\n if (composed.status === \"unsupported\") {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n if (composed.status === \"unchanged\") {\n return { status: \"success\", changed: false };\n }\n\n // The static template's comment explains handleStatic(). Where that was the\n // whole handle, replaceHandle already dropped it; in a sequence (i18n or\n // negotiation composed in since) it is still there, describing a handle\n // that is gone.\n const statement = composed.statement;\n if (statement && Node.isJSDocable(statement)) {\n for (const doc of statement.getJsDocs()) {\n if (doc.getText().includes(\"vela legal\")) doc.remove();\n }\n }\n\n pruneUnusedImports(sourceFile, [\"@velastack/kit\"]);\n for (const name of POCKETBASE_ENV_NAMES) {\n ensureNamedImport(sourceFile, \"$app/env/private\", name);\n }\n ensureNamedImport(sourceFile, \"@velastack/pocketbase\", \"handlePocketbase\");\n\n formatLikeSource(sourceFile);\n ensureBlankLineAfterImports(sourceFile);\n sourceFile.saveSync();\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== original,\n };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { modifySvelteConfig } from \"./modifies/svelte-config\";\nimport { modifyGitignore } from \"./modifies/gitignore\";\nimport { modifyTsconfigBackend } from \"./modifies/tsconfig\";\nimport { languageFromPath } from \"../../../core/util\";\nimport {\n hasVitestConfig,\n modifyTestSetup,\n VITEST_CONFIG,\n WITH_BACKEND,\n} from \"./modifies/test-setup\";\nimport { modifyHooksServerBackend } from \"./modifies/hooks.server\";\nimport { modifyEnvVarsFiles } from \"../../../runtime/env-vars\";\nimport { BACKEND_ENV_VARS } from \"./env-vars\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n const creates: File[] = [];\n const create = (filePath: string, content: string) =>\n creates.push({\n path: filePath,\n language: languageFromPath(filePath),\n content,\n status: \"success\",\n });\n\n logger.info(\"Modifying adapter config\");\n const adapter = modifySvelteConfig(options.root);\n const svelteConfigFile = modifyOutcomeToFile(\n adapter.filePath,\n adapter.outcome,\n );\n if (svelteConfigFile) modifies.push(svelteConfigFile);\n\n // A hooks.server.ts the project already has keeps its handles; the create\n // only writes the file where there is none (see `keepMissing` in index.ts).\n const hooksServerPath = path.join(options.root, \"src\", \"hooks.server.ts\");\n const hooksServerFile = modifyOutcomeToFile(\n hooksServerPath,\n modifyHooksServerBackend(hooksServerPath),\n );\n if (hooksServerFile) {\n logger.info(\"Modifying hooks.server.ts\");\n modifies.push(hooksServerFile);\n }\n\n // SvelteKit 3 exposes only declared variables: the handle above reads\n // these three from `$app/env/private`.\n logger.info(\"Declaring the PocketBase variables in src/env.ts\");\n const envVars = modifyEnvVarsFiles(options.root, BACKEND_ENV_VARS);\n if (envVars.create) creates.push(envVars.create);\n if (envVars.modify) modifies.push(envVars.modify);\n\n logger.info(\"Modifying .gitignore\");\n const gitignorePath = path.join(options.root, \".gitignore\");\n const gitignoreFile = modifyOutcomeToFile(\n gitignorePath,\n modifyGitignore(gitignorePath),\n );\n if (gitignoreFile) modifies.push(gitignoreFile);\n\n // A backend brings server tests with it. The static template and a project\n // vela did not create have no harness at all, so what is missing is created:\n // the setup file, and the vitest config that loads it.\n const testSetupPath = path.join(options.root, \"test\", \"setup.ts\");\n if (fs.existsSync(testSetupPath)) {\n logger.info(\"Modifying test/setup.ts\");\n const testSetupFile = modifyOutcomeToFile(\n testSetupPath,\n modifyTestSetup(testSetupPath),\n );\n if (testSetupFile) modifies.push(testSetupFile);\n } else {\n logger.info(\"Creating test/setup.ts\");\n create(\"test/setup.ts\", WITH_BACKEND);\n }\n\n if (!hasVitestConfig(options.root)) {\n logger.info(\"Creating vitest.config.ts\");\n create(\"vitest.config.ts\", VITEST_CONFIG);\n }\n\n // Kit 3's tsconfig lists no files, so the test harness and PocketBase's\n // generated types are type-checked only when the project's include names them.\n const tsconfigPath = path.join(options.root, \"tsconfig.json\");\n const tsconfigFile = modifyOutcomeToFile(\n tsconfigPath,\n modifyTsconfigBackend(options.root),\n );\n if (tsconfigFile) {\n logger.info(\"Modifying tsconfig.json\");\n modifies.push(tsconfigFile);\n }\n\n return {\n creates,\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;;;;;;AAKA,IAAae,IAAmB,uCAE1BC,IAAiB;CAAC;CAAM;CAAO;CAAM;AAAK,CAAC,CAAC,KAC/C,MAAQ,iBAAiBC,GAC5B;AAcA,SAAgBC,EAAsB,GAA6B;CACjE,IAAMC,IAAWL,EAAK,KAAKM,GAAM,eAAe;CAChD,IAAI,CAACP,EAAG,WAAWM,CAAQ,GACzB,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAE7C,IAAME,IAAWR,EAAG,aAAaM,GAAU,MAAM,GAC3CG,IACJN,EAAe,MAAM,MAASH,EAAG,WAAWC,EAAK,KAAKM,GAAMG,CAAI,CAAC,CAAC,KAClE,oBACIC,IAAS;EAAC;EAAQF;EAAcP;CAAgB,GAElDU;CACJ,IAAI;EACF,IAAS,KAAK,MAAMJ,CAAQ;CAC9B,QAAQ;EACN,OAAO;GACL,QAAQ;GACR,SAA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EACnBQ,GACAhD,EAAsBkC,EAAQ,IAAI,CACpC;CAMA,OALIe,MACFjB,EAAO,KAAK,yBAAyB,GACrCG,EAAS,KAAKc,CAAY,IAGrB;EACL;EACA;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { n as e } from "./logger-CQONztPm.js";
|
|
2
|
-
import { t } from "./shared-
|
|
3
|
-
import { f as n, o as r } from "./ts-morph-helpers-
|
|
4
|
-
import { modifyOutcomeToFile as i } from "./modify-file-
|
|
2
|
+
import { t } from "./shared-Cc_ns5-y.js";
|
|
3
|
+
import { f as n, o as r } from "./ts-morph-helpers-Bepc-Es2.js";
|
|
4
|
+
import { modifyOutcomeToFile as i } from "./modify-file-DK-tCH9k.js";
|
|
5
5
|
import { t as a } from "./svelte-file-B3RfgVdt.js";
|
|
6
6
|
import o from "node:fs";
|
|
7
7
|
import s from "node:path";
|
|
@@ -91,4 +91,4 @@ async function f(n) {
|
|
|
91
91
|
//#endregion
|
|
92
92
|
export { f as generate };
|
|
93
93
|
|
|
94
|
-
//# sourceMappingURL=generate.runtime-
|
|
94
|
+
//# sourceMappingURL=generate.runtime-Dl6OQ7pe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.runtime-Dl6OQ7pe.js","names":["apiObj","getLogger","removeNavItemFromScript","formatLikeSource","SvelteFile","fs","path","unmodifyHooksServer","hooksServerPath","originalSource","sourceFile","Project","callExpr","SyntaxKind","ce","firstArg","apiProp","apiInit","apiKeysProp","unmodifyNavUser","navUserPath","source","file","wasRemoved","tryRemove","run","result","src","fn","generate","logger","options","modifies","pushResult","modifyOutcomeToFile","planDropsForCollections"],"sources":["../../src/patterns/disable/api-keys/modifies/hooks.server.ts","../../src/patterns/disable/api-keys/modifies/nav-user.svelte.ts","../../src/patterns/disable/api-keys/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { Project, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { formatLikeSource } from \"../../../../runtime/ts-morph-helpers\";\n\nexport function unmodifyHooksServer(hooksServerPath: string): ModifyOutcome {\n if (!fs.existsSync(hooksServerPath)) {\n return { status: \"success\", changed: false };\n }\n\n const originalSource = fs.readFileSync(hooksServerPath, \"utf8\");\n const project = new Project();\n const sourceFile = project.addSourceFileAtPath(hooksServerPath);\n\n const callExpr = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .find((ce) => ce.getExpression().getText() === \"handlePocketbase\");\n if (!callExpr) return { status: \"success\", changed: false };\n\n const [firstArg] = callExpr.getArguments();\n if (!firstArg || firstArg.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n return { status: \"success\", changed: false };\n }\n\n const optionsObj = firstArg.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);\n const apiProp = optionsObj.getProperty(\"api\");\n if (!apiProp || apiProp.getKind() !== SyntaxKind.PropertyAssignment) {\n return { status: \"success\", changed: false };\n }\n\n const apiInit = (\n apiProp as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n if (!apiInit || apiInit.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n return { status: \"success\", changed: false };\n }\n\n const apiObj = apiInit as import(\"ts-morph\").ObjectLiteralExpression;\n const apiKeysProp = apiObj.getProperty(\"apiKeys\");\n if (!apiKeysProp) {\n return { status: \"success\", changed: false };\n }\n\n apiKeysProp.remove();\n\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\n };\n}\n","import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport { removeNavItemFromScript } from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nexport function unmodifyNavUser(navUserPath: string): ModifyOutcome {\n if (!fs.existsSync(navUserPath)) {\n return { status: \"success\", changed: false };\n }\n\n const source = fs.readFileSync(navUserPath, \"utf8\");\n if (!source.includes(\"/api-keys\")) {\n return { status: \"success\", changed: false };\n }\n\n const file = new SvelteFile(source);\n let wasRemoved = false;\n\n const tryRemove = (run: (fn: (s: string) => string) => boolean) => {\n if (wasRemoved) return;\n run((src) => {\n const result = removeNavItemFromScript(\n src,\n \"API Keys\",\n \"@lucide/svelte/icons/key-round\",\n );\n if (result.wasRemoved) wasRemoved = true;\n return result.source;\n });\n };\n\n tryRemove((fn) => file.modifyModuleScript(fn));\n if (!wasRemoved) tryRemove((fn) => file.modifyScript(fn));\n\n if (!wasRemoved) {\n return { status: \"success\", changed: false };\n }\n\n fs.writeFileSync(navUserPath, file.toString(), \"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 { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { unmodifyHooksServer } from \"./modifies/hooks.server\";\nimport { unmodifyNavUser } from \"./modifies/nav-user.svelte\";\nimport { planDropsForCollections } from \"../../destroy/shared\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Reverting hooks.server.ts\");\n const hooksServerPath = path.join(options.root, \"src\", \"hooks.server.ts\");\n pushResult(\n modifyOutcomeToFile(hooksServerPath, unmodifyHooksServer(hooksServerPath)),\n );\n\n logger.info(\"Reverting nav-user.svelte\");\n const navUserPath = path.join(\n options.root,\n \"src\",\n \"lib\",\n \"components\",\n \"nav-user.svelte\",\n );\n pushResult(modifyOutcomeToFile(navUserPath, unmodifyNavUser(navUserPath)));\n\n const collectionDrops = await planDropsForCollections([\"api_keys\"], options);\n\n return {\n creates: [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionP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 +3,9 @@ import { t as r } from "./dedent-Gq6Krl4n.js";
|
|
|
3
3
|
import { n as i } from "./logger-CQONztPm.js";
|
|
4
4
|
import { r as a, t as o } from "./generate-DetW_gbr.js";
|
|
5
5
|
import { t as s } from "./env-BPfk1VAw.js";
|
|
6
|
-
import { _ as c, r as l } from "./ts-morph-helpers-
|
|
7
|
-
import { modifyOutcomeToFile as u } from "./modify-file-
|
|
8
|
-
import { modifyEnvVarsFiles as d } from "./env-vars-
|
|
6
|
+
import { _ as c, r as l } from "./ts-morph-helpers-Bepc-Es2.js";
|
|
7
|
+
import { modifyOutcomeToFile as u } from "./modify-file-DK-tCH9k.js";
|
|
8
|
+
import { modifyEnvVarsFiles as d } from "./env-vars-CcE6ODqC.js";
|
|
9
9
|
import { t as f } from "./svelte-file-B3RfgVdt.js";
|
|
10
10
|
import p from "node:fs";
|
|
11
11
|
import m from "node:path";
|
|
@@ -82,4 +82,4 @@ async function x(r) {
|
|
|
82
82
|
//#endregion
|
|
83
83
|
export { x as generate };
|
|
84
84
|
|
|
85
|
-
//# sourceMappingURL=generate.runtime-
|
|
85
|
+
//# sourceMappingURL=generate.runtime-DoZJHtZh.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.runtime-DoZJHtZh.js","names":["providerEnvVars","resolveProvider","suppliedProviderEnv","dedent","getLogger","envEditsFor","META","modifyEnv","withInMemoryScript","ensureImports","SvelteFile","fs","path","MODULE_SPECIFIER","IMPORT_SNIPPET","MARKUP_SNIPPET","NOT_FOUND_HINT","FAILURE_HINT","modifyLayoutSvelte","layoutPath","file","out","source","sf","generate","logger","options","provider","creates","modifies","pushResult","modifyOutcomeToFile","envVars","modifyEnvVarsFiles","envPath"],"sources":["../../src/patterns/enable/analytics/modifies/layout.svelte.ts","../../src/patterns/enable/analytics/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport {\n ensureImports,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst MODULE_SPECIFIER = \"#lib/components/analytics/analytics.svelte\";\n\nconst IMPORT_SNIPPET = dedent`\n import Analytics from '${MODULE_SPECIFIER}';\n`;\n\nconst MARKUP_SNIPPET = \"\\n<Analytics />\\n\";\n\nconst NOT_FOUND_HINT = [\n \"Create the root src/routes/+layout.svelte and mount <Analytics /> inside it.\",\n \"\",\n \"Import for the <script> tag:\",\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup to add at the top level of the layout, above {@render children()}:\",\n MARKUP_SNIPPET.trim(),\n].join(\"\\n\");\n\nconst FAILURE_HINT = [\n \"Mount <Analytics /> in the root src/routes/+layout.svelte.\",\n \"\",\n 'Import for a <script lang=\"ts\"> tag:',\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup to add at the top level of the layout, above {@render children()}:\",\n MARKUP_SNIPPET.trim(),\n].join(\"\\n\");\n\n/**\n * Mounts `<Analytics />` at the top level of the root layout, ahead of\n * `{@render children()}`. The component is the same path for every provider,\n * so this modifier is provider-agnostic and a re-run with another provider\n * leaves the layout alone.\n */\nexport function modifyLayoutSvelte(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const file = SvelteFile.fromPath(layoutPath);\n if (file.hasElement(\"Analytics\")) {\n return { status: \"success\", changed: false };\n }\n if (!file.getScript()) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n file.modifyScript((source) => {\n const { source: out } = withInMemoryScript(source, (sf) => {\n ensureImports(sf, [\n { defaultImport: \"Analytics\", moduleSpecifier: MODULE_SPECIFIER },\n ]);\n });\n return out;\n });\n\n if (!file.insertBeforeChildren(MARKUP_SNIPPET)) {\n file.appendMarkup(MARKUP_SNIPPET);\n }\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport {\n providerEnvVars,\n resolveProvider,\n suppliedProviderEnv,\n} from \"../../../core/providers\";\nimport { modifyEnvVarsFiles } from \"../../../runtime/env-vars\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { modifyEnv } from \"../../../runtime/env\";\nimport { envEditsFor, META } from \"./generate\";\nimport { modifyLayoutSvelte } from \"./modifies/layout.svelte\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const provider = resolveProvider(META, options);\n const creates: File[] = [];\n const modifies: File[] = [];\n\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Modifying src/routes/+layout.svelte\");\n const layoutPath = path.join(options.root, \"src\", \"routes\", \"+layout.svelte\");\n pushResult(modifyOutcomeToFile(layoutPath, modifyLayoutSvelte(layoutPath)));\n\n // SvelteKit 3 exposes only declared variables, and only `public: true`\n // ones through `$app/env/public`, where the component imports them.\n logger.info(\"Declaring the analytics variables in src/env.ts\");\n const envVars = modifyEnvVarsFiles(options.root, providerEnvVars(provider));\n if (envVars.create) creates.push(envVars.create);\n pushResult(envVars.modify);\n\n logger.info(\"Updating .env\");\n const envPath = path.join(options.root, \".env\");\n pushResult(\n modifyOutcomeToFile(\n envPath,\n modifyEnv(envPath, envEditsFor(provider, suppliedProviderEnv(options))),\n ),\n );\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":";;;;;;;;;;;;AASA,IAAMa,IAAmB,8CAEnBC,IAAiB,CAAM;2BACFD,EAAiB;GAGtCE,IAAiB,qBAEjBC,IAAiB;CACrB;CACA;CACA;CACA;CACAF;CACA;CACA;CACAC,EAAe,KAAK;AACtB,CAAC,CAAC,KAAK,IAAI,GAELE,IAAe;CACnB;CACA;CACA;CACA;CACAH;CACA;CACA;CACA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,eAAe;CAC3B,IAAMS,IAAUtB,EAAK,KAAKc,EAAQ,MAAM,MAAM;CAQ9C,OAPAI,EACEC,EACEG,GACA3B,EAAU2B,GAAS7B,EAAYsB,GAAUzB,EAAoBwB,CAAO,CAAC,CAAC,CACxE,CACF,GAEO;EACL;EACA;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { n as e } from "./logger-CQONztPm.js";
|
|
2
|
+
import { modifyOutcomeToFile as t } from "./modify-file-DK-tCH9k.js";
|
|
3
|
+
import { i as n, n as r } from "./pocketbase-CgwbH1gI.js";
|
|
4
|
+
import { i, n as a, o } from "./whatsapp-CguKGTtw.js";
|
|
5
|
+
import { swapAuthPages as s } from "./auth-pages-B52ei-4z.js";
|
|
6
|
+
import c from "node:fs";
|
|
7
|
+
import l from "node:path";
|
|
8
|
+
//#region src/patterns/disable/whatsapp/generate.runtime.ts
|
|
9
|
+
var u = "https://docs.velastack.dev/disable/whatsapp";
|
|
10
|
+
async function d(d) {
|
|
11
|
+
let f = e(d), p = [];
|
|
12
|
+
await n(d.root, async (e) => {
|
|
13
|
+
if (!await i(e)) return;
|
|
14
|
+
f.info("Turning off WhatsApp sign-in for users"), await a(e), await r();
|
|
15
|
+
let t = o(d, !1);
|
|
16
|
+
t && p.push({
|
|
17
|
+
path: t,
|
|
18
|
+
language: "js",
|
|
19
|
+
content: c.readFileSync(t, "utf8"),
|
|
20
|
+
status: "success"
|
|
21
|
+
});
|
|
22
|
+
}), f.info("Keeping the phone fields on users, and email optional: they hold your users' data"), f.info("Taking WhatsApp off the login and signup pages");
|
|
23
|
+
let m = [], h = await s(d.root, "disable", (e) => `${l.relative(d.root, e)} is not the page enable-whatsapp wrote, so it was left as it is. Take the WhatsApp option out of it by hand: ${u}`);
|
|
24
|
+
for (let [e, n] of h) {
|
|
25
|
+
let r = t(e, n);
|
|
26
|
+
r && m.push(r);
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
creates: p,
|
|
30
|
+
modifies: m,
|
|
31
|
+
deletes: [],
|
|
32
|
+
components: [],
|
|
33
|
+
packages: [],
|
|
34
|
+
collections: [],
|
|
35
|
+
collectionPatches: [],
|
|
36
|
+
collectionDrops: []
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
export { d as generate };
|
|
41
|
+
|
|
42
|
+
//# sourceMappingURL=generate.runtime-Dp7SsCQG.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.runtime-Dp7SsCQG.js","names":["getLogger","withPocketbase","migrationDelay","disableWhatsAppAuth","fs","path","DOCS_URL","generate","logger","options","creates","hasWhatsAppPlugin","pb","file","writeWhatsAppConfigMigration","modifies","outcomes","swapAuthPages","filePath","outcome","modifyOutcomeToFile"],"sources":["../../src/patterns/disable/whatsapp/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { migrationDelay, withPocketbase } from \"../../../runtime/pocketbase\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport {\n disableWhatsAppAuth,\n hasWhatsAppPlugin,\n writeWhatsAppConfigMigration,\n} from \"../../enable/whatsapp/runtime/whatsapp\";\nimport { swapAuthPages } from \"../../enable/whatsapp/modifies/auth-pages\";\n\nconst DOCS_URL = \"https://docs.velastack.dev/disable/whatsapp\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const creates: File[] = [];\n\n await withPocketbase(options.root, async (pb) => {\n // Without the plugin there is no WhatsApp sign-in to turn off.\n if (!(await hasWhatsAppPlugin(pb))) return;\n\n logger.info(\"Turning off WhatsApp sign-in for users\");\n await disableWhatsAppAuth(pb);\n await migrationDelay();\n const file = writeWhatsAppConfigMigration(options, false);\n if (!file) return;\n creates.push({\n path: file,\n language: \"js\",\n content: fs.readFileSync(file, \"utf8\"),\n status: \"success\",\n });\n });\n logger.info(\n \"Keeping the phone fields on users, and email optional: they hold your users' data\",\n );\n\n logger.info(\"Taking WhatsApp off the login and signup pages\");\n const modifies: File[] = [];\n const outcomes = await swapAuthPages(\n options.root,\n \"disable\",\n (filePath) =>\n `${path.relative(options.root, filePath)} is not the page enable-whatsapp wrote, so it was left as it is. Take the WhatsApp option out of it by hand: ${DOCS_URL}`,\n );\n for (const [filePath, outcome] of outcomes) {\n const file = modifyOutcomeToFile(filePath, outcome);\n if (file) modifies.push(file);\n }\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":";;;;;;;;AAaA,IAAMM,IAAW;AAEjB,eAAsBC,EAAS,GAAkB;CAC/C,IAAMC,IAASR,EAAUS,CAAO,GAC1BC,IAAkB,CAAC;CAsBzB,AApBA,MAAMT,EAAeQ,EAAQ,MAAM,OAAO,MAAO;EAE/C,IAAI,CAAE,MAAME,EAAkBC,CAAE,GAAI;EAIpC,AAFAJ,EAAO,KAAK,wCAAwC,GACpD,MAAML,EAAoBS,CAAE,GAC5B,MAAMV,EAAe;EACrB,IAAMW,IAAOC,EAA6BL,GAAS,EAAK;EACxD,AAAKI,KACLH,EAAQ,KAAK;GACX,MAAMG;GACN,UAAU;GACV,SAAST,EAAG,aAAaS,GAAM,MAAM;GACrC,QAAQ;EACV,CAAC;CACH,CAAC,GACDL,EAAO,KACL,mFACF,GAEAA,EAAO,KAAK,gDAAgD;CAC5D,IAAMO,IAAmB,CAAC,GACpBC,IAAW,MAAMC,EACrBR,EAAQ,MACR,YACC,MACC,GAAGJ,EAAK,SAASI,EAAQ,MAAMS,CAAQ,EAAE,+GAA+GZ,GAC5J;CACA,KAAK,IAAM,CAACY,GAAUC,MAAYH,GAAU;EAC1C,IAAMH,IAAOO,EAAoBF,GAAUC,CAAO;EAClD,AAAIN,KAAME,EAAS,KAAKF,CAAI;CAC9B;CAEA,OAAO;EACL;EACA;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { r as e, t } from "./lib-specifier-Cngo1zF_.js";
|
|
2
2
|
import { t as n } from "./dedent-Gq6Krl4n.js";
|
|
3
3
|
import { n as r } from "./logger-CQONztPm.js";
|
|
4
|
-
import { n as i } from "./shared-
|
|
5
|
-
import { _ as a, d as o, n as s, o as c, u as l } from "./ts-morph-helpers-
|
|
6
|
-
import { modifyOutcomeToFile as u, revertOutcomeToFile as d } from "./modify-file-
|
|
4
|
+
import { n as i } from "./shared-Cc_ns5-y.js";
|
|
5
|
+
import { _ as a, d as o, n as s, o as c, u as l } from "./ts-morph-helpers-Bepc-Es2.js";
|
|
6
|
+
import { modifyOutcomeToFile as u, revertOutcomeToFile as d } from "./modify-file-DK-tCH9k.js";
|
|
7
7
|
import { t as f } from "./svelte-file-B3RfgVdt.js";
|
|
8
|
-
import { n as p } from "./compose-handle-
|
|
8
|
+
import { n as p } from "./compose-handle-BDlZ7Pif.js";
|
|
9
9
|
import m from "node:fs";
|
|
10
10
|
import h from "node:path";
|
|
11
11
|
import { Project as g, QuoteKind as _, SyntaxKind as v } from "ts-morph";
|
|
@@ -121,4 +121,4 @@ async function E(e) {
|
|
|
121
121
|
//#endregion
|
|
122
122
|
export { E as generate };
|
|
123
123
|
|
|
124
|
-
//# sourceMappingURL=generate.runtime-
|
|
124
|
+
//# sourceMappingURL=generate.runtime-E-zoeSKW.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.runtime-E-zoeSKW.js","names":["removeNegotiateImport","libModule","dedent","getLogger","toDeleteEntry","withInMemoryScript","removeNamedImportIfUnused","ensureBlankLineAfterImports","formatLikeSource","removeImportByModuleSpecifier","SvelteFile","removeHandle","fs","path","FAILURE_HINT","removeNegotiateImport$1","decl","sourceFile","isLibSpecifier","d","named","ni","unmodifyHooksServerNegotiate","hooksServerPath","original","Project","QuoteKind","removeNegotiateImport","isMeaningfullyEmpty","s","SyntaxKind","unmodifyHooksNegotiate","hooksPath","rerouteDecl","initText","hasI18nHelper","unmodifyRootLayoutNegotiate","layoutPath","file","hasElement","out","source","sf","generate","logger","options","modifies","deletes","pushResult","hooksServerRevert","revertOutcomeToFile","hooksOutcome","modifyOutcomeToFile","rootLayoutPath"],"sources":["../../src/patterns/disable/content-negotiation/modifies/hooks.server.ts","../../src/patterns/disable/content-negotiation/modifies/hooks.ts","../../src/patterns/disable/content-negotiation/modifies/root-layout.svelte.ts","../../src/patterns/disable/content-negotiation/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { Project, QuoteKind, type SourceFile } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { removeHandle } from \"../../../../runtime/compose-handle\";\nimport {\n ensureBlankLineAfterImports,\n removeNamedImportIfUnused,\n formatLikeSource,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport { isLibSpecifier } from \"../../../../runtime/lib-specifier\";\n\nconst FAILURE_HINT = dedent`\n Take handleNegotiate out of the exported handle in src/hooks.server.ts, then\n remove its import:\n\n import { handle as handleNegotiate } from '#lib/negotiate.js';\n`;\n\nfunction removeNegotiateImport(sourceFile: SourceFile): boolean {\n const decl = sourceFile\n .getImportDeclarations()\n .find((d) => isLibSpecifier(d.getModuleSpecifierValue(), \"negotiate\"));\n if (!decl) return false;\n\n const named = decl.getNamedImports().find((ni) => {\n return (\n ni.getName() === \"handle\" &&\n ni.getAliasNode()?.getText() === \"handleNegotiate\"\n );\n });\n\n if (!named) return false;\n\n if (decl.getNamedImports().length === 1 && !decl.getDefaultImport()) {\n decl.remove();\n } else {\n named.remove();\n }\n return true;\n}\n\n/**\n * Undo `modifyHooksServerNegotiate`: take `handleNegotiate` out of the\n * exported handle and drop its import. A file that held nothing else comes\n * out empty, for the caller to delete.\n */\nexport function unmodifyHooksServerNegotiate(\n hooksServerPath: string,\n): ModifyOutcome {\n if (!fs.existsSync(hooksServerPath)) {\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(hooksServerPath, \"utf8\");\n if (!original.includes(\"handleNegotiate\")) {\n return { status: \"success\", changed: false };\n }\n\n const project = new Project({\n compilerOptions: { allowJs: true },\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(hooksServerPath);\n\n const removed = removeHandle(sourceFile, \"handleNegotiate\");\n if (removed.status === \"unsupported\") {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n removeNegotiateImport(sourceFile);\n removeNamedImportIfUnused(sourceFile, \"@sveltejs/kit/hooks\", \"sequence\");\n formatLikeSource(sourceFile);\n ensureBlankLineAfterImports(sourceFile);\n sourceFile.saveSync();\n\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== original,\n };\n}\n","import fs from \"node:fs\";\nimport { Project, QuoteKind, SyntaxKind, type SourceFile } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { formatLikeSource } from \"../../../../runtime/ts-morph-helpers\";\nimport { isLibSpecifier } from \"../../../../runtime/lib-specifier\";\n\nfunction removeNegotiateImport(sourceFile: SourceFile): boolean {\n const decl = sourceFile\n .getImportDeclarations()\n .find((d) => isLibSpecifier(d.getModuleSpecifierValue(), \"negotiate\"));\n if (!decl) return false;\n\n const named = decl.getNamedImports().find((ni) => {\n return (\n ni.getName() === \"reroute\" &&\n ni.getAliasNode()?.getText() === \"negotiateReroute\"\n );\n });\n if (!named) return false;\n\n if (decl.getNamedImports().length === 1 && !decl.getDefaultImport()) {\n decl.remove();\n } else {\n named.remove();\n }\n return true;\n}\n\nfunction isMeaningfullyEmpty(sourceFile: SourceFile): boolean {\n return sourceFile\n .getStatements()\n .every((s) => s.getKind() === SyntaxKind.EmptyStatement);\n}\n\nexport function unmodifyHooksNegotiate(hooksPath: string): ModifyOutcome {\n if (!fs.existsSync(hooksPath)) {\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(hooksPath, \"utf8\");\n if (!original.includes(\"negotiateReroute\")) {\n return { status: \"success\", changed: false };\n }\n\n const project = new Project({\n compilerOptions: { allowJs: true },\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(hooksPath);\n\n const rerouteDecl = sourceFile.getVariableDeclaration(\"reroute\");\n const init = rerouteDecl?.getInitializer();\n const initText = init?.getText() ?? \"\";\n\n const hasI18nHelper = sourceFile\n .getVariableDeclarations()\n .some((d) => d.getName() === \"rerouteDeLocalize\");\n\n if (\n rerouteDecl &&\n hasI18nHelper &&\n initText.includes(\"rerouteDeLocalize\") &&\n initText.includes(\"negotiateReroute\")\n ) {\n rerouteDecl.setInitializer(\"({ url }) => rerouteDeLocalize(url.pathname)\");\n } else if (rerouteDecl && initText.includes(\"negotiateReroute\")) {\n const stmt = rerouteDecl.getFirstAncestorByKind(\n SyntaxKind.VariableStatement,\n );\n stmt?.remove();\n }\n\n removeNegotiateImport(sourceFile);\n\n if (isMeaningfullyEmpty(sourceFile)) {\n // Emptied rather than removed: the runtime turns an empty hooks.ts into a\n // delete entry, so the removal is written and reported like any other.\n fs.writeFileSync(hooksPath, \"\", \"utf8\");\n return { status: \"success\", changed: true };\n }\n\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== original,\n };\n}\n","import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport {\n removeImportByModuleSpecifier,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { libModule } from \"../../../../runtime/lib-specifier\";\n\nexport function unmodifyRootLayoutNegotiate(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"success\", changed: false };\n }\n\n const file = SvelteFile.fromPath(layoutPath);\n const hasElement = file.hasElement(\"Negotiate\");\n\n file.modifyScript((source) => {\n const { source: out } = withInMemoryScript(source, (sf) => {\n removeImportByModuleSpecifier(sf, libModule(\"negotiate\"));\n });\n return out;\n });\n\n if (hasElement) {\n file.removeElement(\"Negotiate\");\n }\n\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { toDeleteEntry } from \"../../destroy/shared\";\nimport { getLogger } from \"../../../core/logger\";\nimport {\n modifyOutcomeToFile,\n revertOutcomeToFile,\n} from \"../../../runtime/modify-file\";\nimport { unmodifyHooksServerNegotiate } from \"./modifies/hooks.server\";\nimport { unmodifyHooksNegotiate } from \"./modifies/hooks\";\nimport { unmodifyRootLayoutNegotiate } from \"./modifies/root-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 hooks.server.ts\");\n const hooksServerPath = path.join(options.root, \"src\", \"hooks.server.ts\");\n // Emptied once the negotiation handle was all it held, it goes.\n const hooksServerRevert = revertOutcomeToFile(\n hooksServerPath,\n unmodifyHooksServerNegotiate(hooksServerPath),\n );\n pushResult(hooksServerRevert.modify);\n if (hooksServerRevert.delete) deletes.push(hooksServerRevert.delete);\n\n logger.info(\"Reverting hooks.ts\");\n const hooksPath = path.join(options.root, \"src\", \"hooks.ts\");\n const hooksOutcome = unmodifyHooksNegotiate(hooksPath);\n if (\n fs.existsSync(hooksPath) &&\n fs.readFileSync(hooksPath, \"utf8\").trim() === \"\"\n ) {\n // The reroute was all it contained; the file goes with it.\n deletes.push(toDeleteEntry(hooksPath));\n } else {\n pushResult(modifyOutcomeToFile(hooksPath, hooksOutcome));\n }\n\n logger.info(\"Reverting src/routes/+layout.svelte\");\n const rootLayoutPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(\n rootLayoutPath,\n unmodifyRootLayoutNegotiate(rootLayoutPath),\n ),\n );\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":";;;;;;;;;;;;AAYA,IAAMc,IAAe,CAAM;;;;;;AAO3B,SAASd,EAAsB,GAAiC;CAC9D,IAAMgB,IAAOC,EACV,sBAAsB,CAAC,CACvB,MAAM,MAAMC,EAAeC,EAAE,wBAAwB,GAAG,WAAW,CAAC;CACvE,IAAI,CAACH,GAAM,OAAO;CAElB,IAAMI,IAAQJ,EAAK,gBAAgB,CAAC,CAAC,MAAM,MAEvCK,EAAG,QAAQ,MAAM,YACjBA,EAAG,aAAa,CAAC,EAAE,QAAQ,MAAM,iBAEpC;CASD,OAPKD,KAEDJ,EAAK,gBAAgB,CAAC,CAAC,WAAW,KAAK,CAACA,EAAK,iBAAiB,IAChEA,EAAK,OAAO,IAEZI,EAAM,OAAO,GAER,MAPY;AAQrB;AAOA,SAAgBE,EACd,GACe;CACf,IAAI,CAACV,EAAG,WAAWW,CAAe,GAChC,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAMC,IAAWZ,EAAG,aAAaW,GAAiB,MAAM;CACxD,IAAI,CAACC,EAAS,SAAS,iBAAiB,GACtC,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAO7C,IAAMP,IAAa,IAJCQ,EAAQ;EAC1B,iBAAiB,EAAE,SAAS,GAAK;EACjC,sBAAsB,EAAE,WAAWC,EAAU,OAAO;CACtD,CACmB,CAAA,CAAQ,oBAAoBH,CAAe;CAY9D,OAVgBZ,EAAaM,GAAY,iBACrC,CAAA,CAAQ,W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AAK,KAAKgC,EAAQ,MAAM,OAAO,iBAAiB,GAElEI,IAAoBC,EACxB3B,GACAD,EAA6BC,CAAe,CAC9C;CAIA,AAHAyB,EAAWC,EAAkB,MAAM,GAC/BA,EAAkB,UAAQF,EAAQ,KAAKE,EAAkB,MAAM,GAEnEL,EAAO,KAAK,oBAAoB;CAChC,IAAMZ,IAAYnB,EAAK,KAAKgC,EAAQ,MAAM,OAAO,UAAU,GACrDM,IAAepB,EAAuBC,CAAS;CAWrD,AATEpB,EAAG,WAAWoB,CAAS,KACvBpB,EAAG,aAAaoB,GAAW,MAAM,CAAC,CAAC,KAAK,MAAM,KAG9Ce,EAAQ,KAAK3C,EAAc4B,CAAS,CAAC,IAErCgB,EAAWI,EAAoBpB,GAAWmB,CAAY,CAAC,GAGzDP,EAAO,KAAK,qCAAqC;CACjD,IAAMS,IAAiBxC,EAAK,KAC1BgC,EAAQ,MACR,OACA,UACA,gBACF;CAQA,OAPAG,EACEI,EACEC,GACAjB,EAA4BiB,CAAc,CAC5C,CACF,GAEO;EACL,SAAS,CAAC;EACV;EACA;EACA,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
|
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
import { t as e } from "./lib-specifier-Cngo1zF_.js";
|
|
2
2
|
import { n as t } from "./logger-CQONztPm.js";
|
|
3
|
-
import { t as n } from "./shared-
|
|
3
|
+
import { t as n } from "./shared-Cc_ns5-y.js";
|
|
4
4
|
import { n as r } from "./env-BPfk1VAw.js";
|
|
5
|
-
import { f as i,
|
|
6
|
-
import { modifyOutcomeToFile as
|
|
7
|
-
import { unmodifyEnvVarsFiles as
|
|
8
|
-
import { t as
|
|
9
|
-
import { n as
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import { Project as
|
|
5
|
+
import { f as i, m as a, n as o, o as s } from "./ts-morph-helpers-Bepc-Es2.js";
|
|
6
|
+
import { modifyOutcomeToFile as c } from "./modify-file-DK-tCH9k.js";
|
|
7
|
+
import { unmodifyEnvVarsFiles as l } from "./env-vars-CcE6ODqC.js";
|
|
8
|
+
import { t as u } from "./svelte-file-B3RfgVdt.js";
|
|
9
|
+
import { n as d } from "./env-vars-De0Xs0L2.js";
|
|
10
|
+
import f from "node:fs";
|
|
11
|
+
import p from "node:path";
|
|
12
|
+
import { Project as m, QuoteKind as h, SyntaxKind as g } from "ts-morph";
|
|
13
13
|
//#region src/patterns/disable/payments/modifies/modify-nav-user.ts
|
|
14
|
-
function
|
|
15
|
-
if (!
|
|
14
|
+
function _(e) {
|
|
15
|
+
if (!f.existsSync(e)) return {
|
|
16
16
|
status: "success",
|
|
17
17
|
changed: !1
|
|
18
18
|
};
|
|
19
|
-
let t =
|
|
19
|
+
let t = f.readFileSync(e, "utf8");
|
|
20
20
|
if (!t.includes("/billing")) return {
|
|
21
21
|
status: "success",
|
|
22
22
|
changed: !1
|
|
23
23
|
};
|
|
24
|
-
let n = new
|
|
24
|
+
let n = new u(t), r = !1, a = (e) => {
|
|
25
25
|
r || e((e) => {
|
|
26
26
|
let t = i(e, "Billing", "@lucide/svelte/icons/credit-card");
|
|
27
27
|
return t.wasRemoved && (r = !0), t.source;
|
|
28
28
|
});
|
|
29
29
|
};
|
|
30
|
-
return a((e) => n.modifyModuleScript(e)), r || a((e) => n.modifyScript(e)), r ? (
|
|
30
|
+
return a((e) => n.modifyModuleScript(e)), r || a((e) => n.modifyScript(e)), r ? (f.writeFileSync(e, n.toString(), "utf8"), {
|
|
31
31
|
status: "success",
|
|
32
32
|
changed: !0
|
|
33
33
|
}) : {
|
|
@@ -37,42 +37,42 @@ function h(e) {
|
|
|
37
37
|
}
|
|
38
38
|
//#endregion
|
|
39
39
|
//#region src/patterns/disable/payments/modifies/modify-user-signup.ts
|
|
40
|
-
var
|
|
41
|
-
function
|
|
42
|
-
if (!
|
|
40
|
+
var v = /* @__PURE__ */ new Set(["linkStripeCustomer.run", "linkStripeCustomer"]);
|
|
41
|
+
function y(t) {
|
|
42
|
+
if (!f.existsSync(t)) return {
|
|
43
43
|
status: "success",
|
|
44
44
|
changed: !1
|
|
45
45
|
};
|
|
46
|
-
let n =
|
|
46
|
+
let n = f.readFileSync(t, "utf8");
|
|
47
47
|
if (!n.includes("linkStripeCustomer")) return {
|
|
48
48
|
status: "success",
|
|
49
49
|
changed: !1
|
|
50
50
|
};
|
|
51
|
-
let r = new
|
|
51
|
+
let r = new m({ manipulationSettings: { quoteKind: h.Single } }).addSourceFileAtPath(t);
|
|
52
52
|
for (let t of ["workflows/link-stripe-customer", "stripe"]) {
|
|
53
53
|
let n = r.getImportDeclarations().find((n) => e(n.getModuleSpecifierValue(), t));
|
|
54
54
|
n && n.remove();
|
|
55
55
|
}
|
|
56
56
|
let i = r.getVariableStatement((e) => e.getDeclarations().some((e) => e.getName() === "linkStripeCustomer"));
|
|
57
57
|
i && i.remove();
|
|
58
|
-
let
|
|
59
|
-
for (let e of
|
|
60
|
-
let t = e.getFirstAncestorByKind(
|
|
61
|
-
t && t
|
|
58
|
+
let c = r.getDescendantsOfKind(g.CallExpression).filter((e) => v.has(e.getExpression().getText()));
|
|
59
|
+
for (let e of c) {
|
|
60
|
+
let t = e.getFirstAncestorByKind(g.ExpressionStatement);
|
|
61
|
+
t && a(r, t);
|
|
62
62
|
}
|
|
63
|
-
return
|
|
63
|
+
return s(r), o(r), r.saveSync(), {
|
|
64
64
|
status: "success",
|
|
65
65
|
changed: r.getFullText() !== n
|
|
66
66
|
};
|
|
67
67
|
}
|
|
68
68
|
//#endregion
|
|
69
69
|
//#region src/patterns/disable/payments/generate.runtime.ts
|
|
70
|
-
async function
|
|
71
|
-
let i = e.features.auth, a = t(e),
|
|
72
|
-
e &&
|
|
70
|
+
async function b(e) {
|
|
71
|
+
let i = e.features.auth, a = t(e), o = [], s = [], u = (e) => {
|
|
72
|
+
e && o.push(e);
|
|
73
73
|
};
|
|
74
74
|
a.info("Stripping Stripe credentials from .env");
|
|
75
|
-
let
|
|
75
|
+
let f = [
|
|
76
76
|
{
|
|
77
77
|
type: "comment",
|
|
78
78
|
key: "Stripe credentials"
|
|
@@ -89,20 +89,20 @@ async function v(e) {
|
|
|
89
89
|
type: "var",
|
|
90
90
|
key: "STRIPE_WEBHOOK_SECRET"
|
|
91
91
|
}
|
|
92
|
-
], m =
|
|
93
|
-
|
|
94
|
-
let
|
|
95
|
-
if (
|
|
92
|
+
], m = p.join(e.root, ".env");
|
|
93
|
+
u(c(m, r(m, f))), a.info("Removing Stripe variables from src/env.ts");
|
|
94
|
+
let h = l(e.root, d);
|
|
95
|
+
if (u(h.modify), h.delete && s.push(h.delete), i) {
|
|
96
96
|
a.info("Reverting nav-user.svelte");
|
|
97
|
-
let t =
|
|
98
|
-
|
|
99
|
-
let n =
|
|
100
|
-
|
|
97
|
+
let t = p.join(e.root, "src", "lib", "components", "nav-user.svelte");
|
|
98
|
+
u(c(t, _(t))), a.info("Reverting signup +page.server.ts");
|
|
99
|
+
let n = p.join(e.root, "src", "routes", "(public)", "(auth)", "signup", "+page.server.ts");
|
|
100
|
+
u(c(n, y(n)));
|
|
101
101
|
}
|
|
102
102
|
return {
|
|
103
103
|
creates: [],
|
|
104
|
-
modifies:
|
|
105
|
-
deletes:
|
|
104
|
+
modifies: o,
|
|
105
|
+
deletes: s,
|
|
106
106
|
components: [],
|
|
107
107
|
packages: [],
|
|
108
108
|
collections: [],
|
|
@@ -117,6 +117,6 @@ async function v(e) {
|
|
|
117
117
|
};
|
|
118
118
|
}
|
|
119
119
|
//#endregion
|
|
120
|
-
export {
|
|
120
|
+
export { b as generate };
|
|
121
121
|
|
|
122
|
-
//# sourceMappingURL=generate.runtime-
|
|
122
|
+
//# sourceMappingURL=generate.runtime-EQnytCFL.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.runtime-EQnytCFL.js","names":["isLibSpecifier","getLogger","planDropsForCollections","modifyEnvRemove","removeNavItemFromScript","removeStatementWithComments","ensureBlankLineAfterImports","formatLikeSource","SvelteFile","STRIPE_ENV_VAR_NAMES","fs","path","unmodifyNavUser","navUserPath","source","file","wasRemoved","tryRemove","run","result","src","fn","CALL_EXPRESSIONS","unmodifyUserSignup","userSignupPath","originalSource","sourceFile","Project","QuoteKind","module","decl","d","linkFn","s","callStatements","SyntaxKind","ce","call","stmt","generate","isAppMode","options","logger","modifies","deletes","pushResult","envEdits","envPath","modifyOutcomeToFile","envVars","unmodifyEnvVarsFiles"],"sources":["../../src/patterns/disable/payments/modifies/modify-nav-user.ts","../../src/patterns/disable/payments/modifies/modify-user-signup.ts","../../src/patterns/disable/payments/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport { removeNavItemFromScript } from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nexport function unmodifyNavUser(navUserPath: string): ModifyOutcome {\n if (!fs.existsSync(navUserPath)) {\n return { status: \"success\", changed: false };\n }\n\n const source = fs.readFileSync(navUserPath, \"utf8\");\n if (!source.includes(\"/billing\")) {\n return { status: \"success\", changed: false };\n }\n\n const file = new SvelteFile(source);\n let wasRemoved = false;\n\n const tryRemove = (run: (fn: (s: string) => string) => boolean) => {\n if (wasRemoved) return;\n run((src) => {\n const result = removeNavItemFromScript(\n src,\n \"Billing\",\n \"@lucide/svelte/icons/credit-card\",\n );\n if (result.wasRemoved) wasRemoved = true;\n return result.source;\n });\n };\n\n tryRemove((fn) => file.modifyModuleScript(fn));\n if (!wasRemoved) tryRemove((fn) => file.modifyScript(fn));\n\n if (!wasRemoved) {\n return { status: \"success\", changed: false };\n }\n\n fs.writeFileSync(navUserPath, file.toString(), \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport { Project, QuoteKind, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport {\n ensureBlankLineAfterImports,\n formatLikeSource,\n removeStatementWithComments,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport { isLibSpecifier } from \"../../../../runtime/lib-specifier\";\n\nconst CALL_EXPRESSIONS = new Set([\n \"linkStripeCustomer.run\",\n // Projects from before the workflow: an inline helper called directly.\n \"linkStripeCustomer\",\n]);\n\nexport function unmodifyUserSignup(userSignupPath: string): ModifyOutcome {\n if (!fs.existsSync(userSignupPath)) {\n return { status: \"success\", changed: false };\n }\n\n const originalSource = fs.readFileSync(userSignupPath, \"utf8\");\n if (!originalSource.includes(\"linkStripeCustomer\")) {\n return { status: \"success\", changed: false };\n }\n\n const project = new Project({\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(userSignupPath);\n\n for (const module of [\"workflows/link-stripe-customer\", \"stripe\"]) {\n const decl = sourceFile\n .getImportDeclarations()\n .find((d) => isLibSpecifier(d.getModuleSpecifierValue(), module));\n if (decl) decl.remove();\n }\n\n const linkFn = sourceFile.getVariableStatement((s) =>\n s.getDeclarations().some((d) => d.getName() === \"linkStripeCustomer\"),\n );\n if (linkFn) linkFn.remove();\n\n const callStatements = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .filter((ce) => CALL_EXPRESSIONS.has(ce.getExpression().getText()));\n for (const call of callStatements) {\n const stmt = call.getFirstAncestorByKind(SyntaxKind.ExpressionStatement);\n // With the two comment lines enable-payments put above it: left behind,\n // they keep the file from matching the stock signup, and enable-whatsapp\n // then refuses to swap it.\n if (stmt) removeStatementWithComments(sourceFile, stmt);\n }\n\n formatLikeSource(sourceFile);\n ensureBlankLineAfterImports(sourceFile);\n sourceFile.saveSync();\n\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\n };\n}\n","import path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { modifyEnvRemove, type EnvEdit } from \"../../../runtime/env\";\nimport { unmodifyEnvVarsFiles } from \"../../../runtime/env-vars\";\nimport { STRIPE_ENV_VAR_NAMES } from \"../../enable/payments/runtime/env-vars\";\nimport { unmodifyNavUser } from \"./modifies/modify-nav-user\";\nimport { unmodifyUserSignup } from \"./modifies/modify-user-signup\";\nimport { planDropsForCollections } from \"../../destroy/shared\";\n\nexport async function generate(options: Options) {\n const isAppMode = options.features.auth;\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(\"Stripping Stripe credentials from .env\");\n const envEdits: EnvEdit[] = [\n { type: \"comment\", key: \"Stripe credentials\" },\n { type: \"var\", key: \"STRIPE_SECRET_KEY\" },\n { type: \"var\", key: \"PUBLIC_STRIPE_PUBLISHABLE_KEY\" },\n { type: \"var\", key: \"STRIPE_WEBHOOK_SECRET\" },\n ];\n const envPath = path.join(options.root, \".env\");\n pushResult(modifyOutcomeToFile(envPath, modifyEnvRemove(envPath, envEdits)));\n\n logger.info(\"Removing Stripe variables from src/env.ts\");\n const envVars = unmodifyEnvVarsFiles(options.root, STRIPE_ENV_VAR_NAMES);\n pushResult(envVars.modify);\n if (envVars.delete) deletes.push(envVars.delete);\n\n if (isAppMode) {\n logger.info(\"Reverting nav-user.svelte\");\n const navUserPath = path.join(\n options.root,\n \"src\",\n \"lib\",\n \"components\",\n \"nav-user.svelte\",\n );\n pushResult(modifyOutcomeToFile(navUserPath, unmodifyNavUser(navUserPath)));\n\n logger.info(\"Reverting signup +page.server.ts\");\n const userSignupPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(public)\",\n \"(auth)\",\n \"signup\",\n \"+page.server.ts\",\n );\n pushResult(\n modifyOutcomeToFile(userSignupPath, unmodifyUserSignup(userSignupPath)),\n );\n }\n\n const collectionNames = [\n \"transactions\",\n \"stripe_customers\",\n \"stripe_payment_methods\",\n \"stripe_prices\",\n \"stripe_products\",\n ];\n const collectionDrops = await planDropsForCollections(\n isAppMode ? collectionNames : [\"stripe_prices\", \"stripe_products\"],\n options,\n );\n\n return {\n creates: [],\n modifies,\n deletes,\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops,\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;;;;;;AAKA,SAAgBY,EAAgB,GAAoC;CAClE,IAAI,CAACF,EAAG,WAAWG,CAAW,GAC5B,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAMC,IAASJ,EAAG,aAAaG,GAAa,MAAM;CAClD,IAAI,CAACC,EAAO,SAAS,UAAU,GAC7B,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAMC,IAAO,IAAIP,EAAWM,CAAM,GAC9BE,IAAa,IAEXC,KAAa,MAAgD;EACjE,AAAID,KACJE,GAAK,MAAQ;GACX,IAAMC,IAASf,EACbgB,GACA,WACA,kCACF;GAEA,OADID,EAAO,eAAY,IAAa,KAC7BA,EAAO;EAChB,CAAC;CACH;CAUA,OARAF,GAAW,MAAOF,EAAK,mBAAmBM,CAAE,CAAC,GACxCL,KAAYC,GAAW,MAAOF,EAAK,aAAaM,CAAE,CAAC,GAEnDL,KAILN,EAAG,cAAcG,GAAaE,EAAK,SAAS,GAAG,MAAM,GAC9C;EAAE,QAAQ;EAAW,SAAS;CAAK,KAJjC;EAAE,QAAQ;EAAW,SAAS;CAAM;AAK/C;;;AC9BA,IAAMO,oBAAmB,IAAI,IAAI,CAC/B,0BAEA,oBACF,CAAC;AAED,SAAgBC,EAAmB,GAAuC;CACxE,IAAI,CAACb,EAAG,WAAWc,CAAc,GAC/B,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAMC,IAAiBf,EAAG,aAAac,GAAgB,MAAM;CAC7D,IAAI,CAACC,EAAe,SAAS,oBAAoB,GAC/C,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAM7C,IAAMC,IAAa,IAHCC,EAAQ,EAC1B,sBAAs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GACMC,IAAUpC,EAAK,KAAK8B,EAAQ,MAAM,MAAM;CAG9C,AAFAI,EAAWG,EAAoBD,GAAS5C,EAAgB4C,GAASD,CAAQ,CAAC,CAAC,GAE3EJ,EAAO,KAAK,2CAA2C;CACvD,IAAMO,IAAUC,EAAqBT,EAAQ,MAAMhC,CAAoB;CAIvE,IAHAoC,EAAWI,EAAQ,MAAM,GACrBA,EAAQ,UAAQL,EAAQ,KAAKK,EAAQ,MAAM,GAE3CT,GAAW;EACb,EAAO,KAAK,2BAA2B;EACvC,IAAM3B,IAAcF,EAAK,KACvB8B,EAAQ,MACR,OACA,OACA,cACA,iBACF;EAGA,AAFAI,EAAWG,EAAoBnC,GAAaD,EAAgBC,CAAW,CAAC,CAAC,GAEzE6B,EAAO,KAAK,kCAAkC;EAC9C,IAAMlB,IAAiBb,EAAK,KAC1B8B,EAAQ,MACR,OACA,UACA,YACA,UACA,UACA,iBACF;EACA,EACEO,EAAoBxB,GAAgBD,EAAmBC,CAAc,CAAC,CACxE;CACF;CAcA,OAAO;EACL,SAAS,CAAC;EACV;EACA;EACA,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAA,MAb4BtB,EAC5BsC,IAAY;GAPZ;GACA;GACA;GACA;GACA;EAGY,IAAkB,CAAC,iBAAiB,iBAAiB,GACjEC,CACF;CAWA;AACF"}
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import { n as e } from "./logger-CQONztPm.js";
|
|
2
|
+
import { n as t, t as n } from "./_page-e_I-fdSR.js";
|
|
3
|
+
import { t as r } from "./shared-Cc_ns5-y.js";
|
|
4
|
+
import { _ as i, h as a, o, u as s } from "./ts-morph-helpers-Bepc-Es2.js";
|
|
5
|
+
import { modifyOutcomeToFile as c } from "./modify-file-DK-tCH9k.js";
|
|
6
|
+
import { t as l } from "./svelte-file-B3RfgVdt.js";
|
|
7
|
+
import { t as u } from "./unmodify-load-Bl5vXQiL.js";
|
|
8
|
+
import { r as d, t as f } from "./modify-nav-user-BLyrW2sK.js";
|
|
9
|
+
import p from "node:fs";
|
|
10
|
+
import m from "node:path";
|
|
11
|
+
import { Project as h, QuoteKind as g, SyntaxKind as _ } from "ts-morph";
|
|
12
|
+
//#region src/patterns/disable/subscriptions/modifies/modify-webhook-server.ts
|
|
13
|
+
var v = /* @__PURE__ */ new Set([
|
|
14
|
+
"customer.subscription.created",
|
|
15
|
+
"customer.subscription.updated",
|
|
16
|
+
"customer.subscription.deleted"
|
|
17
|
+
]);
|
|
18
|
+
function y(e) {
|
|
19
|
+
if (!p.existsSync(e)) return {
|
|
20
|
+
status: "success",
|
|
21
|
+
changed: !1
|
|
22
|
+
};
|
|
23
|
+
let t = p.readFileSync(e, "utf8");
|
|
24
|
+
if (!t.includes("handleSubscriptionCreated")) return {
|
|
25
|
+
status: "success",
|
|
26
|
+
changed: !1
|
|
27
|
+
};
|
|
28
|
+
let { source: n } = i(t, (e) => {
|
|
29
|
+
s(e, "./subscription/created"), s(e, "./subscription/updated"), s(e, "./subscription/deleted");
|
|
30
|
+
let t = e.getDescendantsOfKind(_.SwitchStatement).find((e) => e.getExpression().getText().includes("event.type"));
|
|
31
|
+
if (!t) return;
|
|
32
|
+
let n = t.getCaseBlock().getClauses().filter((e) => {
|
|
33
|
+
if (e.getKind() !== _.CaseClause) return !1;
|
|
34
|
+
let t = e.asKindOrThrow(_.CaseClause).getExpression(), n = t.asKind(_.StringLiteral) ?? t.asKind(_.NoSubstitutionTemplateLiteral);
|
|
35
|
+
return n ? v.has(n.getLiteralValue()) : !1;
|
|
36
|
+
}).map((e) => e.asKindOrThrow(_.CaseClause));
|
|
37
|
+
for (let e of n.reverse()) e.remove();
|
|
38
|
+
o(e);
|
|
39
|
+
}), r = n.replace(/(break;)\n(\s*default:)/, "$1\n\n$2");
|
|
40
|
+
return r === t ? {
|
|
41
|
+
status: "success",
|
|
42
|
+
changed: !1
|
|
43
|
+
} : (p.writeFileSync(e, r, "utf8"), {
|
|
44
|
+
status: "success",
|
|
45
|
+
changed: !0
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region src/patterns/disable/subscriptions/modifies/modify-app-layout-svelte.ts
|
|
50
|
+
function b(e) {
|
|
51
|
+
if (!p.existsSync(e)) return {
|
|
52
|
+
status: "success",
|
|
53
|
+
changed: !1
|
|
54
|
+
};
|
|
55
|
+
let t = l.fromPath(e);
|
|
56
|
+
return !t.hasElement("AppSidebar") || !t.hasAttribute("AppSidebar", "subscription") || !t.removeAttribute("AppSidebar", "subscription") ? {
|
|
57
|
+
status: "success",
|
|
58
|
+
changed: !1
|
|
59
|
+
} : (t.writeTo(e), {
|
|
60
|
+
status: "success",
|
|
61
|
+
changed: t.hasChanged()
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
//#endregion
|
|
65
|
+
//#region src/patterns/disable/subscriptions/modifies/modify-app-sidebar.ts
|
|
66
|
+
function x(e) {
|
|
67
|
+
let { source: t } = i(e, (e) => {
|
|
68
|
+
for (let t of e.getVariableDeclarations()) {
|
|
69
|
+
let e = t.getInitializer();
|
|
70
|
+
if (!e || e.getText() !== "$props()") continue;
|
|
71
|
+
let n = t.getNameNode();
|
|
72
|
+
if (n.getKind() !== _.ObjectBindingPattern) continue;
|
|
73
|
+
let r = n.asKindOrThrow(_.ObjectBindingPattern), i = r.getElements(), a = i.some((e) => e.getName() === "subscription"), o = t.getTypeNode();
|
|
74
|
+
if (o?.getKind() === _.IntersectionType) {
|
|
75
|
+
let e = o.asKindOrThrow(_.IntersectionType);
|
|
76
|
+
for (let t of e.getTypeNodes()) {
|
|
77
|
+
if (t.getKind() !== _.TypeLiteral) continue;
|
|
78
|
+
let e = t.asKindOrThrow(_.TypeLiteral), n = e.getProperties().map((e) => e.getText().replace(/[;,]\s*$/, "")).filter((e) => !/^\s*subscription\??\s*:/.test(e));
|
|
79
|
+
e.replaceWithText(n.length ? `{ ${n.join("; ")}; }` : "{}");
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (a) {
|
|
84
|
+
let e = i.filter((e) => e.getName() !== "subscription").map((e) => e.getText());
|
|
85
|
+
r.replaceWithText(`{ ${e.join(", ")} }`);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
o(e);
|
|
89
|
+
});
|
|
90
|
+
return t;
|
|
91
|
+
}
|
|
92
|
+
function S(e) {
|
|
93
|
+
if (!p.existsSync(e)) return {
|
|
94
|
+
status: "success",
|
|
95
|
+
changed: !1
|
|
96
|
+
};
|
|
97
|
+
let t = p.readFileSync(e, "utf8"), n = /subscription\??\s*:\s*\{/.test(t), r = /\bsubscription\s*=\s*null\b/.test(t), i = new l(t), a = i.hasElement("NavUser") && i.hasAttribute("NavUser", "subscription");
|
|
98
|
+
return !n && !r && !a ? {
|
|
99
|
+
status: "success",
|
|
100
|
+
changed: !1
|
|
101
|
+
} : ((n || r) && i.modifyScript(x), a && i.removeAttribute("NavUser", "subscription"), i.writeTo(e), {
|
|
102
|
+
status: "success",
|
|
103
|
+
changed: i.hasChanged()
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
//#endregion
|
|
107
|
+
//#region src/patterns/disable/subscriptions/modifies/modify-app-layout-server.ts
|
|
108
|
+
function C(e) {
|
|
109
|
+
if (!p.existsSync(e)) return {
|
|
110
|
+
status: "success",
|
|
111
|
+
changed: !1
|
|
112
|
+
};
|
|
113
|
+
let t = p.readFileSync(e, "utf8");
|
|
114
|
+
if (!t.includes("loadActiveSubscription")) return {
|
|
115
|
+
status: "success",
|
|
116
|
+
changed: !1
|
|
117
|
+
};
|
|
118
|
+
let n = u(e, {
|
|
119
|
+
variables: ["subscription"],
|
|
120
|
+
dependsKeys: [],
|
|
121
|
+
returnProps: ["subscription"]
|
|
122
|
+
});
|
|
123
|
+
if (n.status !== "success") return n;
|
|
124
|
+
let r = new h({ manipulationSettings: { quoteKind: g.Single } }).addSourceFileAtPath(e);
|
|
125
|
+
return a(r, "loadActiveSubscription"), o(r), r.saveSync(), {
|
|
126
|
+
status: "success",
|
|
127
|
+
changed: p.readFileSync(e, "utf8") !== t
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
//#endregion
|
|
131
|
+
//#region src/patterns/disable/subscriptions/modifies/modify-nav-user.ts
|
|
132
|
+
function w(e) {
|
|
133
|
+
if (!p.existsSync(e)) return {
|
|
134
|
+
status: "success",
|
|
135
|
+
changed: !1
|
|
136
|
+
};
|
|
137
|
+
let t = p.readFileSync(e, "utf8");
|
|
138
|
+
if (!t.includes("planLabel")) return {
|
|
139
|
+
status: "success",
|
|
140
|
+
changed: !1
|
|
141
|
+
};
|
|
142
|
+
let n = new l(t);
|
|
143
|
+
n.modifyScript((e) => i(e.replace(/\n[ \t]*\n[ \t]*const planLabel = \$derived\([^\n]*\);/, ""), (e) => {
|
|
144
|
+
let t = d(e)?.getDeclarations()[0], n = t?.getNameNode().asKind(_.ObjectBindingPattern), r = n?.getElements().filter((e) => e.getName() !== "subscription").map((e) => e.getText());
|
|
145
|
+
n && r && n.replaceWithText(f(n.getText(), r)), t?.getTypeNode()?.asKind(_.TypeLiteral)?.getProperty("subscription")?.remove();
|
|
146
|
+
}).source);
|
|
147
|
+
let r = n.toString().replace(/\n[ \t]*<span class="[^"]*">\s*\{planLabel\}\s*<\/span>/g, "");
|
|
148
|
+
return p.writeFileSync(e, r, "utf8"), {
|
|
149
|
+
status: "success",
|
|
150
|
+
changed: r !== t
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
//#endregion
|
|
154
|
+
//#region src/patterns/disable/subscriptions/modifies/revert-by-template.ts
|
|
155
|
+
function T(e, t, n) {
|
|
156
|
+
if (!p.existsSync(e)) return {
|
|
157
|
+
status: "success",
|
|
158
|
+
changed: !1
|
|
159
|
+
};
|
|
160
|
+
let r = p.readFileSync(e, "utf8");
|
|
161
|
+
if (!r.includes(n)) return {
|
|
162
|
+
status: "success",
|
|
163
|
+
changed: !1
|
|
164
|
+
};
|
|
165
|
+
let i = t.replace(/^[ \t]*\/\/[ \t]*\[!code highlight:\d+\][ \t]*\r?\n/gm, "").replace(/^[ \t]*<!--[ \t]*\[!code highlight:\d+\][ \t]*-->[ \t]*\r?\n/gm, "");
|
|
166
|
+
return r === i ? {
|
|
167
|
+
status: "success",
|
|
168
|
+
changed: !1
|
|
169
|
+
} : (p.writeFileSync(e, i, "utf8"), {
|
|
170
|
+
status: "success",
|
|
171
|
+
changed: !0
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
//#endregion
|
|
175
|
+
//#region src/patterns/disable/subscriptions/modifies/modify-billing-page-server.ts
|
|
176
|
+
function E(e, t) {
|
|
177
|
+
return T(e, t, "selectPlan");
|
|
178
|
+
}
|
|
179
|
+
//#endregion
|
|
180
|
+
//#region src/patterns/disable/subscriptions/modifies/modify-billing-page-svelte.ts
|
|
181
|
+
function D(e, t) {
|
|
182
|
+
return T(e, t, "availablePlans");
|
|
183
|
+
}
|
|
184
|
+
//#endregion
|
|
185
|
+
//#region src/patterns/disable/subscriptions/generate.runtime.ts
|
|
186
|
+
async function O(i) {
|
|
187
|
+
let a = e(i), o = [], s = (e) => {
|
|
188
|
+
e && o.push(e);
|
|
189
|
+
};
|
|
190
|
+
a.info("Reverting webhooks/stripe/handlers/dispatch.ts");
|
|
191
|
+
let l = m.join(i.root, "src", "routes", "webhooks", "stripe", "handlers", "dispatch.ts");
|
|
192
|
+
s(c(l, y(l))), a.info("Reverting (app)/+layout.server.ts");
|
|
193
|
+
let u = m.join(i.root, "src", "routes", "(app)", "+layout.server.ts");
|
|
194
|
+
s(c(u, C(u))), a.info("Reverting (app)/+layout.svelte");
|
|
195
|
+
let d = m.join(i.root, "src", "routes", "(app)", "+layout.svelte");
|
|
196
|
+
s(c(d, b(d))), a.info("Reverting app-sidebar.svelte");
|
|
197
|
+
let f = m.join(i.root, "src", "lib", "components", "app-sidebar.svelte");
|
|
198
|
+
s(c(f, S(f))), a.info("Reverting nav-user.svelte");
|
|
199
|
+
let p = m.join(i.root, "src", "lib", "components", "nav-user.svelte");
|
|
200
|
+
s(c(p, w(p))), a.info("Reverting billing/+page.server.ts");
|
|
201
|
+
let h = m.join(i.root, "src", "routes", "(app)", "billing", "+page.server.ts");
|
|
202
|
+
s(c(h, E(h, t))), a.info("Reverting billing/+page.svelte");
|
|
203
|
+
let g = m.join(i.root, "src", "routes", "(app)", "billing", "+page.svelte");
|
|
204
|
+
return s(c(g, D(g, n))), {
|
|
205
|
+
creates: [],
|
|
206
|
+
modifies: o,
|
|
207
|
+
deletes: [],
|
|
208
|
+
components: [],
|
|
209
|
+
packages: [],
|
|
210
|
+
collections: [],
|
|
211
|
+
collectionPatches: [],
|
|
212
|
+
collectionDrops: await r(["stripe_subscriptions"], i)
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
//#endregion
|
|
216
|
+
export { O as generate };
|
|
217
|
+
|
|
218
|
+
//# sourceMappingURL=generate.runtime-IWEhGhWY.js.map
|