create-bakery 2.0.0-alpha.11 → 2.0.0-alpha.13

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-bakery",
3
- "version": "2.0.0-alpha.11",
3
+ "version": "2.0.0-alpha.13",
4
4
  "description": "Scaffold a Bakery app: bun create bakery <directory>",
5
5
  "keywords": [
6
6
  "bakery",
package/src/index.ts CHANGED
@@ -7,6 +7,7 @@ import {
7
7
  dependencyRange,
8
8
  isValidAppName,
9
9
  PLUGIN_IDS,
10
+ PLUGINS_NEEDING_ORM,
10
11
  type PluginId,
11
12
  type TemplateFile,
12
13
  templateFiles,
@@ -227,12 +228,22 @@ export async function resolveChoices(
227
228
  { id: 'vue', label: 'vue', hint: 'single-file components' },
228
229
  { id: 'analytics', label: 'analytics', hint: 'request metrics' },
229
230
  { id: 'dashboard', label: 'dashboard', hint: 'admin console' },
231
+ { id: 'db-explorer', label: 'db-explorer', hint: 'browse and edit rows' },
230
232
  ])
231
233
  if (chosen === null) return null
232
234
  plugins = PLUGIN_IDS.filter(id => chosen.includes(id))
233
235
  }
234
236
  }
235
237
 
238
+ // The explorer browses and edits whatever the ORM is connected to, so
239
+ // scaffolding it without `orm/` produces an app whose headline feature has
240
+ // nothing to show. Turned on rather than refused: the two are asked for
241
+ // separately, and a generated app that boots is better than a prompt that
242
+ // argues with the answer it was just given.
243
+ if (!orm && plugins.some(id => PLUGINS_NEEDING_ORM.includes(id))) {
244
+ orm = true
245
+ }
246
+
236
247
  return { orm, plugins }
237
248
  }
238
249
 
package/src/template.ts CHANGED
@@ -22,7 +22,12 @@ export type TemplateFile = {
22
22
  }
23
23
 
24
24
  /** The plugins `--plugins` accepts, in the order they are registered. */
25
- export const PLUGIN_IDS = ['vue', 'analytics', 'dashboard'] as const
25
+ export const PLUGIN_IDS = [
26
+ 'vue',
27
+ 'analytics',
28
+ 'dashboard',
29
+ 'db-explorer',
30
+ ] as const
26
31
  export type PluginId = (typeof PLUGIN_IDS)[number]
27
32
 
28
33
  export type TemplateOptions = {
@@ -65,8 +70,32 @@ const PLUGINS: Record<
65
70
  // because it is a local demo; a generated app is not.
66
71
  call: 'dashboardPlugin()',
67
72
  },
73
+ 'db-explorer': {
74
+ pkg: '@bakery-framework/plugin-db-explorer',
75
+ import: 'dbExplorerPlugin',
76
+ // Same rule as the dashboard and for a stronger reason: this one edits
77
+ // rows. With no `users` and no `authorize` the explorer allows loopback in
78
+ // development and denies in production, so a generated app is never born
79
+ // able to write to its database from a browser on the internet.
80
+ //
81
+ // It does not share the dashboard's door. Access here is a *level* per
82
+ // caller rather than a yes, which is why configuring one grants nothing in
83
+ // the other — see `docs/plugins/db-explorer.md`.
84
+ call: 'dbExplorerPlugin()',
85
+ },
68
86
  }
69
87
 
88
+ /**
89
+ * Plugins that cannot work without the ORM.
90
+ *
91
+ * `db-explorer` browses and edits whatever the ORM is connected to, so
92
+ * scaffolding it without `orm/` produces an app whose headline feature has
93
+ * nothing to show. The scaffolder turns the ORM on rather than refusing: the
94
+ * two are asked for separately and a generated app that boots is better than
95
+ * a prompt that argues.
96
+ */
97
+ export const PLUGINS_NEEDING_ORM: readonly PluginId[] = ['db-explorer']
98
+
70
99
  /**
71
100
  * The version range the generated `package.json` asks for.
72
101
  *
@@ -354,6 +383,11 @@ function readme(name: string, orm: boolean, plugins: PluginId[]): string {
354
383
  ? '\n\nThe dashboard is loopback-only in development and denied in production ' +
355
384
  'until you give it an `authorize` predicate.'
356
385
  : '') +
386
+ (plugins.includes('db-explorer')
387
+ ? '\n\nThe database explorer is served at `/_db` and follows the same rule, ' +
388
+ 'with its own access model: a level per caller rather than a yes. ' +
389
+ 'Configuring the dashboard grants nothing there.'
390
+ : '') +
357
391
  (plugins.includes('vue')
358
392
  ? '\n\n`vue` and `@vue/compiler-sfc` are direct dependencies rather than ' +
359
393
  'unmet peers, so `.vue` pages compile straight after install.'