create-strata 2.2.14 → 2.2.16
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/cli.js +60 -5
- package/dist/templates/package.json +3 -3
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -2849,6 +2849,10 @@ function renderEnvExample(projectName, layers) {
|
|
|
2849
2849
|
`TENANCY_DRIVER=${layers.tenancy}`,
|
|
2850
2850
|
`CACHE_DRIVER=${layers.cache}`,
|
|
2851
2851
|
`QUEUE_DRIVER=${layers.queue}`,
|
|
2852
|
+
...layers.queue === "redis" ? [
|
|
2853
|
+
"# New apps use Streams. Do not point this at Redis that still holds list jobs.",
|
|
2854
|
+
"QUEUE_REDIS_TRANSPORT=streams"
|
|
2855
|
+
] : [],
|
|
2852
2856
|
`MAIL_DRIVER=${layers.mail}`,
|
|
2853
2857
|
`AUTH_DEV_HEADERS=${envFlag(layers.auth === "headers")}`
|
|
2854
2858
|
];
|
|
@@ -3127,9 +3131,9 @@ function renderPackageJson(projectName, options = {}) {
|
|
|
3127
3131
|
"@getstrata/cli": "workspace:*",
|
|
3128
3132
|
"@getstrata/core": "workspace:*"
|
|
3129
3133
|
} : {
|
|
3130
|
-
"@getstrata/bootstrap": "^2.2.
|
|
3131
|
-
"@getstrata/cli": "^2.2.
|
|
3132
|
-
"@getstrata/core": "^2.2.
|
|
3134
|
+
"@getstrata/bootstrap": "^2.2.16",
|
|
3135
|
+
"@getstrata/cli": "^2.2.16",
|
|
3136
|
+
"@getstrata/core": "^2.2.16"
|
|
3133
3137
|
};
|
|
3134
3138
|
coreDeps.eta = "^4.6.0";
|
|
3135
3139
|
if (options.layers?.database === "mysql") {
|
|
@@ -3142,6 +3146,7 @@ function renderPackageJson(projectName, options = {}) {
|
|
|
3142
3146
|
"db:seed:demo": "bun run src/db/seed.ts",
|
|
3143
3147
|
"db:fresh": "strata migrate:fresh",
|
|
3144
3148
|
"queue:work": "strata queue:work",
|
|
3149
|
+
"outbox:work": "strata outbox:work",
|
|
3145
3150
|
check: "tsc --noEmit"
|
|
3146
3151
|
};
|
|
3147
3152
|
if (options.layers && needsFrontendBuild(options.layers.frontend)) {
|
|
@@ -3408,7 +3413,7 @@ ${next.join(`
|
|
|
3408
3413
|
`)}
|
|
3409
3414
|
\`\`\`
|
|
3410
3415
|
|
|
3411
|
-
Open http://localhost:3000. Health check: \`GET /health\`. Redis worker: \`bun run queue:work\` (requires \`REDIS_URL\`).
|
|
3416
|
+
Open http://localhost:3000. Health check: \`GET /health\`. Redis worker: \`bun run queue:work\` (requires \`REDIS_URL\`). Durable events: \`bun run outbox:work\` after \`bun run db:migrate\`. Add listeners in \`src/outbox/registry.ts\` before publishing.
|
|
3412
3417
|
|
|
3413
3418
|
${renderSupportingToolsReadme(layers)}${layers.auth !== "headers" ? `
|
|
3414
3419
|
For the first production admin, apply migrations and run \`bunx strata auth:provision-admin --email operator@example.test --name "Initial Operator" --password-stdin${layers.tenancy !== "none" ? " --tenant 1" : ""} < /run/secrets/initial_admin_password\` before admitting traffic. Supply your own private secret-manager-mounted file, not a demo password. Passwords require at least 16 characters and at most 72 UTF-8 bytes. Tenant-enabled applications require an existing tenant ID; this command does not create tenants. It refuses existing admins/accounts, records a transactional one-time claim, and does not mark email verified or enroll MFA. Additional admins and recovery remain explicit application administration. The command does not migrate or seed automatically.
|
|
@@ -4351,7 +4356,8 @@ ${databaseDefaults}process.env.FRONTEND_MODE ??= ${JSON.stringify(layers.fronten
|
|
|
4351
4356
|
process.env.SPA_PREFIX ??= ${JSON.stringify(layers.spaPrefix)};
|
|
4352
4357
|
process.env.CACHE_DRIVER ??= ${JSON.stringify(layers.cache)};
|
|
4353
4358
|
process.env.QUEUE_DRIVER ??= ${JSON.stringify(layers.queue)};
|
|
4354
|
-
process.env.
|
|
4359
|
+
${layers.queue === "redis" ? `process.env.QUEUE_REDIS_TRANSPORT ??= "streams";
|
|
4360
|
+
` : ""}process.env.MAIL_DRIVER ??= ${JSON.stringify(layers.mail)};
|
|
4355
4361
|
process.env.TENANCY_DRIVER ??= ${JSON.stringify(layers.tenancy)};
|
|
4356
4362
|
configureModulesDirectory(join(import.meta.dir, "../modules"));
|
|
4357
4363
|
`;
|
|
@@ -4760,6 +4766,7 @@ const commands: StrataCommandMap = {${layers && authNeedsUsers(layers.auth) ? `
|
|
|
4760
4766
|
"make:factory": async () => (await import("@getstrata/cli/scaffold")).makeFactoryCommand,
|
|
4761
4767
|
"make:migration": async () => (await import("@getstrata/cli/scaffold")).makeMigrationCommand,
|
|
4762
4768
|
"queue:work": async () => (await import("./queueWork.ts")).queueWorkCommand,
|
|
4769
|
+
"outbox:work": async () => (await import("./outboxWork.ts")).outboxWorkCommand,
|
|
4763
4770
|
"queue:failed": async () => (await import("./queueFailed.ts")).queueFailedCommand,
|
|
4764
4771
|
"queue:retry": async () => (await import("./queueFailed.ts")).queueRetryCommand,
|
|
4765
4772
|
"queue:flush-failed": async () => (await import("./queueFailed.ts")).queueFlushFailedCommand,
|
|
@@ -4802,6 +4809,51 @@ function renderCliQueueWorkTs() {
|
|
|
4802
4809
|
export { queueWorkCommand };
|
|
4803
4810
|
`;
|
|
4804
4811
|
}
|
|
4812
|
+
function renderCliOutboxWorkTs() {
|
|
4813
|
+
return `async function outboxWorkCommand(): Promise<void> {
|
|
4814
|
+
const { runOutboxWorkerCommand } = await import("@getstrata/cli/outboxWorker");
|
|
4815
|
+
const { listeners } = await import("../outbox/registry.ts");
|
|
4816
|
+
const { bootstrapApp } = await import("../bootstrap/createApp.ts");
|
|
4817
|
+
const { closeDatabase } = await import("../bootstrap/database.ts");
|
|
4818
|
+
|
|
4819
|
+
let app: Awaited<ReturnType<typeof bootstrapApp>> | undefined;
|
|
4820
|
+
await runOutboxWorkerCommand({
|
|
4821
|
+
listeners,
|
|
4822
|
+
boot: async () => {
|
|
4823
|
+
app = await bootstrapApp({ migrate: false });
|
|
4824
|
+
},
|
|
4825
|
+
drain: () => app?.context.drain(),
|
|
4826
|
+
flush: () => app?.context.flush(),
|
|
4827
|
+
close: async () => {
|
|
4828
|
+
try {
|
|
4829
|
+
await app?.context.dispose();
|
|
4830
|
+
} finally {
|
|
4831
|
+
await closeDatabase();
|
|
4832
|
+
}
|
|
4833
|
+
},
|
|
4834
|
+
});
|
|
4835
|
+
}
|
|
4836
|
+
|
|
4837
|
+
export { outboxWorkCommand };
|
|
4838
|
+
`;
|
|
4839
|
+
}
|
|
4840
|
+
function renderOutboxRegistryTs() {
|
|
4841
|
+
return `import type { DurableListener } from "@getstrata/core/events/outbox";
|
|
4842
|
+
|
|
4843
|
+
/** Add listeners before publishing. An empty registry can run, and publish rejects unknown events. */
|
|
4844
|
+
const listeners: readonly DurableListener[] = [];
|
|
4845
|
+
|
|
4846
|
+
export { listeners };
|
|
4847
|
+
`;
|
|
4848
|
+
}
|
|
4849
|
+
function renderOutboxMigration(layers) {
|
|
4850
|
+
const driver = layers.database === "postgres" ? "pgsql" : layers.database;
|
|
4851
|
+
const rls = layers.tenancy === "rls" && layers.database === "postgres";
|
|
4852
|
+
return `import { createOutboxMigration } from "@getstrata/core/events/outbox";
|
|
4853
|
+
|
|
4854
|
+
export default createOutboxMigration("0005_outbox", "${driver}", { rls: ${rls} });
|
|
4855
|
+
`;
|
|
4856
|
+
}
|
|
4805
4857
|
function renderCliQueueFailedTs() {
|
|
4806
4858
|
return `async function bootApp(): Promise<void> {
|
|
4807
4859
|
const { bootstrapApp } = await import("../bootstrap/createApp.ts");
|
|
@@ -5611,6 +5663,8 @@ function writeGeneratedFiles(options) {
|
|
|
5611
5663
|
removeIfExists(join2(src, "db/migrations/0004_initial_admin_provisioning.ts"));
|
|
5612
5664
|
}
|
|
5613
5665
|
writeText(join2(src, "cli/queueWork.ts"), renderCliQueueWorkTs());
|
|
5666
|
+
writeText(join2(src, "cli/outboxWork.ts"), renderCliOutboxWorkTs());
|
|
5667
|
+
writeText(join2(src, "outbox/registry.ts"), renderOutboxRegistryTs());
|
|
5614
5668
|
writeText(join2(src, "cli/queueFailed.ts"), renderCliQueueFailedTs());
|
|
5615
5669
|
writeText(join2(src, "cli/openapi.ts"), renderCliOpenApiTs());
|
|
5616
5670
|
writeText(join2(src, "cli/scheduleRun.ts"), renderCliScheduleRunTs());
|
|
@@ -5636,6 +5690,7 @@ function writeGeneratedFiles(options) {
|
|
|
5636
5690
|
writeText(join2(src, "db/migrate.ts"), renderMigrateTs(layers));
|
|
5637
5691
|
writeText(join2(src, "db/migrationRuntime.ts"), renderMigrationRuntimeTs(layers));
|
|
5638
5692
|
writeText(join2(src, "db/migrations/0001_starter_schema.ts"), renderStarterSchemaMigration(layers));
|
|
5693
|
+
writeText(join2(src, "db/migrations/0005_outbox.ts"), renderOutboxMigration(layers));
|
|
5639
5694
|
removeIfExists(join2(src, "db/migrations/0002_webhooks_schema.ts"));
|
|
5640
5695
|
removeIfExists(join2(src, "db/migrations/0002_billing_schema.ts"));
|
|
5641
5696
|
removeIfExists(join2(src, "db/migrations/0003_billing_schema.ts"));
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
"check": "tsc --noEmit"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@getstrata/bootstrap": "^2.2.
|
|
16
|
-
"@getstrata/cli": "^2.2.
|
|
17
|
-
"@getstrata/core": "^2.2.
|
|
15
|
+
"@getstrata/bootstrap": "^2.2.16",
|
|
16
|
+
"@getstrata/cli": "^2.2.16",
|
|
17
|
+
"@getstrata/core": "^2.2.16",
|
|
18
18
|
"eta": "^4.6.0"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|