create-payload-stack 0.5.0 → 0.5.1
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/index.js +56 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -86,7 +86,7 @@ async function removeVariants(directory) {
|
|
|
86
86
|
|
|
87
87
|
// src/scheduler.ts
|
|
88
88
|
var SCHEDULER_PACKAGE = "@payload-solutions/plugin-action-scheduler";
|
|
89
|
-
var SCHEDULER_VERSION = "0.
|
|
89
|
+
var SCHEDULER_VERSION = "0.3.0";
|
|
90
90
|
var VARIANT_SCHEDULER = variantPath("scheduler-plugin");
|
|
91
91
|
var SEAM_FILES = ["plugin.ts", "jobs.ts", "hooks.ts"];
|
|
92
92
|
var ACTION_DIR = "actions";
|
|
@@ -466,7 +466,7 @@ import { existsSync as existsSync2 } from "fs";
|
|
|
466
466
|
import path3 from "path";
|
|
467
467
|
var CONSENT_PACKAGE = "@payload-solutions/plugin-consent";
|
|
468
468
|
var CONSENT_REACT_PACKAGE = "@payload-solutions/consent-react";
|
|
469
|
-
var CONSENT_VERSION = "0.1.
|
|
469
|
+
var CONSENT_VERSION = "0.1.1";
|
|
470
470
|
var CONSENT_PACKAGES = {
|
|
471
471
|
[CONSENT_PACKAGE]: CONSENT_VERSION,
|
|
472
472
|
[CONSENT_REACT_PACKAGE]: CONSENT_VERSION
|
|
@@ -518,7 +518,7 @@ import { cp as cp3, rm as rm3 } from "fs/promises";
|
|
|
518
518
|
import { existsSync as existsSync3 } from "fs";
|
|
519
519
|
import path4 from "path";
|
|
520
520
|
var EMAILS_PACKAGE = "@payload-solutions/plugin-emails";
|
|
521
|
-
var EMAILS_VERSION = "0.1.
|
|
521
|
+
var EMAILS_VERSION = "0.1.1";
|
|
522
522
|
var REACT_EMAIL_COMPONENTS = ["@react-email/components", "^1.0.12"];
|
|
523
523
|
var REACT_EMAIL_ONLY_PACKAGES = {
|
|
524
524
|
"@react-email/render": "^2.1.0",
|
|
@@ -650,6 +650,8 @@ function runCommand(pm, script) {
|
|
|
650
650
|
// src/configure.ts
|
|
651
651
|
function renderStackConfig(o) {
|
|
652
652
|
const list = (items) => `[${items.map((i) => `'${i}'`).join(", ")}]`;
|
|
653
|
+
const parts = ["Authentication", ...o.organizations ? ["organizations"] : [], ...o.billing === "none" ? [] : ["subscriptions"], "an admin panel"];
|
|
654
|
+
const description = `${parts.slice(0, -1).join(", ")} and ${parts.at(-1)}, wired together on Payload CMS and Next.js.`;
|
|
653
655
|
const billingBlock = o.billing === "none" ? ` billing: { provider: 'none' },` : ` billing: {
|
|
654
656
|
provider: 'stripe',
|
|
655
657
|
attachedTo: '${o.billing}', // or '${o.billing === "organization" ? "user" : "organization"}'
|
|
@@ -708,7 +710,7 @@ export default defineStack({
|
|
|
708
710
|
name: '${o.name.replace(/'/g, "\\'")}',
|
|
709
711
|
tagline: 'A new SaaS, built on Payload CMS.',
|
|
710
712
|
description:
|
|
711
|
-
'
|
|
713
|
+
'${description}',
|
|
712
714
|
url: process.env.NEXT_PUBLIC_APP_URL ?? 'http://localhost:3000',
|
|
713
715
|
support: { email: 'support@example.com' },
|
|
714
716
|
|
|
@@ -856,6 +858,24 @@ function renderEnv(example, o) {
|
|
|
856
858
|
function sortKeys4(obj) {
|
|
857
859
|
return Object.fromEntries(Object.entries(obj).sort(([a], [b]) => a.localeCompare(b)));
|
|
858
860
|
}
|
|
861
|
+
function renderTestEnv(source, db, projectSlug) {
|
|
862
|
+
const urls = {
|
|
863
|
+
sqlite: {
|
|
864
|
+
int: "file:./test.db",
|
|
865
|
+
e2e: "file:./e2e.db",
|
|
866
|
+
note: "# SQLite: two local files, created on first run. Delete them to start the suites from empty."
|
|
867
|
+
},
|
|
868
|
+
mongodb: {
|
|
869
|
+
int: `mongodb://127.0.0.1/${projectSlug}-test`,
|
|
870
|
+
e2e: `mongodb://127.0.0.1/${projectSlug}-e2e`,
|
|
871
|
+
note: "# MongoDB: two databases on a local server (mongodb://127.0.0.1:27017). docker-compose.yml does not start one."
|
|
872
|
+
}
|
|
873
|
+
};
|
|
874
|
+
const target = urls[db.key];
|
|
875
|
+
if (!target) return source;
|
|
876
|
+
return source.replace(/^DATABASE_URL=.*$/m, `${target.note}
|
|
877
|
+
DATABASE_URL=${target.int}`).replace(/^E2E_DATABASE_URL=.*$/m, `E2E_DATABASE_URL=${target.e2e}`);
|
|
878
|
+
}
|
|
859
879
|
function escapeRegExp(s) {
|
|
860
880
|
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
861
881
|
}
|
|
@@ -887,6 +907,18 @@ async function configureProject(o) {
|
|
|
887
907
|
"package.json",
|
|
888
908
|
JSON.stringify(renameProject(stripWorkspaceDependencies(configured), o.slug), null, 2) + "\n"
|
|
889
909
|
);
|
|
910
|
+
await write("test.env", renderTestEnv(await read("test.env"), db, o.slug));
|
|
911
|
+
if (db.key === "sqlite") {
|
|
912
|
+
const ignore = await read(".gitignore");
|
|
913
|
+
if (!/^\*\.db$/m.test(ignore)) await write(".gitignore", `${ignore.trimEnd()}
|
|
914
|
+
|
|
915
|
+
# SQLite databases
|
|
916
|
+
*.db
|
|
917
|
+
*.db-journal
|
|
918
|
+
*.db-wal
|
|
919
|
+
*.db-shm
|
|
920
|
+
`);
|
|
921
|
+
}
|
|
890
922
|
const runner = RUNNER_CHOICES[o.runner];
|
|
891
923
|
const example = await read(".env.example");
|
|
892
924
|
await write(
|
|
@@ -1161,6 +1193,7 @@ async function run(flags, positionalName) {
|
|
|
1161
1193
|
env: { ...process.env, CI: "true" }
|
|
1162
1194
|
});
|
|
1163
1195
|
s2.stop(`Installed dependencies with ${packageManager}`);
|
|
1196
|
+
await generateArtifacts(directory, packageManager, slug);
|
|
1164
1197
|
} catch (error) {
|
|
1165
1198
|
s2.stop("Dependency installation failed");
|
|
1166
1199
|
p.log.warn(`Run ${pc2.cyan(installCommand(packageManager))} inside ./${slug} to retry.
|
|
@@ -1195,6 +1228,25 @@ ${error instanceof Error ? error.message.split("\n")[0] : ""}`);
|
|
|
1195
1228
|
p.note(steps.join("\n"), "Done. Next steps:");
|
|
1196
1229
|
p.outro(`Docs: ${pc2.underline(DOCS2)}`);
|
|
1197
1230
|
}
|
|
1231
|
+
async function generateArtifacts(directory, packageManager, slug) {
|
|
1232
|
+
const s = p.spinner();
|
|
1233
|
+
s.start("Generating the admin import map and Payload types");
|
|
1234
|
+
const failed = [];
|
|
1235
|
+
for (const script of ["generate:importmap", "generate:types"]) {
|
|
1236
|
+
const [bin, ...args] = runCommand(packageManager, script).split(" ");
|
|
1237
|
+
try {
|
|
1238
|
+
await execa2(bin, args, { cwd: directory, env: { ...process.env, CI: "true" } });
|
|
1239
|
+
} catch {
|
|
1240
|
+
failed.push(runCommand(packageManager, script));
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
if (failed.length === 0) {
|
|
1244
|
+
s.stop("Generated the admin import map and Payload types");
|
|
1245
|
+
return;
|
|
1246
|
+
}
|
|
1247
|
+
s.stop("Could not generate every file");
|
|
1248
|
+
p.log.warn(`Run ${failed.map((c) => pc2.cyan(c)).join(" and ")} inside ./${slug} before the first build.`);
|
|
1249
|
+
}
|
|
1198
1250
|
|
|
1199
1251
|
// src/index.ts
|
|
1200
1252
|
var require2 = createRequire(import.meta.url);
|
package/package.json
CHANGED