@velastack/patterns 0.4.2 → 0.4.3
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/{generate.runtime-Dp7SsCQG.js → generate.runtime-Bcrht4M9.js} +2 -2
- package/dist/chunks/{generate.runtime-Dp7SsCQG.js.map → generate.runtime-Bcrht4M9.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DG2z6kqH.js → generate.runtime-DJHUBL4Z.js} +2 -2
- package/dist/chunks/{generate.runtime-DG2z6kqH.js.map → generate.runtime-DJHUBL4Z.js.map} +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -6,7 +6,7 @@ import { swapAuthPages as s } from "./auth-pages-B52ei-4z.js";
|
|
|
6
6
|
import c from "node:fs";
|
|
7
7
|
import l from "node:path";
|
|
8
8
|
//#region src/patterns/disable/whatsapp/generate.runtime.ts
|
|
9
|
-
var u = "https://
|
|
9
|
+
var u = "https://velastack.dev/docs/disable/whatsapp";
|
|
10
10
|
async function d(d) {
|
|
11
11
|
let f = e(d), p = [];
|
|
12
12
|
await n(d.root, async (e) => {
|
|
@@ -39,4 +39,4 @@ async function d(d) {
|
|
|
39
39
|
//#endregion
|
|
40
40
|
export { d as generate };
|
|
41
41
|
|
|
42
|
-
//# sourceMappingURL=generate.runtime-
|
|
42
|
+
//# sourceMappingURL=generate.runtime-Bcrht4M9.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.runtime-
|
|
1
|
+
{"version":3,"file":"generate.runtime-Bcrht4M9.js","names":["getLogger","withPocketbase","migrationDelay","disableWhatsAppAuth","fs","path","DOCS_URL","generate","logger","options","creates","hasWhatsAppPlugin","pb","file","writeWhatsAppConfigMigration","modifies","outcomes","swapAuthPages","filePath","outcome","modifyOutcomeToFile"],"sources":["../../src/patterns/disable/whatsapp/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { migrationDelay, withPocketbase } from \"../../../runtime/pocketbase\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport {\n disableWhatsAppAuth,\n hasWhatsAppPlugin,\n writeWhatsAppConfigMigration,\n} from \"../../enable/whatsapp/runtime/whatsapp\";\nimport { swapAuthPages } from \"../../enable/whatsapp/modifies/auth-pages\";\n\nconst DOCS_URL = \"https://velastack.dev/docs/disable/whatsapp\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const creates: File[] = [];\n\n await withPocketbase(options.root, async (pb) => {\n // Without the plugin there is no WhatsApp sign-in to turn off.\n if (!(await hasWhatsAppPlugin(pb))) return;\n\n logger.info(\"Turning off WhatsApp sign-in for users\");\n await disableWhatsAppAuth(pb);\n await migrationDelay();\n const file = writeWhatsAppConfigMigration(options, false);\n if (!file) return;\n creates.push({\n path: file,\n language: \"js\",\n content: fs.readFileSync(file, \"utf8\"),\n status: \"success\",\n });\n });\n logger.info(\n \"Keeping the phone fields on users, and email optional: they hold your users' data\",\n );\n\n logger.info(\"Taking WhatsApp off the login and signup pages\");\n const modifies: File[] = [];\n const outcomes = await swapAuthPages(\n options.root,\n \"disable\",\n (filePath) =>\n `${path.relative(options.root, filePath)} is not the page enable-whatsapp wrote, so it was left as it is. Take the WhatsApp option out of it by hand: ${DOCS_URL}`,\n );\n for (const [filePath, outcome] of outcomes) {\n const file = modifyOutcomeToFile(filePath, outcome);\n if (file) modifies.push(file);\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":";;;;;;;;AAaA,IAAMM,IAAW;AAEjB,eAAsBC,EAAS,GAAkB;CAC/C,IAAMC,IAASR,EAAUS,CAAO,GAC1BC,IAAkB,CAAC;CAsBzB,AApBA,MAAMT,EAAeQ,EAAQ,MAAM,OAAO,MAAO;EAE/C,IAAI,CAAE,MAAME,EAAkBC,CAAE,GAAI;EAIpC,AAFAJ,EAAO,KAAK,wCAAwC,GACpD,MAAML,EAAoBS,CAAE,GAC5B,MAAMV,EAAe;EACrB,IAAMW,IAAOC,EAA6BL,GAAS,EAAK;EACxD,AAAKI,KACLH,EAAQ,KAAK;GACX,MAAMG;GACN,UAAU;GACV,SAAST,EAAG,aAAaS,GAAM,MAAM;GACrC,QAAQ;EACV,CAAC;CACH,CAAC,GACDL,EAAO,KACL,mFACF,GAEAA,EAAO,KAAK,gDAAgD;CAC5D,IAAMO,IAAmB,CAAC,GACpBC,IAAW,MAAMC,EACrBR,EAAQ,MACR,YACC,MACC,GAAGJ,EAAK,SAASI,EAAQ,MAAMS,CAAQ,EAAE,+GAA+GZ,GAC5J;CACA,KAAK,IAAM,CAACY,GAAUC,MAAYH,GAAU;EAC1C,IAAMH,IAAOO,EAAoBF,GAAUC,CAAO;EAClD,AAAIN,KAAME,EAAS,KAAKF,CAAI;CAC9B;CAEA,OAAO;EACL;EACA;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
|
|
@@ -22,7 +22,7 @@ function p(e) {
|
|
|
22
22
|
}
|
|
23
23
|
//#endregion
|
|
24
24
|
//#region src/patterns/enable/whatsapp/generate.runtime.ts
|
|
25
|
-
var m = "https://
|
|
25
|
+
var m = "https://velastack.dev/docs/enable/whatsapp";
|
|
26
26
|
function h(e) {
|
|
27
27
|
return {
|
|
28
28
|
path: e,
|
|
@@ -65,4 +65,4 @@ async function g(d) {
|
|
|
65
65
|
//#endregion
|
|
66
66
|
export { g as generate };
|
|
67
67
|
|
|
68
|
-
//# sourceMappingURL=generate.runtime-
|
|
68
|
+
//# sourceMappingURL=generate.runtime-DJHUBL4Z.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.runtime-
|
|
1
|
+
{"version":3,"file":"generate.runtime-DJHUBL4Z.js","names":["getLogger","withPocketbase","migrationDelay","getMigrationFile","hasWhatsAppPlugin","writeWhatsAppConfigMigration","enableWhatsAppAuth","MIN_POCKETBASE_SERVER","fs","path","modifyTestSetup","setupPath","original","content","indent","head","tail","bodyIndent","value","fieldIndent","DOCS_URL","migrationCreate","file","generate","logger","options","creates","pb","setupWhatsAppFields","configMigration","modifies","outcomes","swapAuthPages","filePath","outcome","modifyOutcomeToFile","testSetup","testSetupFile"],"sources":["../../src/patterns/enable/whatsapp/modifies/modify-test-setup.ts","../../src/patterns/enable/whatsapp/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\n/**\n * `email` turns optional on `users`, which the generated types follow, so a\n * test setup from before enable-backend handled that no longer type-checks:\n * its `authenticateUser` takes `{ email: string }` and it signs the test\n * user in with `context.user.email`. Brings those two spots up to the\n * current setup; anything else in the file is the project's own.\n */\nexport function modifyTestSetup(setupPath: string): ModifyOutcome {\n if (!fs.existsSync(setupPath)) {\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(setupPath, \"utf8\");\n let content = original;\n\n content = content.replace(\n /^([ \\t]*)(async function authenticateUser\\(agent: Agent, user: \\{ )email: string( \\}\\) \\{\\n)([ \\t]*)/m,\n (_, indent, head, tail, bodyIndent) =>\n `${indent}${head}email?: string${tail}` +\n `${bodyIndent}// Logs in with the password, so it needs the email (made optional by\\n` +\n `${bodyIndent}// enable-whatsapp, for accounts that sign in with a phone number).\\n` +\n `${bodyIndent}if (!user.email) {\\n` +\n `${bodyIndent}${bodyIndent.includes(\"\\t\") ? \"\\t\" : \" \"}throw new Error('authenticateUser needs a user with an email');\\n` +\n `${bodyIndent}}\\n` +\n bodyIndent,\n );\n\n // The user is made with a known email: sign in with that.\n content = content.replace(\n /^([ \\t]*)context\\.user = await context\\.admin\\.collection\\('users'\\)\\.create\\(\\{\\n([ \\t]*)email: (`test-\\$\\{Math\\.random\\(\\)\\.toString\\(36\\)\\.slice\\(2\\)\\}@example\\.com`),/m,\n (_, indent, fieldIndent, value) =>\n `${indent}const email = ${value};\\n` +\n `${indent}context.user = await context.admin.collection('users').create({\\n` +\n `${fieldIndent}email,`,\n );\n if (content.includes(\"const email = `test-\")) {\n content = content.replace(\n \".authWithPassword(context.user.email, testUserPassword)\",\n \".authWithPassword(email, testUserPassword)\",\n );\n }\n\n if (content === original) {\n return { status: \"success\", changed: false };\n }\n fs.writeFileSync(setupPath, content, \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport {\n getMigrationFile,\n migrationDelay,\n withPocketbase,\n} from \"../../../runtime/pocketbase\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport {\n MIN_POCKETBASE_SERVER,\n enableWhatsAppAuth,\n hasWhatsAppPlugin,\n setupWhatsAppFields,\n writeWhatsAppConfigMigration,\n} from \"./runtime/whatsapp\";\nimport { swapAuthPages } from \"./modifies/auth-pages\";\nimport { modifyTestSetup } from \"./modifies/modify-test-setup\";\n\nexport const DOCS_URL = \"https://velastack.dev/docs/enable/whatsapp\";\n\nfunction migrationCreate(file: string): File {\n return {\n path: file,\n language: \"js\",\n content: fs.readFileSync(file, \"utf8\"),\n status: \"success\",\n };\n}\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const creates: File[] = [];\n\n await withPocketbase(options.root, async (pb) => {\n if (!(await hasWhatsAppPlugin(pb))) {\n throw new Error(\n `This PocketBase has no WhatsApp sign-in. It comes with pocketbase-server ${MIN_POCKETBASE_SERVER} and later: run \\`npm install -D pocketbase-server@^${MIN_POCKETBASE_SERVER}\\`, then \\`vela enable whatsapp\\` again.`,\n );\n }\n\n logger.info(\"Adding the phone fields to users and making email optional\");\n if (await setupWhatsAppFields(pb)) {\n await migrationDelay();\n const file = getMigrationFile(\"users\", \"updated\", options);\n if (file) creates.push(migrationCreate(file));\n }\n\n logger.info(\"Turning on WhatsApp sign-in for users\");\n await enableWhatsAppAuth(pb);\n await migrationDelay();\n const configMigration = writeWhatsAppConfigMigration(options, true);\n if (configMigration) creates.push(migrationCreate(configMigration));\n });\n\n logger.info(\"Adding WhatsApp to the login and signup pages\");\n const modifies: File[] = [];\n const outcomes = await swapAuthPages(\n options.root,\n \"enable\",\n (filePath) =>\n `${path.relative(options.root, filePath)} is not the page enable-auth wrote, so it was left as it is. Add the WhatsApp option to it by hand: ${DOCS_URL}`,\n );\n for (const [filePath, outcome] of outcomes) {\n const file = modifyOutcomeToFile(filePath, outcome);\n if (file) modifies.push(file);\n }\n\n logger.info(\"Updating test/setup.ts for an optional email\");\n const testSetup = path.join(options.root, \"test\", \"setup.ts\");\n const testSetupFile = modifyOutcomeToFile(\n testSetup,\n modifyTestSetup(testSetup),\n );\n if (testSetupFile) modifies.push(testSetupFile);\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,SAAgBU,EAAgB,GAAkC;CAChE,IAAI,CAACF,EAAG,WAAWG,CAAS,GAC1B,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAMC,IAAWJ,EAAG,aAAaG,GAAW,MAAM,GAC9CE,IAAUD;CAiCd,OA/BA,IAAUC,EAAQ,QAChB,0GACC,GAAG,GAAQ,GAAM,GAAM,MACtB,GAAGC,IAASC,EAAK,gBAAgBC,IAC9BC,EAAW,yEACXA,EAAW,uEACXA,EAAW,sBACXA,IAAaA,EAAW,SAAS,GAAI,IAAI,MAAO,KAAK,mEACrDA,EAAW,OACdA,CACJ,GAGA,IAAUJ,EAAQ,QAChB,gLACC,GAAG,GAAQ,GAAa,MACvB,GAAGC,EAAO,gBAAgBI,EAAM,KA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,GAAU;EAC1C,IAAMT,IAAOa,EAAoBF,GAAUC,CAAO;EAClD,AAAIZ,KAAMQ,EAAS,KAAKR,CAAI;CAC9B;CAEA,EAAO,KAAK,8CAA8C;CAC1D,IAAMc,IAAY3B,EAAK,KAAKgB,EAAQ,MAAM,QAAQ,UAAU,GACtDY,IAAgBF,EACpBC,GACA1B,EAAgB0B,CAAS,CAC3B;CAGA,OAFIC,KAAeP,EAAS,KAAKO,CAAa,GAEvC;EACL;EACA;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1828,6 +1828,7 @@ export declare interface Pattern {
|
|
|
1828
1828
|
source: string;
|
|
1829
1829
|
plan: "open" | "pro" | "agency";
|
|
1830
1830
|
title: string;
|
|
1831
|
+
/** The pattern's docs page as a path under velastack.dev/docs, e.g. `/enable/auth`. */
|
|
1831
1832
|
docs: string;
|
|
1832
1833
|
summary: string;
|
|
1833
1834
|
requires: Features;
|
package/dist/index.js
CHANGED
|
@@ -25,7 +25,7 @@ import { i as ur } from "./chunks/generate-CFqpRi9D.js";
|
|
|
25
25
|
import { r as dr } from "./chunks/generate-Bg0E3eWm.js";
|
|
26
26
|
var fr = {
|
|
27
27
|
name: "@velastack/patterns",
|
|
28
|
-
version: "0.4.
|
|
28
|
+
version: "0.4.3",
|
|
29
29
|
description: "Registry of VelaStack patterns: generators and modifications applied to SvelteKit projects by the VelaStack CLI.",
|
|
30
30
|
type: "module",
|
|
31
31
|
private: !1,
|
|
@@ -7008,7 +7008,7 @@ async function Im(e) {
|
|
|
7008
7008
|
let t = await km(e), n = await jm(e);
|
|
7009
7009
|
return T(S([t, n]), e);
|
|
7010
7010
|
}
|
|
7011
|
-
let { detectMode: t } = await import("./chunks/auth-pages-B52ei-4z.js"), { keepMissing: n } = await import("./chunks/modify-file-DK-tCH9k.js"), r = await km(e, t(e.root)), { generate: i } = await import("./chunks/generate.runtime-
|
|
7011
|
+
let { detectMode: t } = await import("./chunks/auth-pages-B52ei-4z.js"), { keepMissing: n } = await import("./chunks/modify-file-DK-tCH9k.js"), r = await km(e, t(e.root)), { generate: i } = await import("./chunks/generate.runtime-DJHUBL4Z.js"), o = await i(e), { writeResult: s } = await import("./chunks/write-result-DiZsCS_y.js").then((e) => e.l);
|
|
7012
7012
|
return s(await T(S([{
|
|
7013
7013
|
...r,
|
|
7014
7014
|
creates: n(r.creates, e.root)
|
|
@@ -8529,7 +8529,7 @@ var M_ = "disable-whatsapp", N_ = "1.0.0", P_ = "src/patterns/disable/whatsapp",
|
|
|
8529
8529
|
async function I_(e) {
|
|
8530
8530
|
let t = await j_(e);
|
|
8531
8531
|
if (e.env !== "runtime" || e.input.destructive !== !0) return T(t, e);
|
|
8532
|
-
let { generate: n } = await import("./chunks/generate.runtime-
|
|
8532
|
+
let { generate: n } = await import("./chunks/generate.runtime-Bcrht4M9.js"), r = await n(e), { writeResult: i } = await import("./chunks/write-result-DiZsCS_y.js").then((e) => e.l);
|
|
8533
8533
|
return i(await T(S([t, r]), e), e);
|
|
8534
8534
|
}
|
|
8535
8535
|
var L_ = {
|