D1: deployment UI, docs and G17
Servers dialog (write-only keychain secret, test connection, unknown and changed host key), status-bar progress with Cancel, Deployment log tool window, Upload/Download in the project tree menu and Tools › Deployment. docs/deployment.md, architecture section, G17 row. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
f3c9ef9ce3
commit
872b5cb258
22 changed files with 2628 additions and 26 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
|
@ -3236,6 +3236,7 @@ dependencies = [
|
||||||
name = "lutra-engine"
|
name = "lutra-engine"
|
||||||
version = "0.1.0-alpha"
|
version = "0.1.0-alpha"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"lutra-deploy",
|
||||||
"lutra-index",
|
"lutra-index",
|
||||||
"lutra-lsp",
|
"lutra-lsp",
|
||||||
"lutra-proc",
|
"lutra-proc",
|
||||||
|
|
|
||||||
|
|
@ -972,7 +972,7 @@ impl Command for TestConnection {
|
||||||
&CommandSpec {
|
&CommandSpec {
|
||||||
id: "deploy.testConnection",
|
id: "deploy.testConnection",
|
||||||
label: "Deployment: Test Connection",
|
label: "Deployment: Test Connection",
|
||||||
menu_path: Some("Tools/Deployment/Test Connection"),
|
menu_path: None,
|
||||||
default_shortcut: None,
|
default_shortcut: None,
|
||||||
params: "{ id?: server id (default server when absent) }; returns { ok: true, message } or { ok: false, message, hostKey?: { status: unknown|changed, host, algorithm, fingerprint, known? }, needsSecret?: password|passphrase, authFailed?: true }; other failures are errors",
|
params: "{ id?: server id (default server when absent) }; returns { ok: true, message } or { ok: false, message, hostKey?: { status: unknown|changed, host, algorithm, fingerprint, known? }, needsSecret?: password|passphrase, authFailed?: true }; other failures are errors",
|
||||||
}
|
}
|
||||||
|
|
@ -1095,7 +1095,7 @@ impl Command for Upload {
|
||||||
&CommandSpec {
|
&CommandSpec {
|
||||||
id: "deploy.upload",
|
id: "deploy.upload",
|
||||||
label: "Deployment: Upload to Server",
|
label: "Deployment: Upload to Server",
|
||||||
menu_path: Some("Tools/Deployment/Upload to Default Server"),
|
menu_path: None,
|
||||||
default_shortcut: None,
|
default_shortcut: None,
|
||||||
params: "{ paths: [project-relative file or folder, \"\" for the whole project], id?: server id (default server when absent) }; returns { files, bytes, skipped, failed }; progress as deployProgress, lines as deployLog; deploy.cancel stops it",
|
params: "{ paths: [project-relative file or folder, \"\" for the whole project], id?: server id (default server when absent) }; returns { files, bytes, skipped, failed }; progress as deployProgress, lines as deployLog; deploy.cancel stops it",
|
||||||
}
|
}
|
||||||
|
|
@ -1121,7 +1121,7 @@ impl Command for Download {
|
||||||
&CommandSpec {
|
&CommandSpec {
|
||||||
id: "deploy.download",
|
id: "deploy.download",
|
||||||
label: "Deployment: Download from Server",
|
label: "Deployment: Download from Server",
|
||||||
menu_path: Some("Tools/Deployment/Download from Default Server"),
|
menu_path: None,
|
||||||
default_shortcut: None,
|
default_shortcut: None,
|
||||||
params: "{ paths: [project-relative file or folder], id?: server id (default server when absent) }; replaces the local files; returns { files, bytes, skipped, failed }; progress as deployProgress; deploy.cancel stops it",
|
params: "{ paths: [project-relative file or folder], id?: server id (default server when absent) }; replaces the local files; returns { files, bytes, skipped, failed }; progress as deployProgress; deploy.cancel stops it",
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ crates/engine (L4) command registry, workspace state, guard, recovery jou
|
||||||
crates/lsp (L3) LSP client (Phpactor first), later DAP client
|
crates/lsp (L3) LSP client (Phpactor first), later DAP client
|
||||||
crates/terminal (L3) pseudo-terminal sessions (portable-pty)
|
crates/terminal (L3) pseudo-terminal sessions (portable-pty)
|
||||||
crates/vcs (L3) Git through the installed git command
|
crates/vcs (L3) Git through the installed git command
|
||||||
|
crates/deploy (L3) deployment: SFTP, FTP/FTPS, folder; keychain secrets, known hosts
|
||||||
crates/index (L2) symbol index, usages, later type inference
|
crates/index (L2) symbol index, usages, later type inference
|
||||||
crates/vfs (L2) project model, file watching, ignore rules, encodings
|
crates/vfs (L2) project model, file watching, ignore rules, encodings
|
||||||
crates/search (L2) find in files (ignore + grep-searcher crates)
|
crates/search (L2) find in files (ignore + grep-searcher crates)
|
||||||
|
|
@ -752,6 +753,15 @@ Watched directories: the VFS watcher is non-recursive, so `project.children` wat
|
||||||
- **Checked in the app** (debug build with the bundled UI, Windows 11, git 2.47.1, control port 7949, a demo repository with two stashes on two branches and a modified file; commands and screenshots only, no input): `git.stashList` 143–157 ms, `git.stash` 640 ms, a pop 366 ms, each including the control round trip. The refusals came back as written above: applying onto a modified file ("would be overwritten" with git's text), nothing to stash (with the untracked hint), a missing entry. Screenshots of the list (`stash@{n}`, WIP text, branch, date; Drop, Pop, Apply) and of the form, plus the two new buttons in the Changes bar, read in the dark theme.
|
- **Checked in the app** (debug build with the bundled UI, Windows 11, git 2.47.1, control port 7949, a demo repository with two stashes on two branches and a modified file; commands and screenshots only, no input): `git.stashList` 143–157 ms, `git.stash` 640 ms, a pop 366 ms, each including the control round trip. The refusals came back as written above: applying onto a modified file ("would be overwritten" with git's text), nothing to stash (with the untracked hint), a missing entry. Screenshots of the list (`stash@{n}`, WIP text, branch, date; Drop, Pop, Apply) and of the form, plus the two new buttons in the Changes bar, read in the dark theme.
|
||||||
- **Tests:** `crates/vcs/tests/stash.rs` (6 tests against real temp repositories: stash with and without a message, list order and hashes, apply, pop by an abbreviated hash, drop; untracked files only with the flag, including a nested folder and a name starting with `-`; no commit and nothing to stash; a missing and a changed entry, a bad hash; overwritten local changes and untracked files in the way, both leaving the work tree and the entry alone; a conflicted pop keeping the entry and blocking the next stash and apply); unit and property tests in `stash.rs` (list and subject parsing, message cleaning, unmerged counting, hints, chunking); `crates/engine/tests/git_stash.rs` (the command shapes, `gitChanged` only after changes, a changed hash, an empty stash, bad params); Vitest `ui/tests/vcs/Stash.test.ts` (13 tests: parsing, the form with `flushDirty` first, a blank message, a refusal, a failed save, Escape and focus, the list with keyboard and apply, a conflicted pop, the drop question, an empty stash, a failed read, the commands' registration, the Changes window's buttons).
|
- **Tests:** `crates/vcs/tests/stash.rs` (6 tests against real temp repositories: stash with and without a message, list order and hashes, apply, pop by an abbreviated hash, drop; untracked files only with the flag, including a nested folder and a name starting with `-`; no commit and nothing to stash; a missing and a changed entry, a bad hash; overwritten local changes and untracked files in the way, both leaving the work tree and the entry alone; a conflicted pop keeping the entry and blocking the next stash and apply); unit and property tests in `stash.rs` (list and subject parsing, message cleaning, unmerged counting, hints, chunking); `crates/engine/tests/git_stash.rs` (the command shapes, `gitChanged` only after changes, a changed hash, an empty stash, bad params); Vitest `ui/tests/vcs/Stash.test.ts` (13 tests: parsing, the form with `flushDirty` first, a blank message, a refusal, a failed save, Escape and focus, the list with keyboard and apply, a conflicted pop, the drop question, an empty stash, a failed read, the commands' registration, the Changes window's buttons).
|
||||||
|
|
||||||
|
### Deployment (C9 D1)
|
||||||
|
|
||||||
|
- **Owner decision D27 (2026-11-02):** pure-Rust libraries (`russh` + `russh-sftp` with `ring`, `suppaftp` with `rustls`/`ring`, `keyring`); secrets only in the OS keychain. User guide: [`deployment.md`](deployment.md).
|
||||||
|
- **Crate (`crates/deploy`, L3):** `config` (servers per project, `deny_unknown_fields` so a hand-written `password` field is refused), `mapping` (longest local prefix wins, no `..`, excluded paths and `*`/`?` name patterns; unit and property tests), `secrets` (`SecretStore` trait, `Keychain`, `MemoryStore`; `Secret` debug-prints as `***`), `known_hosts` (Lutra's own file; unknown → `HostKeyUnknown`, different → `HostKeyMismatch`, checked before any credential is sent), `remote` (the `Remote` trait: `mkdir_all`, `put`, `get`, `kind`, `list`, `close`; the extension point for D2), `sftp`, `ftp`, `job` (plan, connect once, transfer file by file; a `Monitor` holds progress and log lines; a `Cancel` flag is checked between 32 KiB chunks and races every SFTP wait). Every library error passes `DeployError::redacted` with the secret in use. Names from remote listings are checked before they become local paths.
|
||||||
|
- **Test servers** (feature `testserver`, 127.0.0.1 only): a russh SFTP server over a folder with a fixed Ed25519 host key, and a small FTP server. Example `testserver` runs both for live checks.
|
||||||
|
- **Engine (`cmd/deploy.rs`):** configuration at `<config_dir>/deployment/<project-id>.json`, known hosts at `<config_dir>/deployment/known_hosts`, keychain account `<project-id>/<server-id>/<password|passphrase>`. Commands: `deploy.servers`, `deploy.saveServer {server, secret?}`, `deploy.removeServer`, `deploy.setDefault`, `deploy.setSecret`, `deploy.clearSecret`, `deploy.testConnection {id?}` (an unknown or changed host key, a missing secret or a refused sign-in is a value with `ok: false`), `deploy.trustHostKey {id, algorithm, fingerprint, replace?}`, `deploy.upload {paths, id?}`, `deploy.download {paths, id?}`, `deploy.cancel`, `deploy.log`, `deploy.clearLog`. Jobs are pending outcomes on a `lutra-deploy` thread; one at a time. `file.save` and `file.saveAll` queue uploads on save, which the pump starts and finishes. Events: `deployProgress`, `deployLog {entry}`. `Engine::set_secret_store` swaps the keychain (tests).
|
||||||
|
- **UI (`ui/src/components/deploy/`):** `deploy.ts` store, `DeployStatusItem.vue` (progress, Cancel, the `deployment.*` UI commands), `DeploymentDialog.vue` (exclusive modal `deployment`; write-only secret field; host-key question), `DeploymentLogToolWindow.vue` (bottom panel). The project tree's context menu gains Upload/Download for files and folders.
|
||||||
|
- **Tests:** `crates/deploy/tests/transfer.rs` (7: host key first use and mismatch, password and key sign-in, upload, download, cancel, FTP, unreachable), `crates/engine/tests/deploy.rs` (4, including a grep of every event, value, error and the config and data directories for the test password), `ui/tests/deploy/Deploy.test.ts` (12).
|
||||||
|
|
||||||
## Decisions (M0)
|
## Decisions (M0)
|
||||||
|
|
||||||
| Question | Decision | Why |
|
| Question | Decision | Why |
|
||||||
|
|
@ -772,6 +782,7 @@ Watched directories: the VFS watcher is non-recursive, so `project.children` wat
|
||||||
|
|
||||||
| Date | Change | Summary |
|
| Date | Change | Summary |
|
||||||
|---|---|---|
|
|---|---|---|
|
||||||
|
| 2026-11-06 | minor | C9 D1: `crates/deploy` (L3), `deploy.*` commands, deployment events and UI |
|
||||||
| 2026-11-02 | minor | C9 F1: `Kind::Path` and `check_path` (one validator for `settings.set` and the dialog, `path` in `settings.list`), `lutra_proc::spawn_detached` for the CLI's desktop start |
|
| 2026-11-02 | minor | C9 F1: `Kind::Path` and `check_path` (one validator for `settings.set` and the dialog, `path` in `settings.list`), `lutra_proc::spawn_detached` for the CLI's desktop start |
|
||||||
| 2026-10-31 | minor | C7 B1: app identifier `com.tyrveil.lutra` with the one-time copy from `dev.lutra.desktop`, NSIS and DMG installers, `cargo xtask bundle` |
|
| 2026-10-31 | minor | C7 B1: app identifier `com.tyrveil.lutra` with the one-time copy from `dev.lutra.desktop`, NSIS and DMG installers, `cargo xtask bundle` |
|
||||||
| 2026-10-31 | minor | C7 A3: `git.mergeMessage` and the merge message prefill, `git.ignore` and the Changes context menu, gutter markers kept on their line, per-module `COMMAND_IDS` for the command listing test |
|
| 2026-10-31 | minor | C7 A3: `git.mergeMessage` and the merge message prefill, `git.ignore` and the Changes context menu, gutter markers kept on their line, per-module `COMMAND_IDS` for the command listing test |
|
||||||
|
|
|
||||||
54
docs/deployment.md
Normal file
54
docs/deployment.md
Normal file
|
|
@ -0,0 +1,54 @@
|
||||||
|
# Deployment
|
||||||
|
|
||||||
|
> **Status:** Deployment v1 (C9 D1, owner decision D27): servers per project, upload, download, upload on save, test connection, host keys, Deployment log. Remote browser, compare and sync follow in D2 · **Last updated:** 2026-11-06
|
||||||
|
|
||||||
|
Lutra uploads a PHP project to a server and downloads files back, the way people deploy shared hosting and small servers every day.
|
||||||
|
|
||||||
|
## Servers
|
||||||
|
|
||||||
|
Open **Tools › Deployment › Servers…**. Each project has its own list; one is the default server (the only one is the default automatically).
|
||||||
|
|
||||||
|
| Field | Meaning |
|
||||||
|
|---|---|
|
||||||
|
| Name | Shown in the log, the status bar and toasts. |
|
||||||
|
| Type | **SFTP** (SSH), **FTPS** (FTP with explicit TLS, certificates checked against the system's trusted roots), **FTP** (unencrypted: everything, including the password, crosses the network in clear text; prefer SFTP or FTPS), or a **local or mounted folder**. |
|
||||||
|
| Host, Port, User | Port defaults to 22 (SFTP) or 21 (FTP, FTPS). |
|
||||||
|
| Sign in with | SFTP: password, private key file (with an optional passphrase), or the SSH agent (Pageant or the OpenSSH Authentication Agent on Windows, `SSH_AUTH_SOCK` on macOS). FTP and FTPS: password. |
|
||||||
|
| Root folder | The server folder everything is relative to; empty for the login folder. For a folder server: the absolute local folder. |
|
||||||
|
| Path mappings | Local folder (project-relative, empty for the root) → remote folder (relative to the root, or absolute with a leading `/`). The longest matching local folder wins. Without mappings the project root goes to the root. Files outside every mapping are skipped. |
|
||||||
|
| Excluded paths | One per line. A path excludes itself and everything below it (`var/cache`); a pattern with `*` or `?` matches file and folder names (`*.log`). `.git`, `.svn` and `.hg` are never deployed. |
|
||||||
|
| Upload on save | Off by default. When on, every saved file that maps to the server is uploaded in the background. |
|
||||||
|
|
||||||
|
The configuration lives in Lutra's config directory (`deployment/<project-id>.json`), not in the project, and never contains a password.
|
||||||
|
|
||||||
|
## Passwords and passphrases
|
||||||
|
|
||||||
|
- They are stored **only in the operating system's keychain**: the Windows Credential Manager or the macOS Keychain, under the service "Lutra Deployment".
|
||||||
|
- Lutra never writes them to a file, a log, the recovery journal, an event, MCP or control-channel output, or an error message. The password field in the dialog is write-only: after Save it empties again and says "Stored in the system keychain".
|
||||||
|
- Removing a server removes its keychain entries.
|
||||||
|
- Linux has no keychain store yet; there, use the SSH agent or a key without a passphrase.
|
||||||
|
|
||||||
|
## Host keys (SFTP)
|
||||||
|
|
||||||
|
On the first connection, **Test Connection** shows the server's key fingerprint (`ssh-ed25519 SHA256:…`). Compare it with the one from the server's administrator, then choose **Trust and Connect**. Trusted keys are kept in Lutra's own known-hosts file (`deployment/known_hosts` in the config directory); `~/.ssh/known_hosts` is neither read nor changed.
|
||||||
|
|
||||||
|
If the key later differs, Lutra **refuses to connect** and says so: someone may be intercepting the connection. Only if you know the server was reinstalled, test the connection and choose **Replace the Trusted Key**.
|
||||||
|
|
||||||
|
Uploads and downloads never ask about a key; they fail with a message pointing to Test Connection.
|
||||||
|
|
||||||
|
## Upload and download
|
||||||
|
|
||||||
|
- **Project tree:** right-click a file or folder › **Upload to Server** / **Download from Server** (default server).
|
||||||
|
- **Tools › Deployment:** Upload Current File, Download Current File, Upload Project, Test Connection, Deployment Log.
|
||||||
|
- The same actions are in the command palette. Lutra assigns no default shortcuts; bind them in the keymap.
|
||||||
|
- Uploads send what is on disk; save first. Downloads replace the local files.
|
||||||
|
- While a job runs, the status bar shows it with a Cancel button. One job runs at a time; uploads on save wait for the running one.
|
||||||
|
- Every file, skip and error goes to the **Deployment** log in the bottom panel (newest 1,000 lines). A failing file is logged and the job goes on; a lost connection or a refused sign-in stops it. Each error says what to do.
|
||||||
|
|
||||||
|
## For agents and scripts
|
||||||
|
|
||||||
|
The `deploy.*` engine commands (`deploy.servers`, `deploy.saveServer`, `deploy.setSecret`, `deploy.testConnection`, `deploy.trustHostKey`, `deploy.upload`, `deploy.download`, `deploy.cancel`, `deploy.log`, …) work over the control channel and MCP like every command; see `docs/architecture.md` › Deployment. Their results never contain a secret.
|
||||||
|
|
||||||
|
## Not yet (D2)
|
||||||
|
|
||||||
|
A remote file browser, opening and editing remote files, compare with the server, and sync with a preview.
|
||||||
|
|
@ -22,7 +22,7 @@ Every known shortfall, ranked. This is the work list: unless the owner gives a t
|
||||||
| G14 | Localization: English and German interface: ~~English message catalog for UI strings~~ (M1.11), engine messages (`EngineError.message`) as message keys, language switch, plurals, German catalog | later | ~38 h |
|
| G14 | Localization: English and German interface: ~~English message catalog for UI strings~~ (M1.11), engine messages (`EngineError.message`) as message keys, language switch, plurals, German catalog | later | ~38 h |
|
||||||
| G15 | Database tools, HTTP client, Docker and remote | later | ~430 h |
|
| G15 | Database tools, HTTP client, Docker and remote | later | ~430 h |
|
||||||
| G16 | Plug-ins and ecosystem | later | ~120 h |
|
| G16 | Plug-ins and ecosystem | later | ~120 h |
|
||||||
| G17 | Deployment: servers (FTP, SFTP, local/mounted), path mappings, upload/download, compare with server, edit remote files, save before deploy, optional upload on save per server (owner wish 2026-10-18; needs credential storage and network access, §4) | M7 | ~120 h |
|
| G17 | Deployment: **v1 done (C9 D1)**: SFTP, FTP, FTPS and folder servers per project, path mappings, excluded paths, upload/download of files and folders, upload on save (off by default), test connection, host-key check, keychain secrets, Deployment log. Open (D2): remote browser, edit remote files, compare with server, sync with preview | M7 | ~40 h |
|
||||||
| G18 | Editor productivity: Local History, live and file templates, postfix completion, code generation, intention actions, auto import, scratch files, macros, compare files/folders, TODO view, language injections, code style/formatter | M6–M7 | ~400 h |
|
| G18 | Editor productivity: Local History, live and file templates, postfix completion, code generation, intention actions, auto import, scratch files, macros, compare files/folders, TODO view, language injections, code style/formatter | M6–M7 | ~400 h |
|
||||||
| G19 | Remote development and Dev Containers | M9 | ~200 h |
|
| G19 | Remote development and Dev Containers | M9 | ~200 h |
|
||||||
| G20 | AI features (chat, inline prompts, commit messages); MCP server is G7/M3 | M9 | ~60 h |
|
| G20 | AI features (chat, inline prompts, commit messages); MCP server is G7/M3 | M9 | ~60 h |
|
||||||
|
|
@ -55,6 +55,7 @@ G6 progress: M3.2 landed the LSP client library in `crates/lsp`: JSON-RPC framin
|
||||||
|
|
||||||
| Date | Change | Summary |
|
| Date | Change | Summary |
|
||||||
|---|---|---|
|
|---|---|---|
|
||||||
|
| 2026-11-06 | patch | G17: deployment v1 (C9 D1); remote browser, compare and sync left for D2 |
|
||||||
| 2026-11-01 | patch | G8: chunk staging, unstaging and revert from the gutter and the diff viewer (C8 C3) |
|
| 2026-11-01 | patch | G8: chunk staging, unstaging and revert from the gutter and the diff viewer (C8 C3) |
|
||||||
| 2026-10-31 | patch | C7 review: stray revision rows moved here; installers (B1, B2) and the alpha checklist (A2) change no gap |
|
| 2026-10-31 | patch | C7 review: stray revision rows moved here; installers (B1, B2) and the alpha checklist (A2) change no gap |
|
||||||
| 2026-10-31 | patch | A1: macOS system menus (G3), Retina region for the macOS screenshot fallback |
|
| 2026-10-31 | patch | A1: macOS system menus (G3), Retina region for the macOS screenshot fallback |
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,8 @@
|
||||||
* - **Navigation (M3.5):** the definition picker and the inline rename field
|
* - **Navigation (M3.5):** the definition picker and the inline rename field
|
||||||
* are exclusive modals too. So is the branches popup (M4.5), and so are
|
* are exclusive modals too. So is the branches popup (M4.5), and so are
|
||||||
* "Clone Repository…" and "Manage Remotes…" (M4.10), the merge
|
* "Clone Repository…" and "Manage Remotes…" (M4.10), the merge
|
||||||
* dialog (M4.8) and the stash dialog (M4.9).
|
* dialog (M4.8) and the stash dialog (M4.9), and the deployment servers
|
||||||
|
* dialog (G17).
|
||||||
*/
|
*/
|
||||||
import { defineStore } from "pinia";
|
import { defineStore } from "pinia";
|
||||||
import { ref, watch } from "vue";
|
import { ref, watch } from "vue";
|
||||||
|
|
@ -38,6 +39,7 @@ export type ModalId =
|
||||||
| "branches"
|
| "branches"
|
||||||
| "clone"
|
| "clone"
|
||||||
| "remotes"
|
| "remotes"
|
||||||
|
| "deployment"
|
||||||
| "merge"
|
| "merge"
|
||||||
| "stash";
|
| "stash";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,12 @@ export interface UiCommandSpec {
|
||||||
|
|
||||||
/** The frontend's UI commands. */
|
/** The frontend's UI commands. */
|
||||||
export const UI_COMMANDS: readonly UiCommandSpec[] = [
|
export const UI_COMMANDS: readonly UiCommandSpec[] = [
|
||||||
|
{ id: "deployment.download", labelKey: "command.deployment.download", menuPath: "Tools/Deployment/Download Current File" },
|
||||||
|
{ id: "deployment.servers", labelKey: "command.deployment.servers", menuPath: "Tools/Deployment/Servers…" },
|
||||||
|
{ id: "deployment.showLog", labelKey: "command.deployment.showLog", menuPath: "Tools/Deployment/Deployment Log" },
|
||||||
|
{ id: "deployment.testConnection", labelKey: "command.deployment.testConnection", menuPath: "Tools/Deployment/Test Connection" },
|
||||||
|
{ id: "deployment.upload", labelKey: "command.deployment.upload", menuPath: "Tools/Deployment/Upload Current File" },
|
||||||
|
{ id: "deployment.uploadProject", labelKey: "command.deployment.uploadProject", menuPath: "Tools/Deployment/Upload Project" },
|
||||||
{ id: "editor.reveal", labelKey: "command.editor.reveal" },
|
{ id: "editor.reveal", labelKey: "command.editor.reveal" },
|
||||||
{ id: "editor.complete", labelKey: "command.editor.complete", menuPath: "Edit/Complete Code" },
|
{ id: "editor.complete", labelKey: "command.editor.complete", menuPath: "Edit/Complete Code" },
|
||||||
{ id: "editor.quickDocumentation", labelKey: "command.editor.quickDocumentation", menuPath: "Edit/Quick Documentation", defaultShortcut: "Mod+I" },
|
{ id: "editor.quickDocumentation", labelKey: "command.editor.quickDocumentation", menuPath: "Edit/Quick Documentation", defaultShortcut: "Mod+I" },
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,14 @@
|
||||||
* Status bar along the bottom of the main window. Shows the product name and
|
* Status bar along the bottom of the main window. Shows the product name and
|
||||||
* version, or the last engine error, and on the right the language server's
|
* version, or the last engine error, and on the right the language server's
|
||||||
* progress (H3), a running fetch, pull, push or clone or the commits
|
* progress (H3), a running fetch, pull, push or clone or the commits
|
||||||
* ahead and behind (M4.10), and the Git branch (M4.5).
|
* ahead and behind (M4.10), a running deployment job (G17), and the Git
|
||||||
|
* branch (M4.5).
|
||||||
*/
|
*/
|
||||||
import { computed } from "vue";
|
import { computed } from "vue";
|
||||||
import { t } from "../i18n";
|
import { t } from "../i18n";
|
||||||
import { useAppStore } from "../stores/app";
|
import { useAppStore } from "../stores/app";
|
||||||
import LspProgressItem from "./problems/LspProgressItem.vue";
|
import LspProgressItem from "./problems/LspProgressItem.vue";
|
||||||
|
import DeployStatusItem from "./deploy/DeployStatusItem.vue";
|
||||||
import BranchStatusItem from "./vcs/branches/BranchStatusItem.vue";
|
import BranchStatusItem from "./vcs/branches/BranchStatusItem.vue";
|
||||||
import RemoteStatusItem from "./vcs/remote/RemoteStatusItem.vue";
|
import RemoteStatusItem from "./vcs/remote/RemoteStatusItem.vue";
|
||||||
|
|
||||||
|
|
@ -31,6 +33,7 @@ const label = computed(() => {
|
||||||
>
|
>
|
||||||
<span>{{ label }}</span>
|
<span>{{ label }}</span>
|
||||||
<LspProgressItem />
|
<LspProgressItem />
|
||||||
|
<DeployStatusItem />
|
||||||
<RemoteStatusItem />
|
<RemoteStatusItem />
|
||||||
<BranchStatusItem />
|
<BranchStatusItem />
|
||||||
</footer>
|
</footer>
|
||||||
|
|
|
||||||
233
ui/src/components/deploy/DeployStatusItem.vue
Normal file
233
ui/src/components/deploy/DeployStatusItem.vue
Normal file
|
|
@ -0,0 +1,233 @@
|
||||||
|
<script setup lang="ts">
|
||||||
|
/**
|
||||||
|
* Status-bar item of deployment (G17): while a test, upload or download
|
||||||
|
* runs, the server, the file count and the current file from
|
||||||
|
* `deployProgress`, and a Cancel button (`deploy.cancel`). Hidden
|
||||||
|
* otherwise.
|
||||||
|
*
|
||||||
|
* The item supplies the deployment UI commands, so they work wherever the
|
||||||
|
* status bar is shown (none has a default shortcut):
|
||||||
|
* - `deployment.upload {path?}` and `deployment.download {path?}`: the
|
||||||
|
* given project path (file or folder) or the active editor's file, to or
|
||||||
|
* from the default server. Without a default server the servers dialog
|
||||||
|
* opens instead;
|
||||||
|
* - `deployment.uploadProject`: the whole project;
|
||||||
|
* - `deployment.testConnection`: opens the servers dialog and tests the
|
||||||
|
* default server, so a host key can be checked there;
|
||||||
|
* - `deployment.servers`: opens the servers dialog.
|
||||||
|
* All are enabled with a project and while no job runs. It also mounts
|
||||||
|
* the dialog.
|
||||||
|
*/
|
||||||
|
import { LoaderCircle, X } from "@lucide/vue";
|
||||||
|
import { computed, onBeforeUnmount, onMounted } from "vue";
|
||||||
|
import { useCommandsStore } from "../../commands/store";
|
||||||
|
import { t } from "../../i18n";
|
||||||
|
import { useEditorStore } from "../../stores/editor";
|
||||||
|
import { useNotificationsStore } from "../../stores/notifications";
|
||||||
|
import { useProjectStore } from "../../stores/project";
|
||||||
|
import DeploymentDialog from "./DeploymentDialog.vue";
|
||||||
|
import { useDeployStore } from "./deploy";
|
||||||
|
|
||||||
|
const deploy = useDeployStore();
|
||||||
|
const commands = useCommandsStore();
|
||||||
|
const editor = useEditorStore();
|
||||||
|
const project = useProjectStore();
|
||||||
|
const notifications = useNotificationsStore();
|
||||||
|
|
||||||
|
/** The running job's text, or null while none runs. */
|
||||||
|
const progressText = computed(() => {
|
||||||
|
const p = deploy.progress;
|
||||||
|
if (p === null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
const operation =
|
||||||
|
p.operation === "test"
|
||||||
|
? t("deploy.operation.test")
|
||||||
|
: p.operation === "upload"
|
||||||
|
? t("deploy.operation.upload")
|
||||||
|
: t("deploy.operation.download");
|
||||||
|
if (p.filesTotal === 0) {
|
||||||
|
return t("deploy.progress.short", { operation, server: p.server });
|
||||||
|
}
|
||||||
|
return t("deploy.progress.files", {
|
||||||
|
operation,
|
||||||
|
server: p.server,
|
||||||
|
done: p.filesDone,
|
||||||
|
total: p.filesTotal,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The path a command acts on: its `path` param, else the active file.
|
||||||
|
*
|
||||||
|
* @param params - the command's params.
|
||||||
|
*/
|
||||||
|
function pathOf(params: unknown): string | null {
|
||||||
|
const given = (params as { path?: unknown } | null)?.path;
|
||||||
|
if (typeof given === "string") {
|
||||||
|
return given;
|
||||||
|
}
|
||||||
|
return editor.activeTab?.path ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Runs `action` against the default server, or opens the servers dialog
|
||||||
|
* when there is none.
|
||||||
|
*
|
||||||
|
* @param action - what to do with the default server.
|
||||||
|
*/
|
||||||
|
async function withTarget(action: () => Promise<unknown>): Promise<void> {
|
||||||
|
if (deploy.servers.length === 0) {
|
||||||
|
await deploy.load();
|
||||||
|
}
|
||||||
|
if (deploy.target === null) {
|
||||||
|
notifications.notify({ level: "warning", messageKey: "notification.deploy.noServer" });
|
||||||
|
await deploy.showDialog();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await action();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Withdraws the command handlers; filled while mounted. */
|
||||||
|
let withdraw: (() => void)[] = [];
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
deploy.start();
|
||||||
|
if (project.root !== null) {
|
||||||
|
void deploy.load();
|
||||||
|
}
|
||||||
|
const idle = (): boolean => project.root !== null && !deploy.busy;
|
||||||
|
withdraw = [
|
||||||
|
commands.provide("deployment.upload", {
|
||||||
|
run: async (params) => {
|
||||||
|
const path = pathOf(params);
|
||||||
|
if (path !== null) {
|
||||||
|
await withTarget(() => deploy.upload([path]));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
enabled: idle,
|
||||||
|
}),
|
||||||
|
commands.provide("deployment.download", {
|
||||||
|
run: async (params) => {
|
||||||
|
const path = pathOf(params);
|
||||||
|
if (path !== null) {
|
||||||
|
await withTarget(() => deploy.download([path]));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
enabled: idle,
|
||||||
|
}),
|
||||||
|
commands.provide("deployment.uploadProject", {
|
||||||
|
run: () => withTarget(() => deploy.upload([""])),
|
||||||
|
enabled: idle,
|
||||||
|
}),
|
||||||
|
commands.provide("deployment.testConnection", {
|
||||||
|
run: async () => {
|
||||||
|
await deploy.showDialog();
|
||||||
|
const target = deploy.target;
|
||||||
|
if (target !== null) {
|
||||||
|
await deploy.testConnection(target.id);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
enabled: idle,
|
||||||
|
}),
|
||||||
|
commands.provide("deployment.servers", {
|
||||||
|
run: () => deploy.showDialog(),
|
||||||
|
enabled: () => project.root !== null,
|
||||||
|
}),
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
onBeforeUnmount(() => {
|
||||||
|
for (const fn of withdraw) {
|
||||||
|
fn();
|
||||||
|
}
|
||||||
|
withdraw = [];
|
||||||
|
deploy.stop();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<span
|
||||||
|
v-if="progressText !== null"
|
||||||
|
class="deploy-item"
|
||||||
|
role="status"
|
||||||
|
:title="deploy.progress?.file || progressText"
|
||||||
|
data-test="deploy-progress"
|
||||||
|
>
|
||||||
|
<LoaderCircle
|
||||||
|
class="deploy-item__icon"
|
||||||
|
:size="12"
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
|
<span class="deploy-item__text">{{ progressText }}</span>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="deploy-item__cancel"
|
||||||
|
:title="t('deploy.cancel')"
|
||||||
|
:aria-label="t('deploy.cancel')"
|
||||||
|
data-test="deploy-cancel"
|
||||||
|
@click="deploy.cancel()"
|
||||||
|
>
|
||||||
|
<X
|
||||||
|
:size="12"
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
|
</button>
|
||||||
|
</span>
|
||||||
|
<DeploymentDialog />
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.deploy-item {
|
||||||
|
display: inline-flex;
|
||||||
|
margin-left: auto;
|
||||||
|
align-items: center;
|
||||||
|
gap: 4px;
|
||||||
|
padding: 0 6px;
|
||||||
|
min-width: 0;
|
||||||
|
max-width: 35%;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.deploy-item__text {
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
|
.deploy-item__icon {
|
||||||
|
flex: none;
|
||||||
|
animation: deploy-item-spin 1.2s linear infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-reduced-motion: reduce) {
|
||||||
|
.deploy-item__icon {
|
||||||
|
animation: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes deploy-item-spin {
|
||||||
|
to {
|
||||||
|
transform: rotate(360deg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.deploy-item__cancel {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
padding: 0 2px;
|
||||||
|
font: inherit;
|
||||||
|
color: inherit;
|
||||||
|
background: transparent;
|
||||||
|
border: none;
|
||||||
|
border-radius: var(--lt-radius, 4px);
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.deploy-item__cancel:hover {
|
||||||
|
background: color-mix(in srgb, var(--lt-statusbar-fg) 12%, transparent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.deploy-item__cancel:focus-visible {
|
||||||
|
outline: 2px solid var(--lt-accent);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
867
ui/src/components/deploy/DeploymentDialog.vue
Normal file
867
ui/src/components/deploy/DeploymentDialog.vue
Normal file
|
|
@ -0,0 +1,867 @@
|
||||||
|
<script setup lang="ts">
|
||||||
|
/**
|
||||||
|
* "Deployment Servers…" (G17): the project's servers on the left, the
|
||||||
|
* selected one's settings on the right.
|
||||||
|
*
|
||||||
|
* - **Fields:** name, type (SFTP, FTP, FTPS, local or mounted folder),
|
||||||
|
* host, port, user, root folder, sign-in (password, key file with an
|
||||||
|
* optional passphrase, or the SSH agent for SFTP), path mappings,
|
||||||
|
* excluded paths (one per line), upload on save (off by default) and
|
||||||
|
* "default server".
|
||||||
|
* - **Secrets:** the password or passphrase field is write-only. A typed
|
||||||
|
* value goes to the engine with Save and is kept only in the OS
|
||||||
|
* keychain; the field then empties again and says that one is stored.
|
||||||
|
* - **Test Connection** saves first, then tests. An unknown SFTP host key
|
||||||
|
* shows its fingerprint with "Trust and Connect"; a changed one is a
|
||||||
|
* warning whose replace button must be chosen explicitly.
|
||||||
|
* - Remove asks in place. Escape closes. The dialog is an exclusive modal
|
||||||
|
* (`commands/modals.ts`).
|
||||||
|
*/
|
||||||
|
import { computed, nextTick, ref, watch } from "vue";
|
||||||
|
import { useModalsStore } from "../../commands/modals";
|
||||||
|
import { t } from "../../i18n";
|
||||||
|
import { pickDir, pickFile } from "../../ipc";
|
||||||
|
import { blankServer, useDeployStore, type DeployServer, type ServerKind } from "./deploy";
|
||||||
|
|
||||||
|
const deploy = useDeployStore();
|
||||||
|
const modals = useModalsStore();
|
||||||
|
|
||||||
|
/** The selected server's id, "" for a new one. */
|
||||||
|
const selected = ref<string>("");
|
||||||
|
/** The form's values. */
|
||||||
|
const form = ref<DeployServer>(blankServer());
|
||||||
|
/** The typed password or passphrase, sent once with Save. */
|
||||||
|
const secret = ref("");
|
||||||
|
/** Whether the form's server is (to become) the default. */
|
||||||
|
const isDefault = ref(false);
|
||||||
|
/** The excluded paths, one per line. */
|
||||||
|
const excludedText = ref("");
|
||||||
|
/** Whether Remove waits for its confirmation. */
|
||||||
|
const confirmRemove = ref(false);
|
||||||
|
/** Whether Save or Test runs. */
|
||||||
|
const working = ref(false);
|
||||||
|
/** The name field. */
|
||||||
|
const nameInput = ref<HTMLInputElement | null>(null);
|
||||||
|
/** The host-key question box. */
|
||||||
|
const questionBox = ref<HTMLElement | null>(null);
|
||||||
|
/** The element that had the focus before the dialog opened. */
|
||||||
|
let returnFocus: HTMLElement | null = null;
|
||||||
|
|
||||||
|
/** Server types in the select, with their labels. */
|
||||||
|
const kindLabels = computed<{ id: ServerKind; label: string }[]>(() => [
|
||||||
|
{ id: "sftp", label: t("deploy.kind.sftp") },
|
||||||
|
{ id: "ftps", label: t("deploy.kind.ftps") },
|
||||||
|
{ id: "ftp", label: t("deploy.kind.ftp") },
|
||||||
|
{ id: "folder", label: t("deploy.kind.folder") },
|
||||||
|
]);
|
||||||
|
|
||||||
|
/** Whether the form needs a host, user and port. */
|
||||||
|
const remote = computed(() => form.value.kind !== "folder");
|
||||||
|
|
||||||
|
/** The secret the form's server needs, or null. */
|
||||||
|
const secretKind = computed<"password" | "passphrase" | null>(() => {
|
||||||
|
if (form.value.kind === "folder" || (form.value.kind === "sftp" && form.value.auth === "agent")) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return form.value.kind === "sftp" && form.value.auth === "key" ? "passphrase" : "password";
|
||||||
|
});
|
||||||
|
|
||||||
|
/** Whether the selected server has its secret in the keychain. */
|
||||||
|
const hasSecret = computed(() => deploy.servers.find((s) => s.id === selected.value)?.hasSecret === true);
|
||||||
|
|
||||||
|
/** The port field as text; empty means the default port. */
|
||||||
|
const portText = computed({
|
||||||
|
get: () => (form.value.port === null ? "" : String(form.value.port)),
|
||||||
|
set: (text: string) => {
|
||||||
|
const n = Number.parseInt(text, 10);
|
||||||
|
form.value.port = text.trim() === "" || !Number.isFinite(n) ? null : n;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
/** The key path field as text. */
|
||||||
|
const keyText = computed({
|
||||||
|
get: () => form.value.keyPath ?? "",
|
||||||
|
set: (text: string) => {
|
||||||
|
form.value.keyPath = text === "" ? null : text;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shows a server in the form.
|
||||||
|
*
|
||||||
|
* @param id - its id, or "" for a new server.
|
||||||
|
*/
|
||||||
|
function select(id: string): void {
|
||||||
|
const server = deploy.servers.find((s) => s.id === id);
|
||||||
|
const copy = server ? { ...server, mappings: server.mappings.map((m) => ({ ...m })), excluded: [...server.excluded] } : blankServer();
|
||||||
|
selected.value = server ? id : "";
|
||||||
|
form.value = copy;
|
||||||
|
secret.value = "";
|
||||||
|
isDefault.value = server ? deploy.defaultServer === id || deploy.servers.length === 1 : deploy.servers.length === 0;
|
||||||
|
excludedText.value = copy.excluded.join("\n");
|
||||||
|
confirmRemove.value = false;
|
||||||
|
deploy.tested = null;
|
||||||
|
deploy.question = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Starts a new server. */
|
||||||
|
async function addNew(): Promise<void> {
|
||||||
|
select("");
|
||||||
|
await nextTick();
|
||||||
|
nameInput.value?.focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Adds an empty mapping row. */
|
||||||
|
function addMapping(): void {
|
||||||
|
form.value.mappings = [...form.value.mappings, { local: "", remote: "" }];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes a mapping row.
|
||||||
|
*
|
||||||
|
* @param index - the row.
|
||||||
|
*/
|
||||||
|
function removeMapping(index: number): void {
|
||||||
|
form.value.mappings = form.value.mappings.filter((_, i) => i !== index);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Saves the form.
|
||||||
|
*
|
||||||
|
* @returns the saved server's id, or null.
|
||||||
|
*/
|
||||||
|
async function save(): Promise<string | null> {
|
||||||
|
working.value = true;
|
||||||
|
try {
|
||||||
|
form.value.excluded = excludedText.value.split(/\r?\n/);
|
||||||
|
const id = await deploy.saveServer(form.value, secretKind.value === null ? "" : secret.value, isDefault.value);
|
||||||
|
if (id !== null) {
|
||||||
|
select(id);
|
||||||
|
}
|
||||||
|
return id;
|
||||||
|
} finally {
|
||||||
|
working.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Saves, then tests the connection. */
|
||||||
|
async function test(): Promise<void> {
|
||||||
|
const id = await save();
|
||||||
|
if (id === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
working.value = true;
|
||||||
|
try {
|
||||||
|
await deploy.testConnection(id);
|
||||||
|
} finally {
|
||||||
|
working.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Removes the selected server after the confirmation. */
|
||||||
|
async function remove(): Promise<void> {
|
||||||
|
if (!confirmRemove.value) {
|
||||||
|
confirmRemove.value = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const id = selected.value;
|
||||||
|
confirmRemove.value = false;
|
||||||
|
await deploy.removeServer(id);
|
||||||
|
select(deploy.servers[0]?.id ?? "");
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Chooses the key file with the shell's picker. */
|
||||||
|
async function browseKey(): Promise<void> {
|
||||||
|
const picked = await pickFile(t("deploy.dialog.pickKey"));
|
||||||
|
if (picked.ok && picked.value !== null) {
|
||||||
|
form.value.keyPath = picked.value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Chooses the deployment folder with the shell's picker. */
|
||||||
|
async function browseFolder(): Promise<void> {
|
||||||
|
const picked = await pickDir(t("deploy.dialog.pickFolder"));
|
||||||
|
if (picked.ok && picked.value !== null) {
|
||||||
|
form.value.root = picked.value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Closes the dialog. */
|
||||||
|
function close(): void {
|
||||||
|
deploy.hideDialog();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Escape closes.
|
||||||
|
*
|
||||||
|
* @param event - the key.
|
||||||
|
*/
|
||||||
|
function onKeydown(event: KeyboardEvent): void {
|
||||||
|
if (event.key === "Escape") {
|
||||||
|
event.preventDefault();
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => deploy.dialogOpen,
|
||||||
|
async (isOpen) => {
|
||||||
|
if (isOpen) {
|
||||||
|
const active = document.activeElement;
|
||||||
|
returnFocus = active instanceof HTMLElement ? active : null;
|
||||||
|
modals.opened("deployment", close);
|
||||||
|
select(deploy.target?.id ?? deploy.servers[0]?.id ?? "");
|
||||||
|
await nextTick();
|
||||||
|
nameInput.value?.focus();
|
||||||
|
} else {
|
||||||
|
modals.closed("deployment");
|
||||||
|
returnFocus?.focus();
|
||||||
|
returnFocus = null;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scrolls a new host-key question into view; environments without
|
||||||
|
* `scrollIntoView` (tests) skip it.
|
||||||
|
*/
|
||||||
|
watch(
|
||||||
|
() => deploy.question,
|
||||||
|
async (question) => {
|
||||||
|
if (question !== null) {
|
||||||
|
await nextTick();
|
||||||
|
const box = questionBox.value;
|
||||||
|
if (box !== null && typeof box.scrollIntoView === "function") {
|
||||||
|
box.scrollIntoView({ block: "nearest" });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => deploy.servers,
|
||||||
|
() => {
|
||||||
|
if (deploy.dialogOpen && selected.value !== "" && !deploy.servers.some((s) => s.id === selected.value)) {
|
||||||
|
select(deploy.servers[0]?.id ?? "");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div
|
||||||
|
v-if="deploy.dialogOpen"
|
||||||
|
class="deploy-dialog"
|
||||||
|
data-test="deploy-dialog"
|
||||||
|
@mousedown.self="close"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="deploy-dialog__box"
|
||||||
|
role="dialog"
|
||||||
|
aria-modal="true"
|
||||||
|
aria-labelledby="lt-deploy-title"
|
||||||
|
@keydown="onKeydown"
|
||||||
|
>
|
||||||
|
<h2
|
||||||
|
id="lt-deploy-title"
|
||||||
|
class="deploy-dialog__title"
|
||||||
|
>
|
||||||
|
{{ t("deploy.dialog.title") }}
|
||||||
|
</h2>
|
||||||
|
<div class="deploy-dialog__body">
|
||||||
|
<nav
|
||||||
|
class="deploy-dialog__servers"
|
||||||
|
:aria-label="t('deploy.dialog.servers')"
|
||||||
|
>
|
||||||
|
<ul class="deploy-dialog__list">
|
||||||
|
<li
|
||||||
|
v-for="server in deploy.servers"
|
||||||
|
:key="server.id"
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="deploy-dialog__server"
|
||||||
|
:class="{ 'deploy-dialog__server--selected': server.id === selected }"
|
||||||
|
:aria-current="server.id === selected ? 'true' : undefined"
|
||||||
|
data-test="deploy-server"
|
||||||
|
@click="select(server.id)"
|
||||||
|
>
|
||||||
|
<span class="deploy-dialog__server-name">{{ server.name }}</span>
|
||||||
|
<span class="deploy-dialog__server-sub">
|
||||||
|
{{ server.kind.toUpperCase() }}{{ server.host ? ` · ${server.host}` : "" }}{{ server.id === deploy.defaultServer ? ` · ${t("deploy.dialog.defaultMark")}` : "" }}
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="deploy-dialog__button"
|
||||||
|
data-test="deploy-add"
|
||||||
|
@click="addNew"
|
||||||
|
>
|
||||||
|
{{ t("deploy.dialog.add") }}
|
||||||
|
</button>
|
||||||
|
</nav>
|
||||||
|
<form
|
||||||
|
class="deploy-dialog__form"
|
||||||
|
@submit.prevent="save"
|
||||||
|
>
|
||||||
|
<label class="deploy-dialog__field">
|
||||||
|
<span>{{ t("deploy.field.name") }}</span>
|
||||||
|
<input
|
||||||
|
ref="nameInput"
|
||||||
|
v-model="form.name"
|
||||||
|
class="deploy-dialog__input"
|
||||||
|
type="text"
|
||||||
|
autocomplete="off"
|
||||||
|
data-test="deploy-name"
|
||||||
|
>
|
||||||
|
</label>
|
||||||
|
<label class="deploy-dialog__field">
|
||||||
|
<span>{{ t("deploy.field.kind") }}</span>
|
||||||
|
<select
|
||||||
|
v-model="form.kind"
|
||||||
|
class="deploy-dialog__input"
|
||||||
|
data-test="deploy-kind"
|
||||||
|
>
|
||||||
|
<option
|
||||||
|
v-for="kind in kindLabels"
|
||||||
|
:key="kind.id"
|
||||||
|
:value="kind.id"
|
||||||
|
>
|
||||||
|
{{ kind.label }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<p
|
||||||
|
v-if="form.kind === 'ftp'"
|
||||||
|
class="deploy-dialog__warning"
|
||||||
|
data-test="deploy-ftp-warning"
|
||||||
|
>
|
||||||
|
{{ t("deploy.dialog.ftpWarning") }}
|
||||||
|
</p>
|
||||||
|
<template v-if="remote">
|
||||||
|
<div class="deploy-dialog__pair">
|
||||||
|
<label class="deploy-dialog__field deploy-dialog__field--grow">
|
||||||
|
<span>{{ t("deploy.field.host") }}</span>
|
||||||
|
<input
|
||||||
|
v-model="form.host"
|
||||||
|
class="deploy-dialog__input"
|
||||||
|
type="text"
|
||||||
|
spellcheck="false"
|
||||||
|
autocomplete="off"
|
||||||
|
data-test="deploy-host"
|
||||||
|
>
|
||||||
|
</label>
|
||||||
|
<label class="deploy-dialog__field deploy-dialog__field--port">
|
||||||
|
<span>{{ t("deploy.field.port") }}</span>
|
||||||
|
<input
|
||||||
|
v-model="portText"
|
||||||
|
class="deploy-dialog__input"
|
||||||
|
type="text"
|
||||||
|
inputmode="numeric"
|
||||||
|
:placeholder="form.kind === 'sftp' ? '22' : '21'"
|
||||||
|
data-test="deploy-port"
|
||||||
|
>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<label class="deploy-dialog__field">
|
||||||
|
<span>{{ t("deploy.field.user") }}</span>
|
||||||
|
<input
|
||||||
|
v-model="form.user"
|
||||||
|
class="deploy-dialog__input"
|
||||||
|
type="text"
|
||||||
|
spellcheck="false"
|
||||||
|
autocomplete="off"
|
||||||
|
data-test="deploy-user"
|
||||||
|
>
|
||||||
|
</label>
|
||||||
|
<label
|
||||||
|
v-if="form.kind === 'sftp'"
|
||||||
|
class="deploy-dialog__field"
|
||||||
|
>
|
||||||
|
<span>{{ t("deploy.field.auth") }}</span>
|
||||||
|
<select
|
||||||
|
v-model="form.auth"
|
||||||
|
class="deploy-dialog__input"
|
||||||
|
data-test="deploy-auth"
|
||||||
|
>
|
||||||
|
<option value="password">{{ t("deploy.auth.password") }}</option>
|
||||||
|
<option value="key">{{ t("deploy.auth.key") }}</option>
|
||||||
|
<option value="agent">{{ t("deploy.auth.agent") }}</option>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<label
|
||||||
|
v-if="form.kind === 'sftp' && form.auth === 'key'"
|
||||||
|
class="deploy-dialog__field"
|
||||||
|
>
|
||||||
|
<span>{{ t("deploy.field.keyPath") }}</span>
|
||||||
|
<span class="deploy-dialog__row">
|
||||||
|
<input
|
||||||
|
v-model="keyText"
|
||||||
|
class="deploy-dialog__input"
|
||||||
|
type="text"
|
||||||
|
spellcheck="false"
|
||||||
|
data-test="deploy-key"
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="deploy-dialog__button"
|
||||||
|
@click="browseKey"
|
||||||
|
>{{ t("deploy.dialog.browse") }}</button>
|
||||||
|
</span>
|
||||||
|
</label>
|
||||||
|
<label
|
||||||
|
v-if="secretKind !== null"
|
||||||
|
class="deploy-dialog__field"
|
||||||
|
>
|
||||||
|
<span>{{ secretKind === "password" ? t("deploy.field.password") : t("deploy.field.passphrase") }}</span>
|
||||||
|
<input
|
||||||
|
v-model="secret"
|
||||||
|
class="deploy-dialog__input"
|
||||||
|
type="password"
|
||||||
|
autocomplete="new-password"
|
||||||
|
:placeholder="hasSecret ? t('deploy.dialog.secretStored') : t('deploy.dialog.secretNone')"
|
||||||
|
data-test="deploy-secret"
|
||||||
|
>
|
||||||
|
</label>
|
||||||
|
<label class="deploy-dialog__field">
|
||||||
|
<span>{{ t("deploy.field.root") }}</span>
|
||||||
|
<input
|
||||||
|
v-model="form.root"
|
||||||
|
class="deploy-dialog__input"
|
||||||
|
type="text"
|
||||||
|
spellcheck="false"
|
||||||
|
:placeholder="t('deploy.field.rootPlaceholder')"
|
||||||
|
data-test="deploy-root"
|
||||||
|
>
|
||||||
|
</label>
|
||||||
|
</template>
|
||||||
|
<label
|
||||||
|
v-else
|
||||||
|
class="deploy-dialog__field"
|
||||||
|
>
|
||||||
|
<span>{{ t("deploy.field.folder") }}</span>
|
||||||
|
<span class="deploy-dialog__row">
|
||||||
|
<input
|
||||||
|
v-model="form.root"
|
||||||
|
class="deploy-dialog__input"
|
||||||
|
type="text"
|
||||||
|
spellcheck="false"
|
||||||
|
data-test="deploy-root"
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="deploy-dialog__button"
|
||||||
|
@click="browseFolder"
|
||||||
|
>{{ t("deploy.dialog.browse") }}</button>
|
||||||
|
</span>
|
||||||
|
</label>
|
||||||
|
<fieldset class="deploy-dialog__group">
|
||||||
|
<legend>{{ t("deploy.field.mappings") }}</legend>
|
||||||
|
<p class="deploy-dialog__hint">
|
||||||
|
{{ t("deploy.dialog.mappingsHint") }}
|
||||||
|
</p>
|
||||||
|
<div
|
||||||
|
v-for="(mapping, index) in form.mappings"
|
||||||
|
:key="index"
|
||||||
|
class="deploy-dialog__row"
|
||||||
|
data-test="deploy-mapping"
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
v-model="mapping.local"
|
||||||
|
class="deploy-dialog__input"
|
||||||
|
type="text"
|
||||||
|
spellcheck="false"
|
||||||
|
:aria-label="t('deploy.field.mappingLocal')"
|
||||||
|
:placeholder="t('deploy.field.mappingLocal')"
|
||||||
|
>
|
||||||
|
<span aria-hidden="true">{{ t("deploy.dialog.mapsTo") }}</span>
|
||||||
|
<input
|
||||||
|
v-model="mapping.remote"
|
||||||
|
class="deploy-dialog__input"
|
||||||
|
type="text"
|
||||||
|
spellcheck="false"
|
||||||
|
:aria-label="t('deploy.field.mappingRemote')"
|
||||||
|
:placeholder="t('deploy.field.mappingRemote')"
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="deploy-dialog__button"
|
||||||
|
:aria-label="t('deploy.dialog.removeMapping')"
|
||||||
|
@click="removeMapping(index)"
|
||||||
|
>
|
||||||
|
×
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="deploy-dialog__button deploy-dialog__button--small"
|
||||||
|
data-test="deploy-add-mapping"
|
||||||
|
@click="addMapping"
|
||||||
|
>
|
||||||
|
{{ t("deploy.dialog.addMapping") }}
|
||||||
|
</button>
|
||||||
|
</fieldset>
|
||||||
|
<label class="deploy-dialog__field">
|
||||||
|
<span>{{ t("deploy.field.excluded") }}</span>
|
||||||
|
<textarea
|
||||||
|
v-model="excludedText"
|
||||||
|
class="deploy-dialog__input deploy-dialog__textarea"
|
||||||
|
rows="3"
|
||||||
|
spellcheck="false"
|
||||||
|
data-test="deploy-excluded"
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
<label class="deploy-dialog__check">
|
||||||
|
<input
|
||||||
|
v-model="form.uploadOnSave"
|
||||||
|
type="checkbox"
|
||||||
|
data-test="deploy-upload-on-save"
|
||||||
|
>
|
||||||
|
{{ t("deploy.field.uploadOnSave") }}
|
||||||
|
</label>
|
||||||
|
<label class="deploy-dialog__check">
|
||||||
|
<input
|
||||||
|
v-model="isDefault"
|
||||||
|
type="checkbox"
|
||||||
|
data-test="deploy-default"
|
||||||
|
>
|
||||||
|
{{ t("deploy.field.default") }}
|
||||||
|
</label>
|
||||||
|
<div
|
||||||
|
v-if="deploy.question !== null"
|
||||||
|
ref="questionBox"
|
||||||
|
class="deploy-dialog__question"
|
||||||
|
:class="{ 'deploy-dialog__question--changed': deploy.question.status === 'changed' }"
|
||||||
|
role="alert"
|
||||||
|
data-test="deploy-hostkey"
|
||||||
|
>
|
||||||
|
<template v-if="deploy.question.status === 'unknown'">
|
||||||
|
<strong>{{ t("deploy.hostKey.unknownTitle") }}</strong>
|
||||||
|
<span>{{ t("deploy.hostKey.unknown", { host: deploy.question.host }) }}</span>
|
||||||
|
<code class="deploy-dialog__fingerprint">{{ deploy.question.algorithm }} {{ deploy.question.fingerprint }}</code>
|
||||||
|
<span class="deploy-dialog__buttons">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="deploy-dialog__button"
|
||||||
|
@click="deploy.rejectHostKey()"
|
||||||
|
>{{ t("deploy.hostKey.reject") }}</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="deploy-dialog__button deploy-dialog__button--primary"
|
||||||
|
data-test="deploy-trust"
|
||||||
|
@click="deploy.trustHostKey(false)"
|
||||||
|
>{{ t("deploy.hostKey.trust") }}</button>
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<strong>{{ t("deploy.hostKey.changedTitle") }}</strong>
|
||||||
|
<span>{{ t("deploy.hostKey.changed", { host: deploy.question.host }) }}</span>
|
||||||
|
<span>{{ t("deploy.hostKey.trusted") }} <code class="deploy-dialog__fingerprint">{{ deploy.question.known }}</code></span>
|
||||||
|
<span>{{ t("deploy.hostKey.offered") }} <code class="deploy-dialog__fingerprint">{{ deploy.question.algorithm }} {{ deploy.question.fingerprint }}</code></span>
|
||||||
|
<span class="deploy-dialog__buttons">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="deploy-dialog__button deploy-dialog__button--primary"
|
||||||
|
@click="deploy.rejectHostKey()"
|
||||||
|
>{{ t("deploy.hostKey.keep") }}</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="deploy-dialog__button deploy-dialog__button--danger"
|
||||||
|
data-test="deploy-replace"
|
||||||
|
@click="deploy.trustHostKey(true)"
|
||||||
|
>{{ t("deploy.hostKey.replace") }}</button>
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
<p
|
||||||
|
v-if="deploy.tested !== null && deploy.question === null"
|
||||||
|
class="deploy-dialog__outcome"
|
||||||
|
:class="{ 'deploy-dialog__outcome--ok': deploy.tested.ok }"
|
||||||
|
role="status"
|
||||||
|
data-test="deploy-tested"
|
||||||
|
>
|
||||||
|
{{ deploy.tested.message }}
|
||||||
|
</p>
|
||||||
|
<p
|
||||||
|
v-if="deploy.dialogError !== null"
|
||||||
|
class="deploy-dialog__error"
|
||||||
|
role="alert"
|
||||||
|
data-test="deploy-error"
|
||||||
|
>
|
||||||
|
{{ deploy.dialogError }}
|
||||||
|
</p>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div class="deploy-dialog__buttons">
|
||||||
|
<button
|
||||||
|
v-if="selected !== ''"
|
||||||
|
type="button"
|
||||||
|
class="deploy-dialog__button"
|
||||||
|
:class="{ 'deploy-dialog__button--danger': confirmRemove }"
|
||||||
|
data-test="deploy-remove"
|
||||||
|
@click="remove"
|
||||||
|
>
|
||||||
|
{{ confirmRemove ? t("deploy.dialog.confirmRemove") : t("deploy.dialog.remove") }}
|
||||||
|
</button>
|
||||||
|
<span class="deploy-dialog__spacer" />
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="deploy-dialog__button"
|
||||||
|
:disabled="working || deploy.busy"
|
||||||
|
data-test="deploy-test"
|
||||||
|
@click="test"
|
||||||
|
>
|
||||||
|
{{ t("deploy.dialog.test") }}
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="deploy-dialog__button deploy-dialog__button--primary"
|
||||||
|
:disabled="working"
|
||||||
|
data-test="deploy-save"
|
||||||
|
@click="save"
|
||||||
|
>
|
||||||
|
{{ t("deploy.dialog.save") }}
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="deploy-dialog__button"
|
||||||
|
data-test="deploy-close"
|
||||||
|
@click="close"
|
||||||
|
>
|
||||||
|
{{ t("deploy.dialog.close") }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.deploy-dialog {
|
||||||
|
position: fixed;
|
||||||
|
inset: 0;
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-start;
|
||||||
|
justify-content: center;
|
||||||
|
padding-top: 5vh;
|
||||||
|
background: color-mix(in srgb, var(--lt-bg) 50%, transparent);
|
||||||
|
z-index: 20;
|
||||||
|
}
|
||||||
|
|
||||||
|
.deploy-dialog__box {
|
||||||
|
width: min(860px, 94vw);
|
||||||
|
max-height: 90vh;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 10px;
|
||||||
|
padding: 16px;
|
||||||
|
background: var(--lt-bg);
|
||||||
|
color: var(--lt-fg);
|
||||||
|
border: 1px solid var(--lt-border);
|
||||||
|
border-radius: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.deploy-dialog__title {
|
||||||
|
margin: 0;
|
||||||
|
font-size: var(--lt-font-size-ui);
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.deploy-dialog__body {
|
||||||
|
display: flex;
|
||||||
|
gap: 12px;
|
||||||
|
min-height: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.deploy-dialog__servers {
|
||||||
|
display: flex;
|
||||||
|
flex: 0 0 200px;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 8px;
|
||||||
|
padding-right: 12px;
|
||||||
|
border-right: 1px solid var(--lt-border);
|
||||||
|
}
|
||||||
|
|
||||||
|
.deploy-dialog__list {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
list-style: none;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.deploy-dialog__server {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
width: 100%;
|
||||||
|
padding: 4px 6px;
|
||||||
|
font: inherit;
|
||||||
|
text-align: left;
|
||||||
|
color: var(--lt-fg);
|
||||||
|
background: transparent;
|
||||||
|
border: none;
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.deploy-dialog__server--selected {
|
||||||
|
background: var(--lt-editor-selection-bg);
|
||||||
|
}
|
||||||
|
|
||||||
|
.deploy-dialog__server-sub {
|
||||||
|
color: var(--lt-fg-muted);
|
||||||
|
font-size: var(--lt-font-size-small);
|
||||||
|
}
|
||||||
|
|
||||||
|
.deploy-dialog__form {
|
||||||
|
display: flex;
|
||||||
|
flex: 1;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 8px;
|
||||||
|
min-width: 0;
|
||||||
|
overflow-y: auto;
|
||||||
|
padding-right: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.deploy-dialog__field {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.deploy-dialog__field--grow {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.deploy-dialog__field--port {
|
||||||
|
flex: 0 0 8ch;
|
||||||
|
}
|
||||||
|
|
||||||
|
.deploy-dialog__pair,
|
||||||
|
.deploy-dialog__row {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.deploy-dialog__input {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
padding: 4px 6px;
|
||||||
|
font: inherit;
|
||||||
|
color: var(--lt-fg);
|
||||||
|
background: var(--lt-editor-bg);
|
||||||
|
border: 1px solid var(--lt-border);
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.deploy-dialog__textarea {
|
||||||
|
resize: vertical;
|
||||||
|
font-family: var(--lt-font-mono);
|
||||||
|
}
|
||||||
|
|
||||||
|
.deploy-dialog__group {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 6px;
|
||||||
|
margin: 0;
|
||||||
|
padding: 6px 8px;
|
||||||
|
border: 1px solid var(--lt-border);
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.deploy-dialog__check {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.deploy-dialog__hint {
|
||||||
|
margin: 0;
|
||||||
|
color: var(--lt-fg-muted);
|
||||||
|
font-size: var(--lt-font-size-small);
|
||||||
|
}
|
||||||
|
|
||||||
|
.deploy-dialog__warning {
|
||||||
|
margin: 0;
|
||||||
|
color: var(--lt-diag-warning);
|
||||||
|
font-size: var(--lt-font-size-small);
|
||||||
|
}
|
||||||
|
|
||||||
|
.deploy-dialog__question {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 6px;
|
||||||
|
padding: 8px;
|
||||||
|
border: 1px solid var(--lt-accent);
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.deploy-dialog__question--changed {
|
||||||
|
border-color: var(--lt-error);
|
||||||
|
}
|
||||||
|
|
||||||
|
.deploy-dialog__fingerprint {
|
||||||
|
font-family: var(--lt-font-mono);
|
||||||
|
overflow-wrap: anywhere;
|
||||||
|
}
|
||||||
|
|
||||||
|
.deploy-dialog__outcome {
|
||||||
|
margin: 0;
|
||||||
|
overflow-wrap: anywhere;
|
||||||
|
}
|
||||||
|
|
||||||
|
.deploy-dialog__outcome--ok {
|
||||||
|
color: var(--lt-diag-info);
|
||||||
|
}
|
||||||
|
|
||||||
|
.deploy-dialog__error {
|
||||||
|
margin: 0;
|
||||||
|
color: var(--lt-error);
|
||||||
|
white-space: pre-wrap;
|
||||||
|
overflow-wrap: anywhere;
|
||||||
|
}
|
||||||
|
|
||||||
|
.deploy-dialog__buttons {
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.deploy-dialog__spacer {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.deploy-dialog__button {
|
||||||
|
padding: 4px 12px;
|
||||||
|
font: inherit;
|
||||||
|
color: var(--lt-fg);
|
||||||
|
background: var(--lt-editor-bg);
|
||||||
|
border: 1px solid var(--lt-border);
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.deploy-dialog__button--small {
|
||||||
|
align-self: flex-start;
|
||||||
|
padding: 2px 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.deploy-dialog__button--primary {
|
||||||
|
border-color: var(--lt-accent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.deploy-dialog__button--danger {
|
||||||
|
border-color: var(--lt-error);
|
||||||
|
color: var(--lt-error);
|
||||||
|
}
|
||||||
|
|
||||||
|
.deploy-dialog__button:disabled {
|
||||||
|
color: var(--lt-fg-muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.deploy-dialog__input:focus-visible,
|
||||||
|
.deploy-dialog__button:focus-visible,
|
||||||
|
.deploy-dialog__server:focus-visible {
|
||||||
|
outline: 1px solid var(--lt-accent);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
217
ui/src/components/deploy/DeploymentLogToolWindow.vue
Normal file
217
ui/src/components/deploy/DeploymentLogToolWindow.vue
Normal file
|
|
@ -0,0 +1,217 @@
|
||||||
|
<script setup lang="ts">
|
||||||
|
/**
|
||||||
|
* The Deployment log tool window (G17), shown in the bottom panel: every
|
||||||
|
* line of the deployment log (newest at the bottom), with its time, the
|
||||||
|
* server and a severity icon; the running job's progress above the list
|
||||||
|
* with Cancel; and Clear. The log follows new lines while it is scrolled
|
||||||
|
* to the bottom. State lives in the Deployment store (`deploy.ts`).
|
||||||
|
*/
|
||||||
|
import { CircleAlert, Info, TriangleAlert } from "@lucide/vue";
|
||||||
|
import { computed, nextTick, ref, watch } from "vue";
|
||||||
|
import { t } from "../../i18n";
|
||||||
|
import { useDeployStore, type LogEntry } from "./deploy";
|
||||||
|
|
||||||
|
const deploy = useDeployStore();
|
||||||
|
|
||||||
|
/** The list element. */
|
||||||
|
const list = ref<HTMLElement | null>(null);
|
||||||
|
|
||||||
|
/** Icons by severity. */
|
||||||
|
const ICONS = { error: CircleAlert, warning: TriangleAlert, info: Info } as const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The time of a line, `HH:MM:SS` in local time.
|
||||||
|
*
|
||||||
|
* @param entry - the line.
|
||||||
|
*/
|
||||||
|
function timeOf(entry: LogEntry): string {
|
||||||
|
const d = new Date(entry.time);
|
||||||
|
const two = (n: number) => String(n).padStart(2, "0");
|
||||||
|
return `${two(d.getHours())}:${two(d.getMinutes())}:${two(d.getSeconds())}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The accessible name of a severity.
|
||||||
|
*
|
||||||
|
* @param level - the severity.
|
||||||
|
*/
|
||||||
|
function levelLabel(level: LogEntry["level"]): string {
|
||||||
|
return level === "error"
|
||||||
|
? t("deploy.log.error")
|
||||||
|
: level === "warning"
|
||||||
|
? t("deploy.log.warning")
|
||||||
|
: t("deploy.log.info");
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The running job's line, or null. */
|
||||||
|
const running = computed(() => {
|
||||||
|
const p = deploy.progress;
|
||||||
|
if (p === null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return t("deploy.log.running", {
|
||||||
|
server: p.server,
|
||||||
|
done: p.filesDone,
|
||||||
|
total: p.filesTotal,
|
||||||
|
file: p.file,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => deploy.entries.length,
|
||||||
|
async () => {
|
||||||
|
const el = list.value;
|
||||||
|
const atBottom = el === null || el.scrollTop + el.clientHeight >= el.scrollHeight - 24;
|
||||||
|
await nextTick();
|
||||||
|
if (atBottom && list.value) {
|
||||||
|
list.value.scrollTop = list.value.scrollHeight;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<section
|
||||||
|
class="deploy-log"
|
||||||
|
:aria-label="t('deploy.log.title')"
|
||||||
|
data-test="deploy-log"
|
||||||
|
>
|
||||||
|
<header class="deploy-log__header">
|
||||||
|
<span
|
||||||
|
v-if="running !== null"
|
||||||
|
class="deploy-log__running"
|
||||||
|
role="status"
|
||||||
|
>{{ running }}</span>
|
||||||
|
<span
|
||||||
|
v-else
|
||||||
|
class="deploy-log__idle"
|
||||||
|
>{{ deploy.entries.length === 0 ? t("deploy.log.empty") : "" }}</span>
|
||||||
|
<button
|
||||||
|
v-if="running !== null"
|
||||||
|
type="button"
|
||||||
|
class="deploy-log__button"
|
||||||
|
data-test="deploy-log-cancel"
|
||||||
|
@click="deploy.cancel()"
|
||||||
|
>
|
||||||
|
{{ t("deploy.cancel") }}
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="deploy-log__button"
|
||||||
|
:disabled="deploy.entries.length === 0"
|
||||||
|
data-test="deploy-log-clear"
|
||||||
|
@click="deploy.clearLog()"
|
||||||
|
>
|
||||||
|
{{ t("deploy.log.clear") }}
|
||||||
|
</button>
|
||||||
|
</header>
|
||||||
|
<ol
|
||||||
|
ref="list"
|
||||||
|
class="deploy-log__list"
|
||||||
|
>
|
||||||
|
<li
|
||||||
|
v-for="entry in deploy.entries"
|
||||||
|
:key="entry.id"
|
||||||
|
class="deploy-log__line"
|
||||||
|
:class="`deploy-log__line--${entry.level}`"
|
||||||
|
data-test="deploy-log-line"
|
||||||
|
>
|
||||||
|
<component
|
||||||
|
:is="ICONS[entry.level]"
|
||||||
|
class="deploy-log__icon"
|
||||||
|
:size="12"
|
||||||
|
:aria-label="levelLabel(entry.level)"
|
||||||
|
/>
|
||||||
|
<time class="deploy-log__time">{{ timeOf(entry) }}</time>
|
||||||
|
<span class="deploy-log__server">{{ entry.server }}</span>
|
||||||
|
<span class="deploy-log__message">{{ entry.message }}</span>
|
||||||
|
</li>
|
||||||
|
</ol>
|
||||||
|
</section>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.deploy-log {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
height: 100%;
|
||||||
|
min-height: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.deploy-log__header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
flex: none;
|
||||||
|
padding: 2px 8px;
|
||||||
|
border-bottom: 1px solid var(--lt-border);
|
||||||
|
}
|
||||||
|
|
||||||
|
.deploy-log__running,
|
||||||
|
.deploy-log__idle {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
color: var(--lt-fg-muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.deploy-log__button {
|
||||||
|
padding: 1px 8px;
|
||||||
|
font: inherit;
|
||||||
|
color: var(--lt-fg);
|
||||||
|
background: transparent;
|
||||||
|
border: 1px solid var(--lt-border);
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.deploy-log__button:disabled {
|
||||||
|
color: var(--lt-fg-muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.deploy-log__button:focus-visible {
|
||||||
|
outline: 1px solid var(--lt-accent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.deploy-log__list {
|
||||||
|
flex: 1;
|
||||||
|
margin: 0;
|
||||||
|
padding: 2px 0;
|
||||||
|
list-style: none;
|
||||||
|
overflow-y: auto;
|
||||||
|
font-family: var(--lt-font-mono);
|
||||||
|
font-size: var(--lt-font-size-small);
|
||||||
|
}
|
||||||
|
|
||||||
|
.deploy-log__line {
|
||||||
|
display: flex;
|
||||||
|
align-items: baseline;
|
||||||
|
gap: 8px;
|
||||||
|
padding: 1px 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.deploy-log__icon {
|
||||||
|
flex: none;
|
||||||
|
align-self: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.deploy-log__line--error {
|
||||||
|
color: var(--lt-error);
|
||||||
|
}
|
||||||
|
|
||||||
|
.deploy-log__line--warning {
|
||||||
|
color: var(--lt-diag-warning);
|
||||||
|
}
|
||||||
|
|
||||||
|
.deploy-log__time,
|
||||||
|
.deploy-log__server {
|
||||||
|
flex: none;
|
||||||
|
color: var(--lt-fg-muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.deploy-log__message {
|
||||||
|
white-space: pre-wrap;
|
||||||
|
overflow-wrap: anywhere;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
694
ui/src/components/deploy/deploy.ts
Normal file
694
ui/src/components/deploy/deploy.ts
Normal file
|
|
@ -0,0 +1,694 @@
|
||||||
|
/**
|
||||||
|
* Deployment (G17, owner decision D27): servers of the project, test
|
||||||
|
* connection, host keys, upload, download, the log and the running job,
|
||||||
|
* through the engine's `deploy.*` commands.
|
||||||
|
*
|
||||||
|
* - **Secrets** go to the engine once (`deploy.saveServer {secret}` or
|
||||||
|
* `deploy.setSecret`), which keeps them only in the OS keychain. The store
|
||||||
|
* never keeps or shows one; a server only says whether one is stored.
|
||||||
|
* - **Host keys:** test connection answers an unknown or changed SFTP host
|
||||||
|
* key as a {@link HostKeyQuestion}; the dialog shows the fingerprint and
|
||||||
|
* the user trusts it (`deploy.trustHostKey`), replacing a changed one only
|
||||||
|
* on an explicit second choice.
|
||||||
|
* - **Progress and log:** `deployProgress` feeds {@link progress} (the
|
||||||
|
* status-bar item, with Cancel); `deployLog` appends to {@link entries}
|
||||||
|
* (the Deployment log tool window, newest 1,000 lines).
|
||||||
|
* - **Upload and download** are pending outcomes (`runWaiting`) and end in
|
||||||
|
* a toast: what was transferred, cancelled, or the explained refusal.
|
||||||
|
*/
|
||||||
|
import { defineStore } from "pinia";
|
||||||
|
import { computed, ref, shallowRef } from "vue";
|
||||||
|
import { onEngineEvent, run, runWaiting, type EngineEventPayload, type JsonValue } from "../../ipc";
|
||||||
|
import { t } from "../../i18n";
|
||||||
|
import { useNotificationsStore } from "../../stores/notifications";
|
||||||
|
|
||||||
|
/** Most log lines kept, like the engine. */
|
||||||
|
export const MAX_LOG = 1000;
|
||||||
|
|
||||||
|
/** Most servers read from one answer. */
|
||||||
|
export const MAX_SERVERS = 100;
|
||||||
|
|
||||||
|
/** A server's protocol. */
|
||||||
|
export type ServerKind = "sftp" | "ftp" | "ftps" | "folder";
|
||||||
|
|
||||||
|
/** How a server signs in. */
|
||||||
|
export type AuthKind = "password" | "key" | "agent";
|
||||||
|
|
||||||
|
/** One local folder mapped to one remote folder. */
|
||||||
|
export interface Mapping {
|
||||||
|
/** Project-relative folder, "" for the root. */
|
||||||
|
local: string;
|
||||||
|
/** Remote folder, relative to the root or absolute. */
|
||||||
|
remote: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A server as `deploy.servers` lists it. */
|
||||||
|
export interface DeployServer {
|
||||||
|
/** Stable id. */
|
||||||
|
id: string;
|
||||||
|
/** Shown name. */
|
||||||
|
name: string;
|
||||||
|
/** Protocol. */
|
||||||
|
kind: ServerKind;
|
||||||
|
/** Host; "" for a folder. */
|
||||||
|
host: string;
|
||||||
|
/** Port, or null for the default. */
|
||||||
|
port: number | null;
|
||||||
|
/** User name. */
|
||||||
|
user: string;
|
||||||
|
/** Remote root, or the local folder. */
|
||||||
|
root: string;
|
||||||
|
/** How to sign in. */
|
||||||
|
auth: AuthKind;
|
||||||
|
/** Private key file for key sign-in. */
|
||||||
|
keyPath: string | null;
|
||||||
|
/** Path mappings. */
|
||||||
|
mappings: Mapping[];
|
||||||
|
/** Excluded paths and patterns. */
|
||||||
|
excluded: string[];
|
||||||
|
/** Upload after every save. */
|
||||||
|
uploadOnSave: boolean;
|
||||||
|
/** Which secret the server needs, if any. */
|
||||||
|
secretKind: "password" | "passphrase" | null;
|
||||||
|
/** Whether that secret is in the keychain. */
|
||||||
|
hasSecret: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The running job, as `deployProgress` reports it. */
|
||||||
|
export interface DeployProgress {
|
||||||
|
/** `test`, `upload` or `download`. */
|
||||||
|
operation: "test" | "upload" | "download";
|
||||||
|
/** The server's name. */
|
||||||
|
server: string;
|
||||||
|
/** `connecting`, `planning` or `transferring`. */
|
||||||
|
phase: string;
|
||||||
|
/** The file being transferred, or "". */
|
||||||
|
file: string;
|
||||||
|
/** Files done. */
|
||||||
|
filesDone: number;
|
||||||
|
/** Files planned. */
|
||||||
|
filesTotal: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** One line of the deployment log. */
|
||||||
|
export interface LogEntry {
|
||||||
|
/** Increasing id. */
|
||||||
|
id: number;
|
||||||
|
/** Milliseconds since the epoch. */
|
||||||
|
time: number;
|
||||||
|
/** Severity. */
|
||||||
|
level: "info" | "warning" | "error";
|
||||||
|
/** The server's name. */
|
||||||
|
server: string;
|
||||||
|
/** The text. */
|
||||||
|
message: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** An SFTP host key test connection asks about. */
|
||||||
|
export interface HostKeyQuestion {
|
||||||
|
/** The server's id. */
|
||||||
|
serverId: string;
|
||||||
|
/** `unknown`: first connection; `changed`: differs from the trusted one. */
|
||||||
|
status: "unknown" | "changed";
|
||||||
|
/** `host:port`. */
|
||||||
|
host: string;
|
||||||
|
/** The key's algorithm. */
|
||||||
|
algorithm: string;
|
||||||
|
/** The offered fingerprint. */
|
||||||
|
fingerprint: string;
|
||||||
|
/** The trusted fingerprint, for a changed key. */
|
||||||
|
known: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** What test connection said, for the dialog. */
|
||||||
|
export interface TestOutcome {
|
||||||
|
/** Whether it connected. */
|
||||||
|
ok: boolean;
|
||||||
|
/** The engine's sentence. */
|
||||||
|
message: string;
|
||||||
|
/** Which secret is missing, if that was the reason. */
|
||||||
|
needsSecret: "password" | "passphrase" | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads an untrusted object.
|
||||||
|
*
|
||||||
|
* @param raw - anything.
|
||||||
|
*/
|
||||||
|
function obj(raw: unknown): Record<string, unknown> {
|
||||||
|
return typeof raw === "object" && raw !== null && !Array.isArray(raw) ? (raw as Record<string, unknown>) : {};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A string field, or "".
|
||||||
|
*
|
||||||
|
* @param raw - anything.
|
||||||
|
*/
|
||||||
|
function str(raw: unknown): string {
|
||||||
|
return typeof raw === "string" ? raw : "";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A non-negative integer field, or 0.
|
||||||
|
*
|
||||||
|
* @param raw - anything.
|
||||||
|
*/
|
||||||
|
function count(raw: unknown): number {
|
||||||
|
return typeof raw === "number" && Number.isFinite(raw) && raw > 0 ? Math.floor(raw) : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads one server; null when malformed.
|
||||||
|
*
|
||||||
|
* @param raw - untrusted.
|
||||||
|
*/
|
||||||
|
export function toServer(raw: unknown): DeployServer | null {
|
||||||
|
const s = obj(raw);
|
||||||
|
const kind = s.kind;
|
||||||
|
if (typeof s.id !== "string" || s.id === "" || (kind !== "sftp" && kind !== "ftp" && kind !== "ftps" && kind !== "folder")) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
const auth: AuthKind = s.auth === "key" || s.auth === "agent" ? s.auth : "password";
|
||||||
|
const mappings = Array.isArray(s.mappings)
|
||||||
|
? (s.mappings as unknown[]).slice(0, 200).map((m) => ({ local: str(obj(m).local), remote: str(obj(m).remote) }))
|
||||||
|
: [];
|
||||||
|
const excluded = Array.isArray(s.excluded)
|
||||||
|
? (s.excluded as unknown[]).filter((e): e is string => typeof e === "string").slice(0, 200)
|
||||||
|
: [];
|
||||||
|
return {
|
||||||
|
id: s.id,
|
||||||
|
name: str(s.name),
|
||||||
|
kind,
|
||||||
|
host: str(s.host),
|
||||||
|
port: typeof s.port === "number" && Number.isInteger(s.port) ? s.port : null,
|
||||||
|
user: str(s.user),
|
||||||
|
root: str(s.root),
|
||||||
|
auth,
|
||||||
|
keyPath: typeof s.keyPath === "string" ? s.keyPath : null,
|
||||||
|
mappings,
|
||||||
|
excluded,
|
||||||
|
uploadOnSave: s.uploadOnSave === true,
|
||||||
|
secretKind: s.secretKind === "password" || s.secretKind === "passphrase" ? s.secretKind : null,
|
||||||
|
hasSecret: s.hasSecret === true,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads a `deployProgress` event; null when nothing runs or it is
|
||||||
|
* malformed.
|
||||||
|
*
|
||||||
|
* @param event - the untrusted event.
|
||||||
|
*/
|
||||||
|
export function toProgress(event: EngineEventPayload): DeployProgress | null {
|
||||||
|
if (event.kind !== "deployProgress" || event.active !== true) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
const operation = event.operation;
|
||||||
|
if (operation !== "test" && operation !== "upload" && operation !== "download") {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
operation,
|
||||||
|
server: str(event.server).slice(0, 200),
|
||||||
|
phase: str(event.phase).slice(0, 40),
|
||||||
|
file: str(event.file).slice(0, 500),
|
||||||
|
filesDone: count(event.filesDone),
|
||||||
|
filesTotal: count(event.filesTotal),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads one log line; null when malformed.
|
||||||
|
*
|
||||||
|
* @param raw - untrusted.
|
||||||
|
*/
|
||||||
|
export function toEntry(raw: unknown): LogEntry | null {
|
||||||
|
const e = obj(raw);
|
||||||
|
const level = e.level;
|
||||||
|
if (typeof e.id !== "number" || (level !== "info" && level !== "warning" && level !== "error")) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return { id: e.id, time: count(e.time), level, server: str(e.server), message: str(e.message).slice(0, 4000) };
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads a test-connection answer into the dialog's outcome and the host
|
||||||
|
* key question, if any.
|
||||||
|
*
|
||||||
|
* @param serverId - the tested server.
|
||||||
|
* @param raw - the untrusted value.
|
||||||
|
*/
|
||||||
|
export function toTest(serverId: string, raw: unknown): { outcome: TestOutcome; question: HostKeyQuestion | null } {
|
||||||
|
const v = obj(raw);
|
||||||
|
const key = obj(v.hostKey);
|
||||||
|
const status = key.status;
|
||||||
|
const question: HostKeyQuestion | null =
|
||||||
|
status === "unknown" || status === "changed"
|
||||||
|
? {
|
||||||
|
serverId,
|
||||||
|
status,
|
||||||
|
host: str(key.host),
|
||||||
|
algorithm: str(key.algorithm),
|
||||||
|
fingerprint: str(key.fingerprint),
|
||||||
|
known: str(key.known),
|
||||||
|
}
|
||||||
|
: null;
|
||||||
|
const needs = v.needsSecret;
|
||||||
|
return {
|
||||||
|
outcome: {
|
||||||
|
ok: v.ok === true,
|
||||||
|
message: str(v.message),
|
||||||
|
needsSecret: needs === "password" || needs === "passphrase" ? needs : null,
|
||||||
|
},
|
||||||
|
question,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A server definition as `deploy.saveServer` takes it: without the
|
||||||
|
* read-only fields, with the port only when set.
|
||||||
|
*
|
||||||
|
* @param server - the edited server; an empty id adds a new one.
|
||||||
|
*/
|
||||||
|
export function toSaveParams(server: DeployServer): Record<string, JsonValue> {
|
||||||
|
const out: Record<string, JsonValue> = {
|
||||||
|
name: server.name,
|
||||||
|
kind: server.kind,
|
||||||
|
host: server.host,
|
||||||
|
user: server.user,
|
||||||
|
root: server.root,
|
||||||
|
auth: server.kind === "sftp" ? server.auth : "password",
|
||||||
|
mappings: server.mappings
|
||||||
|
.filter((m) => m.local.trim() !== "" || m.remote.trim() !== "")
|
||||||
|
.map((m) => ({ local: m.local.trim(), remote: m.remote.trim() })),
|
||||||
|
excluded: server.excluded.map((e) => e.trim()).filter((e) => e !== ""),
|
||||||
|
uploadOnSave: server.uploadOnSave,
|
||||||
|
};
|
||||||
|
if (server.id !== "") {
|
||||||
|
out.id = server.id;
|
||||||
|
}
|
||||||
|
if (server.port !== null) {
|
||||||
|
out.port = server.port;
|
||||||
|
}
|
||||||
|
if (server.kind === "sftp" && server.auth === "key" && server.keyPath !== null) {
|
||||||
|
out.keyPath = server.keyPath;
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* "1 file" or "{n} files".
|
||||||
|
*
|
||||||
|
* @param n - the number of files.
|
||||||
|
*/
|
||||||
|
export function filesText(n: number): string {
|
||||||
|
return n === 1 ? t("deploy.files.one") : t("deploy.files.other", { count: String(n) });
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A new server's starting values: SFTP, `.git` and `.env` excluded. */
|
||||||
|
export function blankServer(): DeployServer {
|
||||||
|
return {
|
||||||
|
id: "",
|
||||||
|
name: "",
|
||||||
|
kind: "sftp",
|
||||||
|
host: "",
|
||||||
|
port: null,
|
||||||
|
user: "",
|
||||||
|
root: "",
|
||||||
|
auth: "password",
|
||||||
|
keyPath: null,
|
||||||
|
mappings: [],
|
||||||
|
excluded: [".env", ".idea", "node_modules"],
|
||||||
|
uploadOnSave: false,
|
||||||
|
secretKind: "password",
|
||||||
|
hasSecret: false,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The Deployment store. */
|
||||||
|
export const useDeployStore = defineStore("deploy", () => {
|
||||||
|
const notifications = useNotificationsStore();
|
||||||
|
|
||||||
|
/** The project's servers. */
|
||||||
|
const servers = shallowRef<DeployServer[]>([]);
|
||||||
|
/** The default server's id. */
|
||||||
|
const defaultServer = ref<string | null>(null);
|
||||||
|
/** The running job, or null. */
|
||||||
|
const progress = shallowRef<DeployProgress | null>(null);
|
||||||
|
/** A job was started here and has not answered. */
|
||||||
|
const starting = ref(false);
|
||||||
|
/** Whether a job runs. */
|
||||||
|
const busy = computed(() => starting.value || progress.value !== null);
|
||||||
|
/** The log, oldest first. */
|
||||||
|
const entries = ref<LogEntry[]>([]);
|
||||||
|
/** Whether the log tool window is shown. */
|
||||||
|
const visible = ref(false);
|
||||||
|
/** Whether the bottom panel is expanded while the log is shown. */
|
||||||
|
const expanded = ref(true);
|
||||||
|
/** Whether the servers dialog is open. */
|
||||||
|
const dialogOpen = ref(false);
|
||||||
|
/** The open host-key question. */
|
||||||
|
const question = shallowRef<HostKeyQuestion | null>(null);
|
||||||
|
/** The last test's outcome, for the dialog. */
|
||||||
|
const tested = shallowRef<TestOutcome | null>(null);
|
||||||
|
/** The dialog's last error. */
|
||||||
|
const dialogError = ref<string | null>(null);
|
||||||
|
|
||||||
|
/** The default server, or null. */
|
||||||
|
const target = computed(() => servers.value.find((s) => s.id === defaultServer.value) ?? null);
|
||||||
|
|
||||||
|
/** Stops listening; set while started. */
|
||||||
|
let unsubscribe: (() => void) | null = null;
|
||||||
|
/** How many holders called {@link start}. */
|
||||||
|
let holders = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Appends a log line, keeping the newest {@link MAX_LOG}.
|
||||||
|
*
|
||||||
|
* @param entry - the line.
|
||||||
|
*/
|
||||||
|
function append(entry: LogEntry): void {
|
||||||
|
const next = [...entries.value, entry];
|
||||||
|
entries.value = next.length > MAX_LOG ? next.slice(next.length - MAX_LOG) : next;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Follows the deployment events. Counted: every `start` needs a `stop`. */
|
||||||
|
function start(): void {
|
||||||
|
holders += 1;
|
||||||
|
if (unsubscribe === null) {
|
||||||
|
unsubscribe = onEngineEvent((event) => {
|
||||||
|
if (event.kind === "deployProgress") {
|
||||||
|
progress.value = toProgress(event);
|
||||||
|
} else if (event.kind === "deployLog") {
|
||||||
|
const entry = toEntry(event.entry);
|
||||||
|
if (entry !== null) {
|
||||||
|
append(entry);
|
||||||
|
}
|
||||||
|
} else if (event.kind === "projectOpened") {
|
||||||
|
void load();
|
||||||
|
} else if (event.kind === "projectClosed") {
|
||||||
|
servers.value = [];
|
||||||
|
defaultServer.value = null;
|
||||||
|
dialogOpen.value = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Stops following the events when the last holder stops. */
|
||||||
|
function stop(): void {
|
||||||
|
holders = Math.max(0, holders - 1);
|
||||||
|
if (holders === 0) {
|
||||||
|
unsubscribe?.();
|
||||||
|
unsubscribe = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads the project's servers.
|
||||||
|
*
|
||||||
|
* @returns whether it worked.
|
||||||
|
*/
|
||||||
|
async function load(): Promise<boolean> {
|
||||||
|
const result = await run("deploy.servers");
|
||||||
|
if (!result.ok) {
|
||||||
|
servers.value = [];
|
||||||
|
defaultServer.value = null;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const v = obj(result.value);
|
||||||
|
const list = Array.isArray(v.servers) ? (v.servers as unknown[]) : [];
|
||||||
|
servers.value = list
|
||||||
|
.slice(0, MAX_SERVERS)
|
||||||
|
.map(toServer)
|
||||||
|
.filter((s): s is DeployServer => s !== null);
|
||||||
|
defaultServer.value = typeof v.defaultServer === "string" ? v.defaultServer : null;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Reads the log the engine kept (after a reload of the window). */
|
||||||
|
async function loadLog(): Promise<void> {
|
||||||
|
const result = await run("deploy.log");
|
||||||
|
if (!result.ok) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const v = obj(result.value);
|
||||||
|
const list = Array.isArray(v.entries) ? (v.entries as unknown[]) : [];
|
||||||
|
entries.value = list
|
||||||
|
.map(toEntry)
|
||||||
|
.filter((e): e is LogEntry => e !== null)
|
||||||
|
.slice(-MAX_LOG);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Shows the log tool window. */
|
||||||
|
function showLog(): void {
|
||||||
|
visible.value = true;
|
||||||
|
expanded.value = true;
|
||||||
|
void loadLog();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Hides the log tool window. */
|
||||||
|
function hide(): void {
|
||||||
|
visible.value = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Clears the log. */
|
||||||
|
async function clearLog(): Promise<void> {
|
||||||
|
const result = await run("deploy.clearLog");
|
||||||
|
if (result.ok) {
|
||||||
|
entries.value = [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Reads the servers, then opens the servers dialog on the default one. */
|
||||||
|
async function showDialog(): Promise<void> {
|
||||||
|
dialogError.value = null;
|
||||||
|
tested.value = null;
|
||||||
|
question.value = null;
|
||||||
|
await load();
|
||||||
|
dialogOpen.value = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Closes the servers dialog. */
|
||||||
|
function hideDialog(): void {
|
||||||
|
dialogOpen.value = false;
|
||||||
|
question.value = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds or replaces a server, with a new secret when one was typed.
|
||||||
|
*
|
||||||
|
* @param server - the edited server.
|
||||||
|
* @param secret - the typed password or passphrase, or "".
|
||||||
|
* @param makeDefault - also make it the default server.
|
||||||
|
* @returns the saved server's id, or null (the reason is in {@link dialogError}).
|
||||||
|
*/
|
||||||
|
async function saveServer(server: DeployServer, secret: string, makeDefault: boolean): Promise<string | null> {
|
||||||
|
const params: Record<string, JsonValue> = { server: toSaveParams(server) };
|
||||||
|
if (secret !== "") {
|
||||||
|
params.secret = secret;
|
||||||
|
}
|
||||||
|
const result = await run("deploy.saveServer", params);
|
||||||
|
if (!result.ok) {
|
||||||
|
dialogError.value = result.error.message;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
const saved = toServer(obj(result.value).server);
|
||||||
|
if (saved === null) {
|
||||||
|
dialogError.value = null;
|
||||||
|
await load();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (makeDefault && defaultServer.value !== saved.id) {
|
||||||
|
await run("deploy.setDefault", { id: saved.id });
|
||||||
|
} else if (!makeDefault && defaultServer.value === saved.id && servers.value.length > 1) {
|
||||||
|
await run("deploy.setDefault", { id: null });
|
||||||
|
}
|
||||||
|
dialogError.value = null;
|
||||||
|
await load();
|
||||||
|
return saved.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes a server and its keychain entries.
|
||||||
|
*
|
||||||
|
* @param id - the server.
|
||||||
|
*/
|
||||||
|
async function removeServer(id: string): Promise<void> {
|
||||||
|
const result = await run("deploy.removeServer", { id });
|
||||||
|
dialogError.value = result.ok ? null : result.error.message;
|
||||||
|
await load();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests the connection to a saved server; fills {@link tested} and, for
|
||||||
|
* an unknown or changed host key, {@link question}.
|
||||||
|
*
|
||||||
|
* @param id - the server.
|
||||||
|
*/
|
||||||
|
async function testConnection(id: string): Promise<TestOutcome | null> {
|
||||||
|
starting.value = true;
|
||||||
|
tested.value = null;
|
||||||
|
question.value = null;
|
||||||
|
try {
|
||||||
|
const result = await runWaiting("deploy.testConnection", { id });
|
||||||
|
if (!result.ok) {
|
||||||
|
dialogError.value = result.error.message;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
dialogError.value = null;
|
||||||
|
const read = toTest(id, result.value);
|
||||||
|
tested.value = read.outcome;
|
||||||
|
question.value = read.question;
|
||||||
|
return read.outcome;
|
||||||
|
} finally {
|
||||||
|
starting.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Trusts the asked host key and tests again.
|
||||||
|
*
|
||||||
|
* @param replace - replace a changed trusted key (the second, explicit choice).
|
||||||
|
*/
|
||||||
|
async function trustHostKey(replace: boolean): Promise<void> {
|
||||||
|
const q = question.value;
|
||||||
|
if (q === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const result = await run("deploy.trustHostKey", {
|
||||||
|
id: q.serverId,
|
||||||
|
algorithm: q.algorithm,
|
||||||
|
fingerprint: q.fingerprint,
|
||||||
|
replace,
|
||||||
|
});
|
||||||
|
if (!result.ok) {
|
||||||
|
dialogError.value = result.error.message;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
question.value = null;
|
||||||
|
await testConnection(q.serverId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Dismisses the host-key question without trusting the key. */
|
||||||
|
function rejectHostKey(): void {
|
||||||
|
question.value = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Runs an upload or download and reports it in a toast.
|
||||||
|
*
|
||||||
|
* @param command - `deploy.upload` or `deploy.download`.
|
||||||
|
* @param paths - project-relative paths, "" for the whole project.
|
||||||
|
* @param id - a server, or the default one when absent.
|
||||||
|
* @returns whether it ran without failures.
|
||||||
|
*/
|
||||||
|
async function transfer(command: "deploy.upload" | "deploy.download", paths: string[], id?: string): Promise<boolean> {
|
||||||
|
if (busy.value) {
|
||||||
|
notifications.notify({ level: "warning", messageKey: "notification.deploy.busy" });
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
starting.value = true;
|
||||||
|
try {
|
||||||
|
const params: Record<string, JsonValue> = { paths };
|
||||||
|
if (id !== undefined) {
|
||||||
|
params.id = id;
|
||||||
|
}
|
||||||
|
const result = await runWaiting(command, params);
|
||||||
|
const upload = command === "deploy.upload";
|
||||||
|
if (!result.ok) {
|
||||||
|
const reason = result.error.message.trim() || "?";
|
||||||
|
if (reason === "cancelled" || reason.endsWith(": cancelled")) {
|
||||||
|
notifications.notify({ level: "info", messageKey: "notification.deploy.cancelled" });
|
||||||
|
} else {
|
||||||
|
notifications.notify({
|
||||||
|
level: "error",
|
||||||
|
messageKey: upload ? "notification.deploy.uploadFailed" : "notification.deploy.downloadFailed",
|
||||||
|
message: reason,
|
||||||
|
params: { reason },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const v = obj(result.value);
|
||||||
|
const files = count(v.files);
|
||||||
|
const failed = count(v.failed);
|
||||||
|
const skipped = count(v.skipped);
|
||||||
|
const server = (id !== undefined ? servers.value.find((s) => s.id === id) : target.value)?.name ?? "";
|
||||||
|
notifications.notify({
|
||||||
|
level: failed > 0 ? "warning" : "info",
|
||||||
|
messageKey: failed > 0
|
||||||
|
? "notification.deploy.partly"
|
||||||
|
: upload
|
||||||
|
? "notification.deploy.uploaded"
|
||||||
|
: "notification.deploy.downloaded",
|
||||||
|
params: { files: filesText(files), failed: filesText(failed), skipped: String(skipped), server },
|
||||||
|
});
|
||||||
|
return failed === 0;
|
||||||
|
} finally {
|
||||||
|
starting.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Uploads files or folders.
|
||||||
|
*
|
||||||
|
* @param paths - project-relative paths, "" for the whole project.
|
||||||
|
* @param id - a server, or the default one.
|
||||||
|
*/
|
||||||
|
function upload(paths: string[], id?: string): Promise<boolean> {
|
||||||
|
return transfer("deploy.upload", paths, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Downloads files or folders, replacing the local ones.
|
||||||
|
*
|
||||||
|
* @param paths - project-relative paths.
|
||||||
|
* @param id - a server, or the default one.
|
||||||
|
*/
|
||||||
|
function download(paths: string[], id?: string): Promise<boolean> {
|
||||||
|
return transfer("deploy.download", paths, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stops the running job.
|
||||||
|
*
|
||||||
|
* @returns whether one was stopped.
|
||||||
|
*/
|
||||||
|
async function cancel(): Promise<boolean> {
|
||||||
|
const result = await run("deploy.cancel");
|
||||||
|
return result.ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
servers,
|
||||||
|
defaultServer,
|
||||||
|
target,
|
||||||
|
progress,
|
||||||
|
busy,
|
||||||
|
entries,
|
||||||
|
visible,
|
||||||
|
expanded,
|
||||||
|
dialogOpen,
|
||||||
|
question,
|
||||||
|
tested,
|
||||||
|
dialogError,
|
||||||
|
start,
|
||||||
|
stop,
|
||||||
|
load,
|
||||||
|
loadLog,
|
||||||
|
showLog,
|
||||||
|
hide,
|
||||||
|
clearLog,
|
||||||
|
showDialog,
|
||||||
|
hideDialog,
|
||||||
|
saveServer,
|
||||||
|
removeServer,
|
||||||
|
testConnection,
|
||||||
|
trustHostKey,
|
||||||
|
rejectHostKey,
|
||||||
|
upload,
|
||||||
|
download,
|
||||||
|
cancel,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
@ -16,7 +16,8 @@
|
||||||
* the left window when that tool window is already shown.
|
* the left window when that tool window is already shown.
|
||||||
*
|
*
|
||||||
* The bottom panel ({@link BottomPanel}) holds the Find, Terminal and
|
* The bottom panel ({@link BottomPanel}) holds the Find, Terminal and
|
||||||
* Problems tool windows, as tabs in its header while more than one is
|
* Problems tool windows (and the Deployment log, G17, which appears with
|
||||||
|
* `deployment.showLog`), as tabs in its header while more than one is
|
||||||
* shown. Find appears with the UI command `find.open` (`Mod+Alt+F`),
|
* shown. Find appears with the UI command `find.open` (`Mod+Alt+F`),
|
||||||
* Terminal with `terminal.open` (`Mod+Shift+T`, M3.6), Problems with
|
* Terminal with `terminal.open` (`Mod+Shift+T`, M3.6), Problems with
|
||||||
* `problems.open` (`Mod+Alt+P`, M3.3); all are supplied here so they work
|
* `problems.open` (`Mod+Alt+P`, M3.3); all are supplied here so they work
|
||||||
|
|
@ -60,6 +61,8 @@ import { useChangesStore } from "../vcs/changes/changes";
|
||||||
import LogToolWindow from "../vcs/log/LogToolWindow.vue";
|
import LogToolWindow from "../vcs/log/LogToolWindow.vue";
|
||||||
import { SHOW_HISTORY_COMMAND, SHOW_LOG_COMMAND, useLogStore } from "../vcs/log/log";
|
import { SHOW_HISTORY_COMMAND, SHOW_LOG_COMMAND, useLogStore } from "../vcs/log/log";
|
||||||
import StashDialog from "../vcs/stash/StashDialog.vue";
|
import StashDialog from "../vcs/stash/StashDialog.vue";
|
||||||
|
import DeploymentLogToolWindow from "../deploy/DeploymentLogToolWindow.vue";
|
||||||
|
import { useDeployStore } from "../deploy/deploy";
|
||||||
import { SHOW_COMMIT_COMMAND, TOGGLE_BLAME_COMMAND, setCommitOpener, toggleBlame } from "../editor/blame";
|
import { SHOW_COMMIT_COMMAND, TOGGLE_BLAME_COMMAND, setCommitOpener, toggleBlame } from "../editor/blame";
|
||||||
import { SHOW_CHUNK_COMMAND, openChunkPopup } from "../editor/chunkPopup";
|
import { SHOW_CHUNK_COMMAND, openChunkPopup } from "../editor/chunkPopup";
|
||||||
import { activeView } from "../editor/nav/navExtension";
|
import { activeView } from "../editor/nav/navExtension";
|
||||||
|
|
@ -113,11 +116,12 @@ const problems = useProblemsStore();
|
||||||
const nav = useNavStore();
|
const nav = useNavStore();
|
||||||
const changes = useChangesStore();
|
const changes = useChangesStore();
|
||||||
const vcsLog = useLogStore();
|
const vcsLog = useLogStore();
|
||||||
|
const deploy = useDeployStore();
|
||||||
const editor = useEditorStore();
|
const editor = useEditorStore();
|
||||||
const project = useProjectStore();
|
const project = useProjectStore();
|
||||||
|
|
||||||
/** Tool windows of the bottom panel. */
|
/** Tool windows of the bottom panel. */
|
||||||
type BottomTool = "find" | "terminal" | "problems" | "references" | "changes" | "log";
|
type BottomTool = "find" | "terminal" | "problems" | "references" | "changes" | "log" | "deployment";
|
||||||
/** The bottom tool window last chosen. */
|
/** The bottom tool window last chosen. */
|
||||||
const bottomTool = ref<BottomTool>("find");
|
const bottomTool = ref<BottomTool>("find");
|
||||||
/** Bottom tool windows that are shown, in tab order. */
|
/** Bottom tool windows that are shown, in tab order. */
|
||||||
|
|
@ -129,6 +133,7 @@ const bottomTools = computed(() => {
|
||||||
if (nav.visible) tools.push({ id: "references", title: t("nav.references.title") });
|
if (nav.visible) tools.push({ id: "references", title: t("nav.references.title") });
|
||||||
if (changes.visible) tools.push({ id: "changes", title: t("vcs.changes.toolWindow.title") });
|
if (changes.visible) tools.push({ id: "changes", title: t("vcs.changes.toolWindow.title") });
|
||||||
if (vcsLog.visible) tools.push({ id: "log", title: t("vcs.log.toolWindow.title") });
|
if (vcsLog.visible) tools.push({ id: "log", title: t("vcs.log.toolWindow.title") });
|
||||||
|
if (deploy.visible) tools.push({ id: "deployment", title: t("deploy.log.title") });
|
||||||
return tools;
|
return tools;
|
||||||
});
|
});
|
||||||
/** The active bottom tool window: the chosen one if shown, else the first. */
|
/** The active bottom tool window: the chosen one if shown, else the first. */
|
||||||
|
|
@ -148,6 +153,8 @@ const bottomStore = computed(() =>
|
||||||
? changes
|
? changes
|
||||||
: bottomActive.value === "log"
|
: bottomActive.value === "log"
|
||||||
? vcsLog
|
? vcsLog
|
||||||
|
: bottomActive.value === "deployment"
|
||||||
|
? deploy
|
||||||
: find,
|
: find,
|
||||||
);
|
);
|
||||||
/** Expansion of the panel, kept per tool window by its store. */
|
/** Expansion of the panel, kept per tool window by its store. */
|
||||||
|
|
@ -164,7 +171,15 @@ const bottomOpen = computed({
|
||||||
* @param id - the tool window id from the panel.
|
* @param id - the tool window id from the panel.
|
||||||
*/
|
*/
|
||||||
function chooseBottom(id: string): void {
|
function chooseBottom(id: string): void {
|
||||||
if (id === "find" || id === "terminal" || id === "problems" || id === "references" || id === "changes" || id === "log") {
|
if (
|
||||||
|
id === "find" ||
|
||||||
|
id === "terminal" ||
|
||||||
|
id === "problems" ||
|
||||||
|
id === "references" ||
|
||||||
|
id === "changes" ||
|
||||||
|
id === "log" ||
|
||||||
|
id === "deployment"
|
||||||
|
) {
|
||||||
bottomTool.value = id;
|
bottomTool.value = id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -273,6 +288,12 @@ onMounted(() => {
|
||||||
},
|
},
|
||||||
enabled: () => project.root !== null && activeView() !== null,
|
enabled: () => project.root !== null && activeView() !== null,
|
||||||
}),
|
}),
|
||||||
|
commands.provide("deployment.showLog", {
|
||||||
|
run: () => {
|
||||||
|
bottomTool.value = "deployment";
|
||||||
|
deploy.showLog();
|
||||||
|
},
|
||||||
|
}),
|
||||||
commands.provide("view.toggleStructure", {
|
commands.provide("view.toggleStructure", {
|
||||||
run: () => {
|
run: () => {
|
||||||
toggleLeft("structure");
|
toggleLeft("structure");
|
||||||
|
|
@ -370,6 +391,10 @@ onBeforeUnmount(() => {
|
||||||
v-if="vcsLog.visible"
|
v-if="vcsLog.visible"
|
||||||
v-show="bottomActive === 'log'"
|
v-show="bottomActive === 'log'"
|
||||||
/>
|
/>
|
||||||
|
<DeploymentLogToolWindow
|
||||||
|
v-if="deploy.visible"
|
||||||
|
v-show="bottomActive === 'deployment'"
|
||||||
|
/>
|
||||||
</BottomPanel>
|
</BottomPanel>
|
||||||
<StatusBar />
|
<StatusBar />
|
||||||
<StashDialog />
|
<StashDialog />
|
||||||
|
|
|
||||||
|
|
@ -92,26 +92,24 @@ function isPhp(name: string): boolean {
|
||||||
return /\.(php|phtml|inc)$/i.test(name);
|
return /\.(php|phtml|inc)$/i.test(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The open context menu: the file and where it shows; null when closed. */
|
/** The open context menu: the entry and where it shows; null when closed. */
|
||||||
const menu = ref<{ path: string; name: string; x: number; y: number } | null>(null);
|
const menu = ref<{ path: string; name: string; kind: "file" | "dir"; x: number; y: number } | null>(null);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Opens the context menu of a file; folders have none yet.
|
* Opens the context menu of a file or folder (folders get the deployment
|
||||||
|
* items only).
|
||||||
*
|
*
|
||||||
* @param entry - the entry.
|
* @param entry - the entry.
|
||||||
* @param x - window x of the menu.
|
* @param x - window x of the menu.
|
||||||
* @param y - window y of the menu.
|
* @param y - window y of the menu.
|
||||||
*/
|
*/
|
||||||
function openMenu(entry: TreeEntry, x: number, y: number): void {
|
function openMenu(entry: TreeEntry, x: number, y: number): void {
|
||||||
if (entry.kind !== "file") {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
project.select(entry.path);
|
project.select(entry.path);
|
||||||
menu.value = { path: entry.path, name: entry.name, x, y };
|
menu.value = { path: entry.path, name: entry.name, kind: entry.kind === "dir" ? "dir" : "file", x, y };
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Opens the context menu of the selected file from the keyboard, below its row.
|
* Opens the context menu of the selected entry from the keyboard, below its row.
|
||||||
*
|
*
|
||||||
* @param entry - the selected entry.
|
* @param entry - the selected entry.
|
||||||
*/
|
*/
|
||||||
|
|
@ -375,6 +373,7 @@ function onFocus(): void {
|
||||||
v-if="menu"
|
v-if="menu"
|
||||||
:path="menu.path"
|
:path="menu.path"
|
||||||
:name="menu.name"
|
:name="menu.name"
|
||||||
|
:kind="menu.kind"
|
||||||
:x="menu.x"
|
:x="menu.x"
|
||||||
:y="menu.y"
|
:y="menu.y"
|
||||||
@close="closeMenu"
|
@close="closeMenu"
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,11 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
/**
|
/**
|
||||||
* The project tree's context menu for a file (M4.3): Open, Show Diff
|
* The project tree's context menu (M4.3). For a file: Open, Show Diff
|
||||||
* (`vcs.showDiff {path}`) and Show History (`vcs.showHistory {path}`,
|
* (`vcs.showDiff {path}`) and Show History (`vcs.showHistory {path}`,
|
||||||
* M4.6), the Git items dimmed while their command is disabled.
|
* M4.6), the Git items dimmed while their command is disabled. For a file
|
||||||
|
* and a folder: Upload to Server and Download from Server
|
||||||
|
* (`deployment.upload` / `deployment.download {path}`, G17), dimmed while
|
||||||
|
* no project is open or a deployment job runs.
|
||||||
*
|
*
|
||||||
* Follows the WAI-ARIA menu pattern: it takes the focus when it opens,
|
* Follows the WAI-ARIA menu pattern: it takes the focus when it opens,
|
||||||
* Up/Down move between items (wrapping), Enter or Space runs one, Escape,
|
* Up/Down move between items (wrapping), Enter or Space runs one, Escape,
|
||||||
|
|
@ -21,6 +24,8 @@ const props = defineProps<{
|
||||||
path: string;
|
path: string;
|
||||||
/** File name, for the accessible label. */
|
/** File name, for the accessible label. */
|
||||||
name: string;
|
name: string;
|
||||||
|
/** Whether the entry is a file or a folder; a file when absent. */
|
||||||
|
kind?: "file" | "dir";
|
||||||
/** Window x of the pointer (or the row) in pixels. */
|
/** Window x of the pointer (or the row) in pixels. */
|
||||||
x: number;
|
x: number;
|
||||||
/** Window y of the pointer (or the row) in pixels. */
|
/** Window y of the pointer (or the row) in pixels. */
|
||||||
|
|
@ -52,8 +57,24 @@ interface MenuItem {
|
||||||
run: () => Promise<void>;
|
run: () => Promise<void>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The items, in order. */
|
/** The deployment items, for files and folders. */
|
||||||
const items = computed<MenuItem[]>(() => [
|
const deployItems = computed<MenuItem[]>(() => [
|
||||||
|
{
|
||||||
|
id: "upload",
|
||||||
|
label: t("project.tree.menu.upload"),
|
||||||
|
enabled: commands.isEnabled("deployment.upload"),
|
||||||
|
run: () => commands.execute("deployment.upload", { path: props.path }),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "download",
|
||||||
|
label: t("project.tree.menu.download"),
|
||||||
|
enabled: commands.isEnabled("deployment.download"),
|
||||||
|
run: () => commands.execute("deployment.download", { path: props.path }),
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
|
/** The file items. */
|
||||||
|
const fileItems = computed<MenuItem[]>(() => [
|
||||||
{
|
{
|
||||||
id: "open",
|
id: "open",
|
||||||
label: t("project.tree.menu.open"),
|
label: t("project.tree.menu.open"),
|
||||||
|
|
@ -76,6 +97,9 @@ const items = computed<MenuItem[]>(() => [
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
/** The items, in order. */
|
||||||
|
const items = computed<MenuItem[]>(() => (props.kind === "dir" ? deployItems.value : [...fileItems.value, ...deployItems.value]));
|
||||||
|
|
||||||
/** The menu's position, kept inside the window. */
|
/** The menu's position, kept inside the window. */
|
||||||
const position = computed(() => ({
|
const position = computed(() => ({
|
||||||
left: `${String(Math.max(0, Math.min(props.x, window.innerWidth - 200)))}px`,
|
left: `${String(Math.max(0, Math.min(props.x, window.innerWidth - 200)))}px`,
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,11 @@
|
||||||
{
|
{
|
||||||
"app.statusBar.version": "{name} {version}",
|
"app.statusBar.version": "{name} {version}",
|
||||||
|
"command.deployment.download": "Download Current File from Server",
|
||||||
|
"command.deployment.servers": "Deployment Servers…",
|
||||||
|
"command.deployment.showLog": "Deployment Log",
|
||||||
|
"command.deployment.testConnection": "Test Deployment Connection",
|
||||||
|
"command.deployment.upload": "Upload Current File to Server",
|
||||||
|
"command.deployment.uploadProject": "Upload Project to Server",
|
||||||
"command.editor.complete": "Complete Code",
|
"command.editor.complete": "Complete Code",
|
||||||
"command.editor.parameterInfo": "Parameter Info",
|
"command.editor.parameterInfo": "Parameter Info",
|
||||||
"command.editor.quickDocumentation": "Quick Documentation",
|
"command.editor.quickDocumentation": "Quick Documentation",
|
||||||
|
|
@ -58,6 +64,75 @@
|
||||||
"common.toolWindow.resize": "Resize {title}",
|
"common.toolWindow.resize": "Resize {title}",
|
||||||
"common.toolWindow.show": "Show {title}",
|
"common.toolWindow.show": "Show {title}",
|
||||||
"common.toolWindow.stripe": "Tool windows",
|
"common.toolWindow.stripe": "Tool windows",
|
||||||
|
"deploy.auth.agent": "SSH agent",
|
||||||
|
"deploy.auth.key": "Key file",
|
||||||
|
"deploy.auth.password": "Password",
|
||||||
|
"deploy.cancel": "Cancel the deployment",
|
||||||
|
"deploy.dialog.add": "Add Server",
|
||||||
|
"deploy.dialog.addMapping": "Add Mapping",
|
||||||
|
"deploy.dialog.browse": "Browse…",
|
||||||
|
"deploy.dialog.close": "Close",
|
||||||
|
"deploy.dialog.confirmRemove": "Really Remove",
|
||||||
|
"deploy.dialog.defaultMark": "default",
|
||||||
|
"deploy.dialog.ftpWarning": "Plain FTP sends everything, including the password, unencrypted. Prefer SFTP or FTPS.",
|
||||||
|
"deploy.dialog.mappingsHint": "Local folder (project-relative, empty for the project root) → remote folder (relative to the root, or absolute). Without mappings the project root goes to the root.",
|
||||||
|
"deploy.dialog.mapsTo": "→",
|
||||||
|
"deploy.dialog.pickFolder": "Choose the deployment folder",
|
||||||
|
"deploy.dialog.pickKey": "Choose the private key file",
|
||||||
|
"deploy.dialog.remove": "Remove",
|
||||||
|
"deploy.dialog.removeMapping": "Remove this mapping",
|
||||||
|
"deploy.dialog.save": "Save",
|
||||||
|
"deploy.dialog.secretNone": "Not stored yet; kept only in the system keychain",
|
||||||
|
"deploy.dialog.secretStored": "Stored in the system keychain; type to replace",
|
||||||
|
"deploy.dialog.servers": "Servers",
|
||||||
|
"deploy.dialog.test": "Test Connection",
|
||||||
|
"deploy.dialog.title": "Deployment Servers",
|
||||||
|
"deploy.field.auth": "Sign in with",
|
||||||
|
"deploy.field.default": "Default server of this project",
|
||||||
|
"deploy.field.excluded": "Excluded paths (one per line; * and ? match names)",
|
||||||
|
"deploy.field.folder": "Folder",
|
||||||
|
"deploy.field.host": "Host",
|
||||||
|
"deploy.field.keyPath": "Private key file",
|
||||||
|
"deploy.field.kind": "Type",
|
||||||
|
"deploy.field.mappingLocal": "Local folder",
|
||||||
|
"deploy.field.mappingRemote": "Remote folder",
|
||||||
|
"deploy.field.mappings": "Path mappings",
|
||||||
|
"deploy.field.name": "Name",
|
||||||
|
"deploy.field.passphrase": "Key passphrase",
|
||||||
|
"deploy.field.password": "Password",
|
||||||
|
"deploy.field.port": "Port",
|
||||||
|
"deploy.field.root": "Root folder on the server",
|
||||||
|
"deploy.field.rootPlaceholder": "/var/www/html",
|
||||||
|
"deploy.field.uploadOnSave": "Upload files when they are saved",
|
||||||
|
"deploy.field.user": "User",
|
||||||
|
"deploy.files.one": "1 file",
|
||||||
|
"deploy.files.other": "{count} files",
|
||||||
|
"deploy.hostKey.changed": "The host key of {host} is not the one you trusted. Someone may be intercepting the connection. Replace the trusted key only if you know the server was reinstalled.",
|
||||||
|
"deploy.hostKey.changedTitle": "The server's host key changed",
|
||||||
|
"deploy.hostKey.keep": "Keep the Trusted Key",
|
||||||
|
"deploy.hostKey.offered": "Offered now:",
|
||||||
|
"deploy.hostKey.reject": "Don't Trust",
|
||||||
|
"deploy.hostKey.replace": "Replace the Trusted Key",
|
||||||
|
"deploy.hostKey.trust": "Trust and Connect",
|
||||||
|
"deploy.hostKey.trusted": "Trusted:",
|
||||||
|
"deploy.hostKey.unknown": "This is the first connection to {host}. Compare this fingerprint with the one from the server's administrator before you trust it:",
|
||||||
|
"deploy.hostKey.unknownTitle": "Unknown host key",
|
||||||
|
"deploy.kind.folder": "Local or mounted folder",
|
||||||
|
"deploy.kind.ftp": "FTP",
|
||||||
|
"deploy.kind.ftps": "FTPS (FTP over TLS)",
|
||||||
|
"deploy.kind.sftp": "SFTP",
|
||||||
|
"deploy.log.clear": "Clear",
|
||||||
|
"deploy.log.empty": "No deployment yet.",
|
||||||
|
"deploy.log.error": "Error",
|
||||||
|
"deploy.log.info": "Info",
|
||||||
|
"deploy.log.running": "{server}: {done} of {total} files {file}",
|
||||||
|
"deploy.log.title": "Deployment",
|
||||||
|
"deploy.log.warning": "Warning",
|
||||||
|
"deploy.operation.download": "Downloading",
|
||||||
|
"deploy.operation.test": "Testing",
|
||||||
|
"deploy.operation.upload": "Uploading",
|
||||||
|
"deploy.progress.files": "{operation} {done}/{total} · {server}",
|
||||||
|
"deploy.progress.short": "{operation} · {server}",
|
||||||
"editor.assist.kind.class": "Class",
|
"editor.assist.kind.class": "Class",
|
||||||
"editor.assist.kind.color": "Colour",
|
"editor.assist.kind.color": "Colour",
|
||||||
"editor.assist.kind.constant": "Constant",
|
"editor.assist.kind.constant": "Constant",
|
||||||
|
|
@ -175,6 +250,15 @@
|
||||||
"notification.app.dataMigrationFailed": "Cannot copy your settings and tools from {from}: {error}. Lutra starts with the defaults and tries again next time.",
|
"notification.app.dataMigrationFailed": "Cannot copy your settings and tools from {from}: {error}. Lutra starts with the defaults and tries again next time.",
|
||||||
"notification.close": "Close notification",
|
"notification.close": "Close notification",
|
||||||
"notification.command.failed": "{command} failed: {message}",
|
"notification.command.failed": "{command} failed: {message}",
|
||||||
|
"notification.deploy.busy": "A deployment is running; wait for it or cancel it.",
|
||||||
|
"notification.deploy.cancelled": "Deployment cancelled.",
|
||||||
|
"notification.deploy.downloadFailed": "Download failed: {reason}",
|
||||||
|
"notification.deploy.downloaded": "Downloaded {files} from {server}.",
|
||||||
|
"notification.deploy.noServer": "No default deployment server yet. Add one, or choose the default.",
|
||||||
|
"notification.deploy.partly": "Transferred {files}, but {failed} failed ({server}); see the Deployment log.",
|
||||||
|
"notification.deploy.uploadFailed": "Upload failed: {reason}",
|
||||||
|
"notification.deploy.uploadOnSaveFailed": "Upload on save to {server} failed: {error}",
|
||||||
|
"notification.deploy.uploaded": "Uploaded {files} to {server}.",
|
||||||
"notification.lsp.failed": "The PHP language server stopped: {reason}. Run Restart PHP Language Server to try again.",
|
"notification.lsp.failed": "The PHP language server stopped: {reason}. Run Restart PHP Language Server to try again.",
|
||||||
"notification.lsp.message": "PHP language server: {message}",
|
"notification.lsp.message": "PHP language server: {message}",
|
||||||
"notification.lsp.renamed": "Renamed to {name}: {edits} changes in {files} files ({written} closed files saved)",
|
"notification.lsp.renamed": "Renamed to {name}: {edits} changes in {files} files ({written} closed files saved)",
|
||||||
|
|
@ -256,10 +340,12 @@
|
||||||
"project.openFolder": "Open Folder…",
|
"project.openFolder": "Open Folder…",
|
||||||
"project.toolWindow.title": "Project",
|
"project.toolWindow.title": "Project",
|
||||||
"project.tree.loading": "Loading…",
|
"project.tree.loading": "Loading…",
|
||||||
|
"project.tree.menu.download": "Download from Server",
|
||||||
"project.tree.menu.label": "Actions for {name}",
|
"project.tree.menu.label": "Actions for {name}",
|
||||||
"project.tree.menu.open": "Open",
|
"project.tree.menu.open": "Open",
|
||||||
"project.tree.menu.showDiff": "Show Diff",
|
"project.tree.menu.showDiff": "Show Diff",
|
||||||
"project.tree.menu.showHistory": "Show History",
|
"project.tree.menu.showHistory": "Show History",
|
||||||
|
"project.tree.menu.upload": "Upload to Server",
|
||||||
"project.tree.truncated": "Listing truncated: more entries than can be shown",
|
"project.tree.truncated": "Listing truncated: more entries than can be shown",
|
||||||
"recovery.dialog.changedOnDisk": "The file changed on disk since then",
|
"recovery.dialog.changedOnDisk": "The file changed on disk since then",
|
||||||
"recovery.dialog.discard": "Discard",
|
"recovery.dialog.discard": "Discard",
|
||||||
|
|
|
||||||
|
|
@ -165,6 +165,29 @@ export type EngineEventPayload =
|
||||||
phase?: unknown;
|
phase?: unknown;
|
||||||
/** 0–100; unchecked. */
|
/** 0–100; unchecked. */
|
||||||
percent?: unknown;
|
percent?: unknown;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
kind: "deployProgress";
|
||||||
|
/** Whether a deployment job runs; unchecked. */
|
||||||
|
active: unknown;
|
||||||
|
/** `test`, `upload` or `download`; unchecked. */
|
||||||
|
operation?: unknown;
|
||||||
|
/** The server's name; unchecked. */
|
||||||
|
server?: unknown;
|
||||||
|
/** `connecting`, `planning` or `transferring`; unchecked. */
|
||||||
|
phase?: unknown;
|
||||||
|
/** The file being transferred; unchecked. */
|
||||||
|
file?: unknown;
|
||||||
|
/** Files done and planned, bytes done and planned; unchecked. */
|
||||||
|
filesDone?: unknown;
|
||||||
|
filesTotal?: unknown;
|
||||||
|
bytesDone?: unknown;
|
||||||
|
bytesTotal?: unknown;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
kind: "deployLog";
|
||||||
|
/** `{id, time, level, server, message}`; unchecked. */
|
||||||
|
entry: unknown;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Callback receiving engine events. */
|
/** Callback receiving engine events. */
|
||||||
|
|
|
||||||
356
ui/tests/deploy/Deploy.test.ts
Normal file
356
ui/tests/deploy/Deploy.test.ts
Normal file
|
|
@ -0,0 +1,356 @@
|
||||||
|
/**
|
||||||
|
* Tests of deployment (G17): reading untrusted servers, progress, log
|
||||||
|
* lines and test-connection answers; the save params (no read-only
|
||||||
|
* fields); the status-bar item (progress with Cancel); upload and download
|
||||||
|
* through the UI commands with their toasts (no default server opens the
|
||||||
|
* dialog); the servers dialog (save with a write-only secret that is never
|
||||||
|
* shown again, test connection, the unknown and the changed host key, and
|
||||||
|
* remove after asking); the Deployment log; and the registration of the
|
||||||
|
* UI commands. The engine is a fake behind the mocked Tauri `invoke` and
|
||||||
|
* `listen`.
|
||||||
|
*/
|
||||||
|
import { flushPromises, mount, type VueWrapper } from "@vue/test-utils";
|
||||||
|
import { createPinia, setActivePinia, type Pinia } from "pinia";
|
||||||
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||||
|
|
||||||
|
const invoke = vi.hoisted(() => vi.fn());
|
||||||
|
const listen = vi.hoisted(() => vi.fn());
|
||||||
|
vi.mock("@tauri-apps/api/core", () => ({ invoke }));
|
||||||
|
vi.mock("@tauri-apps/api/event", () => ({ listen }));
|
||||||
|
|
||||||
|
import { useCommandsStore } from "../../src/commands/store";
|
||||||
|
import { UI_COMMANDS } from "../../src/commands/uiCommands";
|
||||||
|
import DeployStatusItem from "../../src/components/deploy/DeployStatusItem.vue";
|
||||||
|
import DeploymentLogToolWindow from "../../src/components/deploy/DeploymentLogToolWindow.vue";
|
||||||
|
import {
|
||||||
|
blankServer,
|
||||||
|
toEntry,
|
||||||
|
toProgress,
|
||||||
|
toSaveParams,
|
||||||
|
toServer,
|
||||||
|
toTest,
|
||||||
|
useDeployStore,
|
||||||
|
} from "../../src/components/deploy/deploy";
|
||||||
|
import { useNotificationsStore } from "../../src/stores/notifications";
|
||||||
|
import { useProjectStore } from "../../src/stores/project";
|
||||||
|
|
||||||
|
/** The test password; it must never show anywhere. */
|
||||||
|
const SECRET = "Otter-UI-Pa55!";
|
||||||
|
|
||||||
|
/** A recorded engine call. */
|
||||||
|
interface Call {
|
||||||
|
/** Command id. */
|
||||||
|
command: string;
|
||||||
|
/** Its params. */
|
||||||
|
params: Record<string, unknown>;
|
||||||
|
}
|
||||||
|
|
||||||
|
let calls: Call[];
|
||||||
|
let servers: unknown;
|
||||||
|
let testAnswer: unknown;
|
||||||
|
let failures: Record<string, { code: string; message: string }>;
|
||||||
|
let listeners: ((event: { payload: unknown }) => void)[];
|
||||||
|
let pinia: Pinia;
|
||||||
|
let mounted: VueWrapper[];
|
||||||
|
|
||||||
|
/** The calls of a command. */
|
||||||
|
function callsOf(command: string): Call[] {
|
||||||
|
return calls.filter((c) => c.command === command);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Sends an engine event to every listener. */
|
||||||
|
async function emit(payload: unknown): Promise<void> {
|
||||||
|
for (const listener of listeners) {
|
||||||
|
listener({ payload });
|
||||||
|
}
|
||||||
|
await flushPromises();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The texts of the toasts shown. */
|
||||||
|
function toasts(): string[] {
|
||||||
|
return useNotificationsStore(pinia).toasts.map((toast) => toast.text);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A server as the engine lists it. */
|
||||||
|
const STAGING = {
|
||||||
|
id: "s1",
|
||||||
|
name: "Staging",
|
||||||
|
kind: "sftp",
|
||||||
|
host: "staging.example",
|
||||||
|
user: "deploy",
|
||||||
|
root: "/var/www",
|
||||||
|
auth: "password",
|
||||||
|
mappings: [{ local: "public", remote: "html" }],
|
||||||
|
excluded: [".env"],
|
||||||
|
uploadOnSave: false,
|
||||||
|
secretKind: "password",
|
||||||
|
hasSecret: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Mounts the status-bar item with a project open. */
|
||||||
|
async function mountItem(): Promise<VueWrapper> {
|
||||||
|
useProjectStore(pinia).root = { root: "C:/p", name: "p" } as never;
|
||||||
|
const wrapper = mount(DeployStatusItem, { attachTo: document.body, global: { plugins: [pinia] } });
|
||||||
|
mounted.push(wrapper);
|
||||||
|
await useCommandsStore(pinia).start();
|
||||||
|
await flushPromises();
|
||||||
|
return wrapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
pinia = createPinia();
|
||||||
|
setActivePinia(pinia);
|
||||||
|
calls = [];
|
||||||
|
mounted = [];
|
||||||
|
failures = {};
|
||||||
|
listeners = [];
|
||||||
|
servers = { servers: [STAGING], defaultServer: "s1" };
|
||||||
|
testAnswer = { ok: true, message: "Connected to Staging; the root folder /var/www exists." };
|
||||||
|
invoke.mockReset();
|
||||||
|
listen.mockReset();
|
||||||
|
listen.mockImplementation((_name: string, callback: (event: { payload: unknown }) => void) => {
|
||||||
|
listeners.push(callback);
|
||||||
|
return Promise.resolve(() => {
|
||||||
|
listeners = listeners.filter((l) => l !== callback);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
invoke.mockImplementation((cmd: string, args?: { command: string; params: Record<string, unknown> }) => {
|
||||||
|
if (cmd === "engine_list_commands") {
|
||||||
|
return Promise.resolve(
|
||||||
|
["deploy.servers", "deploy.upload", "deploy.download"].map((id) => ({ id, label: id, enabled: true })),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if ((cmd !== "engine_execute" && cmd !== "engine_execute_waiting") || !args) {
|
||||||
|
return Promise.resolve(null);
|
||||||
|
}
|
||||||
|
calls.push({ command: args.command, params: args.params });
|
||||||
|
const failure = failures[args.command];
|
||||||
|
if (failure) {
|
||||||
|
return Promise.reject(Object.assign(new Error(failure.message), failure));
|
||||||
|
}
|
||||||
|
switch (args.command) {
|
||||||
|
case "deploy.servers":
|
||||||
|
return Promise.resolve(servers);
|
||||||
|
case "deploy.saveServer":
|
||||||
|
return Promise.resolve({ server: { ...STAGING, ...(args.params.server as object), id: "s1" } });
|
||||||
|
case "deploy.testConnection":
|
||||||
|
return Promise.resolve(testAnswer);
|
||||||
|
case "deploy.upload":
|
||||||
|
return Promise.resolve({ files: 3, bytes: 10, skipped: 1, failed: 0 });
|
||||||
|
case "deploy.download":
|
||||||
|
return Promise.resolve({ files: 1, bytes: 10, skipped: 0, failed: 0 });
|
||||||
|
case "deploy.log":
|
||||||
|
return Promise.resolve({
|
||||||
|
entries: [{ id: 1, time: 0, level: "info", server: "Staging", message: "public/index.php → html/index.php" }],
|
||||||
|
});
|
||||||
|
default:
|
||||||
|
return Promise.resolve({});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
for (const wrapper of mounted) {
|
||||||
|
wrapper.unmount();
|
||||||
|
}
|
||||||
|
document.body.innerHTML = "";
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("reading the engine's answers", () => {
|
||||||
|
it("reads servers and drops malformed ones", () => {
|
||||||
|
expect(toServer(STAGING)?.mappings).toEqual([{ local: "public", remote: "html" }]);
|
||||||
|
expect(toServer({ ...STAGING, kind: "gopher" })).toBeNull();
|
||||||
|
expect(toServer({ ...STAGING, id: "" })).toBeNull();
|
||||||
|
expect(toServer({ ...STAGING, auth: "magic", port: 2.5 })).toMatchObject({ auth: "password", port: null });
|
||||||
|
expect(toServer(null)).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("reads progress, log lines and test answers", () => {
|
||||||
|
expect(
|
||||||
|
toProgress({ kind: "deployProgress", active: true, operation: "upload", server: "S", filesDone: 2, filesTotal: 5, file: "a.php" }),
|
||||||
|
).toMatchObject({ operation: "upload", filesDone: 2, filesTotal: 5, file: "a.php" });
|
||||||
|
expect(toProgress({ kind: "deployProgress", active: false, operation: "upload" })).toBeNull();
|
||||||
|
expect(toProgress({ kind: "deployProgress", active: true, operation: "rm" })).toBeNull();
|
||||||
|
expect(toEntry({ id: 1, time: 5, level: "error", server: "S", message: "x" })).toMatchObject({ level: "error" });
|
||||||
|
expect(toEntry({ id: 1, level: "loud" })).toBeNull();
|
||||||
|
const asked = toTest("s1", {
|
||||||
|
ok: false,
|
||||||
|
message: "unknown",
|
||||||
|
hostKey: { status: "unknown", host: "h:22", algorithm: "ssh-ed25519", fingerprint: "SHA256:abc" },
|
||||||
|
});
|
||||||
|
expect(asked.question).toMatchObject({ serverId: "s1", status: "unknown", fingerprint: "SHA256:abc" });
|
||||||
|
expect(toTest("s1", { ok: false, needsSecret: "passphrase" }).outcome.needsSecret).toBe("passphrase");
|
||||||
|
expect(toTest("s1", null).outcome.ok).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("sends only editable fields when saving", () => {
|
||||||
|
const params = toSaveParams({
|
||||||
|
...blankServer(),
|
||||||
|
name: "New",
|
||||||
|
host: "h",
|
||||||
|
user: "u",
|
||||||
|
hasSecret: true,
|
||||||
|
mappings: [{ local: " public ", remote: "html" }, { local: "", remote: " " }],
|
||||||
|
excluded: [" .env ", ""],
|
||||||
|
});
|
||||||
|
expect(params).not.toHaveProperty("id");
|
||||||
|
expect(params).not.toHaveProperty("hasSecret");
|
||||||
|
expect(params).not.toHaveProperty("secretKind");
|
||||||
|
expect(params.mappings).toEqual([{ local: "public", remote: "html" }]);
|
||||||
|
expect(params.excluded).toEqual([".env"]);
|
||||||
|
expect(toSaveParams({ ...blankServer(), kind: "ftp", auth: "agent" }).auth).toBe("password");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("status bar and commands", () => {
|
||||||
|
it("shows progress with Cancel and hides when done", async () => {
|
||||||
|
const wrapper = await mountItem();
|
||||||
|
expect(wrapper.find("[data-test='deploy-progress']").exists()).toBe(false);
|
||||||
|
await emit({ kind: "deployProgress", active: true, operation: "upload", server: "Staging", filesDone: 1, filesTotal: 4, phase: "transferring" });
|
||||||
|
expect(wrapper.find("[data-test='deploy-progress']").text()).toContain("1/4");
|
||||||
|
await wrapper.find("[data-test='deploy-cancel']").trigger("click");
|
||||||
|
await flushPromises();
|
||||||
|
expect(callsOf("deploy.cancel")).toHaveLength(1);
|
||||||
|
await emit({ kind: "deployProgress", active: false, operation: "upload" });
|
||||||
|
expect(wrapper.find("[data-test='deploy-progress']").exists()).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("uploads and downloads a path through the UI commands", async () => {
|
||||||
|
await mountItem();
|
||||||
|
const commands = useCommandsStore(pinia);
|
||||||
|
await commands.execute("deployment.upload", { path: "public" });
|
||||||
|
await flushPromises();
|
||||||
|
expect(callsOf("deploy.upload")[0]?.params).toEqual({ paths: ["public"] });
|
||||||
|
expect(toasts().some((t) => t.includes("3 files") && t.includes("Staging"))).toBe(true);
|
||||||
|
await commands.execute("deployment.download", { path: "public/index.php" });
|
||||||
|
await flushPromises();
|
||||||
|
expect(callsOf("deploy.download")[0]?.params).toEqual({ paths: ["public/index.php"] });
|
||||||
|
expect(toasts().some((t) => t.includes("1 file from"))).toBe(true);
|
||||||
|
await commands.execute("deployment.uploadProject");
|
||||||
|
await flushPromises();
|
||||||
|
expect(callsOf("deploy.upload")[1]?.params).toEqual({ paths: [""] });
|
||||||
|
});
|
||||||
|
|
||||||
|
it("explains a failed upload and opens the dialog without a default server", async () => {
|
||||||
|
failures["deploy.upload"] = { code: "failed", message: "the host key of h:22 is not known yet" };
|
||||||
|
await mountItem();
|
||||||
|
const commands = useCommandsStore(pinia);
|
||||||
|
await commands.execute("deployment.upload", { path: "a.php" });
|
||||||
|
await flushPromises();
|
||||||
|
expect(toasts().some((t) => t.includes("host key"))).toBe(true);
|
||||||
|
servers = { servers: [], defaultServer: null };
|
||||||
|
await useDeployStore(pinia).load();
|
||||||
|
await commands.execute("deployment.upload", { path: "a.php" });
|
||||||
|
await flushPromises();
|
||||||
|
expect(callsOf("deploy.upload")).toHaveLength(1);
|
||||||
|
expect(useDeployStore(pinia).dialogOpen).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("registers the UI commands with menu paths and without shortcuts", () => {
|
||||||
|
for (const id of ["deployment.upload", "deployment.download", "deployment.uploadProject", "deployment.testConnection", "deployment.servers", "deployment.showLog"]) {
|
||||||
|
const spec = UI_COMMANDS.find((c) => c.id === id);
|
||||||
|
expect(spec?.menuPath?.startsWith("Tools/Deployment/")).toBe(true);
|
||||||
|
expect(spec?.defaultShortcut).toBeUndefined();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("servers dialog", () => {
|
||||||
|
it("saves with a write-only secret and tests the connection", async () => {
|
||||||
|
const wrapper = await mountItem();
|
||||||
|
await useDeployStore(pinia).showDialog();
|
||||||
|
await flushPromises();
|
||||||
|
expect(wrapper.find("[data-test='deploy-dialog']").exists()).toBe(true);
|
||||||
|
const secret = wrapper.find<HTMLInputElement>("[data-test='deploy-secret']");
|
||||||
|
expect(secret.attributes("type")).toBe("password");
|
||||||
|
expect(secret.element.value).toBe("");
|
||||||
|
expect(secret.attributes("placeholder")).toContain("keychain");
|
||||||
|
await secret.setValue(SECRET);
|
||||||
|
await wrapper.find("[data-test='deploy-upload-on-save']").setValue(true);
|
||||||
|
await wrapper.find("[data-test='deploy-test']").trigger("click");
|
||||||
|
await flushPromises();
|
||||||
|
const saved = callsOf("deploy.saveServer")[0]?.params;
|
||||||
|
expect(saved?.secret).toBe(SECRET);
|
||||||
|
expect((saved?.server as Record<string, unknown>).uploadOnSave).toBe(true);
|
||||||
|
expect(callsOf("deploy.testConnection")[0]?.params).toEqual({ id: "s1" });
|
||||||
|
expect(wrapper.find("[data-test='deploy-tested']").text()).toContain("exists");
|
||||||
|
expect(wrapper.find<HTMLInputElement>("[data-test='deploy-secret']").element.value).toBe("");
|
||||||
|
expect(document.body.innerHTML).not.toContain(SECRET);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("asks about an unknown host key and trusts it", async () => {
|
||||||
|
testAnswer = {
|
||||||
|
ok: false,
|
||||||
|
message: "unknown",
|
||||||
|
hostKey: { status: "unknown", host: "staging.example:22", algorithm: "ssh-ed25519", fingerprint: "SHA256:fp1" },
|
||||||
|
};
|
||||||
|
const wrapper = await mountItem();
|
||||||
|
await useDeployStore(pinia).showDialog();
|
||||||
|
await flushPromises();
|
||||||
|
await wrapper.find("[data-test='deploy-test']").trigger("click");
|
||||||
|
await flushPromises();
|
||||||
|
expect(wrapper.find("[data-test='deploy-hostkey']").text()).toContain("SHA256:fp1");
|
||||||
|
testAnswer = { ok: true, message: "Connected." };
|
||||||
|
await wrapper.find("[data-test='deploy-trust']").trigger("click");
|
||||||
|
await flushPromises();
|
||||||
|
expect(callsOf("deploy.trustHostKey")[0]?.params).toEqual({
|
||||||
|
id: "s1",
|
||||||
|
algorithm: "ssh-ed25519",
|
||||||
|
fingerprint: "SHA256:fp1",
|
||||||
|
replace: false,
|
||||||
|
});
|
||||||
|
expect(callsOf("deploy.testConnection")).toHaveLength(2);
|
||||||
|
expect(wrapper.find("[data-test='deploy-hostkey']").exists()).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("warns about a changed host key and replaces it only on the explicit button", async () => {
|
||||||
|
testAnswer = {
|
||||||
|
ok: false,
|
||||||
|
message: "changed",
|
||||||
|
hostKey: { status: "changed", host: "h:22", algorithm: "ssh-ed25519", fingerprint: "SHA256:new", known: "SHA256:old" },
|
||||||
|
};
|
||||||
|
const wrapper = await mountItem();
|
||||||
|
await useDeployStore(pinia).showDialog();
|
||||||
|
await flushPromises();
|
||||||
|
await wrapper.find("[data-test='deploy-test']").trigger("click");
|
||||||
|
await flushPromises();
|
||||||
|
const box = wrapper.find("[data-test='deploy-hostkey']");
|
||||||
|
expect(box.text()).toContain("SHA256:old");
|
||||||
|
expect(box.text()).toContain("SHA256:new");
|
||||||
|
expect(wrapper.find("[data-test='deploy-trust']").exists()).toBe(false);
|
||||||
|
await wrapper.find("[data-test='deploy-replace']").trigger("click");
|
||||||
|
await flushPromises();
|
||||||
|
expect(callsOf("deploy.trustHostKey")[0]?.params).toMatchObject({ replace: true });
|
||||||
|
});
|
||||||
|
|
||||||
|
it("removes a server only after asking", async () => {
|
||||||
|
const wrapper = await mountItem();
|
||||||
|
await useDeployStore(pinia).showDialog();
|
||||||
|
await flushPromises();
|
||||||
|
await wrapper.find("[data-test='deploy-remove']").trigger("click");
|
||||||
|
expect(callsOf("deploy.removeServer")).toHaveLength(0);
|
||||||
|
await wrapper.find("[data-test='deploy-remove']").trigger("click");
|
||||||
|
await flushPromises();
|
||||||
|
expect(callsOf("deploy.removeServer")[0]?.params).toEqual({ id: "s1" });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("deployment log", () => {
|
||||||
|
it("shows the kept log and new lines, and clears", async () => {
|
||||||
|
await mountItem();
|
||||||
|
const deploy = useDeployStore(pinia);
|
||||||
|
deploy.showLog();
|
||||||
|
const wrapper = mount(DeploymentLogToolWindow, { global: { plugins: [pinia] } });
|
||||||
|
mounted.push(wrapper);
|
||||||
|
await flushPromises();
|
||||||
|
expect(wrapper.findAll("[data-test='deploy-log-line']")).toHaveLength(1);
|
||||||
|
await emit({ kind: "deployLog", entry: { id: 2, time: 0, level: "error", server: "Staging", message: "a.php: denied" } });
|
||||||
|
const lines = wrapper.findAll("[data-test='deploy-log-line']");
|
||||||
|
expect(lines).toHaveLength(2);
|
||||||
|
expect(lines[1]?.classes()).toContain("deploy-log__line--error");
|
||||||
|
await wrapper.find("[data-test='deploy-log-clear']").trigger("click");
|
||||||
|
await flushPromises();
|
||||||
|
expect(callsOf("deploy.clearLog")).toHaveLength(1);
|
||||||
|
expect(wrapper.findAll("[data-test='deploy-log-line']")).toHaveLength(0);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
@ -165,7 +165,7 @@ describe("en.json", () => {
|
||||||
it("uses flat dotted keys of known areas with string values", () => {
|
it("uses flat dotted keys of known areas with string values", () => {
|
||||||
for (const [key, value] of Object.entries(en)) {
|
for (const [key, value] of Object.entries(en)) {
|
||||||
expect(key).toMatch(
|
expect(key).toMatch(
|
||||||
/^(app|command|project|editor|common|palette|theme|recovery|notification|settings|find|goto|structure|menu|terminal|problems|nav|vcs)\.[A-Za-z0-9]+(\.[A-Za-z0-9]+)*$/,
|
/^(app|command|project|editor|common|palette|theme|recovery|notification|settings|find|goto|structure|menu|terminal|problems|nav|vcs|deploy)\.[A-Za-z0-9]+(\.[A-Za-z0-9]+)*$/,
|
||||||
);
|
);
|
||||||
expect(typeof value).toBe("string");
|
expect(typeof value).toBe("string");
|
||||||
expect(value.trim()).not.toBe("");
|
expect(value.trim()).not.toBe("");
|
||||||
|
|
|
||||||
|
|
@ -254,7 +254,7 @@ describe("AppMenu", () => {
|
||||||
expect(menuShown()).toBe(true);
|
expect(menuShown()).toBe(true);
|
||||||
expect(menu.find("[data-test=menu-button]").attributes("aria-expanded")).toBe("true");
|
expect(menu.find("[data-test=menu-button]").attributes("aria-expanded")).toBe("true");
|
||||||
const headings = [...document.querySelectorAll("[data-test=menu-group]")].map((g) => g.querySelector(".app-menu__heading")?.textContent.trim());
|
const headings = [...document.querySelectorAll("[data-test=menu-group]")].map((g) => g.querySelector(".app-menu__heading")?.textContent.trim());
|
||||||
expect(headings).toEqual(["File", "Edit", "View", "Go", "Git", "Help"]);
|
expect(headings).toEqual(["File", "Edit", "View", "Go", "Git", "Tools", "Help"]);
|
||||||
const listed = listing() as { id: string; menuPath: string | null }[];
|
const listed = listing() as { id: string; menuPath: string | null }[];
|
||||||
const withPath = listed.filter((c) => c.menuPath !== null);
|
const withPath = listed.filter((c) => c.menuPath !== null);
|
||||||
expect([...itemIds()].sort()).toEqual(withPath.map((c) => c.id).sort());
|
expect([...itemIds()].sort()).toEqual(withPath.map((c) => c.id).sort());
|
||||||
|
|
|
||||||
|
|
@ -295,7 +295,7 @@ describe("CommandPalette", () => {
|
||||||
const wrapper = await mountPalette();
|
const wrapper = await mountPalette();
|
||||||
await press(PALETTE_KEY);
|
await press(PALETTE_KEY);
|
||||||
await press({ key: "ArrowUp" });
|
await press({ key: "ArrowUp" });
|
||||||
expect(wrapper.find("[aria-selected=true]").attributes("data-command")).toBe("terminal.open");
|
expect(wrapper.find("[aria-selected=true]").attributes("data-command")).toBe("deployment.uploadProject");
|
||||||
await press({ key: "ArrowDown" });
|
await press({ key: "ArrowDown" });
|
||||||
expect(wrapper.find("[aria-selected=true]").attributes("data-command")).toBe("vcs.abortMerge");
|
expect(wrapper.find("[aria-selected=true]").attributes("data-command")).toBe("vcs.abortMerge");
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -475,7 +475,7 @@ describe("project tree context menu", () => {
|
||||||
await tree.find("[data-path='a.php']").trigger("contextmenu", { clientX: 40, clientY: 50 });
|
await tree.find("[data-path='a.php']").trigger("contextmenu", { clientX: 40, clientY: 50 });
|
||||||
const menu = document.querySelector("[data-test=tree-menu]");
|
const menu = document.querySelector("[data-test=tree-menu]");
|
||||||
expect(menu).not.toBeNull();
|
expect(menu).not.toBeNull();
|
||||||
expect([...document.querySelectorAll("[data-test=tree-menu-item]")].map((item) => item.textContent.trim())).toEqual(["Open", "Show Diff", "Show History"]);
|
expect([...document.querySelectorAll("[data-test=tree-menu-item]")].map((item) => item.textContent.trim())).toEqual(["Open", "Show Diff", "Show History", "Upload to Server", "Download from Server"]);
|
||||||
(document.querySelector("[data-item=showDiff]") as HTMLElement).click();
|
(document.querySelector("[data-item=showDiff]") as HTMLElement).click();
|
||||||
await flushPromises();
|
await flushPromises();
|
||||||
await flushPromises();
|
await flushPromises();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue