@dfosco/storyboard-core 4.0.0-beta.0 → 4.0.0-beta.2

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": "@dfosco/storyboard-core",
3
- "version": "4.0.0-beta.0",
3
+ "version": "4.0.0-beta.2",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "bin": {
package/src/cli/dev.js CHANGED
@@ -1,26 +1,14 @@
1
1
  /**
2
2
  * storyboard dev — Start Vite with correct base path for the current worktree.
3
3
  *
4
- * Main: http://storyboard.localhost/
5
- * Branch: http://storyboard.localhost/branch--<name>/
4
+ * Main: http://<devDomain>.localhost/
5
+ * Branch: http://<devDomain>.localhost/branch--<name>/
6
6
  */
7
7
 
8
8
  import * as p from '@clack/prompts'
9
9
  import { spawn } from 'child_process'
10
- import { readFileSync } from 'fs'
11
- import { resolve } from 'path'
12
10
  import { detectWorktreeName, getPort } from '../worktree/port.js'
13
- import { generateCaddyfile, isCaddyRunning, reloadCaddy } from './proxy.js'
14
-
15
- function readRepoName() {
16
- try {
17
- const configPath = resolve(process.cwd(), 'storyboard.config.json')
18
- const config = JSON.parse(readFileSync(configPath, 'utf8'))
19
- return config.repository?.name || 'storyboard'
20
- } catch {
21
- return 'storyboard'
22
- }
23
- }
11
+ import { generateCaddyfile, isCaddyRunning, reloadCaddy, readDevDomain } from './proxy.js'
24
12
 
25
13
  async function main() {
26
14
  const worktreeName = detectWorktreeName()
@@ -31,7 +19,8 @@ async function main() {
31
19
  ? '/'
32
20
  : `/branch--${worktreeName}/`
33
21
 
34
- const proxyUrl = `http://storyboard.localhost${basePath}`
22
+ const domain = readDevDomain()
23
+ const proxyUrl = `http://${domain}${basePath}`
35
24
  const directUrl = `http://localhost:${port}${basePath}`
36
25
 
37
26
  p.intro('storyboard dev')
package/src/cli/index.js CHANGED
@@ -6,7 +6,9 @@
6
6
  * storyboard dev Start Vite dev server + update proxy
7
7
  * storyboard setup Install deps, Caddy, start proxy
8
8
  * storyboard proxy Generate Caddyfile + start/reload Caddy
9
- * storyboard update:flag K V Update a feature flag in storyboard.config.json
9
+ * storyboard update:version Update @dfosco/storyboard-* packages to latest
10
+ * storyboard update:beta Update to latest beta
11
+ * storyboard update:alpha Update to latest alpha
10
12
  *
11
13
  * Aliases: `sb` is equivalent to `storyboard`.
12
14
  */
@@ -36,9 +38,6 @@ switch (command) {
36
38
  case 'proxy':
37
39
  import('./proxy.js')
38
40
  break
39
- case 'update:flag':
40
- import('./updateFlag.js')
41
- break
42
41
  case 'create':
43
42
  import('./create.js')
44
43
  break
@@ -46,6 +45,10 @@ switch (command) {
46
45
  import('./exit.js')
47
46
  break
48
47
  default: {
48
+ if (command === 'update' || (command && command.startsWith('update:'))) {
49
+ import('./updateVersion.js')
50
+ break
51
+ }
49
52
  const version = getVersion()
50
53
  p.intro(`storyboard v${version}`)
51
54
  p.log.message(`Commands:
@@ -54,7 +57,10 @@ switch (command) {
54
57
  setup Install deps, Caddy proxy, start proxy
55
58
  proxy Generate Caddyfile + start/reload Caddy
56
59
  exit Stop all dev servers and proxy
57
- update:flag K V Update a feature flag`)
60
+ update Update storyboard packages to latest
61
+ update:<version> Update to specific version
62
+ update:beta Update to latest beta
63
+ update:alpha Update to latest alpha`)
58
64
 
59
65
  if (command) {
60
66
  p.log.error(`Unknown command: ${command}`)
package/src/cli/proxy.js CHANGED
@@ -11,10 +11,20 @@
11
11
 
12
12
  import { readFileSync, writeFileSync, existsSync, mkdirSync } from 'fs'
13
13
  import { execSync } from 'child_process'
14
- import { dirname } from 'path'
14
+ import { dirname, resolve } from 'path'
15
15
  import { portsFilePath } from '../worktree/port.js'
16
16
 
17
- const DOMAIN = 'storyboard.localhost'
17
+ export function readDevDomain() {
18
+ try {
19
+ const configPath = resolve(process.cwd(), 'storyboard.config.json')
20
+ const config = JSON.parse(readFileSync(configPath, 'utf8'))
21
+ return `${config.devDomain || 'storyboard'}.localhost`
22
+ } catch {
23
+ return 'storyboard.localhost'
24
+ }
25
+ }
26
+
27
+ const DOMAIN = readDevDomain()
18
28
 
19
29
  export function generateCaddyfile(portOverrides = {}) {
20
30
  const portsFile = portsFilePath()
@@ -0,0 +1,73 @@
1
+ /**
2
+ * storyboard update[:channel|:version] — Update all @dfosco/storyboard-* packages.
3
+ *
4
+ * Usage:
5
+ * storyboard update # update to latest stable
6
+ * storyboard update:version 4.0.0 # update to specific version
7
+ * storyboard update:4.0.0-beta.1 # update to specific version (shorthand)
8
+ * storyboard update:beta # update to latest beta
9
+ * storyboard update:alpha # update to latest alpha
10
+ */
11
+
12
+ import * as p from '@clack/prompts'
13
+ import { execSync } from 'child_process'
14
+ import { readFileSync } from 'fs'
15
+ import { resolve } from 'path'
16
+
17
+ const command = process.argv[2]
18
+ const channels = { 'update:beta': 'beta', 'update:alpha': 'alpha' }
19
+
20
+ let channel, targetVersion
21
+ if (channels[command]) {
22
+ channel = channels[command]
23
+ } else if (command === 'update:version') {
24
+ targetVersion = process.argv[3]
25
+ } else if (command && command.startsWith('update:')) {
26
+ // update:<version> shorthand, e.g. update:4.0.0-beta.1
27
+ targetVersion = command.slice('update:'.length)
28
+ }
29
+
30
+ const pkgPath = resolve(process.cwd(), 'package.json')
31
+ let pkg
32
+ try {
33
+ pkg = JSON.parse(readFileSync(pkgPath, 'utf8'))
34
+ } catch (err) {
35
+ p.log.error(`Failed to read package.json: ${err.message}`)
36
+ process.exit(1)
37
+ }
38
+
39
+ // Collect all @dfosco/storyboard-* packages from deps and devDeps
40
+ const storyboardPkgs = new Set()
41
+ for (const depField of ['dependencies', 'devDependencies']) {
42
+ if (!pkg[depField]) continue
43
+ for (const name of Object.keys(pkg[depField])) {
44
+ if (name.startsWith('@dfosco/storyboard-') || name === '@dfosco/tiny-canvas') {
45
+ storyboardPkgs.add(name)
46
+ }
47
+ }
48
+ }
49
+
50
+ if (storyboardPkgs.size === 0) {
51
+ p.log.warn('No @dfosco/storyboard-* packages found in package.json')
52
+ process.exit(0)
53
+ }
54
+
55
+ const tag = channel || (targetVersion ? undefined : 'latest')
56
+ const suffix = targetVersion ? `@${targetVersion}` : `@${tag}`
57
+ const packages = [...storyboardPkgs].map(name => `${name}${suffix}`).join(' ')
58
+
59
+ const label = channel ? `to ${channel}` : targetVersion ? `to ${targetVersion}` : ''
60
+ p.intro(`storyboard ${command}`)
61
+ p.log.info(`Updating ${storyboardPkgs.size} package(s)${label ? ` ${label}` : ''}…`)
62
+ for (const name of storyboardPkgs) {
63
+ p.log.message(` ${name}${suffix}`)
64
+ }
65
+
66
+ try {
67
+ execSync(`npm install ${packages}`, { stdio: 'inherit', cwd: process.cwd() })
68
+ p.log.success('All storyboard packages updated')
69
+ p.outro('Done')
70
+ } catch {
71
+ p.log.error('Failed to update packages — see npm output above')
72
+ process.exit(1)
73
+ }
@@ -1,45 +0,0 @@
1
- /**
2
- * storyboard update:flag <key> <value> — Update a feature flag in storyboard.config.json.
3
- *
4
- * Usage:
5
- * storyboard update:flag show-banner false
6
- * storyboard update:flag debug-mode true
7
- */
8
-
9
- import * as p from '@clack/prompts'
10
- import { readFileSync, writeFileSync } from 'fs'
11
- import { resolve } from 'path'
12
-
13
- const key = process.argv[3]
14
- const rawValue = process.argv[4]
15
-
16
- if (!key || rawValue === undefined) {
17
- p.intro('storyboard update:flag')
18
- p.log.error('Usage: storyboard update:flag <key> <value>')
19
- p.outro('Example: npx storyboard update:flag show-banner false')
20
- process.exit(1)
21
- }
22
-
23
- // Parse value: "true"/"false" → boolean, numbers → number, else string
24
- let value
25
- if (rawValue === 'true') value = true
26
- else if (rawValue === 'false') value = false
27
- else if (!isNaN(rawValue) && rawValue !== '') value = Number(rawValue)
28
- else value = rawValue
29
-
30
- const configPath = resolve(process.cwd(), 'storyboard.config.json')
31
-
32
- let config
33
- try {
34
- config = JSON.parse(readFileSync(configPath, 'utf8'))
35
- } catch (err) {
36
- p.log.error(`Failed to read storyboard.config.json: ${err.message}`)
37
- process.exit(1)
38
- }
39
-
40
- if (!config.featureFlags) config.featureFlags = {}
41
- const prev = config.featureFlags[key]
42
- config.featureFlags[key] = value
43
-
44
- writeFileSync(configPath, JSON.stringify(config, null, 2) + '\n')
45
- p.log.success(`featureFlags.${key}: ${JSON.stringify(prev)} → ${JSON.stringify(value)}`)