@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-koQxLywh.js","names":["languageFromPath","NOTIFICATION_RULE_PATCHES","withInMemoryScript","formatLikeSource","ensureImports","SvelteFile","withPocketbase","migrationDelay","getMigrationFile","modifyUtils","fs","path","BELL_SNIPPET","IMPORT_SNIPPET","FAILURE_HINT","NOT_FOUND_HINT","modifyAppLayout","layoutPath","file","out","source","sf","FETCH_STATEMENT","NOTIFICATIONS_STATEMENT","DEPENDS_STATEMENT","modifyLayoutServer","layoutServerPath","snippet","originalSource","sourceFile","Project","addProperty","obj","name","initializer","loadArrow","loadFn","varDecl","SyntaxKind","directArrow","init","innerArrow","innerFnExpr","maybeFn","fnLike","params","first","original","nameNode","obp","elementNames","el","hasDepends","hasLocals","existingParts","parts","currentName","body","blockBody","statements","declaresVar","stmt","d","hasDependsCall","ce","args","argText","hasNotificationsList","hasNotifications","returnIdx","s","insertAt","augmentReturnObject","augmentReturns","expr","ret","inner","arrowBody","bodyExpr","fnBody","pushMigrationCreates","created","migrationFile","collectionName","options","creates","generate","logger","getLogger","userCollection","pb","create","createCollectionIdempotent","spec","result","ruleMigrations","applyCollectionRulePatches","modifies","pushResult","appLayoutPath","modifyOutcomeToFile","appLayoutServerPath","utilsPath"],"sources":["../../src/patterns/enable/notifications/modifies/modify-app-layout.ts","../../src/patterns/enable/notifications/modifies/+layout.server.ts","../../src/patterns/enable/notifications/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 BELL_SNIPPET = `\n\t\t<div class=\"ml-auto px-4\">\n\t\t\t<NotificationsBell />\n\t\t</div>\n\t`;\n\nconst IMPORT_SNIPPET = dedent`\n import NotificationsBell from '#lib/components/notifications-bell.svelte';\n`;\n\nconst FAILURE_HINT = [\n \"Add the notifications bell inside the (app) layout's <header>.\",\n \"\",\n \"Imports to add to the <script> tag:\",\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup to add inside <header>:\",\n BELL_SNIPPET,\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create src/routes/(app)/+layout.svelte with a <header> that includes the bell.\",\n \"\",\n \"Imports for the <script> tag:\",\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup inside <header>:\",\n BELL_SNIPPET,\n].join(\"\\n\");\n\nexport function modifyAppLayout(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(\"header\")) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n if (file.hasElement(\"NotificationsBell\")) {\n return { status: \"success\", changed: false };\n }\n\n file.modifyScript((source) => {\n const { source: out } = withInMemoryScript(source, (sf) => {\n ensureImports(sf, [\n {\n defaultImport: \"NotificationsBell\",\n moduleSpecifier: \"#lib/components/notifications-bell.svelte\",\n },\n ]);\n });\n return out;\n });\n\n file.insertBeforeClosingTag(\"header\", BELL_SNIPPET);\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { Project, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { formatLikeSource } from \"../../../../runtime/ts-morph-helpers\";\n\nconst FETCH_STATEMENT = dedent`\n const notificationsList = await locals.pb\n .collection(\"notifications\")\n .getList(1, 5, {\n filter: \\`user = \"\\${locals.pb.authStore.record!.id}\" && read = false\\`,\n sort: \"-created\",\n });\n`;\n\nconst NOTIFICATIONS_STATEMENT =\n \"const notifications = { count: notificationsList.totalItems, items: notificationsList.items };\";\n\nconst DEPENDS_STATEMENT = 'depends(\"app:notifications\");';\n\nexport function modifyLayoutServer(layoutServerPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutServerPath)) {\n const snippet = dedent`\n export const load = async ({ locals, depends }) => {\n ${FETCH_STATEMENT}\n ${NOTIFICATIONS_STATEMENT}\n ${DEPENDS_STATEMENT}\n return { notifications };\n };\n `;\n fs.writeFileSync(layoutServerPath, snippet);\n return { status: \"success\", changed: true };\n }\n\n const originalSource = fs.readFileSync(layoutServerPath, \"utf8\");\n const project = new Project();\n const sourceFile = project.addSourceFileAtPath(layoutServerPath);\n\n const addProperty = (\n obj: import(\"ts-morph\").ObjectLiteralExpression,\n name: string,\n initializer: string,\n ) => {\n if (obj.getProperty(name)) return;\n if (name === initializer) {\n obj.addShorthandPropertyAssignment({ name });\n } else {\n obj.addPropertyAssignment({ name, initializer });\n }\n };\n\n let loadArrow: import(\"ts-morph\").ArrowFunction | undefined;\n let loadFn:\n | import(\"ts-morph\").FunctionDeclaration\n | import(\"ts-morph\").FunctionExpression\n | undefined;\n\n const varDecl = sourceFile.getVariableDeclaration(\"load\");\n if (varDecl) {\n const vs = varDecl.getFirstAncestorByKind(SyntaxKind.VariableStatement);\n if (vs?.hasExportKeyword()) {\n const directArrow = varDecl.getInitializerIfKind(\n SyntaxKind.ArrowFunction,\n );\n if (directArrow) {\n loadArrow = directArrow;\n } else {\n const init = varDecl.getInitializer();\n if (init) {\n const innerArrow = init.getFirstDescendantByKind(\n SyntaxKind.ArrowFunction,\n );\n if (innerArrow) {\n loadArrow = innerArrow;\n } else {\n const innerFnExpr = init.getFirstDescendantByKind(\n SyntaxKind.FunctionExpression,\n );\n if (innerFnExpr) loadFn = innerFnExpr;\n }\n }\n }\n }\n }\n\n if (!loadArrow && !loadFn) {\n const maybeFn = sourceFile.getFunction(\"load\");\n if (maybeFn && maybeFn.isExported()) loadFn = maybeFn;\n }\n\n if (!loadArrow && !loadFn) {\n sourceFile.addFunction({\n isExported: true,\n isAsync: true,\n name: \"load\",\n parameters: [{ name: \"{ locals, depends }\" }],\n statements: [\n FETCH_STATEMENT,\n NOTIFICATIONS_STATEMENT,\n DEPENDS_STATEMENT,\n \"return { notifications };\",\n ],\n });\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n }\n\n const fnLike = (loadArrow ?? loadFn!) as\n | import(\"ts-morph\").ArrowFunction\n | import(\"ts-morph\").FunctionDeclaration\n | import(\"ts-morph\").FunctionExpression;\n\n // Ensure first param destructures { locals, depends }\n const params = fnLike.getParameters();\n if (params.length === 0) {\n fnLike.insertParameter(0, { name: \"{ locals, depends }\" });\n } else {\n const first = params[0];\n const original = first.getStructure();\n const nameNode = first.getNameNode();\n if (nameNode.getKind() === SyntaxKind.ObjectBindingPattern) {\n const obp = nameNode as import(\"ts-morph\").ObjectBindingPattern;\n const elementNames = obp.getElements().map((el) => el.getName());\n const hasDepends = elementNames.includes(\"depends\");\n const hasLocals = elementNames.includes(\"locals\");\n\n if (!hasDepends || !hasLocals) {\n const existingParts = obp\n .getElements()\n .map((el) => el.getText())\n .filter(Boolean);\n const parts: string[] = hasLocals ? [] : [\"locals\"];\n parts.push(...existingParts);\n if (!hasDepends) parts.push(\"depends\");\n first.set({\n name: `{ ${parts.join(\", \")} }`,\n type: original.type,\n initializer: (original as { initializer?: string }).initializer,\n });\n }\n } else {\n const currentName = first.getName();\n if (currentName !== \"locals\") {\n first.set({\n name: `{ locals, depends, ...${currentName} }`,\n type: original.type,\n initializer: (original as { initializer?: string }).initializer,\n });\n } else {\n first.set({\n name: `{ locals, depends }`,\n type: original.type,\n initializer: (original as { initializer?: string }).initializer,\n });\n }\n }\n }\n\n if (loadArrow && !loadArrow.isAsync()) loadArrow.setIsAsync(true);\n else if (loadFn && !loadFn.isAsync()) loadFn.setIsAsync(true);\n\n const body = fnLike.getBody();\n if (body && body.getKind() === SyntaxKind.Block) {\n const blockBody = body as import(\"ts-morph\").Block;\n const statements = blockBody.getStatements();\n\n const declaresVar = (name: string) =>\n statements.some((stmt) => {\n if (stmt.getKind() !== SyntaxKind.VariableStatement) return false;\n return (stmt as import(\"ts-morph\").VariableStatement)\n .getDeclarations()\n .some((d) => d.getName() === name);\n });\n\n const hasDependsCall = statements.some(\n (stmt) =>\n stmt.getKind() === SyntaxKind.ExpressionStatement &&\n stmt.getDescendantsOfKind(SyntaxKind.CallExpression).some((ce) => {\n if (ce.getExpression().getText() !== \"depends\") return false;\n const args = ce.getArguments();\n const argText = args[0]?.getText() ?? \"\";\n return (\n args.length === 1 &&\n (argText === \"'app:notifications'\" ||\n argText === '\"app:notifications\"')\n );\n }),\n );\n\n const hasNotificationsList = declaresVar(\"notificationsList\");\n const hasNotifications = declaresVar(\"notifications\");\n\n const returnIdx = statements.findIndex(\n (s) => s.getKind() === SyntaxKind.ReturnStatement,\n );\n let insertAt = returnIdx >= 0 ? returnIdx : statements.length;\n\n if (!hasNotificationsList) {\n blockBody.insertStatements(insertAt, FETCH_STATEMENT);\n insertAt++;\n }\n if (!hasNotifications) {\n blockBody.insertStatements(insertAt, NOTIFICATIONS_STATEMENT);\n insertAt++;\n }\n if (!hasDependsCall) {\n blockBody.insertStatements(insertAt, DEPENDS_STATEMENT);\n }\n }\n\n const augmentReturnObject = (\n obj: import(\"ts-morph\").ObjectLiteralExpression,\n ) => {\n addProperty(obj, \"notifications\", \"notifications\");\n };\n\n const augmentReturns = (target: import(\"ts-morph\").Node) => {\n const returns = target.getDescendantsOfKind(SyntaxKind.ReturnStatement);\n returns.forEach((ret) => {\n const expr = ret.getExpression();\n if (!expr) return;\n if (expr.getKind() === SyntaxKind.ObjectLiteralExpression) {\n augmentReturnObject(expr as import(\"ts-morph\").ObjectLiteralExpression);\n } else if (expr.getKind() === SyntaxKind.ParenthesizedExpression) {\n const inner = (\n expr as import(\"ts-morph\").ParenthesizedExpression\n ).getExpression();\n if (inner.getKind() === SyntaxKind.ObjectLiteralExpression) {\n augmentReturnObject(\n inner as import(\"ts-morph\").ObjectLiteralExpression,\n );\n }\n }\n });\n };\n\n if (loadArrow) {\n const arrowBody = loadArrow.getBody();\n if (arrowBody.getKind() === SyntaxKind.Block) {\n augmentReturns(arrowBody);\n } else {\n const bodyExpr = arrowBody as import(\"ts-morph\").Expression;\n if (bodyExpr.getKind() === SyntaxKind.ParenthesizedExpression) {\n const inner = (\n bodyExpr as import(\"ts-morph\").ParenthesizedExpression\n ).getExpression();\n if (inner.getKind() === SyntaxKind.ObjectLiteralExpression) {\n augmentReturnObject(\n inner as import(\"ts-morph\").ObjectLiteralExpression,\n );\n }\n } else if (bodyExpr.getKind() === SyntaxKind.ObjectLiteralExpression) {\n augmentReturnObject(\n bodyExpr as import(\"ts-morph\").ObjectLiteralExpression,\n );\n }\n }\n } else if (loadFn) {\n const fnBody = loadFn.getBody();\n if (fnBody) augmentReturns(fnBody);\n }\n\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\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 { languageFromPath } from \"../../../core/util\";\nimport {\n applyCollectionRulePatches,\n createCollectionIdempotent,\n} from \"../../../runtime/collections\";\nimport {\n getMigrationFile,\n migrationDelay,\n withPocketbase,\n} from \"../../../runtime/pocketbase\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { modifyUtils } from \"../../../runtime/modify-utils\";\nimport { modifyAppLayout } from \"./modifies/modify-app-layout\";\nimport { modifyLayoutServer } from \"./modifies/+layout.server\";\nimport { NOTIFICATION_RULE_PATCHES } from \"./runtime/pocketbase\";\n\nasync function pushMigrationCreates(\n creates: File[],\n collectionName: string,\n options: Options,\n created = true,\n) {\n if (!created) return;\n await migrationDelay();\n const migrationFile = getMigrationFile(collectionName, \"created\", options);\n if (!migrationFile) return;\n creates.push({\n path: migrationFile,\n language: languageFromPath(migrationFile),\n content: fs.readFileSync(migrationFile, \"utf8\"),\n status: \"success\",\n });\n}\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 const userCollection = await pb.collections.getOne(\"users\");\n const create = (spec: Parameters<typeof createCollectionIdempotent>[1]) =>\n createCollectionIdempotent(pb, spec, logger);\n\n logger.info(\"Creating notifications collection\");\n const result = await create({\n name: \"notifications\",\n type: \"base\",\n fields: [\n {\n name: \"id\",\n type: \"text\",\n primaryKey: true,\n autogeneratePattern: \"[a-z0-9]{15}\",\n max: 15,\n min: 15,\n pattern: \"^[a-z0-9]+$\",\n required: true,\n },\n {\n name: \"user\",\n type: \"relation\",\n cascadeDelete: true,\n collectionId: userCollection.id,\n maxSelect: 1,\n minSelect: 0,\n required: true,\n },\n {\n name: \"title\",\n type: \"text\",\n required: true,\n },\n {\n name: \"body\",\n type: \"text\",\n },\n {\n name: \"read\",\n type: \"bool\",\n },\n {\n name: \"created\",\n type: \"autodate\",\n onCreate: true,\n onUpdate: false,\n },\n {\n name: \"updated\",\n type: \"autodate\",\n onCreate: true,\n onUpdate: true,\n },\n ],\n indexes: [\n \"CREATE INDEX `idx_notifications_user_read_created` ON `notifications` (`user`, `read`, `created` DESC)\",\n ],\n });\n await pushMigrationCreates(\n creates,\n \"notifications\",\n options,\n result.created,\n );\n\n logger.info(\"Applying notifications rule patches\");\n const ruleMigrations = await applyCollectionRulePatches(\n pb,\n NOTIFICATION_RULE_PATCHES,\n options,\n logger,\n );\n creates.push(...ruleMigrations);\n });\n\n const modifies: File[] = [];\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Modifying (app) +layout.svelte\");\n const appLayoutPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"+layout.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(appLayoutPath, modifyAppLayout(appLayoutPath)),\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 modifyLayoutServer(appLayoutServerPath),\n ),\n );\n\n logger.info(\"Modifying utils.ts\");\n const utilsPath = path.join(options.root, \"src\", \"lib\", \"utils.ts\");\n pushResult(modifyOutcomeToFile(utilsPath, modifyUtils(utilsPath)));\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,IAAMY,IAAe,2EAMfC,IAAiB,CAAM;;GAIvBC,IAAe;CACnB;CACA;CACA;CACA;CACAD;CACA;CACA;CACAD;AACF,CAAC,CAAC,KAAK,IAAI,GAELG,IAAiB;CACrB;CACA;CACA;CACA;CACAF;CACA;CACA;CACAD;AACF,CAAC,CAAC,KAAK,IAAI;AAEX,SAAgBI,EAAgB,GAAmC;CACjE,IAAI,CAACN,EAAG,WAAWO,CAAU,GAC3B,OAAO;EAAE,QAAQ;EAAa,SAASF;CAAe;CAGxD,IAAMG,IAAOb,EAAW,SAASY,CAAU;CAsB3C,OArBKC,EAAK,WAAW,QAAQ,IAGzBA,EAAK,WAAW,mBAAmB,IAC9B;EAAE,QAAQ;EAAW,SAAS;CAAM,KAG7CA,EAAK,cAAc,MAAW;EAC5B,IAAM,EAAE,QAAQC,MAAQjB,EAA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A,EAAO,KAAK,gCAAgC;CAC5C,IAAMiF,IAAgBxF,EAAK,KACzByE,EAAQ,MACR,OACA,UACA,SACA,gBACF;CAKA,AAJAc,EACEE,EAAoBD,GAAenF,EAAgBmF,CAAa,CAAC,CACnE,GAEAZ,EAAO,KAAK,mCAAmC;CAC/C,IAAMc,IAAsB1F,EAAK,KAC/ByE,EAAQ,MACR,OACA,UACA,SACA,mBACF;CAQA,AAPAc,EACEE,EACEC,GACA5E,EAAmB4E,CAAmB,CACxC,CACF,GAEAd,EAAO,KAAK,oBAAoB;CAChC,IAAMe,IAAY3F,EAAK,KAAKyE,EAAQ,MAAM,OAAO,OAAO,UAAU;CAGlE,OAFAc,EAAWE,EAAoBE,GAAW7F,EAAY6F,CAAS,CAAC,CAAC,GAE1D;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 { t as e } from "./dedent-Gq6Krl4n.js";
|
|
2
|
-
import { t } from "./taggedTemplateLiteral-
|
|
2
|
+
import { t } from "./taggedTemplateLiteral-CswN2AAa.js";
|
|
3
3
|
import { n } from "./logger-CQONztPm.js";
|
|
4
|
-
import { r } from "./ts-morph-helpers-
|
|
5
|
-
import { modifyOutcomeToFile as i } from "./modify-file-
|
|
4
|
+
import { r } from "./ts-morph-helpers-Bepc-Es2.js";
|
|
5
|
+
import { modifyOutcomeToFile as i } from "./modify-file-DK-tCH9k.js";
|
|
6
6
|
import { t as a } from "./svelte-file-B3RfgVdt.js";
|
|
7
|
-
import { t as o } from "./site-
|
|
8
|
-
import { i as s } from "./config-target-
|
|
7
|
+
import { t as o } from "./site-lj0CDdQ1.js";
|
|
8
|
+
import { i as s } from "./config-target-rHgjaA8u.js";
|
|
9
9
|
import c from "node:fs";
|
|
10
10
|
import l from "node:path";
|
|
11
11
|
import { SyntaxKind as u } from "ts-morph";
|
|
@@ -173,4 +173,4 @@ async function T(e) {
|
|
|
173
173
|
//#endregion
|
|
174
174
|
export { T as generate };
|
|
175
175
|
|
|
176
|
-
//# sourceMappingURL=generate.runtime-
|
|
176
|
+
//# sourceMappingURL=generate.runtime-rs1ZOIET.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.runtime-BXkZob1O.js","names":[],"sources":["../../src/patterns/enable/blog/modifies/vite-config.ts","../../src/patterns/enable/blog/modifies/root-layout-svelte.ts","../../src/patterns/enable/blog/modifies/public-root-layout-svelte.ts","../../src/patterns/enable/blog/generate.runtime.ts"],"sourcesContent":["import dedent from \"dedent\";\nimport {\n SyntaxKind,\n type ArrayLiteralExpression,\n type ObjectLiteralExpression,\n} from \"ts-morph\";\nimport {\n modifyConfig,\n type ConfigModifyResult,\n} from \"../../../../runtime/config-target\";\nimport { ensureImports } from \"../../../../runtime/ts-morph-helpers\";\n\nconst FAILURE_HINT = dedent`\n Enable mdsvex in your config (the sveltekit() arg in vite.config):\n\n import { mdsvex } from 'mdsvex';\n\n // ...\n extensions: ['.svelte', '.svx'],\n preprocess: [mdsvex()],\n`;\n\nconst NOT_FOUND_HINT = dedent`\n Enable mdsvex by passing config to the sveltekit() plugin in vite.config.ts:\n\n import { sveltekit } from '@sveltejs/kit/vite';\n import { mdsvex } from 'mdsvex';\n import { defineConfig } from 'vite';\n\n export default defineConfig({\n plugins: [\n sveltekit({\n extensions: ['.svelte', '.svx'],\n preprocess: [mdsvex()],\n }),\n ],\n });\n`;\n\nfunction ensureExtensionsSvx(obj: ObjectLiteralExpression): boolean {\n const existing = obj.getProperty(\"extensions\");\n if (!existing) {\n obj.addPropertyAssignment({\n name: \"extensions\",\n initializer: \"['.svelte', '.svx']\",\n });\n return true;\n }\n if (existing.getKind() !== SyntaxKind.PropertyAssignment) return false;\n const init = (\n existing as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n if (!init || init.getKind() !== SyntaxKind.ArrayLiteralExpression) {\n (existing as import(\"ts-morph\").PropertyAssignment).setInitializer(\n \"['.svelte', '.svx']\",\n );\n return true;\n }\n const arr = init as ArrayLiteralExpression;\n const hasSvx = arr\n .getElements()\n .some((el) => el.getText().replace(/['\"`]/g, \"\") === \".svx\");\n if (hasSvx) return false;\n arr.addElement(\"'.svx'\");\n return true;\n}\n\nfunction ensurePreprocessMdsvex(obj: ObjectLiteralExpression): boolean {\n const existing = obj.getProperty(\"preprocess\");\n if (!existing) {\n obj.addPropertyAssignment({\n name: \"preprocess\",\n initializer: \"[mdsvex()]\",\n });\n return true;\n }\n if (existing.getKind() !== SyntaxKind.PropertyAssignment) return false;\n const init = (\n existing as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n if (!init) {\n (existing as import(\"ts-morph\").PropertyAssignment).setInitializer(\n \"[mdsvex()]\",\n );\n return true;\n }\n if (init.getKind() === SyntaxKind.ArrayLiteralExpression) {\n const arr = init as ArrayLiteralExpression;\n const hasMdsvex = arr\n .getElements()\n .some((el) => /\\bmdsvex\\s*\\(/.test(el.getText()));\n if (hasMdsvex) return false;\n arr.addElement(\"mdsvex()\");\n return true;\n }\n const text = init.getText();\n if (/\\bmdsvex\\s*\\(/.test(text)) return false;\n (existing as import(\"ts-morph\").PropertyAssignment).setInitializer(\n `[${text}, mdsvex()]`,\n );\n return true;\n}\n\n/**\n * Enable mdsvex: ensure `extensions` includes `.svx`, `preprocess` includes\n * `mdsvex()`, and the `mdsvex` import is present, at the top level of the\n * inline sveltekit() arg in vite.config.\n */\nexport function modifyViteConfigMdsvex(root: string): ConfigModifyResult {\n return modifyConfig(\n root,\n { notFound: NOT_FOUND_HINT, failed: FAILURE_HINT },\n (target) => {\n ensureExtensionsSvx(target.configObject);\n ensurePreprocessMdsvex(target.configObject);\n ensureImports(target.sourceFile, [\n { namedImports: [\"mdsvex\"], moduleSpecifier: \"mdsvex\" },\n ]);\n return true;\n },\n );\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst PRISM_IMPORT = `import '../css/prism-vsc-dark-plus.css';`;\n\nconst NOT_FOUND_HINT = dedent`\n Create src/routes/+layout.svelte and import the Prism theme for\n code block highlighting in blog posts:\n\n <script lang=\"ts\">\n import '../app.css';\n ${PRISM_IMPORT}\n </script>\n`;\n\nconst FAILURE_HINT = dedent`\n Import the Prism theme in your root +layout.svelte for blog code\n block highlighting:\n\n ${PRISM_IMPORT}\n`;\n\nexport function modifyRootLayoutSvelte(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 const script = file.getScript();\n if (!script) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n if (script.content.includes(\"prism-vsc-dark-plus.css\")) {\n return { status: \"success\", changed: false };\n }\n\n file.modifyScript((source) => {\n const appCssMatch = source.match(\n /^(\\s*)import\\s+['\"][^'\"]*app\\.css['\"];?\\s*$/m,\n );\n if (appCssMatch) {\n const indent = appCssMatch[1] ?? \"\";\n const insertion = `\\n${indent}${PRISM_IMPORT}`;\n const end = (appCssMatch.index ?? 0) + appCssMatch[0].length;\n return source.slice(0, end) + insertion + source.slice(end);\n }\n return source.replace(/^/, `\\n\\t${PRISM_IMPORT}\\n`);\n });\n\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst BLOG_NAVBAR_ITEM = `\n\t\t<Navbar.Item>\n\t\t\t<Button class=\"w-full justify-start md:justify-center md:w-auto\" href=\"/blog\" variant=\"ghost\">\n\t\t\t\tBlog\n\t\t\t</Button>\n\t\t</Navbar.Item>\n\t`;\n\nconst FAILURE_HINT = dedent`\n Add a Blog link inside <Navbar.List> in the public root layout:\n\n <Navbar.Item>\n <Button class=\"w-full justify-start md:justify-center md:w-auto\" href=\"/blog\" variant=\"ghost\">\n Blog\n </Button>\n </Navbar.Item>\n`;\n\nconst NOT_FOUND_HINT = dedent`\n Create a public root layout with a Blog link in its Navbar.List:\n\n <Navbar.Item>\n <Button class=\"w-full justify-start md:justify-center md:w-auto\" href=\"/blog\" variant=\"ghost\">\n Blog\n </Button>\n </Navbar.Item>\n`;\n\nexport function modifyPublicRootLayout(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(\"Navbar.List\")) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const raw = fs.readFileSync(layoutPath, \"utf8\");\n if (/href=[\"']\\/blog[\"']/.test(raw)) {\n return { status: \"success\", changed: false };\n }\n\n file.insertBeforeClosingTag(\"Navbar.List\", BLOG_NAVBAR_ITEM);\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import path from \"node:path\";\nimport fs from \"node:fs\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { ensureSiteFile } from \"../../../runtime/site\";\nimport { modifyViteConfigMdsvex } from \"./modifies/vite-config\";\nimport { modifyRootLayoutSvelte } from \"./modifies/root-layout-svelte\";\nimport { modifyPublicRootLayout } from \"./modifies/public-root-layout-svelte\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Modifying vite.config for mdsvex\");\n const mdsvex = modifyViteConfigMdsvex(options.root);\n pushResult(modifyOutcomeToFile(mdsvex.filePath, mdsvex.outcome));\n\n logger.info(\"Modifying src/routes/+layout.svelte\");\n const rootLayoutPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(rootLayoutPath, modifyRootLayoutSvelte(rootLayoutPath)),\n );\n\n logger.info(\"Modifying public root layout\");\n const publicLayoutCandidates = [\n path.join(options.root, \"src\", \"routes\", \"(public)\", \"root-layout.svelte\"),\n path.join(options.root, \"src\", \"routes\", \"root-layout.svelte\"),\n path.join(options.root, \"src\", \"routes\", \"(public)\", \"+layout.svelte\"),\n ];\n const publicLayoutPath =\n publicLayoutCandidates.find((p) => fs.existsSync(p)) ??\n publicLayoutCandidates[0];\n pushResult(\n modifyOutcomeToFile(\n publicLayoutPath,\n modifyPublicRootLayout(publicLayoutPath),\n ),\n );\n\n // The RSS feed is titled and linked from `src/lib/site.ts`.\n const siteFile = await ensureSiteFile(options);\n\n return {\n creates: siteFile ? [siteFile] : [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;;;;;AAYA,IAAM,IAAe,CAAM;;;;;;;;GAUrB,IAAiB,CAAM;;;;;;;;;;;;;;;;AAiB7B,SAAS,EAAoB,GAAuC;CAClE,IAAM,IAAW,EAAI,YAAY,YAAY;CAC7C,IAAI,CAAC,GAKH,OAJA,EAAI,sBAAsB;EACxB,MAAM;EACN,aAAa;CACf,CAAC,GACM;CAET,IAAI,EAAS,QAAQ,MAAM,EAAW,oBAAoB,OAAO;CACjE,IAAM,IACJ,EACA,eAAe;CACjB,IAAI,CAAC,KAAQ,EAAK,QAAQ,MAAM,EAAW,wBAIzC,OAHA,EAAoD,eAClD,qBACF,GACO;CAET,IAAM,IAAM;CAMZ,OAFA,CAHe,EACZ,YAAY,CAAC,CACb,MAAM,MAAO,EAAG,QAAQ,CAAC,CAAC,QAAQ,UAAU,EAAE,MAAM,MACnD,MACJ,EAAI,WAAW,QAAQ,GAChB;AACT;AAEA,SAAS,EAAuB,G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AM,IAAiB,EAAK,KAC1B,EAAQ,MACR,OACA,UACA,gBACF;CAKA,AAJA,EACE,EAAoB,GAAgB,EAAuB,CAAc,CAAC,CAC5E,GAEA,EAAO,KAAK,8BAA8B;CAC1C,IAAM,IAAyB;EAC7B,EAAK,KAAK,EAAQ,MAAM,OAAO,UAAU,YAAY,oBAAoB;EACzE,EAAK,KAAK,EAAQ,MAAM,OAAO,UAAU,oBAAoB;EAC7D,EAAK,KAAK,EAAQ,MAAM,OAAO,UAAU,YAAY,gBAAgB;CACvE,GACM,IACJ,EAAuB,MAAM,MAAM,EAAG,WAAW,CAAC,CAAC,KACnD,EAAuB;CACzB,EACE,EACE,GACA,EAAuB,CAAgB,CACzC,CACF;CAGA,IAAM,IAAW,MAAM,EAAe,CAAO;CAE7C,OAAO;EACL,SAAS,IAAW,CAAC,CAAQ,IAAI,CAAC;EAClC;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
|
|
1
|
+
{"version":3,"file":"generate.runtime-rs1ZOIET.js","names":["FAILURE_HINT","NOT_FOUND_HINT","NOT_FOUND_HINT","FAILURE_HINT","dedent","SvelteFile","ensureSiteFile","modifyConfig","fs","path","FAILURE_HINT$2","NOT_FOUND_HINT$2","ensureExtensionsSvx","existing","obj","SyntaxKind","init","arr","el","ensurePreprocessMdsvex","text","modifyViteConfigMdsvex","root","target","ensureImports","_templateObject","PRISM_IMPORT","NOT_FOUND_HINT$1","_taggedTemplateLiteral","FAILURE_HINT$1","modifyRootLayoutSvelte","layoutPath","file","script","appCssMatch","source","insertion","end","BLOG_NAVBAR_ITEM","FAILURE_HINT","NOT_FOUND_HINT","modifyPublicRootLayout","raw","generate","logger","getLogger","options","modifies","pushResult","mdsvex","modifyOutcomeToFile","rootLayoutPath","publicLayoutCandidates","publicLayoutPath","p","siteFile"],"sources":["../../src/patterns/enable/blog/modifies/vite-config.ts","../../src/patterns/enable/blog/modifies/root-layout-svelte.ts","../../src/patterns/enable/blog/modifies/public-root-layout-svelte.ts","../../src/patterns/enable/blog/generate.runtime.ts"],"sourcesContent":["import dedent from \"dedent\";\nimport {\n SyntaxKind,\n type ArrayLiteralExpression,\n type ObjectLiteralExpression,\n} from \"ts-morph\";\nimport {\n modifyConfig,\n type ConfigModifyResult,\n} from \"../../../../runtime/config-target\";\nimport { ensureImports } from \"../../../../runtime/ts-morph-helpers\";\n\nconst FAILURE_HINT = dedent`\n Enable mdsvex in your config (the sveltekit() arg in vite.config):\n\n import { mdsvex } from 'mdsvex';\n\n // ...\n extensions: ['.svelte', '.svx'],\n preprocess: [mdsvex()],\n`;\n\nconst NOT_FOUND_HINT = dedent`\n Enable mdsvex by passing config to the sveltekit() plugin in vite.config.ts:\n\n import { sveltekit } from '@sveltejs/kit/vite';\n import { mdsvex } from 'mdsvex';\n import { defineConfig } from 'vite';\n\n export default defineConfig({\n plugins: [\n sveltekit({\n extensions: ['.svelte', '.svx'],\n preprocess: [mdsvex()],\n }),\n ],\n });\n`;\n\nfunction ensureExtensionsSvx(obj: ObjectLiteralExpression): boolean {\n const existing = obj.getProperty(\"extensions\");\n if (!existing) {\n obj.addPropertyAssignment({\n name: \"extensions\",\n initializer: \"['.svelte', '.svx']\",\n });\n return true;\n }\n if (existing.getKind() !== SyntaxKind.PropertyAssignment) return false;\n const init = (\n existing as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n if (!init || init.getKind() !== SyntaxKind.ArrayLiteralExpression) {\n (existing as import(\"ts-morph\").PropertyAssignment).setInitializer(\n \"['.svelte', '.svx']\",\n );\n return true;\n }\n const arr = init as ArrayLiteralExpression;\n const hasSvx = arr\n .getElements()\n .some((el) => el.getText().replace(/['\"`]/g, \"\") === \".svx\");\n if (hasSvx) return false;\n arr.addElement(\"'.svx'\");\n return true;\n}\n\nfunction ensurePreprocessMdsvex(obj: ObjectLiteralExpression): boolean {\n const existing = obj.getProperty(\"preprocess\");\n if (!existing) {\n obj.addPropertyAssignment({\n name: \"preprocess\",\n initializer: \"[mdsvex()]\",\n });\n return true;\n }\n if (existing.getKind() !== SyntaxKind.PropertyAssignment) return false;\n const init = (\n existing as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n if (!init) {\n (existing as import(\"ts-morph\").PropertyAssignment).setInitializer(\n \"[mdsvex()]\",\n );\n return true;\n }\n if (init.getKind() === SyntaxKind.ArrayLiteralExpression) {\n const arr = init as ArrayLiteralExpression;\n const hasMdsvex = arr\n .getElements()\n .some((el) => /\\bmdsvex\\s*\\(/.test(el.getText()));\n if (hasMdsvex) return false;\n arr.addElement(\"mdsvex()\");\n return true;\n }\n const text = init.getText();\n if (/\\bmdsvex\\s*\\(/.test(text)) return false;\n (existing as import(\"ts-morph\").PropertyAssignment).setInitializer(\n `[${text}, mdsvex()]`,\n );\n return true;\n}\n\n/**\n * Enable mdsvex: ensure `extensions` includes `.svx`, `preprocess` includes\n * `mdsvex()`, and the `mdsvex` import is present, at the top level of the\n * inline sveltekit() arg in vite.config.\n */\nexport function modifyViteConfigMdsvex(root: string): ConfigModifyResult {\n return modifyConfig(\n root,\n { notFound: NOT_FOUND_HINT, failed: FAILURE_HINT },\n (target) => {\n ensureExtensionsSvx(target.configObject);\n ensurePreprocessMdsvex(target.configObject);\n ensureImports(target.sourceFile, [\n { namedImports: [\"mdsvex\"], moduleSpecifier: \"mdsvex\" },\n ]);\n return true;\n },\n );\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst PRISM_IMPORT = `import '../css/prism-vsc-dark-plus.css';`;\n\nconst NOT_FOUND_HINT = dedent`\n Create src/routes/+layout.svelte and import the Prism theme for\n code block highlighting in blog posts:\n\n <script lang=\"ts\">\n import '../app.css';\n ${PRISM_IMPORT}\n </script>\n`;\n\nconst FAILURE_HINT = dedent`\n Import the Prism theme in your root +layout.svelte for blog code\n block highlighting:\n\n ${PRISM_IMPORT}\n`;\n\nexport function modifyRootLayoutSvelte(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 const script = file.getScript();\n if (!script) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n if (script.content.includes(\"prism-vsc-dark-plus.css\")) {\n return { status: \"success\", changed: false };\n }\n\n file.modifyScript((source) => {\n const appCssMatch = source.match(\n /^(\\s*)import\\s+['\"][^'\"]*app\\.css['\"];?\\s*$/m,\n );\n if (appCssMatch) {\n const indent = appCssMatch[1] ?? \"\";\n const insertion = `\\n${indent}${PRISM_IMPORT}`;\n const end = (appCssMatch.index ?? 0) + appCssMatch[0].length;\n return source.slice(0, end) + insertion + source.slice(end);\n }\n return source.replace(/^/, `\\n\\t${PRISM_IMPORT}\\n`);\n });\n\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst BLOG_NAVBAR_ITEM = `\n\t\t<Navbar.Item>\n\t\t\t<Button class=\"w-full justify-start md:justify-center md:w-auto\" href=\"/blog\" variant=\"ghost\">\n\t\t\t\tBlog\n\t\t\t</Button>\n\t\t</Navbar.Item>\n\t`;\n\nconst FAILURE_HINT = dedent`\n Add a Blog link inside <Navbar.List> in the public root layout:\n\n <Navbar.Item>\n <Button class=\"w-full justify-start md:justify-center md:w-auto\" href=\"/blog\" variant=\"ghost\">\n Blog\n </Button>\n </Navbar.Item>\n`;\n\nconst NOT_FOUND_HINT = dedent`\n Create a public root layout with a Blog link in its Navbar.List:\n\n <Navbar.Item>\n <Button class=\"w-full justify-start md:justify-center md:w-auto\" href=\"/blog\" variant=\"ghost\">\n Blog\n </Button>\n </Navbar.Item>\n`;\n\nexport function modifyPublicRootLayout(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(\"Navbar.List\")) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const raw = fs.readFileSync(layoutPath, \"utf8\");\n if (/href=[\"']\\/blog[\"']/.test(raw)) {\n return { status: \"success\", changed: false };\n }\n\n file.insertBeforeClosingTag(\"Navbar.List\", BLOG_NAVBAR_ITEM);\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import path from \"node:path\";\nimport fs from \"node:fs\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { ensureSiteFile } from \"../../../runtime/site\";\nimport { modifyViteConfigMdsvex } from \"./modifies/vite-config\";\nimport { modifyRootLayoutSvelte } from \"./modifies/root-layout-svelte\";\nimport { modifyPublicRootLayout } from \"./modifies/public-root-layout-svelte\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Modifying vite.config for mdsvex\");\n const mdsvex = modifyViteConfigMdsvex(options.root);\n pushResult(modifyOutcomeToFile(mdsvex.filePath, mdsvex.outcome));\n\n logger.info(\"Modifying src/routes/+layout.svelte\");\n const rootLayoutPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(rootLayoutPath, modifyRootLayoutSvelte(rootLayoutPath)),\n );\n\n logger.info(\"Modifying public root layout\");\n const publicLayoutCandidates = [\n path.join(options.root, \"src\", \"routes\", \"(public)\", \"root-layout.svelte\"),\n path.join(options.root, \"src\", \"routes\", \"root-layout.svelte\"),\n path.join(options.root, \"src\", \"routes\", \"(public)\", \"+layout.svelte\"),\n ];\n const publicLayoutPath =\n publicLayoutCandidates.find((p) => fs.existsSync(p)) ??\n publicLayoutCandidates[0];\n pushResult(\n modifyOutcomeToFile(\n publicLayoutPath,\n modifyPublicRootLayout(publicLayoutPath),\n ),\n );\n\n // The RSS feed is titled and linked from `src/lib/site.ts`.\n const siteFile = await ensureSiteFile(options);\n\n return {\n creates: siteFile ? [siteFile] : [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;;;;;AAYA,IAAMA,IAAe,CAAM;;;;;;;;GAUrBC,IAAiB,CAAM;;;;;;;;;;;;;;;;AAiB7B,SAASW,EAAoB,GAAuC;CAClE,IAAMC,IAAWC,EAAI,YAAY,YAAY;CAC7C,IAAI,CAACD,GAKH,OAJAC,EAAI,sBAAsB;EACxB,MAAM;EACN,aAAa;CACf,CAAC,GACM;CAET,IAAID,EAAS,QAAQ,MAAME,EAAW,oBAAoB,OAAO;CACjE,IAAMC,IACJH,EACA,eAAe;CACjB,IAAI,CAACG,KAAQA,EAAK,QAAQ,MAAMD,EAAW,wBAIzC,OAHAF,EAAoD,eAClD,qBACF,GACO;CAET,IAAMI,IAAMD;CAMZ,OAFA,CAHeC,EACZ,YAAY,CAAC,CACb,MAAM,MAAOC,EAAG,QAAQ,CAAC,CAAC,QAAQ,UAAU,EAAE,MAAM,MACnD,MACJD,EAAI,WAAW,QAAQ,GAChB;AACT;AAEA,SAASE,EAAuB,GAAuC;CACrE,IAAMN,IAAWC,EAAI,YAAY,YAAY;CAC7C,IAAI,CAACD,GAKH,OAJAC,EAAI,sBAAsB;EACxB,MAAM;EACN,aAAa;CACf,CAAC,GACM;CAET,IAAID,EAAS,QAAQ,MAAME,EAAW,oBAAoB,OAAO;CACjE,IAAMC,IACJH,EACA,eAAe;CACjB,IAAI,CAACG,GAIH,OAHAH,EAAoD,eAClD,YACF,GACO;CAET,IAAIG,EA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BAA8B;CAC1C,IAAMQ,IAAyB;EAC7B3C,EAAK,KAAKqC,EAAQ,MAAM,OAAO,UAAU,YAAY,oBAAoB;EACzErC,EAAK,KAAKqC,EAAQ,MAAM,OAAO,UAAU,oBAAoB;EAC7DrC,EAAK,KAAKqC,EAAQ,MAAM,OAAO,UAAU,YAAY,gBAAgB;CACvE,GACMO,IACJD,EAAuB,MAAM,MAAM5C,EAAG,WAAW8C,CAAC,CAAC,KACnDF,EAAuB;CACzB,EACEF,EACEG,GACAZ,EAAuBY,CAAgB,CACzC,CACF;CAGA,IAAME,IAAW,MAAMjD,EAAewC,CAAO;CAE7C,OAAO;EACL,SAASS,IAAW,CAACA,CAAQ,IAAI,CAAC;EAClC;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { o as e } from "./generate-
|
|
1
|
+
import { o as e } from "./generate-CZGHByV3.js";
|
|
2
2
|
import { n as t } from "./logger-CQONztPm.js";
|
|
3
|
-
import { n } from "./shared-
|
|
4
|
-
import { n as r, r as i, t as a } from "./generate-
|
|
3
|
+
import { n } from "./shared-Cc_ns5-y.js";
|
|
4
|
+
import { n as r, r as i, t as a } from "./generate-CFqpRi9D.js";
|
|
5
5
|
import { n as o } from "./env-BPfk1VAw.js";
|
|
6
|
-
import { envRevertOutcomeToFile as s } from "./modify-file-
|
|
7
|
-
import { unmodifyEnvVarsFiles as c } from "./env-vars-
|
|
6
|
+
import { envRevertOutcomeToFile as s } from "./modify-file-DK-tCH9k.js";
|
|
7
|
+
import { unmodifyEnvVarsFiles as c } from "./env-vars-CcE6ODqC.js";
|
|
8
8
|
import l from "node:fs";
|
|
9
9
|
import u from "node:path";
|
|
10
10
|
//#region src/patterns/disable/ai/generate.runtime.ts
|
|
@@ -32,4 +32,4 @@ async function d(d) {
|
|
|
32
32
|
//#endregion
|
|
33
33
|
export { d as generate };
|
|
34
34
|
|
|
35
|
-
//# sourceMappingURL=generate.runtime-
|
|
35
|
+
//# sourceMappingURL=generate.runtime-uLUiPgqx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.runtime-uLUiPgqx.js","names":["demoDir","getLogger","allEnvNames","demoDirs","allEnvEdits","modifyEnvRemove","fs","path","generate","logger","options","modifies","deletes","current","dir","page","toDeleteEntry","envVars","unmodifyEnvVarsFiles","envPath","env","envRevertOutcomeToFile"],"sources":["../../src/patterns/disable/ai/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 { modifyEnvRemove } from \"../../../runtime/env\";\nimport { envRevertOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { toDeleteEntry } from \"../../destroy/shared\";\nimport { demoDir } from \"../../enable/ai/generate\";\nimport { allEnvEdits, allEnvNames, demoDirs } from \"./generate\";\nimport { unmodifyEnvVarsFiles } from \"../../../runtime/env-vars\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n const deletes: File[] = [];\n\n // The base result names the page in the current default group; a page\n // generated before auth was enabled sits in the other one.\n const current = demoDir(options);\n for (const dir of demoDirs(options)) {\n const page = `${dir}/+page.svelte`;\n if (dir !== current && fs.existsSync(path.join(options.root, page))) {\n deletes.push(toDeleteEntry(page));\n }\n }\n\n // Which provider was chosen is not recorded, so every one's key goes; the\n // file goes too when these were all it declared.\n logger.info(\"Removing the AI provider's API key from src/env.ts\");\n const envVars = unmodifyEnvVarsFiles(options.root, allEnvNames());\n if (envVars.modify) modifies.push(envVars.modify);\n if (envVars.delete) deletes.push(envVars.delete);\n\n logger.info(\"Removing the AI provider's API key from .env\");\n const envPath = path.join(options.root, \".env\");\n const env = envRevertOutcomeToFile(\n envPath,\n modifyEnvRemove(envPath, allEnvEdits()),\n );\n if (env.modify) modifies.push(env.modify);\n if (env.delete) deletes.push(env.delete);\n\n return {\n creates: [],\n modifies,\n deletes,\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;;;AAWA,eAAsBQ,EAAS,GAAkB;CAC/C,IAAMC,IAASR,EAAUS,CAAO,GAC1BC,IAAmB,CAAC,GACpBC,IAAkB,CAAC,GAInBC,IAAUb,EAAQU,CAAO;CAC/B,KAAK,IAAMI,KAAOX,EAASO,CAAO,GAAG;EACnC,IAAMK,IAAO,GAAGD,EAAI;EACpB,AAAIA,MAAQD,KAAWP,EAAG,WAAWC,EAAK,KAAKG,EAAQ,MAAMK,CAAI,CAAC,KAChEH,EAAQ,KAAKI,EAAcD,CAAI,CAAC;CAEpC;CAIA,EAAO,KAAK,oDAAoD;CAChE,IAAME,IAAUC,EAAqBR,EAAQ,MAAMR,EAAY,CAAC;CAIhE,AAHIe,EAAQ,UAAQN,EAAS,KAAKM,EAAQ,MAAM,GAC5CA,EAAQ,UAAQL,EAAQ,KAAKK,EAAQ,MAAM,GAE/CR,EAAO,KAAK,8CAA8C;CAC1D,IAAMU,IAAUZ,EAAK,KAAKG,EAAQ,MAAM,MAAM,GACxCU,IAAMC,EACVF,GACAd,EAAgBc,GAASf,EAAY,CAAC,CACxC;CAIA,OAHIgB,EAAI,UAAQT,EAAS,KAAKS,EAAI,MAAM,GACpCA,EAAI,UAAQR,EAAQ,KAAKQ,EAAI,MAAM,GAEhC;EACL,SAAS,CAAC;EACV;EACA;EACA,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lib-specifier-Cngo1zF_.js","names":[],"sources":["../../src/runtime/lib-specifier.ts"],"sourcesContent":["/**\n * `#lib` specifiers, written the way `sv migrate sveltekit-3` (sv 1.0.1, the\n * `lib-alias` task) writes them. SvelteKit 3 drops `$lib`; projects map\n * `\"#lib/*\": \"./src/lib/*\"` in package.json `imports`, and Node subpath\n * imports don't add extensions or resolve directories, so every specifier\n * names the file the import loads:\n *\n * - a `.ts` or `.js` module gets `.js` (`site.ts` → `#lib/site.js`,\n * `x.svelte.ts` → `#lib/x.svelte.js`);\n * - a directory gets `/index.js` (`components/ui/button` →\n * `#lib/components/ui/button/index.js`);\n * - `.svelte`, `.svg`, `.svx`, `.css` and `.json` files keep their name.\n */\n\n/** Extensions an import names as they are on disk. */\nconst KEPT_EXTENSIONS = [\".svelte\", \".svg\", \".svx\", \".css\", \".json\"];\n\nconst SCRIPT_EXTENSION = /\\.(ts|js)$/;\nconst INDEX_SUFFIX = /\\/index(\\.(ts|js))?$/;\n\nfunction trimSlashes(rel: string): string {\n return rel\n .replace(/\\\\/g, \"/\")\n .replace(/^\\.?\\/+/, \"\")\n .replace(/\\/+$/, \"\");\n}\n\n/**\n * The `#lib` specifier for a path under `src/lib`. `rel` names a file by its\n * name on disk (`site.ts`, `components/app-sidebar.svelte`) or, when its last\n * segment has none of the extensions above, a directory imported through its\n * `index` (`components/ui/button`). `\"\"` is `src/lib` itself: `#lib`.\n */\nexport function libSpecifier(relPathUnderSrcLib: string): string {\n const rel = trimSlashes(relPathUnderSrcLib);\n if (rel === \"\" || rel === \".\") return \"#lib\";\n if (SCRIPT_EXTENSION.test(rel))\n return `#lib/${rel.replace(SCRIPT_EXTENSION, \".js\")}`;\n if (KEPT_EXTENSIONS.some((ext) => rel.endsWith(ext))) return `#lib/${rel}`;\n return `#lib/${rel}/index.js`;\n}\n\n/** `components/ui/avatar/index.js` and `site.ts` → `components/ui/avatar`, `site`. */\nfunction modulePath(rel: string): string {\n return trimSlashes(rel)\n .replace(INDEX_SUFFIX, \"\")\n .replace(SCRIPT_EXTENSION, \"\");\n}\n\n/**\n * Whether `spec` imports `relPath` under `src/lib`: `#lib/x.js`, `#lib/x.ts`,\n * `#lib/x/index.js`, or the `$lib/x` a project from before SvelteKit 3 still\n * has. `relPath` is written either way (`site`, `site.ts`,\n * `components/ui/avatar`, `components/notifications-bell.svelte`).\n */\nexport function isLibSpecifier(spec: string, relPath: string): boolean {\n const match = /^[#$]lib(?:\\/(.*))?$/.exec(spec);\n if (!match) return false;\n return modulePath(match[1] ?? \"\") === modulePath(relPath);\n}\n\n/**\n * The directory under `src/lib` a `components.json` alias names: `#lib` and\n * `#lib/components/ui` (what shadcn-svelte writes for a SvelteKit 3 project),\n * or the `$lib` forms of a project from before it. Aliases name directories,\n * so no extension is involved. `\"\"` is `src/lib` itself; anything else (a\n * custom alias) is null.\n */\nexport function libAliasPath(alias: string): string | null {\n const match = /^[#$]lib(?:\\/(.*))?$/.exec(alias);\n if (!match) return null;\n return trimSlashes(match[1] ?? \"\");\n}\n\n/** `isLibSpecifier` bound to one path, for the import helpers' module matchers. */\nexport function libModule(relPath: string): (spec: string) => boolean {\n return (spec) => isLibSpecifier(spec, relPath);\n}\n"],"mappings":";AAeA,
|
|
1
|
+
{"version":3,"file":"lib-specifier-Cngo1zF_.js","names":["KEPT_EXTENSIONS","SCRIPT_EXTENSION","INDEX_SUFFIX","trimSlashes","rel","libSpecifier","relPathUnderSrcLib","ext","modulePath","isLibSpecifier","match","spec","relPath","libAliasPath","alias","libModule"],"sources":["../../src/runtime/lib-specifier.ts"],"sourcesContent":["/**\n * `#lib` specifiers, written the way `sv migrate sveltekit-3` (sv 1.0.1, the\n * `lib-alias` task) writes them. SvelteKit 3 drops `$lib`; projects map\n * `\"#lib/*\": \"./src/lib/*\"` in package.json `imports`, and Node subpath\n * imports don't add extensions or resolve directories, so every specifier\n * names the file the import loads:\n *\n * - a `.ts` or `.js` module gets `.js` (`site.ts` → `#lib/site.js`,\n * `x.svelte.ts` → `#lib/x.svelte.js`);\n * - a directory gets `/index.js` (`components/ui/button` →\n * `#lib/components/ui/button/index.js`);\n * - `.svelte`, `.svg`, `.svx`, `.css` and `.json` files keep their name.\n */\n\n/** Extensions an import names as they are on disk. */\nconst KEPT_EXTENSIONS = [\".svelte\", \".svg\", \".svx\", \".css\", \".json\"];\n\nconst SCRIPT_EXTENSION = /\\.(ts|js)$/;\nconst INDEX_SUFFIX = /\\/index(\\.(ts|js))?$/;\n\nfunction trimSlashes(rel: string): string {\n return rel\n .replace(/\\\\/g, \"/\")\n .replace(/^\\.?\\/+/, \"\")\n .replace(/\\/+$/, \"\");\n}\n\n/**\n * The `#lib` specifier for a path under `src/lib`. `rel` names a file by its\n * name on disk (`site.ts`, `components/app-sidebar.svelte`) or, when its last\n * segment has none of the extensions above, a directory imported through its\n * `index` (`components/ui/button`). `\"\"` is `src/lib` itself: `#lib`.\n */\nexport function libSpecifier(relPathUnderSrcLib: string): string {\n const rel = trimSlashes(relPathUnderSrcLib);\n if (rel === \"\" || rel === \".\") return \"#lib\";\n if (SCRIPT_EXTENSION.test(rel))\n return `#lib/${rel.replace(SCRIPT_EXTENSION, \".js\")}`;\n if (KEPT_EXTENSIONS.some((ext) => rel.endsWith(ext))) return `#lib/${rel}`;\n return `#lib/${rel}/index.js`;\n}\n\n/** `components/ui/avatar/index.js` and `site.ts` → `components/ui/avatar`, `site`. */\nfunction modulePath(rel: string): string {\n return trimSlashes(rel)\n .replace(INDEX_SUFFIX, \"\")\n .replace(SCRIPT_EXTENSION, \"\");\n}\n\n/**\n * Whether `spec` imports `relPath` under `src/lib`: `#lib/x.js`, `#lib/x.ts`,\n * `#lib/x/index.js`, or the `$lib/x` a project from before SvelteKit 3 still\n * has. `relPath` is written either way (`site`, `site.ts`,\n * `components/ui/avatar`, `components/notifications-bell.svelte`).\n */\nexport function isLibSpecifier(spec: string, relPath: string): boolean {\n const match = /^[#$]lib(?:\\/(.*))?$/.exec(spec);\n if (!match) return false;\n return modulePath(match[1] ?? \"\") === modulePath(relPath);\n}\n\n/**\n * The directory under `src/lib` a `components.json` alias names: `#lib` and\n * `#lib/components/ui` (what shadcn-svelte writes for a SvelteKit 3 project),\n * or the `$lib` forms of a project from before it. Aliases name directories,\n * so no extension is involved. `\"\"` is `src/lib` itself; anything else (a\n * custom alias) is null.\n */\nexport function libAliasPath(alias: string): string | null {\n const match = /^[#$]lib(?:\\/(.*))?$/.exec(alias);\n if (!match) return null;\n return trimSlashes(match[1] ?? \"\");\n}\n\n/** `isLibSpecifier` bound to one path, for the import helpers' module matchers. */\nexport function libModule(relPath: string): (spec: string) => boolean {\n return (spec) => isLibSpecifier(spec, relPath);\n}\n"],"mappings":";AAeA,IAAMA,IAAkB;CAAC;CAAW;CAAQ;CAAQ;CAAQ;AAAO,GAE7DC,IAAmB,cACnBC,IAAe;AAErB,SAASC,EAAY,GAAqB;CACxC,OAAOC,EACJ,QAAQ,OAAO,GAAG,CAAC,CACnB,QAAQ,WAAW,EAAE,CAAC,CACtB,QAAQ,QAAQ,EAAE;AACvB;AAQA,SAAgBC,EAAa,GAAoC;CAC/D,IAAMD,IAAMD,EAAYG,CAAkB;CAK1C,OAJIF,MAAQ,MAAMA,MAAQ,MAAY,SAClCH,EAAiB,KAAKG,CAAG,IACpB,QAAQA,EAAI,QAAQH,GAAkB,KAAK,MAChDD,EAAgB,MAAM,MAAQI,EAAI,SAASG,CAAG,CAAC,IAAU,QAAQH,MAC9D,QAAQA,EAAI;AACrB;AAGA,SAASI,EAAW,GAAqB;CACvC,OAAOL,EAAYC,CAAG,CAAC,CACpB,QAAQF,GAAc,EAAE,CAAC,CACzB,QAAQD,GAAkB,EAAE;AACjC;AAQA,SAAgBQ,EAAe,GAAc,GAA0B;CACrE,IAAMC,IAAQ,uBAAuB,KAAKC,CAAI;CAE9C,OADKD,IACEF,EAAWE,EAAM,MAAM,EAAE,MAAMF,EAAWI,CAAO,IADrC;AAErB;AASA,SAAgBC,EAAa,GAA8B;CACzD,IAAMH,IAAQ,uBAAuB,KAAKI,CAAK;CAE/C,OADKJ,IACEP,EAAYO,EAAM,MAAM,EAAE,IADd;AAErB;AAGA,SAAgBK,EAAU,GAA4C;CACpE,QAAQ,MAASN,EAAeE,GAAMC,CAAO;AAC/C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger-CQONztPm.js","names":[],"sources":["../../src/core/logger.ts"],"sourcesContent":["export interface Logger {\n info: (message: string) => void;\n}\n\nexport const NOOP_LOGGER: Logger = {\n info: () => {},\n};\n\nexport function getLogger(options: { logger?: Logger }): Logger {\n return options.logger ?? NOOP_LOGGER;\n}\n"],"mappings":";AAIA,
|
|
1
|
+
{"version":3,"file":"logger-CQONztPm.js","names":["NOOP_LOGGER","getLogger","options"],"sources":["../../src/core/logger.ts"],"sourcesContent":["export interface Logger {\n info: (message: string) => void;\n}\n\nexport const NOOP_LOGGER: Logger = {\n info: () => {},\n};\n\nexport function getLogger(options: { logger?: Logger }): Logger {\n return options.logger ?? NOOP_LOGGER;\n}\n"],"mappings":";AAIA,IAAaA,IAAsB,EACjC,YAAY,CAAC,EACf;AAEA,SAAgBC,EAAU,GAAsC;CAC9D,OAAOC,EAAQ,UAAUF;AAC3B"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as e } from "./util-BLYliuUK.js";
|
|
2
|
-
import { n as t } from "./shared-
|
|
3
|
-
import { _ as n, s as r } from "./ts-morph-helpers-
|
|
2
|
+
import { n as t } from "./shared-Cc_ns5-y.js";
|
|
3
|
+
import { _ as n, s as r } from "./ts-morph-helpers-Bepc-Es2.js";
|
|
4
4
|
import i from "node:fs";
|
|
5
5
|
import a from "node:path";
|
|
6
6
|
//#region src/runtime/modify-file.ts
|
|
@@ -43,4 +43,4 @@ function l(e, t) {
|
|
|
43
43
|
//#endregion
|
|
44
44
|
export { c as envRevertOutcomeToFile, l as keepMissing, o as modifyOutcomeToFile, s as revertOutcomeToFile };
|
|
45
45
|
|
|
46
|
-
//# sourceMappingURL=modify-file-
|
|
46
|
+
//# sourceMappingURL=modify-file-DK-tCH9k.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modify-file-DK-tCH9k.js","names":["languageFromPath","toDeleteEntry","withInMemoryScript","isEffectivelyEmpty","fs","path","modifyOutcomeToFile","language","filePath","outcome","revertOutcomeToFile","envRevertOutcomeToFile","envPath","keepMissing","creates","root","file"],"sources":["../../src/runtime/modify-file.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { File, ModifyOutcome } from \"../core/types\";\nimport { languageFromPath } from \"../core/util\";\nimport { toDeleteEntry } from \"../patterns/destroy/shared\";\nimport { isEffectivelyEmpty, withInMemoryScript } from \"./ts-morph-helpers\";\n\nexport function modifyOutcomeToFile(\n filePath: string,\n outcome: ModifyOutcome,\n): File | null {\n const language = languageFromPath(filePath);\n\n if (outcome.status === \"success\") {\n if (!outcome.changed) return null;\n return {\n path: filePath,\n language,\n content: fs.readFileSync(filePath, \"utf8\"),\n status: \"success\",\n };\n }\n\n const content =\n outcome.status === \"failed\" && fs.existsSync(filePath)\n ? fs.readFileSync(filePath, \"utf8\")\n : \"\";\n\n return {\n path: filePath,\n language,\n content,\n status: outcome.status,\n message: outcome.message,\n };\n}\n\n/**\n * `modifyOutcomeToFile` for a revert that may have taken out everything the\n * file held: a script left with no statements, only comments and whitespace,\n * is reported as a delete. For hooks files a pattern created, or that ended\n * up holding nothing but what patterns put there.\n */\nexport function revertOutcomeToFile(\n filePath: string,\n outcome: ModifyOutcome,\n): { modify: File | null; delete: File | null } {\n if (\n outcome.status === \"success\" &&\n outcome.changed &&\n fs.existsSync(filePath) &&\n withInMemoryScript(fs.readFileSync(filePath, \"utf8\"), isEffectivelyEmpty)\n .result\n ) {\n return { modify: null, delete: toDeleteEntry(filePath) };\n }\n return { modify: modifyOutcomeToFile(filePath, outcome), delete: null };\n}\n\n/**\n * `modifyOutcomeToFile` for a `.env` revert: a file the revert left empty is\n * reported as a delete. The enable pattern most likely created it, and an\n * empty `.env` holds nothing worth keeping.\n */\nexport function envRevertOutcomeToFile(\n envPath: string,\n outcome: ModifyOutcome,\n): { modify: File | null; delete: File | null } {\n if (\n outcome.status === \"success\" &&\n outcome.changed &&\n fs.existsSync(envPath) &&\n fs.readFileSync(envPath, \"utf8\").trim() === \"\"\n ) {\n return { modify: null, delete: toDeleteEntry(envPath) };\n }\n return { modify: modifyOutcomeToFile(envPath, outcome), delete: null };\n}\n\n/**\n * Drop any create that already exists on disk.\n *\n * `writeResult` overwrites an existing create whose content differs and\n * reports it as a modify, which would mean a re-run silently resetting a\n * developer's edits, or a create clobbering a file other patterns have\n * already written to. The file is theirs once it exists; a pattern that has\n * something to add to it does so with a modifier.\n */\nexport function keepMissing(creates: File[], root: string): File[] {\n return creates.filter((file) => !fs.existsSync(path.join(root, file.path)));\n}\n"],"mappings":";;;;;;AAOA,SAAgBM,EACd,GACA,GACa;CACb,IAAMC,IAAWP,EAAiBQ,CAAQ;CAiB1C,OAfIC,EAAQ,WAAW,YAChBA,EAAQ,UACN;EACL,MAAMD;EACN;EACA,SAASJ,EAAG,aAAaI,GAAU,MAAM;EACzC,QAAQ;CACV,IAN6B,OAcxB;EACL,MAAMA;EACN;EACA,SAPAC,EAAQ,WAAW,YAAYL,EAAG,WAAWI,CAAQ,IACjDJ,EAAG,aAAaI,GAAU,MAAM,IAChC;EAMJ,QAAQC,EAAQ;EAChB,SAASA,EAAQ;CACnB;AACF;AAQA,SAAgBC,EACd,GACA,GAC8C;CAU9C,OARED,EAAQ,WAAW,aACnBA,EAAQ,WACRL,EAAG,WAAWI,CAAQ,KACtBN,EAAmBE,EAAG,aAAaI,GAAU,MAAM,GAAGL,CAAkB,CAAC,CACtE,SAEI;EAAE,QAAQ;EAAM,QAAQF,EAAcO,CAAQ;CAAE,IAElD;EAAE,QAAQF,EAAoBE,GAAUC,CAAO;EAAG,QAAQ;CAAK;AACxE;AAOA,SAAgBE,EACd,GACA,GAC8C;CAS9C,OAPEF,EAAQ,WAAW,aACnBA,EAAQ,WACRL,EAAG,WAAWQ,CAAO,KACrBR,EAAG,aAAaQ,GAAS,MAAM,CAAC,CAAC,KAAK,MAAM,KAErC;EAAE,QAAQ;EAAM,QAAQX,EAAcW,CAAO;CAAE,IAEjD;EAAE,QAAQN,EAAoBM,GAASH,CAAO;EAAG,QAAQ;CAAK;AACvE;AAWA,SAAgBI,EAAY,GAAiB,GAAsB;CACjE,OAAOC,EAAQ,QAAQ,MAAS,CAACV,EAAG,WAAWC,EAAK,KAAKU,GAAMC,EAAK,IAAI,CAAC,CAAC;AAC5E"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { _ as e } from "./ts-morph-helpers-Bepc-Es2.js";
|
|
2
|
+
import { t } from "./svelte-file-B3RfgVdt.js";
|
|
3
|
+
import n from "node:fs";
|
|
4
|
+
import { SyntaxKind as r } from "ts-morph";
|
|
5
|
+
//#region src/patterns/enable/subscriptions/modifies/modify-nav-user.ts
|
|
6
|
+
var i = ["src/lib/components/nav-user.svelte is missing.", "Enable auth and payments first; subscriptions layers a plan label on top of the existing nav-user."].join("\n"), a = [
|
|
7
|
+
"Could not find the props and the name lines in nav-user.svelte. Show the plan by hand:",
|
|
8
|
+
"",
|
|
9
|
+
"let { user, subscription = null }: { ...; subscription?: { id: string; productName: string | null } | null } = $props();",
|
|
10
|
+
"const planLabel = $derived(subscription?.productName ?? 'Free');",
|
|
11
|
+
"",
|
|
12
|
+
"<!-- Under the name, in the trigger and in the dropdown label: -->",
|
|
13
|
+
"<span class=\"truncate text-xs text-muted-foreground\">{planLabel}</span>"
|
|
14
|
+
].join("\n"), o = "{ id: string; productName: string | null } | null", s = "const planLabel = $derived(subscription?.productName ?? 'Free');", c = ["<span class=\"truncate text-xs text-muted-foreground\">{planLabel}</span>", "<span class=\"truncate text-xs\">{planLabel}</span>"];
|
|
15
|
+
function l(e) {
|
|
16
|
+
return e.getVariableStatements().find((e) => e.getDeclarations().some((e) => e.getInitializer()?.getText() === "$props()" && e.getNameNode().getKind() === r.ObjectBindingPattern));
|
|
17
|
+
}
|
|
18
|
+
function u(e, t) {
|
|
19
|
+
if (!e.includes("\n")) return `{ ${t.join(", ")} }`;
|
|
20
|
+
let n = e.match(/\n([ \t]+)\S/)?.[1] ?? " ", r = e.match(/\n([ \t]*)\}$/)?.[1] ?? "";
|
|
21
|
+
return `{\n${t.map((e) => n + e).join(",\n")}\n${r}}`;
|
|
22
|
+
}
|
|
23
|
+
function d(e) {
|
|
24
|
+
let t = l(e), n = t?.getDeclarations()[0], i = n?.getNameNode().asKind(r.ObjectBindingPattern), a = n?.getTypeNode()?.asKind(r.TypeLiteral);
|
|
25
|
+
if (!t || !n || !i || !a) return !1;
|
|
26
|
+
if (!i.getElements().some((e) => e.getName() === "subscription")) {
|
|
27
|
+
let e = i.getElements().map((e) => e.getText()), t = i.getElements().findIndex((e) => e.getDotDotDotToken());
|
|
28
|
+
e.splice(t === -1 ? e.length : t, 0, "subscription = null"), i.replaceWithText(u(i.getText(), e));
|
|
29
|
+
}
|
|
30
|
+
return a.getProperty("subscription") || a.addProperty({
|
|
31
|
+
name: "subscription",
|
|
32
|
+
hasQuestionToken: !0,
|
|
33
|
+
type: o
|
|
34
|
+
}), e.insertStatements(e.getStatements().indexOf(t) + 1, (e) => e.blankLine().write(s)), !0;
|
|
35
|
+
}
|
|
36
|
+
function f(r) {
|
|
37
|
+
if (!n.existsSync(r)) return {
|
|
38
|
+
status: "not-found",
|
|
39
|
+
message: i
|
|
40
|
+
};
|
|
41
|
+
let o = n.readFileSync(r, "utf8");
|
|
42
|
+
if (o.includes("planLabel")) return {
|
|
43
|
+
status: "success",
|
|
44
|
+
changed: !1
|
|
45
|
+
};
|
|
46
|
+
let s = new t(o), l = !1;
|
|
47
|
+
if (s.modifyScript((t) => e(t, (e) => {
|
|
48
|
+
l = d(e);
|
|
49
|
+
}).source), !l) return {
|
|
50
|
+
status: "failed",
|
|
51
|
+
message: a
|
|
52
|
+
};
|
|
53
|
+
let u = s.toString(), f = u.indexOf("<\/script>"), p = [...u.slice(f).matchAll(/^([ \t]*)<span class="truncate font-medium">[\s\S]*?<\/span>/gm)];
|
|
54
|
+
if (p.length < 2) return {
|
|
55
|
+
status: "failed",
|
|
56
|
+
message: a
|
|
57
|
+
};
|
|
58
|
+
let m = u;
|
|
59
|
+
for (let [e, t] of [...p.slice(0, 2).entries()].reverse()) {
|
|
60
|
+
let n = f + t.index + t[0].length;
|
|
61
|
+
m = `${m.slice(0, n)}\n${t[1]}${c[e]}${m.slice(n)}`;
|
|
62
|
+
}
|
|
63
|
+
return n.writeFileSync(r, m, "utf8"), {
|
|
64
|
+
status: "success",
|
|
65
|
+
changed: !0
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
//#endregion
|
|
69
|
+
export { f as n, l as r, u as t };
|
|
70
|
+
|
|
71
|
+
//# sourceMappingURL=modify-nav-user-BLyrW2sK.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modify-nav-user-BLyrW2sK.js","names":["withInMemoryScript","fs","NOT_FOUND_HINT","FAILURE_HINT","SUBSCRIPTION_TYPE","PLAN_LABEL","PLAN_LINES","propsStatement","sf","s","d","SyntaxKind","bindingText","current","texts","indent","close","t","addSubscriptionProp","statement","decl","binding","type","rest","writer","modifyNavUser","filePath","original","file","SvelteFile","added","content","source","markupStart","names","out","i","match","end"],"sources":["../../src/patterns/enable/subscriptions/modifies/modify-nav-user.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { SyntaxKind, type SourceFile, type VariableStatement } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport { withInMemoryScript } from \"../../../../runtime/ts-morph-helpers\";\n\nconst NOT_FOUND_HINT = [\n \"src/lib/components/nav-user.svelte is missing.\",\n \"Enable auth and payments first; subscriptions layers a plan label on top of the existing nav-user.\",\n].join(\"\\n\");\n\nconst FAILURE_HINT = [\n \"Could not find the props and the name lines in nav-user.svelte. Show the plan by hand:\",\n \"\",\n \"let { user, subscription = null }: { ...; subscription?: { id: string; productName: string | null } | null } = $props();\",\n \"const planLabel = $derived(subscription?.productName ?? 'Free');\",\n \"\",\n \"<!-- Under the name, in the trigger and in the dropdown label: -->\",\n '<span class=\"truncate text-xs text-muted-foreground\">{planLabel}</span>',\n].join(\"\\n\");\n\nconst SUBSCRIPTION_TYPE = \"{ id: string; productName: string | null } | null\";\nconst PLAN_LABEL =\n \"const planLabel = $derived(subscription?.productName ?? 'Free');\";\n\n/** The line under the name: muted in the trigger, plain in the dropdown label. */\nconst PLAN_LINES = [\n '<span class=\"truncate text-xs text-muted-foreground\">{planLabel}</span>',\n '<span class=\"truncate text-xs\">{planLabel}</span>',\n];\n\n/** `let { ... }: { ... } = $props();` */\nexport function propsStatement(sf: SourceFile): VariableStatement | undefined {\n return sf\n .getVariableStatements()\n .find((s) =>\n s\n .getDeclarations()\n .some(\n (d) =>\n d.getInitializer()?.getText() === \"$props()\" &&\n d.getNameNode().getKind() === SyntaxKind.ObjectBindingPattern,\n ),\n );\n}\n\n/** `{ a, b }` with `texts` as its elements, one per line if it was. */\nexport function bindingText(current: string, texts: string[]): string {\n if (!current.includes(\"\\n\")) return `{ ${texts.join(\", \")} }`;\n const indent = current.match(/\\n([ \\t]+)\\S/)?.[1] ?? \"\\t\";\n const close = current.match(/\\n([ \\t]*)\\}$/)?.[1] ?? \"\";\n return `{\\n${texts.map((t) => indent + t).join(\",\\n\")}\\n${close}}`;\n}\n\nfunction addSubscriptionProp(sf: SourceFile): boolean {\n const statement = propsStatement(sf);\n const decl = statement?.getDeclarations()[0];\n const binding = decl?.getNameNode().asKind(SyntaxKind.ObjectBindingPattern);\n const type = decl?.getTypeNode()?.asKind(SyntaxKind.TypeLiteral);\n if (!statement || !decl || !binding || !type) return false;\n\n if (!binding.getElements().some((e) => e.getName() === \"subscription\")) {\n const texts = binding.getElements().map((e) => e.getText());\n const rest = binding.getElements().findIndex((e) => e.getDotDotDotToken());\n texts.splice(rest === -1 ? texts.length : rest, 0, \"subscription = null\");\n binding.replaceWithText(bindingText(binding.getText(), texts));\n }\n if (!type.getProperty(\"subscription\")) {\n type.addProperty({\n name: \"subscription\",\n hasQuestionToken: true,\n type: SUBSCRIPTION_TYPE,\n });\n }\n sf.insertStatements(sf.getStatements().indexOf(statement) + 1, (writer) =>\n writer.blankLine().write(PLAN_LABEL),\n );\n return true;\n}\n\n/**\n * Shows the user's plan under their name in nav-user: a `subscription` prop\n * (the (app) layout passes it), `planLabel` from it, and a line under each\n * name. Edits the file rather than replacing it, so the items other patterns\n * added to the menu (teams, API keys) stay.\n */\nexport function modifyNavUser(filePath: string): 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(\"planLabel\")) {\n return { status: \"success\", changed: false };\n }\n\n const file = new SvelteFile(original);\n let added = false;\n file.modifyScript(\n (content) =>\n withInMemoryScript(content, (sf) => {\n added = addSubscriptionProp(sf);\n }).source,\n );\n if (!added) return { status: \"failed\", message: FAILURE_HINT };\n\n // The name lines, in the markup after the script.\n const source = file.toString();\n const markupStart = source.indexOf(\"</script>\");\n const names = [\n ...source\n .slice(markupStart)\n .matchAll(\n /^([ \\t]*)<span class=\"truncate font-medium\">[\\s\\S]*?<\\/span>/gm,\n ),\n ];\n if (names.length < 2) return { status: \"failed\", message: FAILURE_HINT };\n\n let out = source;\n // From the last, so the earlier offsets stay put.\n for (const [i, match] of [...names.slice(0, 2).entries()].reverse()) {\n const end = markupStart + match.index! + match[0].length;\n out = `${out.slice(0, end)}\\n${match[1]}${PLAN_LINES[i]}${out.slice(end)}`;\n }\n\n fs.writeFileSync(filePath, out, \"utf8\");\n return { status: \"success\", changed: true };\n}\n"],"mappings":";;;;;AAMA,IAAME,IAAiB,CACrB,kDACA,oGACF,CAAC,CAAC,KAAK,IAAI,GAELC,IAAe;CACnB;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC,CAAC,KAAK,IAAI,GAELC,IAAoB,qDACpBC,IACJ,oEAGIC,IAAa,CACjB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CAGA,OADArC,EAAG,cAAcyB,GAAUS,GAAK,MAAM,GAC/B;EAAE,QAAQ;EAAW,SAAS;CAAK;AAC5C"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as e, n as t, r as n } from "./config-target-
|
|
1
|
+
import { i as e, n as t, r as n } from "./config-target-rHgjaA8u.js";
|
|
2
2
|
//#region src/runtime/modify-svelte-config-remote.ts
|
|
3
3
|
var r = [
|
|
4
4
|
"Enable SvelteKit remote functions and Svelte async in your config",
|
|
@@ -39,4 +39,4 @@ function a(a) {
|
|
|
39
39
|
//#endregion
|
|
40
40
|
export { a as modifySvelteConfigRemote };
|
|
41
41
|
|
|
42
|
-
//# sourceMappingURL=modify-svelte-config-remote-
|
|
42
|
+
//# sourceMappingURL=modify-svelte-config-remote-DhuRX4FI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modify-svelte-config-remote-DhuRX4FI.js","names":["modifyConfig","ensureBooleanTrue","getOrCreateObjectLiteralProperty","FAILURE_HINT","NOT_FOUND_HINT","modifySvelteConfigRemote","root","kitExperimental","target","compilerObj","compilerExperimental"],"sources":["../../src/runtime/modify-svelte-config-remote.ts"],"sourcesContent":["import {\n ensureBooleanTrue,\n getOrCreateObjectLiteralProperty,\n modifyConfig,\n type ConfigModifyResult,\n} from \"./config-target\";\n\nconst FAILURE_HINT = [\n \"Enable SvelteKit remote functions and Svelte async in your config\",\n \"(the sveltekit() plugin arg in vite.config):\",\n \"\",\n \"experimental: { remoteFunctions: true },\",\n \"compilerOptions: { experimental: { async: true } },\",\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Enable SvelteKit remote functions and Svelte async by passing config to the\",\n \"sveltekit() plugin in vite.config.ts:\",\n \"\",\n \"import { sveltekit } from '@sveltejs/kit/vite';\",\n \"import { defineConfig } from 'vite';\",\n \"\",\n \"export default defineConfig({\",\n \" plugins: [\",\n \" sveltekit({\",\n \" experimental: { remoteFunctions: true },\",\n \" compilerOptions: { experimental: { async: true } },\",\n \" }),\",\n \" ],\",\n \"});\",\n].join(\"\\n\");\n\n/**\n * Enable SvelteKit remote functions (`experimental.remoteFunctions`) and Svelte\n * async (`compilerOptions.experimental.async`) in the inline `sveltekit()` arg\n * in vite.config, where both sit at the top level.\n */\nexport function modifySvelteConfigRemote(root: string): ConfigModifyResult {\n return modifyConfig(\n root,\n { notFound: NOT_FOUND_HINT, failed: FAILURE_HINT },\n (target) => {\n const kitExperimental = getOrCreateObjectLiteralProperty(\n target.configObject,\n \"experimental\",\n \"{}\",\n );\n if (!kitExperimental) return false;\n ensureBooleanTrue(kitExperimental, \"remoteFunctions\");\n\n const compilerObj = getOrCreateObjectLiteralProperty(\n target.configObject,\n \"compilerOptions\",\n \"{}\",\n );\n if (!compilerObj) return false;\n const compilerExperimental = getOrCreateObjectLiteralProperty(\n compilerObj,\n \"experimental\",\n \"{}\",\n );\n if (!compilerExperimental) return false;\n ensureBooleanTrue(compilerExperimental, \"async\");\n\n return true;\n },\n );\n}\n"],"mappings":";;AAOA,IAAMG,IAAe;CACnB;CACA;CACA;CACA;CACA;AACF,CAAC,CAAC,KAAK,IAAI,GAELC,IAAiB;CACrB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC,CAAC,KAAK,IAAI;AAOX,SAAgBC,EAAyB,GAAkC;CACzE,OAAOL,EACLM,GACA;EAAE,UAAUF;EAAgB,QAAQD;CAAa,IAChD,MAAW;EACV,IAAMI,IAAkBL,EACtBM,EAAO,cACP,gBACA,IACF;EACA,IAAI,CAACD,GAAiB,OAAO;EAC7B,EAAkBA,GAAiB,iBAAiB;EAEpD,IAAME,IAAcP,EAClBM,EAAO,cACP,mBACA,IACF;EACA,IAAI,CAACC,GAAa,OAAO;EACzB,IAAMC,IAAuBR,EAC3BO,GACA,gBACA,IACF;EAIA,OAHKC,KACLT,EAAkBS,GAAsB,OAAO,GAExC,MAH2B;CAIpC,CACF;AACF"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { t as e } from "./dedent-Gq6Krl4n.js";
|
|
2
|
+
import { o as t } from "./ts-morph-helpers-Bepc-Es2.js";
|
|
3
|
+
import n from "node:fs";
|
|
4
|
+
import { Project as r, QuoteKind as i, SyntaxKind as a } from "ts-morph";
|
|
5
|
+
//#region src/patterns/enable/payments/modifies/modify-user-signup.ts
|
|
6
|
+
var o = "#lib/workflows/link-stripe-customer.js", s = e`
|
|
7
|
+
// Queued here, done in the background: the Stripe calls retry on their own,
|
|
8
|
+
// and the key means a retry never makes a second customer for this user.
|
|
9
|
+
await linkStripeCustomer.run(
|
|
10
|
+
{ userId: user.id, email: form.data.email },
|
|
11
|
+
{ idempotencyKey: user.id }
|
|
12
|
+
);
|
|
13
|
+
`, c = [
|
|
14
|
+
"Could not locate the requestVerification call in signup +page.server.ts.",
|
|
15
|
+
"Start the workflow once the user exists:",
|
|
16
|
+
"",
|
|
17
|
+
`import { linkStripeCustomer } from '${o}';`,
|
|
18
|
+
"",
|
|
19
|
+
s
|
|
20
|
+
].join("\n"), l = ["Create src/routes/(public)/(auth)/signup/+page.server.ts before enabling payments."].join("\n");
|
|
21
|
+
function u(e) {
|
|
22
|
+
if (!n.existsSync(e)) return {
|
|
23
|
+
status: "not-found",
|
|
24
|
+
message: l
|
|
25
|
+
};
|
|
26
|
+
let u = n.readFileSync(e, "utf8");
|
|
27
|
+
if (u.includes("linkStripeCustomer")) return {
|
|
28
|
+
status: "success",
|
|
29
|
+
changed: !1
|
|
30
|
+
};
|
|
31
|
+
let d = new r({ manipulationSettings: { quoteKind: i.Single } }).addSourceFileAtPath(e), f = d.getDescendantsOfKind(a.CallExpression).find((e) => {
|
|
32
|
+
let t = e.getExpression();
|
|
33
|
+
return t.getKind() === a.PropertyAccessExpression && t.getText().includes("requestVerification");
|
|
34
|
+
});
|
|
35
|
+
if (!f) return {
|
|
36
|
+
status: "failed",
|
|
37
|
+
message: c
|
|
38
|
+
};
|
|
39
|
+
let p = f.getFirstAncestorByKind(a.ExpressionStatement);
|
|
40
|
+
return p ? (d.addImportDeclaration({
|
|
41
|
+
namedImports: ["linkStripeCustomer"],
|
|
42
|
+
moduleSpecifier: o
|
|
43
|
+
}), p.replaceWithText(s + "\n\n" + p.getText()), t(d), d.saveSync(), {
|
|
44
|
+
status: "success",
|
|
45
|
+
changed: d.getFullText() !== u
|
|
46
|
+
}) : {
|
|
47
|
+
status: "failed",
|
|
48
|
+
message: c
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
52
|
+
export { u as t };
|
|
53
|
+
|
|
54
|
+
//# sourceMappingURL=modify-user-signup-BbqTiUuA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modify-user-signup-BbqTiUuA.js","names":["dedent","formatLikeSource","fs","WORKFLOW_MODULE","RUN_SNIPPET","FAILURE_HINT","NOT_FOUND_HINT","modifyUserSignup","userSignupPath","originalSource","sourceFile","Project","QuoteKind","requestVerificationCall","SyntaxKind","expr","ce","statement"],"sources":["../../src/patterns/enable/payments/modifies/modify-user-signup.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { Project, QuoteKind, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { formatLikeSource } from \"../../../../runtime/ts-morph-helpers\";\n\nconst WORKFLOW_MODULE = \"#lib/workflows/link-stripe-customer.js\";\n\nconst RUN_SNIPPET = dedent`\n // Queued here, done in the background: the Stripe calls retry on their own,\n // and the key means a retry never makes a second customer for this user.\n await linkStripeCustomer.run(\n { userId: user.id, email: form.data.email },\n { idempotencyKey: user.id }\n );\n`;\n\nconst FAILURE_HINT = [\n \"Could not locate the requestVerification call in signup +page.server.ts.\",\n \"Start the workflow once the user exists:\",\n \"\",\n `import { linkStripeCustomer } from '${WORKFLOW_MODULE}';`,\n \"\",\n RUN_SNIPPET,\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create src/routes/(public)/(auth)/signup/+page.server.ts before enabling payments.\",\n].join(\"\\n\");\n\n/**\n * Starts the link-stripe-customer workflow right after the user is created.\n * The work itself lives in src/lib/workflows/link-stripe-customer.ts.\n */\nexport function modifyUserSignup(userSignupPath: string): ModifyOutcome {\n if (!fs.existsSync(userSignupPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\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 const requestVerificationCall = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .find((ce) => {\n const expr = ce.getExpression();\n return (\n expr.getKind() === SyntaxKind.PropertyAccessExpression &&\n expr.getText().includes(\"requestVerification\")\n );\n });\n\n if (!requestVerificationCall) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const statement = requestVerificationCall.getFirstAncestorByKind(\n SyntaxKind.ExpressionStatement,\n );\n\n if (!statement) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n sourceFile.addImportDeclaration({\n namedImports: [\"linkStripeCustomer\"],\n moduleSpecifier: WORKFLOW_MODULE,\n });\n\n statement.replaceWithText(RUN_SNIPPET + \"\\n\\n\" + statement.getText());\n\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\n };\n}\n"],"mappings":";;;;;AAMA,IAAMG,IAAkB,0CAElBC,IAAc,CAAM;;;;;;;GASpBC,IAAe;CACnB;CACA;CACA;CACA,uCAAuCF,EAAgB;CACvD;CACAC;AACF,CAAC,CAAC,KAAK,IAAI,GAELE,IAAiB,CACrB,oFACF,CAAC,CAAC,KAAK,IAAI;AAMX,SAAgBC,EAAiB,GAAuC;CACtE,IAAI,CAACL,EAAG,WAAWM,CAAc,GAC/B,OAAO;EAAE,QAAQ;EAAa,SAASF;CAAe;CAGxD,IAAMG,IAAiBP,EAAG,aAAaM,GAAgB,MAAM;CAC7D,IAAIC,EAAe,SAAS,oBAAoB,GAC9C,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAM7C,IAAMC,IAAa,IAHCC,EAAQ,EAC1B,sBAAsB,EAAE,WAAWC,EAAU,OAAO,EACtD,CACmB,CAAA,CAAQ,oBAAoBJ,CAAc,GAEvDK,IAA0BH,EAC7B,qBAAqBI,EAAW,cAAc,CAAC,CAC/C,MAAM,MAAO;EACZ,IAAMC,IAAOC,EAAG,cAAc;EAC9B,OACED,EAAK,QAAQ,MAAMD,EAAW,4BAC9BC,EAAK,QAAQ,CAAC,CAAC,SAAS,qBAAqB;CAEjD,CAAC;CAEH,IAAI,CAACF,GACH,OAAO;EAAE,QAAQ;EAAU,SAASR;CAAa;CAGnD,IAAMY,IAAYJ,EAAwB,uBACxCC,EAAW,mBACb;CAgBA,OAdKG,KAILP,EAAW,qBAAqB;EAC9B,cAAc,CAAC,oBAAoB;EACnC,iBAAiBP;CACnB,CAAC,GAEDc,EAAU,gBAAgBb,IAAc,SAASa,EAAU,QAAQ,CAAC,GAEpEhB,EAAiBS,CAAU,GAC3BA,EAAW,SAAS,GAEb;EACL,QAAQ;EACR,SAASA,EAAW,YAAY,MAAMD;CACxC,KAhBS;EAAE,QAAQ;EAAU,SAASJ;CAAa;AAiBrD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modify-utils-Cw-on_cL.js","names":[],"sources":["../../src/runtime/modify-utils.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { Project, QuoteKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../core/types\";\n\nconst TIME_AGO_SNIPPET = dedent`\n const TIME_AGO_UNITS: [Intl.RelativeTimeFormatUnit, number][] = [\n ['year', 60 * 60 * 24 * 365],\n ['month', 60 * 60 * 24 * 30],\n ['day', 60 * 60 * 24],\n ['hour', 60 * 60],\n ['minute', 60],\n ['second', 1]\n ];\n\n export function timeAgo(date: Date | string | number, locale?: string) {\n const rtf = new Intl.RelativeTimeFormat(locale, { numeric: 'auto' });\n const diff = (new Date(date).getTime() - Date.now()) / 1000;\n\n for (const [unit, secs] of TIME_AGO_UNITS) {\n if (Math.abs(diff) >= secs || unit === 'second') {\n return rtf.format(Math.round(diff / secs), unit);\n }\n }\n }\n`;\n\nconst NOT_FOUND_HINT = dedent`\n Create src/lib/utils.ts with a timeAgo helper:\n\n ${TIME_AGO_SNIPPET}\n`;\n\nconst UNITS_SNIPPET = dedent`\n const TIME_AGO_UNITS: [Intl.RelativeTimeFormatUnit, number][] = [\n ['year', 60 * 60 * 24 * 365],\n ['month', 60 * 60 * 24 * 30],\n ['day', 60 * 60 * 24],\n ['hour', 60 * 60],\n ['minute', 60],\n ['second', 1]\n ];\n`;\n\nconst FUNCTION_SNIPPET = dedent`\n export function timeAgo(date: Date | string | number, locale?: string) {\n const rtf = new Intl.RelativeTimeFormat(locale, { numeric: 'auto' });\n const diff = (new Date(date).getTime() - Date.now()) / 1000;\n\n for (const [unit, secs] of TIME_AGO_UNITS) {\n if (Math.abs(diff) >= secs || unit === 'second') {\n return rtf.format(Math.round(diff / secs), unit);\n }\n }\n }\n`;\n\nexport function modifyUtils(utilsPath: string): ModifyOutcome {\n if (!fs.existsSync(utilsPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const originalSource = fs.readFileSync(utilsPath, \"utf8\");\n const project = new Project({\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(utilsPath);\n\n const hasTimeAgo =\n sourceFile.getFunction(\"timeAgo\") !== undefined ||\n sourceFile.getVariableDeclaration(\"timeAgo\") !== undefined;\n const hasUnits =\n sourceFile.getVariableDeclaration(\"TIME_AGO_UNITS\") !== undefined;\n\n if (hasTimeAgo && hasUnits) {\n return { status: \"success\", changed: false };\n }\n\n const toAppend: string[] = [];\n if (!hasUnits) toAppend.push(UNITS_SNIPPET);\n if (!hasTimeAgo) toAppend.push(FUNCTION_SNIPPET);\n\n sourceFile.addStatements(\"\\n\" + toAppend.join(\"\\n\\n\") + \"\\n\");\n sourceFile.saveSync();\n\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\n };\n}\n"],"mappings":";;;;AAKA,
|
|
1
|
+
{"version":3,"file":"modify-utils-Cw-on_cL.js","names":["dedent","fs","TIME_AGO_SNIPPET","NOT_FOUND_HINT","UNITS_SNIPPET","FUNCTION_SNIPPET","modifyUtils","utilsPath","originalSource","sourceFile","Project","QuoteKind","hasTimeAgo","hasUnits","toAppend"],"sources":["../../src/runtime/modify-utils.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { Project, QuoteKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../core/types\";\n\nconst TIME_AGO_SNIPPET = dedent`\n const TIME_AGO_UNITS: [Intl.RelativeTimeFormatUnit, number][] = [\n ['year', 60 * 60 * 24 * 365],\n ['month', 60 * 60 * 24 * 30],\n ['day', 60 * 60 * 24],\n ['hour', 60 * 60],\n ['minute', 60],\n ['second', 1]\n ];\n\n export function timeAgo(date: Date | string | number, locale?: string) {\n const rtf = new Intl.RelativeTimeFormat(locale, { numeric: 'auto' });\n const diff = (new Date(date).getTime() - Date.now()) / 1000;\n\n for (const [unit, secs] of TIME_AGO_UNITS) {\n if (Math.abs(diff) >= secs || unit === 'second') {\n return rtf.format(Math.round(diff / secs), unit);\n }\n }\n }\n`;\n\nconst NOT_FOUND_HINT = dedent`\n Create src/lib/utils.ts with a timeAgo helper:\n\n ${TIME_AGO_SNIPPET}\n`;\n\nconst UNITS_SNIPPET = dedent`\n const TIME_AGO_UNITS: [Intl.RelativeTimeFormatUnit, number][] = [\n ['year', 60 * 60 * 24 * 365],\n ['month', 60 * 60 * 24 * 30],\n ['day', 60 * 60 * 24],\n ['hour', 60 * 60],\n ['minute', 60],\n ['second', 1]\n ];\n`;\n\nconst FUNCTION_SNIPPET = dedent`\n export function timeAgo(date: Date | string | number, locale?: string) {\n const rtf = new Intl.RelativeTimeFormat(locale, { numeric: 'auto' });\n const diff = (new Date(date).getTime() - Date.now()) / 1000;\n\n for (const [unit, secs] of TIME_AGO_UNITS) {\n if (Math.abs(diff) >= secs || unit === 'second') {\n return rtf.format(Math.round(diff / secs), unit);\n }\n }\n }\n`;\n\nexport function modifyUtils(utilsPath: string): ModifyOutcome {\n if (!fs.existsSync(utilsPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const originalSource = fs.readFileSync(utilsPath, \"utf8\");\n const project = new Project({\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(utilsPath);\n\n const hasTimeAgo =\n sourceFile.getFunction(\"timeAgo\") !== undefined ||\n sourceFile.getVariableDeclaration(\"timeAgo\") !== undefined;\n const hasUnits =\n sourceFile.getVariableDeclaration(\"TIME_AGO_UNITS\") !== undefined;\n\n if (hasTimeAgo && hasUnits) {\n return { status: \"success\", changed: false };\n }\n\n const toAppend: string[] = [];\n if (!hasUnits) toAppend.push(UNITS_SNIPPET);\n if (!hasTimeAgo) toAppend.push(FUNCTION_SNIPPET);\n\n sourceFile.addStatements(\"\\n\" + toAppend.join(\"\\n\\n\") + \"\\n\");\n sourceFile.saveSync();\n\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\n };\n}\n"],"mappings":";;;;AAKA,IAAME,IAAmB,CAAM;;;;;;;;;;;;;;;;;;;;GAsBzBC,IAAiB,CAAM;;;IAGzBD,EAAiB;GAGfE,IAAgB,CAAM;;;;;;;;;GAWtBC,IAAmB,CAAM;;;;;;;;;;;;AAa/B,SAAgBC,EAAY,GAAkC;CAC5D,IAAI,CAACL,EAAG,WAAWM,CAAS,GAC1B,OAAO;EAAE,QAAQ;EAAa,SAASJ;CAAe;CAGxD,IAAMK,IAAiBP,EAAG,aAAaM,GAAW,MAAM,GAIlDE,IAAa,IAHCC,EAAQ,EAC1B,sBAAsB,EAAE,WAAWC,EAAU,OAAO,EACtD,CACmB,CAAA,CAAQ,oBAAoBJ,CAAS,GAElDK,IACJH,EAAW,YAAY,SAAS,MAAM,KAAA,KACtCA,EAAW,uBAAuB,SAAS,MAAM,KAAA,GAC7CI,IACJJ,EAAW,uBAAuB,gBAAgB,MAAM,KAAA;CAE1D,IAAIG,KAAcC,GAChB,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAMC,IAAqB,CAAC;CAO5B,OANKD,KAAUC,EAAS,KAAKV,CAAa,GACrCQ,KAAYE,EAAS,KAAKT,CAAgB,GAE/CI,EAAW,cAAc,OAAOK,EAAS,KAAK,MAAM,IAAI,IAAI,GAC5DL,EAAW,SAAS,GAEb;EACL,QAAQ;EACR,SAASA,EAAW,YAAY,MAAMD;CACxC;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package-imports-Bbw3iMPg.js","names":[],"sources":["../../src/runtime/package-imports.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { ModifyOutcome } from \"../core/types\";\n\n/**\n * Edits to the project's `package.json` that npm has no command for: the\n * `imports` map SvelteKit 3 resolves `#lib` (and `#locales`) through, and\n * `overrides`. The file is rewritten with the indentation and trailing\n * newline it had, and a key that already holds a different value is never\n * overwritten: it is the project's, and the outcome says what to change.\n */\n\nexport interface PackageJsonEditResult {\n filePath: string;\n outcome: ModifyOutcome;\n}\n\ntype Json = string | number | boolean | null | Json[] | { [key: string]: Json };\ntype JsonObject = { [key: string]: Json };\n\n/** An `overrides` value: a version, or nested overrides (npm's `\".\"` is the package itself). */\nexport type OverrideValue = string | { [key: string]: OverrideValue };\n\ninterface PackageFile {\n filePath: string;\n text: string;\n pkg: JsonObject;\n indent: string;\n eol: string;\n trailing: string;\n}\n\nfunction isObject(value: unknown): value is JsonObject {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction readPackage(root: string): PackageFile | PackageJsonEditResult {\n const filePath = path.join(root, \"package.json\");\n if (!fs.existsSync(filePath)) {\n return {\n filePath,\n outcome: { status: \"not-found\", message: \"No package.json to edit.\" },\n };\n }\n const text = fs.readFileSync(filePath, \"utf8\");\n let pkg: unknown;\n try {\n pkg = JSON.parse(text);\n } catch {\n return {\n filePath,\n outcome: { status: \"failed\", message: \"package.json is not valid JSON.\" },\n };\n }\n if (!isObject(pkg)) {\n return {\n filePath,\n outcome: { status: \"failed\", message: \"package.json is not an object.\" },\n };\n }\n const indent = text.match(/^[{[][^\\S\\n]*\\r?\\n([\\t ]+)\\S/)?.[1] ?? \"\\t\";\n const eol = text.includes(\"\\r\\n\") ? \"\\r\\n\" : \"\\n\";\n const trailing = text.match(/(\\r?\\n)*$/)?.[0] ?? \"\";\n return { filePath, text, pkg, indent, eol, trailing };\n}\n\nfunction writePackage(file: PackageFile): ModifyOutcome {\n const body = JSON.stringify(file.pkg, null, file.indent).replace(\n /\\n/g,\n file.eol,\n );\n const next = body + file.trailing;\n if (next === file.text) return { status: \"success\", changed: false };\n fs.writeFileSync(file.filePath, next, \"utf8\");\n return { status: \"success\", changed: true };\n}\n\n/**\n * Add `key` to `pkg` right after the first of `after` it has, else at the end.\n * JSON object key order is insertion order, so this rebuilds the object.\n */\nfunction insertKey(\n pkg: JsonObject,\n key: string,\n value: Json,\n after: string[],\n): JsonObject {\n const anchor = after.find((name) => name in pkg);\n if (!anchor) return { ...pkg, [key]: value };\n const next: JsonObject = {};\n for (const [name, existing] of Object.entries(pkg)) {\n next[name] = existing;\n if (name === anchor) next[key] = value;\n }\n return next;\n}\n\nfunction finish(\n file: PackageFile,\n conflicts: string[],\n field: string,\n): PackageJsonEditResult {\n const outcome = writePackage(file);\n if (conflicts.length === 0) return { filePath: file.filePath, outcome };\n return {\n filePath: file.filePath,\n outcome: {\n status: \"failed\",\n message: [\n `package.json \\`${field}\\` already has a different value for:`,\n ...conflicts.map((line) => ` ${line}`),\n \"Change these by hand if vela's value is the one you want.\",\n ].join(\"\\n\"),\n },\n };\n}\n\n/**\n * Add the subpath `imports` (`{ \"#lib/*\": \"./src/lib/*\" }`) that are missing.\n * Creates `imports` after `type` when the project has none.\n */\nexport function ensurePackageImports(\n root: string,\n entries: Record<string, string>,\n): PackageJsonEditResult {\n const file = readPackage(root);\n if (!(\"pkg\" in file)) return file;\n\n const current = file.pkg.imports;\n if (current !== undefined && !isObject(current)) {\n return {\n filePath: file.filePath,\n outcome: {\n status: \"failed\",\n message: [\n \"package.json `imports` is not an object. Add these entries to it by hand:\",\n ...Object.entries(entries).map(\n ([key, value]) =>\n ` ${JSON.stringify(key)}: ${JSON.stringify(value)}`,\n ),\n ].join(\"\\n\"),\n },\n };\n }\n\n const imports: JsonObject = { ...(current ?? {}) };\n const conflicts: string[] = [];\n for (const [key, value] of Object.entries(entries)) {\n if (!(key in imports)) {\n imports[key] = value;\n } else if (imports[key] !== value) {\n conflicts.push(\n `${JSON.stringify(key)}: ${JSON.stringify(imports[key])} (vela uses ${JSON.stringify(value)})`,\n );\n }\n }\n file.pkg =\n current === undefined\n ? Object.keys(imports).length > 0\n ? insertKey(file.pkg, \"imports\", imports, [\"type\", \"version\", \"name\"])\n : file.pkg\n : { ...file.pkg, imports };\n return finish(file, conflicts, \"imports\");\n}\n\n/**\n * Remove subpath `imports` keys. With `expected`, a key is removed only while\n * it still maps to the value vela wrote, so one the developer repointed stays.\n * An `imports` left empty is removed too.\n */\nexport function removePackageImports(\n root: string,\n keys: string[],\n expected?: Record<string, string>,\n): PackageJsonEditResult {\n const file = readPackage(root);\n if (!(\"pkg\" in file)) {\n // Nothing to revert in a project without a package.json.\n return file.outcome.status === \"not-found\"\n ? {\n filePath: file.filePath,\n outcome: { status: \"success\", changed: false },\n }\n : file;\n }\n const current = file.pkg.imports;\n if (!isObject(current)) {\n return {\n filePath: file.filePath,\n outcome: { status: \"success\", changed: false },\n };\n }\n const imports: JsonObject = { ...current };\n for (const key of keys) {\n if (!(key in imports)) continue;\n if (expected && key in expected && imports[key] !== expected[key]) continue;\n delete imports[key];\n }\n if (Object.keys(imports).length === 0) {\n const { imports: _, ...rest } = file.pkg;\n file.pkg = rest;\n } else {\n file.pkg = { ...file.pkg, imports };\n }\n return { filePath: file.filePath, outcome: writePackage(file) };\n}\n\n/**\n * Deep-merge `overrides` into package.json's `overrides`, created at the end\n * when missing. A version already there that differs is left as it is and\n * reported. A package overridden with a bare version that now needs nested\n * overrides keeps that version as npm's `\".\"`.\n */\nexport function ensurePackageOverrides(\n root: string,\n overrides: Record<string, OverrideValue>,\n): PackageJsonEditResult {\n const file = readPackage(root);\n if (!(\"pkg\" in file)) return file;\n\n const current = file.pkg.overrides;\n if (current !== undefined && !isObject(current)) {\n return {\n filePath: file.filePath,\n outcome: {\n status: \"failed\",\n message: `package.json \\`overrides\\` is not an object. Add this to it by hand:\\n${JSON.stringify(overrides, null, 2)}`,\n },\n };\n }\n const conflicts: string[] = [];\n const merged = mergeOverrides(current ?? {}, overrides, [], conflicts);\n file.pkg = { ...file.pkg, overrides: merged };\n return finish(file, conflicts, \"overrides\");\n}\n\nfunction mergeOverrides(\n target: JsonObject,\n source: Record<string, OverrideValue>,\n trail: string[],\n conflicts: string[],\n): JsonObject {\n const out: JsonObject = { ...target };\n for (const [key, wanted] of Object.entries(source)) {\n const have = out[key];\n const where = [...trail, key].join(\" > \");\n if (have === undefined) {\n out[key] = wanted as Json;\n } else if (typeof wanted === \"string\") {\n if (have === wanted) continue;\n if (isObject(have) && have[\".\"] === wanted) continue;\n conflicts.push(\n `${where}: ${JSON.stringify(have)} (vela uses ${JSON.stringify(wanted)})`,\n );\n } else if (isObject(have)) {\n out[key] = mergeOverrides(have, wanted, [...trail, key], conflicts);\n } else if (typeof have === \"string\") {\n out[key] = mergeOverrides(\n { \".\": have },\n wanted,\n [...trail, key],\n conflicts,\n );\n } else {\n conflicts.push(\n `${where}: ${JSON.stringify(have)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,GAAG,GAAW,CAAC,GAAG,CAAS;CAErE,OADA,EAAK,MAAM;EAAE,GAAG,EAAK;EAAK,WAAW;CAAO,GACrC,EAAO,GAAM,GAAW,WAAW;AAC5C;AAEA,SAAS,EACP,GACA,GACA,GACA,GACY;CACZ,IAAM,IAAkB,EAAE,GAAG,EAAO;CACpC,KAAK,IAAM,CAAC,GAAK,MAAW,OAAO,QAAQ,CAAM,GAAG;EAClD,IAAM,IAAO,EAAI,IACX,IAAQ,CAAC,GAAG,GAAO,CAAG,CAAC,CAAC,KAAK,KAAK;EACxC,IAAI,MAAS,KAAA,GACX,EAAI,KAAO;OACN,IAAI,OAAO,KAAW,UAAU;GAErC,IADI,MAAS,KACT,EAAS,CAAI,KAAK,EAAK,SAAS,GAAQ;GAC5C,EAAU,KACR,GAAG,EAAM,IAAI,KAAK,UAAU,CAAI,EAAE,cAAc,KAAK,UAAU,CAAM,EAAE,EACzE;EACF,OAAO,AAAI,EAAS,CAAI,IACtB,EAAI,KAAO,EAAe,GAAM,GAAQ,CAAC,GAAG,GAAO,CAAG,GAAG,CAAS,IACzD,OAAO,KAAS,WACzB,EAAI,KAAO,EACT,EAAE,KAAK,EAAK,GACZ,GACA,CAAC,GAAG,GAAO,CAAG,GACd,CACF,IAEA,EAAU,KACR,GAAG,EAAM,IAAI,KAAK,UAAU,CAAI,EAAE,cAAc,KAAK,UAAU,CAAM,EAAE,EACzE;CAEJ;CACA,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"package-imports-Bbw3iMPg.js","names":["__exportAll","fs","path","package_imports_exports","ensurePackageImports","ensurePackageOverrides","removePackageImports","isObject","value","readPackage","filePath","root","text","pkg","indent","eol","trailing","writePackage","next","file","insertKey","anchor","after","name","key","existing","finish","outcome","conflicts","field","line","current","entries","imports","keys","expected","_","rest","overrides","merged","mergeOverrides","out","target","wanted","source","have","where","trail"],"sources":["../../src/runtime/package-imports.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { ModifyOutcome } from \"../core/types\";\n\n/**\n * Edits to the project's `package.json` that npm has no command for: the\n * `imports` map SvelteKit 3 resolves `#lib` (and `#locales`) through, and\n * `overrides`. The file is rewritten with the indentation and trailing\n * newline it had, and a key that already holds a different value is never\n * overwritten: it is the project's, and the outcome says what to change.\n */\n\nexport interface PackageJsonEditResult {\n filePath: string;\n outcome: ModifyOutcome;\n}\n\ntype Json = string | number | boolean | null | Json[] | { [key: string]: Json };\ntype JsonObject = { [key: string]: Json };\n\n/** An `overrides` value: a version, or nested overrides (npm's `\".\"` is the package itself). */\nexport type OverrideValue = string | { [key: string]: OverrideValue };\n\ninterface PackageFile {\n filePath: string;\n text: string;\n pkg: JsonObject;\n indent: string;\n eol: string;\n trailing: string;\n}\n\nfunction isObject(value: unknown): value is JsonObject {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction readPackage(root: string): PackageFile | PackageJsonEditResult {\n const filePath = path.join(root, \"package.json\");\n if (!fs.existsSync(filePath)) {\n return {\n filePath,\n outcome: { status: \"not-found\", message: \"No package.json to edit.\" },\n };\n }\n const text = fs.readFileSync(filePath, \"utf8\");\n let pkg: unknown;\n try {\n pkg = JSON.parse(text);\n } catch {\n return {\n filePath,\n outcome: { status: \"failed\", message: \"package.json is not valid JSON.\" },\n };\n }\n if (!isObject(pkg)) {\n return {\n filePath,\n outcome: { status: \"failed\", message: \"package.json is not an object.\" },\n };\n }\n const indent = text.match(/^[{[][^\\S\\n]*\\r?\\n([\\t ]+)\\S/)?.[1] ?? \"\\t\";\n const eol = text.includes(\"\\r\\n\") ? \"\\r\\n\" : \"\\n\";\n const trailing = text.match(/(\\r?\\n)*$/)?.[0] ?? \"\";\n return { filePath, text, pkg, indent, eol, trailing };\n}\n\nfunction writePackage(file: PackageFile): ModifyOutcome {\n const body = JSON.stringify(file.pkg, null, file.indent).replace(\n /\\n/g,\n file.eol,\n );\n const next = body + file.trailing;\n if (next === file.text) return { status: \"success\", changed: false };\n fs.writeFileSync(file.filePath, next, \"utf8\");\n return { status: \"success\", changed: true };\n}\n\n/**\n * Add `key` to `pkg` right after the first of `after` it has, else at the end.\n * JSON object key order is insertion order, so this rebuilds the object.\n */\nfunction insertKey(\n pkg: JsonObject,\n key: string,\n value: Json,\n after: string[],\n): JsonObject {\n const anchor = after.find((name) => name in pkg);\n if (!anchor) return { ...pkg, [key]: value };\n const next: JsonObject = {};\n for (const [name, existing] of Object.entries(pkg)) {\n next[name] = existing;\n if (name === anchor) next[key] = value;\n }\n return next;\n}\n\nfunction finish(\n file: PackageFile,\n conflicts: string[],\n field: string,\n): PackageJsonEditResult {\n const outcome = writePackage(file);\n if (conflicts.length === 0) return { filePath: file.filePath, outcome };\n return {\n filePath: file.filePath,\n outcome: {\n status: \"failed\",\n message: [\n `package.json \\`${field}\\` already has a different value for:`,\n ...conflicts.map((line) => ` ${line}`),\n \"Change these by hand if vela's value is the one you want.\",\n ].join(\"\\n\"),\n },\n };\n}\n\n/**\n * Add the subpath `imports` (`{ \"#lib/*\": \"./src/lib/*\" }`) that are missing.\n * Creates `imports` after `type` when the project has none.\n */\nexport function ensurePackageImports(\n root: string,\n entries: Record<string, string>,\n): PackageJsonEditResult {\n const file = readPackage(root);\n if (!(\"pkg\" in file)) return file;\n\n const current = file.pkg.imports;\n if (current !== undefined && !isObject(current)) {\n return {\n filePath: file.filePath,\n outcome: {\n status: \"failed\",\n message: [\n \"package.json `imports` is not an object. Add these entries to it by hand:\",\n ...Object.entries(entries).map(\n ([key, value]) =>\n ` ${JSON.stringify(key)}: ${JSON.stringify(value)}`,\n ),\n ].join(\"\\n\"),\n },\n };\n }\n\n const imports: JsonObject = { ...(current ?? {}) };\n const conflicts: string[] = [];\n for (const [key, value] of Object.entries(entries)) {\n if (!(key in imports)) {\n imports[key] = value;\n } else if (imports[key] !== value) {\n conflicts.push(\n `${JSON.stringify(key)}: ${JSON.stringify(imports[key])} (vela uses ${JSON.stringify(value)})`,\n );\n }\n }\n file.pkg =\n current === undefined\n ? Object.keys(imports).length > 0\n ? insertKey(file.pkg, \"imports\", imports, [\"type\", \"version\", \"name\"])\n : file.pkg\n : { ...file.pkg, imports };\n return finish(file, conflicts, \"imports\");\n}\n\n/**\n * Remove subpath `imports` keys. With `expected`, a key is removed only while\n * it still maps to the value vela wrote, so one the developer repointed stays.\n * An `imports` left empty is removed too.\n */\nexport function removePackageImports(\n root: string,\n keys: string[],\n expected?: Record<string, string>,\n): PackageJsonEditResult {\n const file = readPackage(root);\n if (!(\"pkg\" in file)) {\n // Nothing to revert in a project without a package.json.\n return file.outcome.status === \"not-found\"\n ? {\n filePath: file.filePath,\n outcome: { status: \"success\", changed: false },\n }\n : file;\n }\n const current = file.pkg.imports;\n if (!isObject(current)) {\n return {\n filePath: file.filePath,\n outcome: { status: \"success\", changed: false },\n };\n }\n const imports: JsonObject = { ...current };\n for (const key of keys) {\n if (!(key in imports)) continue;\n if (expected && key in expected && imports[key] !== expected[key]) continue;\n delete imports[key];\n }\n if (Object.keys(imports).length === 0) {\n const { imports: _, ...rest } = file.pkg;\n file.pkg = rest;\n } else {\n file.pkg = { ...file.pkg, imports };\n }\n return { filePath: file.filePath, outcome: writePackage(file) };\n}\n\n/**\n * Deep-merge `overrides` into package.json's `overrides`, created at the end\n * when missing. A version already there that differs is left as it is and\n * reported. A package overridden with a bare version that now needs nested\n * overrides keeps that version as npm's `\".\"`.\n */\nexport function ensurePackageOverrides(\n root: string,\n overrides: Record<string, OverrideValue>,\n): PackageJsonEditResult {\n const file = readPackage(root);\n if (!(\"pkg\" in file)) return file;\n\n const current = file.pkg.overrides;\n if (current !== undefined && !isObject(current)) {\n return {\n filePath: file.filePath,\n outcome: {\n status: \"failed\",\n message: `package.json \\`overrides\\` is not an object. Add this to it by hand:\\n${JSON.stringify(overrides, null, 2)}`,\n },\n };\n }\n const conflicts: string[] = [];\n const merged = mergeOverrides(current ?? {}, overrides, [], conflicts);\n file.pkg = { ...file.pkg, overrides: merged };\n return finish(file, conflicts, \"overrides\");\n}\n\nfunction mergeOverrides(\n target: JsonObject,\n source: Record<string, OverrideValue>,\n trail: string[],\n conflicts: string[],\n): JsonObject {\n const out: JsonObject = { ...target };\n for (const [key, wanted] of Object.entries(source)) {\n const have = out[key];\n const where = [...trail, key].join(\" > \");\n if (have === undefined) {\n out[key] = wanted as Json;\n } else if (typeof wanted === \"string\") {\n if (have === wanted) continue;\n if (isObject(have) && have[\".\"] === wanted) continue;\n conflicts.push(\n `${where}: ${JSON.stringify(have)} (vela uses ${JSON.stringify(wanted)})`,\n );\n } else if (isObject(have)) {\n out[key] = mergeOverrides(have, wanted, [...trail, key], conflicts);\n } else if (typeof have === \"string\") {\n out[key] = mergeOverrides(\n { \".\": have },\n wanted,\n [...trail, key],\n conflicts,\n );\n } else {\n conflicts.push(\n `${where}: ${JSON.stringify(have)} (vela uses ${JSON.stringify(wanted)})`,\n );\n }\n }\n return out;\n}\n"],"mappings":";;;;;;;;;AAgCA,SAASO,EAAS,GAAqC;CACrD,OAAO,OAAOC,KAAU,cAAYA,KAAkB,CAAC,MAAM,QAAQA,CAAK;AAC5E;AAEA,SAASC,EAAY,GAAmD;CACtE,IAAMC,IAAWR,EAAK,KAAKS,GAAM,cAAc;CAC/C,IAAI,CAACV,EAAG,WAAWS,CAAQ,GACzB,OAAO;EACL;EACA,SAAS;GAAE,QAAQ;GAAa,SAAS;EAA2B;CACtE;CAEF,IAAME,IAAOX,EAAG,aAAaS,GAAU,MAAM,GACzCG;CACJ,IAAI;EACF,IAAM,KAAK,MAAMD,CAAI;CACvB,QAAQ;EACN,OAAO;GACL;GACA,SAAS;IAAE,QAAQ;IAAU,SAAS;GAAkC;EAC1E;CACF;CACA,IAAI,CAACL,EAASM,CAAG,GACf,OAAO;EACL;EACA,SAAS;GAAE,QAAQ;GAAU,SAAS;EAAiC;CACzE;CAEF,IAAMC,IAASF,EAAK,MAAM,8BAA8B,CAAC,GAAG,MAAM,KAC5DG,IAAMH,EAAK,SAAS,MAAM,IAAI,SAAS,MACvCI,IAA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,GAAGG,EAAM,IAAI,KAAK,UAAUD,CAAI,EAAE,cAAc,KAAK,UAAUF,CAAM,EAAE,EACzE;EACF,OAAO,AAAIpC,EAASsC,CAAI,IACtB,EAAIrB,KAAOgB,EAAeK,GAAMF,GAAQ,CAAC,GAAGI,GAAOvB,CAAG,GAAGI,CAAS,IACzD,OAAOiB,KAAS,WACzB,EAAIrB,KAAOgB,EACT,EAAE,KAAKK,EAAK,GACZF,GACA,CAAC,GAAGI,GAAOvB,CAAG,GACdI,CACF,IAEAA,EAAU,KACR,GAAGkB,EAAM,IAAI,KAAK,UAAUD,CAAI,EAAE,cAAc,KAAK,UAAUF,CAAM,EAAE,EACzE;CAEJ;CACA,OAAOF;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pocketbase-C5GS-Dh5.js","names":[],"sources":["../../src/patterns/enable/teams/runtime/pocketbase.ts"],"sourcesContent":["import type { CollectionRulesPatch } from \"../../../../core/types\";\n\n/** Applied after all team collections are created (create-time rules are omitted). */\nexport const TEAM_RULE_PATCHES: CollectionRulesPatch[] = [\n {\n collectionName: \"teams\",\n listRule:\n \"team_memberships_via_team.user ?= @request.auth.id || owner = @request.auth.id\",\n viewRule: '@request.auth.id != \"\"',\n createRule: \"owner = @request.auth.id\",\n updateRule: \"owner = @request.auth.id\",\n deleteRule: \"owner = @request.auth.id\",\n },\n {\n collectionName: \"team_memberships\",\n listRule:\n \"user = @request.auth.id || team.team_memberships_via_team.user ?= @request.auth.id\",\n viewRule:\n \"user = @request.auth.id || team.team_memberships_via_team.user ?= @request.auth.id\",\n createRule: null,\n updateRule:\n \"((team.team_memberships_via_team.role ?= 'owner' || team.team_memberships_via_team.role ?= 'admin') && team.team_memberships_via_team.user ?= @request.auth.id)\",\n deleteRule:\n \"user = @request.auth.id || ((team.team_memberships_via_team.role ?= 'owner' || team.team_memberships_via_team.role ?= 'admin') && team.team_memberships_via_team.user ?= @request.auth.id)\",\n },\n {\n collectionName: \"team_users\",\n listRule:\n \"id = @request.auth.id || team.team_memberships_via_team.user ?= @request.auth.id\",\n viewRule:\n \"id = @request.auth.id || team.team_memberships_via_team.user ?= @request.auth.id\",\n createRule: null,\n updateRule: null,\n deleteRule: null,\n },\n {\n collectionName: \"team_invites\",\n listRule:\n \"email = @request.auth.email || ((team.team_memberships_via_team.role ?= 'owner' || team.team_memberships_via_team.role ?= 'admin') && team.team_memberships_via_team.user ?= @request.auth.id)\",\n viewRule:\n \"email = @request.auth.email || ((team.team_memberships_via_team.role ?= 'owner' || team.team_memberships_via_team.role ?= 'admin') && team.team_memberships_via_team.user ?= @request.auth.id)\",\n createRule:\n \"((team.team_memberships_via_team.role ?= 'owner' || team.team_memberships_via_team.role ?= 'admin') && team.team_memberships_via_team.user ?= @request.auth.id)\",\n updateRule: null,\n deleteRule:\n \"((team.team_memberships_via_team.role ?= 'owner' || team.team_memberships_via_team.role ?= 'admin') && team.team_memberships_via_team.user ?= @request.auth.id)\",\n },\n {\n collectionName: \"team_invite_links\",\n listRule: null,\n viewRule: '@request.auth.id != \"\"',\n createRule: null,\n updateRule: null,\n deleteRule: null,\n },\n];\n"],"mappings":";AAGA,
|
|
1
|
+
{"version":3,"file":"pocketbase-C5GS-Dh5.js","names":["TEAM_RULE_PATCHES"],"sources":["../../src/patterns/enable/teams/runtime/pocketbase.ts"],"sourcesContent":["import type { CollectionRulesPatch } from \"../../../../core/types\";\n\n/** Applied after all team collections are created (create-time rules are omitted). */\nexport const TEAM_RULE_PATCHES: CollectionRulesPatch[] = [\n {\n collectionName: \"teams\",\n listRule:\n \"team_memberships_via_team.user ?= @request.auth.id || owner = @request.auth.id\",\n viewRule: '@request.auth.id != \"\"',\n createRule: \"owner = @request.auth.id\",\n updateRule: \"owner = @request.auth.id\",\n deleteRule: \"owner = @request.auth.id\",\n },\n {\n collectionName: \"team_memberships\",\n listRule:\n \"user = @request.auth.id || team.team_memberships_via_team.user ?= @request.auth.id\",\n viewRule:\n \"user = @request.auth.id || team.team_memberships_via_team.user ?= @request.auth.id\",\n createRule: null,\n updateRule:\n \"((team.team_memberships_via_team.role ?= 'owner' || team.team_memberships_via_team.role ?= 'admin') && team.team_memberships_via_team.user ?= @request.auth.id)\",\n deleteRule:\n \"user = @request.auth.id || ((team.team_memberships_via_team.role ?= 'owner' || team.team_memberships_via_team.role ?= 'admin') && team.team_memberships_via_team.user ?= @request.auth.id)\",\n },\n {\n collectionName: \"team_users\",\n listRule:\n \"id = @request.auth.id || team.team_memberships_via_team.user ?= @request.auth.id\",\n viewRule:\n \"id = @request.auth.id || team.team_memberships_via_team.user ?= @request.auth.id\",\n createRule: null,\n updateRule: null,\n deleteRule: null,\n },\n {\n collectionName: \"team_invites\",\n listRule:\n \"email = @request.auth.email || ((team.team_memberships_via_team.role ?= 'owner' || team.team_memberships_via_team.role ?= 'admin') && team.team_memberships_via_team.user ?= @request.auth.id)\",\n viewRule:\n \"email = @request.auth.email || ((team.team_memberships_via_team.role ?= 'owner' || team.team_memberships_via_team.role ?= 'admin') && team.team_memberships_via_team.user ?= @request.auth.id)\",\n createRule:\n \"((team.team_memberships_via_team.role ?= 'owner' || team.team_memberships_via_team.role ?= 'admin') && team.team_memberships_via_team.user ?= @request.auth.id)\",\n updateRule: null,\n deleteRule:\n \"((team.team_memberships_via_team.role ?= 'owner' || team.team_memberships_via_team.role ?= 'admin') && team.team_memberships_via_team.user ?= @request.auth.id)\",\n },\n {\n collectionName: \"team_invite_links\",\n listRule: null,\n viewRule: '@request.auth.id != \"\"',\n createRule: null,\n updateRule: null,\n deleteRule: null,\n },\n];\n"],"mappings":";AAGA,IAAaA,IAA4C;CACvD;EACE,gBAAgB;EAChB,UACE;EACF,UAAU;EACV,YAAY;EACZ,YAAY;EACZ,YAAY;CACd;CACA;EACE,gBAAgB;EAChB,UACE;EACF,UACE;EACF,YAAY;EACZ,YACE;EACF,YACE;CACJ;CACA;EACE,gBAAgB;EAChB,UACE;EACF,UACE;EACF,YAAY;EACZ,YAAY;EACZ,YAAY;CACd;CACA;EACE,gBAAgB;EAChB,UACE;EACF,UACE;EACF,YACE;EACF,YAAY;EACZ,YACE;CACJ;CACA;EACE,gBAAgB;EAChB,UAAU;EACV,UAAU;EACV,YAAY;EACZ,YAAY;EACZ,YAAY;CACd;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as e } from "./rolldown-runtime-DArdT4gl.js";
|
|
2
|
-
import { c as t, i as n } from "./constants-
|
|
2
|
+
import { c as t, i as n } from "./constants-Rq8SCXwH.js";
|
|
3
3
|
import { existsSync as r, readFileSync as i, readdirSync as a } from "node:fs";
|
|
4
4
|
import o from "node:path";
|
|
5
5
|
import s from "pocketbase";
|
|
@@ -232,4 +232,4 @@ function T(e, t) {
|
|
|
232
232
|
//#endregion
|
|
233
233
|
export { w as i, b as n, v as r, x as t };
|
|
234
234
|
|
|
235
|
-
//# sourceMappingURL=pocketbase-
|
|
235
|
+
//# sourceMappingURL=pocketbase-CgwbH1gI.js.map
|