@velastack/patterns 0.0.5 → 0.0.6

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.
@@ -1,6 +1,6 @@
1
1
  import { readFileSync as s } from "node:fs";
2
- import { l as c } from "./index-DBV0rNRK.js";
3
- import { w as l, g as u } from "./pocketbase-PTRPGp8W.js";
2
+ import { l as c } from "./index-CbDX3h_c.js";
3
+ import { w as l, g as u } from "./pocketbase-Bg-FsyGQ.js";
4
4
  function m(o) {
5
5
  var n, a, t, e;
6
6
  if (((t = (a = (n = o.response) == null ? void 0 : n.data) == null ? void 0 : a.name) == null ? void 0 : t.code) === "validation_not_unique")
@@ -35,4 +35,4 @@ async function h(o, r) {
35
35
  export {
36
36
  h as createCollections
37
37
  };
38
- //# sourceMappingURL=collections-DVLGhVXc.js.map
38
+ //# sourceMappingURL=collections-Q0--CN0k.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"collections-DVLGhVXc.js","sources":["../../src/runtime/collections.ts"],"sourcesContent":["import { readFileSync } from \"node:fs\";\nimport type { CollectionSpec, File, Options } from \"../core/types\";\nimport { languageFromPath } from \"../core/util\";\nimport { getMigrationFile, withPocketbase } from \"./pocketbase\";\n\ninterface PocketBaseCollectionCreateError {\n response?: {\n data?: {\n name?: {\n code?: string;\n };\n };\n };\n message?: string;\n}\n\nfunction isCollectionAlreadyExistsError(\n error: PocketBaseCollectionCreateError,\n): boolean {\n if (error.response?.data?.name?.code === \"validation_not_unique\") {\n return true;\n }\n\n const message = error.message?.toLowerCase() ?? \"\";\n return message.includes(\"already exists\") || message.includes(\"must be unique\");\n}\n\nexport async function createCollections(\n collections: CollectionSpec[],\n options: Options,\n): Promise<File[]> {\n if (collections.length === 0) {\n return [];\n }\n\n const migrations: File[] = [];\n\n await withPocketbase(options.root, async (pb) => {\n for (const collection of collections) {\n try {\n await pb.collections.create(collection);\n } catch (error) {\n if (\n isCollectionAlreadyExistsError(\n error as PocketBaseCollectionCreateError,\n )\n ) {\n throw new Error(\n `Collection \"${collection.name}\" already exists. Choose a different model name or remove the existing collection first.`,\n );\n }\n throw error;\n }\n\n const migrationFile = getMigrationFile(collection.name, \"created\", options);\n if (!migrationFile) {\n continue;\n }\n\n migrations.push({\n path: migrationFile,\n language: languageFromPath(migrationFile),\n content: readFileSync(migrationFile, \"utf8\"),\n });\n }\n });\n\n return migrations;\n}\n"],"names":["isCollectionAlreadyExistsError","error","_c","_b","_a","message","_d","createCollections","collections","options","migrations","withPocketbase","pb","collection","migrationFile","getMigrationFile","languageFromPath","readFileSync"],"mappings":";;;AAgBA,SAASA,EACPC,GACS;;AACT,QAAIC,KAAAC,KAAAC,IAAAH,EAAM,aAAN,gBAAAG,EAAgB,SAAhB,gBAAAD,EAAsB,SAAtB,gBAAAD,EAA4B,UAAS;AACvC,WAAO;AAGT,QAAMG,MAAUC,IAAAL,EAAM,YAAN,gBAAAK,EAAe,kBAAiB;AAChD,SAAOD,EAAQ,SAAS,gBAAgB,KAAKA,EAAQ,SAAS,gBAAgB;AAChF;AAEA,eAAsBE,EACpBC,GACAC,GACiB;AACjB,MAAID,EAAY,WAAW;AACzB,WAAO,CAAA;AAGT,QAAME,IAAqB,CAAA;AAE3B,eAAMC,EAAeF,EAAQ,MAAM,OAAOG,MAAO;AAC/C,eAAWC,KAAcL,GAAa;AACpC,UAAI;AACF,cAAMI,EAAG,YAAY,OAAOC,CAAU;AAAA,MACxC,SAASZ,GAAO;AACd,cACED;AAAA,UACEC;AAAA,QAAA,IAGI,IAAI;AAAA,UACR,eAAeY,EAAW,IAAI;AAAA,QAAA,IAG5BZ;AAAA,MACR;AAEA,YAAMa,IAAgBC,EAAiBF,EAAW,MAAM,WAAWJ,CAAO;AAC1E,MAAKK,KAILJ,EAAW,KAAK;AAAA,QACd,MAAMI;AAAA,QACN,UAAUE,EAAiBF,CAAa;AAAA,QACxC,SAASG,EAAaH,GAAe,MAAM;AAAA,MAAA,CAC5C;AAAA,IACH;AAAA,EACF,CAAC,GAEMJ;AACT;"}
1
+ {"version":3,"file":"collections-Q0--CN0k.js","sources":["../../src/runtime/collections.ts"],"sourcesContent":["import { readFileSync } from \"node:fs\";\nimport type { CollectionSpec, File, Options } from \"../core/types\";\nimport { languageFromPath } from \"../core/util\";\nimport { getMigrationFile, withPocketbase } from \"./pocketbase\";\n\ninterface PocketBaseCollectionCreateError {\n response?: {\n data?: {\n name?: {\n code?: string;\n };\n };\n };\n message?: string;\n}\n\nfunction isCollectionAlreadyExistsError(\n error: PocketBaseCollectionCreateError,\n): boolean {\n if (error.response?.data?.name?.code === \"validation_not_unique\") {\n return true;\n }\n\n const message = error.message?.toLowerCase() ?? \"\";\n return message.includes(\"already exists\") || message.includes(\"must be unique\");\n}\n\nexport async function createCollections(\n collections: CollectionSpec[],\n options: Options,\n): Promise<File[]> {\n if (collections.length === 0) {\n return [];\n }\n\n const migrations: File[] = [];\n\n await withPocketbase(options.root, async (pb) => {\n for (const collection of collections) {\n try {\n await pb.collections.create(collection);\n } catch (error) {\n if (\n isCollectionAlreadyExistsError(\n error as PocketBaseCollectionCreateError,\n )\n ) {\n throw new Error(\n `Collection \"${collection.name}\" already exists. Choose a different model name or remove the existing collection first.`,\n );\n }\n throw error;\n }\n\n const migrationFile = getMigrationFile(collection.name, \"created\", options);\n if (!migrationFile) {\n continue;\n }\n\n migrations.push({\n path: migrationFile,\n language: languageFromPath(migrationFile),\n content: readFileSync(migrationFile, \"utf8\"),\n });\n }\n });\n\n return migrations;\n}\n"],"names":["isCollectionAlreadyExistsError","error","_c","_b","_a","message","_d","createCollections","collections","options","migrations","withPocketbase","pb","collection","migrationFile","getMigrationFile","languageFromPath","readFileSync"],"mappings":";;;AAgBA,SAASA,EACPC,GACS;;AACT,QAAIC,KAAAC,KAAAC,IAAAH,EAAM,aAAN,gBAAAG,EAAgB,SAAhB,gBAAAD,EAAsB,SAAtB,gBAAAD,EAA4B,UAAS;AACvC,WAAO;AAGT,QAAMG,MAAUC,IAAAL,EAAM,YAAN,gBAAAK,EAAe,kBAAiB;AAChD,SAAOD,EAAQ,SAAS,gBAAgB,KAAKA,EAAQ,SAAS,gBAAgB;AAChF;AAEA,eAAsBE,EACpBC,GACAC,GACiB;AACjB,MAAID,EAAY,WAAW;AACzB,WAAO,CAAA;AAGT,QAAME,IAAqB,CAAA;AAE3B,eAAMC,EAAeF,EAAQ,MAAM,OAAOG,MAAO;AAC/C,eAAWC,KAAcL,GAAa;AACpC,UAAI;AACF,cAAMI,EAAG,YAAY,OAAOC,CAAU;AAAA,MACxC,SAASZ,GAAO;AACd,cACED;AAAA,UACEC;AAAA,QAAA,IAGI,IAAI;AAAA,UACR,eAAeY,EAAW,IAAI;AAAA,QAAA,IAG5BZ;AAAA,MACR;AAEA,YAAMa,IAAgBC,EAAiBF,EAAW,MAAM,WAAWJ,CAAO;AAC1E,MAAKK,KAILJ,EAAW,KAAK;AAAA,QACd,MAAMI;AAAA,QACN,UAAUE,EAAiBF,CAAa;AAAA,QACxC,SAASG,EAAaH,GAAe,MAAM;AAAA,MAAA,CAC5C;AAAA,IACH;AAAA,EACF,CAAC,GAEMJ;AACT;"}
@@ -2,7 +2,7 @@ import { getCollections as i } from "@velastack/pocketbase/internal";
2
2
  import s from "node:fs";
3
3
  import r from "node:path";
4
4
  import t from "node:process";
5
- import { D as c } from "./index-DBV0rNRK.js";
5
+ import { D as c } from "./index-CbDX3h_c.js";
6
6
  function a(o) {
7
7
  return s.existsSync(r.join(o, "package.json")) && s.existsSync(r.join(o, c));
8
8
  }
@@ -33,4 +33,4 @@ export {
33
33
  S as getCollections,
34
34
  p as resolveProjectRoot
35
35
  };
36
- //# sourceMappingURL=env.runtime-BzRhpNR3.js.map
36
+ //# sourceMappingURL=env.runtime-wPrXEoHB.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"env.runtime-BzRhpNR3.js","sources":["../../src/parse/env.runtime.ts"],"sourcesContent":["import { getCollections as getCollectionsFromPB } from \"@velastack/pocketbase/internal\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport process from \"node:process\";\nimport { DATA_DIR } from \"../core/constants\";\nimport type { Collection } from \"./types\";\n\nfunction hasProjectMarkers(dir: string): boolean {\n return (\n fs.existsSync(path.join(dir, \"package.json\")) &&\n fs.existsSync(path.join(dir, DATA_DIR))\n );\n}\n\nexport function resolveProjectRoot(startDir = process.cwd()): string {\n let current = path.resolve(startDir);\n\n while (true) {\n if (hasProjectMarkers(current)) {\n return current;\n }\n\n const parent = path.dirname(current);\n if (parent === current) {\n break;\n }\n current = parent;\n }\n\n throw new Error(\n `Could not resolve project root from \"${startDir}\". Expected package.json, and ${DATA_DIR}.`,\n );\n}\n\nexport async function getCollections(): Promise<Collection[]> {\n const root = resolveProjectRoot();\n\n return getCollectionsFromPB({\n pocketbaseUrl: \"\",\n superuserEmail: process.env.POCKETBASE_SUPERUSER_EMAIL!,\n superuserPassword: process.env.POCKETBASE_SUPERUSER_PASSWORD!,\n root,\n }) as Promise<Collection[]>;\n}\n"],"names":["hasProjectMarkers","dir","fs","path","DATA_DIR","resolveProjectRoot","startDir","process","current","parent","getCollections","root","getCollectionsFromPB"],"mappings":";;;;;AAOA,SAASA,EAAkBC,GAAsB;AAC/C,SACEC,EAAG,WAAWC,EAAK,KAAKF,GAAK,cAAc,CAAC,KAC5CC,EAAG,WAAWC,EAAK,KAAKF,GAAKG,CAAQ,CAAC;AAE1C;AAEO,SAASC,EAAmBC,IAAWC,EAAQ,OAAe;AACnE,MAAIC,IAAUL,EAAK,QAAQG,CAAQ;AAEnC,aAAa;AACX,QAAIN,EAAkBQ,CAAO;AAC3B,aAAOA;AAGT,UAAMC,IAASN,EAAK,QAAQK,CAAO;AACnC,QAAIC,MAAWD;AACb;AAEF,IAAAA,IAAUC;AAAA,EACZ;AAEA,QAAM,IAAI;AAAA,IACR,wCAAwCH,CAAQ,iCAAiCF,CAAQ;AAAA,EAAA;AAE7F;AAEA,eAAsBM,IAAwC;AAC5D,QAAMC,IAAON,EAAA;AAEb,SAAOO,EAAqB;AAAA,IAC1B,eAAe;AAAA,IACf,gBAAgBL,EAAQ,IAAI;AAAA,IAC5B,mBAAmBA,EAAQ,IAAI;AAAA,IAC/B,MAAAI;AAAA,EAAA,CACD;AACH;"}
1
+ {"version":3,"file":"env.runtime-wPrXEoHB.js","sources":["../../src/parse/env.runtime.ts"],"sourcesContent":["import { getCollections as getCollectionsFromPB } from \"@velastack/pocketbase/internal\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport process from \"node:process\";\nimport { DATA_DIR } from \"../core/constants\";\nimport type { Collection } from \"./types\";\n\nfunction hasProjectMarkers(dir: string): boolean {\n return (\n fs.existsSync(path.join(dir, \"package.json\")) &&\n fs.existsSync(path.join(dir, DATA_DIR))\n );\n}\n\nexport function resolveProjectRoot(startDir = process.cwd()): string {\n let current = path.resolve(startDir);\n\n while (true) {\n if (hasProjectMarkers(current)) {\n return current;\n }\n\n const parent = path.dirname(current);\n if (parent === current) {\n break;\n }\n current = parent;\n }\n\n throw new Error(\n `Could not resolve project root from \"${startDir}\". Expected package.json, and ${DATA_DIR}.`,\n );\n}\n\nexport async function getCollections(): Promise<Collection[]> {\n const root = resolveProjectRoot();\n\n return getCollectionsFromPB({\n pocketbaseUrl: \"\",\n superuserEmail: process.env.POCKETBASE_SUPERUSER_EMAIL!,\n superuserPassword: process.env.POCKETBASE_SUPERUSER_PASSWORD!,\n root,\n }) as Promise<Collection[]>;\n}\n"],"names":["hasProjectMarkers","dir","fs","path","DATA_DIR","resolveProjectRoot","startDir","process","current","parent","getCollections","root","getCollectionsFromPB"],"mappings":";;;;;AAOA,SAASA,EAAkBC,GAAsB;AAC/C,SACEC,EAAG,WAAWC,EAAK,KAAKF,GAAK,cAAc,CAAC,KAC5CC,EAAG,WAAWC,EAAK,KAAKF,GAAKG,CAAQ,CAAC;AAE1C;AAEO,SAASC,EAAmBC,IAAWC,EAAQ,OAAe;AACnE,MAAIC,IAAUL,EAAK,QAAQG,CAAQ;AAEnC,aAAa;AACX,QAAIN,EAAkBQ,CAAO;AAC3B,aAAOA;AAGT,UAAMC,IAASN,EAAK,QAAQK,CAAO;AACnC,QAAIC,MAAWD;AACb;AAEF,IAAAA,IAAUC;AAAA,EACZ;AAEA,QAAM,IAAI;AAAA,IACR,wCAAwCH,CAAQ,iCAAiCF,CAAQ;AAAA,EAAA;AAE7F;AAEA,eAAsBM,IAAwC;AAC5D,QAAMC,IAAON,EAAA;AAEb,SAAOO,EAAqB;AAAA,IAC1B,eAAe;AAAA,IACf,gBAAgBL,EAAQ,IAAI;AAAA,IAC5B,mBAAmBA,EAAQ,IAAI;AAAA,IAC/B,MAAAI;AAAA,EAAA,CACD;AACH;"}
@@ -1,7 +1,7 @@
1
1
  import y from "node:path";
2
2
  import m from "node:fs";
3
- import { w as v, g as S } from "./pocketbase-PTRPGp8W.js";
4
- import { d as A } from "./index-DBV0rNRK.js";
3
+ import { w as v, g as S } from "./pocketbase-Bg-FsyGQ.js";
4
+ import { d as A } from "./index-CbDX3h_c.js";
5
5
  import { Project as b, SyntaxKind as s } from "ts-morph";
6
6
  function w(u) {
7
7
  if (!m.existsSync(u)) {
@@ -350,4 +350,4 @@ async function R(u) {
350
350
  export {
351
351
  R as generate
352
352
  };
353
- //# sourceMappingURL=generate.runtime-BCboVR38.js.map
353
+ //# sourceMappingURL=generate.runtime-BT46R-FS.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"generate.runtime-BCboVR38.js","sources":["../../src/patterns/enable/auth/modifies/+layout.server.ts","../../src/patterns/enable/auth/modifies/+layout.svelte.ts","../../src/patterns/enable/auth/modifies/hooks.server.ts","../../src/patterns/enable/auth/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { Project, SyntaxKind } from \"ts-morph\";\n\nexport function modifyLayoutServer(layoutPath: string) {\n if (!fs.existsSync(layoutPath)) {\n // write file directly\n\n const snippet = dedent`\n\t\t\texport const load = async ({ locals }) => {\n\t\t\t\treturn { user: locals.pb.authStore.record };\n\t\t\t};\n\t\t`;\n\n fs.writeFileSync(layoutPath, snippet);\n return;\n }\n\n const project = new Project();\n const sourceFile = project.addSourceFileAtPath(layoutPath);\n\n // helper to add user property to an object literal if missing\n const addUserProp = (obj: import(\"ts-morph\").ObjectLiteralExpression) => {\n const hasUser = !!obj.getProperty(\"user\");\n if (!hasUser) {\n obj.addPropertyAssignment({\n name: \"user\",\n initializer: \"locals.pb.authStore.record\",\n });\n }\n };\n\n // find existing exported load (function or const with arrow)\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 const isExported = !!vs?.hasExportKeyword();\n if (isExported) {\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) {\n loadFn = innerFnExpr;\n }\n }\n }\n }\n }\n }\n\n if (!loadArrow) {\n const maybeFn = sourceFile.getFunction(\"load\");\n if (maybeFn && maybeFn.isExported()) {\n loadFn = maybeFn;\n }\n }\n\n // if no load found, create one\n if (!loadArrow && !loadFn) {\n sourceFile.addFunction({\n isExported: true,\n isAsync: true,\n name: \"load\",\n parameters: [{ name: \"{ locals }\" }],\n statements: `return { user: locals.pb.authStore.record };`,\n });\n sourceFile.formatText();\n sourceFile.saveSync();\n return;\n }\n\n // normalize function-like to a single handle\n const fnLike:\n | import(\"ts-morph\").ArrowFunction\n | import(\"ts-morph\").FunctionDeclaration\n | import(\"ts-morph\").FunctionExpression = (loadArrow ?? loadFn!) as any;\n\n // ensure first parameter destructures locals, preserving existing information\n const params = fnLike.getParameters();\n if (params.length === 0) {\n fnLike.insertParameter(0, { name: \"{ locals }\" });\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 hasLocals = obp\n .getElements()\n .some((el) => el.getName() === \"locals\");\n if (!hasLocals) {\n const parts = obp\n .getElements()\n .map((el) => el.getText())\n .filter(Boolean);\n const tail = parts.length > 0 ? \", \" + parts.join(\", \") : \"\";\n first.set({\n name: `{ locals${tail} }`,\n type: original.type,\n initializer: (original as any).initializer,\n });\n }\n } else {\n const currentName = first.getName();\n if (currentName !== \"locals\") {\n first.set({\n name: `{ locals, ...${currentName} }`,\n type: original.type,\n initializer: (original as any).initializer,\n });\n }\n }\n }\n\n // add user to returned object literals without altering other properties\n if (loadArrow) {\n const body = loadArrow.getBody();\n if (body.getKind() === SyntaxKind.Block) {\n const returns = body.getDescendantsOfKind(SyntaxKind.ReturnStatement);\n returns.forEach((ret) => {\n const expr = ret.getExpression();\n if (!expr) return;\n if (expr.getKind() === SyntaxKind.ObjectLiteralExpression) {\n addUserProp(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 addUserProp(inner as import(\"ts-morph\").ObjectLiteralExpression);\n }\n }\n });\n } else {\n // concise body\n const bodyExpr = body 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 addUserProp(inner as import(\"ts-morph\").ObjectLiteralExpression);\n }\n } else if (bodyExpr.getKind() === SyntaxKind.ObjectLiteralExpression) {\n addUserProp(bodyExpr as import(\"ts-morph\").ObjectLiteralExpression);\n }\n }\n } else if (loadFn) {\n const body = loadFn.getBody();\n if (body) {\n const returns = body.getDescendantsOfKind(SyntaxKind.ReturnStatement);\n returns.forEach((ret) => {\n const expr = ret.getExpression();\n if (!expr) return;\n if (expr.getKind() === SyntaxKind.ObjectLiteralExpression) {\n addUserProp(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 addUserProp(inner as import(\"ts-morph\").ObjectLiteralExpression);\n }\n }\n });\n }\n }\n\n sourceFile.formatText();\n sourceFile.saveSync();\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\n\nexport function modifyLayoutSvelte(layoutPath: string) {\n let layout = fs.readFileSync(layoutPath, \"utf8\");\n // TODO: use magic-string to modify the layout\n\n // find the navbar.root > navbar.list\n const navbarRoot = layout.match(/<Navbar\\.Root>([\\s\\S]*?)<\\/Navbar\\.Root>/);\n if (!navbarRoot) {\n return;\n }\n\n const navbarList = navbarRoot[1].match(\n /<Navbar\\.List>([\\s\\S]*?)<\\/Navbar\\.List>/,\n );\n if (!navbarList) {\n return;\n }\n\n // add imports\n const imports = dedent`\n\t\timport * as AuthMenu from '$lib/components/ui/auth-menu';\n\t\timport * as Avatar from '$lib/components/ui/avatar';\n\t`;\n\n // Insert imports after the last existing import inside the first <script> block (if any)\n const scriptOpenIdx = layout.indexOf(\"<script\");\n if (scriptOpenIdx !== -1) {\n const scriptOpenEnd = layout.indexOf(\">\", scriptOpenIdx);\n const scriptCloseIdx =\n scriptOpenEnd !== -1\n ? layout.indexOf(\"</script>\", scriptOpenEnd + 1)\n : -1;\n if (scriptOpenEnd !== -1 && scriptCloseIdx !== -1) {\n const scriptContent = layout.slice(scriptOpenEnd + 1, scriptCloseIdx);\n let lastImportEnd = -1;\n const importRegex = /^\\s*import[\\s\\S]*?;[ \\t]*$/gm;\n let match: RegExpExecArray | null;\n while ((match = importRegex.exec(scriptContent)) !== null) {\n lastImportEnd = match.index + match[0].length;\n }\n\n if (lastImportEnd !== -1) {\n const before = scriptContent.slice(0, lastImportEnd);\n const after = scriptContent.slice(lastImportEnd);\n const newScriptContent = `${before}\\n${imports}\\n${after}`;\n layout =\n layout.slice(0, scriptOpenEnd + 1) +\n newScriptContent +\n layout.slice(scriptCloseIdx);\n } else {\n layout = layout.replace(\"</script>\", `${imports}\\n</script>`);\n }\n } else {\n layout = layout.replace(\"</script>\", `${imports}\\n</script>`);\n }\n } else {\n layout = layout.replace(\"</script>\", `${imports}\\n</script>`);\n }\n\n // add the auth menu to the navbar.list\n const newNavbarList =\n navbarList[1] +\n `\n\t\t\t<Navbar.Item\n\t\t\t\t\tclass=\"flex flex-col md:flex-row items-center space-y-2 md:space-y-0 md:space-x-4\"\n\t\t\t>\n\t\t\t\t\t<AuthMenu.Root>\n\t\t\t\t\t\t\t{#snippet user()}\n\t\t\t\t\t\t\t\t\t<AuthMenu.Trigger>\n\t\t\t\t\t\t\t\t\t\t\t<Avatar.Root>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{#if data.user?.avatar}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<Avatar.Image\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tsrc=\"/api/files/users/{data.user?.id}/{data.user?.avatar}\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\talt={data.user?.email}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t\t\t\t\t\t\t\t<Avatar.Fallback>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t{data.user?.email?.charAt(0).toUpperCase()}\n\t\t\t\t\t\t\t\t\t\t\t\t\t</Avatar.Fallback>\n\t\t\t\t\t\t\t\t\t\t\t</Avatar.Root>\n\t\t\t\t\t\t\t\t\t</AuthMenu.Trigger>\n\n\t\t\t\t\t\t\t\t\t<AuthMenu.Content align=\"end\">\n\t\t\t\t\t\t\t\t\t\t\t<AuthMenu.Item href=\"/dashboard\">Dashboard</AuthMenu.Item>\n\t\t\t\t\t\t\t\t\t\t\t<AuthMenu.Group>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<AuthMenu.Item href=\"/settings\">Settings</AuthMenu.Item>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<AuthMenu.Item>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<form action=\"/logout\" method=\"post\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<button type=\"submit\" class=\"contents\">Logout</button>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</form>\n\t\t\t\t\t\t\t\t\t\t\t\t\t</AuthMenu.Item>\n\t\t\t\t\t\t\t\t\t\t\t</AuthMenu.Group>\n\t\t\t\t\t\t\t\t\t</AuthMenu.Content>\n\t\t\t\t\t\t\t{/snippet}\n\n\t\t\t\t\t\t\t{#snippet guest()}\n\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t\tclass=\"w-full justify-start md:justify-center md:w-auto\"\n\t\t\t\t\t\t\t\t\t\t\tvariant=\"ghost\"\n\t\t\t\t\t\t\t\t\t\t\thref=\"/login\">Login</Button\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t\tclass=\"w-full justify-start md:justify-center md:w-auto\"\n\t\t\t\t\t\t\t\t\t\t\tvariant=\"outline\"\n\t\t\t\t\t\t\t\t\t\t\thref=\"/signup\">Sign up</Button\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{/snippet}\n\t\t\t\t\t</AuthMenu.Root>\n\t\t\t</Navbar.Item>\n\t\t`;\n\n // replace the navbar.list with the new one\n layout = layout.replace(navbarList[1], newNavbarList);\n\n fs.writeFileSync(layoutPath, layout);\n}\n","import { Project, SyntaxKind } from \"ts-morph\";\n\nexport function modifyHooksServer(hooksServerPath: string) {\n const project = new Project();\n const sourceFile = project.addSourceFileAtPath(hooksServerPath);\n\n // Find the handlePocketbase(...) call\n const callExpr = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .find((ce) => ce.getExpression().getText() === \"handlePocketbase\");\n\n if (!callExpr) {\n sourceFile.saveSync();\n return;\n }\n\n const args = callExpr.getArguments();\n if (args.length === 0) {\n // Create an options object if missing\n callExpr.addArgument(`{ auth: { protectedRoutes: ['/(app)'] } }`);\n sourceFile.formatText();\n sourceFile.saveSync();\n return;\n }\n\n const firstArg = args[0];\n if (firstArg.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n // Replace non-object first arg with an object including auth\n callExpr.insertArgument(0, `{ auth: { protectedRoutes: ['/(app)'] } }`);\n sourceFile.formatText();\n sourceFile.saveSync();\n return;\n }\n\n const optionsObj = firstArg.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);\n\n // Ensure auth property exists\n const authProp = optionsObj.getProperty(\"auth\");\n if (!authProp) {\n optionsObj.addPropertyAssignment({\n name: \"auth\",\n initializer: `{ protectedRoutes: ['/(app)'] }`,\n });\n sourceFile.formatText();\n sourceFile.saveSync();\n return;\n }\n\n // If auth exists, ensure protectedRoutes includes '/(app)'\n if (authProp.getKind() === SyntaxKind.PropertyAssignment) {\n const authInit = (\n authProp as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n if (authInit && authInit.getKind() === SyntaxKind.ObjectLiteralExpression) {\n const authObj = authInit as import(\"ts-morph\").ObjectLiteralExpression;\n const prProp = authObj.getProperty(\"protectedRoutes\");\n if (!prProp) {\n authObj.addPropertyAssignment({\n name: \"protectedRoutes\",\n initializer: `['/(app)']`,\n });\n } else if (prProp.getKind() === SyntaxKind.PropertyAssignment) {\n const prInit = (\n prProp as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n if (prInit && prInit.getKind() === SyntaxKind.ArrayLiteralExpression) {\n const arr = prInit as import(\"ts-morph\").ArrayLiteralExpression;\n const hasApp = arr\n .getElements()\n .some((el) => el.getText().replace(/['\"`]/g, \"\") === \"/(app)\");\n if (!hasApp) {\n arr.addElement(`'/(app)'`);\n }\n } else {\n // Replace non-array with desired value\n (prProp as import(\"ts-morph\").PropertyAssignment).setInitializer(\n `['/(app)']`,\n );\n }\n }\n }\n }\n\n sourceFile.formatText();\n sourceFile.saveSync();\n}\n","import path from \"node:path\";\nimport fs from \"node:fs\";\nimport { Options, Result, File } from \"../../../core/types\";\nimport { getMigrationFile, withPocketbase } from \"../../../runtime/pocketbase\";\n\nimport { modifyLayoutServer } from \"./modifies/+layout.server\";\nimport { modifyLayoutSvelte } from \"./modifies/+layout.svelte\";\nimport { modifyHooksServer } from \"./modifies/hooks.server\";\n\nexport async function generate(options: Options) {\n const { input } = options;\n\n let creates: File[] = [];\n\n // Update PocketBase\n await withPocketbase(options.root, async (pb) => {\n await pb.settings.update({\n meta: {\n senderName: input.senderName,\n senderAddress: input.senderAddress,\n },\n });\n\n const userCollection = await pb.collections.getOne(\"users\");\n\n if (!userCollection) {\n throw new Error(\"Users collection not found\");\n }\n\n const verificationTemplate =\n userCollection.verificationTemplate.body.replace(\n \"{APP_URL}/_/#/auth/confirm-verification/{TOKEN}\",\n \"{APP_URL}/confirm-verification/{TOKEN}\",\n );\n const resetPasswordTemplate =\n userCollection.resetPasswordTemplate.body.replace(\n \"{APP_URL}/_/#/auth/confirm-password-reset/{TOKEN}\",\n \"{APP_URL}/confirm-password-reset/{TOKEN}\",\n );\n const confirmEmailChangeTemplate =\n userCollection.confirmEmailChangeTemplate.body.replace(\n \"{APP_URL}/_/#/auth/confirm-email-change/{TOKEN}\",\n \"{APP_URL}/confirm-email-change/{TOKEN}\",\n );\n\n // Update user auth rules to lock down access to the user's own account\n await pb.collections.update(\"users\", {\n listRule: \"@request.auth.id = id\",\n viewRule: \"@request.auth.id = id\",\n createRule: \"@request.auth.id = id\",\n updateRule: \"@request.auth.id = id\",\n deleteRule: \"@request.auth.id = id\",\n\n // Update email templates to VelaStack auth urls\n verificationTemplate: {\n body: verificationTemplate,\n },\n resetPasswordTemplate: {\n body: resetPasswordTemplate,\n },\n confirmEmailChangeTemplate: {\n body: confirmEmailChangeTemplate,\n },\n });\n\n const migrationFile = getMigrationFile(\"users\", \"updated\", options);\n if (migrationFile) {\n creates.push({\n path: migrationFile,\n language: \"ts\",\n content: fs.readFileSync(migrationFile, \"utf8\"),\n });\n }\n\n });\n\n // Modify files\n let modifies: File[] = [];\n\n const layoutServerFile = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.server.ts\",\n );\n\n await modifyLayoutServer(layoutServerFile);\n modifies.push({\n path: layoutServerFile,\n language: \"ts\",\n content: fs.readFileSync(layoutServerFile, \"utf8\"),\n });\n\n // TODO: make this more robust by searching for Navbar.Root > Navbar.List\n // src/routes/(public)/root-layout.svelte is what vela creates by default\n let layoutFile = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(public)\",\n \"root-layout.svelte\",\n );\n\n if (!fs.existsSync(layoutFile)) {\n layoutFile = path.join(options.root, \"src\", \"routes\", \"root-layout.svelte\");\n }\n\n if (!fs.existsSync(layoutFile)) {\n layoutFile = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(public)\",\n \"+layout.svelte\",\n );\n }\n\n if (!fs.existsSync(layoutFile)) {\n layoutFile = path.join(options.root, \"src\", \"routes\", \"+layout.svelte\");\n }\n\n if (fs.existsSync(layoutFile)) {\n modifyLayoutSvelte(layoutFile);\n modifies.push({\n path: layoutFile,\n language: \"svelte\",\n content: fs.readFileSync(layoutFile, \"utf8\"),\n });\n }\n\n const hooksServerFile = path.join(options.root, \"src\", \"hooks.server.ts\");\n\n if (fs.existsSync(hooksServerFile)) {\n modifyHooksServer(hooksServerFile);\n modifies.push({\n path: hooksServerFile,\n language: \"ts\",\n content: fs.readFileSync(hooksServerFile, \"utf8\"),\n });\n }\n\n return {\n creates: [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n } satisfies Result;\n}\n"],"names":["modifyLayoutServer","layoutPath","fs","snippet","dedent","sourceFile","Project","addUserProp","obj","loadArrow","loadFn","varDecl","vs","SyntaxKind","directArrow","init","innerArrow","innerFnExpr","maybeFn","fnLike","params","first","original","nameNode","obp","el","parts","tail","currentName","body","ret","expr","inner","bodyExpr","modifyLayoutSvelte","layout","navbarRoot","navbarList","imports","scriptOpenIdx","scriptOpenEnd","scriptCloseIdx","scriptContent","lastImportEnd","importRegex","match","before","after","newScriptContent","newNavbarList","modifyHooksServer","hooksServerPath","callExpr","ce","args","firstArg","optionsObj","authProp","authInit","authObj","prProp","prInit","arr","generate","options","input","creates","withPocketbase","pb","userCollection","verificationTemplate","resetPasswordTemplate","confirmEmailChangeTemplate","migrationFile","getMigrationFile","modifies","layoutServerFile","path","layoutFile","hooksServerFile"],"mappings":";;;;;AAIO,SAASA,EAAmBC,GAAoB;AACrD,MAAI,CAACC,EAAG,WAAWD,CAAU,GAAG;AAG9B,UAAME,IAAUC;AAAA;AAAA;AAAA;AAAA;AAMhB,IAAAF,EAAG,cAAcD,GAAYE,CAAO;AACpC;AAAA,EACF;AAGA,QAAME,IADU,IAAIC,EAAA,EACO,oBAAoBL,CAAU,GAGnDM,IAAc,CAACC,MAAoD;AAEvE,IADgB,CAAC,CAACA,EAAI,YAAY,MAAM,KAEtCA,EAAI,sBAAsB;AAAA,MACxB,MAAM;AAAA,MACN,aAAa;AAAA,IAAA,CACd;AAAA,EAEL;AAGA,MAAIC,GACAC;AAKJ,QAAMC,IAAUN,EAAW,uBAAuB,MAAM;AACxD,MAAIM,GAAS;AACX,UAAMC,IAAKD,EAAQ,uBAAuBE,EAAW,iBAAiB;AAEtE,QADmB,CAAC,EAACD,KAAA,QAAAA,EAAI,qBACT;AACd,YAAME,IAAcH,EAAQ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,EAAG,WAAW4E,CAAU,MAC3BA,IAAaD,EAAK,KAAKb,EAAQ,MAAM,OAAO,UAAU,oBAAoB,IAGvE9D,EAAG,WAAW4E,CAAU,MAC3BA,IAAaD,EAAK;AAAA,IAChBb,EAAQ;AAAA,IACR;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,IAIC9D,EAAG,WAAW4E,CAAU,MAC3BA,IAAaD,EAAK,KAAKb,EAAQ,MAAM,OAAO,UAAU,gBAAgB,IAGpE9D,EAAG,WAAW4E,CAAU,MAC1B5C,EAAmB4C,CAAU,GAC7BH,EAAS,KAAK;AAAA,IACZ,MAAMG;AAAA,IACN,UAAU;AAAA,IACV,SAAS5E,EAAG,aAAa4E,GAAY,MAAM;AAAA,EAAA,CAC5C;AAGH,QAAMC,IAAkBF,EAAK,KAAKb,EAAQ,MAAM,OAAO,iBAAiB;AAExE,SAAI9D,EAAG,WAAW6E,CAAe,MAC/B7B,EAAkB6B,CAAe,GACjCJ,EAAS,KAAK;AAAA,IACZ,MAAMI;AAAA,IACN,UAAU;AAAA,IACV,SAAS7E,EAAG,aAAa6E,GAAiB,MAAM;AAAA,EAAA,CACjD,IAGI;AAAA,IACL,SAAS,CAAA;AAAA,IACT,UAAAJ;AAAA,IACA,SAAS,CAAA;AAAA,IACT,YAAY,CAAA;AAAA,IACZ,UAAU,CAAA;AAAA,IACV,aAAa,CAAA;AAAA,EAAC;AAElB;"}
1
+ {"version":3,"file":"generate.runtime-BT46R-FS.js","sources":["../../src/patterns/enable/auth/modifies/+layout.server.ts","../../src/patterns/enable/auth/modifies/+layout.svelte.ts","../../src/patterns/enable/auth/modifies/hooks.server.ts","../../src/patterns/enable/auth/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { Project, SyntaxKind } from \"ts-morph\";\n\nexport function modifyLayoutServer(layoutPath: string) {\n if (!fs.existsSync(layoutPath)) {\n // write file directly\n\n const snippet = dedent`\n\t\t\texport const load = async ({ locals }) => {\n\t\t\t\treturn { user: locals.pb.authStore.record };\n\t\t\t};\n\t\t`;\n\n fs.writeFileSync(layoutPath, snippet);\n return;\n }\n\n const project = new Project();\n const sourceFile = project.addSourceFileAtPath(layoutPath);\n\n // helper to add user property to an object literal if missing\n const addUserProp = (obj: import(\"ts-morph\").ObjectLiteralExpression) => {\n const hasUser = !!obj.getProperty(\"user\");\n if (!hasUser) {\n obj.addPropertyAssignment({\n name: \"user\",\n initializer: \"locals.pb.authStore.record\",\n });\n }\n };\n\n // find existing exported load (function or const with arrow)\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 const isExported = !!vs?.hasExportKeyword();\n if (isExported) {\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) {\n loadFn = innerFnExpr;\n }\n }\n }\n }\n }\n }\n\n if (!loadArrow) {\n const maybeFn = sourceFile.getFunction(\"load\");\n if (maybeFn && maybeFn.isExported()) {\n loadFn = maybeFn;\n }\n }\n\n // if no load found, create one\n if (!loadArrow && !loadFn) {\n sourceFile.addFunction({\n isExported: true,\n isAsync: true,\n name: \"load\",\n parameters: [{ name: \"{ locals }\" }],\n statements: `return { user: locals.pb.authStore.record };`,\n });\n sourceFile.formatText();\n sourceFile.saveSync();\n return;\n }\n\n // normalize function-like to a single handle\n const fnLike:\n | import(\"ts-morph\").ArrowFunction\n | import(\"ts-morph\").FunctionDeclaration\n | import(\"ts-morph\").FunctionExpression = (loadArrow ?? loadFn!) as any;\n\n // ensure first parameter destructures locals, preserving existing information\n const params = fnLike.getParameters();\n if (params.length === 0) {\n fnLike.insertParameter(0, { name: \"{ locals }\" });\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 hasLocals = obp\n .getElements()\n .some((el) => el.getName() === \"locals\");\n if (!hasLocals) {\n const parts = obp\n .getElements()\n .map((el) => el.getText())\n .filter(Boolean);\n const tail = parts.length > 0 ? \", \" + parts.join(\", \") : \"\";\n first.set({\n name: `{ locals${tail} }`,\n type: original.type,\n initializer: (original as any).initializer,\n });\n }\n } else {\n const currentName = first.getName();\n if (currentName !== \"locals\") {\n first.set({\n name: `{ locals, ...${currentName} }`,\n type: original.type,\n initializer: (original as any).initializer,\n });\n }\n }\n }\n\n // add user to returned object literals without altering other properties\n if (loadArrow) {\n const body = loadArrow.getBody();\n if (body.getKind() === SyntaxKind.Block) {\n const returns = body.getDescendantsOfKind(SyntaxKind.ReturnStatement);\n returns.forEach((ret) => {\n const expr = ret.getExpression();\n if (!expr) return;\n if (expr.getKind() === SyntaxKind.ObjectLiteralExpression) {\n addUserProp(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 addUserProp(inner as import(\"ts-morph\").ObjectLiteralExpression);\n }\n }\n });\n } else {\n // concise body\n const bodyExpr = body 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 addUserProp(inner as import(\"ts-morph\").ObjectLiteralExpression);\n }\n } else if (bodyExpr.getKind() === SyntaxKind.ObjectLiteralExpression) {\n addUserProp(bodyExpr as import(\"ts-morph\").ObjectLiteralExpression);\n }\n }\n } else if (loadFn) {\n const body = loadFn.getBody();\n if (body) {\n const returns = body.getDescendantsOfKind(SyntaxKind.ReturnStatement);\n returns.forEach((ret) => {\n const expr = ret.getExpression();\n if (!expr) return;\n if (expr.getKind() === SyntaxKind.ObjectLiteralExpression) {\n addUserProp(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 addUserProp(inner as import(\"ts-morph\").ObjectLiteralExpression);\n }\n }\n });\n }\n }\n\n sourceFile.formatText();\n sourceFile.saveSync();\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\n\nexport function modifyLayoutSvelte(layoutPath: string) {\n let layout = fs.readFileSync(layoutPath, \"utf8\");\n // TODO: use magic-string to modify the layout\n\n // find the navbar.root > navbar.list\n const navbarRoot = layout.match(/<Navbar\\.Root>([\\s\\S]*?)<\\/Navbar\\.Root>/);\n if (!navbarRoot) {\n return;\n }\n\n const navbarList = navbarRoot[1].match(\n /<Navbar\\.List>([\\s\\S]*?)<\\/Navbar\\.List>/,\n );\n if (!navbarList) {\n return;\n }\n\n // add imports\n const imports = dedent`\n\t\timport * as AuthMenu from '$lib/components/ui/auth-menu';\n\t\timport * as Avatar from '$lib/components/ui/avatar';\n\t`;\n\n // Insert imports after the last existing import inside the first <script> block (if any)\n const scriptOpenIdx = layout.indexOf(\"<script\");\n if (scriptOpenIdx !== -1) {\n const scriptOpenEnd = layout.indexOf(\">\", scriptOpenIdx);\n const scriptCloseIdx =\n scriptOpenEnd !== -1\n ? layout.indexOf(\"</script>\", scriptOpenEnd + 1)\n : -1;\n if (scriptOpenEnd !== -1 && scriptCloseIdx !== -1) {\n const scriptContent = layout.slice(scriptOpenEnd + 1, scriptCloseIdx);\n let lastImportEnd = -1;\n const importRegex = /^\\s*import[\\s\\S]*?;[ \\t]*$/gm;\n let match: RegExpExecArray | null;\n while ((match = importRegex.exec(scriptContent)) !== null) {\n lastImportEnd = match.index + match[0].length;\n }\n\n if (lastImportEnd !== -1) {\n const before = scriptContent.slice(0, lastImportEnd);\n const after = scriptContent.slice(lastImportEnd);\n const newScriptContent = `${before}\\n${imports}\\n${after}`;\n layout =\n layout.slice(0, scriptOpenEnd + 1) +\n newScriptContent +\n layout.slice(scriptCloseIdx);\n } else {\n layout = layout.replace(\"</script>\", `${imports}\\n</script>`);\n }\n } else {\n layout = layout.replace(\"</script>\", `${imports}\\n</script>`);\n }\n } else {\n layout = layout.replace(\"</script>\", `${imports}\\n</script>`);\n }\n\n // add the auth menu to the navbar.list\n const newNavbarList =\n navbarList[1] +\n `\n\t\t\t<Navbar.Item\n\t\t\t\t\tclass=\"flex flex-col md:flex-row items-center space-y-2 md:space-y-0 md:space-x-4\"\n\t\t\t>\n\t\t\t\t\t<AuthMenu.Root>\n\t\t\t\t\t\t\t{#snippet user()}\n\t\t\t\t\t\t\t\t\t<AuthMenu.Trigger>\n\t\t\t\t\t\t\t\t\t\t\t<Avatar.Root>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{#if data.user?.avatar}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<Avatar.Image\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tsrc=\"/api/files/users/{data.user?.id}/{data.user?.avatar}\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\talt={data.user?.email}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t\t\t\t\t\t\t\t<Avatar.Fallback>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t{data.user?.email?.charAt(0).toUpperCase()}\n\t\t\t\t\t\t\t\t\t\t\t\t\t</Avatar.Fallback>\n\t\t\t\t\t\t\t\t\t\t\t</Avatar.Root>\n\t\t\t\t\t\t\t\t\t</AuthMenu.Trigger>\n\n\t\t\t\t\t\t\t\t\t<AuthMenu.Content align=\"end\">\n\t\t\t\t\t\t\t\t\t\t\t<AuthMenu.Item href=\"/dashboard\">Dashboard</AuthMenu.Item>\n\t\t\t\t\t\t\t\t\t\t\t<AuthMenu.Group>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<AuthMenu.Item href=\"/settings\">Settings</AuthMenu.Item>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<AuthMenu.Item>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<form action=\"/logout\" method=\"post\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<button type=\"submit\" class=\"contents\">Logout</button>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</form>\n\t\t\t\t\t\t\t\t\t\t\t\t\t</AuthMenu.Item>\n\t\t\t\t\t\t\t\t\t\t\t</AuthMenu.Group>\n\t\t\t\t\t\t\t\t\t</AuthMenu.Content>\n\t\t\t\t\t\t\t{/snippet}\n\n\t\t\t\t\t\t\t{#snippet guest()}\n\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t\tclass=\"w-full justify-start md:justify-center md:w-auto\"\n\t\t\t\t\t\t\t\t\t\t\tvariant=\"ghost\"\n\t\t\t\t\t\t\t\t\t\t\thref=\"/login\">Login</Button\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t\tclass=\"w-full justify-start md:justify-center md:w-auto\"\n\t\t\t\t\t\t\t\t\t\t\tvariant=\"outline\"\n\t\t\t\t\t\t\t\t\t\t\thref=\"/signup\">Sign up</Button\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{/snippet}\n\t\t\t\t\t</AuthMenu.Root>\n\t\t\t</Navbar.Item>\n\t\t`;\n\n // replace the navbar.list with the new one\n layout = layout.replace(navbarList[1], newNavbarList);\n\n fs.writeFileSync(layoutPath, layout);\n}\n","import { Project, SyntaxKind } from \"ts-morph\";\n\nexport function modifyHooksServer(hooksServerPath: string) {\n const project = new Project();\n const sourceFile = project.addSourceFileAtPath(hooksServerPath);\n\n // Find the handlePocketbase(...) call\n const callExpr = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .find((ce) => ce.getExpression().getText() === \"handlePocketbase\");\n\n if (!callExpr) {\n sourceFile.saveSync();\n return;\n }\n\n const args = callExpr.getArguments();\n if (args.length === 0) {\n // Create an options object if missing\n callExpr.addArgument(`{ auth: { protectedRoutes: ['/(app)'] } }`);\n sourceFile.formatText();\n sourceFile.saveSync();\n return;\n }\n\n const firstArg = args[0];\n if (firstArg.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n // Replace non-object first arg with an object including auth\n callExpr.insertArgument(0, `{ auth: { protectedRoutes: ['/(app)'] } }`);\n sourceFile.formatText();\n sourceFile.saveSync();\n return;\n }\n\n const optionsObj = firstArg.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);\n\n // Ensure auth property exists\n const authProp = optionsObj.getProperty(\"auth\");\n if (!authProp) {\n optionsObj.addPropertyAssignment({\n name: \"auth\",\n initializer: `{ protectedRoutes: ['/(app)'] }`,\n });\n sourceFile.formatText();\n sourceFile.saveSync();\n return;\n }\n\n // If auth exists, ensure protectedRoutes includes '/(app)'\n if (authProp.getKind() === SyntaxKind.PropertyAssignment) {\n const authInit = (\n authProp as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n if (authInit && authInit.getKind() === SyntaxKind.ObjectLiteralExpression) {\n const authObj = authInit as import(\"ts-morph\").ObjectLiteralExpression;\n const prProp = authObj.getProperty(\"protectedRoutes\");\n if (!prProp) {\n authObj.addPropertyAssignment({\n name: \"protectedRoutes\",\n initializer: `['/(app)']`,\n });\n } else if (prProp.getKind() === SyntaxKind.PropertyAssignment) {\n const prInit = (\n prProp as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n if (prInit && prInit.getKind() === SyntaxKind.ArrayLiteralExpression) {\n const arr = prInit as import(\"ts-morph\").ArrayLiteralExpression;\n const hasApp = arr\n .getElements()\n .some((el) => el.getText().replace(/['\"`]/g, \"\") === \"/(app)\");\n if (!hasApp) {\n arr.addElement(`'/(app)'`);\n }\n } else {\n // Replace non-array with desired value\n (prProp as import(\"ts-morph\").PropertyAssignment).setInitializer(\n `['/(app)']`,\n );\n }\n }\n }\n }\n\n sourceFile.formatText();\n sourceFile.saveSync();\n}\n","import path from \"node:path\";\nimport fs from \"node:fs\";\nimport { Options, Result, File } from \"../../../core/types\";\nimport { getMigrationFile, withPocketbase } from \"../../../runtime/pocketbase\";\n\nimport { modifyLayoutServer } from \"./modifies/+layout.server\";\nimport { modifyLayoutSvelte } from \"./modifies/+layout.svelte\";\nimport { modifyHooksServer } from \"./modifies/hooks.server\";\n\nexport async function generate(options: Options) {\n const { input } = options;\n\n let creates: File[] = [];\n\n // Update PocketBase\n await withPocketbase(options.root, async (pb) => {\n await pb.settings.update({\n meta: {\n senderName: input.senderName,\n senderAddress: input.senderAddress,\n },\n });\n\n const userCollection = await pb.collections.getOne(\"users\");\n\n if (!userCollection) {\n throw new Error(\"Users collection not found\");\n }\n\n const verificationTemplate =\n userCollection.verificationTemplate.body.replace(\n \"{APP_URL}/_/#/auth/confirm-verification/{TOKEN}\",\n \"{APP_URL}/confirm-verification/{TOKEN}\",\n );\n const resetPasswordTemplate =\n userCollection.resetPasswordTemplate.body.replace(\n \"{APP_URL}/_/#/auth/confirm-password-reset/{TOKEN}\",\n \"{APP_URL}/confirm-password-reset/{TOKEN}\",\n );\n const confirmEmailChangeTemplate =\n userCollection.confirmEmailChangeTemplate.body.replace(\n \"{APP_URL}/_/#/auth/confirm-email-change/{TOKEN}\",\n \"{APP_URL}/confirm-email-change/{TOKEN}\",\n );\n\n // Update user auth rules to lock down access to the user's own account\n await pb.collections.update(\"users\", {\n listRule: \"@request.auth.id = id\",\n viewRule: \"@request.auth.id = id\",\n createRule: \"@request.auth.id = id\",\n updateRule: \"@request.auth.id = id\",\n deleteRule: \"@request.auth.id = id\",\n\n // Update email templates to VelaStack auth urls\n verificationTemplate: {\n body: verificationTemplate,\n },\n resetPasswordTemplate: {\n body: resetPasswordTemplate,\n },\n confirmEmailChangeTemplate: {\n body: confirmEmailChangeTemplate,\n },\n });\n\n const migrationFile = getMigrationFile(\"users\", \"updated\", options);\n if (migrationFile) {\n creates.push({\n path: migrationFile,\n language: \"ts\",\n content: fs.readFileSync(migrationFile, \"utf8\"),\n });\n }\n\n });\n\n // Modify files\n let modifies: File[] = [];\n\n const layoutServerFile = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.server.ts\",\n );\n\n await modifyLayoutServer(layoutServerFile);\n modifies.push({\n path: layoutServerFile,\n language: \"ts\",\n content: fs.readFileSync(layoutServerFile, \"utf8\"),\n });\n\n // TODO: make this more robust by searching for Navbar.Root > Navbar.List\n // src/routes/(public)/root-layout.svelte is what vela creates by default\n let layoutFile = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(public)\",\n \"root-layout.svelte\",\n );\n\n if (!fs.existsSync(layoutFile)) {\n layoutFile = path.join(options.root, \"src\", \"routes\", \"root-layout.svelte\");\n }\n\n if (!fs.existsSync(layoutFile)) {\n layoutFile = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(public)\",\n \"+layout.svelte\",\n );\n }\n\n if (!fs.existsSync(layoutFile)) {\n layoutFile = path.join(options.root, \"src\", \"routes\", \"+layout.svelte\");\n }\n\n if (fs.existsSync(layoutFile)) {\n modifyLayoutSvelte(layoutFile);\n modifies.push({\n path: layoutFile,\n language: \"svelte\",\n content: fs.readFileSync(layoutFile, \"utf8\"),\n });\n }\n\n const hooksServerFile = path.join(options.root, \"src\", \"hooks.server.ts\");\n\n if (fs.existsSync(hooksServerFile)) {\n modifyHooksServer(hooksServerFile);\n modifies.push({\n path: hooksServerFile,\n language: \"ts\",\n content: fs.readFileSync(hooksServerFile, \"utf8\"),\n });\n }\n\n return {\n creates: [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n } satisfies Result;\n}\n"],"names":["modifyLayoutServer","layoutPath","fs","snippet","dedent","sourceFile","Project","addUserProp","obj","loadArrow","loadFn","varDecl","vs","SyntaxKind","directArrow","init","innerArrow","innerFnExpr","maybeFn","fnLike","params","first","original","nameNode","obp","el","parts","tail","currentName","body","ret","expr","inner","bodyExpr","modifyLayoutSvelte","layout","navbarRoot","navbarList","imports","scriptOpenIdx","scriptOpenEnd","scriptCloseIdx","scriptContent","lastImportEnd","importRegex","match","before","after","newScriptContent","newNavbarList","modifyHooksServer","hooksServerPath","callExpr","ce","args","firstArg","optionsObj","authProp","authInit","authObj","prProp","prInit","arr","generate","options","input","creates","withPocketbase","pb","userCollection","verificationTemplate","resetPasswordTemplate","confirmEmailChangeTemplate","migrationFile","getMigrationFile","modifies","layoutServerFile","path","layoutFile","hooksServerFile"],"mappings":";;;;;AAIO,SAASA,EAAmBC,GAAoB;AACrD,MAAI,CAACC,EAAG,WAAWD,CAAU,GAAG;AAG9B,UAAME,IAAUC;AAAA;AAAA;AAAA;AAAA;AAMhB,IAAAF,EAAG,cAAcD,GAAYE,CAAO;AACpC;AAAA,EACF;AAGA,QAAME,IADU,IAAIC,EAAA,EACO,oBAAoBL,CAAU,GAGnDM,IAAc,CAACC,MAAoD;AAEvE,IADgB,CAAC,CAACA,EAAI,YAAY,MAAM,KAEtCA,EAAI,sBAAsB;AAAA,MACxB,MAAM;AAAA,MACN,aAAa;AAAA,IAAA,CACd;AAAA,EAEL;AAGA,MAAIC,GACAC;AAKJ,QAAMC,IAAUN,EAAW,uBAAuB,MAAM;AACxD,MAAIM,GAAS;AACX,UAAMC,IAAKD,EAAQ,uBAAuBE,EAAW,iBAAiB;AAEtE,QADmB,CAAC,EAACD,KAAA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A,IACA;AAAA,IACA;AAAA,EAAA;AAGF,EAAK9D,EAAG,WAAW4E,CAAU,MAC3BA,IAAaD,EAAK,KAAKb,EAAQ,MAAM,OAAO,UAAU,oBAAoB,IAGvE9D,EAAG,WAAW4E,CAAU,MAC3BA,IAAaD,EAAK;AAAA,IAChBb,EAAQ;AAAA,IACR;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,IAIC9D,EAAG,WAAW4E,CAAU,MAC3BA,IAAaD,EAAK,KAAKb,EAAQ,MAAM,OAAO,UAAU,gBAAgB,IAGpE9D,EAAG,WAAW4E,CAAU,MAC1B5C,EAAmB4C,CAAU,GAC7BH,EAAS,KAAK;AAAA,IACZ,MAAMG;AAAA,IACN,UAAU;AAAA,IACV,SAAS5E,EAAG,aAAa4E,GAAY,MAAM;AAAA,EAAA,CAC5C;AAGH,QAAMC,IAAkBF,EAAK,KAAKb,EAAQ,MAAM,OAAO,iBAAiB;AAExE,SAAI9D,EAAG,WAAW6E,CAAe,MAC/B7B,EAAkB6B,CAAe,GACjCJ,EAAS,KAAK;AAAA,IACZ,MAAMI;AAAA,IACN,UAAU;AAAA,IACV,SAAS7E,EAAG,aAAa6E,GAAiB,MAAM;AAAA,EAAA,CACjD,IAGI;AAAA,IACL,SAAS,CAAA;AAAA,IACT,UAAAJ;AAAA,IACA,SAAS,CAAA;AAAA,IACT,YAAY,CAAA;AAAA,IACZ,UAAU,CAAA;AAAA,IACV,aAAa,CAAA;AAAA,EAAC;AAElB;"}
@@ -1637,7 +1637,7 @@ function an(t, e, n, r) {
1637
1637
  async function W(t, e, n) {
1638
1638
  let r;
1639
1639
  if (n.env === "runtime") {
1640
- const { getCollections: a } = await import("./env.runtime-BzRhpNR3.js");
1640
+ const { getCollections: a } = await import("./env.runtime-wPrXEoHB.js");
1641
1641
  r = await a();
1642
1642
  } else {
1643
1643
  const { getPreviewCollections: a } = await import("./env.preview-HlXZOEL4.js");
@@ -2199,7 +2199,7 @@ function U(t, e) {
2199
2199
  async function kn(t) {
2200
2200
  const { modelPath: e, fields: n } = wn(t.argv);
2201
2201
  K(e);
2202
- const r = E(e, t), s = (await W(n, r, t)).fields, { pagePath: i, pageUrl: o } = vn(e, r.routesDir), c = t.env === "runtime" ? await (await import("./env.runtime-BzRhpNR3.js")).getCollections() : (await import("./env.preview-HlXZOEL4.js")).getPreviewCollections(t), m = [
2202
+ const r = E(e, t), s = (await W(n, r, t)).fields, { pagePath: i, pageUrl: o } = vn(e, r.routesDir), c = t.env === "runtime" ? await (await import("./env.runtime-wPrXEoHB.js")).getCollections() : (await import("./env.preview-HlXZOEL4.js")).getPreviewCollections(t), m = [
2203
2203
  U(`${i}/+page.svelte`, _n(r, s)),
2204
2204
  U(`${i}/+page.server.ts`, Sn(r, s)),
2205
2205
  U(
@@ -2233,14 +2233,8 @@ const Pn = {
2233
2233
  tags: ["sveltekit", "superforms", "validation", "zod"],
2234
2234
  command: {
2235
2235
  raw: "vela generate form contact name:text email:email message:editor",
2236
- argv: [
2237
- "generate",
2238
- "form",
2239
- "contact",
2240
- "name:text",
2241
- "email:email",
2242
- "message:editor"
2243
- ]
2236
+ base: "vela generate form",
2237
+ argv: ["contact", "name:text", "email:email", "message:editor"]
2244
2238
  },
2245
2239
  baseline: "velastack",
2246
2240
  generate: Rn
@@ -2512,7 +2506,7 @@ async function Ln(t, e, n) {
2512
2506
  const i = await W(n, r, t);
2513
2507
  return { model: r, fields: i.fields, auth: i.auth, shouldCreateCollection: !0 };
2514
2508
  }
2515
- const a = t.env === "runtime" ? await (await import("./env.runtime-BzRhpNR3.js")).getCollections() : (await import("./env.preview-HlXZOEL4.js")).getPreviewCollections(t), s = st(r, a, t);
2509
+ const a = t.env === "runtime" ? await (await import("./env.runtime-wPrXEoHB.js")).getCollections() : (await import("./env.preview-HlXZOEL4.js")).getPreviewCollections(t), s = st(r, a, t);
2516
2510
  return { model: r, fields: s, auth: void 0, shouldCreateCollection: !1 };
2517
2511
  }
2518
2512
  async function On(t) {
@@ -2538,7 +2532,7 @@ async function Un(t) {
2538
2532
  const e = await On(t);
2539
2533
  if (t.env !== "runtime")
2540
2534
  return k(e);
2541
- const { createCollections: n } = await import("./collections-DVLGhVXc.js"), r = await n(e.collections, t), a = {
2535
+ const { createCollections: n } = await import("./collections-Q0--CN0k.js"), r = await n(e.collections, t), a = {
2542
2536
  ...e,
2543
2537
  creates: [...e.creates, ...r]
2544
2538
  }, { writeResult: s } = await import("./write-result-DG5OAbe1.js");
@@ -2552,7 +2546,8 @@ const Vn = {
2552
2546
  tags: ["pocketbase", "resource", "schema"],
2553
2547
  command: {
2554
2548
  raw: "vela generate resource contact name:text email:email",
2555
- argv: ["generate", "resource", "contact", "name:text", "email:email"]
2549
+ base: "vela generate resource",
2550
+ argv: ["contact", "name:text", "email:email"]
2556
2551
  },
2557
2552
  baseline: "velastack",
2558
2553
  generate: Un
@@ -3281,7 +3276,7 @@ function nr(t, e, n, r) {
3281
3276
  }
3282
3277
  async function rr(t, e, n) {
3283
3278
  K(e);
3284
- const r = E(e, t), a = t.env === "runtime" ? await (await import("./env.runtime-BzRhpNR3.js")).getCollections() : (await import("./env.preview-HlXZOEL4.js")).getPreviewCollections(t);
3279
+ const r = E(e, t), a = t.env === "runtime" ? await (await import("./env.runtime-wPrXEoHB.js")).getCollections() : (await import("./env.preview-HlXZOEL4.js")).getPreviewCollections(t);
3285
3280
  if (n.length > 0) {
3286
3281
  const i = await W(n, r, t);
3287
3282
  return {
@@ -3377,7 +3372,7 @@ async function sr(t) {
3377
3372
  const e = await ar(t);
3378
3373
  if (t.env !== "runtime")
3379
3374
  return k(e);
3380
- const { createCollections: n } = await import("./collections-DVLGhVXc.js"), r = await n(e.collections, t), a = {
3375
+ const { createCollections: n } = await import("./collections-Q0--CN0k.js"), r = await n(e.collections, t), a = {
3381
3376
  ...e,
3382
3377
  creates: [...e.creates, ...r]
3383
3378
  }, { writeResult: s } = await import("./write-result-DG5OAbe1.js");
@@ -3391,7 +3386,8 @@ const ir = {
3391
3386
  tags: ["crud", "scaffold", "pocketbase", "sveltekit"],
3392
3387
  command: {
3393
3388
  raw: "vela generate scaffold contact name:text email:email",
3394
- argv: ["generate", "scaffold", "contact", "name:text", "email:email"]
3389
+ base: "vela generate scaffold",
3390
+ argv: ["contact", "name:text", "email:email"]
3395
3391
  },
3396
3392
  baseline: "velastack",
3397
3393
  generate: sr
@@ -3423,7 +3419,7 @@ async function ur(t, e, n) {
3423
3419
  const i = await W(n, r, t);
3424
3420
  return { model: r, fields: i.fields, includeModelFields: !1 };
3425
3421
  }
3426
- const a = t.env === "runtime" ? await (await import("./env.runtime-BzRhpNR3.js")).getCollections() : (await import("./env.preview-HlXZOEL4.js")).getPreviewCollections(t), s = st(r, a, t);
3422
+ const a = t.env === "runtime" ? await (await import("./env.runtime-wPrXEoHB.js")).getCollections() : (await import("./env.preview-HlXZOEL4.js")).getPreviewCollections(t), s = st(r, a, t);
3427
3423
  return { model: r, fields: s, includeModelFields: !0 };
3428
3424
  }
3429
3425
  async function pr(t) {
@@ -3460,7 +3456,8 @@ const hr = {
3460
3456
  tags: ["zod", "schema", "pocketbase"],
3461
3457
  command: {
3462
3458
  raw: "vela generate schema contact name:text email:email",
3463
- argv: ["generate", "schema", "contact", "name:text", "email:email"]
3459
+ base: "vela generate schema",
3460
+ argv: ["contact", "name:text", "email:email"]
3464
3461
  },
3465
3462
  baseline: "velastack",
3466
3463
  generate: fr
@@ -5985,7 +5982,7 @@ async function Ca(t) {
5985
5982
  const s = await $a();
5986
5983
  return k(pt([e, s]));
5987
5984
  }
5988
- const { generate: n } = await import("./generate.runtime-BCboVR38.js"), r = await n(t), { writeResult: a } = await import("./write-result-DG5OAbe1.js");
5985
+ const { generate: n } = await import("./generate.runtime-BT46R-FS.js"), r = await n(t), { writeResult: a } = await import("./write-result-DG5OAbe1.js");
5989
5986
  return a(await k(pt([e, r])), t);
5990
5987
  }
5991
5988
  const _a = {
@@ -6003,7 +6000,8 @@ const _a = {
6003
6000
  ],
6004
6001
  command: {
6005
6002
  raw: "vela enable auth",
6006
- argv: ["enable", "auth"]
6003
+ base: "vela enable auth",
6004
+ argv: []
6007
6005
  },
6008
6006
  baseline: "velastack",
6009
6007
  generate: Ca
@@ -6028,4 +6026,4 @@ export {
6028
6026
  Ia as i,
6029
6027
  j as l
6030
6028
  };
6031
- //# sourceMappingURL=index-DBV0rNRK.js.map
6029
+ //# sourceMappingURL=index-CbDX3h_c.js.map