@velastack/patterns 0.0.18 → 0.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -0
- package/dist/chunks/collections-C7dgGs-E.js +67 -0
- package/dist/chunks/collections-C7dgGs-E.js.map +1 -0
- package/dist/chunks/{env.runtime-DtXAdiod.js → env.runtime-DwDRkEXV.js} +2 -2
- package/dist/chunks/{env.runtime-DtXAdiod.js.map → env.runtime-DwDRkEXV.js.map} +1 -1
- package/dist/chunks/generate.runtime-C7g-zL0o.js.map +1 -1
- package/dist/chunks/generate.runtime-D21wXYWT.js +172 -0
- package/dist/chunks/generate.runtime-D21wXYWT.js.map +1 -0
- package/dist/chunks/generate.runtime-DcDyK2xK.js +334 -0
- package/dist/chunks/generate.runtime-DcDyK2xK.js.map +1 -0
- package/dist/chunks/{generate.runtime-Bhlrr9q4.js → generate.runtime-cNqC7P0N.js} +33 -10
- package/dist/chunks/generate.runtime-cNqC7P0N.js.map +1 -0
- package/dist/chunks/generate.runtime-toUqgDQY.js +610 -0
- package/dist/chunks/generate.runtime-toUqgDQY.js.map +1 -0
- package/dist/chunks/{index-DAkiQcTu.js → index-GTS4D08Z.js} +2538 -2248
- package/dist/chunks/index-GTS4D08Z.js.map +1 -0
- package/dist/chunks/{pocketbase-lfpOUvM5.js → pocketbase-QZ34CciJ.js} +50 -45
- package/dist/chunks/pocketbase-QZ34CciJ.js.map +1 -0
- package/dist/chunks/ts-morph-helpers-BNCluWTs.js +166 -0
- package/dist/chunks/ts-morph-helpers-BNCluWTs.js.map +1 -0
- package/dist/chunks/{write-result-CbUTMeAc.js → write-result-DmD7kWlV.js} +81 -70
- package/dist/chunks/write-result-DmD7kWlV.js.map +1 -0
- package/dist/index.d.ts +67 -0
- package/dist/index.js +1 -1
- package/package.json +19 -4
- package/dist/chunks/collections-CMh5lXoZ.js +0 -62
- package/dist/chunks/collections-CMh5lXoZ.js.map +0 -1
- package/dist/chunks/generate.runtime-B4YCHeuI.js +0 -227
- package/dist/chunks/generate.runtime-B4YCHeuI.js.map +0 -1
- package/dist/chunks/generate.runtime-Bhlrr9q4.js.map +0 -1
- package/dist/chunks/generate.runtime-C4q7Pq37.js +0 -633
- package/dist/chunks/generate.runtime-C4q7Pq37.js.map +0 -1
- package/dist/chunks/generate.runtime-MR_6kBLS.js +0 -353
- package/dist/chunks/generate.runtime-MR_6kBLS.js.map +0 -1
- package/dist/chunks/index-DAkiQcTu.js.map +0 -1
- package/dist/chunks/pocketbase-lfpOUvM5.js.map +0 -1
- package/dist/chunks/write-result-CbUTMeAc.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generate.runtime-Bhlrr9q4.js","sources":["../../src/patterns/enable/i18n/modifies/vite-config.ts","../../src/patterns/enable/i18n/modifies/svelte-config.ts","../../src/patterns/enable/i18n/modifies/hooks.server.ts","../../src/patterns/enable/i18n/modifies/app-html.ts","../../src/patterns/enable/i18n/modifies/gitignore.ts","../../src/patterns/enable/i18n/modifies/+layout.ts","../../src/patterns/enable/i18n/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { Project, QuoteKind, SyntaxKind } from \"ts-morph\";\n\nexport function modifyViteConfig(viteConfigPath: string) {\n if (!fs.existsSync(viteConfigPath)) return false;\n\n const project = new Project({\n compilerOptions: { allowJs: true },\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(viteConfigPath);\n\n let changed = false;\n\n const hasImport = sourceFile\n .getImportDeclarations()\n .some((d) => d.getModuleSpecifierValue() === \"wuchale/vite\");\n\n if (!hasImport) {\n sourceFile.insertImportDeclaration(0, {\n namedImports: [\"wuchale\"],\n moduleSpecifier: \"wuchale/vite\",\n });\n changed = true;\n }\n\n const defineConfigCall = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .find((ce) => ce.getExpression().getText() === \"defineConfig\");\n\n const configArg = defineConfigCall?.getArguments()?.[0];\n const configObj =\n configArg?.getKind() === SyntaxKind.ObjectLiteralExpression\n ? (configArg as import(\"ts-morph\").ObjectLiteralExpression)\n : null;\n\n if (!configObj) {\n if (changed) {\n sourceFile.formatText();\n sourceFile.saveSync();\n }\n return changed;\n }\n\n const pluginsProp = configObj.getProperty(\"plugins\");\n if (!pluginsProp) {\n configObj.addPropertyAssignment({ name: \"plugins\", initializer: \"[wuchale()]\" });\n sourceFile.formatText();\n sourceFile.saveSync();\n return true;\n }\n\n if (pluginsProp.getKind() !== SyntaxKind.PropertyAssignment) {\n if (changed) {\n sourceFile.formatText();\n sourceFile.saveSync();\n }\n return changed;\n }\n\n const pluginsInit = (\n pluginsProp as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n if (!pluginsInit) {\n (pluginsProp as import(\"ts-morph\").PropertyAssignment).setInitializer(\n \"[wuchale()]\",\n );\n sourceFile.formatText();\n sourceFile.saveSync();\n return true;\n }\n\n if (pluginsInit.getKind() !== SyntaxKind.ArrayLiteralExpression) {\n if (changed) {\n sourceFile.formatText();\n sourceFile.saveSync();\n }\n return changed;\n }\n\n const arr = pluginsInit as import(\"ts-morph\").ArrayLiteralExpression;\n const hasWuchale = arr\n .getElements()\n .some((el) => el.getText().replace(/\\s/g, \"\") === \"wuchale()\");\n\n if (!hasWuchale) {\n arr.insertElement(0, \"wuchale()\");\n changed = true;\n }\n\n if (changed) {\n sourceFile.formatText();\n sourceFile.saveSync();\n }\n\n return changed;\n}\n","import fs from \"node:fs\";\nimport { Project, QuoteKind, SyntaxKind, type ObjectLiteralExpression } from \"ts-morph\";\n\nfunction getOrCreateObjectLiteralProperty(\n obj: ObjectLiteralExpression,\n name: string,\n initializer: string,\n): ObjectLiteralExpression | null {\n const prop = obj.getProperty(name);\n if (!prop) {\n obj.addPropertyAssignment({ name, initializer });\n const added = obj.getProperty(name);\n if (!added || added.getKind() !== SyntaxKind.PropertyAssignment) return null;\n const init = (added as import(\"ts-morph\").PropertyAssignment).getInitializer();\n if (!init || init.getKind() !== SyntaxKind.ObjectLiteralExpression) return null;\n return init as ObjectLiteralExpression;\n }\n\n if (prop.getKind() !== SyntaxKind.PropertyAssignment) return null;\n const init = (prop as import(\"ts-morph\").PropertyAssignment).getInitializer();\n if (!init) return null;\n if (init.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n (prop as import(\"ts-morph\").PropertyAssignment).setInitializer(initializer);\n const init2 = (prop as import(\"ts-morph\").PropertyAssignment).getInitializer();\n return init2 && init2.getKind() === SyntaxKind.ObjectLiteralExpression\n ? (init2 as ObjectLiteralExpression)\n : null;\n }\n\n return init as ObjectLiteralExpression;\n}\n\nexport function modifySvelteConfig(svelteConfigPath: string) {\n if (!fs.existsSync(svelteConfigPath)) return false;\n\n const project = new Project({\n compilerOptions: { allowJs: true },\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(svelteConfigPath);\n\n const defaultExport = sourceFile.getExportAssignment((ea) => !ea.isExportEquals());\n const exportedExpr = defaultExport?.getExpression();\n\n let configObj: ObjectLiteralExpression | null = null;\n if (exportedExpr?.getKind() === SyntaxKind.ObjectLiteralExpression) {\n configObj = exportedExpr as ObjectLiteralExpression;\n } else if (exportedExpr?.getKind() === SyntaxKind.Identifier) {\n const ident = exportedExpr.getText();\n const varDecl = sourceFile.getVariableDeclaration(ident);\n const init = varDecl?.getInitializer();\n if (init?.getKind() === SyntaxKind.ObjectLiteralExpression) {\n configObj = init as ObjectLiteralExpression;\n }\n }\n\n if (!configObj) return false;\n\n const kitObj = getOrCreateObjectLiteralProperty(configObj, \"kit\", \"{}\");\n if (!kitObj) return false;\n\n const aliasObj = getOrCreateObjectLiteralProperty(kitObj, \"alias\", \"{}\");\n if (!aliasObj) return false;\n\n const existingLocales = aliasObj.getProperty(\"$locales\");\n if (!existingLocales) {\n aliasObj.addPropertyAssignment({ name: \"$locales\", initializer: \"'src/locales'\" });\n sourceFile.formatText();\n sourceFile.saveSync();\n return true;\n }\n\n if (existingLocales.getKind() !== SyntaxKind.PropertyAssignment) return false;\n const init = (existingLocales as import(\"ts-morph\").PropertyAssignment).getInitializer();\n const current = init?.getText()?.replace(/['\"`]/g, \"\");\n if (current === \"src/locales\") return false;\n\n (existingLocales as import(\"ts-morph\").PropertyAssignment).setInitializer(\n \"'src/locales'\",\n );\n sourceFile.formatText();\n sourceFile.saveSync();\n return true;\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { Project, QuoteKind, SyntaxKind } from \"ts-morph\";\n\nfunction ensureNamedImport(\n sourceFile: import(\"ts-morph\").SourceFile,\n moduleSpecifier: string,\n name: string,\n) {\n const existing = sourceFile\n .getImportDeclarations()\n .find((d) => d.getModuleSpecifierValue() === moduleSpecifier);\n if (existing) {\n const has = existing.getNamedImports().some((ni) => ni.getName() === name);\n if (!has) existing.addNamedImport(name);\n return;\n }\n sourceFile.addImportDeclaration({ namedImports: [name], moduleSpecifier });\n}\n\nfunction ensureNamespaceImport(\n sourceFile: import(\"ts-morph\").SourceFile,\n moduleSpecifier: string,\n ns: string,\n) {\n const existing = sourceFile\n .getImportDeclarations()\n .find((d) => d.getModuleSpecifierValue() === moduleSpecifier);\n if (existing) return;\n sourceFile.addImportDeclaration({ namespaceImport: ns, moduleSpecifier });\n}\n\nexport function modifyHooksServerI18n(hooksServerPath: string) {\n if (!fs.existsSync(hooksServerPath)) return false;\n\n const original = fs.readFileSync(hooksServerPath, \"utf8\");\n if (original.includes(\"runWithLocale\") || original.includes(\"loadLocales(\")) {\n return false;\n }\n\n const project = new Project({\n compilerOptions: { allowJs: true },\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(hooksServerPath);\n\n const handleDecl = sourceFile.getVariableDeclaration(\"handle\");\n if (!handleDecl) return false;\n\n const handleStmt = handleDecl.getFirstAncestorByKind(SyntaxKind.VariableStatement);\n if (!handleStmt?.hasExportKeyword()) {\n return false;\n }\n\n ensureNamedImport(sourceFile, \"@sveltejs/kit/hooks\", \"sequence\");\n ensureNamedImport(sourceFile, \"wuchale/load-utils/server\", \"runWithLocale\");\n ensureNamedImport(sourceFile, \"wuchale/load-utils/server\", \"loadLocales\");\n ensureNamedImport(sourceFile, \"$locales/main.url\", \"getLocale\");\n ensureNamedImport(sourceFile, \"$locales/data\", \"locales\");\n ensureNamespaceImport(sourceFile, \"$locales/main.loader.server.svelte.js\", \"main\");\n ensureNamespaceImport(sourceFile, \"$locales/js.loader.server.js\", \"js\");\n\n const statements = sourceFile.getStatements();\n const handleStmtIndex = statements.findIndex((s) => s === handleStmt);\n const i18nHandleName = \"handleWuchale\";\n\n const startupSnippet = dedent`\n loadLocales(main.key, main.loadIDs, main.loadCatalog, locales);\n loadLocales(js.key, js.loadIDs, js.loadCatalog, locales);\n `;\n\n const i18nHandleSnippet = dedent`\n const ${i18nHandleName} = async ({ event, resolve }: any) => {\n const locale = getLocale(event.url);\n return await runWithLocale(locale, () =>\n resolve(event, {\n transformPageChunk: ({ html }: { html: string }) =>\n html.replace('%sveltekit.lang%', locale)\n })\n );\n };\n `;\n\n if (handleStmtIndex >= 0) {\n sourceFile.insertStatements(\n handleStmtIndex,\n `\\n${startupSnippet}\\n\\n${i18nHandleSnippet}\\n`,\n );\n } else {\n sourceFile.addStatements(`\\n${startupSnippet}\\n\\n${i18nHandleSnippet}\\n`);\n }\n\n const init = handleDecl.getInitializer();\n if (!init) return false;\n\n const initText = init.getText();\n if (initText.includes(i18nHandleName) || initText.includes(\"runWithLocale\")) {\n return false;\n }\n\n handleDecl.setInitializer(`sequence(${i18nHandleName}, ${initText})`);\n sourceFile.formatText();\n sourceFile.saveSync();\n return true;\n}\n","import fs from \"node:fs\";\n\nexport function modifyAppHtml(appHtmlPath: string) {\n if (!fs.existsSync(appHtmlPath)) return false;\n\n const original = fs.readFileSync(appHtmlPath, \"utf8\");\n if (\n original.includes('lang=\"%sveltekit.lang%\"') ||\n original.includes(\"lang='%sveltekit.lang%'\")\n ) {\n return false;\n }\n\n const updated = original.replace(/<html(\\s[^>]*?)?>/i, (match) => {\n if (/lang\\s*=/.test(match)) {\n return match;\n }\n return match.replace(/<html/i, '<html lang=\"%sveltekit.lang%\"');\n });\n\n if (updated === original) return false;\n fs.writeFileSync(appHtmlPath, updated);\n return true;\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\n\nexport function modifyGitignore(gitignorePath: string) {\n if (!fs.existsSync(gitignorePath)) return false;\n\n const original = fs.readFileSync(gitignorePath, \"utf8\");\n if (original.includes(\"src/locales/.wuchale\")) return false;\n\n const block = dedent`\n # Wuchale\n src/locales/.wuchale\n `;\n\n const needsNewline = original.length > 0 && !original.endsWith(\"\\n\");\n const updated = original + (needsNewline ? \"\\n\" : \"\") + \"\\n\" + block + \"\\n\";\n fs.writeFileSync(gitignorePath, updated);\n return true;\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport dedent from \"dedent\";\n\nexport function ensureRootLayoutI18n(layoutPath: string) {\n if (fs.existsSync(layoutPath)) {\n const existing = fs.readFileSync(layoutPath, \"utf8\");\n if (existing.includes(\"loadLocale\") || existing.includes(\"translateUrl\")) {\n return false;\n }\n\n if (/\\bexport\\s+(const|function)\\s+load\\b/.test(existing)) {\n return false;\n }\n }\n\n const snippet = dedent`\n import { browser } from '$app/environment';\n import { loadLocale } from 'wuchale/load-utils';\n\n import { getLocale } from '$locales/main.url';\n import '$locales/main.loader.svelte';\n import '$locales/js.loader';\n\n export const load = async ({ url, data }) => {\n const locale = getLocale(url);\n\n if (browser) {\n await loadLocale(locale);\n }\n\n return data;\n };\n `;\n\n fs.mkdirSync(path.dirname(layoutPath), { recursive: true });\n fs.writeFileSync(layoutPath, snippet + \"\\n\");\n return true;\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { modifyViteConfig } from \"./modifies/vite-config\";\nimport { modifySvelteConfig } from \"./modifies/svelte-config\";\nimport { modifyHooksServerI18n } from \"./modifies/hooks.server\";\nimport { modifyAppHtml } from \"./modifies/app-html\";\nimport { modifyGitignore } from \"./modifies/gitignore\";\nimport { ensureRootLayoutI18n } from \"./modifies/+layout\";\n\nfunction findFirstExistingFile(root: string, candidates: string[]): string | null {\n for (const relPath of candidates) {\n const absPath = path.join(root, relPath);\n if (fs.existsSync(absPath)) {\n return absPath;\n }\n }\n return null;\n}\n\nfunction pushIfChanged(modifies: File[], filePath: string, changed: boolean) {\n if (!changed || !fs.existsSync(filePath)) return;\n modifies.push({\n path: filePath,\n language: filePath.endsWith(\".svelte\")\n ? \"svelte\"\n : filePath.endsWith(\".ts\")\n ? \"ts\"\n : filePath.endsWith(\".js\")\n ? \"js\"\n : \"text\",\n content: fs.readFileSync(filePath, \"utf8\"),\n });\n}\n\nexport async function generate(options: Options) {\n const modifies: File[] = [];\n\n const viteConfigPath = findFirstExistingFile(options.root, [\n \"vite.config.ts\",\n \"vite.config.js\",\n \"vite.config.mjs\",\n \"vite.config.cjs\",\n ]);\n if (viteConfigPath) {\n pushIfChanged(modifies, viteConfigPath, modifyViteConfig(viteConfigPath));\n }\n\n const svelteConfigPath = findFirstExistingFile(options.root, [\n \"svelte.config.ts\",\n \"svelte.config.js\",\n \"svelte.config.mjs\",\n \"svelte.config.cjs\",\n ]);\n if (svelteConfigPath) {\n pushIfChanged(modifies, svelteConfigPath, modifySvelteConfig(svelteConfigPath));\n }\n\n const hooksServerPath = path.join(options.root, \"src\", \"hooks.server.ts\");\n pushIfChanged(modifies, hooksServerPath, modifyHooksServerI18n(hooksServerPath));\n\n const appHtmlPath = path.join(options.root, \"src\", \"app.html\");\n pushIfChanged(modifies, appHtmlPath, modifyAppHtml(appHtmlPath));\n\n const layoutPath = path.join(options.root, \"src\", \"routes\", \"+layout.ts\");\n pushIfChanged(modifies, layoutPath, ensureRootLayoutI18n(layoutPath));\n\n const gitignorePath = path.join(options.root, \".gitignore\");\n pushIfChanged(modifies, gitignorePath, modifyGitignore(gitignorePath));\n\n return {\n creates: [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n } satisfies Result;\n}\n"],"names":["modifyViteConfig","viteConfigPath","fs","sourceFile","Project","QuoteKind","changed","d","defineConfigCall","SyntaxKind","ce","configArg","_a","configObj","pluginsProp","pluginsInit","arr","el","getOrCreateObjectLiteralProperty","obj","name","initializer","prop","added","init","init2","modifySvelteConfig","svelteConfigPath","defaultExport","ea","exportedExpr","ident","varDecl","kitObj","aliasObj","existingLocales","ensureNamedImport","moduleSpecifier","existing","ni","ensureNamespaceImport","ns","modifyHooksServerI18n","hooksServerPath","original","handleDecl","handleStmt","handleStmtIndex","s","i18nHandleName","startupSnippet","dedent","i18nHandleSnippet","initText","modifyAppHtml","appHtmlPath","updated","match","modifyGitignore","gitignorePath","block","needsNewline","ensureRootLayoutI18n","layoutPath","snippet","path","findFirstExistingFile","root","candidates","relPath","absPath","pushIfChanged","modifies","filePath","generate","options"],"mappings":";;;;AAGO,SAASA,EAAiBC,GAAwB;;AACvD,MAAI,CAACC,EAAG,WAAWD,CAAc,EAAG,QAAO;AAM3C,QAAME,IAJU,IAAIC,EAAQ;AAAA,IAC1B,iBAAiB,EAAE,SAAS,GAAA;AAAA,IAC5B,sBAAsB,EAAE,WAAWC,EAAU,OAAA;AAAA,EAAO,CACrD,EAC0B,oBAAoBJ,CAAc;AAE7D,MAAIK,IAAU;AAMd,EAJkBH,EACf,wBACA,KAAK,CAACI,MAAMA,EAAE,wBAAA,MAA8B,cAAc,MAG3DJ,EAAW,wBAAwB,GAAG;AAAA,IACpC,cAAc,CAAC,SAAS;AAAA,IACxB,iBAAiB;AAAA,EAAA,CAClB,GACDG,IAAU;AAGZ,QAAME,IAAmBL,EACtB,qBAAqBM,EAAW,cAAc,EAC9C,KAAK,CAACC,MAAOA,EAAG,cAAA,EAAgB,QAAA,MAAc,cAAc,GAEzDC,KAAYC,IAAAJ,KAAA,gBAAAA,EAAkB,mBAAlB,gBAAAI,EAAmC,IAC/CC,KACJF,KAAA,gBAAAA,EAAW,e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AAgBM,EAAK,KAAKU,EAAQ,MAAM,YAAY;AAC1D,SAAAJ,EAAcC,GAAUb,GAAeD,EAAgBC,CAAa,CAAC,GAE9D;AAAA,IACL,SAAS,CAAA;AAAA,IACT,UAAAa;AAAA,IACA,SAAS,CAAA;AAAA,IACT,YAAY,CAAA;AAAA,IACZ,UAAU,CAAA;AAAA,IACV,aAAa,CAAA;AAAA,EAAC;AAElB;"}
|
|
@@ -1,633 +0,0 @@
|
|
|
1
|
-
import f from "node:fs";
|
|
2
|
-
import A from "node:path";
|
|
3
|
-
import { d as z, T as j, l as P } from "./index-DAkiQcTu.js";
|
|
4
|
-
import { applyCollectionRulePatches as _ } from "./collections-CMh5lXoZ.js";
|
|
5
|
-
import { w as O, g as D } from "./pocketbase-lfpOUvM5.js";
|
|
6
|
-
import { Project as F, SyntaxKind as s, QuoteKind as N } from "ts-morph";
|
|
7
|
-
function L(t) {
|
|
8
|
-
if (!f.existsSync(t))
|
|
9
|
-
return !1;
|
|
10
|
-
let n = f.readFileSync(t, "utf8");
|
|
11
|
-
if (n.includes("teams={data.teams"))
|
|
12
|
-
return !1;
|
|
13
|
-
const o = "<AppSidebar user={data.user} meta={data.meta} />", r = "<AppSidebar user={data.user} meta={data.meta} team={data.team} teams={data.teams ?? []} />";
|
|
14
|
-
return n.includes(o) ? (n = n.replace(o, r), f.writeFileSync(t, n, "utf8"), !0) : !1;
|
|
15
|
-
}
|
|
16
|
-
const I = /import NavUser from ['"]\.\/nav-user\.svelte['"];/, C = `import NavUser from './nav-user.svelte';
|
|
17
|
-
import TeamSwitcher from '$lib/components/team-switcher.svelte';
|
|
18
|
-
import ChevronsUpDownIcon from '@lucide/svelte/icons/chevrons-up-down';
|
|
19
|
-
import * as Avatar from '$lib/components/ui/avatar';`, U = `<Sidebar.Header>
|
|
20
|
-
<Sidebar.Menu>
|
|
21
|
-
<TeamSwitcher {teams}>
|
|
22
|
-
{#snippet children()}
|
|
23
|
-
{@const activeTeam = teams.find((t) => t.id === team)}
|
|
24
|
-
{#if activeTeam}
|
|
25
|
-
<Avatar.Root class="size-8 rounded-lg">
|
|
26
|
-
<Avatar.Fallback class="rounded-lg bg-primary text-primary-foreground font-medium">
|
|
27
|
-
{activeTeam.name?.charAt(0).toUpperCase()}
|
|
28
|
-
</Avatar.Fallback>
|
|
29
|
-
</Avatar.Root>
|
|
30
|
-
<div class="grid flex-1 text-left text-sm leading-tight">
|
|
31
|
-
<span class="truncate font-medium">
|
|
32
|
-
{activeTeam.name}
|
|
33
|
-
</span>
|
|
34
|
-
</div>
|
|
35
|
-
{:else}
|
|
36
|
-
<div
|
|
37
|
-
class="bg-sidebar-accent text-sidebar-primary-foreground flex aspect-square size-8 items-center justify-center rounded-lg"
|
|
38
|
-
>
|
|
39
|
-
<img src="/favicon.svg" alt="logo" class="size-6" />
|
|
40
|
-
</div>
|
|
41
|
-
<div class="grid flex-1 text-left text-sm leading-tight">
|
|
42
|
-
<span class="truncate font-medium">{meta.appName}</span>
|
|
43
|
-
</div>
|
|
44
|
-
{/if}
|
|
45
|
-
<ChevronsUpDownIcon class="ml-auto" />
|
|
46
|
-
{/snippet}
|
|
47
|
-
</TeamSwitcher>
|
|
48
|
-
</Sidebar.Menu>
|
|
49
|
-
</Sidebar.Header>`;
|
|
50
|
-
function q(t) {
|
|
51
|
-
if (!f.existsSync(t))
|
|
52
|
-
return !1;
|
|
53
|
-
let n = f.readFileSync(t, "utf8");
|
|
54
|
-
if (n.includes("TeamSwitcher") || !I.test(n))
|
|
55
|
-
return !1;
|
|
56
|
-
n = n.replace(I, C), n = n.replace(
|
|
57
|
-
/let \{[\s\S]*?\}: ComponentProps<typeof Sidebar\.Root> & \{ user: any; meta: any \} = \$props\(\);/,
|
|
58
|
-
`let {
|
|
59
|
-
user,
|
|
60
|
-
meta,
|
|
61
|
-
team,
|
|
62
|
-
teams = [],
|
|
63
|
-
ref = $bindable(null),
|
|
64
|
-
...restProps
|
|
65
|
-
}: ComponentProps<typeof Sidebar.Root> & {
|
|
66
|
-
user: any;
|
|
67
|
-
meta: any;
|
|
68
|
-
team?: string | undefined;
|
|
69
|
-
teams?: { id: string; name: string }[];
|
|
70
|
-
} = $props();`
|
|
71
|
-
);
|
|
72
|
-
const o = n.match(/<Sidebar\.Header>[\s\S]*?<\/Sidebar\.Header>/);
|
|
73
|
-
return o ? (n = n.replace(o[0], U), f.writeFileSync(t, n, "utf8"), !0) : !1;
|
|
74
|
-
}
|
|
75
|
-
function R(t) {
|
|
76
|
-
if (!f.existsSync(t)) {
|
|
77
|
-
const e = z`
|
|
78
|
-
export const load = async ({ locals, depends }) => {
|
|
79
|
-
const user = locals.pb.authStore.record!;
|
|
80
|
-
const team = locals.team;
|
|
81
|
-
const teams = await locals.pb.collection("teams").getFullList();
|
|
82
|
-
depends("app:team");
|
|
83
|
-
|
|
84
|
-
const breadcrumbs = [{ title: "Home", url: "/dashboard" }];
|
|
85
|
-
return { user, team, teams, breadcrumbs };
|
|
86
|
-
};
|
|
87
|
-
`;
|
|
88
|
-
f.writeFileSync(t, e);
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
const o = new F().addSourceFileAtPath(t), r = (e, a, c) => {
|
|
92
|
-
!!e.getProperty(a) || (a === c ? e.addShorthandPropertyAssignment({ name: a }) : e.addPropertyAssignment({ name: a, initializer: c }));
|
|
93
|
-
};
|
|
94
|
-
let p, m;
|
|
95
|
-
const g = o.getVariableDeclaration("load");
|
|
96
|
-
if (g) {
|
|
97
|
-
const e = g.getFirstAncestorByKind(s.VariableStatement);
|
|
98
|
-
if (!!(e != null && e.hasExportKeyword())) {
|
|
99
|
-
const c = g.getInitializerIfKind(s.ArrowFunction);
|
|
100
|
-
if (c)
|
|
101
|
-
p = c;
|
|
102
|
-
else {
|
|
103
|
-
const i = g.getInitializer();
|
|
104
|
-
if (i) {
|
|
105
|
-
const l = i.getFirstDescendantByKind(s.ArrowFunction);
|
|
106
|
-
if (l)
|
|
107
|
-
p = l;
|
|
108
|
-
else {
|
|
109
|
-
const u = i.getFirstDescendantByKind(s.FunctionExpression);
|
|
110
|
-
u && (m = u);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
if (!p) {
|
|
117
|
-
const e = o.getFunction("load");
|
|
118
|
-
e && e.isExported() && (m = e);
|
|
119
|
-
}
|
|
120
|
-
if (!p && !m) {
|
|
121
|
-
o.addFunction({
|
|
122
|
-
isExported: !0,
|
|
123
|
-
isAsync: !0,
|
|
124
|
-
name: "load",
|
|
125
|
-
parameters: [{ name: "{ locals, depends }" }],
|
|
126
|
-
statements: [
|
|
127
|
-
"const user = locals.pb.authStore.record!;",
|
|
128
|
-
"const team = locals.team;",
|
|
129
|
-
'const teams = await locals.pb.collection("teams").getFullList();',
|
|
130
|
-
'depends("app:team");',
|
|
131
|
-
"",
|
|
132
|
-
'const breadcrumbs = [{ title: "Home", url: "/dashboard" }];',
|
|
133
|
-
"return { user, team, teams, breadcrumbs };"
|
|
134
|
-
]
|
|
135
|
-
}), o.formatText(), o.saveSync();
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
const d = p ?? m, S = d.getParameters();
|
|
139
|
-
if (S.length === 0)
|
|
140
|
-
d.insertParameter(0, { name: "{ locals, depends }" });
|
|
141
|
-
else {
|
|
142
|
-
const e = S[0], a = e.getStructure(), c = e.getNameNode();
|
|
143
|
-
if (c.getKind() === s.ObjectBindingPattern) {
|
|
144
|
-
const i = c, l = i.getElements().some((x) => x.getName() === "depends"), u = i.getElements().some((x) => x.getName() === "locals");
|
|
145
|
-
if (!l) {
|
|
146
|
-
const x = i.getElements().map((w) => w.getText()).filter(Boolean), b = x.length > 0 ? ", " + x.join(", ") : "";
|
|
147
|
-
u ? e.set({
|
|
148
|
-
name: `{ depends${b} }`,
|
|
149
|
-
type: a.type,
|
|
150
|
-
initializer: a.initializer
|
|
151
|
-
}) : e.set({
|
|
152
|
-
name: `{ locals, depends${b} }`,
|
|
153
|
-
type: a.type,
|
|
154
|
-
initializer: a.initializer
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
} else {
|
|
158
|
-
const i = e.getName();
|
|
159
|
-
i !== "locals" ? e.set({
|
|
160
|
-
name: `{ locals, depends, ...${i} }`,
|
|
161
|
-
type: a.type,
|
|
162
|
-
initializer: a.initializer
|
|
163
|
-
}) : e.set({
|
|
164
|
-
name: "{ locals, depends }",
|
|
165
|
-
type: a.type,
|
|
166
|
-
initializer: a.initializer
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
p && !p.isAsync() ? p.setIsAsync(!0) : m && !m.isAsync() && m.setIsAsync(!0);
|
|
171
|
-
const y = d.getBody();
|
|
172
|
-
if (y && y.getKind() === s.Block) {
|
|
173
|
-
const e = y, a = e.getStatements(), c = a.some(
|
|
174
|
-
(u) => u.getKind() === s.VariableStatement && u.getDescendantsOfKind(s.Identifier).some((x) => x.getText() === "team")
|
|
175
|
-
), i = a.some(
|
|
176
|
-
(u) => u.getKind() === s.VariableStatement && u.getDescendantsOfKind(s.Identifier).some((x) => x.getText() === "teams")
|
|
177
|
-
), l = a.some(
|
|
178
|
-
(u) => u.getKind() === s.ExpressionStatement && u.getDescendantsOfKind(s.CallExpression).some((x) => {
|
|
179
|
-
var K;
|
|
180
|
-
if (x.getExpression().getText() !== "depends") return !1;
|
|
181
|
-
const w = x.getArguments(), h = ((K = w[0]) == null ? void 0 : K.getText()) ?? "";
|
|
182
|
-
return w.length === 1 && (h === "'app:team'" || h === '"app:team"');
|
|
183
|
-
})
|
|
184
|
-
);
|
|
185
|
-
c || e.insertStatements(1, "const team = locals.team;"), i || e.insertStatements(
|
|
186
|
-
2,
|
|
187
|
-
'const teams = await locals.pb.collection("teams").getFullList();'
|
|
188
|
-
), l || e.insertStatements(3, 'depends("app:team");');
|
|
189
|
-
}
|
|
190
|
-
if (p) {
|
|
191
|
-
const e = p.getBody();
|
|
192
|
-
if (e.getKind() === s.Block)
|
|
193
|
-
e.getDescendantsOfKind(s.ReturnStatement).forEach((c) => {
|
|
194
|
-
const i = c.getExpression();
|
|
195
|
-
if (i) {
|
|
196
|
-
if (i.getKind() === s.ObjectLiteralExpression) {
|
|
197
|
-
const l = i;
|
|
198
|
-
r(l, "team", "team"), r(l, "teams", "teams");
|
|
199
|
-
} else if (i.getKind() === s.ParenthesizedExpression) {
|
|
200
|
-
const l = i.getExpression();
|
|
201
|
-
if (l.getKind() === s.ObjectLiteralExpression) {
|
|
202
|
-
const u = l;
|
|
203
|
-
r(u, "team", "team"), r(u, "teams", "teams");
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
});
|
|
208
|
-
else {
|
|
209
|
-
const a = e;
|
|
210
|
-
if (a.getKind() === s.ParenthesizedExpression) {
|
|
211
|
-
const c = a.getExpression();
|
|
212
|
-
if (c.getKind() === s.ObjectLiteralExpression) {
|
|
213
|
-
const i = c;
|
|
214
|
-
r(i, "team", "team"), r(i, "teams", "teams");
|
|
215
|
-
}
|
|
216
|
-
} else if (a.getKind() === s.ObjectLiteralExpression) {
|
|
217
|
-
const c = a;
|
|
218
|
-
r(c, "team", "team"), r(c, "teams", "teams");
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
} else if (m) {
|
|
222
|
-
const e = m.getBody();
|
|
223
|
-
e && e.getDescendantsOfKind(s.ReturnStatement).forEach((c) => {
|
|
224
|
-
const i = c.getExpression();
|
|
225
|
-
if (i) {
|
|
226
|
-
if (i.getKind() === s.ObjectLiteralExpression) {
|
|
227
|
-
const l = i;
|
|
228
|
-
r(l, "team", "team"), r(l, "teams", "teams");
|
|
229
|
-
} else if (i.getKind() === s.ParenthesizedExpression) {
|
|
230
|
-
const l = i.getExpression();
|
|
231
|
-
if (l.getKind() === s.ObjectLiteralExpression) {
|
|
232
|
-
const u = l;
|
|
233
|
-
r(u, "team", "team"), r(u, "teams", "teams");
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
});
|
|
238
|
-
}
|
|
239
|
-
o.formatText(), o.saveSync();
|
|
240
|
-
}
|
|
241
|
-
function T(t, n, o, r, p) {
|
|
242
|
-
const m = `
|
|
243
|
-
{
|
|
244
|
-
title: '${n}',
|
|
245
|
-
url: '${o}',
|
|
246
|
-
icon: ${r}
|
|
247
|
-
}
|
|
248
|
-
`, d = new F({
|
|
249
|
-
useInMemoryFileSystem: !0,
|
|
250
|
-
skipFileDependencyResolution: !0,
|
|
251
|
-
manipulationSettings: { quoteKind: N.Single }
|
|
252
|
-
}).createSourceFile("module.ts", t, { overwrite: !0 });
|
|
253
|
-
d.getImportDeclarations().some((a) => a.getModuleSpecifierValue() === p) || d.addImportDeclaration({ defaultImport: r, moduleSpecifier: p });
|
|
254
|
-
const y = d.getVariableDeclarations().find((a) => a.getName() === "data"), e = y == null ? void 0 : y.getInitializer();
|
|
255
|
-
if (e && e.getKind() === s.ObjectLiteralExpression) {
|
|
256
|
-
const c = e.asKindOrThrow(s.ObjectLiteralExpression).getProperty("navUser");
|
|
257
|
-
if (c && c.getKind() === s.PropertyAssignment) {
|
|
258
|
-
const l = c.asKindOrThrow(s.PropertyAssignment).getInitializer();
|
|
259
|
-
if (l && l.getKind() === s.ArrayLiteralExpression) {
|
|
260
|
-
const u = l.asKindOrThrow(s.ArrayLiteralExpression);
|
|
261
|
-
if (!u.getElements().some((b) => {
|
|
262
|
-
if (b.getKind() !== s.ObjectLiteralExpression) return !1;
|
|
263
|
-
const h = b.asKindOrThrow(s.ObjectLiteralExpression).getProperty("title");
|
|
264
|
-
if (!h || h.getKind() !== s.PropertyAssignment) return !1;
|
|
265
|
-
const E = h.asKindOrThrow(s.PropertyAssignment).getInitializer();
|
|
266
|
-
return (E == null ? void 0 : E.getKind()) === s.StringLiteral && E.getLiteralText() === n;
|
|
267
|
-
}))
|
|
268
|
-
return u.addElement(m.trim()), d.formatText(), { newInner: d.getFullText(), wasAdded: !0 };
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
return { newInner: t, wasAdded: !1 };
|
|
273
|
-
}
|
|
274
|
-
function $(t, n, o, r, p) {
|
|
275
|
-
const m = /<script\b([^>]*)>([\s\S]*?)<\/script>/gi;
|
|
276
|
-
let g;
|
|
277
|
-
for (; (g = m.exec(t)) !== null; ) {
|
|
278
|
-
const d = g[1] ?? "";
|
|
279
|
-
if (!(/\bmodule\b/.test(d) || /context\s*=\s*"module"/.test(d)))
|
|
280
|
-
continue;
|
|
281
|
-
const y = `<script${d}>`, e = g[2] ?? "", a = g.index, c = m.lastIndex, { newInner: i, wasAdded: l } = T(
|
|
282
|
-
e,
|
|
283
|
-
n,
|
|
284
|
-
o,
|
|
285
|
-
r,
|
|
286
|
-
p
|
|
287
|
-
);
|
|
288
|
-
if (l)
|
|
289
|
-
return {
|
|
290
|
-
newNavUserSnippet: t.slice(0, a) + y + i + "<\/script>" + t.slice(c),
|
|
291
|
-
wasAdded: !0
|
|
292
|
-
};
|
|
293
|
-
}
|
|
294
|
-
for (m.lastIndex = 0; (g = m.exec(t)) !== null; ) {
|
|
295
|
-
const d = g[1] ?? "";
|
|
296
|
-
if (/\bmodule\b/.test(d) || /context\s*=\s*"module"/.test(d))
|
|
297
|
-
continue;
|
|
298
|
-
const y = g[2] ?? "";
|
|
299
|
-
if (!y.includes("navUser"))
|
|
300
|
-
continue;
|
|
301
|
-
const e = `<script${d}>`, a = g.index, c = m.lastIndex, { newInner: i, wasAdded: l } = T(
|
|
302
|
-
y,
|
|
303
|
-
n,
|
|
304
|
-
o,
|
|
305
|
-
r,
|
|
306
|
-
p
|
|
307
|
-
);
|
|
308
|
-
if (l)
|
|
309
|
-
return {
|
|
310
|
-
newNavUserSnippet: t.slice(0, a) + e + i + "<\/script>" + t.slice(c),
|
|
311
|
-
wasAdded: !0
|
|
312
|
-
};
|
|
313
|
-
}
|
|
314
|
-
return { newNavUserSnippet: t, wasAdded: !1 };
|
|
315
|
-
}
|
|
316
|
-
function M(t) {
|
|
317
|
-
if (!f.existsSync(t))
|
|
318
|
-
return !1;
|
|
319
|
-
const n = f.readFileSync(t, "utf8"), { newNavUserSnippet: o, wasAdded: r } = $(
|
|
320
|
-
n,
|
|
321
|
-
"Teams",
|
|
322
|
-
"/teams",
|
|
323
|
-
"UsersIcon",
|
|
324
|
-
"@lucide/svelte/icons/users"
|
|
325
|
-
);
|
|
326
|
-
return r && f.writeFileSync(t, o, "utf8"), r;
|
|
327
|
-
}
|
|
328
|
-
function v(t, n, o) {
|
|
329
|
-
const r = D(n, "created", o);
|
|
330
|
-
r && t.push({
|
|
331
|
-
path: r,
|
|
332
|
-
language: P(r),
|
|
333
|
-
content: f.readFileSync(r, "utf8")
|
|
334
|
-
});
|
|
335
|
-
}
|
|
336
|
-
async function X(t) {
|
|
337
|
-
const n = [];
|
|
338
|
-
await O(t.root, async (d) => {
|
|
339
|
-
const S = await d.collections.getOne("users"), y = await d.collections.create({
|
|
340
|
-
name: "teams",
|
|
341
|
-
type: "base",
|
|
342
|
-
fields: [
|
|
343
|
-
{
|
|
344
|
-
name: "id",
|
|
345
|
-
type: "text",
|
|
346
|
-
primaryKey: !0,
|
|
347
|
-
autogeneratePattern: "[a-z0-9]{15}",
|
|
348
|
-
max: 15,
|
|
349
|
-
min: 15,
|
|
350
|
-
pattern: "^[a-z0-9]+$",
|
|
351
|
-
required: !0
|
|
352
|
-
},
|
|
353
|
-
{
|
|
354
|
-
name: "name",
|
|
355
|
-
type: "text",
|
|
356
|
-
required: !0
|
|
357
|
-
},
|
|
358
|
-
{
|
|
359
|
-
name: "owner",
|
|
360
|
-
type: "relation",
|
|
361
|
-
cascadeDelete: !1,
|
|
362
|
-
collectionId: S.id,
|
|
363
|
-
maxSelect: 1,
|
|
364
|
-
minSelect: 0,
|
|
365
|
-
required: !0
|
|
366
|
-
},
|
|
367
|
-
{
|
|
368
|
-
name: "created",
|
|
369
|
-
type: "autodate",
|
|
370
|
-
onCreate: !0,
|
|
371
|
-
onUpdate: !1
|
|
372
|
-
},
|
|
373
|
-
{
|
|
374
|
-
name: "updated",
|
|
375
|
-
type: "autodate",
|
|
376
|
-
onCreate: !0,
|
|
377
|
-
onUpdate: !0
|
|
378
|
-
}
|
|
379
|
-
]
|
|
380
|
-
});
|
|
381
|
-
v(n, "teams", t);
|
|
382
|
-
const e = await d.collections.create({
|
|
383
|
-
name: "team_memberships",
|
|
384
|
-
type: "base",
|
|
385
|
-
fields: [
|
|
386
|
-
{
|
|
387
|
-
name: "id",
|
|
388
|
-
autogeneratePattern: "[a-z0-9]{15}",
|
|
389
|
-
max: 15,
|
|
390
|
-
min: 15,
|
|
391
|
-
pattern: "^[a-z0-9]+$",
|
|
392
|
-
primaryKey: !0,
|
|
393
|
-
required: !0,
|
|
394
|
-
type: "text"
|
|
395
|
-
},
|
|
396
|
-
{
|
|
397
|
-
name: "team",
|
|
398
|
-
cascadeDelete: !0,
|
|
399
|
-
collectionId: y.id,
|
|
400
|
-
maxSelect: 1,
|
|
401
|
-
minSelect: 0,
|
|
402
|
-
required: !0,
|
|
403
|
-
type: "relation"
|
|
404
|
-
},
|
|
405
|
-
{
|
|
406
|
-
name: "user",
|
|
407
|
-
cascadeDelete: !0,
|
|
408
|
-
collectionId: S.id,
|
|
409
|
-
maxSelect: 1,
|
|
410
|
-
minSelect: 0,
|
|
411
|
-
required: !0,
|
|
412
|
-
type: "relation"
|
|
413
|
-
},
|
|
414
|
-
{
|
|
415
|
-
name: "role",
|
|
416
|
-
maxSelect: 1,
|
|
417
|
-
required: !0,
|
|
418
|
-
type: "select",
|
|
419
|
-
values: ["owner", "admin", "member"]
|
|
420
|
-
},
|
|
421
|
-
{
|
|
422
|
-
name: "created",
|
|
423
|
-
onCreate: !0,
|
|
424
|
-
onUpdate: !1,
|
|
425
|
-
type: "autodate"
|
|
426
|
-
},
|
|
427
|
-
{
|
|
428
|
-
name: "updated",
|
|
429
|
-
onCreate: !0,
|
|
430
|
-
onUpdate: !0,
|
|
431
|
-
type: "autodate"
|
|
432
|
-
}
|
|
433
|
-
]
|
|
434
|
-
});
|
|
435
|
-
v(n, "team_memberships", t), await d.collections.create({
|
|
436
|
-
name: "team_users",
|
|
437
|
-
type: "view",
|
|
438
|
-
fields: [
|
|
439
|
-
{
|
|
440
|
-
name: "id",
|
|
441
|
-
pattern: "^[a-z0-9]+$",
|
|
442
|
-
primaryKey: !0,
|
|
443
|
-
required: !0,
|
|
444
|
-
type: "text"
|
|
445
|
-
},
|
|
446
|
-
{
|
|
447
|
-
name: "email",
|
|
448
|
-
exceptDomains: null,
|
|
449
|
-
onlyDomains: null,
|
|
450
|
-
required: !0,
|
|
451
|
-
type: "email"
|
|
452
|
-
},
|
|
453
|
-
{
|
|
454
|
-
name: "name",
|
|
455
|
-
max: 255,
|
|
456
|
-
required: !1,
|
|
457
|
-
type: "text"
|
|
458
|
-
},
|
|
459
|
-
{
|
|
460
|
-
name: "membership_id",
|
|
461
|
-
cascadeDelete: !1,
|
|
462
|
-
collectionId: e.id,
|
|
463
|
-
maxSelect: 1,
|
|
464
|
-
minSelect: 0,
|
|
465
|
-
required: !1,
|
|
466
|
-
type: "relation"
|
|
467
|
-
},
|
|
468
|
-
{
|
|
469
|
-
name: "team",
|
|
470
|
-
cascadeDelete: !0,
|
|
471
|
-
collectionId: y.id,
|
|
472
|
-
maxSelect: 1,
|
|
473
|
-
minSelect: 0,
|
|
474
|
-
required: !0,
|
|
475
|
-
type: "relation"
|
|
476
|
-
},
|
|
477
|
-
{
|
|
478
|
-
name: "role",
|
|
479
|
-
maxSelect: 1,
|
|
480
|
-
required: !0,
|
|
481
|
-
type: "select",
|
|
482
|
-
values: ["owner", "admin", "member"]
|
|
483
|
-
}
|
|
484
|
-
],
|
|
485
|
-
viewQuery: "select users.id, users.email, users.name, team_memberships.id as membership_id, team_memberships.team, team_memberships.role from users join team_memberships on team_memberships.user = users.id;"
|
|
486
|
-
}), v(n, "team_users", t), await d.collections.create({
|
|
487
|
-
name: "team_invites",
|
|
488
|
-
type: "base",
|
|
489
|
-
fields: [
|
|
490
|
-
{
|
|
491
|
-
name: "id",
|
|
492
|
-
type: "text",
|
|
493
|
-
primaryKey: !0,
|
|
494
|
-
autogeneratePattern: "[a-z0-9]{15}",
|
|
495
|
-
max: 15,
|
|
496
|
-
min: 15,
|
|
497
|
-
pattern: "^[a-z0-9]+$",
|
|
498
|
-
required: !0
|
|
499
|
-
},
|
|
500
|
-
{
|
|
501
|
-
name: "team",
|
|
502
|
-
type: "relation",
|
|
503
|
-
cascadeDelete: !0,
|
|
504
|
-
collectionId: y.id,
|
|
505
|
-
maxSelect: 1,
|
|
506
|
-
minSelect: 0,
|
|
507
|
-
required: !0
|
|
508
|
-
},
|
|
509
|
-
{
|
|
510
|
-
name: "email",
|
|
511
|
-
type: "email",
|
|
512
|
-
required: !0
|
|
513
|
-
},
|
|
514
|
-
{
|
|
515
|
-
name: "created",
|
|
516
|
-
onCreate: !0,
|
|
517
|
-
onUpdate: !1,
|
|
518
|
-
type: "autodate"
|
|
519
|
-
},
|
|
520
|
-
{
|
|
521
|
-
name: "updated",
|
|
522
|
-
onCreate: !0,
|
|
523
|
-
onUpdate: !0,
|
|
524
|
-
type: "autodate"
|
|
525
|
-
}
|
|
526
|
-
]
|
|
527
|
-
}), v(n, "team_invites", t), await d.collections.create({
|
|
528
|
-
name: "team_invite_links",
|
|
529
|
-
type: "base",
|
|
530
|
-
fields: [
|
|
531
|
-
{
|
|
532
|
-
name: "id",
|
|
533
|
-
autogeneratePattern: "[a-z0-9]{15}",
|
|
534
|
-
max: 15,
|
|
535
|
-
min: 15,
|
|
536
|
-
pattern: "^[a-z0-9]+$",
|
|
537
|
-
primaryKey: !0,
|
|
538
|
-
required: !0,
|
|
539
|
-
type: "text"
|
|
540
|
-
},
|
|
541
|
-
{
|
|
542
|
-
name: "team",
|
|
543
|
-
cascadeDelete: !0,
|
|
544
|
-
collectionId: y.id,
|
|
545
|
-
maxSelect: 1,
|
|
546
|
-
minSelect: 0,
|
|
547
|
-
required: !0,
|
|
548
|
-
type: "relation"
|
|
549
|
-
},
|
|
550
|
-
{
|
|
551
|
-
name: "created",
|
|
552
|
-
onCreate: !0,
|
|
553
|
-
onUpdate: !1,
|
|
554
|
-
type: "autodate"
|
|
555
|
-
},
|
|
556
|
-
{
|
|
557
|
-
name: "updated",
|
|
558
|
-
onCreate: !0,
|
|
559
|
-
onUpdate: !0,
|
|
560
|
-
type: "autodate"
|
|
561
|
-
}
|
|
562
|
-
],
|
|
563
|
-
indexes: [
|
|
564
|
-
"CREATE UNIQUE INDEX `idx_9y3Oz1KVzz` ON `team_invite_links` (`team`)"
|
|
565
|
-
]
|
|
566
|
-
}), v(n, "team_invite_links", t);
|
|
567
|
-
const a = await _(
|
|
568
|
-
d,
|
|
569
|
-
j,
|
|
570
|
-
t
|
|
571
|
-
);
|
|
572
|
-
n.push(...a);
|
|
573
|
-
});
|
|
574
|
-
const o = [], r = A.join(
|
|
575
|
-
t.root,
|
|
576
|
-
"src",
|
|
577
|
-
"routes",
|
|
578
|
-
"(app)",
|
|
579
|
-
"+layout.server.ts"
|
|
580
|
-
);
|
|
581
|
-
f.existsSync(r) && (R(r), o.push({
|
|
582
|
-
path: r,
|
|
583
|
-
language: "ts",
|
|
584
|
-
content: f.readFileSync(r, "utf8")
|
|
585
|
-
}));
|
|
586
|
-
const p = A.join(
|
|
587
|
-
t.root,
|
|
588
|
-
"src",
|
|
589
|
-
"routes",
|
|
590
|
-
"(app)",
|
|
591
|
-
"+layout.svelte"
|
|
592
|
-
);
|
|
593
|
-
f.existsSync(p) && L(p) && o.push({
|
|
594
|
-
path: p,
|
|
595
|
-
language: "svelte",
|
|
596
|
-
content: f.readFileSync(p, "utf8")
|
|
597
|
-
});
|
|
598
|
-
const m = A.join(
|
|
599
|
-
t.root,
|
|
600
|
-
"src",
|
|
601
|
-
"lib",
|
|
602
|
-
"components",
|
|
603
|
-
"app-sidebar.svelte"
|
|
604
|
-
);
|
|
605
|
-
f.existsSync(m) && q(m) && o.push({
|
|
606
|
-
path: m,
|
|
607
|
-
language: "svelte",
|
|
608
|
-
content: f.readFileSync(m, "utf8")
|
|
609
|
-
});
|
|
610
|
-
const g = A.join(
|
|
611
|
-
t.root,
|
|
612
|
-
"src",
|
|
613
|
-
"lib",
|
|
614
|
-
"components",
|
|
615
|
-
"nav-user.svelte"
|
|
616
|
-
);
|
|
617
|
-
return M(g) && o.push({
|
|
618
|
-
path: g,
|
|
619
|
-
language: "svelte",
|
|
620
|
-
content: f.readFileSync(g, "utf8")
|
|
621
|
-
}), {
|
|
622
|
-
creates: n,
|
|
623
|
-
modifies: o,
|
|
624
|
-
deletes: [],
|
|
625
|
-
components: [],
|
|
626
|
-
packages: [],
|
|
627
|
-
collections: []
|
|
628
|
-
};
|
|
629
|
-
}
|
|
630
|
-
export {
|
|
631
|
-
X as generate
|
|
632
|
-
};
|
|
633
|
-
//# sourceMappingURL=generate.runtime-C4q7Pq37.js.map
|