simplemdg-dev-cli 2.5.0 → 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -0
- package/USER_GUIDE.md +58 -1
- package/dist/commands/cache.command.d.ts +2 -0
- package/dist/commands/cache.command.js +129 -0
- package/dist/commands/cache.command.js.map +1 -0
- package/dist/commands/cf.command.js +201 -122
- package/dist/commands/cf.command.js.map +1 -1
- package/dist/commands/gitlab.command.js +33 -23
- package/dist/commands/gitlab.command.js.map +1 -1
- package/dist/core/cache/smart-cache-events.d.ts +3 -0
- package/dist/core/cache/smart-cache-events.js +20 -0
- package/dist/core/cache/smart-cache-events.js.map +1 -0
- package/dist/core/cache/smart-cache-manager.d.ts +20 -0
- package/dist/core/cache/smart-cache-manager.js +148 -0
- package/dist/core/cache/smart-cache-manager.js.map +1 -0
- package/dist/core/cache/smart-cache-store.d.ts +8 -0
- package/dist/core/cache/smart-cache-store.js +74 -0
- package/dist/core/cache/smart-cache-store.js.map +1 -0
- package/dist/core/cache/smart-cache.d.ts +18 -0
- package/dist/core/cache/smart-cache.js +117 -0
- package/dist/core/cache/smart-cache.js.map +1 -0
- package/dist/core/cache/smart-cache.types.d.ts +62 -0
- package/dist/core/cache/smart-cache.types.js +17 -0
- package/dist/core/cache/smart-cache.types.js.map +1 -0
- package/dist/core/cf/cf-target-cache.d.ts +7 -0
- package/dist/core/cf/cf-target-cache.js +58 -0
- package/dist/core/cf/cf-target-cache.js.map +1 -0
- package/dist/core/cf/cf-target.types.d.ts +11 -0
- package/dist/core/cf/cf-target.types.js +11 -0
- package/dist/core/cf/cf-target.types.js.map +1 -0
- package/dist/core/db/db-studio-client.d.ts +1 -1
- package/dist/core/db/db-studio-client.js +250 -55
- package/dist/core/db/db-studio-client.js.map +1 -1
- package/dist/core/db/db-studio-server.js +171 -0
- package/dist/core/db/db-studio-server.js.map +1 -1
- package/dist/core/db/db-studio-styles.d.ts +1 -1
- package/dist/core/db/db-studio-styles.js +63 -0
- package/dist/core/db/db-studio-styles.js.map +1 -1
- package/dist/core/db/db-types.d.ts +54 -0
- package/dist/core/db/studio/sql-formatter.d.ts +25 -0
- package/dist/core/db/studio/sql-formatter.js +139 -0
- package/dist/core/db/studio/sql-formatter.js.map +1 -0
- package/dist/core/db/studio/studio-settings.d.ts +4 -0
- package/dist/core/db/studio/studio-settings.js +39 -0
- package/dist/core/db/studio/studio-settings.js.map +1 -0
- package/dist/core/db/studio/workspace-cache.d.ts +3 -0
- package/dist/core/db/studio/workspace-cache.js +51 -0
- package/dist/core/db/studio/workspace-cache.js.map +1 -0
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/commands/cache.command.ts +159 -0
- package/src/commands/cf.command.ts +232 -129
- package/src/commands/gitlab.command.ts +37 -21
- package/src/core/cache/smart-cache-events.ts +20 -0
- package/src/core/cache/smart-cache-manager.ts +169 -0
- package/src/core/cache/smart-cache-store.ts +83 -0
- package/src/core/cache/smart-cache.ts +97 -0
- package/src/core/cache/smart-cache.types.ts +79 -0
- package/src/core/cf/cf-target-cache.ts +61 -0
- package/src/core/cf/cf-target.types.ts +17 -0
- package/src/core/db/db-studio-client.ts +250 -55
- package/src/core/db/db-studio-server.ts +156 -1
- package/src/core/db/db-studio-styles.ts +63 -0
- package/src/core/db/db-types.ts +61 -0
- package/src/core/db/studio/sql-formatter.ts +139 -0
- package/src/core/db/studio/studio-settings.ts +36 -0
- package/src/core/db/studio/workspace-cache.ts +51 -0
- package/src/index.ts +3 -1
package/README.md
CHANGED
|
@@ -13,12 +13,35 @@ smdg -V
|
|
|
13
13
|
|
|
14
14
|
Some commands rely on external CLIs: `cf` (Cloud Foundry), `cds` (SAP CAP), and `git`. The CLI checks for these **before** running an interactive flow — so you are not asked for credentials only to fail at the end. If a tool is missing, it offers to install it via a detected package manager (`choco`/`brew` for `cf`, `winget`/`choco`/`scoop`/`brew`/`apt-get` for `git`, `npm -g` for `@sap/cds-dk`), or prints the official install link when no manager is available. After installing a tool, open a new terminal so PATH refreshes.
|
|
15
15
|
|
|
16
|
+
## Smart cache (instant, stale-while-revalidate)
|
|
17
|
+
|
|
18
|
+
Slow BTP/CF/GitLab lookups are cached under `~/.simplemdg/cache/` and served **cache-first**: the CLI shows the last known result immediately, then refreshes in the background and updates the cache for next time. These resources rarely change second-to-second, so this makes the CLI feel instant.
|
|
19
|
+
|
|
20
|
+
- `smdg cf apps` prints cached apps right away (e.g. *"Using cached apps for br10 / single-npi-laidon / app from 4 minutes ago."*) and refreshes in the background; `--refresh` forces a live fetch.
|
|
21
|
+
- `smdg gitlab groups` / `smdg gitlab projects` work the same way.
|
|
22
|
+
- `smdg cf org` is a **CF target switcher**: it lists **★ favorites** first, then **◷ recent** targets, then all cached targets — searchable, switchable, and instant (cached-first, no login needed to browse). Switching auto re-logs-in from saved credentials (no repeated password prompts), targets the org/space, and records the target as recent. Choose *Refresh all regions* to rescan. `--list`, `--switch`, `--org`, `--space`, `--api`, `--refresh` still work.
|
|
23
|
+
- A **failed background refresh never wipes the cache** — you keep working from the last good data with a warning.
|
|
24
|
+
- Background refreshes are **deduplicated**: concurrent requests for the same key share one network call.
|
|
25
|
+
- Default TTLs: CF apps 10m, CF env 5m, CF orgs/spaces 6h, CF regions 7d, GitLab groups 6h, GitLab projects 30m. Secrets are never written to plain cache files.
|
|
26
|
+
|
|
27
|
+
Manage the cache with:
|
|
28
|
+
|
|
29
|
+
```powershell
|
|
30
|
+
smdg cache # interactive: status / clear / refresh / open folder
|
|
31
|
+
smdg cache status # counts + "last updated" per namespace
|
|
32
|
+
smdg cache clear cf # scopes: all | cf | gitlab | db | target | <namespace>
|
|
33
|
+
smdg cache refresh cf # invalidate so the next command fetches fresh
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
DB Studio streams background-refresh events over `GET /api/events` (SSE) so its lists can update silently.
|
|
37
|
+
|
|
16
38
|
## Main commands
|
|
17
39
|
|
|
18
40
|
```powershell
|
|
19
41
|
smdg i
|
|
20
42
|
smdg cf login
|
|
21
43
|
smdg cf apps
|
|
44
|
+
smdg cache
|
|
22
45
|
smdg cf bind
|
|
23
46
|
smdg cf env
|
|
24
47
|
smdg cf logs
|
|
@@ -70,6 +93,16 @@ Studio starts a local web server bound to `127.0.0.1` only (auto-selects a free
|
|
|
70
93
|
- **read-only** mode blocks all writes/DDL; dangerous SQL (DROP/TRUNCATE/ALTER/DELETE-or-UPDATE-without-WHERE) asks for confirmation
|
|
71
94
|
- clear loading states (skeletons, spinners, status bar) for every async action
|
|
72
95
|
|
|
96
|
+
IDE-grade workflow:
|
|
97
|
+
|
|
98
|
+
- **workspace tabs** that drag-to-reorder, pin, and restore on next launch (auto-saved to `~/.simplemdg/db-studio-workspace.json`) — unsaved SQL survives a refresh/restart; right-click a tab for Close / Close Others / Close to Right / Pin / Rename / Duplicate
|
|
99
|
+
- **search highlight** on every list (connections, object tree, saved queries) with debounce, Enter-to-search, Esc-to-clear, and "No results found"
|
|
100
|
+
- **quick-filter SQL preview** in the data grid: **Show SQL** (formatted, dialect-correct, with WHERE/ORDER BY/LIMIT/OFFSET), **Copy**, **Open in SQL Console**
|
|
101
|
+
- **SQL editor**: line numbers, **Run dropdown** (Run Selected / Current Statement / All / Explain), `Ctrl+Enter` runs selected/current, `F5` runs all, server-side **Format**, `Ctrl+S` saves (updates linked file or Save As)
|
|
102
|
+
- **grid editing**: `Ctrl+Z`/`Ctrl+Y` undo/redo of pending edits, `Delete` marks a row, `Enter`/`Tab` confirm-and-move, a sticky **change-summary bar** with **Show Changes** (per-cell old→new review)
|
|
103
|
+
- **command palette** (`Ctrl+Shift+P`), keyboard-shortcut help, and a **Settings** panel (restore-workspace, default row limit/schema, read-only default, query timeout, auto-save delay…) stored in `~/.simplemdg/db-studio-settings.json`
|
|
104
|
+
- **breadcrumbs**, **cell value viewer** (pretty-prints JSON), and **copy helpers** (name / full name / SELECT / INSERT / UPDATE templates)
|
|
105
|
+
|
|
73
106
|
### Commands
|
|
74
107
|
|
|
75
108
|
```powershell
|
package/USER_GUIDE.md
CHANGED
|
@@ -1,5 +1,48 @@
|
|
|
1
1
|
# SimpleMDG CLI User Guide
|
|
2
2
|
|
|
3
|
+
## Smart cache
|
|
4
|
+
|
|
5
|
+
The CLI caches slow BTP/Cloud Foundry/GitLab lookups under `~/.simplemdg/cache/` and serves them **cache-first, then refreshes in the background** (stale-while-revalidate). You see the last known result instantly; fresh data replaces it quietly when the refresh finishes.
|
|
6
|
+
|
|
7
|
+
What it means in practice:
|
|
8
|
+
|
|
9
|
+
- `smdg cf apps`, `smdg gitlab groups`, `smdg gitlab projects` show cached results immediately with a note like *"Using cached apps … from 4 minutes ago. Refreshing in background…"*, then update the cache.
|
|
10
|
+
- Add `--refresh` to any of those to force a live fetch and skip the cache.
|
|
11
|
+
- If a refresh fails (e.g. expired CF session, no network), the **old cache is kept** and you get a warning — you can keep working.
|
|
12
|
+
- Concurrent requests for the same data share a single network call (deduplication).
|
|
13
|
+
|
|
14
|
+
Manage the cache:
|
|
15
|
+
|
|
16
|
+
```powershell
|
|
17
|
+
smdg cache # interactive menu
|
|
18
|
+
smdg cache status # what is cached and how old it is
|
|
19
|
+
smdg cache clear cf # clear a scope: all | cf | gitlab | db | target
|
|
20
|
+
smdg cache refresh cf # invalidate so the next command refetches
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Default freshness windows (configurable later): CF apps 10 min, CF env 5 min, CF orgs/spaces 6 h, CF regions 7 days, GitLab groups 6 h, GitLab projects 30 min. **Secrets are never stored in plain cache files** — passwords/tokens/DB credentials stay in the existing encrypted stores.
|
|
24
|
+
|
|
25
|
+
### CF target switcher (`smdg cf org`)
|
|
26
|
+
|
|
27
|
+
When you work across many regions/orgs, `smdg cf org` is a fast target switcher:
|
|
28
|
+
|
|
29
|
+
```txt
|
|
30
|
+
CF Target Switcher
|
|
31
|
+
Favorites
|
|
32
|
+
★ eu20 / arthrex-qas-simplemdg / app
|
|
33
|
+
Recent
|
|
34
|
+
◷ br10 / single-npi-laidon / app
|
|
35
|
+
◷ us21 / par-pacific-qas-simplemdg / app
|
|
36
|
+
All Targets (243)
|
|
37
|
+
...
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
- Browsing is **instant** — it reads cached targets and doesn't need a CF login.
|
|
41
|
+
- Type to search; favorites (★) appear first, recent (◷) second, then all cached targets.
|
|
42
|
+
- Switching sets the API endpoint, **auto re-logs-in from your saved credentials** (no repeated password prompts), targets the org and space, and saves the target to *recent*. You're offered to mark it a **favorite**.
|
|
43
|
+
- *Refresh all regions* rescans live; *Manage favorites* removes saved favorites.
|
|
44
|
+
- Favorites/recent are stored under `~/.simplemdg/cache/` and show up in `smdg cache status`; clear them with `smdg cache clear target`.
|
|
45
|
+
|
|
3
46
|
## GitLab
|
|
4
47
|
|
|
5
48
|
Login once:
|
|
@@ -47,12 +90,26 @@ The Studio opens on a **Welcome page**. The left side has three collapsible sect
|
|
|
47
90
|
|
|
48
91
|
- **Object Explorer** — expand a connection → Catalog → Schemas → a schema → folders (Tables, Views, Procedures, Functions, Synonyms). Children load only when expanded; each folder has its own search and a count badge. Double-click a table to open its data; right-click for Open Data / Open Structure / Generate SELECT / Generate COUNT / Copy Full Name.
|
|
49
92
|
- **SQL tabs** — open from "Open SQL Console", "New query", "Generate SELECT", or a saved query. Run with **Ctrl+Enter**, format, explain (PostgreSQL), pick a row limit, export CSV/JSON, save to a `.sql` file. Dangerous statements require confirmation; read-only mode blocks writes.
|
|
50
|
-
- **Data tabs** —
|
|
93
|
+
- **Data tabs** — a compact, icon-based toolbar gives the **WHERE filter** most of the width (Enter applies, Ctrl+Enter applies + shows generated SQL); next to it are small icon buttons: Apply ▶, Show SQL, Refresh ⟳, Insert +, Delete 🗑 (danger), Structure ▦, and an **Export ⬇ menu** (current page / current query / selected rows as CSV/JSON, plus *Export custom…* for choosing source, columns and format). **Pagination moved to a footer** below the table showing the range, offset, duration, page-size and ◀/▶ buttons. Click row numbers to **multi-select** (Ctrl/Shift to add). For tables with a primary key you can **edit inline** (double-click a cell → yellow), **Insert** (green), and **mark rows for delete** (red) — deletes show a *"N rows marked for delete · Undo"* toast and aren't applied until **Save changes**. A colored pending bar (yellow edits · green inserts · red deletes) offers Save / Revert / Show changes. Right-click a row for **View details / Copy row JSON / Copy INSERT / Copy UPDATE**. Keyboard: `Ctrl+S` save, `Ctrl+Z`/`Ctrl+Y` undo/redo, `Delete` mark selected.
|
|
51
94
|
- **Structure tabs** — Columns (name, type, length, scale, nullable, key, default, comment), Indexes + primary key, generated **DDL**, and table Info (row count).
|
|
52
95
|
- **BTP Import wizard** — a modal (Target → App → Services → Save) that reads `cf env`, detects HANA/PostgreSQL services, and saves a connection with a display name, color, environment, and favorite.
|
|
53
96
|
|
|
54
97
|
The bottom status bar shows connection state, last query duration, row count, and pending-change count.
|
|
55
98
|
|
|
99
|
+
### Productivity features
|
|
100
|
+
|
|
101
|
+
- **Workspace restore** — your open tabs (including unsaved "New Query" content) are auto-saved and restored next time you open the Studio. Toggle this in **Settings**.
|
|
102
|
+
- **Tabs** — drag to reorder, right-click for Close / Close Others / Close to Right / Pin / Rename / Duplicate. `Ctrl+Tab` / `Ctrl+Shift+Tab` switch tabs, `Ctrl+W` closes the active tab.
|
|
103
|
+
- **Command palette** — press `Ctrl+Shift+P` to run any action (new SQL, run, save, import, toggle read-only, settings, …).
|
|
104
|
+
- **SQL editor** — `Ctrl+Enter` runs the selection or the statement at the cursor, `F5` runs the whole tab, the Run ▾ menu offers Run Selected / Current / All / Explain, and **Format** pretty-prints. `Ctrl+S` saves to a `.sql` file (or Save As).
|
|
105
|
+
- **Quick-filter SQL** — in a Data tab, type a `WHERE` and click **Show SQL** to see/copy the exact generated query or open it in a SQL console.
|
|
106
|
+
- **Grid editing** — `Ctrl+Z`/`Ctrl+Y` undo/redo pending edits, `Delete` marks the selected row, `Enter`/`Tab` confirm a cell and move. A change-summary bar shows counts and **Show Changes** lists every old→new value before you save.
|
|
107
|
+
- **Search** — every list highlights matches; press Enter to search, Esc to clear.
|
|
108
|
+
- **Cell viewer** — double-click a result cell to open a viewer that pretty-prints JSON.
|
|
109
|
+
- Press `Ctrl+Shift+P` → **Show Keyboard Shortcuts** for the full list.
|
|
110
|
+
|
|
111
|
+
Settings, the workspace, saved queries, and history live under `~/.simplemdg/` (`db-studio-settings.json`, `db-studio-workspace.json`, `db-queries/`, `db-query-history.json`).
|
|
112
|
+
|
|
56
113
|
### Read-only and dangerous SQL
|
|
57
114
|
|
|
58
115
|
Toggle **Read-only** in the top bar to block INSERT/UPDATE/DELETE/DROP/TRUNCATE/ALTER/CREATE/GRANT/REVOKE. Even in read/write mode, dangerous statements (DROP, TRUNCATE, ALTER, DELETE/UPDATE without WHERE) require confirmation. A "Production-like" badge appears for prod-looking orgs/apps.
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.registerCacheCommands = registerCacheCommands;
|
|
7
|
+
const execa_1 = require("execa");
|
|
8
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
+
const prompts_1 = require("../core/prompts");
|
|
10
|
+
const smart_cache_1 = require("../core/cache/smart-cache");
|
|
11
|
+
function resolveScopeNamespaces(scope) {
|
|
12
|
+
if (!scope) {
|
|
13
|
+
return smart_cache_1.CACHE_SCOPES.all;
|
|
14
|
+
}
|
|
15
|
+
const normalized = scope.trim().toLowerCase();
|
|
16
|
+
if (smart_cache_1.CACHE_SCOPES[normalized]) {
|
|
17
|
+
return smart_cache_1.CACHE_SCOPES[normalized];
|
|
18
|
+
}
|
|
19
|
+
if (smart_cache_1.CACHE_NAMESPACES[normalized]) {
|
|
20
|
+
return [normalized];
|
|
21
|
+
}
|
|
22
|
+
throw new Error(`Unknown cache scope: ${scope}. Use one of: ${Object.keys(smart_cache_1.CACHE_SCOPES).join(", ")} or a namespace.`);
|
|
23
|
+
}
|
|
24
|
+
async function printCacheStatus() {
|
|
25
|
+
console.log(chalk_1.default.bold("SimpleMDG Cache"));
|
|
26
|
+
console.log("");
|
|
27
|
+
const namespaces = Object.keys(smart_cache_1.CACHE_NAMESPACES);
|
|
28
|
+
const stats = await Promise.all(namespaces.map((namespace) => (0, smart_cache_1.statNamespace)(namespace)));
|
|
29
|
+
const labelWidth = Math.max(...namespaces.map((namespace) => smart_cache_1.CACHE_NAMESPACES[namespace].length));
|
|
30
|
+
let total = 0;
|
|
31
|
+
for (const stat of stats) {
|
|
32
|
+
const label = smart_cache_1.CACHE_NAMESPACES[stat.namespace].padEnd(labelWidth);
|
|
33
|
+
total += stat.count;
|
|
34
|
+
if (!stat.exists || stat.count === 0) {
|
|
35
|
+
console.log(`${label} ${chalk_1.default.gray("empty")}`);
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
const countText = `${stat.count} item${stat.count === 1 ? "" : "s"}`.padEnd(13);
|
|
39
|
+
console.log(`${label} ${chalk_1.default.cyan(countText)} ${chalk_1.default.gray(`last updated ${(0, smart_cache_1.formatRelativeTime)(stat.lastUpdatedAt)}`)}`);
|
|
40
|
+
}
|
|
41
|
+
console.log("");
|
|
42
|
+
console.log(chalk_1.default.gray(`${total} cached item(s) total · ${(0, smart_cache_1.getCacheDirectory)()}`));
|
|
43
|
+
}
|
|
44
|
+
async function runClear(scope) {
|
|
45
|
+
const namespaces = resolveScopeNamespaces(scope);
|
|
46
|
+
for (const namespace of namespaces) {
|
|
47
|
+
await (0, smart_cache_1.clearNamespace)(namespace);
|
|
48
|
+
}
|
|
49
|
+
console.log(chalk_1.default.green(`Cleared cache: ${scope ?? "all"} (${namespaces.length} namespace(s)).`));
|
|
50
|
+
}
|
|
51
|
+
async function runRefresh(scope) {
|
|
52
|
+
// "Refresh" invalidates the cache so the next command fetches live data and
|
|
53
|
+
// repopulates under stale-while-revalidate. This avoids needing a live CF/
|
|
54
|
+
// GitLab session inside the cache command itself.
|
|
55
|
+
const namespaces = resolveScopeNamespaces(scope);
|
|
56
|
+
for (const namespace of namespaces) {
|
|
57
|
+
await (0, smart_cache_1.clearNamespace)(namespace);
|
|
58
|
+
}
|
|
59
|
+
console.log(chalk_1.default.green(`Marked for refresh: ${scope ?? "all"}. The next ${scope ?? ""} command will fetch fresh data.`));
|
|
60
|
+
}
|
|
61
|
+
async function openCacheFolder() {
|
|
62
|
+
const directory = (0, smart_cache_1.getCacheDirectory)();
|
|
63
|
+
const command = process.platform === "win32" ? "cmd" : process.platform === "darwin" ? "open" : "xdg-open";
|
|
64
|
+
const args = process.platform === "win32" ? ["/c", "start", "", directory] : [directory];
|
|
65
|
+
await (0, execa_1.execa)(command, args, { reject: false, detached: true, stdio: "ignore" }).catch(() => undefined);
|
|
66
|
+
console.log(chalk_1.default.gray(directory));
|
|
67
|
+
}
|
|
68
|
+
async function runInteractive() {
|
|
69
|
+
for (;;) {
|
|
70
|
+
const action = await (0, prompts_1.searchableSelectChoice)({
|
|
71
|
+
message: "SimpleMDG cache",
|
|
72
|
+
choices: [
|
|
73
|
+
{ title: "View cache status", value: "status" },
|
|
74
|
+
{ title: "Clear a cache scope", value: "clear" },
|
|
75
|
+
{ title: "Refresh a cache scope", value: "refresh" },
|
|
76
|
+
{ title: "Open cache folder", value: "open" },
|
|
77
|
+
{ title: "Exit", value: "exit" },
|
|
78
|
+
],
|
|
79
|
+
allowCustomValue: false,
|
|
80
|
+
});
|
|
81
|
+
if (action === "exit") {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
if (action === "status") {
|
|
85
|
+
await printCacheStatus();
|
|
86
|
+
console.log("");
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
if (action === "open") {
|
|
90
|
+
await openCacheFolder();
|
|
91
|
+
console.log("");
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
const scope = await (0, prompts_1.searchableSelectChoice)({
|
|
95
|
+
message: `Select scope to ${action}`,
|
|
96
|
+
choices: [
|
|
97
|
+
{ title: "All caches", value: "all" },
|
|
98
|
+
{ title: "Cloud Foundry (cf)", value: "cf" },
|
|
99
|
+
{ title: "GitLab", value: "gitlab" },
|
|
100
|
+
{ title: "Database", value: "db" },
|
|
101
|
+
{ title: "CF targets/favorites/recent", value: "target" },
|
|
102
|
+
],
|
|
103
|
+
allowCustomValue: false,
|
|
104
|
+
});
|
|
105
|
+
if (action === "clear") {
|
|
106
|
+
await runClear(scope);
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
await runRefresh(scope);
|
|
110
|
+
}
|
|
111
|
+
console.log("");
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
function registerCacheCommands(program) {
|
|
115
|
+
const cache = program
|
|
116
|
+
.command("cache")
|
|
117
|
+
.description("Inspect and manage the SimpleMDG smart cache (cf/gitlab/db)")
|
|
118
|
+
.action(runInteractive);
|
|
119
|
+
cache.command("status").description("Show cache status for all namespaces").action(printCacheStatus);
|
|
120
|
+
cache
|
|
121
|
+
.command("clear [scope]")
|
|
122
|
+
.description("Clear cache. Scope: all | cf | gitlab | db | target | <namespace>")
|
|
123
|
+
.action((scope) => runClear(scope));
|
|
124
|
+
cache
|
|
125
|
+
.command("refresh [scope]")
|
|
126
|
+
.description("Invalidate cache so the next command fetches fresh. Scope: all | cf | gitlab | db | target")
|
|
127
|
+
.action((scope) => runRefresh(scope));
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=cache.command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.command.js","sourceRoot":"","sources":["../../src/commands/cache.command.ts"],"names":[],"mappings":";;;;;AA6IA,sDAiBC;AA9JD,iCAA8B;AAC9B,kDAA0B;AAE1B,6CAAyD;AACzD,2DAOmC;AAEnC,SAAS,sBAAsB,CAAC,KAAyB;IACvD,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,0BAAY,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