@brust/create-app 2.0.0-alpha.4 → 2.0.0-alpha.5

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 CHANGED
@@ -17,4 +17,4 @@ bun run dev # http://127.0.0.1:1337
17
17
 
18
18
  `bun create` rejects `-t` and `-y`; use the long flags (the short ones work with `bunx @brust/create-app`).
19
19
 
20
- Full guide: [docs/create-app.md](https://github.com/AssetsArt/brust/blob/v2/docs/create-app.md).
20
+ Full guide: [docs/create-app.md](https://github.com/AssetsArt/brust/blob/main/docs/create-app.md).
package/package.json CHANGED
@@ -1,13 +1,17 @@
1
1
  {
2
2
  "name": "@brust/create-app",
3
- "version": "2.0.0-alpha.4",
3
+ "version": "2.0.0-alpha.5",
4
4
  "description": "Scaffold a brust v2 app — bun create @brust/app <name>",
5
5
  "license": "MIT",
6
+ "homepage": "https://brust.dev",
6
7
  "repository": {
7
8
  "type": "git",
8
9
  "url": "git+https://github.com/AssetsArt/brust.git",
9
10
  "directory": "packages/create-app"
10
11
  },
12
+ "bugs": {
13
+ "url": "https://github.com/AssetsArt/brust/issues"
14
+ },
11
15
  "type": "module",
12
16
  "bin": {
13
17
  "create-app": "./bin/create-app.ts"
package/src/args.ts CHANGED
@@ -5,7 +5,7 @@ import { isAbsolute, resolve } from 'node:path'
5
5
  const NAME_RE = /^[a-z0-9][a-z0-9_-]*$/
6
6
  const MAX_NAME_LEN = 50
7
7
 
8
- export const USAGE = 'usage: bun create @brust/app <name> [--template blank|pokedex] [--tailwind] [--dir <path>] [--yes] [--brust-dep <spec>]'
8
+ export const USAGE = 'usage: bun create @brust/app <name> [--template blank|pokedex] [--tailwind] [--dir <path>] [--yes] [--brust-dep <spec>] [--version]'
9
9
 
10
10
  export interface ParsedArgs {
11
11
  projectName: string
@@ -16,6 +16,8 @@ export interface ParsedArgs {
16
16
  /** `--tailwind` (L21): accepted and ignored since L28: the blank template uses Tailwind CSS v4 by default. */
17
17
  tailwind: boolean
18
18
  help: boolean
19
+ /** `--version` (F131): print the bare version and exit; no short form (see the note above). */
20
+ version: boolean
19
21
  }
20
22
 
21
23
  export function parseArgs(args: string[]): ParsedArgs {
@@ -26,6 +28,7 @@ export function parseArgs(args: string[]): ParsedArgs {
26
28
  let yes = false
27
29
  let tailwind = false
28
30
  let help = false
31
+ let version = false
29
32
  const need = (flag: string, v: string | undefined): string => {
30
33
  if (!v) throw new Error(`create-app: ${flag} requires a value`)
31
34
  return v
@@ -35,6 +38,7 @@ export function parseArgs(args: string[]): ParsedArgs {
35
38
  const a = args[i]!
36
39
  if (a === '--') continue
37
40
  if (a === '--help' || a === '-h') help = true
41
+ else if (a === '--version') version = true
38
42
  else if (a === '--dir') dir = need('--dir', args[++i])
39
43
  else if (a.startsWith('--dir=')) dir = need('--dir', a.slice('--dir='.length))
40
44
  else if (a === '--template' || a === '-t') template = need('--template', args[++i])
@@ -48,7 +52,7 @@ export function parseArgs(args: string[]): ParsedArgs {
48
52
  else throw new Error(`create-app: unexpected positional argument "${a}"`)
49
53
  }
50
54
 
51
- if (help) return { projectName: name ?? '', targetDir: '', template, yes, brustDep, tailwind, help }
55
+ if (help || version) return { projectName: name ?? '', targetDir: '', template, yes, brustDep, tailwind, help, version }
52
56
  if (!name) throw new Error(`create-app: missing project name. ${USAGE}`)
53
57
  if (name.length > MAX_NAME_LEN) throw new Error(`create-app: project name too long (max ${MAX_NAME_LEN} chars)`)
54
58
  if (!NAME_RE.test(name)) {
@@ -56,5 +60,5 @@ export function parseArgs(args: string[]): ParsedArgs {
56
60
  }
57
61
  const cwd = process.cwd()
58
62
  const targetDir = dir ? (isAbsolute(dir) ? dir : resolve(cwd, dir)) : resolve(cwd, name)
59
- return { projectName: name, targetDir, template, yes, brustDep, tailwind, help }
63
+ return { projectName: name, targetDir, template, yes, brustDep, tailwind, help, version }
60
64
  }
package/src/cli.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  // `create-app` main — a port of 0.1.x runNew (runtime/cli/new.ts:221-294) with the v2 dependency resolution.
2
- import { existsSync } from 'node:fs'
2
+ import { existsSync, readFileSync } from 'node:fs'
3
3
  import { readdir, rm } from 'node:fs/promises'
4
4
  import { copyTemplate } from './copy.ts'
5
5
  import { parseArgs, USAGE } from './args.ts'
@@ -7,6 +7,9 @@ import { applyOverrides, monorepoRoot, resolveBrustDep } from './dep.ts'
7
7
  import { TAILWIND_DEFAULT_NOTE } from './tailwind.ts'
8
8
  import { selectTemplate } from './templates.ts'
9
9
 
10
+ // F131: read at run time from the package.json that `bun publish` ships, so release-bump.ts stays the only place versions change.
11
+ const ownVersion = (): string => (JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8')) as { version?: string }).version ?? '0.0.0'
12
+
10
13
  const fail = (msg: string): never => {
11
14
  console.error(msg)
12
15
  process.exit(1)
@@ -20,6 +23,11 @@ export async function main(argv: string[]): Promise<void> {
20
23
  console.log(USAGE)
21
24
  return
22
25
  }
26
+ if (parsed.version) {
27
+ console.log(ownVersion())
28
+ return
29
+ }
30
+ console.log(`@brust/create-app ${ownVersion()}\n`)
23
31
  const { projectName, targetDir } = parsed
24
32
 
25
33
  const targetExisted = existsSync(targetDir)
@@ -47,13 +55,13 @@ export async function main(argv: string[]): Promise<void> {
47
55
  if (!targetExisted) await rm(targetDir, { recursive: true, force: true }).catch(() => {})
48
56
  return fail(`create-app: failed to scaffold (${msg(e)})`)
49
57
  }
50
- printNextSteps(projectName, targetDir, tmpl.name, dep.kind === 'workspace')
58
+ printNextSteps(projectName, targetDir, tmpl.name, dep.spec, dep.kind === 'workspace')
51
59
  }
52
60
 
53
- function printNextSteps(name: string, targetDir: string, template: string, workspace: boolean): void {
61
+ function printNextSteps(name: string, targetDir: string, template: string, spec: string, workspace: boolean): void {
54
62
  const cwd = process.cwd()
55
63
  const displayPath = targetDir.startsWith(`${cwd}/`) ? `./${targetDir.slice(cwd.length + 1)}` : targetDir
56
- console.log(`Created ${name} at ${targetDir} (template: ${template})\n`)
64
+ console.log(`Created ${name} at ${targetDir} (template: ${template}, @brust/core ${spec})\n`)
57
65
  console.log('Next:')
58
66
  console.log(` cd ${displayPath}`)
59
67
  console.log(workspace ? ' bun install # run it at the brust repo root: this app is a workspace member' : ' bun install')
@@ -9,7 +9,7 @@ bun install
9
9
  bun run dev # brust dev routes.tsx (hot reload) -> http://127.0.0.1:1337
10
10
  ```
11
11
 
12
- Scripts: `dev` (build then start), `build`, `start`, `typecheck`, `dev:cf` (build for Cloudflare Workers and run `wrangler dev`), `deploy:cf` (build and `wrangler deploy`).
12
+ Scripts: `dev` (`brust dev`, with hot reload), `build`, `start`, `typecheck`, `dev:cf` (build for Cloudflare Workers and run `wrangler dev`), `deploy:cf` (build and `wrangler deploy`).
13
13
 
14
14
  ## Layout
15
15
 
@@ -39,5 +39,5 @@ const { data } = await api.hello.get({ query: { name: 'ash' } })
39
39
 
40
40
  ## Docs
41
41
 
42
- - Actions: https://github.com/AssetsArt/brust/blob/v2/docs/actions.md
43
- - The unified store: https://github.com/AssetsArt/brust/blob/v2/docs/store.md
42
+ - Actions: https://github.com/AssetsArt/brust/blob/main/docs/actions.md
43
+ - The unified store: https://github.com/AssetsArt/brust/blob/main/docs/store.md
@@ -55,5 +55,5 @@ bunx @tailwindcss/cli@4 -i styles/app.css -o public/app.css --minify
55
55
 
56
56
  ## Docs
57
57
 
58
- - Actions: https://github.com/AssetsArt/brust/blob/v2/docs/actions.md
59
- - The unified store: https://github.com/AssetsArt/brust/blob/v2/docs/store.md
58
+ - Actions: https://github.com/AssetsArt/brust/blob/main/docs/actions.md
59
+ - The unified store: https://github.com/AssetsArt/brust/blob/main/docs/store.md