@velastack/patterns 0.15.2 → 0.15.4
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/_page-CFeYIl2d.js +5 -0
- package/dist/chunks/_page-CFeYIl2d.js.map +1 -0
- package/dist/chunks/_page-CiazQY4O.js +5 -0
- package/dist/chunks/{_page-BFUn0CG1.js.map → _page-CiazQY4O.js.map} +1 -1
- package/dist/chunks/{auth-pages-D8n8gfCL.js → auth-pages-B8H3kQPW.js} +2 -2
- package/dist/chunks/{auth-pages-D8n8gfCL.js.map → auth-pages-B8H3kQPW.js.map} +1 -1
- package/dist/chunks/{collections-Daxlnbm0.js → collections-CFTIAty-.js} +2 -2
- package/dist/chunks/{collections-Daxlnbm0.js.map → collections-CFTIAty-.js.map} +1 -1
- package/dist/chunks/{currency.server-BkzwY17R.js → currency.server-CHzEhyTx.js} +74 -74
- package/dist/chunks/currency.server-CHzEhyTx.js.map +1 -0
- package/dist/chunks/dispatch-DSkRrJFe.js +5 -0
- package/dist/chunks/{dispatch-BxlKS_5v.js.map → dispatch-DSkRrJFe.js.map} +1 -1
- package/dist/chunks/{env-vars-C3TSZc4f.js → env-vars--fyhY-ew.js} +3 -3
- package/dist/chunks/{env-vars-C3TSZc4f.js.map → env-vars--fyhY-ew.js.map} +1 -1
- package/dist/chunks/{generate-CbchamhA.js → generate-B2z0kA5C.js} +2 -2
- package/dist/chunks/{generate-CbchamhA.js.map → generate-B2z0kA5C.js.map} +1 -1
- package/dist/chunks/{generate-CAYM7OUF.js → generate-BSCDKlyL.js} +2 -2
- package/dist/chunks/{generate-CAYM7OUF.js.map → generate-BSCDKlyL.js.map} +1 -1
- package/dist/chunks/{generate-DI58vuk1.js → generate-DZ2S8KDR.js} +3 -3
- package/dist/chunks/{generate-DI58vuk1.js.map → generate-DZ2S8KDR.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CZMVPVjS.js → generate.runtime-2T2j6Cgc.js} +5 -5
- package/dist/chunks/{generate.runtime-CZMVPVjS.js.map → generate.runtime-2T2j6Cgc.js.map} +1 -1
- package/dist/chunks/{generate.runtime-_426A1Ij.js → generate.runtime-7rRHLyjy.js} +3 -3
- package/dist/chunks/{generate.runtime-_426A1Ij.js.map → generate.runtime-7rRHLyjy.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Bo_s7gYB.js → generate.runtime-9wfx5sJK.js} +2 -2
- package/dist/chunks/{generate.runtime-Bo_s7gYB.js.map → generate.runtime-9wfx5sJK.js.map} +1 -1
- package/dist/chunks/{generate.runtime-B7VubPTW.js → generate.runtime-B6Tce286.js} +3 -3
- package/dist/chunks/{generate.runtime-B7VubPTW.js.map → generate.runtime-B6Tce286.js.map} +1 -1
- package/dist/chunks/{generate.runtime-B11mOr45.js → generate.runtime-B9nqVvxO.js} +2 -2
- package/dist/chunks/{generate.runtime-B11mOr45.js.map → generate.runtime-B9nqVvxO.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BL6DpWFI.js → generate.runtime-BCa20dNN.js} +3 -3
- package/dist/chunks/{generate.runtime-BL6DpWFI.js.map → generate.runtime-BCa20dNN.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DP63Wwea.js → generate.runtime-BFyTIABc.js} +4 -4
- package/dist/chunks/{generate.runtime-DP63Wwea.js.map → generate.runtime-BFyTIABc.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DlAJQ5Js.js → generate.runtime-B_md4EZa.js} +76 -68
- package/dist/chunks/generate.runtime-B_md4EZa.js.map +1 -0
- package/dist/chunks/{generate.runtime-BH6hHygm.js → generate.runtime-BpXoagaq.js} +76 -76
- package/dist/chunks/generate.runtime-BpXoagaq.js.map +1 -0
- package/dist/chunks/{generate.runtime-DW9bqOtC.js → generate.runtime-C1zb2WxI.js} +2 -2
- package/dist/chunks/{generate.runtime-DW9bqOtC.js.map → generate.runtime-C1zb2WxI.js.map} +1 -1
- package/dist/chunks/{generate.runtime-C3IswX7B.js → generate.runtime-C4R919oE.js} +113 -104
- package/dist/chunks/generate.runtime-C4R919oE.js.map +1 -0
- package/dist/chunks/{generate.runtime-BCv4F1Wm.js → generate.runtime-C4qZ7Q30.js} +4 -4
- package/dist/chunks/{generate.runtime-BCv4F1Wm.js.map → generate.runtime-C4qZ7Q30.js.map} +1 -1
- package/dist/chunks/{generate.runtime-C90_2L-8.js → generate.runtime-C8xFPEgP.js} +2 -2
- package/dist/chunks/{generate.runtime-C90_2L-8.js.map → generate.runtime-C8xFPEgP.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Cs73i6Zf.js → generate.runtime-CC4XoTnb.js} +2 -2
- package/dist/chunks/{generate.runtime-Cs73i6Zf.js.map → generate.runtime-CC4XoTnb.js.map} +1 -1
- package/dist/chunks/{generate.runtime-jIlQ2GMh.js → generate.runtime-CCL_doqr.js} +2 -2
- package/dist/chunks/{generate.runtime-jIlQ2GMh.js.map → generate.runtime-CCL_doqr.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BEWp57Y7.js → generate.runtime-CKyi82cZ.js} +2 -2
- package/dist/chunks/{generate.runtime-BEWp57Y7.js.map → generate.runtime-CKyi82cZ.js.map} +1 -1
- package/dist/chunks/{generate.runtime-D7KYlnvb.js → generate.runtime-CNHEuhx4.js} +4 -4
- package/dist/chunks/{generate.runtime-D7KYlnvb.js.map → generate.runtime-CNHEuhx4.js.map} +1 -1
- package/dist/chunks/{generate.runtime-JftBoKYS.js → generate.runtime-CPF0TcjM.js} +3 -3
- package/dist/chunks/{generate.runtime-JftBoKYS.js.map → generate.runtime-CPF0TcjM.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Bs77Oc8P.js → generate.runtime-CWNIo1xQ.js} +4 -4
- package/dist/chunks/{generate.runtime-Bs77Oc8P.js.map → generate.runtime-CWNIo1xQ.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CDY0Ot_t.js → generate.runtime-Cb2u0ft4.js} +5 -5
- package/dist/chunks/{generate.runtime-CDY0Ot_t.js.map → generate.runtime-Cb2u0ft4.js.map} +1 -1
- package/dist/chunks/{generate.runtime-ChSVP7cD.js → generate.runtime-CdpLsiqC.js} +4 -4
- package/dist/chunks/{generate.runtime-ChSVP7cD.js.map → generate.runtime-CdpLsiqC.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CdZ3GzPS.js → generate.runtime-ChstrVRw.js} +6 -6
- package/dist/chunks/{generate.runtime-CdZ3GzPS.js.map → generate.runtime-ChstrVRw.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Bhs7ttZS.js → generate.runtime-CpDUk3Ev.js} +2 -2
- package/dist/chunks/{generate.runtime-Bhs7ttZS.js.map → generate.runtime-CpDUk3Ev.js.map} +1 -1
- package/dist/chunks/{generate.runtime-xrxAElb3.js → generate.runtime-Ctd_522e.js} +3 -3
- package/dist/chunks/{generate.runtime-xrxAElb3.js.map → generate.runtime-Ctd_522e.js.map} +1 -1
- package/dist/chunks/{generate.runtime-B1Y2JrGW.js → generate.runtime-CviYhOWW.js} +202 -117
- package/dist/chunks/generate.runtime-CviYhOWW.js.map +1 -0
- package/dist/chunks/{generate.runtime-BRV9hIl5.js → generate.runtime-CxJaHusI.js} +2 -2
- package/dist/chunks/{generate.runtime-BRV9hIl5.js.map → generate.runtime-CxJaHusI.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DRPxOLnB.js → generate.runtime-D0acTMRF.js} +4 -4
- package/dist/chunks/{generate.runtime-DRPxOLnB.js.map → generate.runtime-D0acTMRF.js.map} +1 -1
- package/dist/chunks/{generate.runtime-fs6GEMx-.js → generate.runtime-D6vRzBoU.js} +4 -4
- package/dist/chunks/{generate.runtime-fs6GEMx-.js.map → generate.runtime-D6vRzBoU.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BRcP6sFt.js → generate.runtime-D7aGjoTD.js} +2 -2
- package/dist/chunks/{generate.runtime-BRcP6sFt.js.map → generate.runtime-D7aGjoTD.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DG9LRwbt.js → generate.runtime-DPtjvhGr.js} +2 -2
- package/dist/chunks/{generate.runtime-DG9LRwbt.js.map → generate.runtime-DPtjvhGr.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BjrtdoYE.js → generate.runtime-DmHZZz4Z.js} +2 -2
- package/dist/chunks/{generate.runtime-BjrtdoYE.js.map → generate.runtime-DmHZZz4Z.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DdY44Ulv.js → generate.runtime-O5eQdhHV.js} +4 -4
- package/dist/chunks/{generate.runtime-DdY44Ulv.js.map → generate.runtime-O5eQdhHV.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DKL7VAAd.js → generate.runtime-Uq_L7TtO.js} +5 -5
- package/dist/chunks/{generate.runtime-DKL7VAAd.js.map → generate.runtime-Uq_L7TtO.js.map} +1 -1
- package/dist/chunks/{generate.runtime-C_hrLPD4.js → generate.runtime-VWQfzXXv.js} +3 -3
- package/dist/chunks/{generate.runtime-C_hrLPD4.js.map → generate.runtime-VWQfzXXv.js.map} +1 -1
- package/dist/chunks/{generate.runtime-v3KCv1B6.js → generate.runtime-WL1mm8gp.js} +2 -2
- package/dist/chunks/{generate.runtime-v3KCv1B6.js.map → generate.runtime-WL1mm8gp.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DjEj-n6m.js → generate.runtime-vJFz9Q7V.js} +8 -8
- package/dist/chunks/{generate.runtime-DjEj-n6m.js.map → generate.runtime-vJFz9Q7V.js.map} +1 -1
- package/dist/chunks/{gitignore-CBiWFRif.js → gitignore-DUzIQXIo.js} +2 -2
- package/dist/chunks/{gitignore-CBiWFRif.js.map → gitignore-DUzIQXIo.js.map} +1 -1
- package/dist/chunks/{i18n-Ho8H91Ze.js → i18n-BoYcqVBi.js} +2 -2
- package/dist/chunks/{i18n-Ho8H91Ze.js.map → i18n-BoYcqVBi.js.map} +1 -1
- package/dist/chunks/{modify-file-BOEKlIDw.js → modify-file-DRdmZIvW.js} +2 -2
- package/dist/chunks/{modify-file-BOEKlIDw.js.map → modify-file-DRdmZIvW.js.map} +1 -1
- package/dist/chunks/{pocketbase-CvsJYXj-.js → pocketbase-BrDs1_84.js} +23 -7
- package/dist/chunks/pocketbase-BrDs1_84.js.map +1 -0
- package/dist/chunks/{providers-BEjDonyG.js → providers-Dhr_mzm6.js} +2 -2
- package/dist/chunks/{providers-BEjDonyG.js.map → providers-Dhr_mzm6.js.map} +1 -1
- package/dist/chunks/{schema-DnMqw2Hn.js → schema-C16iVOAG.js} +2 -2
- package/dist/chunks/{schema-DnMqw2Hn.js.map → schema-C16iVOAG.js.map} +1 -1
- package/dist/chunks/{shared-CSwGWMcN.js → shared-D7-ZAoqr.js} +2 -2
- package/dist/chunks/{shared-CSwGWMcN.js.map → shared-D7-ZAoqr.js.map} +1 -1
- package/dist/chunks/{ui-CpjUq_lm.js → ui-BI9OQpuR.js} +2 -2
- package/dist/chunks/{ui-CpjUq_lm.js.map → ui-BI9OQpuR.js.map} +1 -1
- package/dist/chunks/{unmodify-load-CdWXJ_Ac.js → unmodify-load-DWixBz7y.js} +17 -4
- package/dist/chunks/unmodify-load-DWixBz7y.js.map +1 -0
- package/dist/chunks/{write-result-DlB-id5k.js → write-result-Do8AcYbL.js} +2 -2
- package/dist/chunks/{write-result-DlB-id5k.js.map → write-result-Do8AcYbL.js.map} +1 -1
- package/dist/index.js +1700 -1681
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunks/_page-BFUn0CG1.js +0 -5
- package/dist/chunks/_page-Bt37d4uo.js +0 -5
- package/dist/chunks/_page-Bt37d4uo.js.map +0 -1
- package/dist/chunks/currency.server-BkzwY17R.js.map +0 -1
- package/dist/chunks/dispatch-BxlKS_5v.js +0 -5
- package/dist/chunks/generate.runtime-B1Y2JrGW.js.map +0 -1
- package/dist/chunks/generate.runtime-BH6hHygm.js.map +0 -1
- package/dist/chunks/generate.runtime-C3IswX7B.js.map +0 -1
- package/dist/chunks/generate.runtime-DlAJQ5Js.js.map +0 -1
- package/dist/chunks/pocketbase-CvsJYXj-.js.map +0 -1
- package/dist/chunks/unmodify-load-CdWXJ_Ac.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.runtime-BpXoagaq.js","names":["paymentsBillingPageServerTemplate","paymentsBillingPageSvelteTemplate","getLogger","modifyOutcomeToFile","planDropsForCollections","withInMemoryScript","removeTopLevelStatementByIdentifier","ensureBlankLineAfterImports","removeImportByModuleSpecifier","SvelteFile","removeFromLoad","propsStatement","bindingText","_page_server_default","_page_default","fs","path","SUBSCRIPTION_CASE_VALUES","unmodifyWebhookServer","filePath","original","sf","switchStmt","SyntaxKind","stmt","toRemove","clause","expr","literal","c","spaced","source","unmodifyAppLayoutSvelte","file","updateScript","out","decl","init","nameNode","pattern","elements","hasSub","typeNode","intersection","member","lit","propTexts","p","t","remaining","unmodifyAppSidebar","hasSubPropType","hasSubProp","hasNavUserSubAttr","unmodifyAppLayoutServer","fromLoad","Project","QuoteKind","formatLikeSource","unmodifyNavUser","content","binding","kept","revertByTemplate","current","enabledMarker","stripped","template","unmodifyBillingPageServer","paymentsBillingPageServerTemplate","unmodifyBillingPageSvelte","paymentsBillingPageSvelteTemplate","generate","logger","options","modifies","pushResult","webhookServerPath","appLayoutServerPath","appLayoutSveltePath","appSidebarPath","navUserPath","billingPageServerPath","billingPageSveltePath"],"sources":["../../src/patterns/disable/subscriptions/modifies/modify-webhook-server.ts","../../src/patterns/disable/subscriptions/modifies/modify-app-layout-svelte.ts","../../src/patterns/disable/subscriptions/modifies/modify-app-sidebar.ts","../../src/patterns/disable/subscriptions/modifies/modify-app-layout-server.ts","../../src/patterns/disable/subscriptions/modifies/modify-nav-user.ts","../../src/patterns/disable/subscriptions/modifies/revert-by-template.ts","../../src/patterns/disable/subscriptions/modifies/modify-billing-page-server.ts","../../src/patterns/disable/subscriptions/modifies/modify-billing-page-svelte.ts","../../src/patterns/disable/subscriptions/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport {\n removeImportByModuleSpecifier,\n withInMemoryScript,\n formatLikeSource,\n} from \"../../../../runtime/ts-morph-helpers\";\n\nconst SUBSCRIPTION_CASE_VALUES = new Set([\n \"customer.subscription.created\",\n \"customer.subscription.updated\",\n \"customer.subscription.deleted\",\n]);\n\nexport function unmodifyWebhookServer(filePath: string): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"success\", changed: false };\n }\n const original = fs.readFileSync(filePath, \"utf8\");\n if (!original.includes(\"handleSubscriptionCreated\")) {\n return { status: \"success\", changed: false };\n }\n\n const { source } = withInMemoryScript(original, (sf) => {\n removeImportByModuleSpecifier(sf, \"./subscription/created\");\n removeImportByModuleSpecifier(sf, \"./subscription/updated\");\n removeImportByModuleSpecifier(sf, \"./subscription/deleted\");\n\n const switchStmt = sf\n .getDescendantsOfKind(SyntaxKind.SwitchStatement)\n .find((stmt) => stmt.getExpression().getText().includes(\"event.type\"));\n if (!switchStmt) return;\n\n const caseBlock = switchStmt.getCaseBlock();\n // Collect matching case clauses first — removing invalidates node refs.\n const toRemove = caseBlock\n .getClauses()\n .filter((clause) => {\n if (clause.getKind() !== SyntaxKind.CaseClause) return false;\n const caseClause = clause.asKindOrThrow(SyntaxKind.CaseClause);\n const expr = caseClause.getExpression();\n const literal =\n expr.asKind(SyntaxKind.StringLiteral) ??\n expr.asKind(SyntaxKind.NoSubstitutionTemplateLiteral);\n if (!literal) return false;\n return SUBSCRIPTION_CASE_VALUES.has(literal.getLiteralValue());\n })\n .map((c) => c.asKindOrThrow(SyntaxKind.CaseClause));\n\n for (const clause of toRemove.reverse()) {\n clause.remove();\n }\n\n formatLikeSource(sf);\n });\n\n // Removing the clauses takes the blank line before `default:` with them.\n const spaced = source.replace(/(break;)\\n(\\s*default:)/, \"$1\\n\\n$2\");\n\n if (spaced === original) {\n return { status: \"success\", changed: false };\n }\n fs.writeFileSync(filePath, spaced, \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nexport function unmodifyAppLayoutSvelte(filePath: string): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"success\", changed: false };\n }\n\n const file = SvelteFile.fromPath(filePath);\n if (!file.hasElement(\"AppSidebar\")) {\n return { status: \"success\", changed: false };\n }\n if (!file.hasAttribute(\"AppSidebar\", \"subscription\")) {\n return { status: \"success\", changed: false };\n }\n\n const removed = file.removeAttribute(\"AppSidebar\", \"subscription\");\n if (!removed) {\n return { status: \"success\", changed: false };\n }\n\n file.writeTo(filePath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import fs from \"node:fs\";\nimport { SyntaxKind } from \"ts-morph\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport {\n withInMemoryScript,\n formatLikeSource,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nfunction updateScript(source: string): string {\n const { source: out } = withInMemoryScript(source, (sf) => {\n for (const decl of sf.getVariableDeclarations()) {\n const init = decl.getInitializer();\n if (!init || init.getText() !== \"$props()\") continue;\n\n const nameNode = decl.getNameNode();\n if (nameNode.getKind() !== SyntaxKind.ObjectBindingPattern) continue;\n const pattern = nameNode.asKindOrThrow(SyntaxKind.ObjectBindingPattern);\n const elements = pattern.getElements();\n const hasSub = elements.some((e) => e.getName() === \"subscription\");\n\n // Strip subscription from the props type literal (the specific type\n // added by enable-subscriptions — leave unrelated `subscription` props\n // alone).\n const typeNode = decl.getTypeNode();\n if (typeNode?.getKind() === SyntaxKind.IntersectionType) {\n const intersection = typeNode.asKindOrThrow(\n SyntaxKind.IntersectionType,\n );\n for (const member of intersection.getTypeNodes()) {\n if (member.getKind() !== SyntaxKind.TypeLiteral) continue;\n const lit = member.asKindOrThrow(SyntaxKind.TypeLiteral);\n const propTexts = lit\n .getProperties()\n .map((p) => p.getText().replace(/[;,]\\s*$/, \"\"))\n .filter((t) => !/^\\s*subscription\\??\\s*:/.test(t));\n lit.replaceWithText(\n propTexts.length ? `{ ${propTexts.join(\"; \")}; }` : \"{}\",\n );\n break;\n }\n }\n\n if (hasSub) {\n const remaining = elements\n .filter((e) => e.getName() !== \"subscription\")\n .map((e) => e.getText());\n pattern.replaceWithText(`{ ${remaining.join(\", \")} }`);\n }\n }\n formatLikeSource(sf);\n });\n return out;\n}\n\nexport function unmodifyAppSidebar(filePath: string): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"success\", changed: false };\n }\n\n const source = fs.readFileSync(filePath, \"utf8\");\n const hasSubPropType = /subscription\\??\\s*:\\s*\\{/.test(source);\n const hasSubProp = /\\bsubscription\\s*=\\s*null\\b/.test(source);\n\n const file = new SvelteFile(source);\n const hasNavUserSubAttr =\n file.hasElement(\"NavUser\") && file.hasAttribute(\"NavUser\", \"subscription\");\n\n if (!hasSubPropType && !hasSubProp && !hasNavUserSubAttr) {\n return { status: \"success\", changed: false };\n }\n\n if (hasSubPropType || hasSubProp) {\n file.modifyScript(updateScript);\n }\n if (hasNavUserSubAttr) {\n file.removeAttribute(\"NavUser\", \"subscription\");\n }\n\n file.writeTo(filePath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import fs from \"node:fs\";\nimport { Project, QuoteKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { removeFromLoad } from \"../../../../runtime/unmodify-load\";\nimport {\n ensureBlankLineAfterImports,\n formatLikeSource,\n removeTopLevelStatementByIdentifier,\n} from \"../../../../runtime/ts-morph-helpers\";\n\n/**\n * Takes out what enable-subscriptions added to the (app) layout load: the\n * `subscription` it loads and returns, and the `loadActiveSubscription`\n * helper. The rest of the load (what other patterns added) stays.\n */\nexport function unmodifyAppLayoutServer(filePath: string): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"success\", changed: false };\n }\n const original = fs.readFileSync(filePath, \"utf8\");\n if (!original.includes(\"loadActiveSubscription\")) {\n return { status: \"success\", changed: false };\n }\n\n const fromLoad = removeFromLoad(filePath, {\n variables: [\"subscription\"],\n dependsKeys: [],\n returnProps: [\"subscription\"],\n });\n if (fromLoad.status !== \"success\") return fromLoad;\n\n const project = new Project({\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sf = project.addSourceFileAtPath(filePath);\n removeTopLevelStatementByIdentifier(sf, \"loadActiveSubscription\");\n formatLikeSource(sf);\n // The helper sat between the import and `load`.\n ensureBlankLineAfterImports(sf);\n sf.saveSync();\n\n return {\n status: \"success\",\n changed: fs.readFileSync(filePath, \"utf8\") !== original,\n };\n}\n","import fs from \"node:fs\";\nimport { SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport { withInMemoryScript } from \"../../../../runtime/ts-morph-helpers\";\nimport {\n bindingText,\n propsStatement,\n} from \"../../../enable/subscriptions/modifies/modify-nav-user\";\n\n/**\n * Takes the plan label out of nav-user: the lines showing it, `planLabel`\n * and the `subscription` prop. What other patterns added stays.\n */\nexport function unmodifyNavUser(filePath: string): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"success\", changed: false };\n }\n const original = fs.readFileSync(filePath, \"utf8\");\n if (!original.includes(\"planLabel\")) {\n return { status: \"success\", changed: false };\n }\n\n const file = new SvelteFile(original);\n file.modifyScript(\n (content) =>\n withInMemoryScript(\n // With the blank line enable-subscriptions put before it.\n content.replace(\n /\\n[ \\t]*\\n[ \\t]*const planLabel = \\$derived\\([^\\n]*\\);/,\n \"\",\n ),\n (sf) => {\n const decl = propsStatement(sf)?.getDeclarations()[0];\n const binding = decl\n ?.getNameNode()\n .asKind(SyntaxKind.ObjectBindingPattern);\n const kept = binding\n ?.getElements()\n .filter((e) => e.getName() !== \"subscription\")\n .map((e) => e.getText());\n if (binding && kept) {\n binding.replaceWithText(bindingText(binding.getText(), kept));\n }\n decl\n ?.getTypeNode()\n ?.asKind(SyntaxKind.TypeLiteral)\n ?.getProperty(\"subscription\")\n ?.remove();\n },\n ).source,\n );\n\n // The lines under the name, with the line break before them.\n const out = file\n .toString()\n .replace(/\\n[ \\t]*<span class=\"[^\"]*\">\\s*\\{planLabel\\}\\s*<\\/span>/g, \"\");\n\n fs.writeFileSync(filePath, out, \"utf8\");\n return { status: \"success\", changed: out !== original };\n}\n","import fs from \"node:fs\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\n/**\n * Rewrites a file to the given `template` if the current content still shows\n * the `enabledMarker` (meaning enable-subscriptions is applied). If the marker\n * is absent (already reverted or never applied), it's a no-op.\n *\n * Strips leading `// [!code highlight:N]` / `<!-- [!code highlight:N] -->`\n * lines so templates can be pulled from `preview-modifies/` directories which\n * use those for documentation highlighting.\n */\nexport function revertByTemplate(\n filePath: string,\n template: string,\n enabledMarker: string,\n): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"success\", changed: false };\n }\n const current = fs.readFileSync(filePath, \"utf8\");\n if (!current.includes(enabledMarker)) {\n return { status: \"success\", changed: false };\n }\n const stripped = template\n .replace(/^[ \\t]*\\/\\/[ \\t]*\\[!code highlight:\\d+\\][ \\t]*\\r?\\n/gm, \"\")\n .replace(\n /^[ \\t]*<!--[ \\t]*\\[!code highlight:\\d+\\][ \\t]*-->[ \\t]*\\r?\\n/gm,\n \"\",\n );\n if (current === stripped) {\n return { status: \"success\", changed: false };\n }\n fs.writeFileSync(filePath, stripped, \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import { revertByTemplate } from \"./revert-by-template\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nexport function unmodifyBillingPageServer(\n filePath: string,\n paymentsBillingPageServerTemplate: string,\n): ModifyOutcome {\n return revertByTemplate(\n filePath,\n paymentsBillingPageServerTemplate,\n \"selectPlan\",\n );\n}\n","import { revertByTemplate } from \"./revert-by-template\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nexport function unmodifyBillingPageSvelte(\n filePath: string,\n paymentsBillingPageSvelteTemplate: string,\n): ModifyOutcome {\n return revertByTemplate(\n filePath,\n paymentsBillingPageSvelteTemplate,\n \"availablePlans\",\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 { planDropsForCollections } from \"../../destroy/shared\";\nimport { unmodifyWebhookServer } from \"./modifies/modify-webhook-server\";\nimport { unmodifyAppLayoutSvelte } from \"./modifies/modify-app-layout-svelte\";\nimport { unmodifyAppSidebar } from \"./modifies/modify-app-sidebar\";\nimport { unmodifyAppLayoutServer } from \"./modifies/modify-app-layout-server\";\nimport { unmodifyNavUser } from \"./modifies/modify-nav-user\";\nimport { unmodifyBillingPageServer } from \"./modifies/modify-billing-page-server\";\nimport { unmodifyBillingPageSvelte } from \"./modifies/modify-billing-page-svelte\";\n\n// Pull the \"post-payments\" state of files that enable-subscriptions fully\n// overwrote. For the billing pages, that's exactly what enable-payments\n// writes in creates-app-mode; for nav-user it's the payments preview-modifies\n// snapshot (with highlight annotations stripped by the revert helper).\nimport paymentsBillingPageServerTemplate from \"../../enable/payments/providers-app-mode/stripe/src/routes/(app)/billing/+page.server.ts?raw\";\nimport paymentsBillingPageSvelteTemplate from \"../../enable/payments/providers-app-mode/stripe/src/routes/(app)/billing/+page.svelte?raw\";\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 webhooks/stripe/handlers/dispatch.ts\");\n const webhookServerPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"webhooks\",\n \"stripe\",\n \"handlers\",\n \"dispatch.ts\",\n );\n pushResult(\n modifyOutcomeToFile(\n webhookServerPath,\n unmodifyWebhookServer(webhookServerPath),\n ),\n );\n\n logger.info(\"Reverting (app)/+layout.server.ts\");\n const appLayoutServerPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"+layout.server.ts\",\n );\n pushResult(\n modifyOutcomeToFile(\n appLayoutServerPath,\n unmodifyAppLayoutServer(appLayoutServerPath),\n ),\n );\n\n logger.info(\"Reverting (app)/+layout.svelte\");\n const appLayoutSveltePath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"+layout.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(\n appLayoutSveltePath,\n unmodifyAppLayoutSvelte(appLayoutSveltePath),\n ),\n );\n\n logger.info(\"Reverting app-sidebar.svelte\");\n const appSidebarPath = path.join(\n options.root,\n \"src\",\n \"lib\",\n \"components\",\n \"app-sidebar.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(appSidebarPath, unmodifyAppSidebar(appSidebarPath)),\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 logger.info(\"Reverting billing/+page.server.ts\");\n const billingPageServerPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"billing\",\n \"+page.server.ts\",\n );\n pushResult(\n modifyOutcomeToFile(\n billingPageServerPath,\n unmodifyBillingPageServer(\n billingPageServerPath,\n paymentsBillingPageServerTemplate,\n ),\n ),\n );\n\n logger.info(\"Reverting billing/+page.svelte\");\n const billingPageSveltePath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"billing\",\n \"+page.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(\n billingPageSveltePath,\n unmodifyBillingPageSvelte(\n billingPageSveltePath,\n paymentsBillingPageSvelteTemplate,\n ),\n ),\n );\n\n const collectionDrops = await planDropsForCollections(\n [\"stripe_subscriptions\"],\n options,\n );\n\n return {\n creates: [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collection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import { r as t } from "./modify-file-
|
|
2
|
+
import { r as t } from "./modify-file-DRdmZIvW.js";
|
|
3
3
|
import { t as n } from "./svelte-file-DfplF3BU.js";
|
|
4
4
|
import { _ as r, n as i, u as a } from "./ts-morph-helpers-B4KZXP44.js";
|
|
5
5
|
import { n as o, t as s } from "./layout.svelte-B6wOQ7SM.js";
|
|
@@ -45,4 +45,4 @@ async function f(n) {
|
|
|
45
45
|
}
|
|
46
46
|
export { f as generate };
|
|
47
47
|
|
|
48
|
-
//# sourceMappingURL=generate.runtime-
|
|
48
|
+
//# sourceMappingURL=generate.runtime-C1zb2WxI.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.runtime-
|
|
1
|
+
{"version":3,"file":"generate.runtime-C1zb2WxI.js","names":["getLogger","modifyOutcomeToFile","SvelteFile","withInMemoryScript","ensureBlankLineAfterImports","removeImportByModuleSpecifier","findMetaTagsDerived","MODULE_SPECIFIER","fs","path","unmodifyLayoutSvelte","layoutPath","file","out","source","call","sf","Node","generate","logger","options","modifies"],"sources":["../../src/patterns/disable/og/modifies/layout.svelte.ts","../../src/patterns/disable/og/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { Node } from \"ts-morph\";\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 {\n findMetaTagsDerived,\n MODULE_SPECIFIER,\n} from \"../../../enable/og/modifies/layout.svelte\";\n\n/**\n * Takes `withCard(..., page.url)` back off the root layout's `metaTags`, and\n * its import with it. `page` stays imported: the layout used it before.\n */\nexport function unmodifyLayoutSvelte(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"success\", changed: false };\n }\n\n const file = SvelteFile.fromPath(layoutPath);\n if (!file.getScript()?.content.includes(\"withCard\")) {\n return { status: \"success\", changed: false };\n }\n\n file.modifyScript((source) => {\n const { source: out } = withInMemoryScript(source, (sf) => {\n const call = findMetaTagsDerived(sf)?.getArguments()[0];\n if (\n call &&\n Node.isCallExpression(call) &&\n call.getExpression().getText() === \"withCard\"\n ) {\n call.replaceWithText(call.getArguments()[0].getText());\n }\n removeImportByModuleSpecifier(sf, MODULE_SPECIFIER);\n ensureBlankLineAfterImports(sf);\n });\n return out;\n });\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 { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { unmodifyLayoutSvelte } from \"./modifies/layout.svelte\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n\n logger.info(\"Reverting src/routes/+layout.svelte\");\n const layoutPath = path.join(options.root, \"src\", \"routes\", \"+layout.svelte\");\n const file = modifyOutcomeToFile(\n layoutPath,\n unmodifyLayoutSvelte(layoutPath),\n );\n if (file) modifies.push(file);\n\n return {\n creates: [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;;AAkBA,SAAgBU,EAAqB,GAAmC;CACtE,IAAI,CAACF,EAAG,WAAWG,CAAU,GAC3B,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAMC,IAAOV,EAAW,SAASS,CAAU;CAsB3C,OArBKC,EAAK,UAAU,CAAC,EAAE,QAAQ,SAAS,UAAU,KAIlDA,EAAK,cAAc,MAAW;EAC5B,IAAM,EAAE,QAAQC,MAAQV,EAAmBW,IAAS,MAAO;GACzD,IAAMC,IAAOT,EAAoBU,CAAE,CAAC,EAAE,aAAa,CAAC,CAAC;GASrD,AAPED,KACAE,EAAK,iBAAiBF,CAAI,KAC1BA,EAAK,cAAc,CAAC,CAAC,QAAQ,MAAM,cAEnCA,EAAK,gBAAgBA,EAAK,aAAa,CAAC,CAAC,EAAE,CAAC,QAAQ,CAAC,GAEvDV,EAA8BW,GAAIT,CAAgB,GAClDH,EAA4BY,CAAE;EAChC,CAAC;EACD,OAAOH;CACT,CAAC,GAEDD,EAAK,QAAQD,CAAU,GAChB;EAAE,QAAQ;EAAW,SAASC,EAAK,WAAW;CAAE,KApB9C;EAAE,QAAQ;EAAW,SAAS;CAAM;AAqB/C;;ACxCA,eAAsBM,EAAS,GAAkB;CAC/C,IAAMC,IAASnB,EAAUoB,CAAO,GAC1BC,IAAmB,CAAC;CAE1B,EAAO,KAAK,qCAAqC;CACjD,IAAMV,IAAaF,EAAK,KAAKW,EAAQ,MAAM,OAAO,UAAU,gBAAgB,GACtER,IAAOX,EACXU,GACAD,EAAqBC,CAAU,CACjC;CAGA,OAFIC,KAAMS,EAAS,KAAKT,CAAI,GAErB;EACL,SAAS,CAAC;EACV;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { a as e, i as t, n, o as r, r as i, s as a, t as o } from "./dispatch-
|
|
1
|
+
import { a as e, i as t, n, o as r, r as i, s as a, t as o } from "./dispatch-DSkRrJFe.js";
|
|
2
2
|
import { t as s } from "./errors-DdSUZI8f.js";
|
|
3
3
|
import { n as c } from "./logger-t1HxmpG2.js";
|
|
4
|
-
import { n as l, r as u } from "./modify-file-
|
|
4
|
+
import { n as l, r as u } from "./modify-file-DRdmZIvW.js";
|
|
5
5
|
import { t as d } from "./dedent-CCUOcPFW.js";
|
|
6
|
-
import { _ as f,
|
|
7
|
-
import { t as
|
|
8
|
-
import { n as
|
|
9
|
-
import { t as
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import { Project as
|
|
6
|
+
import { _ as f, n as p, o as m, r as h } from "./ts-morph-helpers-B4KZXP44.js";
|
|
7
|
+
import { t as g } from "./svelte-file-DfplF3BU.js";
|
|
8
|
+
import { n as _ } from "./modify-nav-user--7OwY9fI.js";
|
|
9
|
+
import { t as v } from "./stripe-customer-5S-nOXP1.js";
|
|
10
|
+
import y from "node:fs";
|
|
11
|
+
import b from "node:path";
|
|
12
|
+
import { Project as x, QuoteKind as S, SyntaxKind as C } from "ts-morph";
|
|
13
13
|
// src/patterns/enable/subscriptions/modifies/modify-webhook-server.ts
|
|
14
|
-
var
|
|
14
|
+
var w = d`
|
|
15
15
|
Wire the subscription event handlers into src/routes/webhooks/stripe/handlers/dispatch.ts:
|
|
16
16
|
|
|
17
17
|
Add imports:
|
|
@@ -29,7 +29,7 @@ var C = d`
|
|
|
29
29
|
case "customer.subscription.deleted":
|
|
30
30
|
await handleSubscriptionDeleted(event.data.object, locals);
|
|
31
31
|
break;
|
|
32
|
-
`,
|
|
32
|
+
`, T = "Enable payments first — src/routes/webhooks/stripe/handlers/dispatch.ts is created by enable-payments.", E = d`
|
|
33
33
|
case "customer.subscription.created":
|
|
34
34
|
await handleSubscriptionCreated(event.data.object, locals);
|
|
35
35
|
break;
|
|
@@ -42,18 +42,18 @@ var C = d`
|
|
|
42
42
|
await handleSubscriptionDeleted(event.data.object, locals);
|
|
43
43
|
break;
|
|
44
44
|
`;
|
|
45
|
-
function
|
|
46
|
-
if (!
|
|
45
|
+
function D(e) {
|
|
46
|
+
if (!y.existsSync(e)) return {
|
|
47
47
|
status: "not-found",
|
|
48
|
-
message:
|
|
48
|
+
message: T
|
|
49
49
|
};
|
|
50
|
-
let t =
|
|
50
|
+
let t = y.readFileSync(e, "utf8");
|
|
51
51
|
if (t.includes("handleSubscriptionCreated")) return {
|
|
52
52
|
status: "success",
|
|
53
53
|
changed: !1
|
|
54
54
|
};
|
|
55
55
|
let n = !1, { source: r } = f(t, (e) => {
|
|
56
|
-
|
|
56
|
+
h(e, [
|
|
57
57
|
{
|
|
58
58
|
namedImports: ["handleSubscriptionCreated"],
|
|
59
59
|
moduleSpecifier: "./subscription/created"
|
|
@@ -67,45 +67,45 @@ function E(e) {
|
|
|
67
67
|
moduleSpecifier: "./subscription/deleted"
|
|
68
68
|
}
|
|
69
69
|
]);
|
|
70
|
-
let t = e.getDescendantsOfKind(
|
|
70
|
+
let t = e.getDescendantsOfKind(C.SwitchStatement).find((e) => e.getExpression().getText().includes("event.type"));
|
|
71
71
|
if (!t) return;
|
|
72
|
-
let r = t.getCaseBlock().getClauses(), i = r.find((e) => e.getKind() ===
|
|
72
|
+
let r = t.getCaseBlock().getClauses(), i = r.find((e) => e.getKind() === C.DefaultClause), a = `${E}\n\n`;
|
|
73
73
|
if (i) i.replaceWithText(a + i.getText());
|
|
74
74
|
else if (r.length > 0) {
|
|
75
75
|
let e = r[r.length - 1];
|
|
76
|
-
e.replaceWithText(e.getText() + `\n\n${
|
|
76
|
+
e.replaceWithText(e.getText() + `\n\n${E}`);
|
|
77
77
|
} else return;
|
|
78
|
-
|
|
78
|
+
m(e), n = !0;
|
|
79
79
|
});
|
|
80
|
-
return n ? (
|
|
80
|
+
return n ? (y.writeFileSync(e, r, "utf8"), {
|
|
81
81
|
status: "success",
|
|
82
82
|
changed: !0
|
|
83
83
|
}) : {
|
|
84
84
|
status: "failed",
|
|
85
|
-
message:
|
|
85
|
+
message: w
|
|
86
86
|
};
|
|
87
87
|
}
|
|
88
88
|
// src/patterns/enable/subscriptions/modifies/modify-app-layout-server.ts
|
|
89
|
-
var
|
|
89
|
+
var O = "const subscription = await loadActiveSubscription(locals, user.id);", k = "Create src/routes/(app)/+layout.server.ts before enabling subscriptions.\nEnable auth first — the (app) layout is provided by the velastack-auth baseline.", A = (e) => [
|
|
90
90
|
"Could not find the user and the returned object in the (app) layout load.",
|
|
91
91
|
"Add the active subscription to it by hand:",
|
|
92
92
|
"",
|
|
93
93
|
e,
|
|
94
94
|
"",
|
|
95
95
|
"// In load, once `user` is set:",
|
|
96
|
-
|
|
96
|
+
O,
|
|
97
97
|
"// ...and return it with the rest:",
|
|
98
98
|
"return { ..., subscription };"
|
|
99
99
|
].join("\n");
|
|
100
|
-
function
|
|
100
|
+
function j(e) {
|
|
101
101
|
let t = e.replace(/^[ \t]*\/\/[ \t]*\[!code highlight:\d+\][ \t]*\r?\n/gm, ""), n = t.indexOf("async function loadActiveSubscription"), r = t.indexOf("\n}\n", n);
|
|
102
102
|
if (n === -1 || r === -1) throw Error("No loadActiveSubscription in the layout template");
|
|
103
103
|
return t.slice(n, r + 2);
|
|
104
104
|
}
|
|
105
|
-
function
|
|
105
|
+
function M(e) {
|
|
106
106
|
let t = e.getVariableDeclaration("load");
|
|
107
107
|
if (t?.getVariableStatement()?.hasExportKeyword()) {
|
|
108
|
-
let e = t.getInitializer(), n = t.getInitializerIfKind(
|
|
108
|
+
let e = t.getInitializer(), n = t.getInitializerIfKind(C.ArrowFunction) ?? e?.getFirstDescendantByKind(C.ArrowFunction) ?? e?.getFirstDescendantByKind(C.FunctionExpression);
|
|
109
109
|
if (n) return {
|
|
110
110
|
fn: n,
|
|
111
111
|
statement: t.getVariableStatement()
|
|
@@ -117,43 +117,52 @@ function j(e) {
|
|
|
117
117
|
statement: n
|
|
118
118
|
} : void 0;
|
|
119
119
|
}
|
|
120
|
-
function
|
|
121
|
-
if (!
|
|
120
|
+
function N(e, t) {
|
|
121
|
+
if (!y.existsSync(e)) return {
|
|
122
122
|
status: "not-found",
|
|
123
|
-
message:
|
|
123
|
+
message: k
|
|
124
124
|
};
|
|
125
|
-
let n =
|
|
125
|
+
let n = y.readFileSync(e, "utf8");
|
|
126
126
|
if (n.includes("loadActiveSubscription")) return {
|
|
127
127
|
status: "success",
|
|
128
128
|
changed: !1
|
|
129
129
|
};
|
|
130
|
-
let r =
|
|
131
|
-
if (!a || !o || o.getKind() !==
|
|
130
|
+
let r = j(t), i = new x({ manipulationSettings: { quoteKind: S.Single } }).addSourceFileAtPath(e), a = M(i), o = a?.fn.getBody();
|
|
131
|
+
if (!a || !o || o.getKind() !== C.Block) return {
|
|
132
132
|
status: "failed",
|
|
133
|
-
message:
|
|
133
|
+
message: A(r)
|
|
134
134
|
};
|
|
135
|
-
let s = o.asKindOrThrow(
|
|
136
|
-
if (
|
|
135
|
+
let s = o.asKindOrThrow(C.Block), c = a.fn.getParameters();
|
|
136
|
+
if (c.length === 0) a.fn.insertParameter(0, { name: "{ locals }" });
|
|
137
|
+
else {
|
|
138
|
+
let e = c[0], t = e.getNameNode().asKind(C.ObjectBindingPattern);
|
|
139
|
+
if (t && !t.getElements().some((e) => e.getName() === "locals")) {
|
|
140
|
+
let n = t.getElements().map((e) => e.getText());
|
|
141
|
+
e.set({ name: `{ ${["locals", ...n].join(", ")} }` });
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
let l = a.fn.getParameters()[0]?.getNameNode(), u = l?.getKind() === C.ObjectBindingPattern && l.asKindOrThrow(C.ObjectBindingPattern).getElements().some((e) => e.getName() === "locals"), d = s.getStatements().findIndex((e) => e.getKind() === C.VariableStatement && e.asKindOrThrow(C.VariableStatement).getDeclarations().some((e) => e.getName() === "user")), f = s.getStatements(), h = [...f].reverse().find((e) => e.getKind() === C.ReturnStatement)?.asKind(C.ReturnStatement), g = h?.getExpression()?.asKind(C.ObjectLiteralExpression);
|
|
145
|
+
if (!u || d === -1 || !h || !g) return {
|
|
137
146
|
status: "failed",
|
|
138
|
-
message:
|
|
147
|
+
message: A(r)
|
|
139
148
|
};
|
|
140
|
-
if (s.insertStatements(
|
|
141
|
-
let e =
|
|
142
|
-
e.includes("\n") ?
|
|
149
|
+
if (s.insertStatements(f.indexOf(h), O), !g.getProperty("subscription")) {
|
|
150
|
+
let e = g.getText();
|
|
151
|
+
e.includes("\n") ? g.addShorthandPropertyAssignment({ name: "subscription" }) : g.replaceWithText(e.replace(/\s*\}$/, ", subscription }"));
|
|
143
152
|
}
|
|
144
|
-
return a.fn.isAsync() || a.fn.setIsAsync(!0), i.insertStatements(i.getStatements().indexOf(a.statement), (e) => e.write(r).blankLine()), p(i), i.saveSync(), {
|
|
153
|
+
return a.fn.isAsync() || a.fn.setIsAsync(!0), i.insertStatements(i.getStatements().indexOf(a.statement), (e) => e.write(r).blankLine()), m(i), p(i), i.saveSync(), {
|
|
145
154
|
status: "success",
|
|
146
155
|
changed: i.getFullText() !== n
|
|
147
156
|
};
|
|
148
157
|
}
|
|
149
158
|
// src/patterns/enable/subscriptions/modifies/modify-app-layout-svelte.ts
|
|
150
|
-
var
|
|
151
|
-
function
|
|
152
|
-
if (!
|
|
159
|
+
var P = "Pass the subscription prop to <AppSidebar> in src/routes/(app)/+layout.svelte:\n\n<AppSidebar user={data.user} subscription={data.subscription} />", F = "Create src/routes/(app)/+layout.svelte with an <AppSidebar /> that receives the subscription prop.";
|
|
160
|
+
function I(e) {
|
|
161
|
+
if (!y.existsSync(e)) return {
|
|
153
162
|
status: "not-found",
|
|
154
|
-
message:
|
|
163
|
+
message: F
|
|
155
164
|
};
|
|
156
|
-
let t =
|
|
165
|
+
let t = g.fromPath(e);
|
|
157
166
|
return t.hasElement("AppSidebar") ? t.hasAttribute("AppSidebar", "subscription") ? {
|
|
158
167
|
status: "success",
|
|
159
168
|
changed: !1
|
|
@@ -162,37 +171,37 @@ function F(e) {
|
|
|
162
171
|
changed: t.hasChanged()
|
|
163
172
|
}) : {
|
|
164
173
|
status: "failed",
|
|
165
|
-
message:
|
|
174
|
+
message: P
|
|
166
175
|
} : {
|
|
167
176
|
status: "failed",
|
|
168
|
-
message:
|
|
177
|
+
message: P
|
|
169
178
|
};
|
|
170
179
|
}
|
|
171
180
|
// src/patterns/enable/subscriptions/modifies/modify-app-sidebar.ts
|
|
172
|
-
var
|
|
181
|
+
var L = "{ id: string; productName: string | null } | null", R = [
|
|
173
182
|
"Update src/lib/components/app-sidebar.svelte to forward a subscription prop:",
|
|
174
183
|
"",
|
|
175
184
|
"1. Add `subscription = null` to the destructured $props() call.",
|
|
176
|
-
`2. Add \`subscription?: ${
|
|
185
|
+
`2. Add \`subscription?: ${L}\` to the props type.`,
|
|
177
186
|
"3. Pass `{subscription}` to <NavUser>."
|
|
178
|
-
].join("\n"),
|
|
179
|
-
function
|
|
187
|
+
].join("\n"), z = "Create src/lib/components/app-sidebar.svelte before enabling subscriptions.";
|
|
188
|
+
function B(e) {
|
|
180
189
|
let t = !1, { source: n } = f(e, (e) => {
|
|
181
190
|
for (let n of e.getVariableDeclarations()) {
|
|
182
191
|
let e = n.getInitializer();
|
|
183
192
|
if (!e || e.getText() !== "$props()") continue;
|
|
184
193
|
let r = n.getNameNode();
|
|
185
|
-
if (r.getKind() !==
|
|
186
|
-
let i = r.asKindOrThrow(
|
|
194
|
+
if (r.getKind() !== C.ObjectBindingPattern) continue;
|
|
195
|
+
let i = r.asKindOrThrow(C.ObjectBindingPattern), a = i.getElements();
|
|
187
196
|
if (a.some((e) => e.getName() === "subscription")) return;
|
|
188
197
|
let o = n.getTypeNode();
|
|
189
|
-
if (o?.getKind() ===
|
|
190
|
-
let e = o.asKindOrThrow(
|
|
198
|
+
if (o?.getKind() === C.IntersectionType) {
|
|
199
|
+
let e = o.asKindOrThrow(C.IntersectionType);
|
|
191
200
|
for (let t of e.getTypeNodes()) {
|
|
192
|
-
if (t.getKind() !==
|
|
193
|
-
let e = t.asKindOrThrow(
|
|
201
|
+
if (t.getKind() !== C.TypeLiteral) continue;
|
|
202
|
+
let e = t.asKindOrThrow(C.TypeLiteral), n = e.getProperties().map((e) => e.getText().replace(/[;,]\s*$/, ""));
|
|
194
203
|
if (!n.some((e) => /^\s*subscription\??\s*:/.test(e))) {
|
|
195
|
-
n.push(`subscription?: ${
|
|
204
|
+
n.push(`subscription?: ${L}`), e.replaceWithText(`{ ${n.join("; ")}; }`);
|
|
196
205
|
break;
|
|
197
206
|
}
|
|
198
207
|
}
|
|
@@ -200,44 +209,44 @@ function z(e) {
|
|
|
200
209
|
let s = a.map((e) => e.getText()), c = a.findIndex((e) => e.getDotDotDotToken() || e.getInitializer());
|
|
201
210
|
c === -1 && (c = s.length), s.splice(c, 0, "subscription = null"), i.replaceWithText(`{ ${s.join(", ")} }`), t = !0;
|
|
202
211
|
}
|
|
203
|
-
|
|
212
|
+
m(e);
|
|
204
213
|
});
|
|
205
214
|
return {
|
|
206
215
|
source: n,
|
|
207
216
|
wasAdded: t
|
|
208
217
|
};
|
|
209
218
|
}
|
|
210
|
-
function
|
|
211
|
-
if (!
|
|
219
|
+
function V(e) {
|
|
220
|
+
if (!y.existsSync(e)) return {
|
|
212
221
|
status: "not-found",
|
|
213
|
-
message:
|
|
222
|
+
message: z
|
|
214
223
|
};
|
|
215
|
-
let t =
|
|
224
|
+
let t = y.readFileSync(e, "utf8");
|
|
216
225
|
if (t.includes("subscription?: {") || t.includes("subscription={subscription}") || t.includes("{subscription}")) return {
|
|
217
226
|
status: "success",
|
|
218
227
|
changed: !1
|
|
219
228
|
};
|
|
220
|
-
let n = new
|
|
229
|
+
let n = new g(t);
|
|
221
230
|
if (!n.hasElement("NavUser")) return {
|
|
222
231
|
status: "failed",
|
|
223
|
-
message:
|
|
232
|
+
message: R
|
|
224
233
|
};
|
|
225
|
-
let r = n.modifyScript((e) =>
|
|
234
|
+
let r = n.modifyScript((e) => B(e).source), i = !n.hasAttribute("NavUser", "subscription") && n.appendToAttributes("NavUser", " {subscription}");
|
|
226
235
|
return !r && !i ? {
|
|
227
236
|
status: "failed",
|
|
228
|
-
message:
|
|
237
|
+
message: R
|
|
229
238
|
} : (n.writeTo(e), {
|
|
230
239
|
status: "success",
|
|
231
240
|
changed: n.hasChanged()
|
|
232
241
|
});
|
|
233
242
|
}
|
|
234
243
|
// src/patterns/enable/subscriptions/modifies/modify-by-template.ts
|
|
235
|
-
function
|
|
236
|
-
if (!
|
|
244
|
+
function H(e, t, n, r) {
|
|
245
|
+
if (!y.existsSync(e)) return {
|
|
237
246
|
status: "not-found",
|
|
238
247
|
message: r
|
|
239
248
|
};
|
|
240
|
-
let i =
|
|
249
|
+
let i = y.readFileSync(e, "utf8");
|
|
241
250
|
if (i.includes(n)) return {
|
|
242
251
|
status: "success",
|
|
243
252
|
changed: !1
|
|
@@ -246,34 +255,34 @@ function V(e, t, n, r) {
|
|
|
246
255
|
return i === a ? {
|
|
247
256
|
status: "success",
|
|
248
257
|
changed: !1
|
|
249
|
-
} : (
|
|
258
|
+
} : (y.writeFileSync(e, a, "utf8"), {
|
|
250
259
|
status: "success",
|
|
251
260
|
changed: !0
|
|
252
261
|
});
|
|
253
262
|
}
|
|
254
263
|
// src/patterns/enable/subscriptions/modifies/modify-billing-page-server.ts
|
|
255
|
-
var
|
|
256
|
-
function
|
|
257
|
-
return
|
|
264
|
+
var U = "src/routes/(app)/billing/+page.server.ts is missing.\nEnable payments first — subscriptions extends the billing page with plan management.";
|
|
265
|
+
function W(e, t) {
|
|
266
|
+
return H(e, t, "selectPlan", U);
|
|
258
267
|
}
|
|
259
268
|
// src/patterns/enable/subscriptions/modifies/modify-billing-page-svelte.ts
|
|
260
|
-
var
|
|
261
|
-
function
|
|
262
|
-
return
|
|
269
|
+
var G = "src/routes/(app)/billing/+page.svelte is missing.\nEnable payments first — subscriptions extends the billing page with plan management.";
|
|
270
|
+
function K(e, t) {
|
|
271
|
+
return H(e, t, "availablePlans", G);
|
|
263
272
|
}
|
|
264
273
|
// src/patterns/enable/subscriptions/generate.runtime.ts
|
|
265
|
-
var
|
|
266
|
-
function
|
|
267
|
-
if (!
|
|
274
|
+
var q = "src/lib/server/stripe-customer.ts", J = "src/routes/(app)/billing/+page.server.ts";
|
|
275
|
+
function Y(e) {
|
|
276
|
+
if (!y.existsSync(b.join(e, J))) throw new s([
|
|
268
277
|
"Subscriptions need payments set up with auth on: they add plans to the billing page",
|
|
269
|
-
`(${
|
|
278
|
+
`(${J}) and link to the stripe_customers collection, which enable-payments`,
|
|
270
279
|
"creates only when auth is already enabled. This project enabled payments before auth.",
|
|
271
280
|
"",
|
|
272
281
|
"Re-enable payments now that auth is on: `vela disable payments`, then `vela enable payments`.",
|
|
273
282
|
"disable-payments drops the catalog collections, which the sync workflow refills from Stripe."
|
|
274
283
|
].join("\n"));
|
|
275
284
|
}
|
|
276
|
-
var
|
|
285
|
+
var X = /* #__PURE__ */ Object.assign({
|
|
277
286
|
"./preview-modifies/src/lib/components/app-sidebar.svelte": a,
|
|
278
287
|
"./preview-modifies/src/lib/components/nav-user.svelte": r,
|
|
279
288
|
"./preview-modifies/src/routes/(app)/+layout.server.ts": e,
|
|
@@ -282,34 +291,34 @@ var Y = /* #__PURE__ */ Object.assign({
|
|
|
282
291
|
"./preview-modifies/src/routes/(app)/billing/+page.svelte": n,
|
|
283
292
|
"./preview-modifies/src/routes/webhooks/stripe/handlers/dispatch.ts": o
|
|
284
293
|
});
|
|
285
|
-
function
|
|
286
|
-
let t =
|
|
294
|
+
function Z(e) {
|
|
295
|
+
let t = X[`./preview-modifies/${e}`];
|
|
287
296
|
if (t === void 0) throw Error(`Missing template for ${e} in subscriptions preview-modifies`);
|
|
288
297
|
return t;
|
|
289
298
|
}
|
|
290
|
-
async function
|
|
299
|
+
async function Q(e) {
|
|
291
300
|
let t = c(e), n = [], r = (e) => {
|
|
292
301
|
e && n.push(e);
|
|
293
302
|
};
|
|
294
303
|
t.info("Modifying webhooks/stripe/handlers/dispatch.ts");
|
|
295
|
-
let i =
|
|
296
|
-
r(u(i,
|
|
297
|
-
let a =
|
|
298
|
-
r(u(a,
|
|
299
|
-
let o =
|
|
300
|
-
r(u(o,
|
|
301
|
-
let s =
|
|
302
|
-
r(u(s,
|
|
303
|
-
let d =
|
|
304
|
-
r(u(d,
|
|
305
|
-
let f =
|
|
306
|
-
r(u(f,
|
|
307
|
-
let p =
|
|
308
|
-
return r(u(p,
|
|
304
|
+
let i = b.join(e.root, "src", "routes", "webhooks", "stripe", "handlers", "dispatch.ts");
|
|
305
|
+
r(u(i, D(i))), t.info("Modifying (app)/+layout.server.ts");
|
|
306
|
+
let a = b.join(e.root, "src", "routes", "(app)", "+layout.server.ts");
|
|
307
|
+
r(u(a, N(a, Z("src/routes/(app)/+layout.server.ts")))), t.info("Modifying (app)/+layout.svelte");
|
|
308
|
+
let o = b.join(e.root, "src", "routes", "(app)", "+layout.svelte");
|
|
309
|
+
r(u(o, I(o))), t.info("Modifying app-sidebar.svelte");
|
|
310
|
+
let s = b.join(e.root, "src", "lib", "components", "app-sidebar.svelte");
|
|
311
|
+
r(u(s, V(s))), t.info("Modifying nav-user.svelte");
|
|
312
|
+
let d = b.join(e.root, "src", "lib", "components", "nav-user.svelte");
|
|
313
|
+
r(u(d, _(d))), t.info("Modifying billing/+page.server.ts");
|
|
314
|
+
let f = b.join(e.root, "src", "routes", "(app)", "billing", "+page.server.ts");
|
|
315
|
+
r(u(f, W(f, Z("src/routes/(app)/billing/+page.server.ts")))), t.info("Modifying billing/+page.svelte");
|
|
316
|
+
let p = b.join(e.root, "src", "routes", "(app)", "billing", "+page.svelte");
|
|
317
|
+
return r(u(p, K(p, Z("src/routes/(app)/billing/+page.svelte")))), {
|
|
309
318
|
creates: l([{
|
|
310
|
-
path:
|
|
319
|
+
path: q,
|
|
311
320
|
language: "ts",
|
|
312
|
-
content:
|
|
321
|
+
content: v,
|
|
313
322
|
status: "success"
|
|
314
323
|
}], e.root),
|
|
315
324
|
modifies: n,
|
|
@@ -321,6 +330,6 @@ async function Z(e) {
|
|
|
321
330
|
collectionDrops: []
|
|
322
331
|
};
|
|
323
332
|
}
|
|
324
|
-
export {
|
|
333
|
+
export { Y as assertPaymentsAppMode, Q as generate };
|
|
325
334
|
|
|
326
|
-
//# sourceMappingURL=generate.runtime-
|
|
335
|
+
//# sourceMappingURL=generate.runtime-C4R919oE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.runtime-C4R919oE.js","names":["FAILURE_HINT","NOT_FOUND_HINT","NOT_FOUND_HINT","FAILURE_HINT","NOT_FOUND_HINT","NOT_FOUND_HINT","NOT_FOUND_HINT","__import_glob__0_0_","__import_glob__0_1_","__import_glob__0_2_","__import_glob__0_3_","__import_glob__0_4_","__import_glob__0_5_","__import_glob__0_6_","stripeCustomerHelper","_layout_server_default","_layout_default","nav_user_default","_page_server_default","app_sidebar_default","dispatch_default","InvalidArgumentError","getLogger","keepMissing","modifyOutcomeToFile","dedent","withInMemoryScript","ensureBlankLineAfterImports","formatLikeSource","ensureImports","SvelteFile","modifyNavUser","stripe_customer_default","fs","path","FAILURE_HINT$2","NOT_FOUND_HINT$5","SUBSCRIPTION_CASES_SNIPPET","modifyWebhookServer","filePath","original","addedCases","sf","switchStmt","SyntaxKind","stmt","clauses","defaultClause","c","prefix","last","source","LOAD_LINE","NOT_FOUND_HINT$4","failureHint","helper","helperFrom","clean","template","start","end","findLoad","varDecl","init","fn","modifyAppLayoutServer","Project","QuoteKind","load","body","block","params","first","pattern","el","rest","binding","hasLocals","userIndex","s","d","statements","ret","returned","text","writer","FAILURE_HINT$1","NOT_FOUND_HINT$3","modifyAppLayoutSvelte","file","SUBSCRIPTION_TYPE","FAILURE_HINT","NOT_FOUND_HINT$2","updateScript","wasAdded","out","decl","nameNode","elements","typeNode","intersection","member","lit","propTexts","p","t","elementTexts","insertIdx","modifyAppSidebar","scriptChanged","src","templateChanged","modifyByTemplate","notFoundHint","current","idempotencyMarker","stripped","NOT_FOUND_HINT$1","modifyBillingPageServer","NOT_FOUND_HINT","modifyBillingPageSvelte","STRIPE_CUSTOMER_HELPER","BILLING_PAGE","assertPaymentsAppMode","root","previewRaw","_page_default","content","relativePath","generate","logger","options","modifies","pushResult","webhookServerPath","appLayoutServerPath","appLayoutSveltePath","appSidebarPath","navUserPath","billingPageServerPath","billingPageSveltePath"],"sources":["../../src/patterns/enable/subscriptions/modifies/modify-webhook-server.ts","../../src/patterns/enable/subscriptions/modifies/modify-app-layout-server.ts","../../src/patterns/enable/subscriptions/modifies/modify-app-layout-svelte.ts","../../src/patterns/enable/subscriptions/modifies/modify-app-sidebar.ts","../../src/patterns/enable/subscriptions/modifies/modify-by-template.ts","../../src/patterns/enable/subscriptions/modifies/modify-billing-page-server.ts","../../src/patterns/enable/subscriptions/modifies/modify-billing-page-svelte.ts","../../src/patterns/enable/subscriptions/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { SyntaxKind } from \"ts-morph\";\nimport dedent from \"dedent\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport {\n ensureImports,\n withInMemoryScript,\n formatLikeSource,\n} from \"../../../../runtime/ts-morph-helpers\";\n\nconst FAILURE_HINT = dedent`\n Wire the subscription event handlers into src/routes/webhooks/stripe/handlers/dispatch.ts:\n\n Add imports:\n import { handleSubscriptionCreated } from \"./subscription/created\";\n import { handleSubscriptionUpdated } from \"./subscription/updated\";\n import { handleSubscriptionDeleted } from \"./subscription/deleted\";\n\n Add switch cases inside the event.type switch:\n case \"customer.subscription.created\":\n await handleSubscriptionCreated(event.data.object, locals);\n break;\n case \"customer.subscription.updated\":\n await handleSubscriptionUpdated(event.data.object, locals);\n break;\n case \"customer.subscription.deleted\":\n await handleSubscriptionDeleted(event.data.object, locals);\n break;\n`;\n\nconst NOT_FOUND_HINT =\n \"Enable payments first — src/routes/webhooks/stripe/handlers/dispatch.ts is created by enable-payments.\";\n\nconst SUBSCRIPTION_CASES_SNIPPET = dedent`\n case \"customer.subscription.created\":\n await handleSubscriptionCreated(event.data.object, locals);\n break;\n\n case \"customer.subscription.updated\":\n await handleSubscriptionUpdated(event.data.object, locals);\n break;\n\n case \"customer.subscription.deleted\":\n await handleSubscriptionDeleted(event.data.object, locals);\n break;\n`;\n\nexport function modifyWebhookServer(filePath: string): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const original = fs.readFileSync(filePath, \"utf8\");\n if (original.includes(\"handleSubscriptionCreated\")) {\n return { status: \"success\", changed: false };\n }\n\n let addedCases = false;\n const { source } = withInMemoryScript(original, (sf) => {\n ensureImports(sf, [\n {\n namedImports: [\"handleSubscriptionCreated\"],\n moduleSpecifier: \"./subscription/created\",\n },\n {\n namedImports: [\"handleSubscriptionUpdated\"],\n moduleSpecifier: \"./subscription/updated\",\n },\n {\n namedImports: [\"handleSubscriptionDeleted\"],\n moduleSpecifier: \"./subscription/deleted\",\n },\n ]);\n\n const switchStmt = sf\n .getDescendantsOfKind(SyntaxKind.SwitchStatement)\n .find((stmt) => stmt.getExpression().getText().includes(\"event.type\"));\n if (!switchStmt) return;\n\n const caseBlock = switchStmt.getCaseBlock();\n const clauses = caseBlock.getClauses();\n const defaultClause = clauses.find(\n (c) => c.getKind() === SyntaxKind.DefaultClause,\n );\n\n // Prepend subscription cases in front of the default clause, or append\n // before the closing brace of the case block if there's no default.\n const prefix = `${SUBSCRIPTION_CASES_SNIPPET}\\n\\n`;\n if (defaultClause) {\n defaultClause.replaceWithText(prefix + defaultClause.getText());\n } else if (clauses.length > 0) {\n const last = clauses[clauses.length - 1];\n last.replaceWithText(\n last.getText() + `\\n\\n${SUBSCRIPTION_CASES_SNIPPET}`,\n );\n } else {\n return;\n }\n\n formatLikeSource(sf);\n addedCases = true;\n });\n\n if (!addedCases) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n fs.writeFileSync(filePath, source, \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport { Project, QuoteKind, SyntaxKind, type SourceFile } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport {\n ensureBlankLineAfterImports,\n formatLikeSource,\n} from \"../../../../runtime/ts-morph-helpers\";\n\nconst LOAD_LINE =\n \"const subscription = await loadActiveSubscription(locals, user.id);\";\n\nconst NOT_FOUND_HINT = [\n \"Create src/routes/(app)/+layout.server.ts before enabling subscriptions.\",\n \"Enable auth first — the (app) layout is provided by the velastack-auth baseline.\",\n].join(\"\\n\");\n\nconst failureHint = (helper: string) =>\n [\n \"Could not find the user and the returned object in the (app) layout load.\",\n \"Add the active subscription to it by hand:\",\n \"\",\n helper,\n \"\",\n \"// In load, once `user` is set:\",\n LOAD_LINE,\n \"// ...and return it with the rest:\",\n \"return { ..., subscription };\",\n ].join(\"\\n\");\n\n/**\n * The `loadActiveSubscription` helper, taken from the preview template so the\n * docs and what gets written stay the same.\n */\nfunction helperFrom(template: string): string {\n const clean = template.replace(\n /^[ \\t]*\\/\\/[ \\t]*\\[!code highlight:\\d+\\][ \\t]*\\r?\\n/gm,\n \"\",\n );\n const start = clean.indexOf(\"async function loadActiveSubscription\");\n const end = clean.indexOf(\"\\n}\\n\", start);\n if (start === -1 || end === -1) {\n throw new Error(\"No loadActiveSubscription in the layout template\");\n }\n return clean.slice(start, end + 2);\n}\n\nfunction findLoad(sf: SourceFile) {\n const varDecl = sf.getVariableDeclaration(\"load\");\n if (varDecl?.getVariableStatement()?.hasExportKeyword()) {\n const init = varDecl.getInitializer();\n const fn =\n varDecl.getInitializerIfKind(SyntaxKind.ArrowFunction) ??\n init?.getFirstDescendantByKind(SyntaxKind.ArrowFunction) ??\n init?.getFirstDescendantByKind(SyntaxKind.FunctionExpression);\n if (fn) return { fn, statement: varDecl.getVariableStatement()! };\n }\n const fn = sf.getFunction(\"load\");\n return fn?.isExported() ? { fn, statement: fn } : undefined;\n}\n\n/**\n * Adds the active subscription to the (app) layout's data: the\n * `loadActiveSubscription` helper, a call to it in `load`, and `subscription`\n * in what `load` returns. Edits the file rather than replacing it, so what\n * other patterns put in the load (teams' `team`/`teams`, say) stays.\n */\nexport function modifyAppLayoutServer(\n filePath: string,\n template: string,\n): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n const original = fs.readFileSync(filePath, \"utf8\");\n if (original.includes(\"loadActiveSubscription\")) {\n return { status: \"success\", changed: false };\n }\n\n const helper = helperFrom(template);\n const project = new Project({\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sf = project.addSourceFileAtPath(filePath);\n const load = findLoad(sf);\n const body = load?.fn.getBody();\n if (!load || !body || body.getKind() !== SyntaxKind.Block) {\n return { status: \"failed\", message: failureHint(helper) };\n }\n const block = body.asKindOrThrow(SyntaxKind.Block);\n\n // The call needs `locals` and `user`, and goes before the return. The\n // stock load takes no argument (it gets its user from `requireUser()`), so\n // `locals` is added to it; one that names its event some other way is left\n // for the hint.\n const params = load.fn.getParameters();\n if (params.length === 0) {\n load.fn.insertParameter(0, { name: \"{ locals }\" });\n } else {\n const first = params[0]!;\n const pattern = first.getNameNode().asKind(SyntaxKind.ObjectBindingPattern);\n if (\n pattern &&\n !pattern.getElements().some((el) => el.getName() === \"locals\")\n ) {\n const rest = pattern.getElements().map((el) => el.getText());\n first.set({ name: `{ ${[\"locals\", ...rest].join(\", \")} }` });\n }\n }\n const binding = load.fn.getParameters()[0]?.getNameNode();\n const hasLocals =\n binding?.getKind() === SyntaxKind.ObjectBindingPattern &&\n binding\n .asKindOrThrow(SyntaxKind.ObjectBindingPattern)\n .getElements()\n .some((el) => el.getName() === \"locals\");\n const userIndex = block.getStatements().findIndex(\n (s) =>\n s.getKind() === SyntaxKind.VariableStatement &&\n s\n .asKindOrThrow(SyntaxKind.VariableStatement)\n .getDeclarations()\n .some((d) => d.getName() === \"user\"),\n );\n const statements = block.getStatements();\n const ret = [...statements]\n .reverse()\n .find((s) => s.getKind() === SyntaxKind.ReturnStatement)\n ?.asKind(SyntaxKind.ReturnStatement);\n const returned = ret\n ?.getExpression()\n ?.asKind(SyntaxKind.ObjectLiteralExpression);\n if (!hasLocals || userIndex === -1 || !ret || !returned) {\n return { status: \"failed\", message: failureHint(helper) };\n }\n\n block.insertStatements(statements.indexOf(ret), LOAD_LINE);\n if (!returned.getProperty(\"subscription\")) {\n const text = returned.getText();\n if (text.includes(\"\\n\")) {\n returned.addShorthandPropertyAssignment({ name: \"subscription\" });\n } else {\n // Kept on one line, as written.\n returned.replaceWithText(text.replace(/\\s*\\}$/, \", subscription }\"));\n }\n }\n if (!load.fn.isAsync()) load.fn.setIsAsync(true);\n sf.insertStatements(sf.getStatements().indexOf(load.statement), (writer) =>\n writer.write(helper).blankLine(),\n );\n\n formatLikeSource(sf);\n // The helper goes in above `load`, which in the stock file is right under\n // the import.\n ensureBlankLineAfterImports(sf);\n sf.saveSync();\n return { status: \"success\", changed: sf.getFullText() !== original };\n}\n","import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst FAILURE_HINT = [\n \"Pass the subscription prop to <AppSidebar> in src/routes/(app)/+layout.svelte:\",\n \"\",\n \"<AppSidebar user={data.user} subscription={data.subscription} />\",\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create src/routes/(app)/+layout.svelte with an <AppSidebar /> that receives the subscription prop.\",\n].join(\"\\n\");\n\nexport function modifyAppLayoutSvelte(filePath: string): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const file = SvelteFile.fromPath(filePath);\n if (!file.hasElement(\"AppSidebar\")) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n if (file.hasAttribute(\"AppSidebar\", \"subscription\")) {\n return { status: \"success\", changed: false };\n }\n\n const appended = file.appendToAttributes(\n \"AppSidebar\",\n \" subscription={data.subscription}\",\n );\n if (!appended) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n file.writeTo(filePath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import fs from \"node:fs\";\nimport { SyntaxKind } from \"ts-morph\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport {\n withInMemoryScript,\n formatLikeSource,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst SUBSCRIPTION_TYPE = \"{ id: string; productName: string | null } | null\";\n\nconst FAILURE_HINT = [\n \"Update src/lib/components/app-sidebar.svelte to forward a subscription prop:\",\n \"\",\n \"1. Add `subscription = null` to the destructured $props() call.\",\n `2. Add \\`subscription?: ${SUBSCRIPTION_TYPE}\\` to the props type.`,\n \"3. Pass `{subscription}` to <NavUser>.\",\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create src/lib/components/app-sidebar.svelte before enabling subscriptions.\",\n].join(\"\\n\");\n\nfunction updateScript(source: string): {\n source: string;\n wasAdded: boolean;\n} {\n let wasAdded = false;\n const { source: out } = withInMemoryScript(source, (sf) => {\n for (const decl of sf.getVariableDeclarations()) {\n const init = decl.getInitializer();\n if (!init || init.getText() !== \"$props()\") continue;\n\n const nameNode = decl.getNameNode();\n if (nameNode.getKind() !== SyntaxKind.ObjectBindingPattern) continue;\n const pattern = nameNode.asKindOrThrow(SyntaxKind.ObjectBindingPattern);\n const elements = pattern.getElements();\n if (elements.some((e) => e.getName() === \"subscription\")) {\n // Already has subscription prop — no-op.\n return;\n }\n\n // Insert subscription?: ... into the props type literal if present.\n const typeNode = decl.getTypeNode();\n if (typeNode?.getKind() === SyntaxKind.IntersectionType) {\n const intersection = typeNode.asKindOrThrow(\n SyntaxKind.IntersectionType,\n );\n for (const member of intersection.getTypeNodes()) {\n if (member.getKind() !== SyntaxKind.TypeLiteral) continue;\n const lit = member.asKindOrThrow(SyntaxKind.TypeLiteral);\n const propTexts = lit\n .getProperties()\n .map((p) => p.getText().replace(/[;,]\\s*$/, \"\"));\n if (propTexts.some((t) => /^\\s*subscription\\??\\s*:/.test(t))) {\n continue;\n }\n propTexts.push(`subscription?: ${SUBSCRIPTION_TYPE}`);\n lit.replaceWithText(`{ ${propTexts.join(\"; \")}; }`);\n break;\n }\n }\n\n // Insert `subscription = null` before the first rest/default-only element.\n const elementTexts = elements.map((e) => e.getText());\n let insertIdx = elements.findIndex(\n (e) => e.getDotDotDotToken() || e.getInitializer(),\n );\n if (insertIdx === -1) insertIdx = elementTexts.length;\n elementTexts.splice(insertIdx, 0, \"subscription = null\");\n pattern.replaceWithText(`{ ${elementTexts.join(\", \")} }`);\n wasAdded = true;\n }\n formatLikeSource(sf);\n });\n return { source: out, wasAdded };\n}\n\nexport function modifyAppSidebar(filePath: string): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const original = fs.readFileSync(filePath, \"utf8\");\n if (\n original.includes(\"subscription?: {\") ||\n original.includes(\"subscription={subscription}\") ||\n original.includes(\"{subscription}\")\n ) {\n return { status: \"success\", changed: false };\n }\n\n const file = new SvelteFile(original);\n if (!file.hasElement(\"NavUser\")) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const scriptChanged = file.modifyScript((src) => updateScript(src).source);\n\n const templateChanged = !file.hasAttribute(\"NavUser\", \"subscription\")\n ? file.appendToAttributes(\"NavUser\", \" {subscription}\")\n : false;\n\n if (!scriptChanged && !templateChanged) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n file.writeTo(filePath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import fs from \"node:fs\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\n/**\n * Overwrites a file with the given template content, guarded by an idempotency\n * marker: if the current file already contains the marker, the modify is a\n * no-op. Used for complex rewrites where surgical AST changes aren't worth it\n * (e.g. pages that are largely replaced).\n *\n * Strips leading `// [!code highlight:N]` and `<!-- [!code highlight:N] -->`\n * lines so the same content can be shared with preview-modifies, which uses\n * those comments for documentation highlighting.\n */\nexport function modifyByTemplate(\n filePath: string,\n template: string,\n idempotencyMarker: string,\n notFoundHint: string,\n): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"not-found\", message: notFoundHint };\n }\n const current = fs.readFileSync(filePath, \"utf8\");\n if (current.includes(idempotencyMarker)) {\n return { status: \"success\", changed: false };\n }\n const stripped = template\n .replace(/^[ \\t]*\\/\\/[ \\t]*\\[!code highlight:\\d+\\][ \\t]*\\r?\\n/gm, \"\")\n .replace(\n /^[ \\t]*<!--[ \\t]*\\[!code highlight:\\d+\\][ \\t]*-->[ \\t]*\\r?\\n/gm,\n \"\",\n );\n if (current === stripped) {\n return { status: \"success\", changed: false };\n }\n fs.writeFileSync(filePath, stripped, \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import { modifyByTemplate } from \"./modify-by-template\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst NOT_FOUND_HINT = [\n \"src/routes/(app)/billing/+page.server.ts is missing.\",\n \"Enable payments first — subscriptions extends the billing page with plan management.\",\n].join(\"\\n\");\n\nexport function modifyBillingPageServer(\n filePath: string,\n template: string,\n): ModifyOutcome {\n return modifyByTemplate(filePath, template, \"selectPlan\", NOT_FOUND_HINT);\n}\n","import { modifyByTemplate } from \"./modify-by-template\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst NOT_FOUND_HINT = [\n \"src/routes/(app)/billing/+page.svelte is missing.\",\n \"Enable payments first — subscriptions extends the billing page with plan management.\",\n].join(\"\\n\");\n\nexport function modifyBillingPageSvelte(\n filePath: string,\n template: string,\n): ModifyOutcome {\n return modifyByTemplate(filePath, template, \"availablePlans\", NOT_FOUND_HINT);\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { InvalidArgumentError } from \"../../../core/errors\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { keepMissing, modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { modifyWebhookServer } from \"./modifies/modify-webhook-server\";\nimport { modifyAppLayoutServer } from \"./modifies/modify-app-layout-server\";\nimport { modifyAppLayoutSvelte } from \"./modifies/modify-app-layout-svelte\";\nimport { modifyAppSidebar } from \"./modifies/modify-app-sidebar\";\nimport { modifyNavUser } from \"./modifies/modify-nav-user\";\nimport { modifyBillingPageServer } from \"./modifies/modify-billing-page-server\";\nimport { modifyBillingPageSvelte } from \"./modifies/modify-billing-page-svelte\";\nimport stripeCustomerHelper from \"../payments/providers-app-mode/stripe/src/lib/server/stripe-customer.ts?raw\";\n\n// The billing page imports this payments helper, which apps that enabled\n// payments before it existed do not have yet.\nconst STRIPE_CUSTOMER_HELPER = \"src/lib/server/stripe-customer.ts\";\n\n// enable-payments writes the billing page (and the stripe_customers collection\n// subscriptions relate to) only when auth is already on.\nconst BILLING_PAGE = \"src/routes/(app)/billing/+page.server.ts\";\n\n/**\n * Refuses a project whose payments were enabled before auth. Every `requires`\n * flag passes there (auth and payments are both on), yet the billing page and\n * `stripe_customers` don't exist, so this runs before any collection is made.\n */\nexport function assertPaymentsAppMode(root: string): void {\n if (fs.existsSync(path.join(root, BILLING_PAGE))) return;\n throw new InvalidArgumentError(\n [\n \"Subscriptions need payments set up with auth on: they add plans to the billing page\",\n `(${BILLING_PAGE}) and link to the stripe_customers collection, which enable-payments`,\n \"creates only when auth is already enabled. This project enabled payments before auth.\",\n \"\",\n \"Re-enable payments now that auth is on: `vela disable payments`, then `vela enable payments`.\",\n \"disable-payments drops the catalog collections, which the sync workflow refills from Stripe.\",\n ].join(\"\\n\"),\n );\n}\n\n// Share the final-state files between preview (rendered as-is) and runtime\n// (used as overwrite templates for modifies that amount to full rewrites).\nconst previewRaw = import.meta.glob<string>(\"./preview-modifies/**\", {\n query: \"?raw\",\n import: \"default\",\n eager: true,\n});\n\nfunction template(relativePath: string): string {\n const key = `./preview-modifies/${relativePath}`;\n const content = previewRaw[key];\n if (content === undefined) {\n throw new Error(\n `Missing template for ${relativePath} in subscriptions preview-modifies`,\n );\n }\n return content;\n}\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(\"Modifying webhooks/stripe/handlers/dispatch.ts\");\n const webhookServerPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"webhooks\",\n \"stripe\",\n \"handlers\",\n \"dispatch.ts\",\n );\n pushResult(\n modifyOutcomeToFile(\n webhookServerPath,\n modifyWebhookServer(webhookServerPath),\n ),\n );\n\n logger.info(\"Modifying (app)/+layout.server.ts\");\n const appLayoutServerPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"+layout.server.ts\",\n );\n pushResult(\n modifyOutcomeToFile(\n appLayoutServerPath,\n modifyAppLayoutServer(\n appLayoutServerPath,\n template(\"src/routes/(app)/+layout.server.ts\"),\n ),\n ),\n );\n\n logger.info(\"Modifying (app)/+layout.svelte\");\n const appLayoutSveltePath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"+layout.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(\n appLayoutSveltePath,\n modifyAppLayoutSvelte(appLayoutSveltePath),\n ),\n );\n\n logger.info(\"Modifying app-sidebar.svelte\");\n const appSidebarPath = path.join(\n options.root,\n \"src\",\n \"lib\",\n \"components\",\n \"app-sidebar.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(appSidebarPath, modifyAppSidebar(appSidebarPath)),\n );\n\n logger.info(\"Modifying 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, modifyNavUser(navUserPath)));\n\n logger.info(\"Modifying billing/+page.server.ts\");\n const billingPageServerPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"billing\",\n \"+page.server.ts\",\n );\n pushResult(\n modifyOutcomeToFile(\n billingPageServerPath,\n modifyBillingPageServer(\n billingPageServerPath,\n template(\"src/routes/(app)/billing/+page.server.ts\"),\n ),\n ),\n );\n\n logger.info(\"Modifying billing/+page.svelte\");\n const billingPageSveltePath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"billing\",\n \"+page.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(\n billingPageSveltePath,\n modifyBillingPageSvelte(\n billingPageSveltePath,\n template(\"src/routes/(app)/billing/+page.svelte\"),\n ),\n ),\n );\n\n const creates = keepMissing(\n [\n {\n path: STRIPE_CUSTOMER_HELPER,\n language: \"ts\",\n content: stripeCustomerHelper,\n status: \"success\",\n },\n ],\n options.root,\n );\n\n return {\n creates,\n modifies,\n deletes: [],\n components: [],\n packages: [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