uniweb 0.12.9 → 0.12.11
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 +13 -5
- package/package.json +5 -5
- package/partials/agents.md +22 -5
- package/src/commands/add.js +2 -2
- package/src/commands/build.js +22 -7
- package/src/commands/deploy.js +150 -30
- package/src/commands/dev.js +111 -0
- package/src/commands/export.js +19 -6
- package/src/commands/handoff.js +1 -1
- package/src/commands/invite.js +1 -1
- package/src/commands/publish.js +1 -1
- package/src/commands/template.js +1 -1
- package/src/framework-index.json +6 -6
- package/src/index.js +362 -12
- package/src/utils/args.js +37 -0
- package/src/utils/auth.js +29 -1
- package/src/utils/config.js +15 -6
- package/src/utils/host-prompt.js +50 -0
- package/src/utils/update-check.js +34 -3
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interactive host adapter selection
|
|
3
|
+
*
|
|
4
|
+
* Prompts the user to pick a host adapter from the registry. Used when
|
|
5
|
+
* `--host` is passed without a value to `uniweb deploy / build / export`.
|
|
6
|
+
*
|
|
7
|
+
* Non-interactive contexts (CI, piped input, --non-interactive) get a
|
|
8
|
+
* structured error instead of a prompt — never silently default to
|
|
9
|
+
* something the user didn't pick.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { promptSelect } from './workspace.js'
|
|
13
|
+
import { isNonInteractive } from './interactive.js'
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Pick a host adapter, optionally with a pre-selection.
|
|
17
|
+
*
|
|
18
|
+
* @param {object} opts
|
|
19
|
+
* @param {string[]} opts.args — Argv, used only to gate non-interactive mode.
|
|
20
|
+
* @param {string|null} [opts.preselect] — Suggested adapter name; the prompt
|
|
21
|
+
* highlights this so Enter accepts it without arrow-key navigation.
|
|
22
|
+
* @returns {Promise<string>} The chosen adapter name.
|
|
23
|
+
* @throws {Error} When non-interactive (with the registry list in the message),
|
|
24
|
+
* or when the user aborts the prompt.
|
|
25
|
+
*/
|
|
26
|
+
export async function promptForHost({ args, preselect = null } = {}) {
|
|
27
|
+
// Lazy-load so this module doesn't pull @uniweb/build at import time
|
|
28
|
+
// for callers that never reach the prompt path.
|
|
29
|
+
const { listAdapters } = await import('@uniweb/build/hosts')
|
|
30
|
+
const adapters = listAdapters()
|
|
31
|
+
|
|
32
|
+
if (isNonInteractive(args || [])) {
|
|
33
|
+
const list = adapters.join(', ')
|
|
34
|
+
throw new Error(
|
|
35
|
+
`--host requires a value when running non-interactively. Known adapters: ${list}.`
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// promptSelect doesn't expose initial-index, so move the preselect to
|
|
40
|
+
// the top of the list — the menu still highlights index 0 by default.
|
|
41
|
+
const ordered = preselect && adapters.includes(preselect)
|
|
42
|
+
? [preselect, ...adapters.filter(a => a !== preselect)]
|
|
43
|
+
: adapters
|
|
44
|
+
|
|
45
|
+
const choice = await promptSelect('Pick a host adapter:', ordered)
|
|
46
|
+
if (!choice) {
|
|
47
|
+
throw new Error('Host selection cancelled.')
|
|
48
|
+
}
|
|
49
|
+
return choice
|
|
50
|
+
}
|
|
@@ -52,15 +52,46 @@ function writeState(state) {
|
|
|
52
52
|
|
|
53
53
|
/**
|
|
54
54
|
* Print update notification to stderr (doesn't interfere with piped output).
|
|
55
|
+
* `tone` controls the lead-in: 'soft' (default — trailing notice for finished
|
|
56
|
+
* commands) vs 'eager' (leading notice for staleness-sensitive commands like
|
|
57
|
+
* `create`, where the user is about to scaffold files from CLI-bundled
|
|
58
|
+
* templates and a stale CLI means stale starter content).
|
|
55
59
|
*/
|
|
56
|
-
function printNotification(current, latest) {
|
|
60
|
+
function printNotification(current, latest, tone = 'soft') {
|
|
57
61
|
const yellow = '\x1b[33m'
|
|
58
62
|
const cyan = '\x1b[36m'
|
|
59
63
|
const dim = '\x1b[2m'
|
|
60
64
|
const reset = '\x1b[0m'
|
|
61
65
|
console.error('')
|
|
62
|
-
|
|
63
|
-
|
|
66
|
+
if (tone === 'eager') {
|
|
67
|
+
console.error(`${yellow}Heads up:${reset} this CLI is ${dim}${current}${reset}; latest is ${cyan}${latest}${reset}.`)
|
|
68
|
+
console.error(`${dim}Templates ship with the CLI — consider updating first:${reset} npm i -g uniweb`)
|
|
69
|
+
console.error(`${dim}Or run a one-shot fresh:${reset} npx uniweb@latest <command>`)
|
|
70
|
+
} else {
|
|
71
|
+
console.error(`${yellow}Update available:${reset} ${dim}${current}${reset} → ${cyan}${latest}${reset}`)
|
|
72
|
+
console.error(`${dim}Run${reset} npm i -g uniweb ${dim}to update${reset}`)
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Synchronously read the cache and print an eager notification if a newer
|
|
78
|
+
* version is known. No network fetch — only reads what `startUpdateCheck`
|
|
79
|
+
* has previously cached. Returns true if a notification was printed.
|
|
80
|
+
*
|
|
81
|
+
* Use this for staleness-sensitive verbs (`create`) BEFORE the verb does
|
|
82
|
+
* its work, so the user sees the warning before any files are written
|
|
83
|
+
* from CLI-bundled templates. For other verbs, the trailing soft
|
|
84
|
+
* notification from startUpdateCheck() is sufficient.
|
|
85
|
+
*
|
|
86
|
+
* @param {string} currentVersion
|
|
87
|
+
* @returns {boolean} true if a notification was printed
|
|
88
|
+
*/
|
|
89
|
+
export function maybeEagerNotification(currentVersion) {
|
|
90
|
+
const state = readState()
|
|
91
|
+
if (!state.latestVersion) return false
|
|
92
|
+
if (compareSemver(state.latestVersion, currentVersion) <= 0) return false
|
|
93
|
+
printNotification(currentVersion, state.latestVersion, 'eager')
|
|
94
|
+
return true
|
|
64
95
|
}
|
|
65
96
|
|
|
66
97
|
/**
|