@nibgat/ncli 0.0.0-stage → 2.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/LICENSE +21 -0
- package/README.md +156 -2
- package/dist/bin/ncli.d.ts +2 -0
- package/dist/bin/ncli.js +9 -0
- package/dist/bin/ncli.js.map +1 -0
- package/dist/commands/auth.d.ts +2 -0
- package/dist/commands/auth.js +723 -0
- package/dist/commands/auth.js.map +1 -0
- package/dist/commands/buyment.d.ts +2 -0
- package/dist/commands/buyment.js +174 -0
- package/dist/commands/buyment.js.map +1 -0
- package/dist/commands/cloud.d.ts +2 -0
- package/dist/commands/cloud.js +281 -0
- package/dist/commands/cloud.js.map +1 -0
- package/dist/commands/context.d.ts +25 -0
- package/dist/commands/context.js +92 -0
- package/dist/commands/context.js.map +1 -0
- package/dist/commands/front.d.ts +2 -0
- package/dist/commands/front.js +135 -0
- package/dist/commands/front.js.map +1 -0
- package/dist/commands/git.d.ts +2 -0
- package/dist/commands/git.js +726 -0
- package/dist/commands/git.js.map +1 -0
- package/dist/commands/health.d.ts +2 -0
- package/dist/commands/health.js +99 -0
- package/dist/commands/health.js.map +1 -0
- package/dist/commands/mail.d.ts +2 -0
- package/dist/commands/mail.js +265 -0
- package/dist/commands/mail.js.map +1 -0
- package/dist/commands/pipeline.d.ts +2 -0
- package/dist/commands/pipeline.js +333 -0
- package/dist/commands/pipeline.js.map +1 -0
- package/dist/commands/profile.d.ts +2 -0
- package/dist/commands/profile.js +229 -0
- package/dist/commands/profile.js.map +1 -0
- package/dist/commands/runner.d.ts +2 -0
- package/dist/commands/runner.js +266 -0
- package/dist/commands/runner.js.map +1 -0
- package/dist/commands/support.d.ts +2 -0
- package/dist/commands/support.js +133 -0
- package/dist/commands/support.js.map +1 -0
- package/dist/constants/index.d.ts +26 -0
- package/dist/constants/index.js +40 -0
- package/dist/constants/index.js.map +1 -0
- package/dist/http/client.d.ts +46 -0
- package/dist/http/client.js +262 -0
- package/dist/http/client.js.map +1 -0
- package/dist/http/coreApi.d.ts +136 -0
- package/dist/http/coreApi.js +485 -0
- package/dist/http/coreApi.js.map +1 -0
- package/dist/http/gitApi.d.ts +128 -0
- package/dist/http/gitApi.js +255 -0
- package/dist/http/gitApi.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +46 -0
- package/dist/index.js.map +1 -0
- package/dist/pipeline/detect.d.ts +13 -0
- package/dist/pipeline/detect.js +90 -0
- package/dist/pipeline/detect.js.map +1 -0
- package/dist/pipeline/release.d.ts +36 -0
- package/dist/pipeline/release.js +250 -0
- package/dist/pipeline/release.js.map +1 -0
- package/dist/pipeline/schema.d.ts +10 -0
- package/dist/pipeline/schema.js +155 -0
- package/dist/pipeline/schema.js.map +1 -0
- package/dist/runner/config.d.ts +21 -0
- package/dist/runner/config.js +235 -0
- package/dist/runner/config.js.map +1 -0
- package/dist/runner/server.d.ts +25 -0
- package/dist/runner/server.js +803 -0
- package/dist/runner/server.js.map +1 -0
- package/dist/runner/systemd.d.ts +14 -0
- package/dist/runner/systemd.js +82 -0
- package/dist/runner/systemd.js.map +1 -0
- package/dist/runner/tarExtract.d.ts +4 -0
- package/dist/runner/tarExtract.js +215 -0
- package/dist/runner/tarExtract.js.map +1 -0
- package/dist/security/execSafe.d.ts +20 -0
- package/dist/security/execSafe.js +216 -0
- package/dist/security/execSafe.js.map +1 -0
- package/dist/security/pkce.d.ts +9 -0
- package/dist/security/pkce.js +35 -0
- package/dist/security/pkce.js.map +1 -0
- package/dist/security/redact.d.ts +3 -0
- package/dist/security/redact.js +76 -0
- package/dist/security/redact.js.map +1 -0
- package/dist/security/sanitize.d.ts +18 -0
- package/dist/security/sanitize.js +216 -0
- package/dist/security/sanitize.js.map +1 -0
- package/dist/security/vault.d.ts +34 -0
- package/dist/security/vault.js +291 -0
- package/dist/security/vault.js.map +1 -0
- package/dist/types/index.d.ts +116 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/dist/ui/output.d.ts +25 -0
- package/dist/ui/output.js +100 -0
- package/dist/ui/output.js.map +1 -0
- package/dist/ui/prompt.d.ts +4 -0
- package/dist/ui/prompt.js +100 -0
- package/dist/ui/prompt.js.map +1 -0
- package/package.json +54 -5
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import crypto from "node:crypto";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import os from "node:os";
|
|
4
|
+
import fs from "node:fs";
|
|
5
|
+
import { DEFAULT_RUNNER_BIND, DEFAULT_RUNNER_PORT } from "../constants/index.js";
|
|
6
|
+
import { validateHttpUrl, parseRepoSpec } from "../security/sanitize.js";
|
|
7
|
+
import { maskSecret } from "../security/redact.js";
|
|
8
|
+
import { resolveDefaultRunnerConfigPath, createEmptyRunnerConfig, loadRunnerConfig, saveRunnerConfig, runRunnerDoctor } from "../runner/config.js";
|
|
9
|
+
import { startRunnerServer } from "../runner/server.js";
|
|
10
|
+
import { generateNginxReverseProxySnippet, generateSystemdUnit } from "../runner/systemd.js";
|
|
11
|
+
import { colorize } from "../ui/output.js";
|
|
12
|
+
import { runCommandAction } from "./context.js";
|
|
13
|
+
export const registerRunnerCommands = (program) => {
|
|
14
|
+
const runner = program
|
|
15
|
+
.command("runner")
|
|
16
|
+
.description("Zero-trust self-hosted CI/CD webhook runner for any git.nibgat.space repository");
|
|
17
|
+
runner
|
|
18
|
+
.command("init")
|
|
19
|
+
.description("Register a self-hosted runner on N - Git and write hardened 0600 runner config")
|
|
20
|
+
.requiredOption("--repo <owner/repo>", "Repository to allowlist and register")
|
|
21
|
+
.requiredOption("--url <https://...>", "Public HTTPS webhook URL pointing to this runner")
|
|
22
|
+
.option("--name <name>", "Runner name", `ncli-runner-${os.hostname()}`)
|
|
23
|
+
.option("--port <port>", "Local HTTP listen port", (v) => parseInt(v, 10), DEFAULT_RUNNER_PORT)
|
|
24
|
+
.option("--bind <host>", "Local bind interface", DEFAULT_RUNNER_BIND)
|
|
25
|
+
.option("--type <type>", "Optional default pipeline type override (docker | static)")
|
|
26
|
+
.option("--image <owner/image>", "Optional OCI image override")
|
|
27
|
+
.option("--target-dir <dir>", "Optional static deployment directory")
|
|
28
|
+
.option("--allowed-root <dir>", "Allowed static deployment root confinement", "/var/www")
|
|
29
|
+
.option("--compose-dir <dir>", "Docker Compose project directory")
|
|
30
|
+
.option("--compose-service <svc>", "Docker Compose service name")
|
|
31
|
+
.option("--config <path>", "Path to runner config JSON")
|
|
32
|
+
.option("--offline", "Generate local config and HMAC secret without calling git.nibgat.space")
|
|
33
|
+
.action(async (opts, cmd) => {
|
|
34
|
+
await runCommandAction(cmd, async (ctx) => {
|
|
35
|
+
const { fullName, owner, repo } = parseRepoSpec(opts.repo);
|
|
36
|
+
const webhookUrl = validateHttpUrl(opts.url, true);
|
|
37
|
+
const configPath = resolveDefaultRunnerConfigPath(opts.config);
|
|
38
|
+
let config = fs.existsSync(configPath)
|
|
39
|
+
? loadRunnerConfig(configPath)
|
|
40
|
+
: createEmptyRunnerConfig({
|
|
41
|
+
allowedStaticRoot: opts.allowedRoot,
|
|
42
|
+
runnerName: opts.name,
|
|
43
|
+
bindHost: opts.bind,
|
|
44
|
+
gitUrl: ctx.gitUrl,
|
|
45
|
+
port: opts.port
|
|
46
|
+
});
|
|
47
|
+
config.bindHost = opts.bind || config.bindHost;
|
|
48
|
+
config.port = Number.isInteger(opts.port) ? opts.port : config.port;
|
|
49
|
+
config.allowedStaticRoot = opts.allowedRoot || config.allowedStaticRoot;
|
|
50
|
+
config.gitUrl = ctx.gitUrl;
|
|
51
|
+
let webhookSecret = crypto.randomBytes(32).toString("hex");
|
|
52
|
+
let runnerToken;
|
|
53
|
+
let runnerId;
|
|
54
|
+
if (!opts.offline) {
|
|
55
|
+
const regRes = await ctx.gitClient.registerRunner(owner, repo, {
|
|
56
|
+
events: [
|
|
57
|
+
"release",
|
|
58
|
+
"deploy"
|
|
59
|
+
],
|
|
60
|
+
webhookUrl,
|
|
61
|
+
name: opts.name,
|
|
62
|
+
url: webhookUrl
|
|
63
|
+
});
|
|
64
|
+
const data = regRes.data;
|
|
65
|
+
const runnerObj = (data.runner && typeof data.runner === "object")
|
|
66
|
+
? data.runner
|
|
67
|
+
: null;
|
|
68
|
+
if (typeof data.webhookSecret === "string" && data.webhookSecret.length >= 16) {
|
|
69
|
+
webhookSecret = data.webhookSecret;
|
|
70
|
+
}
|
|
71
|
+
if (typeof data.runnerToken === "string" && data.runnerToken.length >= 8) {
|
|
72
|
+
runnerToken = data.runnerToken;
|
|
73
|
+
}
|
|
74
|
+
runnerId = String(data.id || runnerObj?.id || "") || undefined;
|
|
75
|
+
}
|
|
76
|
+
const repoEntry = {
|
|
77
|
+
allowedStaticRoot: opts.allowedRoot,
|
|
78
|
+
composeService: opts.composeService,
|
|
79
|
+
composeDir: opts.composeDir,
|
|
80
|
+
targetDir: opts.targetDir,
|
|
81
|
+
image: opts.image,
|
|
82
|
+
type: opts.type === "docker" || opts.type === "static" ? opts.type : undefined,
|
|
83
|
+
webhookSecret,
|
|
84
|
+
runnerToken,
|
|
85
|
+
runnerId
|
|
86
|
+
};
|
|
87
|
+
config.repos[fullName] = repoEntry;
|
|
88
|
+
const savedPath = saveRunnerConfig(configPath, config);
|
|
89
|
+
ctx.output.data({
|
|
90
|
+
ok: true,
|
|
91
|
+
configPath: savedPath,
|
|
92
|
+
repo: fullName,
|
|
93
|
+
webhookUrl,
|
|
94
|
+
runnerId: runnerId || null,
|
|
95
|
+
offline: Boolean(opts.offline),
|
|
96
|
+
webhookSecretMasked: maskSecret(webhookSecret),
|
|
97
|
+
runnerTokenMasked: runnerToken ? maskSecret(runnerToken) : null
|
|
98
|
+
}, () => {
|
|
99
|
+
ctx.output.success(`Runner configured for ${fullName} and saved securely (0600) to ${savedPath}`);
|
|
100
|
+
ctx.output.kv([
|
|
101
|
+
[
|
|
102
|
+
"Config Path",
|
|
103
|
+
savedPath
|
|
104
|
+
],
|
|
105
|
+
[
|
|
106
|
+
"Bind Address",
|
|
107
|
+
`${config.bindHost}:${config.port}`
|
|
108
|
+
],
|
|
109
|
+
[
|
|
110
|
+
"Repository",
|
|
111
|
+
fullName
|
|
112
|
+
],
|
|
113
|
+
[
|
|
114
|
+
"Runner ID",
|
|
115
|
+
runnerId || "(offline)"
|
|
116
|
+
],
|
|
117
|
+
[
|
|
118
|
+
"Webhook Secret",
|
|
119
|
+
maskSecret(webhookSecret)
|
|
120
|
+
],
|
|
121
|
+
[
|
|
122
|
+
"Runner Token",
|
|
123
|
+
runnerToken ? maskSecret(runnerToken) : "(offline)"
|
|
124
|
+
]
|
|
125
|
+
]);
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
runner
|
|
130
|
+
.command("start")
|
|
131
|
+
.description("Start the hardened HTTP webhook runner server")
|
|
132
|
+
.option("--config <path>", "Path to runner config JSON")
|
|
133
|
+
.option("--port <port>", "Override listen port", (v) => parseInt(v, 10))
|
|
134
|
+
.option("--bind <host>", "Override bind host")
|
|
135
|
+
.action(async (opts, cmd) => {
|
|
136
|
+
await runCommandAction(cmd, async () => {
|
|
137
|
+
const configPath = resolveDefaultRunnerConfigPath(opts.config);
|
|
138
|
+
const config = loadRunnerConfig(configPath);
|
|
139
|
+
if (Number.isInteger(opts.port)) {
|
|
140
|
+
config.port = opts.port;
|
|
141
|
+
}
|
|
142
|
+
if (opts.bind) {
|
|
143
|
+
config.bindHost = opts.bind;
|
|
144
|
+
}
|
|
145
|
+
const handle = await startRunnerServer(config);
|
|
146
|
+
const shutdown = async (signal) => {
|
|
147
|
+
process.stdout.write(`\n[ncli-runner] Received ${signal}, shutting down gracefully...\n`);
|
|
148
|
+
await handle.close();
|
|
149
|
+
process.exit(0);
|
|
150
|
+
};
|
|
151
|
+
process.once("SIGINT", () => {
|
|
152
|
+
void shutdown("SIGINT");
|
|
153
|
+
});
|
|
154
|
+
process.once("SIGTERM", () => {
|
|
155
|
+
void shutdown("SIGTERM");
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
runner
|
|
160
|
+
.command("install")
|
|
161
|
+
.description("Generate hardened Linux systemd unit and optional Nginx TLS proxy snippet")
|
|
162
|
+
.option("--config <path>", "Path to runner config JSON")
|
|
163
|
+
.option("--user <user>", "Unprivileged Linux service user", "ncli-runner")
|
|
164
|
+
.option("--nginx-domain <domain>", "Generate an Nginx TLS reverse proxy block for this domain")
|
|
165
|
+
.option("--write", "Write unit file directly to /etc/systemd/system/ncli-runner.service (Linux root only)")
|
|
166
|
+
.option("--out <dir>", "Write generated unit and nginx files into a directory")
|
|
167
|
+
.action(async (opts, cmd) => {
|
|
168
|
+
await runCommandAction(cmd, async (ctx) => {
|
|
169
|
+
const configPath = resolveDefaultRunnerConfigPath(opts.config);
|
|
170
|
+
let allowedStaticRoot = "/var/www";
|
|
171
|
+
let bindHost = DEFAULT_RUNNER_BIND;
|
|
172
|
+
let port = DEFAULT_RUNNER_PORT;
|
|
173
|
+
let composeDir;
|
|
174
|
+
if (fs.existsSync(configPath)) {
|
|
175
|
+
const cfg = loadRunnerConfig(configPath);
|
|
176
|
+
allowedStaticRoot = cfg.allowedStaticRoot;
|
|
177
|
+
bindHost = cfg.bindHost;
|
|
178
|
+
port = cfg.port;
|
|
179
|
+
composeDir = Object.values(cfg.repos).find((r) => r.composeDir)?.composeDir;
|
|
180
|
+
}
|
|
181
|
+
const systemdUnit = generateSystemdUnit({
|
|
182
|
+
allowedStaticRoot,
|
|
183
|
+
user: opts.user,
|
|
184
|
+
composeDir,
|
|
185
|
+
configPath
|
|
186
|
+
});
|
|
187
|
+
const nginxSnippet = opts.nginxDomain
|
|
188
|
+
? generateNginxReverseProxySnippet({
|
|
189
|
+
domain: opts.nginxDomain,
|
|
190
|
+
bindHost,
|
|
191
|
+
port
|
|
192
|
+
})
|
|
193
|
+
: null;
|
|
194
|
+
let writtenSystemdPath = null;
|
|
195
|
+
let writtenNginxPath = null;
|
|
196
|
+
if (opts.out) {
|
|
197
|
+
const outDir = path.resolve(opts.out);
|
|
198
|
+
fs.mkdirSync(outDir, {
|
|
199
|
+
recursive: true
|
|
200
|
+
});
|
|
201
|
+
writtenSystemdPath = path.join(outDir, "ncli-runner.service");
|
|
202
|
+
fs.writeFileSync(writtenSystemdPath, systemdUnit, "utf8");
|
|
203
|
+
if (nginxSnippet) {
|
|
204
|
+
writtenNginxPath = path.join(outDir, `${opts.nginxDomain}.nginx.conf`);
|
|
205
|
+
fs.writeFileSync(writtenNginxPath, nginxSnippet, "utf8");
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
else if (opts.write) {
|
|
209
|
+
if (process.platform !== "linux" || typeof process.getuid !== "function" || process.getuid() !== 0) {
|
|
210
|
+
throw new Error("--write requires root privileges on Linux. Use --out <dir> or redirect stdout instead.");
|
|
211
|
+
}
|
|
212
|
+
writtenSystemdPath = "/etc/systemd/system/ncli-runner.service";
|
|
213
|
+
fs.writeFileSync(writtenSystemdPath, systemdUnit, {
|
|
214
|
+
encoding: "utf8",
|
|
215
|
+
mode: 0o644
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
ctx.output.data({
|
|
219
|
+
ok: true,
|
|
220
|
+
writtenSystemdPath,
|
|
221
|
+
writtenNginxPath,
|
|
222
|
+
systemdUnit,
|
|
223
|
+
nginxSnippet
|
|
224
|
+
}, () => {
|
|
225
|
+
if (writtenSystemdPath) {
|
|
226
|
+
ctx.output.success(`Wrote systemd service unit to ${writtenSystemdPath}`);
|
|
227
|
+
if (writtenNginxPath) {
|
|
228
|
+
ctx.output.success(`Wrote Nginx reverse proxy config to ${writtenNginxPath}`);
|
|
229
|
+
}
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
process.stdout.write(`# /etc/systemd/system/ncli-runner.service\n${systemdUnit}\n`);
|
|
233
|
+
if (nginxSnippet) {
|
|
234
|
+
process.stdout.write(`# /etc/nginx/sites-available/${opts.nginxDomain}\n${nginxSnippet}\n`);
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
});
|
|
238
|
+
});
|
|
239
|
+
runner
|
|
240
|
+
.command("doctor")
|
|
241
|
+
.description("Audit runner config permissions, secret entropy, runtimes and N - Git connectivity")
|
|
242
|
+
.option("--config <path>", "Path to runner config JSON")
|
|
243
|
+
.action(async (opts, cmd) => {
|
|
244
|
+
await runCommandAction(cmd, async (ctx) => {
|
|
245
|
+
const configPath = resolveDefaultRunnerConfigPath(opts.config);
|
|
246
|
+
const report = await runRunnerDoctor(configPath);
|
|
247
|
+
ctx.output.data(report, () => {
|
|
248
|
+
ctx.output.table([
|
|
249
|
+
"CHECK",
|
|
250
|
+
"STATUS",
|
|
251
|
+
"DETAIL"
|
|
252
|
+
], report.checks.map((c) => [
|
|
253
|
+
c.check,
|
|
254
|
+
c.status === "pass"
|
|
255
|
+
? colorize.green("PASS")
|
|
256
|
+
: (c.status === "warn" ? colorize.yellow("WARN") : colorize.red("FAIL")),
|
|
257
|
+
c.detail
|
|
258
|
+
]));
|
|
259
|
+
});
|
|
260
|
+
if (!report.healthy) {
|
|
261
|
+
process.exitCode = 1;
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
});
|
|
265
|
+
};
|
|
266
|
+
//# sourceMappingURL=runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../../src/commands/runner.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AAIzB,OAAO,EACH,mBAAmB,EACnB,mBAAmB,EACtB,MAAM,uBAAuB,CAAC;AAI/B,OAAO,EACH,eAAe,EACf,aAAa,EAChB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACH,UAAU,EACb,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACH,8BAA8B,EAC9B,uBAAuB,EACvB,gBAAgB,EAChB,g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AU,GAAG,8BAA8B,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAC/D,MAAM,MAAM,GAAG,MAAM,eAAe,CAAC,UAAU,CAAC,CAAC;YAEjD,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE;gBACzB,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC;oBACb,OAAO;oBACP,QAAQ;oBACR,QAAQ;iBACX,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;oBACxB,CAAC,CAAC,KAAK;oBACP,CAAC,CAAC,MAAM,KAAK,MAAM;wBACf,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC;wBACxB,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;oBAC5E,CAAC,CAAC,MAAM;iBACX,CAAC,CAAC,CAAC;YACR,CAAC,CAAC,CAAC;YAEH,IAAG,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;gBACjB,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;YACzB,CAAC;QACL,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACX,CAAC,CAAC"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { runCommandAction } from "./context.js";
|
|
2
|
+
export const registerSupportCommands = (program) => {
|
|
3
|
+
const support = program
|
|
4
|
+
.command("support")
|
|
5
|
+
.description("Manage NİBGAT® support tickets");
|
|
6
|
+
const tickets = support
|
|
7
|
+
.command("tickets")
|
|
8
|
+
.description("List, view, create, reply and inspect support tickets");
|
|
9
|
+
tickets
|
|
10
|
+
.command("list")
|
|
11
|
+
.description("List your support tickets")
|
|
12
|
+
.option("--scope <scope>", "Scope: mine | organization | all")
|
|
13
|
+
.option("--status <status>", "Status filter")
|
|
14
|
+
.option("--category <category>", "Category filter")
|
|
15
|
+
.option("--priority <priority>", "Priority filter")
|
|
16
|
+
.option("--search <q>", "Search text")
|
|
17
|
+
.option("--page <n>", "Page number")
|
|
18
|
+
.option("--limit <n>", "Items per page")
|
|
19
|
+
.action(async (opts, cmd) => {
|
|
20
|
+
await runCommandAction(cmd, async (ctx) => {
|
|
21
|
+
const res = await ctx.coreClient.supportTicketsList({
|
|
22
|
+
category: opts.category,
|
|
23
|
+
priority: opts.priority,
|
|
24
|
+
search: opts.search,
|
|
25
|
+
status: opts.status,
|
|
26
|
+
scope: opts.scope,
|
|
27
|
+
limit: opts.limit,
|
|
28
|
+
page: opts.page
|
|
29
|
+
});
|
|
30
|
+
const items = Array.isArray(res.data)
|
|
31
|
+
? res.data
|
|
32
|
+
: (res.data?.tickets || res.data?.items || []);
|
|
33
|
+
ctx.output.data(res.data, () => {
|
|
34
|
+
ctx.output.table([
|
|
35
|
+
"ID",
|
|
36
|
+
"SUBJECT",
|
|
37
|
+
"STATUS",
|
|
38
|
+
"PRIORITY",
|
|
39
|
+
"CATEGORY"
|
|
40
|
+
], items.map((t) => [
|
|
41
|
+
String(t.id || "-"),
|
|
42
|
+
String(t.subject || "-"),
|
|
43
|
+
String(t.status || "-"),
|
|
44
|
+
String(t.priority || "-"),
|
|
45
|
+
String(t.category || "-")
|
|
46
|
+
]));
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
tickets
|
|
51
|
+
.command("show <id>")
|
|
52
|
+
.description("Show support ticket detail and replies")
|
|
53
|
+
.action(async (id, _opts, cmd) => {
|
|
54
|
+
await runCommandAction(cmd, async (ctx) => {
|
|
55
|
+
const res = await ctx.coreClient.supportTicketShow(id);
|
|
56
|
+
ctx.output.data(res.data, () => {
|
|
57
|
+
const t = (res.data?.ticket || res.data);
|
|
58
|
+
ctx.output.kv([
|
|
59
|
+
[
|
|
60
|
+
"ID",
|
|
61
|
+
String(t.id || id)
|
|
62
|
+
],
|
|
63
|
+
[
|
|
64
|
+
"Subject",
|
|
65
|
+
String(t.subject || "-")
|
|
66
|
+
],
|
|
67
|
+
[
|
|
68
|
+
"Status",
|
|
69
|
+
String(t.status || "-")
|
|
70
|
+
],
|
|
71
|
+
[
|
|
72
|
+
"Priority",
|
|
73
|
+
String(t.priority || "-")
|
|
74
|
+
],
|
|
75
|
+
[
|
|
76
|
+
"Category",
|
|
77
|
+
String(t.category || "-")
|
|
78
|
+
],
|
|
79
|
+
[
|
|
80
|
+
"Description",
|
|
81
|
+
String(t.description || "-")
|
|
82
|
+
]
|
|
83
|
+
]);
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
tickets
|
|
88
|
+
.command("create")
|
|
89
|
+
.description("Create a new support ticket")
|
|
90
|
+
.requiredOption("--subject <subject>", "Ticket subject (3-180 chars)")
|
|
91
|
+
.requiredOption("--description <desc>", "Detailed description (10-5000 chars)")
|
|
92
|
+
.option("--category <cat>", "Category (general|technical|bug_report|feature_request|security|account|billing|organization)", "technical")
|
|
93
|
+
.option("--priority <prio>", "Priority (low|normal|high|urgent)", "normal")
|
|
94
|
+
.option("--type <type>", "Ticket type (member|developer|partner|organization)", "developer")
|
|
95
|
+
.action(async (opts, cmd) => {
|
|
96
|
+
await runCommandAction(cmd, async (ctx) => {
|
|
97
|
+
const res = await ctx.coreClient.supportTicketCreate({
|
|
98
|
+
description: opts.description,
|
|
99
|
+
ticketType: opts.type,
|
|
100
|
+
category: opts.category,
|
|
101
|
+
priority: opts.priority,
|
|
102
|
+
subject: opts.subject,
|
|
103
|
+
source: "ncli"
|
|
104
|
+
});
|
|
105
|
+
ctx.output.data(res.data, () => {
|
|
106
|
+
const id = String(res.data?.id || "");
|
|
107
|
+
ctx.output.success(`Support ticket created${id ? ` (${id})` : ""}.`);
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
tickets
|
|
112
|
+
.command("reply <id>")
|
|
113
|
+
.description("Post a reply to an existing support ticket")
|
|
114
|
+
.requiredOption("--message <text>", "Reply message")
|
|
115
|
+
.action(async (id, opts, cmd) => {
|
|
116
|
+
await runCommandAction(cmd, async (ctx) => {
|
|
117
|
+
const res = await ctx.coreClient.supportTicketReply(id, opts.message);
|
|
118
|
+
ctx.output.data(res.data, () => {
|
|
119
|
+
ctx.output.success(`Reply posted to ticket ${id}.`);
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
tickets
|
|
124
|
+
.command("quota")
|
|
125
|
+
.description("Show your support ticket quota")
|
|
126
|
+
.action(async (_opts, cmd) => {
|
|
127
|
+
await runCommandAction(cmd, async (ctx) => {
|
|
128
|
+
const res = await ctx.coreClient.supportTicketsQuota();
|
|
129
|
+
ctx.output.data(res.data);
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
};
|
|
133
|
+
//# sourceMappingURL=support.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"support.js","sourceRoot":"","sources":["../../src/commands/support.ts"],"names":[],"mappings":"AAGA,OAAO,EACH,gBAAgB,EACnB,MAAM,cAAc,CAAC;AAEtB,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,OAAgB,EAAQ,EAAE;IAC9D,MAAM,OAAO,GAAG,OAAO;SAClB,OAAO,CAAC,SAAS,CAAC;SAClB,WAAW,CAAC,gCAAgC,CAAC,CAAC;IAEnD,MAAM,OAAO,GAAG,OAAO;SAClB,OAAO,CAAC,SAAS,CAAC;SAClB,WAAW,CAAC,uDAAuD,CAAC,CAAC;IAE1E,OAAO;SACF,OAAO,CAAC,MAAM,CAAC;SACf,WAAW,CAAC,2BAA2B,CAAC;SACxC,MAAM,CAAC,iBAAiB,EAAE,kCAAkC,CAAC;SAC7D,MAAM,CAAC,mBAAmB,EAAE,eAAe,CAAC;SAC5C,MAAM,CAAC,uBAAuB,EAAE,iBAAiB,CAAC;SAClD,MAAM,CAAC,u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H_FRONT_URL = "https://nauth.nibgat.space";
|
|
4
|
+
export declare const DEFAULT_CORE_API_URL = "https://core.nibgat.space";
|
|
5
|
+
export declare const DEFAULT_FONTS_URL = "https://fonts.nibgat.space";
|
|
6
|
+
export declare const DEFAULT_DOCS_URL = "https://docs.nibgat.space";
|
|
7
|
+
export declare const DEFAULT_GIT_API_URL = "https://git.nibgat.space";
|
|
8
|
+
export declare const DEFAULT_CDN_URL = "https://cdn.nibgat.space";
|
|
9
|
+
export declare const DEFAULT_REGISTRY_HOST = "git.nibgat.space";
|
|
10
|
+
export declare const DEFAULT_OAUTH_SCOPES: string[];
|
|
11
|
+
export declare const DEFAULT_PAT_SCOPES: string[];
|
|
12
|
+
export declare const DEFAULT_HTTP_TIMEOUT_MS = 30000;
|
|
13
|
+
export declare const DEFAULT_RUNNER_PORT = 4295;
|
|
14
|
+
export declare const DEFAULT_RUNNER_BIND = "127.0.0.1";
|
|
15
|
+
export declare const DEFAULT_WEBHOOK_MAX_AGE_SEC = 300;
|
|
16
|
+
export declare const DEFAULT_DELIVERY_TTL_MS: number;
|
|
17
|
+
export declare const DEFAULT_DELIVERY_CACHE_LIMIT = 4096;
|
|
18
|
+
export declare const DEFAULT_HEARTBEAT_INTERVAL_MS = 60000;
|
|
19
|
+
export declare const MAX_WEBHOOK_BODY_BYTES: number;
|
|
20
|
+
export declare const MAX_ARCHIVE_BYTES: number;
|
|
21
|
+
export declare const SSO_COOKIE_CANDIDATES: string[];
|
|
22
|
+
export declare const DEVICE_COOKIE_NAME = "nauth_did";
|
|
23
|
+
export declare const DEFAULT_PROFILE_NAME = "default";
|
|
24
|
+
export declare const VAULT_FILENAME = "credentials.enc";
|
|
25
|
+
export declare const RUNNER_CONFIG_FILENAME = "runner.json";
|
|
26
|
+
export declare const PIPELINE_CONFIG_FILENAME = ".ngit-deploy.json";
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export const NCLI_VERSION = "2.0.0";
|
|
2
|
+
export const NCLI_USER_AGENT = `ncli/${NCLI_VERSION} (+https://docs.nibgat.space/cli)`;
|
|
3
|
+
export const DEFAULT_NAUTH_FRONT_URL = "https://nauth.nibgat.space";
|
|
4
|
+
export const DEFAULT_CORE_API_URL = "https://core.nibgat.space";
|
|
5
|
+
export const DEFAULT_FONTS_URL = "https://fonts.nibgat.space";
|
|
6
|
+
export const DEFAULT_DOCS_URL = "https://docs.nibgat.space";
|
|
7
|
+
export const DEFAULT_GIT_API_URL = "https://git.nibgat.space";
|
|
8
|
+
export const DEFAULT_CDN_URL = "https://cdn.nibgat.space";
|
|
9
|
+
export const DEFAULT_REGISTRY_HOST = "git.nibgat.space";
|
|
10
|
+
export const DEFAULT_OAUTH_SCOPES = [
|
|
11
|
+
"openid",
|
|
12
|
+
"profile",
|
|
13
|
+
"email",
|
|
14
|
+
"offline_access"
|
|
15
|
+
];
|
|
16
|
+
export const DEFAULT_PAT_SCOPES = [
|
|
17
|
+
"repo:read",
|
|
18
|
+
"repo:write",
|
|
19
|
+
"registry:read",
|
|
20
|
+
"registry:write"
|
|
21
|
+
];
|
|
22
|
+
export const DEFAULT_HTTP_TIMEOUT_MS = 30_000;
|
|
23
|
+
export const DEFAULT_RUNNER_PORT = 4295;
|
|
24
|
+
export const DEFAULT_RUNNER_BIND = "127.0.0.1";
|
|
25
|
+
export const DEFAULT_WEBHOOK_MAX_AGE_SEC = 300;
|
|
26
|
+
export const DEFAULT_DELIVERY_TTL_MS = 15 * 60 * 1000;
|
|
27
|
+
export const DEFAULT_DELIVERY_CACHE_LIMIT = 4096;
|
|
28
|
+
export const DEFAULT_HEARTBEAT_INTERVAL_MS = 60_000;
|
|
29
|
+
export const MAX_WEBHOOK_BODY_BYTES = 2 * 1024 * 1024;
|
|
30
|
+
export const MAX_ARCHIVE_BYTES = 512 * 1024 * 1024;
|
|
31
|
+
export const SSO_COOKIE_CANDIDATES = [
|
|
32
|
+
"nauth_sso_sid",
|
|
33
|
+
"nauth_sso_session"
|
|
34
|
+
];
|
|
35
|
+
export const DEVICE_COOKIE_NAME = "nauth_did";
|
|
36
|
+
export const DEFAULT_PROFILE_NAME = "default";
|
|
37
|
+
export const VAULT_FILENAME = "credentials.enc";
|
|
38
|
+
export const RUNNER_CONFIG_FILENAME = "runner.json";
|
|
39
|
+
export const PIPELINE_CONFIG_FILENAME = ".ngit-deploy.json";
|
|
40
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/constants/index.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,YAAY,GAAG,OAAO,CAAC;AACpC,MAAM,CAAC,MAAM,eAAe,GAAG,QAAQ,YAAY,mCAAmC,CAAC;AAEvF,MAAM,CAAC,MAAM,uBAAuB,GAAG,4BAA4B,CAAC;AACpE,MAAM,CAAC,MAAM,oBAAoB,GAAG,2BAA2B,CAAC;AAChE,MAAM,CAAC,MAAM,iBAAiB,GAAG,4BAA4B,CAAC;AAC9D,MAAM,CAAC,MAAM,gBAAgB,GAAG,2BAA2B,CAAC;AAC5D,MAAM,CAAC,MAAM,mBAAmB,GAAG,0BAA0B,CAAC;AAC9D,MAAM,CAAC,MAAM,eAAe,GAAG,0BAA0B,CAAC;AAC1D,MAAM,CAAC,MAAM,qBAAqB,GAAG,kBAAkB,CAAC;AAExD,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAChC,QAAQ;IACR,SAAS;IACT,OAAO;IACP,gBAAgB;CACnB,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAC9B,WAAW;IACX,YAAY;IACZ,eAAe;IACf,gBAAgB;CACnB,CAAC;AAEF,MAAM,CAAC,MAAM,uBAAuB,GAAG,MAAM,CAAC;AAC9C,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,CAAC;AACxC,MAAM,CAAC,MAAM,mBAAmB,GAAG,WAAW,CAAC;AAC/C,MAAM,CAAC,MAAM,2BAA2B,GAAG,GAAG,CAAC;AAC/C,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AACtD,MAAM,CAAC,MAAM,4BAA4B,GAAG,IAAI,CAAC;AACjD,MAAM,CAAC,MAAM,6BAA6B,GAAG,MAAM,CAAC;AACpD,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AACtD,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,CAAC;AAEnD,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACjC,eAAe;IACf,mBAAmB;CACtB,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,WAAW,CAAC;AAC9C,MAAM,CAAC,MAAM,oBAAoB,GAAG,SAAS,CAAC;AAC9C,MAAM,CAAC,MAAM,cAAc,GAAG,iBAAiB,CAAC;AAChD,MAAM,CAAC,MAAM,sBAAsB,GAAG,aAAa,CAAC;AACpD,MAAM,CAAC,MAAM,wBAAwB,GAAG,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export interface IHttpAuthMaterial {
|
|
2
|
+
sessionCookieName?: string;
|
|
3
|
+
sessionCookie?: string;
|
|
4
|
+
deviceCookie?: string;
|
|
5
|
+
bearerToken?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface IHttpRequestOptions {
|
|
8
|
+
query?: Record<string, string | number | boolean | undefined>;
|
|
9
|
+
headers?: Record<string, string>;
|
|
10
|
+
body?: Record<string, unknown>;
|
|
11
|
+
auth?: IHttpAuthMaterial;
|
|
12
|
+
includeAuth?: boolean;
|
|
13
|
+
timeoutMs?: number;
|
|
14
|
+
method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
15
|
+
}
|
|
16
|
+
export interface ICapturedCookies {
|
|
17
|
+
sessionCookieName?: string;
|
|
18
|
+
sessionCookie?: string;
|
|
19
|
+
deviceCookie?: string;
|
|
20
|
+
all: Record<string, string>;
|
|
21
|
+
}
|
|
22
|
+
export interface IHttpResponse<T> {
|
|
23
|
+
cookies: ICapturedCookies;
|
|
24
|
+
headers: Headers;
|
|
25
|
+
status: number;
|
|
26
|
+
data: T;
|
|
27
|
+
raw: unknown;
|
|
28
|
+
}
|
|
29
|
+
export declare class ApiHttpError extends Error {
|
|
30
|
+
readonly payload?: Record<string, unknown>;
|
|
31
|
+
readonly status: number;
|
|
32
|
+
constructor(message: string, status: number, payload?: Record<string, unknown>);
|
|
33
|
+
}
|
|
34
|
+
export declare const parseSetCookieHeaders: (headers: Headers) => ICapturedCookies;
|
|
35
|
+
export declare const buildCookieHeader: (auth?: IHttpAuthMaterial) => string | null;
|
|
36
|
+
export declare class HttpClient {
|
|
37
|
+
readonly baseUrl: string;
|
|
38
|
+
private defaultAuth?;
|
|
39
|
+
constructor(baseUrl: string, defaultAuth?: IHttpAuthMaterial);
|
|
40
|
+
setDefaultAuth(auth?: IHttpAuthMaterial): void;
|
|
41
|
+
request<T = Record<string, unknown>>(endpointPath: string, options?: IHttpRequestOptions): Promise<IHttpResponse<T>>;
|
|
42
|
+
downloadBuffer(endpointPath: string, maxBytes: number, options?: {
|
|
43
|
+
auth?: IHttpAuthMaterial;
|
|
44
|
+
timeoutMs?: number;
|
|
45
|
+
}): Promise<Buffer>;
|
|
46
|
+
}
|