create-guren-app 1.13.2 → 1.14.0

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 CHANGED
@@ -1945,6 +1945,10 @@ runMain(defineCommand({
1945
1945
  type: "boolean",
1946
1946
  description: "Include authentication scaffolding with auto-configured providers and middleware"
1947
1947
  },
1948
+ prototype: {
1949
+ type: "boolean",
1950
+ description: "Install prototype mode (RFC 0021): a fixture module and a static, server-less build for customer walkthroughs"
1951
+ },
1948
1952
  blueprint: {
1949
1953
  type: "string",
1950
1954
  description: `Starter blueprint to scaffold (${listAppBlueprints().join(", ")})`
@@ -1996,6 +2000,15 @@ runMain(defineCommand({
1996
2000
  const shouldInstall = args.install !== false;
1997
2001
  let installed = false;
1998
2002
  if (shouldInstall) installed = await installDependencies(targetDir);
2003
+ if (args.prototype && blueprint.name !== "api") {
2004
+ let prototypeInstalled = false;
2005
+ if (installed) {
2006
+ consola.start("Installing prototype mode...");
2007
+ prototypeInstalled = await runAppCli(targetDir, ["add", "prototype"]);
2008
+ if (prototypeInstalled) consola.success("Prototype mode installed: bun run dev:prototype / bun run build:prototype");
2009
+ }
2010
+ if (!prototypeInstalled) consola.warn("Prototype mode was not installed automatically. Run `bunx guren add prototype` inside the app after installing dependencies.");
2011
+ } else if (args.prototype) consola.info("The api blueprint has no pages to prototype — ignoring --prototype.");
1999
2012
  if (agents === null) consola.info("Skipping the AI agent harness. Add it later with `bunx guren agent:init --target <agents>`.");
2000
2013
  else {
2001
2014
  const targetList = agents.join(",");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-guren-app",
3
- "version": "1.13.2",
3
+ "version": "1.14.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -14,9 +14,6 @@ DATABASE_URL=./data/guren.db
14
14
 
15
15
  REDIS_URL=
16
16
 
17
- CACHE_STORE=memory
18
- # CACHE_STORE=redis
19
-
20
17
  QUEUE_CONNECTION=sync
21
18
  # QUEUE_CONNECTION=redis
22
19
 
@@ -1,11 +1,13 @@
1
1
  {
2
2
  "$schema": "./node_modules/oxlint/configuration_schema.json",
3
3
  // The guren rules ship with @guren/cli: await-async-assertion (a bare
4
- // `expect(...).rejects` statement can never fail its test) and the comment rules.
4
+ // `expect(...).rejects` statement can never fail its test), no-nullish-env-default
5
+ // (`process.env.FOO ?? 'x'` keeps a blank `FOO=` as ''), and the comment rules.
5
6
  "jsPlugins": ["@guren/cli/oxlint"],
6
7
  "ignorePatterns": ["node_modules/**", ".guren/**", "dist/**", "public/build/**"],
7
8
  "rules": {
8
9
  "guren/await-async-assertion": "error",
10
+ "guren/no-nullish-env-default": "error",
9
11
  // Comment hygiene is advisory: the agent harness feeds these back after every
10
12
  // edit, while `bun run lint` stays green on them.
11
13
  "guren/comment-length": "warn",
@@ -10,7 +10,7 @@ try {
10
10
  // `PORT=0` means "any free port", so this tests for a number, not truthiness.
11
11
  const parsedPort = Number.parseInt(process.env.PORT ?? '', 10)
12
12
  const port = Number.isInteger(parsedPort) ? parsedPort : 3333
13
- const hostname = process.env.HOST ?? '0.0.0.0'
13
+ const hostname = process.env.HOST || '0.0.0.0'
14
14
 
15
15
  // The walk past a busy port lives in listen() now, which is also the only
16
16
  // place that can report which port it ended up on. Set GUREN_STRICT_PORT=1 to
@@ -20,16 +20,16 @@
20
20
  "test": "bun test"
21
21
  },
22
22
  "dependencies": {
23
- "@guren/cli": "^2.18.0",
24
- "@guren/core": "^1.15.0",
25
- "@guren/orm": "^2.6.3",
23
+ "@guren/cli": "^2.20.0",
24
+ "@guren/core": "^1.16.0",
25
+ "@guren/orm": "^2.7.1",
26
26
  "drizzle-orm": "1.0.0-rc.4"
27
27
  },
28
28
  "devDependencies": {
29
- "@guren/testing": "^1.9.0",
29
+ "@guren/testing": "^1.10.0",
30
30
  "bun-types": "^1.3.1",
31
31
  "drizzle-kit": "1.0.0-rc.4",
32
32
  "oxlint": "~1.81.0",
33
- "typescript": "^5.4.0"
33
+ "typescript": "^7.0.2"
34
34
  }
35
35
  }
@@ -3,13 +3,9 @@ import DatabaseProvider from '../app/Providers/DatabaseProvider.js'
3
3
  import { registerApiRoutes } from '../routes/api.js'
4
4
 
5
5
  // The Host header is client-controlled, so production should answer only to the
6
- // host this app is deployed as, which APP_URL carries.
7
- //
8
- // Read at module scope, where not every platform has populated process.env yet
9
- // (the Cloudflare worker imports this module before wrangler `vars` land). A
10
- // missing value therefore warns and leaves the check off, rather than throwing
11
- // and stopping the app from booting at all. Emailed links do not depend on this
12
- // — app/Auth/AppUrl.ts resolves those per request and fails closed there.
6
+ // host this app is deployed as, which APP_URL carries. Emailed links do not
7
+ // depend on this — app/Auth/AppUrl.ts resolves those per request and fails
8
+ // closed there.
13
9
  function hostAuthorization() {
14
10
  const exclude = ['/health']
15
11
 
@@ -18,6 +14,10 @@ function hostAuthorization() {
18
14
  }
19
15
 
20
16
  const appUrl = process.env.APP_URL?.trim()
17
+ // Read at module scope, where not every platform has populated process.env yet
18
+ // (the Cloudflare worker imports this module before wrangler `vars` land), so a
19
+ // missing value warns and leaves the check off rather than throwing and
20
+ // stopping the app from booting at all.
21
21
  if (!appUrl) {
22
22
  console.warn('[app] APP_URL is not set — host authorization is disabled. Set it to the public base URL of this app.')
23
23
  return false
@@ -28,15 +28,15 @@ export default class PostController extends Controller {
28
28
  // Serves the HTTP QUERY route `posts.search` — a safe read that carries its
29
29
  // criteria in a JSON body. Matches posts with any keyword in title or
30
30
  // excerpt; `%` and `_` in a keyword act as SQL LIKE wildcards, which this
31
- // starter treats as a feature. All keyword OR pairs sit inside one
32
- // `where(callback)`, keeping this an any-keyword match while AND filters
33
- // added later (a published flag, tenancy) apply to every hit instead of
34
- // being OR'd away.
31
+ // starter treats as a feature.
35
32
  async search(): Promise<Response> {
36
33
  const { keywords, limit } = await this.validateBody(PostSearchSchema)
37
34
 
38
35
  const posts = await Post.newQuery()
39
36
  .with('author')
37
+ // All keyword OR pairs sit inside one callback, keeping this an
38
+ // any-keyword match while AND filters added later (a published flag,
39
+ // tenancy) apply to every hit instead of being OR'd away.
40
40
  .where((q) => {
41
41
  for (const keyword of keywords) {
42
42
  const pattern = `%${keyword}%`
@@ -13,11 +13,10 @@ export default class AuthProvider extends ServiceProvider {
13
13
  })
14
14
  }
15
15
 
16
+ // Nothing shares the signed-in user with the frontend by default, so every
17
+ // page would render as a guest. Layout.tsx reads this to choose between
18
+ // "Sign in" and the Write/Dashboard/Log out controls.
16
19
  boot(): void {
17
- // Nothing shares the signed-in user with the frontend by default, so every
18
- // page would render as a guest. Layout.tsx reads this to choose between
19
- // "Sign in" and the Write/Dashboard/Log out controls.
20
- //
21
20
  // shareInertiaProps merges over resolvers registered earlier instead of
22
21
  // replacing them, so the framework's flashed `errors` still come through.
23
22
  // Passing this.container scopes the props to this app.
@@ -6,13 +6,12 @@ import { PostPolicy } from '../Policies/PostPolicy.js'
6
6
  * Maps models to their policies. `PostController` calls `this.authorize()` in
7
7
  * every mutating action, and without a registered policy the gate has nothing
8
8
  * to consult and denies them all.
9
- *
10
- * The framework's own provider creates the gate during registration, so this
11
- * runs in boot() — getGate() throws before that.
12
9
  */
13
10
  export default class AuthorizationProvider extends ServiceProvider {
14
11
  register(): void {}
15
12
 
13
+ // The framework's own provider creates the gate during registration, so this
14
+ // runs in boot() — getGate() throws before that.
16
15
  boot(): void {
17
16
  getGate().policy(Post, PostPolicy)
18
17
  }
@@ -10,8 +10,9 @@ interface Props extends PaginatedPageProps<PostResourceData> {}
10
10
 
11
11
  // posts.search is an HTTP QUERY route (RFC 10008): safe like GET, but the
12
12
  // criteria travel in a JSON body — HTML forms and Inertia navigation cannot
13
- // send it, so the page calls it through the generated typed client. The
14
- // client types the request body from the schema bound to the route, and
13
+ // send it, so the page calls it through the generated typed client.
14
+
15
+ // The client types the request body from the schema bound to the route, and
15
16
  // json() from the `resource` hint the route declares — both come from the
16
17
  // route definition, so this file never restates the wire shape.
17
18
  const api = createApiClient<ApiRoutes>({ baseUrl: '' })
@@ -34,13 +34,13 @@ export function registerWebRoutes(baseRouter: Router): void {
34
34
 
35
35
  // HTTP QUERY (RFC 10008): safe and idempotent like GET, but carries its
36
36
  // search criteria in a JSON body. Only fetch-based clients can send it —
37
- // the posts page calls it through the generated API client. The
38
- // `resource` hint declares the response shape the controller builds with
39
- // PostResource, so the client's json() comes back typed — no runtime
40
- // validation, just the type codegen already extracts from the Resource.
37
+ // the posts page calls it through the generated API client.
41
38
  posts.query('/search', {
42
39
  name: 'posts.search',
43
40
  body: PostSearchSchema,
41
+ // Declares the response shape the controller builds with PostResource, so
42
+ // the client's json() comes back typed — no runtime validation, just the
43
+ // type codegen already extracts from the Resource.
44
44
  resource: { data: [PostResource] },
45
45
  }, [PostController, 'search'])
46
46
  })
@@ -18,13 +18,9 @@ setInertiaDocument({
18
18
  })
19
19
 
20
20
  // The Host header is client-controlled, so production should answer only to the
21
- // host this app is deployed as, which APP_URL carries.
22
- //
23
- // Read at module scope, where not every platform has populated process.env yet
24
- // (the Cloudflare worker imports this module before wrangler `vars` land). A
25
- // missing value therefore warns and leaves the check off, rather than throwing
26
- // and stopping the app from booting at all. Emailed links do not depend on this
27
- // — app/Auth/AppUrl.ts resolves those per request and fails closed there.
21
+ // host this app is deployed as, which APP_URL carries. Emailed links do not
22
+ // depend on this — app/Auth/AppUrl.ts resolves those per request and fails
23
+ // closed there.
28
24
  function hostAuthorization() {
29
25
  const exclude = ['/health']
30
26
 
@@ -33,6 +29,10 @@ function hostAuthorization() {
33
29
  }
34
30
 
35
31
  const appUrl = process.env.APP_URL?.trim()
32
+ // Read at module scope, where not every platform has populated process.env yet
33
+ // (the Cloudflare worker imports this module before wrangler `vars` land), so a
34
+ // missing value warns and leaves the check off rather than throwing and
35
+ // stopping the app from booting at all.
36
36
  if (!appUrl) {
37
37
  console.warn('[app] APP_URL is not set — host authorization is disabled. Set it to the public base URL of this app.')
38
38
  return false
@@ -2,13 +2,14 @@ import { beforeAll, describe, it } from 'bun:test'
2
2
  import { TestApp } from '@guren/testing'
3
3
  import app from '../src/app.js'
4
4
 
5
- // posts.search is an HTTP QUERY route (RFC 10008). Its controller validates
6
- // the body with validateBody() before building any query — the schema bound
7
- // to the route feeds codegen and `guren audit`, while body parsing stays in
8
- // the controller so the request stream is read once — so an invalid payload
9
- // gets a 422 without the database ever being touched. That keeps this starter
10
- // test green without migrations or fixtures; cover the happy path with real
11
- // feature tests once your test database is set up.
5
+ // posts.search is an HTTP QUERY route (RFC 10008). Its controller validates the
6
+ // body with validateBody() before building any query — the schema bound to the
7
+ // route feeds codegen and `guren audit`, while body parsing stays in the
8
+ // controller so the request stream is read once.
9
+
10
+ // So an invalid payload gets a 422 without the database ever being touched,
11
+ // which keeps this starter test green without migrations or fixtures. Cover the
12
+ // happy path with real feature tests once your test database is set up.
12
13
  describe('posts.search', () => {
13
14
  let http: TestApp
14
15
 
@@ -3,7 +3,7 @@ import { createMySqlDatabase, type MySqlSeederContext } from '@guren/orm'
3
3
  const database = createMySqlDatabase({
4
4
  migrationsFolder: new URL('../db/migrations', import.meta.url),
5
5
  seedersFolder: new URL('../db/seeders', import.meta.url),
6
- connectionString: () => process.env.DATABASE_URL ?? 'mysql://guren:guren@localhost:33306/guren',
6
+ connectionString: () => process.env.DATABASE_URL || 'mysql://guren:guren@localhost:33306/guren',
7
7
  })
8
8
 
9
9
  export const { getDatabase, migrateDatabase, closeDatabase, configureOrm, seedDatabase, resetDatabase, migrationStatus } = database
@@ -10,6 +10,6 @@ export default defineConfig({
10
10
  out: './db/migrations',
11
11
  dialect: 'mysql',
12
12
  dbCredentials: {
13
- url: process.env.DATABASE_URL ?? 'mysql://guren:guren@localhost:33306/guren',
13
+ url: process.env.DATABASE_URL || 'mysql://guren:guren@localhost:33306/guren',
14
14
  },
15
15
  })
@@ -3,7 +3,7 @@ import { createPostgresDatabase, type PostgresSeederContext } from '@guren/orm'
3
3
  const database = createPostgresDatabase({
4
4
  migrationsFolder: new URL('../db/migrations', import.meta.url),
5
5
  seedersFolder: new URL('../db/seeders', import.meta.url),
6
- connectionString: () => process.env.DATABASE_URL ?? 'postgres://guren:guren@localhost:54322/guren',
6
+ connectionString: () => process.env.DATABASE_URL || 'postgres://guren:guren@localhost:54322/guren',
7
7
  })
8
8
 
9
9
  export const { getDatabase, migrateDatabase, closeDatabase, configureOrm, seedDatabase, resetDatabase, migrationStatus } = database
@@ -10,6 +10,6 @@ export default defineConfig({
10
10
  out: './db/migrations',
11
11
  dialect: 'postgresql',
12
12
  dbCredentials: {
13
- url: process.env.DATABASE_URL ?? 'postgres://guren:guren@localhost:54322/guren',
13
+ url: process.env.DATABASE_URL || 'postgres://guren:guren@localhost:54322/guren',
14
14
  },
15
15
  })
@@ -7,9 +7,9 @@ import { createSqliteDatabase, type SqliteSeederContext } from '@guren/orm'
7
7
  // shard parallel CI runs); DATABASE_URL is still authoritative outside tests.
8
8
  function resolveDatabaseFilename(): string {
9
9
  if (process.env.NODE_ENV === 'test') {
10
- return process.env.TEST_DATABASE_URL ?? './data/guren.test.db'
10
+ return process.env.TEST_DATABASE_URL || './data/guren.test.db'
11
11
  }
12
- return process.env.DATABASE_URL ?? './data/guren.db'
12
+ return process.env.DATABASE_URL || './data/guren.db'
13
13
  }
14
14
 
15
15
  const database = createSqliteDatabase({
@@ -1,18 +1,14 @@
1
1
  import { defineConfig } from 'drizzle-kit'
2
2
 
3
- const filename = process.env.DATABASE_URL ?? './data/guren.db'
3
+ // Read by two different SQLite implementations that disagree about URI
4
+ // filenames: the app opens it with `bun:sqlite`, which honours them, while
5
+ // drizzle-kit opens it with `node:sqlite`, which does not. So `file:` is not a
6
+ // shared spelling of anything — `file:local.db` migrates the app into
7
+ // `local.db` and drizzle-kit into a file *named* `file:local.db`.
8
+ const filename = process.env.DATABASE_URL || './data/guren.db'
4
9
 
5
- /**
6
- * DATABASE_URL is read by two different SQLite implementations that disagree
7
- * about URI filenames: the app opens it with `bun:sqlite`, which honours them,
8
- * while drizzle-kit opens it with `node:sqlite`, which does not. So `file:` is
9
- * not a shared spelling of anything — `file:local.db` migrates the app into
10
- * `local.db` and drizzle-kit into a file *named* `file:local.db`. The safe set
11
- * is what both agree on: plain paths, and `:memory:`.
12
- *
13
- * The scheme must be two characters or more, since no registered scheme is one
14
- * letter while `C:/data/app.db` is a Windows drive path.
15
- */
10
+ // Two characters or more: no registered scheme is one letter, while
11
+ // `C:/data/app.db` is a Windows drive path.
16
12
  const uriScheme = /^([a-z][a-z0-9+.-]+):/i.exec(filename)
17
13
 
18
14
  if (uriScheme) {
@@ -14,9 +14,6 @@ DATABASE_URL=./data/guren.db
14
14
 
15
15
  REDIS_URL=
16
16
 
17
- CACHE_STORE=memory
18
- # CACHE_STORE=redis
19
-
20
17
  QUEUE_CONNECTION=sync
21
18
  # QUEUE_CONNECTION=redis
22
19
 
@@ -1,11 +1,13 @@
1
1
  {
2
2
  "$schema": "./node_modules/oxlint/configuration_schema.json",
3
3
  // The guren rules ship with @guren/cli: await-async-assertion (a bare
4
- // `expect(...).rejects` statement can never fail its test) and the comment rules.
4
+ // `expect(...).rejects` statement can never fail its test), no-nullish-env-default
5
+ // (`process.env.FOO ?? 'x'` keeps a blank `FOO=` as ''), and the comment rules.
5
6
  "jsPlugins": ["@guren/cli/oxlint"],
6
7
  "ignorePatterns": ["node_modules/**", ".guren/**", "dist/**", "public/build/**"],
7
8
  "rules": {
8
9
  "guren/await-async-assertion": "error",
10
+ "guren/no-nullish-env-default": "error",
9
11
  // Comment hygiene is advisory: the agent harness feeds these back after every
10
12
  // edit, while `bun run lint` stays green on them.
11
13
  "guren/comment-length": "warn",
@@ -10,7 +10,7 @@ try {
10
10
  // `PORT=0` means "any free port", so this tests for a number, not truthiness.
11
11
  const parsedPort = Number.parseInt(process.env.PORT ?? '', 10)
12
12
  const port = Number.isInteger(parsedPort) ? parsedPort : 3333
13
- const hostname = process.env.HOST ?? '0.0.0.0'
13
+ const hostname = process.env.HOST || '0.0.0.0'
14
14
 
15
15
  // The walk past a busy port lives in listen() now, which is also the only
16
16
  // place that can report which port it ended up on. Set GUREN_STRICT_PORT=1 to
@@ -21,10 +21,10 @@
21
21
  "db:seed": "bunx guren db:seed"
22
22
  },
23
23
  "dependencies": {
24
- "@guren/cli": "^2.18.0",
25
- "@guren/core": "^1.15.0",
26
- "@guren/inertia-client": "^1.1.3",
27
- "@guren/orm": "^2.6.3",
24
+ "@guren/cli": "^2.20.0",
25
+ "@guren/core": "^1.16.0",
26
+ "@guren/inertia-client": "^1.2.0",
27
+ "@guren/orm": "^2.7.1",
28
28
  "@inertiajs/react": "^3.6.1",
29
29
  "drizzle-orm": "1.0.0-rc.4",
30
30
  "react": "^19.0.0",
@@ -32,7 +32,7 @@
32
32
  "zod": "^4.5.0"
33
33
  },
34
34
  "devDependencies": {
35
- "@guren/testing": "^1.9.0",
35
+ "@guren/testing": "^1.10.0",
36
36
  "@tailwindcss/vite": "^4.2.2",
37
37
  "@types/react": "^19.0.0",
38
38
  "@types/react-dom": "^19.0.0",
@@ -42,7 +42,7 @@
42
42
  "mermaid": "^11.0.0",
43
43
  "oxlint": "~1.81.0",
44
44
  "tailwindcss": "^4.2.2",
45
- "typescript": "^5.4.0",
45
+ "typescript": "^7.0.2",
46
46
  "vite": "^8.0.0"
47
47
  }
48
48
  }
@@ -9,6 +9,10 @@
9
9
  fill moves to them only inside a confirm step. */
10
10
 
11
11
  :root {
12
+ /* The dark block below follows the system preference, so the UA chrome
13
+ (scrollbars, native controls, Chrome's autofill wash) must too. */
14
+ color-scheme: light dark;
15
+
12
16
  --g-font-sans: system-ui, 'Noto Sans JP', 'Hiragino Sans', sans-serif;
13
17
  --g-font-mono: ui-monospace, 'JetBrains Mono', 'SFMono-Regular', Menlo, monospace;
14
18
 
@@ -17,13 +17,9 @@ setInertiaDocument({
17
17
  })
18
18
 
19
19
  // The Host header is client-controlled, so production should answer only to the
20
- // host this app is deployed as, which APP_URL carries.
21
- //
22
- // Read at module scope, where not every platform has populated process.env yet
23
- // (the Cloudflare worker imports this module before wrangler `vars` land). A
24
- // missing value therefore warns and leaves the check off, rather than throwing
25
- // and stopping the app from booting at all. Emailed links do not depend on this
26
- // — app/Auth/AppUrl.ts resolves those per request and fails closed there.
20
+ // host this app is deployed as, which APP_URL carries. Emailed links do not
21
+ // depend on this — app/Auth/AppUrl.ts resolves those per request and fails
22
+ // closed there.
27
23
  function hostAuthorization() {
28
24
  const exclude = ['/health']
29
25
 
@@ -32,6 +28,10 @@ function hostAuthorization() {
32
28
  }
33
29
 
34
30
  const appUrl = process.env.APP_URL?.trim()
31
+ // Read at module scope, where not every platform has populated process.env yet
32
+ // (the Cloudflare worker imports this module before wrangler `vars` land), so a
33
+ // missing value warns and leaves the check off rather than throwing and
34
+ // stopping the app from booting at all.
35
35
  if (!appUrl) {
36
36
  console.warn('[app] APP_URL is not set — host authorization is disabled. Set it to the public base URL of this app.')
37
37
  return false