@dfosco/storyboard-core 4.0.0-beta.1 → 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 +1 -1
- package/src/cli/dev.js +5 -16
- package/src/cli/index.js +10 -4
- package/src/cli/proxy.js +12 -2
- package/src/cli/updateVersion.js +22 -8
package/package.json
CHANGED
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
|
|
5
|
-
* Branch: http
|
|
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
|
|
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
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
* storyboard setup Install deps, Caddy, start proxy
|
|
8
8
|
* storyboard proxy Generate Caddyfile + start/reload Caddy
|
|
9
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:version':
|
|
40
|
-
import('./updateVersion.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
|
|
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
|
-
|
|
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()
|
package/src/cli/updateVersion.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* storyboard update:version — Update all @dfosco/storyboard-* packages
|
|
3
|
-
*
|
|
4
|
-
* Equivalent to `npm run update` in a client repo.
|
|
2
|
+
* storyboard update[:channel|:version] — Update all @dfosco/storyboard-* packages.
|
|
5
3
|
*
|
|
6
4
|
* Usage:
|
|
7
|
-
* storyboard update
|
|
5
|
+
* storyboard update # update to latest stable
|
|
8
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
|
|
9
10
|
*/
|
|
10
11
|
|
|
11
12
|
import * as p from '@clack/prompts'
|
|
@@ -13,7 +14,18 @@ import { execSync } from 'child_process'
|
|
|
13
14
|
import { readFileSync } from 'fs'
|
|
14
15
|
import { resolve } from 'path'
|
|
15
16
|
|
|
16
|
-
const
|
|
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
|
+
}
|
|
17
29
|
|
|
18
30
|
const pkgPath = resolve(process.cwd(), 'package.json')
|
|
19
31
|
let pkg
|
|
@@ -40,11 +52,13 @@ if (storyboardPkgs.size === 0) {
|
|
|
40
52
|
process.exit(0)
|
|
41
53
|
}
|
|
42
54
|
|
|
43
|
-
const
|
|
55
|
+
const tag = channel || (targetVersion ? undefined : 'latest')
|
|
56
|
+
const suffix = targetVersion ? `@${targetVersion}` : `@${tag}`
|
|
44
57
|
const packages = [...storyboardPkgs].map(name => `${name}${suffix}`).join(' ')
|
|
45
58
|
|
|
46
|
-
|
|
47
|
-
p.
|
|
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}` : ''}…`)
|
|
48
62
|
for (const name of storyboardPkgs) {
|
|
49
63
|
p.log.message(` ${name}${suffix}`)
|
|
50
64
|
}
|