@velastack/patterns 0.0.34 → 0.0.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{collections-Czm1C8ow.js → collections-DcCZ0dam.js} +74 -6
- package/dist/chunks/collections-DcCZ0dam.js.map +1 -0
- package/dist/chunks/env-DfA_NCKk.js +67 -0
- package/dist/chunks/env-DfA_NCKk.js.map +1 -0
- package/dist/chunks/{env.preview-BZwjhgoi.js → env.preview-7Cc9KCgc.js} +1 -1
- package/dist/chunks/{env.preview-BZwjhgoi.js.map → env.preview-7Cc9KCgc.js.map} +1 -1
- package/dist/chunks/{env.runtime-BEdollKV.js → env.runtime-l1ssTZog.js} +1 -1
- package/dist/chunks/{env.runtime-BEdollKV.js.map → env.runtime-l1ssTZog.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Caqa5ndO.js → generate.runtime-BB0XISiq.js} +4 -3
- package/dist/chunks/{generate.runtime-Caqa5ndO.js.map → generate.runtime-BB0XISiq.js.map} +1 -1
- package/dist/chunks/generate.runtime-Bag8x62P.js +37 -0
- package/dist/chunks/generate.runtime-Bag8x62P.js.map +1 -0
- package/dist/chunks/generate.runtime-Bu5bO86n.js +60 -0
- package/dist/chunks/generate.runtime-Bu5bO86n.js.map +1 -0
- package/dist/chunks/{generate.runtime-DTZ1PeDS.js → generate.runtime-CKouBODu.js} +27 -26
- package/dist/chunks/{generate.runtime-DTZ1PeDS.js.map → generate.runtime-CKouBODu.js.map} +1 -1
- package/dist/chunks/{generate.runtime-D7ksYerH.js → generate.runtime-CS55berV.js} +7 -6
- package/dist/chunks/{generate.runtime-D7ksYerH.js.map → generate.runtime-CS55berV.js.map} +1 -1
- package/dist/chunks/generate.runtime-CVsBIZm4.js +37 -0
- package/dist/chunks/generate.runtime-CVsBIZm4.js.map +1 -0
- package/dist/chunks/{generate.runtime-y1Ga_5QI.js → generate.runtime-Cy56Ypws.js} +27 -26
- package/dist/chunks/{generate.runtime-y1Ga_5QI.js.map → generate.runtime-Cy56Ypws.js.map} +1 -1
- package/dist/chunks/generate.runtime-D3H_yNZA.js +210 -0
- package/dist/chunks/generate.runtime-D3H_yNZA.js.map +1 -0
- package/dist/chunks/generate.runtime-D8DxU99S.js +93 -0
- package/dist/chunks/generate.runtime-D8DxU99S.js.map +1 -0
- package/dist/chunks/generate.runtime-DPbHzukR.js +116 -0
- package/dist/chunks/generate.runtime-DPbHzukR.js.map +1 -0
- package/dist/chunks/{generate.runtime-BZ-KaCUr.js → generate.runtime-DV9S4KW_.js} +116 -132
- package/dist/chunks/generate.runtime-DV9S4KW_.js.map +1 -0
- package/dist/chunks/generate.runtime-GmszNklA.js +56 -0
- package/dist/chunks/generate.runtime-GmszNklA.js.map +1 -0
- package/dist/chunks/generate.runtime-NdlYevoh.js +65 -0
- package/dist/chunks/generate.runtime-NdlYevoh.js.map +1 -0
- package/dist/chunks/{generate.runtime-Cbq2649r.js → generate.runtime-eYyscad0.js} +29 -28
- package/dist/chunks/{generate.runtime-Cbq2649r.js.map → generate.runtime-eYyscad0.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BCz-NNqq.js → generate.runtime-mPNuFTCh.js} +54 -53
- package/dist/chunks/{generate.runtime-BCz-NNqq.js.map → generate.runtime-mPNuFTCh.js.map} +1 -1
- package/dist/chunks/hooks.server-CPVyj3rv.js +75 -0
- package/dist/chunks/hooks.server-CPVyj3rv.js.map +1 -0
- package/dist/chunks/{modify-file-DT_1_kvI.js → modify-file-Bi-4GRwL.js} +2 -2
- package/dist/chunks/{modify-file-DT_1_kvI.js.map → modify-file-Bi-4GRwL.js.map} +1 -1
- package/dist/chunks/{modify-svelte-config-remote-CFsA9Mom.js → modify-svelte-config-remote-B-jnjYqs.js} +1 -1
- package/dist/chunks/{modify-svelte-config-remote-CFsA9Mom.js.map → modify-svelte-config-remote-B-jnjYqs.js.map} +1 -1
- package/dist/chunks/{pocketbase-iFJBbNJu.js → pocketbase-CT78tKFG.js} +1 -1
- package/dist/chunks/{pocketbase-iFJBbNJu.js.map → pocketbase-CT78tKFG.js.map} +1 -1
- package/dist/chunks/shared-D9iYuKxV.js +27 -0
- package/dist/chunks/shared-D9iYuKxV.js.map +1 -0
- package/dist/chunks/{ts-morph-helpers-C0HeJDjR.js → ts-morph-helpers-B0oxeDUU.js} +47 -3
- package/dist/chunks/ts-morph-helpers-B0oxeDUU.js.map +1 -0
- package/dist/chunks/{util-C064WO8o.js → util-CLl3VxaE.js} +4 -3
- package/dist/chunks/util-CLl3VxaE.js.map +1 -0
- package/dist/chunks/{write-result-B0-q-egx.js → write-result-CRq0kUvL.js} +24 -9
- package/dist/chunks/{write-result-B0-q-egx.js.map → write-result-CRq0kUvL.js.map} +1 -1
- package/dist/index.d.ts +912 -209
- package/dist/index.js +1868 -871
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunks/collections-Czm1C8ow.js.map +0 -1
- package/dist/chunks/generate.runtime-BZ-KaCUr.js.map +0 -1
- package/dist/chunks/ts-morph-helpers-C0HeJDjR.js.map +0 -1
- package/dist/chunks/util-C064WO8o.js.map +0 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { t as e } from "./errors-Co77I4oK.js";
|
|
2
|
-
import { n as t } from "./util-
|
|
2
|
+
import { n as t } from "./util-CLl3VxaE.js";
|
|
3
3
|
import { n, t as r } from "./logger-BpgCb-ZG.js";
|
|
4
|
-
import { getMigrationFile as i, migrationDelay as a, withPocketbase as o } from "./pocketbase-
|
|
4
|
+
import { getMigrationFile as i, migrationDelay as a, withPocketbase as o } from "./pocketbase-CT78tKFG.js";
|
|
5
5
|
import { readFileSync as s } from "node:fs";
|
|
6
6
|
//#region src/runtime/collections.ts
|
|
7
7
|
function c(e) {
|
|
8
|
-
if (e.response?.data?.name?.code === "
|
|
8
|
+
if (e.response?.data?.name?.code === "validation_collection_name_exists") return !0;
|
|
9
9
|
let t = e.message?.toLowerCase() ?? "";
|
|
10
10
|
return t.includes("already exists") || t.includes("must be unique");
|
|
11
11
|
}
|
|
@@ -83,7 +83,75 @@ async function p(e, n, o, c = r) {
|
|
|
83
83
|
}
|
|
84
84
|
return l;
|
|
85
85
|
}
|
|
86
|
-
async function m(e, r) {
|
|
86
|
+
async function m(e, t, n = r) {
|
|
87
|
+
try {
|
|
88
|
+
await e.collections.getOne(t);
|
|
89
|
+
} catch (e) {
|
|
90
|
+
if (e.status === 404) return n.info(`Collection "${t}" does not exist, skipping drop`), {
|
|
91
|
+
dropped: !1,
|
|
92
|
+
existed: !1
|
|
93
|
+
};
|
|
94
|
+
throw e;
|
|
95
|
+
}
|
|
96
|
+
return await e.collections.delete(t), {
|
|
97
|
+
dropped: !0,
|
|
98
|
+
existed: !0
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
async function h(e, t) {
|
|
102
|
+
try {
|
|
103
|
+
await e.collections.getOne(t);
|
|
104
|
+
} catch (e) {
|
|
105
|
+
if (e.status === 404) return {
|
|
106
|
+
exists: !1,
|
|
107
|
+
rowCount: 0
|
|
108
|
+
};
|
|
109
|
+
throw e;
|
|
110
|
+
}
|
|
111
|
+
try {
|
|
112
|
+
return {
|
|
113
|
+
exists: !0,
|
|
114
|
+
rowCount: (await e.collection(t).getList(1, 1, { skipTotal: !1 })).totalItems
|
|
115
|
+
};
|
|
116
|
+
} catch {
|
|
117
|
+
return {
|
|
118
|
+
exists: !0,
|
|
119
|
+
rowCount: 0
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
async function g(e, t) {
|
|
124
|
+
let n = [];
|
|
125
|
+
for (let r of t) {
|
|
126
|
+
let t = await h(e, r);
|
|
127
|
+
n.push({
|
|
128
|
+
name: r,
|
|
129
|
+
exists: t.exists,
|
|
130
|
+
rowCount: t.rowCount
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
return n;
|
|
134
|
+
}
|
|
135
|
+
async function _(e, r) {
|
|
136
|
+
if (e.length === 0) return [];
|
|
137
|
+
let c = [], l = n(r);
|
|
138
|
+
return await o(r.root, async (n) => {
|
|
139
|
+
for (let o of e) {
|
|
140
|
+
l.info(`Dropping collection "${o.name}"`);
|
|
141
|
+
let { dropped: e } = await m(n, o.name, l);
|
|
142
|
+
if (!e) continue;
|
|
143
|
+
await a();
|
|
144
|
+
let u = i(o.name, "deleted", r);
|
|
145
|
+
u && c.push({
|
|
146
|
+
path: u,
|
|
147
|
+
language: t(u),
|
|
148
|
+
content: s(u, "utf8"),
|
|
149
|
+
status: "success"
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
}), c;
|
|
153
|
+
}
|
|
154
|
+
async function v(e, r) {
|
|
87
155
|
if (e.length === 0) return [];
|
|
88
156
|
let c = [], u = n(r);
|
|
89
157
|
return await o(r.root, async (n) => {
|
|
@@ -103,6 +171,6 @@ async function m(e, r) {
|
|
|
103
171
|
}), c;
|
|
104
172
|
}
|
|
105
173
|
//#endregion
|
|
106
|
-
export { p as applyCollectionFieldsPatches, d as applyCollectionRulePatches, l as createCollectionIdempotent,
|
|
174
|
+
export { p as applyCollectionFieldsPatches, d as applyCollectionRulePatches, l as createCollectionIdempotent, v as createCollections, _ as dropCollections, g as planCollectionDrops };
|
|
107
175
|
|
|
108
|
-
//# sourceMappingURL=collections-
|
|
176
|
+
//# sourceMappingURL=collections-DcCZ0dam.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collections-DcCZ0dam.js","names":[],"sources":["../../src/runtime/collections.ts"],"sourcesContent":["import { readFileSync } from \"node:fs\";\nimport type PocketBase from \"pocketbase\";\nimport type { CollectionModel } from \"pocketbase\";\nimport type {\n CollectionDropSpec,\n CollectionFieldSpec,\n CollectionFieldsPatch,\n CollectionRulesPatch,\n CollectionSpec,\n File,\n Options,\n} from \"../core/types\";\nimport { InvalidArgumentError } from \"../core/errors\";\nimport { getLogger, NOOP_LOGGER, type Logger } from \"../core/logger\";\nimport { languageFromPath } from \"../core/util\";\nimport { getMigrationFile, migrationDelay, 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 (\n error.response?.data?.name?.code === \"validation_collection_name_exists\"\n ) {\n return true;\n }\n\n const message = error.message?.toLowerCase() ?? \"\";\n return (\n message.includes(\"already exists\") || message.includes(\"must be unique\")\n );\n}\n\ntype CollectionCreateInput = Parameters<PocketBase[\"collections\"][\"create\"]>[0];\n\nexport interface CreateCollectionResult {\n collection: CollectionModel;\n created: boolean;\n}\n\n/**\n * Idempotent wrapper around `pb.collections.create`. If the collection already\n * exists, logs and returns the existing model with `created: false` so callers\n * can skip work tied to a fresh create (e.g. appending a newly-generated\n * migration file to the result).\n */\nexport async function createCollectionIdempotent(\n pb: PocketBase,\n spec: CollectionCreateInput,\n logger: Logger = NOOP_LOGGER,\n): Promise<CreateCollectionResult> {\n const name = (spec as { name: string }).name;\n try {\n const collection = await pb.collections.create(spec);\n return { collection, created: true };\n } catch (error) {\n if (\n !isCollectionAlreadyExistsError(error as PocketBaseCollectionCreateError)\n ) {\n throw error;\n }\n logger.info(`Collection \"${name}\" already exists, skipping`);\n const collection = await pb.collections.getOne(name);\n return { collection, created: false };\n }\n}\n\nfunction rulePayloadFromPatch(\n patch: CollectionRulesPatch,\n): Record<string, unknown> {\n const payload: Record<string, unknown> = {};\n if (patch.listRule !== undefined) payload.listRule = patch.listRule;\n if (patch.viewRule !== undefined) payload.viewRule = patch.viewRule;\n if (patch.createRule !== undefined) payload.createRule = patch.createRule;\n if (patch.updateRule !== undefined) payload.updateRule = patch.updateRule;\n if (patch.deleteRule !== undefined) payload.deleteRule = patch.deleteRule;\n return payload;\n}\n\n/**\n * Applies API rule updates in array order. Call after all referenced collections exist.\n * Collects migration files produced by each update when `options` is provided.\n */\nexport async function applyCollectionRulePatches(\n pb: {\n collections: {\n getFirstListItem: (filter: string) => Promise<{ id: string }>;\n update: (id: string, body: Record<string, unknown>) => Promise<unknown>;\n };\n },\n patches: CollectionRulesPatch[],\n options?: Options,\n logger: Logger = NOOP_LOGGER,\n): Promise<File[]> {\n const migrations: File[] = [];\n\n for (const patch of patches) {\n const escaped = patch.collectionName.replace(/'/g, \"''\");\n const col = await pb.collections.getFirstListItem(`name='${escaped}'`);\n logger.info(`Updating rules on collection \"${patch.collectionName}\"`);\n await pb.collections.update(col.id, rulePayloadFromPatch(patch));\n await migrationDelay();\n\n if (options) {\n const migrationFile = getMigrationFile(\n patch.collectionName,\n \"updated\",\n options,\n );\n if (migrationFile) {\n migrations.push({\n path: migrationFile,\n language: languageFromPath(migrationFile),\n content: readFileSync(migrationFile, \"utf8\"),\n status: \"success\",\n });\n }\n }\n }\n\n return migrations;\n}\n\nfunction applyFieldChanges(\n existing: CollectionFieldSpec[],\n patch: CollectionFieldsPatch,\n): CollectionFieldSpec[] {\n const fields = existing.map((field) => ({ ...field }));\n\n for (const change of patch.changes) {\n if (change.op === \"add\") {\n if (fields.some((f) => f.name === change.field.name)) {\n throw new InvalidArgumentError(\n `Field \"${change.field.name}\" already exists on collection \"${patch.collectionName}\"`,\n );\n }\n fields.push(change.field);\n continue;\n }\n if (change.op === \"remove\") {\n const index = fields.findIndex((f) => f.name === change.fieldName);\n if (index === -1) {\n throw new InvalidArgumentError(\n `Field \"${change.fieldName}\" does not exist on collection \"${patch.collectionName}\"`,\n );\n }\n fields.splice(index, 1);\n continue;\n }\n if (change.op === \"rename\") {\n const field = fields.find((f) => f.name === change.from);\n if (!field) {\n throw new InvalidArgumentError(\n `Field \"${change.from}\" does not exist on collection \"${patch.collectionName}\"`,\n );\n }\n if (fields.some((f) => f.name === change.to)) {\n throw new InvalidArgumentError(\n `Field \"${change.to}\" already exists on collection \"${patch.collectionName}\"`,\n );\n }\n field.name = change.to;\n continue;\n }\n }\n\n return fields;\n}\n\nexport async function applyCollectionFieldsPatches(\n pb: {\n collections: {\n getOne: (\n name: string,\n ) => Promise<{ id: string; fields: CollectionFieldSpec[] }>;\n update: (id: string, body: Record<string, unknown>) => Promise<unknown>;\n };\n },\n patches: CollectionFieldsPatch[],\n options: Options,\n logger: Logger = NOOP_LOGGER,\n): Promise<File[]> {\n const migrations: File[] = [];\n\n for (const patch of patches) {\n const collection = await pb.collections.getOne(patch.collectionName);\n const newFields = applyFieldChanges(collection.fields, patch);\n logger.info(`Updating fields on collection \"${patch.collectionName}\"`);\n await pb.collections.update(collection.id, { fields: newFields });\n await migrationDelay();\n\n const migrationFile = getMigrationFile(\n patch.collectionName,\n \"updated\",\n options,\n );\n if (!migrationFile) continue;\n\n migrations.push({\n path: migrationFile,\n language: languageFromPath(migrationFile),\n content: readFileSync(migrationFile, \"utf8\"),\n status: \"success\",\n });\n }\n\n return migrations;\n}\n\nexport interface DropCollectionResult {\n dropped: boolean;\n existed: boolean;\n}\n\n/**\n * Idempotent collection drop. Returns `{ existed: false, dropped: false }` if\n * the collection is already gone, matching the idempotency contract of\n * `createCollectionIdempotent`.\n */\nexport async function dropCollectionIdempotent(\n pb: PocketBase,\n name: string,\n logger: Logger = NOOP_LOGGER,\n): Promise<DropCollectionResult> {\n try {\n await pb.collections.getOne(name);\n } catch (error) {\n const status = (error as { status?: number }).status;\n if (status === 404) {\n logger.info(`Collection \"${name}\" does not exist, skipping drop`);\n return { dropped: false, existed: false };\n }\n throw error;\n }\n await pb.collections.delete(name);\n return { dropped: true, existed: true };\n}\n\nexport interface CollectionStats {\n exists: boolean;\n rowCount: number;\n}\n\nexport async function getCollectionStats(\n pb: PocketBase,\n name: string,\n): Promise<CollectionStats> {\n try {\n await pb.collections.getOne(name);\n } catch (error) {\n const status = (error as { status?: number }).status;\n if (status === 404) {\n return { exists: false, rowCount: 0 };\n }\n throw error;\n }\n\n try {\n const result = await pb.collection(name).getList(1, 1, { skipTotal: false });\n return { exists: true, rowCount: result.totalItems };\n } catch {\n return { exists: true, rowCount: 0 };\n }\n}\n\n/**\n * Resolve the set of collections to drop, with current row counts. Missing\n * collections are included with `exists: false, rowCount: 0` so callers can\n * display the full reversal plan even when some collections were already gone.\n */\nexport async function planCollectionDrops(\n pb: PocketBase,\n names: string[],\n): Promise<CollectionDropSpec[]> {\n const plans: CollectionDropSpec[] = [];\n for (const name of names) {\n const stats = await getCollectionStats(pb, name);\n plans.push({ name, exists: stats.exists, rowCount: stats.rowCount });\n }\n return plans;\n}\n\n/**\n * Drop each of the given collections (skipping those that are already gone)\n * and collect the `_deleted_<name>.js` migration file PocketBase emits for\n * each successful drop. Symmetric to `createCollections`.\n */\nexport async function dropCollections(\n specs: CollectionDropSpec[],\n options: Options,\n): Promise<File[]> {\n if (specs.length === 0) {\n return [];\n }\n\n const migrations: File[] = [];\n const logger = getLogger(options);\n\n await withPocketbase(options.root, async (pb) => {\n for (const spec of specs) {\n logger.info(`Dropping collection \"${spec.name}\"`);\n const { dropped } = await dropCollectionIdempotent(pb, spec.name, logger);\n if (!dropped) continue;\n await migrationDelay();\n\n const migrationFile = getMigrationFile(spec.name, \"deleted\", options);\n if (!migrationFile) continue;\n\n migrations.push({\n path: migrationFile,\n language: languageFromPath(migrationFile),\n content: readFileSync(migrationFile, \"utf8\"),\n status: \"success\",\n });\n }\n });\n\n return migrations;\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 const logger = getLogger(options);\n\n await withPocketbase(options.root, async (pb) => {\n for (const collection of collections) {\n logger.info(`Creating collection \"${collection.name}\"`);\n const { created } = await createCollectionIdempotent(\n pb,\n collection,\n logger,\n );\n if (!created) continue;\n await migrationDelay();\n\n const migrationFile = getMigrationFile(\n collection.name,\n \"created\",\n options,\n );\n if (!migrationFile) {\n continue;\n }\n\n migrations.push({\n path: migrationFile,\n language: languageFromPath(migrationFile),\n content: readFileSync(migrationFile, \"utf8\"),\n status: \"success\",\n });\n }\n });\n\n return migrations;\n}\n"],"mappings":";;;;;;AA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EACnB,QAAO,EAAE;CAGX,IAAM,IAAqB,EAAE,EACvB,IAAS,EAAU,EAAQ;AAqBjC,QAnBA,MAAM,EAAe,EAAQ,MAAM,OAAO,MAAO;AAC/C,OAAK,IAAM,KAAQ,GAAO;AACxB,KAAO,KAAK,wBAAwB,EAAK,KAAK,GAAG;GACjD,IAAM,EAAE,eAAY,MAAM,EAAyB,GAAI,EAAK,MAAM,EAAO;AACzE,OAAI,CAAC,EAAS;AACd,SAAM,GAAgB;GAEtB,IAAM,IAAgB,EAAiB,EAAK,MAAM,WAAW,EAAQ;AAChE,QAEL,EAAW,KAAK;IACd,MAAM;IACN,UAAU,EAAiB,EAAc;IACzC,SAAS,EAAa,GAAe,OAAO;IAC5C,QAAQ;IACT,CAAC;;GAEJ,EAEK;;AAGT,eAAsB,EACpB,GACA,GACiB;AACjB,KAAI,EAAY,WAAW,EACzB,QAAO,EAAE;CAGX,IAAM,IAAqB,EAAE,EACvB,IAAS,EAAU,EAAQ;AA+BjC,QA7BA,MAAM,EAAe,EAAQ,MAAM,OAAO,MAAO;AAC/C,OAAK,IAAM,KAAc,GAAa;AACpC,KAAO,KAAK,wBAAwB,EAAW,KAAK,GAAG;GACvD,IAAM,EAAE,eAAY,MAAM,EACxB,GACA,GACA,EACD;AACD,OAAI,CAAC,EAAS;AACd,SAAM,GAAgB;GAEtB,IAAM,IAAgB,EACpB,EAAW,MACX,WACA,EACD;AACI,QAIL,EAAW,KAAK;IACd,MAAM;IACN,UAAU,EAAiB,EAAc;IACzC,SAAS,EAAa,GAAe,OAAO;IAC5C,QAAQ;IACT,CAAC;;GAEJ,EAEK"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import e from "node:fs";
|
|
2
|
+
//#region src/runtime/env.ts
|
|
3
|
+
function t(e, t) {
|
|
4
|
+
return (!e.length || e.endsWith("\n") ? e : e + "\n") + t + "\n";
|
|
5
|
+
}
|
|
6
|
+
function n(e, n) {
|
|
7
|
+
let r = e;
|
|
8
|
+
for (let e of n) {
|
|
9
|
+
if (e.type === "comment") {
|
|
10
|
+
let n = `# ${e.key}`;
|
|
11
|
+
r.includes(n) || (r = t(r, n));
|
|
12
|
+
continue;
|
|
13
|
+
}
|
|
14
|
+
r.includes(`${e.key}=`) || (r = t(r, `${e.key}=${e.value ?? ""}`));
|
|
15
|
+
}
|
|
16
|
+
return r;
|
|
17
|
+
}
|
|
18
|
+
function r(t, r) {
|
|
19
|
+
let i = e.existsSync(t) ? e.readFileSync(t, "utf8") : "", a = n(i, r);
|
|
20
|
+
return a === i ? {
|
|
21
|
+
status: "success",
|
|
22
|
+
changed: !1
|
|
23
|
+
} : (e.writeFileSync(t, a, "utf8"), {
|
|
24
|
+
status: "success",
|
|
25
|
+
changed: !0
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
function i(e, t) {
|
|
29
|
+
let n = e.split("\n"), r = n.map(() => !0);
|
|
30
|
+
for (let e of t) if (e.type === "var") for (let t = 0; t < n.length; t++) {
|
|
31
|
+
if (!r[t]) continue;
|
|
32
|
+
let i = n[t];
|
|
33
|
+
(i === `${e.key}=${e.value ?? ""}` || i.startsWith(`${e.key}=`)) && (r[t] = !1);
|
|
34
|
+
}
|
|
35
|
+
for (let e of t) {
|
|
36
|
+
if (e.type !== "comment") continue;
|
|
37
|
+
let t = `# ${e.key}`;
|
|
38
|
+
for (let e = 0; e < n.length; e++) {
|
|
39
|
+
if (!r[e] || n[e] !== t) continue;
|
|
40
|
+
let i = e + 1;
|
|
41
|
+
for (; i < n.length && (!r[i] || n[i].trim() === "");) i++;
|
|
42
|
+
(i >= n.length || n[i].startsWith("#")) && (r[e] = !1);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
let i = [], a = !1;
|
|
46
|
+
for (let e = 0; e < n.length; e++) {
|
|
47
|
+
if (!r[e]) continue;
|
|
48
|
+
let t = n[e].trim() === "";
|
|
49
|
+
t && a || (i.push(n[e]), a = t);
|
|
50
|
+
}
|
|
51
|
+
for (; i.length > 0 && i[i.length - 1].trim() === "";) i.pop();
|
|
52
|
+
return i.length === 0 ? "" : i.join("\n") + "\n";
|
|
53
|
+
}
|
|
54
|
+
function a(t, n) {
|
|
55
|
+
let r = e.existsSync(t) ? e.readFileSync(t, "utf8") : "", a = i(r, n);
|
|
56
|
+
return a === r ? {
|
|
57
|
+
status: "success",
|
|
58
|
+
changed: !1
|
|
59
|
+
} : (e.writeFileSync(t, a, "utf8"), {
|
|
60
|
+
status: "success",
|
|
61
|
+
changed: !0
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
//#endregion
|
|
65
|
+
export { a as n, r as t };
|
|
66
|
+
|
|
67
|
+
//# sourceMappingURL=env-DfA_NCKk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env-DfA_NCKk.js","names":[],"sources":["../../src/runtime/env.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport type { ModifyOutcome } from \"../core/types\";\n\nexport interface EnvEdit {\n type: \"comment\" | \"var\";\n /** For \"comment\": the text after `# `. For \"var\": the KEY. */\n key: string;\n /** Only for \"var\" entries. */\n value?: string;\n}\n\nfunction appendEnvContent(existing: string, content: string): string {\n const withNewLine =\n !existing.length || existing.endsWith(\"\\n\") ? existing : existing + \"\\n\";\n return withNewLine + content + \"\\n\";\n}\n\nexport function applyEnvEdits(source: string, edits: EnvEdit[]): string {\n let next = source;\n for (const edit of edits) {\n if (edit.type === \"comment\") {\n const commented = `# ${edit.key}`;\n if (!next.includes(commented)) {\n next = appendEnvContent(next, commented);\n }\n continue;\n }\n if (!next.includes(`${edit.key}=`)) {\n next = appendEnvContent(next, `${edit.key}=${edit.value ?? \"\"}`);\n }\n }\n return next;\n}\n\nexport function modifyEnv(envPath: string, edits: EnvEdit[]): ModifyOutcome {\n const existing = fs.existsSync(envPath)\n ? fs.readFileSync(envPath, \"utf8\")\n : \"\";\n const next = applyEnvEdits(existing, edits);\n if (next === existing) {\n return { status: \"success\", changed: false };\n }\n fs.writeFileSync(envPath, next, \"utf8\");\n return { status: \"success\", changed: true };\n}\n\n/**\n * Remove lines matching the given edits from env source. Var edits remove the\n * exact `KEY=...` line (anchored, so `FOO` does not match `FOO_BAR`). Comment\n * edits remove the `# key` line only when it has become orphaned — i.e. the\n * next non-blank line is another comment, another orphaned block, or EOF.\n */\nexport function removeEnvEdits(source: string, edits: EnvEdit[]): string {\n const lines = source.split(\"\\n\");\n const keep: boolean[] = lines.map(() => true);\n\n for (const edit of edits) {\n if (edit.type !== \"var\") continue;\n for (let i = 0; i < lines.length; i++) {\n if (!keep[i]) continue;\n const line = lines[i];\n if (line === `${edit.key}=${edit.value ?? \"\"}` || line.startsWith(`${edit.key}=`)) {\n keep[i] = false;\n }\n }\n }\n\n for (const edit of edits) {\n if (edit.type !== \"comment\") continue;\n const target = `# ${edit.key}`;\n for (let i = 0; i < lines.length; i++) {\n if (!keep[i] || lines[i] !== target) continue;\n let j = i + 1;\n while (j < lines.length && (!keep[j] || lines[j].trim() === \"\")) j++;\n const nextIsComment = j >= lines.length || lines[j].startsWith(\"#\");\n if (nextIsComment) {\n keep[i] = false;\n }\n }\n }\n\n const result: string[] = [];\n let lastWasBlank = false;\n for (let i = 0; i < lines.length; i++) {\n if (!keep[i]) continue;\n const isBlank = lines[i].trim() === \"\";\n if (isBlank && lastWasBlank) continue;\n result.push(lines[i]);\n lastWasBlank = isBlank;\n }\n\n while (result.length > 0 && result[result.length - 1].trim() === \"\") {\n result.pop();\n }\n\n return result.length === 0 ? \"\" : result.join(\"\\n\") + \"\\n\";\n}\n\nexport function modifyEnvRemove(\n envPath: string,\n edits: EnvEdit[],\n): ModifyOutcome {\n const existing = fs.existsSync(envPath)\n ? fs.readFileSync(envPath, \"utf8\")\n : \"\";\n const next = removeEnvEdits(existing, edits);\n if (next === existing) {\n return { status: \"success\", changed: false };\n }\n fs.writeFileSync(envPath, next, \"utf8\");\n return { status: \"success\", changed: true };\n}\n"],"mappings":";;AAWA,SAAS,EAAiB,GAAkB,GAAyB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,CAAC,EAAK,MAAM,EAAM,OAAO,EAAQ;GACrC,IAAI,IAAI,IAAI;AACZ,UAAO,IAAI,EAAM,WAAW,CAAC,EAAK,MAAM,EAAM,GAAG,MAAM,KAAK,KAAK;AAEjE,IADsB,KAAK,EAAM,UAAU,EAAM,GAAG,WAAW,IAAI,MAEjE,EAAK,KAAK;;;CAKhB,IAAM,IAAmB,EAAE,EACvB,IAAe;AACnB,MAAK,IAAI,IAAI,GAAG,IAAI,EAAM,QAAQ,KAAK;AACrC,MAAI,CAAC,EAAK,GAAI;EACd,IAAM,IAAU,EAAM,GAAG,MAAM,KAAK;AAChC,OAAW,MACf,EAAO,KAAK,EAAM,GAAG,EACrB,IAAe;;AAGjB,QAAO,EAAO,SAAS,KAAK,EAAO,EAAO,SAAS,GAAG,MAAM,KAAK,IAC/D,GAAO,KAAK;AAGd,QAAO,EAAO,WAAW,IAAI,KAAK,EAAO,KAAK,KAAK,GAAG;;AAGxD,SAAgB,EACd,GACA,GACe;CACf,IAAM,IAAW,EAAG,WAAW,EAAQ,GACnC,EAAG,aAAa,GAAS,OAAO,GAChC,IACE,IAAO,EAAe,GAAU,EAAM;AAK5C,QAJI,MAAS,IACJ;EAAE,QAAQ;EAAW,SAAS;EAAO,IAE9C,EAAG,cAAc,GAAS,GAAM,OAAO,EAChC;EAAE,QAAQ;EAAW,SAAS;EAAM"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.preview-
|
|
1
|
+
{"version":3,"file":"env.preview-7Cc9KCgc.js","names":[],"sources":["../../src/parse/env.preview.ts"],"sourcesContent":["import type { Options } from \"../core/types\";\nimport type { Collection } from \"./types\";\n\nexport function getPreviewCollections(\n options: Pick<Options, \"features\">,\n): Collection[] {\n if (options.features.auth) {\n return [\n {\n id: \"users_preview\",\n name: \"users\",\n type: \"auth\",\n fields: [\n { name: \"email\", type: \"email\" },\n { name: \"name\", type: \"text\" },\n ],\n },\n ];\n }\n return [];\n}\n"],"mappings":";AAGA,SAAgB,EACd,GACc;AAcd,QAbI,EAAQ,SAAS,OACZ,CACL;EACE,IAAI;EACJ,MAAM;EACN,MAAM;EACN,QAAQ,CACN;GAAE,MAAM;GAAS,MAAM;GAAS,EAChC;GAAE,MAAM;GAAQ,MAAM;GAAQ,CAC/B;EACF,CACF,GAEI,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.runtime-
|
|
1
|
+
{"version":3,"file":"env.runtime-l1ssTZog.js","names":[],"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"],"mappings":";;;;;;AAOA,SAAS,EAAkB,GAAsB;AAC/C,QACE,EAAG,WAAW,EAAK,KAAK,GAAK,eAAe,CAAC,IAC7C,EAAG,WAAW,EAAK,KAAK,GAAA,OAAc,CAAC;;AAI3C,SAAgB,EAAmB,IAAW,EAAQ,KAAK,EAAU;CACnE,IAAI,IAAU,EAAK,QAAQ,EAAS;AAEpC,UAAa;AACX,MAAI,EAAkB,EAAQ,CAC5B,QAAO;EAGT,IAAM,IAAS,EAAK,QAAQ,EAAQ;AACpC,MAAI,MAAW,EACb;AAEF,MAAU;;AAGZ,OAAU,MACR,wCAAwC,EAAS,gCAAgC,EAAS,GAC3F;;AAGH,eAAsB,IAAwC;CAC5D,IAAM,IAAO,GAAoB;AAEjC,QAAO,EAAqB;EAC1B,eAAe;EACf,gBAAgB,EAAQ,IAAI;EAC5B,mBAAmB,EAAQ,IAAI;EAC/B;EACD,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as e } from "./dedent-C4qKBQXh.js";
|
|
2
2
|
import { n as t } from "./logger-BpgCb-ZG.js";
|
|
3
|
-
import { modifyOutcomeToFile as n } from "./modify-file-
|
|
3
|
+
import { modifyOutcomeToFile as n } from "./modify-file-Bi-4GRwL.js";
|
|
4
4
|
import r from "node:fs";
|
|
5
5
|
import i from "node:path";
|
|
6
6
|
import { Project as a, SyntaxKind as o } from "ts-morph";
|
|
@@ -76,10 +76,11 @@ async function u(e) {
|
|
|
76
76
|
components: [],
|
|
77
77
|
packages: [],
|
|
78
78
|
collections: [],
|
|
79
|
-
collectionPatches: []
|
|
79
|
+
collectionPatches: [],
|
|
80
|
+
collectionDrops: []
|
|
80
81
|
};
|
|
81
82
|
}
|
|
82
83
|
//#endregion
|
|
83
84
|
export { u as generate };
|
|
84
85
|
|
|
85
|
-
//# sourceMappingURL=generate.runtime-
|
|
86
|
+
//# sourceMappingURL=generate.runtime-BB0XISiq.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.runtime-
|
|
1
|
+
{"version":3,"file":"generate.runtime-BB0XISiq.js","names":[],"sources":["../../src/patterns/enable/api/modifies/hooks.server.ts","../../src/patterns/enable/api/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { Project, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst FAILURE_HINT = dedent`\n Configure handlePocketbase() with the api option in hooks.server.ts:\n\n handlePocketbase({\n api: { enabled: true },\n });\n`;\n\nconst NOT_FOUND_HINT = dedent`\n Create src/hooks.server.ts with handlePocketbase:\n\n import { handlePocketbase } from 'velastack/handle';\n\n export const handle = handlePocketbase({\n api: { enabled: true },\n });\n`;\n\nexport function modifyHooksServer(hooksServerPath: string): ModifyOutcome {\n if (!fs.existsSync(hooksServerPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const originalSource = fs.readFileSync(hooksServerPath, \"utf8\");\n const project = new Project();\n const sourceFile = project.addSourceFileAtPath(hooksServerPath);\n\n const callExpr = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .find((ce) => ce.getExpression().getText() === \"handlePocketbase\");\n\n if (!callExpr) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const args = callExpr.getArguments();\n if (args.length === 0) {\n callExpr.addArgument(`{ api: { enabled: true } }`);\n sourceFile.formatText();\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n }\n\n const firstArg = args[0];\n if (firstArg.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n callExpr.insertArgument(0, `{ api: { enabled: true } }`);\n sourceFile.formatText();\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n }\n\n const optionsObj = firstArg.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);\n const apiProp = optionsObj.getProperty(\"api\");\n\n if (!apiProp) {\n optionsObj.addPropertyAssignment({\n name: \"api\",\n initializer: `{ enabled: true }`,\n });\n sourceFile.formatText();\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n }\n\n if (apiProp.getKind() === SyntaxKind.PropertyAssignment) {\n const apiInit = (\n apiProp as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n if (apiInit && apiInit.getKind() === SyntaxKind.ObjectLiteralExpression) {\n const apiObj = apiInit as import(\"ts-morph\").ObjectLiteralExpression;\n const enabledProp = apiObj.getProperty(\"enabled\");\n if (!enabledProp) {\n apiObj.addPropertyAssignment({ name: \"enabled\", initializer: \"true\" });\n }\n }\n }\n\n sourceFile.formatText();\n sourceFile.saveSync();\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\n };\n}\n","import path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { modifyHooksServer } from \"./modifies/hooks.server\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n\n logger.info(\"Modifying hooks.server.ts\");\n const hooksServerPath = path.join(options.root, \"src\", \"hooks.server.ts\");\n const file = modifyOutcomeToFile(\n hooksServerPath,\n modifyHooksServer(hooksServerPath),\n );\n if (file) modifies.push(file);\n\n return {\n creates: [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;;;AAKA,IAAM,IAAe,CAAM;;;;;;GAQrB,IAAiB,CAAM;;;;;;;;;AAU7B,SAAgB,EAAkB,GAAwC;AACxE,KAAI,CAAC,EAAG,WAAW,EAAgB,CACjC,QAAO;EAAE,QAAQ;EAAa,SAAS;EAAgB;CAGzD,IAAM,IAAiB,EAAG,aAAa,GAAiB,OAAO,EAEzD,IADU,IAAI,GAAS,CACF,oBAAoB,EAAgB,EAEzD,IAAW,EACd,qBAAqB,EAAW,eAAe,CAC/C,MAAM,MAAO,EAAG,eAAe,CAAC,SAAS,KAAK,mBAAmB;AAEpE,KAAI,CAAC,EACH,QAAO;EAAE,QAAQ;EAAU,SAAS;EAAc;CAGpD,IAAM,IAAO,EAAS,cAAc;AACpC,KAAI,EAAK,WAAW,EAIlB,QAHA,EAAS,YAAY,6BAA6B,EAClD,EAAW,YAAY,EACvB,EAAW,UAAU,EACd;EAAE,QAAQ;EAAW,SAAS;EAA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xV.js";
|
|
3
|
+
import { modifyOutcomeToFile as n } from "./modify-file-Bi-4GRwL.js";
|
|
4
|
+
import { n as r, r as i, t as a } from "./hooks.server-CPVyj3rv.js";
|
|
5
|
+
import o from "node:fs";
|
|
6
|
+
import s from "node:path";
|
|
7
|
+
//#region src/patterns/disable/auth/generate.runtime.ts
|
|
8
|
+
async function c(c) {
|
|
9
|
+
let l = e(c), u = [], d = (e) => {
|
|
10
|
+
e && u.push(e);
|
|
11
|
+
};
|
|
12
|
+
l.info("Reverting +layout.server.ts");
|
|
13
|
+
let f = s.join(c.root, "src", "routes", "+layout.server.ts");
|
|
14
|
+
d(n(f, i(f))), l.info("Reverting root layout");
|
|
15
|
+
let p = [
|
|
16
|
+
s.join(c.root, "src", "routes", "(public)", "root-layout.svelte"),
|
|
17
|
+
s.join(c.root, "src", "routes", "root-layout.svelte"),
|
|
18
|
+
s.join(c.root, "src", "routes", "(public)", "+layout.svelte"),
|
|
19
|
+
s.join(c.root, "src", "routes", "+layout.svelte")
|
|
20
|
+
], m = p.find((e) => o.existsSync(e)) ?? p[0];
|
|
21
|
+
d(n(m, r(m))), l.info("Reverting hooks.server.ts");
|
|
22
|
+
let h = s.join(c.root, "src", "hooks.server.ts");
|
|
23
|
+
return d(n(h, a(h))), {
|
|
24
|
+
creates: [],
|
|
25
|
+
modifies: u,
|
|
26
|
+
deletes: [],
|
|
27
|
+
components: [],
|
|
28
|
+
packages: [],
|
|
29
|
+
collections: [],
|
|
30
|
+
collectionPatches: [],
|
|
31
|
+
collectionDrops: await t(["oauth_accounts"], c)
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
//#endregion
|
|
35
|
+
export { c as generate };
|
|
36
|
+
|
|
37
|
+
//# sourceMappingURL=generate.runtime-Bag8x62P.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.runtime-Bag8x62P.js","names":[],"sources":["../../src/patterns/disable/auth/generate.runtime.ts"],"sourcesContent":["import path from \"node:path\";\nimport fs from \"node:fs\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { unmodifyLayoutServer } from \"./modifies/+layout.server\";\nimport { unmodifyRootLayoutSvelte } from \"./modifies/root-layout.svelte\";\nimport { unmodifyHooksServer } from \"./modifies/hooks.server\";\nimport { planDropsForCollections } from \"../../destroy/shared\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Reverting +layout.server.ts\");\n const layoutServerFile = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.server.ts\",\n );\n pushResult(\n modifyOutcomeToFile(\n layoutServerFile,\n unmodifyLayoutServer(layoutServerFile),\n ),\n );\n\n logger.info(\"Reverting root layout\");\n const layoutCandidates = [\n path.join(options.root, \"src\", \"routes\", \"(public)\", \"root-layout.svelte\"),\n path.join(options.root, \"src\", \"routes\", \"root-layout.svelte\"),\n path.join(options.root, \"src\", \"routes\", \"(public)\", \"+layout.svelte\"),\n path.join(options.root, \"src\", \"routes\", \"+layout.svelte\"),\n ];\n const layoutFile =\n layoutCandidates.find((p) => fs.existsSync(p)) ?? layoutCandidates[0];\n pushResult(\n modifyOutcomeToFile(layoutFile, unmodifyRootLayoutSvelte(layoutFile)),\n );\n\n logger.info(\"Reverting hooks.server.ts\");\n const hooksServerFile = path.join(options.root, \"src\", \"hooks.server.ts\");\n pushResult(\n modifyOutcomeToFile(hooksServerFile, unmodifyHooksServer(hooksServerFile)),\n );\n\n const collectionDrops = await planDropsForCollections(\n [\"oauth_accounts\"],\n options,\n );\n\n return {\n creates: [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops,\n } satisfies Result;\n}\n"],"mappings":";;;;;;;AAUA,eAAsB,EAAS,GAAkB;CAC/C,IAAM,IAAS,EAAU,EAAQ,EAC3B,IAAmB,EAAE,EACrB,KAAc,MAAsB;AACxC,EAAI,KAAM,EAAS,KAAK,EAAK;;AAG/B,GAAO,KAAK,8BAA8B;CAC1C,IAAM,IAAmB,EAAK,KAC5B,EAAQ,MACR,OACA,UACA,oBACD;AAQD,CAPA,EACE,EACE,GACA,EAAqB,EAAiB,CACvC,CACF,EAED,EAAO,KAAK,wBAAwB;CACpC,IAAM,IAAmB;EACvB,EAAK,KAAK,EAAQ,MAAM,OAAO,UAAU,YAAY,qBAAqB;EAC1E,EAAK,KAAK,EAAQ,MAAM,OAAO,UAAU,qBAAqB;EAC9D,EAAK,KAAK,EAAQ,MAAM,OAAO,UAAU,YAAY,iBAAiB;EACtE,EAAK,KAAK,EAAQ,MAAM,OAAO,UAAU,iBAAiB;EAC3D,EACK,IACJ,EAAiB,MAAM,MAAM,EAAG,WAAW,EAAE,CAAC,IAAI,EAAiB;AAKrE,CAJA,EACE,EAAoB,GAAY,EAAyB,EAAW,CAAC,CACtE,EAED,EAAO,KAAK,4BAA4B;CACxC,IAAM,IAAkB,EAAK,KAAK,EAAQ,MAAM,OAAO,kBAAkB;AAUzE,QATA,EACE,EAAoB,GAAiB,EAAoB,EAAgB,CAAC,CAC3E,EAOM;EACL,SAAS,EAAE;EACX;EACA,SAAS,EAAE;EACX,YAAY,EAAE;EACd,UAAU,EAAE;EACZ,aAAa,EAAE;EACf,mBAAmB,EAAE;EACrB,iBAbsB,MAAM,EAC5B,CAAC,iBAAiB,EAClB,EACD;EAWA"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { n as e } from "./logger-BpgCb-ZG.js";
|
|
2
|
+
import { t } from "./shared-D9iYuKxV.js";
|
|
3
|
+
import { modifyOutcomeToFile as n } from "./modify-file-Bi-4GRwL.js";
|
|
4
|
+
import { i as r, o as i } from "./ts-morph-helpers-B0oxeDUU.js";
|
|
5
|
+
import a from "node:fs";
|
|
6
|
+
import o from "node:path";
|
|
7
|
+
//#region src/patterns/disable/teams/modifies/modify-nav-user.ts
|
|
8
|
+
function s(e) {
|
|
9
|
+
if (!a.existsSync(e)) return {
|
|
10
|
+
status: "success",
|
|
11
|
+
changed: !1
|
|
12
|
+
};
|
|
13
|
+
let t = a.readFileSync(e, "utf8");
|
|
14
|
+
if (!t.includes("/teams")) return {
|
|
15
|
+
status: "success",
|
|
16
|
+
changed: !1
|
|
17
|
+
};
|
|
18
|
+
let n = new i(t), o = !1, s = (e) => {
|
|
19
|
+
o || e((e) => {
|
|
20
|
+
let t = r(e, "Teams", "@lucide/svelte/icons/users");
|
|
21
|
+
return t.wasRemoved && (o = !0), t.source;
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
return s((e) => n.modifyModuleScript(e)), o || s((e) => n.modifyScript(e)), o ? (a.writeFileSync(e, n.toString(), "utf8"), {
|
|
25
|
+
status: "success",
|
|
26
|
+
changed: !0
|
|
27
|
+
}) : {
|
|
28
|
+
status: "success",
|
|
29
|
+
changed: !1
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
//#region src/patterns/disable/teams/generate.runtime.ts
|
|
34
|
+
var c = ["app-sidebar, +layout.server.ts (teams loader), and app-layout.svelte (AppSidebar team props) must be reverted manually.", "These edits are substantial and are not safely reversed by tooling."].join(" ");
|
|
35
|
+
async function l(r) {
|
|
36
|
+
let i = e(r), l = [], u = (e) => {
|
|
37
|
+
e && l.push(e);
|
|
38
|
+
};
|
|
39
|
+
i.info("Reverting nav-user.svelte");
|
|
40
|
+
let d = [o.join(r.root, "src", "lib", "components", "nav-user.svelte")], f = d.find((e) => a.existsSync(e)) ?? d[0];
|
|
41
|
+
return u(n(f, s(f))), i.info(c), {
|
|
42
|
+
creates: [],
|
|
43
|
+
modifies: l,
|
|
44
|
+
deletes: [],
|
|
45
|
+
components: [],
|
|
46
|
+
packages: [],
|
|
47
|
+
collections: [],
|
|
48
|
+
collectionPatches: [],
|
|
49
|
+
collectionDrops: await t([
|
|
50
|
+
"team_invite_links",
|
|
51
|
+
"team_invites",
|
|
52
|
+
"team_memberships",
|
|
53
|
+
"teams"
|
|
54
|
+
], r)
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
//#endregion
|
|
58
|
+
export { l as generate };
|
|
59
|
+
|
|
60
|
+
//# sourceMappingURL=generate.runtime-Bu5bO86n.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.runtime-Bu5bO86n.js","names":[],"sources":["../../src/patterns/disable/teams/modifies/modify-nav-user.ts","../../src/patterns/disable/teams/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport { removeNavItemFromScript } from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nexport function unmodifyNavUser(navUserPath: string): ModifyOutcome {\n if (!fs.existsSync(navUserPath)) {\n return { status: \"success\", changed: false };\n }\n\n const source = fs.readFileSync(navUserPath, \"utf8\");\n if (!source.includes(\"/teams\")) {\n return { status: \"success\", changed: false };\n }\n\n const file = new SvelteFile(source);\n let wasRemoved = false;\n\n const tryRemove = (run: (fn: (s: string) => string) => boolean) => {\n if (wasRemoved) return;\n run((src) => {\n const result = removeNavItemFromScript(\n src,\n \"Teams\",\n \"@lucide/svelte/icons/users\",\n );\n if (result.wasRemoved) wasRemoved = true;\n return result.source;\n });\n };\n\n tryRemove((fn) => file.modifyModuleScript(fn));\n if (!wasRemoved) tryRemove((fn) => file.modifyScript(fn));\n\n if (!wasRemoved) {\n return { status: \"success\", changed: false };\n }\n\n fs.writeFileSync(navUserPath, file.toString(), \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import path from \"node:path\";\nimport fs from \"node:fs\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { unmodifyNavUser } from \"./modifies/modify-nav-user\";\nimport { planDropsForCollections } from \"../../destroy/shared\";\n\nconst MANUAL_REMEDIATION = [\n \"app-sidebar, +layout.server.ts (teams loader), and app-layout.svelte (AppSidebar team props) must be reverted manually.\",\n \"These edits are substantial and are not safely reversed by tooling.\",\n].join(\" \");\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Reverting nav-user.svelte\");\n const navUserCandidates = [\n path.join(options.root, \"src\", \"lib\", \"components\", \"nav-user.svelte\"),\n ];\n const navUserPath =\n navUserCandidates.find((p) => fs.existsSync(p)) ?? navUserCandidates[0];\n pushResult(modifyOutcomeToFile(navUserPath, unmodifyNavUser(navUserPath)));\n\n logger.info(MANUAL_REMEDIATION);\n\n const collectionDrops = await planDropsForCollections(\n [\"team_invite_links\", \"team_invites\", \"team_memberships\", \"teams\"],\n options,\n );\n\n return {\n creates: [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops,\n } satisfies Result;\n}\n"],"mappings":";;;;;;;AAKA,SAAgB,EAAgB,GAAoC;AAClE,KAAI,CAAC,EAAG,WAAW,EAAY,CAC7B,QAAO;EAAE,QAAQ;EAAW,SAAS;EAAO;CAG9C,IAAM,IAAS,EAAG,aAAa,GAAa,OAAO;AACnD,KAAI,CAAC,EAAO,SAAS,SAAS,CAC5B,QAAO;EAAE,QAAQ;EAAW,SAAS;EAAO;CAG9C,IAAM,IAAO,IAAI,EAAW,EAAO,EAC/B,IAAa,IAEX,KAAa,MAAgD;AAC7D,OACJ,GAAK,MAAQ;GACX,IAAM,IAAS,EACb,GACA,SACA,6BACD;AAED,UADI,EAAO,eAAY,IAAa,KAC7B,EAAO;IACd;;AAWJ,QARA,GAAW,MAAO,EAAK,mBAAmB,EAAG,CAAC,EACzC,KAAY,GAAW,MAAO,EAAK,aAAa,EAAG,CAAC,EAEpD,KAIL,EAAG,cAAc,GAAa,EAAK,UAAU,EAAE,OAAO,EAC/C;EAAE,QAAQ;EAAW,SAAS;EAAM,IAJlC;EAAE,QAAQ;EAAW,SAAS;EAAO;;;;AC3BhD,IAAM,IAAqB,CACzB,2HACA,sEACD,CAAC,KAAK,IAAI;AAEX,eAAsB,EAAS,GAAkB;CAC/C,IAAM,IAAS,EAAU,EAAQ,EAC3B,IAAmB,EAAE,EACrB,KAAc,MAAsB;AACxC,EAAI,KAAM,EAAS,KAAK,EAAK;;AAG/B,GAAO,KAAK,4BAA4B;CACxC,IAAM,IAAoB,CACxB,EAAK,KAAK,EAAQ,MAAM,OAAO,OAAO,cAAc,kBAAkB,CACvE,EACK,IACJ,EAAkB,MAAM,MAAM,EAAG,WAAW,EAAE,CAAC,IAAI,EAAkB;AAUvE,QATA,EAAW,EAAoB,GAAa,EAAgB,EAAY,CAAC,CAAC,EAE1E,EAAO,KAAK,EAAmB,EAOxB;EACL,SAAS,EAAE;EACX;EACA,SAAS,EAAE;EACX,YAAY,EAAE;EACd,UAAU,EAAE;EACZ,aAAa,EAAE;EACf,mBAAmB,EAAE;EACrB,iBAbsB,MAAM,EAC5B;GAAC;GAAqB;GAAgB;GAAoB;GAAQ,EAClE,EACD;EAWA"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { t as e } from "./dedent-C4qKBQXh.js";
|
|
2
2
|
import { n as t } from "./logger-BpgCb-ZG.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
3
|
+
import { modifyOutcomeToFile as n } from "./modify-file-Bi-4GRwL.js";
|
|
4
|
+
import { a as r, n as i, o as a } from "./ts-morph-helpers-B0oxeDUU.js";
|
|
5
|
+
import { getMigrationFile as o, migrationDelay as s, withPocketbase as c } from "./pocketbase-CT78tKFG.js";
|
|
6
6
|
import l from "node:fs";
|
|
7
7
|
import u from "node:path";
|
|
8
8
|
import { Project as d, SyntaxKind as f } from "ts-morph";
|
|
@@ -143,13 +143,13 @@ function v(e) {
|
|
|
143
143
|
status: "not-found",
|
|
144
144
|
message: _
|
|
145
145
|
};
|
|
146
|
-
let t =
|
|
146
|
+
let t = a.fromPath(e);
|
|
147
147
|
return t.hasElement("Navbar.List") ? t.hasElement("AuthMenu.Root") ? {
|
|
148
148
|
status: "success",
|
|
149
149
|
changed: !1
|
|
150
150
|
} : (t.modifyScript((e) => {
|
|
151
|
-
let { source: t } =
|
|
152
|
-
|
|
151
|
+
let { source: t } = r(e, (e) => {
|
|
152
|
+
i(e, [{
|
|
153
153
|
namespaceImport: "AuthMenu",
|
|
154
154
|
moduleSpecifier: "$lib/components/ui/auth-menu"
|
|
155
155
|
}, {
|
|
@@ -236,27 +236,27 @@ function x(e) {
|
|
|
236
236
|
//#endregion
|
|
237
237
|
//#region src/patterns/enable/auth/generate.runtime.ts
|
|
238
238
|
async function S(e) {
|
|
239
|
-
let { input:
|
|
240
|
-
await
|
|
241
|
-
|
|
242
|
-
senderName:
|
|
243
|
-
senderAddress:
|
|
244
|
-
} }), await
|
|
245
|
-
let
|
|
246
|
-
if (!
|
|
247
|
-
let
|
|
248
|
-
|
|
239
|
+
let { input: r } = e, i = t(e), a = [];
|
|
240
|
+
await c(e.root, async (t) => {
|
|
241
|
+
i.info("Updating PocketBase mail settings"), await t.settings.update({ meta: {
|
|
242
|
+
senderName: r.senderName,
|
|
243
|
+
senderAddress: r.senderAddress
|
|
244
|
+
} }), await s();
|
|
245
|
+
let n = await t.collections.getOne("users");
|
|
246
|
+
if (!n) throw Error("Users collection not found");
|
|
247
|
+
let c = n.verificationTemplate.body.replace("{APP_URL}/_/#/auth/confirm-verification/{TOKEN}", "{APP_URL}/confirm-verification/{TOKEN}"), u = n.resetPasswordTemplate.body.replace("{APP_URL}/_/#/auth/confirm-reset/{TOKEN}", "{APP_URL}/confirm-reset/{TOKEN}"), d = n.confirmEmailChangeTemplate.body.replace("{APP_URL}/_/#/auth/confirm-email-change/{TOKEN}", "{APP_URL}/confirm-email-change/{TOKEN}");
|
|
248
|
+
i.info("Locking down users collection rules and email templates"), await t.collections.update("users", {
|
|
249
249
|
listRule: "@request.auth.id = id",
|
|
250
250
|
viewRule: "@request.auth.id = id",
|
|
251
251
|
createRule: "@request.auth.id = id",
|
|
252
252
|
updateRule: "@request.auth.id = id",
|
|
253
253
|
deleteRule: "@request.auth.id = id",
|
|
254
|
-
verificationTemplate: { body:
|
|
254
|
+
verificationTemplate: { body: c },
|
|
255
255
|
resetPasswordTemplate: { body: u },
|
|
256
256
|
confirmEmailChangeTemplate: { body: d }
|
|
257
|
-
}), await
|
|
258
|
-
let f =
|
|
259
|
-
f &&
|
|
257
|
+
}), await s();
|
|
258
|
+
let f = o("users", "updated", e);
|
|
259
|
+
f && a.push({
|
|
260
260
|
path: f,
|
|
261
261
|
language: "ts",
|
|
262
262
|
content: l.readFileSync(f, "utf8"),
|
|
@@ -266,28 +266,29 @@ async function S(e) {
|
|
|
266
266
|
let d = [], f = (e) => {
|
|
267
267
|
e && d.push(e);
|
|
268
268
|
};
|
|
269
|
-
|
|
269
|
+
i.info("Modifying +layout.server.ts");
|
|
270
270
|
let m = u.join(e.root, "src", "routes", "+layout.server.ts");
|
|
271
|
-
f(
|
|
271
|
+
f(n(m, p(m))), i.info("Modifying root layout");
|
|
272
272
|
let h = [
|
|
273
273
|
u.join(e.root, "src", "routes", "(public)", "root-layout.svelte"),
|
|
274
274
|
u.join(e.root, "src", "routes", "root-layout.svelte"),
|
|
275
275
|
u.join(e.root, "src", "routes", "(public)", "+layout.svelte"),
|
|
276
276
|
u.join(e.root, "src", "routes", "+layout.svelte")
|
|
277
277
|
], g = h.find((e) => l.existsSync(e)) ?? h[0];
|
|
278
|
-
f(
|
|
278
|
+
f(n(g, v(g))), i.info("Modifying hooks.server.ts");
|
|
279
279
|
let _ = u.join(e.root, "src", "hooks.server.ts");
|
|
280
|
-
return f(
|
|
280
|
+
return f(n(_, x(_))), {
|
|
281
281
|
creates: [],
|
|
282
282
|
modifies: d,
|
|
283
283
|
deletes: [],
|
|
284
284
|
components: [],
|
|
285
285
|
packages: [],
|
|
286
286
|
collections: [],
|
|
287
|
-
collectionPatches: []
|
|
287
|
+
collectionPatches: [],
|
|
288
|
+
collectionDrops: []
|
|
288
289
|
};
|
|
289
290
|
}
|
|
290
291
|
//#endregion
|
|
291
292
|
export { S as generate };
|
|
292
293
|
|
|
293
|
-
//# sourceMappingURL=generate.runtime-
|
|
294
|
+
//# sourceMappingURL=generate.runtime-CKouBODu.js.map
|