create-bw-app 0.9.6 → 0.9.7
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/README.md +1 -1
- package/package.json +1 -1
- package/src/generator.mjs +48 -0
- package/template/supabase/README.md +8 -20
package/README.md
CHANGED
|
@@ -57,7 +57,7 @@ Current updater behavior:
|
|
|
57
57
|
- copies a clean Next.js App Router starter template
|
|
58
58
|
- platform apps include BrightWeb auth, shell wiring, and optional module starter surfaces
|
|
59
59
|
- platform apps include a local `components/` folder for app-owned UI alongside the shared BrightWeb packages
|
|
60
|
-
- platform apps in published mode also write `supabase/module-registry.json`, `supabase/clients/<slug>/stack.json`, and the resolved shared SQL migrations under `supabase/modules/<module>/migrations`
|
|
60
|
+
- platform apps in published mode also write `supabase/config.toml`, a CLI-ready flat `supabase/migrations/` folder, `supabase/module-registry.json`, `supabase/clients/<slug>/stack.json`, and the resolved shared SQL migrations under `supabase/modules/<module>/migrations`
|
|
61
61
|
- site apps include Next.js, Tailwind CSS v4, and local component primitives
|
|
62
62
|
- writes `package.json`, `next.config.ts`, `.gitignore`, and `README.md` for both templates
|
|
63
63
|
- platform apps also write `.env.local`, `AGENTS.md`, `docs/ai/README.md`, `docs/ai/examples.md`, `docs/ai/app-context.json`, and generated config files for brand and module state
|
package/package.json
CHANGED
package/src/generator.mjs
CHANGED
|
@@ -914,6 +914,24 @@ export async function ensureDirectory(targetDir) {
|
|
|
914
914
|
await fs.mkdir(targetDir, { recursive: true });
|
|
915
915
|
}
|
|
916
916
|
|
|
917
|
+
function createGeneratedSupabaseConfig(projectId) {
|
|
918
|
+
return [
|
|
919
|
+
`project_id = "${projectId}"`,
|
|
920
|
+
"",
|
|
921
|
+
"[db]",
|
|
922
|
+
"major_version = 17",
|
|
923
|
+
"",
|
|
924
|
+
"[db.migrations]",
|
|
925
|
+
"enabled = true",
|
|
926
|
+
'schema_paths = []',
|
|
927
|
+
"",
|
|
928
|
+
"[db.seed]",
|
|
929
|
+
"enabled = false",
|
|
930
|
+
'sql_paths = []',
|
|
931
|
+
"",
|
|
932
|
+
].join("\n");
|
|
933
|
+
}
|
|
934
|
+
|
|
917
935
|
function createScopedDbModuleRegistry(registry, moduleKeys) {
|
|
918
936
|
return {
|
|
919
937
|
modules: Object.fromEntries(
|
|
@@ -965,6 +983,35 @@ async function writeClientStack(baseRoot, slug, dbInstallPlan, options = {}) {
|
|
|
965
983
|
);
|
|
966
984
|
}
|
|
967
985
|
|
|
986
|
+
async function writeSupabaseCliMigrations({ targetDir, dbInstallPlan }) {
|
|
987
|
+
const targetSupabaseDir = path.join(targetDir, "supabase");
|
|
988
|
+
const targetMigrationsDir = path.join(targetSupabaseDir, "migrations");
|
|
989
|
+
|
|
990
|
+
await ensureDirectory(targetMigrationsDir);
|
|
991
|
+
await fs.writeFile(path.join(targetSupabaseDir, "config.toml"), createGeneratedSupabaseConfig(path.basename(targetDir)), "utf8");
|
|
992
|
+
|
|
993
|
+
let sequence = 1;
|
|
994
|
+
for (const moduleKey of dbInstallPlan.resolvedOrder) {
|
|
995
|
+
const sourceModuleDir = path.join(TEMPLATE_SUPABASE_ROOT, "modules", moduleKey, "migrations");
|
|
996
|
+
if (!(await pathExists(sourceModuleDir))) {
|
|
997
|
+
continue;
|
|
998
|
+
}
|
|
999
|
+
|
|
1000
|
+
const fileNames = (await fs.readdir(sourceModuleDir))
|
|
1001
|
+
.filter((fileName) => fileName.endsWith(".sql"))
|
|
1002
|
+
.sort();
|
|
1003
|
+
|
|
1004
|
+
for (const fileName of fileNames) {
|
|
1005
|
+
const targetFileName = `${String(sequence).padStart(4, "0")}_${moduleKey}__${fileName}`;
|
|
1006
|
+
await fs.copyFile(
|
|
1007
|
+
path.join(sourceModuleDir, fileName),
|
|
1008
|
+
path.join(targetMigrationsDir, targetFileName),
|
|
1009
|
+
);
|
|
1010
|
+
sequence += 1;
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
|
|
968
1015
|
async function writeBundledSupabaseBaseline({ targetDir, slug, dbInstallPlan, registry }) {
|
|
969
1016
|
const shippedModuleKeys = dbInstallPlan.resolvedOrder;
|
|
970
1017
|
if (shippedModuleKeys.length === 0) {
|
|
@@ -995,6 +1042,7 @@ async function writeBundledSupabaseBaseline({ targetDir, slug, dbInstallPlan, re
|
|
|
995
1042
|
}
|
|
996
1043
|
|
|
997
1044
|
await writeClientStack(targetDir, slug, dbInstallPlan);
|
|
1045
|
+
await writeSupabaseCliMigrations({ targetDir, dbInstallPlan });
|
|
998
1046
|
}
|
|
999
1047
|
|
|
1000
1048
|
export async function runInstall(command, cwd) {
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
# Brightweb Supabase Structure
|
|
2
2
|
|
|
3
|
-
This directory is the
|
|
3
|
+
This directory is the scaffold-owned home for the Brightweb shared database module baselines and forward migrations that were selected for this project.
|
|
4
4
|
|
|
5
5
|
## Directory map
|
|
6
6
|
|
|
7
7
|
- `module-registry.json`: shared module dependency graph and migration source paths
|
|
8
|
+
- `config.toml`: standard Supabase CLI config for this project
|
|
9
|
+
- `migrations/*.sql`: CLI-ready ordered migrations for `supabase db push`
|
|
8
10
|
- `modules/core`: always-on platform foundations
|
|
9
11
|
- `modules/admin`: RBAC and privileged governance behavior
|
|
10
12
|
- `modules/crm`: organizations, CRM contacts, and invitation flows
|
|
11
13
|
- `modules/projects`: project and work-management data
|
|
12
14
|
- `clients/<client-slug>`: true client-only schema deltas plus the client stack plan
|
|
13
|
-
-
|
|
15
|
+
- `clients/<client-slug>`: client stack metadata and client-only migrations for this project
|
|
14
16
|
|
|
15
17
|
## Ownership rule
|
|
16
18
|
|
|
@@ -20,9 +22,9 @@ Shared database changes should be authored by ownership area, not by client app:
|
|
|
20
22
|
- shared module migrations are applied only when that module is enabled for the client
|
|
21
23
|
- client-specific migrations are the exception, not the default
|
|
22
24
|
|
|
23
|
-
|
|
25
|
+
`create-bw-app` writes `supabase/clients/<slug>/stack.json` so the generated app modules and the database install plan stay aligned.
|
|
24
26
|
|
|
25
|
-
|
|
27
|
+
These module baselines are the project-local Brightweb install path for the selected stack. Future schema work should extend them with forward migrations instead of carrying historical cleanup sequences.
|
|
26
28
|
|
|
27
29
|
Maintainer references:
|
|
28
30
|
|
|
@@ -47,23 +49,9 @@ Create a client-only migration:
|
|
|
47
49
|
pnpm db:new client:acme bespoke_reporting_table
|
|
48
50
|
```
|
|
49
51
|
|
|
50
|
-
|
|
52
|
+
The shipped `module-registry.json` records the shared module dependency graph for this project.
|
|
51
53
|
|
|
52
|
-
|
|
53
|
-
pnpm db:plan acme
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
Materialize an installable Supabase workdir for a client stack:
|
|
57
|
-
|
|
58
|
-
```bash
|
|
59
|
-
pnpm db:materialize acme
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
This writes a generated workdir under `supabase/.generated/<client-slug>` with:
|
|
63
|
-
|
|
64
|
-
- ordered migrations merged from `core`, enabled modules, and client-only deltas
|
|
65
|
-
- a generated `config.toml`
|
|
66
|
-
- a `manifest.json` showing the source file for each materialized migration
|
|
54
|
+
Projects created from the published scaffold should use the Supabase files in this folder directly. `supabase/migrations/*.sql` is the flat ordered layout that Supabase CLI reads, while `supabase/modules/*/migrations` remains the project-local modular source layout. Repo-level `db:materialize` is a deprecated Brightweb workspace compatibility command and is not the intended workflow for standalone generated apps.
|
|
67
55
|
|
|
68
56
|
## Related READMEs
|
|
69
57
|
|