@cicore/cli 1.0.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/bin/ci.js +13 -0
- package/dist/commands/addon/api-actions.d.ts +45 -0
- package/dist/commands/addon/api-actions.d.ts.map +1 -0
- package/dist/commands/addon/api-actions.js +281 -0
- package/dist/commands/addon/api-actions.js.map +1 -0
- package/dist/commands/addon/build.d.ts +11 -0
- package/dist/commands/addon/build.d.ts.map +1 -0
- package/dist/commands/addon/build.js +182 -0
- package/dist/commands/addon/build.js.map +1 -0
- package/dist/commands/addon/create.d.ts +11 -0
- package/dist/commands/addon/create.d.ts.map +1 -0
- package/dist/commands/addon/create.js +1186 -0
- package/dist/commands/addon/create.js.map +1 -0
- package/dist/commands/addon/delete.d.ts +13 -0
- package/dist/commands/addon/delete.d.ts.map +1 -0
- package/dist/commands/addon/delete.js +83 -0
- package/dist/commands/addon/delete.js.map +1 -0
- package/dist/commands/addon/deploy.d.ts +27 -0
- package/dist/commands/addon/deploy.d.ts.map +1 -0
- package/dist/commands/addon/deploy.js +459 -0
- package/dist/commands/addon/deploy.js.map +1 -0
- package/dist/commands/addon/dev-deploy.d.ts +31 -0
- package/dist/commands/addon/dev-deploy.d.ts.map +1 -0
- package/dist/commands/addon/dev-deploy.js +128 -0
- package/dist/commands/addon/dev-deploy.js.map +1 -0
- package/dist/commands/addon/dev.d.ts +36 -0
- package/dist/commands/addon/dev.d.ts.map +1 -0
- package/dist/commands/addon/dev.js +323 -0
- package/dist/commands/addon/dev.js.map +1 -0
- package/dist/commands/addon/extract-classes.d.ts +23 -0
- package/dist/commands/addon/extract-classes.d.ts.map +1 -0
- package/dist/commands/addon/extract-classes.js +281 -0
- package/dist/commands/addon/extract-classes.js.map +1 -0
- package/dist/commands/addon/generate-safelist.d.ts +24 -0
- package/dist/commands/addon/generate-safelist.d.ts.map +1 -0
- package/dist/commands/addon/generate-safelist.js +276 -0
- package/dist/commands/addon/generate-safelist.js.map +1 -0
- package/dist/commands/addon/index.d.ts +19 -0
- package/dist/commands/addon/index.d.ts.map +1 -0
- package/dist/commands/addon/index.js +296 -0
- package/dist/commands/addon/index.js.map +1 -0
- package/dist/commands/addon/init-repo.d.ts +25 -0
- package/dist/commands/addon/init-repo.d.ts.map +1 -0
- package/dist/commands/addon/init-repo.js +171 -0
- package/dist/commands/addon/init-repo.js.map +1 -0
- package/dist/commands/addon/install.d.ts +23 -0
- package/dist/commands/addon/install.d.ts.map +1 -0
- package/dist/commands/addon/install.js +84 -0
- package/dist/commands/addon/install.js.map +1 -0
- package/dist/commands/addon/list.d.ts +10 -0
- package/dist/commands/addon/list.d.ts.map +1 -0
- package/dist/commands/addon/list.js +102 -0
- package/dist/commands/addon/list.js.map +1 -0
- package/dist/commands/addon/manifest-refresh.d.ts +17 -0
- package/dist/commands/addon/manifest-refresh.d.ts.map +1 -0
- package/dist/commands/addon/manifest-refresh.js +48 -0
- package/dist/commands/addon/manifest-refresh.js.map +1 -0
- package/dist/commands/addon/migrate.d.ts +40 -0
- package/dist/commands/addon/migrate.d.ts.map +1 -0
- package/dist/commands/addon/migrate.js +236 -0
- package/dist/commands/addon/migrate.js.map +1 -0
- package/dist/commands/addon/publish.d.ts +33 -0
- package/dist/commands/addon/publish.d.ts.map +1 -0
- package/dist/commands/addon/publish.js +236 -0
- package/dist/commands/addon/publish.js.map +1 -0
- package/dist/commands/addon/scaffold-quality.d.ts +21 -0
- package/dist/commands/addon/scaffold-quality.d.ts.map +1 -0
- package/dist/commands/addon/scaffold-quality.js +90 -0
- package/dist/commands/addon/scaffold-quality.js.map +1 -0
- package/dist/commands/addon/sign.d.ts +9 -0
- package/dist/commands/addon/sign.d.ts.map +1 -0
- package/dist/commands/addon/sign.js +83 -0
- package/dist/commands/addon/sign.js.map +1 -0
- package/dist/commands/addon/toggle.d.ts +6 -0
- package/dist/commands/addon/toggle.d.ts.map +1 -0
- package/dist/commands/addon/toggle.js +46 -0
- package/dist/commands/addon/toggle.js.map +1 -0
- package/dist/commands/agent/index.d.ts +34 -0
- package/dist/commands/agent/index.d.ts.map +1 -0
- package/dist/commands/agent/index.js +564 -0
- package/dist/commands/agent/index.js.map +1 -0
- package/dist/commands/brand/index.d.ts +54 -0
- package/dist/commands/brand/index.d.ts.map +1 -0
- package/dist/commands/brand/index.js +367 -0
- package/dist/commands/brand/index.js.map +1 -0
- package/dist/commands/build/index.d.ts +53 -0
- package/dist/commands/build/index.d.ts.map +1 -0
- package/dist/commands/build/index.js +726 -0
- package/dist/commands/build/index.js.map +1 -0
- package/dist/commands/cache/flush-local.d.ts +31 -0
- package/dist/commands/cache/flush-local.d.ts.map +1 -0
- package/dist/commands/cache/flush-local.js +161 -0
- package/dist/commands/cache/flush-local.js.map +1 -0
- package/dist/commands/cache/index.d.ts +14 -0
- package/dist/commands/cache/index.d.ts.map +1 -0
- package/dist/commands/cache/index.js +453 -0
- package/dist/commands/cache/index.js.map +1 -0
- package/dist/commands/check/index.d.ts +8 -0
- package/dist/commands/check/index.d.ts.map +1 -0
- package/dist/commands/check/index.js +1316 -0
- package/dist/commands/check/index.js.map +1 -0
- package/dist/commands/cloudflare/index.d.ts +8 -0
- package/dist/commands/cloudflare/index.d.ts.map +1 -0
- package/dist/commands/cloudflare/index.js +453 -0
- package/dist/commands/cloudflare/index.js.map +1 -0
- package/dist/commands/core/create.d.ts +12 -0
- package/dist/commands/core/create.d.ts.map +1 -0
- package/dist/commands/core/create.js +206 -0
- package/dist/commands/core/create.js.map +1 -0
- package/dist/commands/core/delete.d.ts +11 -0
- package/dist/commands/core/delete.d.ts.map +1 -0
- package/dist/commands/core/delete.js +64 -0
- package/dist/commands/core/delete.js.map +1 -0
- package/dist/commands/core/env.d.ts +12 -0
- package/dist/commands/core/env.d.ts.map +1 -0
- package/dist/commands/core/env.js +95 -0
- package/dist/commands/core/env.js.map +1 -0
- package/dist/commands/core/health.d.ts +6 -0
- package/dist/commands/core/health.d.ts.map +1 -0
- package/dist/commands/core/health.js +215 -0
- package/dist/commands/core/health.js.map +1 -0
- package/dist/commands/core/index.d.ts +15 -0
- package/dist/commands/core/index.d.ts.map +1 -0
- package/dist/commands/core/index.js +86 -0
- package/dist/commands/core/index.js.map +1 -0
- package/dist/commands/core/list.d.ts +11 -0
- package/dist/commands/core/list.d.ts.map +1 -0
- package/dist/commands/core/list.js +58 -0
- package/dist/commands/core/list.js.map +1 -0
- package/dist/commands/core/rebuild.d.ts +13 -0
- package/dist/commands/core/rebuild.d.ts.map +1 -0
- package/dist/commands/core/rebuild.js +119 -0
- package/dist/commands/core/rebuild.js.map +1 -0
- package/dist/commands/db/index.d.ts +23 -0
- package/dist/commands/db/index.d.ts.map +1 -0
- package/dist/commands/db/index.js +355 -0
- package/dist/commands/db/index.js.map +1 -0
- package/dist/commands/db/promote-silo.d.ts +320 -0
- package/dist/commands/db/promote-silo.d.ts.map +1 -0
- package/dist/commands/db/promote-silo.js +930 -0
- package/dist/commands/db/promote-silo.js.map +1 -0
- package/dist/commands/db/relocate.d.ts +41 -0
- package/dist/commands/db/relocate.d.ts.map +1 -0
- package/dist/commands/db/relocate.js +482 -0
- package/dist/commands/db/relocate.js.map +1 -0
- package/dist/commands/db/rollback-silo.d.ts +44 -0
- package/dist/commands/db/rollback-silo.d.ts.map +1 -0
- package/dist/commands/db/rollback-silo.js +402 -0
- package/dist/commands/db/rollback-silo.js.map +1 -0
- package/dist/commands/deploy/index.d.ts +26 -0
- package/dist/commands/deploy/index.d.ts.map +1 -0
- package/dist/commands/deploy/index.js +107 -0
- package/dist/commands/deploy/index.js.map +1 -0
- package/dist/commands/devops/index.d.ts +6 -0
- package/dist/commands/devops/index.d.ts.map +1 -0
- package/dist/commands/devops/index.js +220 -0
- package/dist/commands/devops/index.js.map +1 -0
- package/dist/commands/domain/index.d.ts +8 -0
- package/dist/commands/domain/index.d.ts.map +1 -0
- package/dist/commands/domain/index.js +386 -0
- package/dist/commands/domain/index.js.map +1 -0
- package/dist/commands/image/index.d.ts +8 -0
- package/dist/commands/image/index.d.ts.map +1 -0
- package/dist/commands/image/index.js +308 -0
- package/dist/commands/image/index.js.map +1 -0
- package/dist/commands/install/factory-reset.d.ts +21 -0
- package/dist/commands/install/factory-reset.d.ts.map +1 -0
- package/dist/commands/install/factory-reset.js +83 -0
- package/dist/commands/install/factory-reset.js.map +1 -0
- package/dist/commands/install/index.d.ts +17 -0
- package/dist/commands/install/index.d.ts.map +1 -0
- package/dist/commands/install/index.js +44 -0
- package/dist/commands/install/index.js.map +1 -0
- package/dist/commands/install/install.d.ts +35 -0
- package/dist/commands/install/install.d.ts.map +1 -0
- package/dist/commands/install/install.js +171 -0
- package/dist/commands/install/install.js.map +1 -0
- package/dist/commands/login/index.d.ts +15 -0
- package/dist/commands/login/index.d.ts.map +1 -0
- package/dist/commands/login/index.js +58 -0
- package/dist/commands/login/index.js.map +1 -0
- package/dist/commands/nginx/index.d.ts +11 -0
- package/dist/commands/nginx/index.d.ts.map +1 -0
- package/dist/commands/nginx/index.js +580 -0
- package/dist/commands/nginx/index.js.map +1 -0
- package/dist/commands/server/bootstrap.d.ts +25 -0
- package/dist/commands/server/bootstrap.d.ts.map +1 -0
- package/dist/commands/server/bootstrap.js +260 -0
- package/dist/commands/server/bootstrap.js.map +1 -0
- package/dist/commands/server/index.d.ts +8 -0
- package/dist/commands/server/index.d.ts.map +1 -0
- package/dist/commands/server/index.js +2524 -0
- package/dist/commands/server/index.js.map +1 -0
- package/dist/commands/setup/index.d.ts +34 -0
- package/dist/commands/setup/index.d.ts.map +1 -0
- package/dist/commands/setup/index.js +423 -0
- package/dist/commands/setup/index.js.map +1 -0
- package/dist/commands/ssl/index.d.ts +8 -0
- package/dist/commands/ssl/index.d.ts.map +1 -0
- package/dist/commands/ssl/index.js +275 -0
- package/dist/commands/ssl/index.js.map +1 -0
- package/dist/commands/superadmin/index.d.ts +16 -0
- package/dist/commands/superadmin/index.d.ts.map +1 -0
- package/dist/commands/superadmin/index.js +81 -0
- package/dist/commands/superadmin/index.js.map +1 -0
- package/dist/commands/tenant/index.d.ts +6 -0
- package/dist/commands/tenant/index.d.ts.map +1 -0
- package/dist/commands/tenant/index.js +192 -0
- package/dist/commands/tenant/index.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +107 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/addon-sign.d.ts +23 -0
- package/dist/lib/addon-sign.d.ts.map +1 -0
- package/dist/lib/addon-sign.js +39 -0
- package/dist/lib/addon-sign.js.map +1 -0
- package/dist/lib/addon-sign.test.d.ts +2 -0
- package/dist/lib/addon-sign.test.d.ts.map +1 -0
- package/dist/lib/addon-sign.test.js +27 -0
- package/dist/lib/addon-sign.test.js.map +1 -0
- package/dist/lib/cdn.d.ts +25 -0
- package/dist/lib/cdn.d.ts.map +1 -0
- package/dist/lib/cdn.js +131 -0
- package/dist/lib/cdn.js.map +1 -0
- package/dist/lib/cloudflare.d.ts +133 -0
- package/dist/lib/cloudflare.d.ts.map +1 -0
- package/dist/lib/cloudflare.js +435 -0
- package/dist/lib/cloudflare.js.map +1 -0
- package/dist/lib/config.d.ts +96 -0
- package/dist/lib/config.d.ts.map +1 -0
- package/dist/lib/config.js +132 -0
- package/dist/lib/config.js.map +1 -0
- package/dist/lib/env.d.ts +8 -0
- package/dist/lib/env.d.ts.map +1 -0
- package/dist/lib/env.js +64 -0
- package/dist/lib/env.js.map +1 -0
- package/dist/lib/hosts.d.ts +194 -0
- package/dist/lib/hosts.d.ts.map +1 -0
- package/dist/lib/hosts.js +183 -0
- package/dist/lib/hosts.js.map +1 -0
- package/dist/lib/logger.d.ts +68 -0
- package/dist/lib/logger.d.ts.map +1 -0
- package/dist/lib/logger.js +130 -0
- package/dist/lib/logger.js.map +1 -0
- package/dist/lib/nginx-config.d.ts +78 -0
- package/dist/lib/nginx-config.d.ts.map +1 -0
- package/dist/lib/nginx-config.js +736 -0
- package/dist/lib/nginx-config.js.map +1 -0
- package/dist/lib/ops/addon-dev.d.ts +93 -0
- package/dist/lib/ops/addon-dev.d.ts.map +1 -0
- package/dist/lib/ops/addon-dev.js +237 -0
- package/dist/lib/ops/addon-dev.js.map +1 -0
- package/dist/lib/ops/addon-quality.d.ts +38 -0
- package/dist/lib/ops/addon-quality.d.ts.map +1 -0
- package/dist/lib/ops/addon-quality.js +338 -0
- package/dist/lib/ops/addon-quality.js.map +1 -0
- package/dist/lib/ops/addon-routes.d.ts +49 -0
- package/dist/lib/ops/addon-routes.d.ts.map +1 -0
- package/dist/lib/ops/addon-routes.js +189 -0
- package/dist/lib/ops/addon-routes.js.map +1 -0
- package/dist/lib/ops/addon.d.ts +120 -0
- package/dist/lib/ops/addon.d.ts.map +1 -0
- package/dist/lib/ops/addon.js +260 -0
- package/dist/lib/ops/addon.js.map +1 -0
- package/dist/lib/ops/cdn.d.ts +87 -0
- package/dist/lib/ops/cdn.d.ts.map +1 -0
- package/dist/lib/ops/cdn.js +170 -0
- package/dist/lib/ops/cdn.js.map +1 -0
- package/dist/lib/ops/cf.d.ts +36 -0
- package/dist/lib/ops/cf.d.ts.map +1 -0
- package/dist/lib/ops/cf.js +114 -0
- package/dist/lib/ops/cf.js.map +1 -0
- package/dist/lib/ops/compose.d.ts +95 -0
- package/dist/lib/ops/compose.d.ts.map +1 -0
- package/dist/lib/ops/compose.js +165 -0
- package/dist/lib/ops/compose.js.map +1 -0
- package/dist/lib/ops/core.d.ts +117 -0
- package/dist/lib/ops/core.d.ts.map +1 -0
- package/dist/lib/ops/core.js +322 -0
- package/dist/lib/ops/core.js.map +1 -0
- package/dist/lib/ops/db.d.ts +116 -0
- package/dist/lib/ops/db.d.ts.map +1 -0
- package/dist/lib/ops/db.js +351 -0
- package/dist/lib/ops/db.js.map +1 -0
- package/dist/lib/ops/dns.d.ts +111 -0
- package/dist/lib/ops/dns.d.ts.map +1 -0
- package/dist/lib/ops/dns.js +306 -0
- package/dist/lib/ops/dns.js.map +1 -0
- package/dist/lib/ops/image.d.ts +94 -0
- package/dist/lib/ops/image.d.ts.map +1 -0
- package/dist/lib/ops/image.js +159 -0
- package/dist/lib/ops/image.js.map +1 -0
- package/dist/lib/ops/nginx.d.ts +114 -0
- package/dist/lib/ops/nginx.d.ts.map +1 -0
- package/dist/lib/ops/nginx.js +388 -0
- package/dist/lib/ops/nginx.js.map +1 -0
- package/dist/lib/ops/redis.d.ts +7 -0
- package/dist/lib/ops/redis.d.ts.map +1 -0
- package/dist/lib/ops/redis.js +35 -0
- package/dist/lib/ops/redis.js.map +1 -0
- package/dist/lib/ops/ssh.d.ts +127 -0
- package/dist/lib/ops/ssh.d.ts.map +1 -0
- package/dist/lib/ops/ssh.js +269 -0
- package/dist/lib/ops/ssh.js.map +1 -0
- package/dist/lib/prompts.d.ts +46 -0
- package/dist/lib/prompts.d.ts.map +1 -0
- package/dist/lib/prompts.js +113 -0
- package/dist/lib/prompts.js.map +1 -0
- package/dist/lib/sast.d.ts +43 -0
- package/dist/lib/sast.d.ts.map +1 -0
- package/dist/lib/sast.js +79 -0
- package/dist/lib/sast.js.map +1 -0
- package/dist/lib/sast.test.d.ts +2 -0
- package/dist/lib/sast.test.d.ts.map +1 -0
- package/dist/lib/sast.test.js +33 -0
- package/dist/lib/sast.test.js.map +1 -0
- package/dist/lib/shell.d.ts +61 -0
- package/dist/lib/shell.d.ts.map +1 -0
- package/dist/lib/shell.js +183 -0
- package/dist/lib/shell.js.map +1 -0
- package/dist/lib/ssh-config.d.ts +37 -0
- package/dist/lib/ssh-config.d.ts.map +1 -0
- package/dist/lib/ssh-config.js +122 -0
- package/dist/lib/ssh-config.js.map +1 -0
- package/dist/lib/tenant-scope.d.ts +38 -0
- package/dist/lib/tenant-scope.d.ts.map +1 -0
- package/dist/lib/tenant-scope.js +129 -0
- package/dist/lib/tenant-scope.js.map +1 -0
- package/dist/lib/tenant-scope.test.d.ts +2 -0
- package/dist/lib/tenant-scope.test.d.ts.map +1 -0
- package/dist/lib/tenant-scope.test.js +223 -0
- package/dist/lib/tenant-scope.test.js.map +1 -0
- package/package.json +58 -0
- package/templates/bootstrap/.env.template +54 -0
- package/templates/bootstrap/docker-compose.yml +145 -0
- package/templates/vhost.conf.tmpl +446 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CiCore CLI — SSH/SCP primitives
|
|
3
|
+
*
|
|
4
|
+
* Host-aware command execution. Every function takes a {@link HostConfig}
|
|
5
|
+
* and uses its `sshAlias`, `sshKeyPath`, and optional `deployUser` to build
|
|
6
|
+
* the SSH target — no global SSH state, no environment-based dispatch.
|
|
7
|
+
*
|
|
8
|
+
* All commands run through execa with `reject: false` so callers can branch
|
|
9
|
+
* on the typed `ExecResult` instead of catching exceptions. Streaming is
|
|
10
|
+
* supported for interactive long-running commands (deploys, compose up).
|
|
11
|
+
*
|
|
12
|
+
* Dry-run is honored: when `--dry-run` is set on the CLI, every primitive
|
|
13
|
+
* logs what it would do and returns a success result without touching the
|
|
14
|
+
* remote host.
|
|
15
|
+
*/
|
|
16
|
+
import type { HostConfig } from '../hosts.js';
|
|
17
|
+
export interface ExecResult {
|
|
18
|
+
readonly stdout: string;
|
|
19
|
+
readonly stderr: string;
|
|
20
|
+
readonly exitCode: number;
|
|
21
|
+
readonly success: boolean;
|
|
22
|
+
}
|
|
23
|
+
export interface RunOptions {
|
|
24
|
+
/** Suppress the `▸ <cmd>` log line before execution. Result still returns. */
|
|
25
|
+
readonly silent?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Stream stdout/stderr to the terminal in real time (inherits parent FDs).
|
|
28
|
+
* Resulting `stdout`/`stderr` strings will be empty — the output went to
|
|
29
|
+
* the screen instead of being captured. Use for long-running deploys.
|
|
30
|
+
*/
|
|
31
|
+
readonly stream?: boolean;
|
|
32
|
+
/** Working directory for local commands. Ignored for remote. */
|
|
33
|
+
readonly cwd?: string;
|
|
34
|
+
/**
|
|
35
|
+
* stdin payload piped to the command. Useful for `bash -s` heredoc-style
|
|
36
|
+
* remote scripts: pass the script body as `input`, pass `bash -s` as the
|
|
37
|
+
* command. Avoids shell-quoting hazards in heredoc embedding.
|
|
38
|
+
*/
|
|
39
|
+
readonly input?: string;
|
|
40
|
+
/**
|
|
41
|
+
* Environment variables overlaid on the inherited environment for the
|
|
42
|
+
* local command only — remote commands need to receive env via `VAR=val`
|
|
43
|
+
* prefix or `export` in the script body.
|
|
44
|
+
*/
|
|
45
|
+
readonly env?: Readonly<Record<string, string>>;
|
|
46
|
+
}
|
|
47
|
+
export interface RemoteOptions extends RunOptions {
|
|
48
|
+
/**
|
|
49
|
+
* Connect as `cfg.deployUser` (the forced-command receiver) instead of
|
|
50
|
+
* `cfg.sshUser`. Only valid for hosts that have a deployUser configured —
|
|
51
|
+
* other hosts ignore this flag and fall back to sshUser. Use for addon /
|
|
52
|
+
* core install scripts that go through the wrapper.
|
|
53
|
+
*/
|
|
54
|
+
readonly asDeployUser?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Execute even when global dry-run is on. For salt-okunur (SELECT) komutlar:
|
|
57
|
+
* bir dry-run *planı* gerçek veriyi okuyabilmeli (validate/inventory/discovery).
|
|
58
|
+
* Yazı yollarında ASLA set edilmez — sadece dbSelectJson gibi read-only
|
|
59
|
+
* helper'lar geçer. Bkz docs/planning/2026-06-02-cli-dryrun-selfloop-fix.md (Part A).
|
|
60
|
+
*/
|
|
61
|
+
readonly allowInDryRun?: boolean;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Run a command on the local machine.
|
|
65
|
+
*
|
|
66
|
+
* Arguments go through execa's argv-array path — no shell, no implicit
|
|
67
|
+
* expansion, no injection risk. If you need shell features (pipes, glob),
|
|
68
|
+
* invoke `bash -c "<script>"` explicitly with the script in `args`.
|
|
69
|
+
*/
|
|
70
|
+
export declare function runLocal(command: string, args?: readonly string[], opts?: RunOptions): Promise<ExecResult>;
|
|
71
|
+
/**
|
|
72
|
+
* Run a single shell command on the host described by `cfg` via SSH.
|
|
73
|
+
*
|
|
74
|
+
* Connection target is built from `cfg.deployUser ?? <sshAlias's User>` and
|
|
75
|
+
* `cfg.sshAlias`. The identity file (`cfg.sshKeyPath`) is passed explicitly
|
|
76
|
+
* with `-i`, so even if `~/.ssh/config` selects a different key for the
|
|
77
|
+
* alias, we use the configured one. ConnectTimeout caps stalled connects
|
|
78
|
+
* at 10 seconds.
|
|
79
|
+
*
|
|
80
|
+
* `command` is sent as a single argument to the remote shell. Quote-aware
|
|
81
|
+
* callers should use {@link runRemoteScript} for multi-line scripts.
|
|
82
|
+
*/
|
|
83
|
+
export declare function runRemote(cfg: HostConfig, command: string, opts?: RemoteOptions): Promise<ExecResult>;
|
|
84
|
+
/**
|
|
85
|
+
* Run a multi-line shell script on the remote host by piping it to `bash -s`.
|
|
86
|
+
*
|
|
87
|
+
* Avoids the quoting hazards of embedding scripts in a single `ssh "<script>"`
|
|
88
|
+
* argument: the script body goes through stdin, so quotes and `$` inside it
|
|
89
|
+
* mean what they look like.
|
|
90
|
+
*
|
|
91
|
+
* `env` is exported into the remote shell before the script runs. Keys are
|
|
92
|
+
* validated as `[A-Z_][A-Z0-9_]*` to prevent injection through env-name; values
|
|
93
|
+
* are single-quote-escaped.
|
|
94
|
+
*/
|
|
95
|
+
export declare function runRemoteScript(cfg: HostConfig, script: string, opts?: RemoteOptions & {
|
|
96
|
+
readonly env?: Readonly<Record<string, string>>;
|
|
97
|
+
}): Promise<ExecResult>;
|
|
98
|
+
/**
|
|
99
|
+
* Copy a local file or directory to the remote host via SCP.
|
|
100
|
+
*
|
|
101
|
+
* Uses `-O` (legacy SCP protocol) which is required by ssh-wrapper.sh
|
|
102
|
+
* forced-command pattern — the newer SFTP protocol skips the command guard.
|
|
103
|
+
* Recursive flag enables directory copy.
|
|
104
|
+
*
|
|
105
|
+
* `remotePath` is interpreted relative to the deploy user's home unless
|
|
106
|
+
* absolute. Callers should pass absolute paths to avoid surprises.
|
|
107
|
+
*/
|
|
108
|
+
export declare function uploadFile(cfg: HostConfig, localPath: string, remotePath: string, opts?: {
|
|
109
|
+
readonly recursive?: boolean;
|
|
110
|
+
readonly silent?: boolean;
|
|
111
|
+
readonly asDeployUser?: boolean;
|
|
112
|
+
}): Promise<ExecResult>;
|
|
113
|
+
/**
|
|
114
|
+
* Quick connectivity probe — runs `true` on the remote and reports success.
|
|
115
|
+
* Useful as a preflight step before a long deploy. Forced-command hosts
|
|
116
|
+
* (cicore-deploy@) reject arbitrary commands, so use {@link sshReachable}
|
|
117
|
+
* instead when targeting such hosts.
|
|
118
|
+
*/
|
|
119
|
+
export declare function sshAlive(cfg: HostConfig): Promise<boolean>;
|
|
120
|
+
/**
|
|
121
|
+
* TCP-level reachability check for hosts whose SSH refuses arbitrary cmds.
|
|
122
|
+
* Returns true if `ssh -o BatchMode=yes -o ConnectTimeout=5 <target> exit`
|
|
123
|
+
* exits cleanly (auth + connection established, command rejected is fine).
|
|
124
|
+
* Probes the deploy-user path because that's where the wrapper sits.
|
|
125
|
+
*/
|
|
126
|
+
export declare function sshReachable(cfg: HostConfig): Promise<boolean>;
|
|
127
|
+
//# sourceMappingURL=ssh.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ssh.d.ts","sourceRoot":"","sources":["../../../src/lib/ops/ssh.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAKH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAQ7C,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;CAC1B;AAaD,MAAM,WAAW,UAAU;IACzB,8EAA8E;IAC9E,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAA;IACzB;;;;OAIG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAA;IACzB,gEAAgE;IAChE,QA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EAAE,OAAO,CAAA;CAAO,GACtG,OAAO,CAAC,UAAU,CAAC,CAkBrB;AAED;;;;;GAKG;AACH,wBAAsB,QAAQ,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,CAKhE;AAED;;;;;GAKG;AACH,wBAAsB,YAAY,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,CAQpE"}
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CiCore CLI — SSH/SCP primitives
|
|
3
|
+
*
|
|
4
|
+
* Host-aware command execution. Every function takes a {@link HostConfig}
|
|
5
|
+
* and uses its `sshAlias`, `sshKeyPath`, and optional `deployUser` to build
|
|
6
|
+
* the SSH target — no global SSH state, no environment-based dispatch.
|
|
7
|
+
*
|
|
8
|
+
* All commands run through execa with `reject: false` so callers can branch
|
|
9
|
+
* on the typed `ExecResult` instead of catching exceptions. Streaming is
|
|
10
|
+
* supported for interactive long-running commands (deploys, compose up).
|
|
11
|
+
*
|
|
12
|
+
* Dry-run is honored: when `--dry-run` is set on the CLI, every primitive
|
|
13
|
+
* logs what it would do and returns a success result without touching the
|
|
14
|
+
* remote host.
|
|
15
|
+
*/
|
|
16
|
+
import { execa } from 'execa';
|
|
17
|
+
import { homedir } from 'node:os';
|
|
18
|
+
import { resolve as resolvePath } from 'node:path';
|
|
19
|
+
import { isDryRun, isVerbose } from '../config.js';
|
|
20
|
+
import { log } from '../logger.js';
|
|
21
|
+
const DRY_RUN_OK = Object.freeze({
|
|
22
|
+
stdout: '',
|
|
23
|
+
stderr: '',
|
|
24
|
+
exitCode: 0,
|
|
25
|
+
success: true,
|
|
26
|
+
});
|
|
27
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
28
|
+
// Local execution
|
|
29
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
30
|
+
/**
|
|
31
|
+
* Run a command on the local machine.
|
|
32
|
+
*
|
|
33
|
+
* Arguments go through execa's argv-array path — no shell, no implicit
|
|
34
|
+
* expansion, no injection risk. If you need shell features (pipes, glob),
|
|
35
|
+
* invoke `bash -c "<script>"` explicitly with the script in `args`.
|
|
36
|
+
*/
|
|
37
|
+
export async function runLocal(command, args = [], opts = {}) {
|
|
38
|
+
if (!opts.silent && !opts.stream) {
|
|
39
|
+
log.cmd(`${command} ${args.join(' ')}`);
|
|
40
|
+
}
|
|
41
|
+
if (isDryRun()) {
|
|
42
|
+
log.debug('[dry-run] local:', command, args.join(' '));
|
|
43
|
+
return DRY_RUN_OK;
|
|
44
|
+
}
|
|
45
|
+
return invokeExeca(command, args, {
|
|
46
|
+
cwd: opts.cwd,
|
|
47
|
+
input: opts.input,
|
|
48
|
+
env: opts.env,
|
|
49
|
+
streamOutput: opts.stream === true,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
53
|
+
// Remote execution (SSH)
|
|
54
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
55
|
+
/**
|
|
56
|
+
* Run a single shell command on the host described by `cfg` via SSH.
|
|
57
|
+
*
|
|
58
|
+
* Connection target is built from `cfg.deployUser ?? <sshAlias's User>` and
|
|
59
|
+
* `cfg.sshAlias`. The identity file (`cfg.sshKeyPath`) is passed explicitly
|
|
60
|
+
* with `-i`, so even if `~/.ssh/config` selects a different key for the
|
|
61
|
+
* alias, we use the configured one. ConnectTimeout caps stalled connects
|
|
62
|
+
* at 10 seconds.
|
|
63
|
+
*
|
|
64
|
+
* `command` is sent as a single argument to the remote shell. Quote-aware
|
|
65
|
+
* callers should use {@link runRemoteScript} for multi-line scripts.
|
|
66
|
+
*/
|
|
67
|
+
export async function runRemote(cfg, command, opts = {}) {
|
|
68
|
+
const target = sshTarget(cfg, opts.asDeployUser === true);
|
|
69
|
+
const sshArgs = buildSshArgs(cfg, target, [command]);
|
|
70
|
+
if (!opts.silent && !opts.stream) {
|
|
71
|
+
log.cmd(`ssh ${target} "${command}"`);
|
|
72
|
+
}
|
|
73
|
+
if (isDryRun() && opts.allowInDryRun !== true) {
|
|
74
|
+
log.debug('[dry-run] remote:', target, command);
|
|
75
|
+
return DRY_RUN_OK;
|
|
76
|
+
}
|
|
77
|
+
return invokeExeca('ssh', sshArgs, {
|
|
78
|
+
input: opts.input,
|
|
79
|
+
streamOutput: opts.stream === true,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Run a multi-line shell script on the remote host by piping it to `bash -s`.
|
|
84
|
+
*
|
|
85
|
+
* Avoids the quoting hazards of embedding scripts in a single `ssh "<script>"`
|
|
86
|
+
* argument: the script body goes through stdin, so quotes and `$` inside it
|
|
87
|
+
* mean what they look like.
|
|
88
|
+
*
|
|
89
|
+
* `env` is exported into the remote shell before the script runs. Keys are
|
|
90
|
+
* validated as `[A-Z_][A-Z0-9_]*` to prevent injection through env-name; values
|
|
91
|
+
* are single-quote-escaped.
|
|
92
|
+
*/
|
|
93
|
+
export async function runRemoteScript(cfg, script, opts = {}) {
|
|
94
|
+
const envPrefix = renderEnvExports(opts.env);
|
|
95
|
+
const body = envPrefix + script;
|
|
96
|
+
const target = sshTarget(cfg, opts.asDeployUser === true);
|
|
97
|
+
if (!opts.silent && !opts.stream) {
|
|
98
|
+
const preview = script.split('\n').slice(0, 3).join(' / ');
|
|
99
|
+
log.cmd(`ssh ${target} bash -s # ${preview.slice(0, 80)}${preview.length > 80 ? '…' : ''}`);
|
|
100
|
+
}
|
|
101
|
+
if (isDryRun() && opts.allowInDryRun !== true) {
|
|
102
|
+
log.debug('[dry-run] remote script (', script.length, 'chars) on', target);
|
|
103
|
+
return DRY_RUN_OK;
|
|
104
|
+
}
|
|
105
|
+
const sshArgs = buildSshArgs(cfg, target, ['bash', '-s']);
|
|
106
|
+
return invokeExeca('ssh', sshArgs, {
|
|
107
|
+
input: body,
|
|
108
|
+
streamOutput: opts.stream === true,
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Copy a local file or directory to the remote host via SCP.
|
|
113
|
+
*
|
|
114
|
+
* Uses `-O` (legacy SCP protocol) which is required by ssh-wrapper.sh
|
|
115
|
+
* forced-command pattern — the newer SFTP protocol skips the command guard.
|
|
116
|
+
* Recursive flag enables directory copy.
|
|
117
|
+
*
|
|
118
|
+
* `remotePath` is interpreted relative to the deploy user's home unless
|
|
119
|
+
* absolute. Callers should pass absolute paths to avoid surprises.
|
|
120
|
+
*/
|
|
121
|
+
export async function uploadFile(cfg, localPath, remotePath, opts = {}) {
|
|
122
|
+
const target = sshTarget(cfg, opts.asDeployUser === true);
|
|
123
|
+
const args = ['-O'];
|
|
124
|
+
if (opts.recursive)
|
|
125
|
+
args.push('-r');
|
|
126
|
+
args.push('-i', expandHome(cfg.sshKeyPath));
|
|
127
|
+
args.push('-o', 'ConnectTimeout=10');
|
|
128
|
+
args.push('-o', 'StrictHostKeyChecking=accept-new');
|
|
129
|
+
args.push(localPath, `${target}:${remotePath}`);
|
|
130
|
+
if (!opts.silent) {
|
|
131
|
+
log.cmd(`scp ${args.join(' ')}`);
|
|
132
|
+
}
|
|
133
|
+
if (isDryRun()) {
|
|
134
|
+
log.debug('[dry-run] upload:', localPath, '→', `${target}:${remotePath}`);
|
|
135
|
+
return DRY_RUN_OK;
|
|
136
|
+
}
|
|
137
|
+
return invokeExeca('scp', args, {});
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Quick connectivity probe — runs `true` on the remote and reports success.
|
|
141
|
+
* Useful as a preflight step before a long deploy. Forced-command hosts
|
|
142
|
+
* (cicore-deploy@) reject arbitrary commands, so use {@link sshReachable}
|
|
143
|
+
* instead when targeting such hosts.
|
|
144
|
+
*/
|
|
145
|
+
export async function sshAlive(cfg) {
|
|
146
|
+
// Probes the normal sshUser path — that's the one orchestration relies on.
|
|
147
|
+
// For deploy-user reachability (forced-command wrapper), use sshReachable.
|
|
148
|
+
const result = await runRemote(cfg, 'true', { silent: true });
|
|
149
|
+
return result.success;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* TCP-level reachability check for hosts whose SSH refuses arbitrary cmds.
|
|
153
|
+
* Returns true if `ssh -o BatchMode=yes -o ConnectTimeout=5 <target> exit`
|
|
154
|
+
* exits cleanly (auth + connection established, command rejected is fine).
|
|
155
|
+
* Probes the deploy-user path because that's where the wrapper sits.
|
|
156
|
+
*/
|
|
157
|
+
export async function sshReachable(cfg) {
|
|
158
|
+
const target = sshTarget(cfg, true /* deploy user */);
|
|
159
|
+
const args = buildSshArgs(cfg, target, ['exit'], { extraOpts: ['-o', 'BatchMode=yes'] });
|
|
160
|
+
const result = await invokeExeca('ssh', args, {});
|
|
161
|
+
// Exit code 0 = ssh OK + remote `exit` succeeded.
|
|
162
|
+
// Exit code 64 = forced-command wrapper rejected `exit` (still reachable).
|
|
163
|
+
// Any other code = real connectivity failure.
|
|
164
|
+
return result.exitCode === 0 || result.exitCode === 64;
|
|
165
|
+
}
|
|
166
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
167
|
+
// Internal helpers
|
|
168
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
169
|
+
/**
|
|
170
|
+
* Build the `ssh <opts> <target> <cmd> [args...]` argv array for execa.
|
|
171
|
+
*
|
|
172
|
+
* Caller passes the resolved `target` so the same routine serves both
|
|
173
|
+
* the regular `sshUser@sshHostname` and the deploy-user variant.
|
|
174
|
+
*
|
|
175
|
+
* Always passes `-i <keyPath>` and `-o ConnectTimeout=10` /
|
|
176
|
+
* `-o StrictHostKeyChecking=accept-new` so the first connect to a new
|
|
177
|
+
* host (e.g. setup flow) doesn't hang on host-key prompts.
|
|
178
|
+
*/
|
|
179
|
+
function buildSshArgs(cfg, target, trailing, opts = {}) {
|
|
180
|
+
return [
|
|
181
|
+
'-i',
|
|
182
|
+
expandHome(cfg.sshKeyPath),
|
|
183
|
+
'-o',
|
|
184
|
+
'ConnectTimeout=10',
|
|
185
|
+
'-o',
|
|
186
|
+
'StrictHostKeyChecking=accept-new',
|
|
187
|
+
...(opts.extraOpts ?? []),
|
|
188
|
+
target,
|
|
189
|
+
...trailing,
|
|
190
|
+
];
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Build the `user@host` target for SSH/SCP.
|
|
194
|
+
*
|
|
195
|
+
* `asDeployUser` = true selects the forced-command receiver account
|
|
196
|
+
* (`cfg.deployUser@cfg.sshHostname`); used only by addon/core install
|
|
197
|
+
* primitives. Default (false) uses the normal sshUser. Hosts without a
|
|
198
|
+
* deployUser configured fall back to sshUser regardless of the flag.
|
|
199
|
+
*/
|
|
200
|
+
function sshTarget(cfg, asDeployUser) {
|
|
201
|
+
const user = asDeployUser && cfg.deployUser !== undefined ? cfg.deployUser : cfg.sshUser;
|
|
202
|
+
return `${user}@${cfg.sshHostname}`;
|
|
203
|
+
}
|
|
204
|
+
/** Expand a leading `~/` or bare `~` to the current user's home directory. */
|
|
205
|
+
function expandHome(p) {
|
|
206
|
+
if (p === '~')
|
|
207
|
+
return homedir();
|
|
208
|
+
if (p.startsWith('~/'))
|
|
209
|
+
return resolvePath(homedir(), p.slice(2));
|
|
210
|
+
return p;
|
|
211
|
+
}
|
|
212
|
+
/** Validate env var name and single-quote-escape value for safe export. */
|
|
213
|
+
function renderEnvExports(env) {
|
|
214
|
+
if (!env || Object.keys(env).length === 0)
|
|
215
|
+
return '';
|
|
216
|
+
const lines = [];
|
|
217
|
+
for (const [key, value] of Object.entries(env)) {
|
|
218
|
+
if (!/^[A-Z_][A-Z0-9_]*$/.test(key)) {
|
|
219
|
+
throw new Error(`Invalid env var name '${key}' — must match /^[A-Z_][A-Z0-9_]*$/`);
|
|
220
|
+
}
|
|
221
|
+
// Single-quote, replace embedded `'` with `'\''` — POSIX-safe quoting.
|
|
222
|
+
const escaped = value.replace(/'/g, `'\\''`);
|
|
223
|
+
lines.push(`export ${key}='${escaped}'`);
|
|
224
|
+
}
|
|
225
|
+
return lines.join('\n') + '\n';
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Thin execa wrapper that returns a {@link ExecResult} for both success
|
|
229
|
+
* and failure, never throws. Verbose mode echoes stderr on non-zero exit.
|
|
230
|
+
*/
|
|
231
|
+
async function invokeExeca(file, args, opts) {
|
|
232
|
+
try {
|
|
233
|
+
const result = opts.streamOutput
|
|
234
|
+
? await execa(file, args, {
|
|
235
|
+
cwd: opts.cwd,
|
|
236
|
+
input: opts.input,
|
|
237
|
+
env: opts.env,
|
|
238
|
+
shell: false,
|
|
239
|
+
reject: false,
|
|
240
|
+
stdout: 'inherit',
|
|
241
|
+
stderr: 'inherit',
|
|
242
|
+
})
|
|
243
|
+
: await execa(file, args, {
|
|
244
|
+
cwd: opts.cwd,
|
|
245
|
+
input: opts.input,
|
|
246
|
+
env: opts.env,
|
|
247
|
+
shell: false,
|
|
248
|
+
reject: false,
|
|
249
|
+
});
|
|
250
|
+
const stdout = opts.streamOutput ? '' : String(result.stdout ?? '');
|
|
251
|
+
const stderr = opts.streamOutput ? '' : String(result.stderr ?? '');
|
|
252
|
+
const exitCode = result.exitCode ?? 0;
|
|
253
|
+
const success = exitCode === 0;
|
|
254
|
+
if (!success && isVerbose() && stderr) {
|
|
255
|
+
log.debug('stderr:', stderr.trim());
|
|
256
|
+
}
|
|
257
|
+
return Object.freeze({ stdout, stderr, exitCode, success });
|
|
258
|
+
}
|
|
259
|
+
catch (error) {
|
|
260
|
+
const execaError = error;
|
|
261
|
+
return Object.freeze({
|
|
262
|
+
stdout: String(execaError.stdout ?? ''),
|
|
263
|
+
stderr: String(execaError.stderr ?? execaError.message ?? ''),
|
|
264
|
+
exitCode: typeof execaError.exitCode === 'number' ? execaError.exitCode : 1,
|
|
265
|
+
success: false,
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
//# sourceMappingURL=ssh.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ssh.js","sourceRoot":"","sources":["../../../src/lib/ops/ssh.ts"],"names":[],"mappings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
8
|
+
*/
|
|
9
|
+
export declare function input(message: string, defaultValue?: string): Promise<string>;
|
|
10
|
+
/**
|
|
11
|
+
* Ask for confirmation (yes/no)
|
|
12
|
+
*/
|
|
13
|
+
export declare function confirm(message: string, defaultValue?: boolean): Promise<boolean>;
|
|
14
|
+
/**
|
|
15
|
+
* Ask for selection from a list
|
|
16
|
+
*/
|
|
17
|
+
export declare function select<T extends string>(message: string, choices: Array<{
|
|
18
|
+
name: T;
|
|
19
|
+
message?: string;
|
|
20
|
+
hint?: string;
|
|
21
|
+
}>): Promise<T>;
|
|
22
|
+
/**
|
|
23
|
+
* Ask for multiple selections
|
|
24
|
+
*/
|
|
25
|
+
export declare function multiSelect<T extends string>(message: string, choices: Array<{
|
|
26
|
+
name: T;
|
|
27
|
+
message?: string;
|
|
28
|
+
hint?: string;
|
|
29
|
+
}>): Promise<T[]>;
|
|
30
|
+
/**
|
|
31
|
+
* Ask for password (hidden input)
|
|
32
|
+
*/
|
|
33
|
+
export declare function password(message: string): Promise<string>;
|
|
34
|
+
/**
|
|
35
|
+
* Double confirmation for dangerous operations
|
|
36
|
+
*/
|
|
37
|
+
export declare function dangerConfirm(message: string, confirmText?: string): Promise<boolean>;
|
|
38
|
+
/**
|
|
39
|
+
* Ask for core name selection
|
|
40
|
+
*/
|
|
41
|
+
export declare function selectCore(cores: string[]): Promise<string>;
|
|
42
|
+
/**
|
|
43
|
+
* Ask for addon name selection
|
|
44
|
+
*/
|
|
45
|
+
export declare function selectAddon(addons: string[]): Promise<string>;
|
|
46
|
+
//# sourceMappingURL=prompts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../src/lib/prompts.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAOH;;GAEG;AACH,wBAAsB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAQnF;AAED;;G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k';
|
|
8
|
+
const { prompt } = enquirer;
|
|
9
|
+
/**
|
|
10
|
+
* Ask for text input
|
|
11
|
+
*/
|
|
12
|
+
export async function input(message, defaultValue) {
|
|
13
|
+
const response = await prompt({
|
|
14
|
+
type: 'input',
|
|
15
|
+
name: 'value',
|
|
16
|
+
message,
|
|
17
|
+
initial: defaultValue,
|
|
18
|
+
});
|
|
19
|
+
return response.value;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Ask for confirmation (yes/no)
|
|
23
|
+
*/
|
|
24
|
+
export async function confirm(message, defaultValue = false) {
|
|
25
|
+
const response = await prompt({
|
|
26
|
+
type: 'confirm',
|
|
27
|
+
name: 'value',
|
|
28
|
+
message,
|
|
29
|
+
initial: defaultValue,
|
|
30
|
+
});
|
|
31
|
+
return response.value;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Ask for selection from a list
|
|
35
|
+
*/
|
|
36
|
+
export async function select(message, choices) {
|
|
37
|
+
const response = await prompt({
|
|
38
|
+
type: 'select',
|
|
39
|
+
name: 'value',
|
|
40
|
+
message,
|
|
41
|
+
choices: choices.map(c => ({
|
|
42
|
+
name: c.name,
|
|
43
|
+
message: c.message || c.name,
|
|
44
|
+
hint: c.hint,
|
|
45
|
+
})),
|
|
46
|
+
});
|
|
47
|
+
return response.value;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Ask for multiple selections
|
|
51
|
+
*/
|
|
52
|
+
export async function multiSelect(message, choices) {
|
|
53
|
+
const response = await prompt({
|
|
54
|
+
type: 'multiselect',
|
|
55
|
+
name: 'value',
|
|
56
|
+
message,
|
|
57
|
+
choices: choices.map(c => ({
|
|
58
|
+
name: c.name,
|
|
59
|
+
message: c.message || c.name,
|
|
60
|
+
hint: c.hint,
|
|
61
|
+
})),
|
|
62
|
+
});
|
|
63
|
+
return response.value;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Ask for password (hidden input)
|
|
67
|
+
*/
|
|
68
|
+
export async function password(message) {
|
|
69
|
+
const response = await prompt({
|
|
70
|
+
type: 'password',
|
|
71
|
+
name: 'value',
|
|
72
|
+
message,
|
|
73
|
+
});
|
|
74
|
+
return response.value;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Double confirmation for dangerous operations
|
|
78
|
+
*/
|
|
79
|
+
export async function dangerConfirm(message, confirmText = 'DELETE') {
|
|
80
|
+
console.log(chalk.red.bold('\n⚠️ DANGER ZONE'));
|
|
81
|
+
console.log(chalk.red(`This action is irreversible!`));
|
|
82
|
+
console.log();
|
|
83
|
+
const firstConfirm = await confirm(message, false);
|
|
84
|
+
if (!firstConfirm)
|
|
85
|
+
return false;
|
|
86
|
+
const typeConfirm = await input(`Type "${chalk.red(confirmText)}" to confirm:`);
|
|
87
|
+
return typeConfirm === confirmText;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Ask for core name selection
|
|
91
|
+
*/
|
|
92
|
+
export async function selectCore(cores) {
|
|
93
|
+
if (cores.length === 0) {
|
|
94
|
+
throw new Error('No cores available');
|
|
95
|
+
}
|
|
96
|
+
if (cores.length === 1) {
|
|
97
|
+
return cores[0];
|
|
98
|
+
}
|
|
99
|
+
return select('Select core:', cores.map(c => ({ name: c })));
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Ask for addon name selection
|
|
103
|
+
*/
|
|
104
|
+
export async function selectAddon(addons) {
|
|
105
|
+
if (addons.length === 0) {
|
|
106
|
+
throw new Error('No addons available');
|
|
107
|
+
}
|
|
108
|
+
if (addons.length === 1) {
|
|
109
|
+
return addons[0];
|
|
110
|
+
}
|
|
111
|
+
return select('Select addon:', addons.map(a => ({ name: a })));
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=prompts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../src/lib/prompts.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,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MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;IACxC,CAAC;IAED,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,OAAO,MAAM,CAAC,cAAc,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAC/D,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,MAAgB;IAChD,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;IACzC,CAAC;IAED,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC;IACnB,CAAC;IAED,OAAO,MAAM,CAAC,eAAe,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AACjE,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CiCore CLI — Semgrep SAST gate (M3.4 P-1b, K8 signed marketplace)
|
|
3
|
+
*
|
|
4
|
+
* Üçüncü-taraf addon PHP'si/JS'i çekirdekte çalışır → publish ÖNCESİ statik analiz
|
|
5
|
+
* KRİTİK kontrol. Bu lib `ci addon publish`'in pre-flight gate'idir (geliştirici
|
|
6
|
+
* tarafı, fail-closed): ERROR-severity bulgu VAR ya da semgrep YOK → publish ABORT
|
|
7
|
+
* (bilinçli `--skip-scan` ile audit'li bypass).
|
|
8
|
+
*
|
|
9
|
+
* NOT (otoriter katman): bu CLI gate'i CLI-run = teorik bypass-edilebilir. OTORİTER
|
|
10
|
+
* tarama (DB scan_status='passed' yazan) ayrı katmandır: publish-addon-job.php
|
|
11
|
+
* (agent, container-içi) — semgrep IMAGE'a eklenince (mehmet/infra) çalışır; o gün
|
|
12
|
+
* gelene dek scan_status server-otoritesiyle 'pending' kalır (P-1, fail-closed: P-2
|
|
13
|
+
* manifest 'passed' istediğinde pending sürüm gated-servable olmaz). KARAR-ENT/seam.
|
|
14
|
+
*/
|
|
15
|
+
export interface SemgrepFinding {
|
|
16
|
+
checkId: string;
|
|
17
|
+
path: string;
|
|
18
|
+
severity: string;
|
|
19
|
+
line?: number;
|
|
20
|
+
}
|
|
21
|
+
export interface SemgrepResult {
|
|
22
|
+
available: boolean;
|
|
23
|
+
ran: boolean;
|
|
24
|
+
errorCount: number;
|
|
25
|
+
findings: SemgrepFinding[];
|
|
26
|
+
message: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Pure: semgrep `--json` stdout'unu bulgulara + ERROR sayısına çevirir.
|
|
30
|
+
* Parse edilemeyen çıktı → boş (ran-but-unparseable; çağıran karar verir).
|
|
31
|
+
*/
|
|
32
|
+
export declare function parseSemgrepJson(raw: string): {
|
|
33
|
+
errorCount: number;
|
|
34
|
+
findings: SemgrepFinding[];
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Semgrep SAST taramasını bir yol üzerinde koşar. Binary yoksa (ENOENT) →
|
|
38
|
+
* `available:false` (çağıran fail-closed ABORT eder). Asla throw etmez.
|
|
39
|
+
*/
|
|
40
|
+
export declare function runSemgrepScan(targetPath: string, opts?: {
|
|
41
|
+
config?: string;
|
|
42
|
+
}): Promise<SemgrepResult>;
|
|
43
|
+
//# sourceMappingURL=sast.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sast.d.ts","sourceRoot":"","sources":["../../src/lib/sast.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,OAAO,CAAC;IACnB,GAAG,EAAE,OAAO,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,cAAc,EAAE,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,cAAc,EAAE,CAAA;CAAE,CAsBhG;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,GAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,OAAO,CAAC,aAAa,CAAC,CA6BzG"}
|