@beechcms/cli 0.6.0-preview.3 → 0.6.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.
Files changed (50) hide show
  1. package/dist/index.js +1298 -765
  2. package/package.json +8 -3
  3. package/.turbo/turbo-build.log +0 -5
  4. package/coverage/base.css +0 -224
  5. package/coverage/block-navigation.js +0 -87
  6. package/coverage/favicon.png +0 -0
  7. package/coverage/index.html +0 -116
  8. package/coverage/lcov-report/base.css +0 -224
  9. package/coverage/lcov-report/block-navigation.js +0 -87
  10. package/coverage/lcov-report/favicon.png +0 -0
  11. package/coverage/lcov-report/index.html +0 -116
  12. package/coverage/lcov-report/prettify.css +0 -1
  13. package/coverage/lcov-report/prettify.js +0 -2
  14. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  15. package/coverage/lcov-report/sorter.js +0 -210
  16. package/coverage/lcov-report/validate.ts.html +0 -325
  17. package/coverage/lcov.info +0 -80
  18. package/coverage/prettify.css +0 -1
  19. package/coverage/prettify.js +0 -2
  20. package/coverage/sort-arrow-sprite.png +0 -0
  21. package/coverage/sorter.js +0 -210
  22. package/coverage/validate.ts.html +0 -325
  23. package/dist/commands/seed-load.d.ts +0 -8
  24. package/dist/commands/seed-load.d.ts.map +0 -1
  25. package/dist/commands/seed-load.js +0 -89
  26. package/dist/index.d.ts +0 -3
  27. package/dist/index.d.ts.map +0 -1
  28. package/dist/lib/schema-diff.d.ts +0 -15
  29. package/dist/lib/schema-diff.d.ts.map +0 -1
  30. package/dist/lib/schema-diff.js +0 -37
  31. package/dist/lib/wrangler.d.ts +0 -17
  32. package/dist/lib/wrangler.d.ts.map +0 -1
  33. package/dist/lib/wrangler.js +0 -65
  34. package/src/commands/deploy.ts +0 -126
  35. package/src/commands/init.ts +0 -599
  36. package/src/commands/onboard.ts +0 -32
  37. package/src/commands/reset.ts +0 -157
  38. package/src/commands/seed-create.ts +0 -192
  39. package/src/commands/seed-load.ts +0 -235
  40. package/src/commands/update.ts +0 -54
  41. package/src/commands/validate.ts +0 -80
  42. package/src/index.ts +0 -20
  43. package/src/lib/schema-diff.ts +0 -150
  44. package/src/lib/wrangler.ts +0 -129
  45. package/src/test/reset.test.ts +0 -128
  46. package/src/test/seed-load.test.ts +0 -158
  47. package/src/test/validate.test.ts +0 -261
  48. package/tsconfig.json +0 -16
  49. package/tsconfig.tsbuildinfo +0 -1
  50. package/vitest.config.ts +0 -33
@@ -1,126 +0,0 @@
1
- // SPDX-License-Identifier: MIT
2
- // Copyright (c) 2024–2026 Flavio De Musso
3
-
4
- import pc from 'picocolors'
5
- import { spawnSync } from 'node:child_process'
6
- import { readFileSync } from 'node:fs'
7
- import { findWranglerConfig } from '../lib/wrangler.js'
8
-
9
- export interface DeployOptions {
10
- skipSeed?: boolean
11
- skipCheck?: boolean
12
- }
13
-
14
- function readWorkerName(configPath: string | null): string | null {
15
- if (!configPath) return null
16
- try {
17
- const raw = readFileSync(configPath, 'utf-8')
18
- const stripped = raw
19
- .replace(/\/\/[^\n]*/g, '')
20
- .replace(/\/\*[\s\S]*?\*\//g, '')
21
- const parsed = JSON.parse(stripped)
22
- return (parsed?.name as string) ?? null
23
- } catch {
24
- return null
25
- }
26
- }
27
-
28
- // Extracts the first workers.dev URL from wrangler deploy stdout.
29
- // wrangler writes progress to stderr (shown live) and the summary to stdout (captured).
30
- function extractWorkerUrl(output: string): string | null {
31
- const match = output.match(/https:\/\/[a-zA-Z0-9-]+\.[a-zA-Z0-9-]+\.workers\.dev\b/)
32
- return match?.[0] ?? null
33
- }
34
-
35
- async function checkAdmin(url: string): Promise<{ ok: boolean; status: number | null }> {
36
- try {
37
- const res = await fetch(`${url}/admin`, {
38
- method: 'HEAD',
39
- redirect: 'follow',
40
- signal: AbortSignal.timeout(12_000),
41
- })
42
- return { ok: res.status < 500, status: res.status }
43
- } catch {
44
- return { ok: false, status: null }
45
- }
46
- }
47
-
48
- export async function deploy(args: DeployOptions): Promise<void> {
49
- console.log(pc.cyan('\n beech deploy\n'))
50
-
51
- // Step 1: wrangler deploy via npm run deploy.
52
- // stdout captured to extract the deployed URL; stderr stays on the terminal for live progress.
53
- console.log(pc.dim(' [1/3] Deploying Worker…\n'))
54
- const deployResult = spawnSync('npm', ['run', 'deploy'], {
55
- stdio: ['inherit', 'pipe', 'inherit'],
56
- encoding: 'utf-8',
57
- cwd: process.cwd(),
58
- shell: true,
59
- })
60
-
61
- const deployStdout = deployResult.stdout ?? ''
62
- if (deployStdout) process.stdout.write(deployStdout)
63
-
64
- if (deployResult.status !== 0) {
65
- console.log(pc.red('\n ✗ Worker deploy failed\n'))
66
- console.log(pc.dim(' Check the wrangler output above for details.'))
67
- console.log(pc.cyan('\n → Run: npx wrangler login # if not authenticated'))
68
- console.log(pc.cyan(' → Or: Update wrangler.jsonc # if database_id is wrong\n'))
69
- process.exit(1)
70
- }
71
-
72
- const deployedUrl = extractWorkerUrl(deployStdout)
73
- console.log(pc.green('\n ✓ Worker deployed'))
74
-
75
- // Step 2: seed:load --remote as a subprocess so that wrangler failures
76
- // (which call process.exit internally) don't abort our own process.
77
- if (args.skipSeed) {
78
- console.log(pc.dim('\n [2/3] Skipping seed:load (--skip-seed)'))
79
- } else {
80
- console.log(pc.dim('\n [2/3] Syncing content schema to remote D1…\n'))
81
- const seedResult = spawnSync('npx', ['beech', 'seed:load'], {
82
- stdio: 'inherit',
83
- cwd: process.cwd(),
84
- shell: true,
85
- })
86
- if (seedResult.status !== 0) {
87
- console.log(pc.yellow('\n ⚠ seed:load failed\n'))
88
- console.log(pc.dim(' Sync the remote content schema manually:'))
89
- console.log(pc.cyan(' → Run: npx beech seed:load\n'))
90
- } else {
91
- console.log(pc.green('\n ✓ Content schema synced'))
92
- }
93
- }
94
-
95
- // Step 3: check /admin reachability.
96
- // Use URL extracted from deploy output; fall back to worker name from wrangler.jsonc.
97
- if (args.skipCheck) {
98
- console.log(pc.dim('\n [3/3] Skipping admin check (--skip-check)\n'))
99
- return
100
- }
101
-
102
- const adminBase = deployedUrl ?? (() => {
103
- const workerName = readWorkerName(findWranglerConfig())
104
- // We can't reliably construct the full workers.dev subdomain without knowing the account,
105
- // so only use the name-based URL as a fallback when nothing better is available.
106
- return workerName ? `https://${workerName}.workers.dev` : null
107
- })()
108
-
109
- if (!adminBase) {
110
- console.log(pc.dim('\n [3/3] Could not determine worker URL — skipping admin check\n'))
111
- console.log(pc.dim(' The deployed URL is printed by wrangler above. Open <url>/admin to verify.\n'))
112
- return
113
- }
114
-
115
- console.log(pc.dim(`\n [3/3] Checking ${adminBase}/admin…\n`))
116
- const { ok, status } = await checkAdmin(adminBase)
117
-
118
- if (ok) {
119
- console.log(pc.green(` ✓ Admin reachable at: ${adminBase}/admin\n`))
120
- } else {
121
- const statusStr = status != null ? ` (HTTP ${status})` : ''
122
- console.log(pc.yellow(` ⚠ Admin returned an error${statusStr} at: ${adminBase}/admin\n`))
123
- console.log(pc.dim(' The database may not be fully initialized.'))
124
- console.log(pc.cyan(' → Run: npx beech init --db --remote\n'))
125
- }
126
- }