xserver-cli 1.0.0 → 1.0.2
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 +30 -21
- package/dist/index.js +1305 -0
- package/dist/index.js.map +1 -0
- package/package.json +41 -16
- package/index.js +0 -47
package/dist/index.js
ADDED
|
@@ -0,0 +1,1305 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// ../core/dist/index.js
|
|
4
|
+
import { Command } from "commander";
|
|
5
|
+
|
|
6
|
+
// ../../shared/dist/api-client.js
|
|
7
|
+
var DEFAULT_TIMEOUT_MS = 3e4;
|
|
8
|
+
var ApiError = class extends Error {
|
|
9
|
+
httpStatus;
|
|
10
|
+
errorCode;
|
|
11
|
+
errors;
|
|
12
|
+
constructor(message, httpStatus, errorCode, errors) {
|
|
13
|
+
super(message);
|
|
14
|
+
this.httpStatus = httpStatus;
|
|
15
|
+
this.errorCode = errorCode;
|
|
16
|
+
this.errors = errors;
|
|
17
|
+
this.name = "ApiError";
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
var ApiClient = class {
|
|
21
|
+
apiBase;
|
|
22
|
+
apiKey;
|
|
23
|
+
servername;
|
|
24
|
+
debug;
|
|
25
|
+
lastRateLimit = null;
|
|
26
|
+
constructor(opts) {
|
|
27
|
+
this.apiBase = opts.apiBase.replace(/\/+$/, "");
|
|
28
|
+
this.apiKey = opts.apiKey;
|
|
29
|
+
this.servername = opts.servername;
|
|
30
|
+
this.debug = opts.debug ?? false;
|
|
31
|
+
}
|
|
32
|
+
serverPath() {
|
|
33
|
+
if (!this.servername) {
|
|
34
|
+
throw new Error("\u30B5\u30FC\u30D0\u30FC\u540D\u304C\u8A2D\u5B9A\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002");
|
|
35
|
+
}
|
|
36
|
+
return `/v1/server/${encodeURIComponent(this.servername)}`;
|
|
37
|
+
}
|
|
38
|
+
// ================================================================
|
|
39
|
+
// サーバー情報
|
|
40
|
+
// ================================================================
|
|
41
|
+
async getServerInfo() {
|
|
42
|
+
return this.get(`${this.serverPath()}/server-info`);
|
|
43
|
+
}
|
|
44
|
+
async getServerUsage() {
|
|
45
|
+
return this.get(`${this.serverPath()}/server-info/usage`);
|
|
46
|
+
}
|
|
47
|
+
// ================================================================
|
|
48
|
+
// Cron
|
|
49
|
+
// ================================================================
|
|
50
|
+
async listCron() {
|
|
51
|
+
return this.get(`${this.serverPath()}/cron`);
|
|
52
|
+
}
|
|
53
|
+
async addCron(data) {
|
|
54
|
+
return this.post(`${this.serverPath()}/cron`, data);
|
|
55
|
+
}
|
|
56
|
+
async updateCron(cronId, data) {
|
|
57
|
+
return this.put(`${this.serverPath()}/cron/${enc(cronId)}`, data);
|
|
58
|
+
}
|
|
59
|
+
async deleteCron(cronId) {
|
|
60
|
+
return this.delete(`${this.serverPath()}/cron/${enc(cronId)}`);
|
|
61
|
+
}
|
|
62
|
+
// ================================================================
|
|
63
|
+
// WordPress
|
|
64
|
+
// ================================================================
|
|
65
|
+
async listWordpress(params) {
|
|
66
|
+
return this.get(`${this.serverPath()}/wp`, params);
|
|
67
|
+
}
|
|
68
|
+
async addWordpress(data) {
|
|
69
|
+
return this.post(`${this.serverPath()}/wp`, data);
|
|
70
|
+
}
|
|
71
|
+
async updateWordpress(wpId, data) {
|
|
72
|
+
return this.put(`${this.serverPath()}/wp/${enc(wpId)}`, data);
|
|
73
|
+
}
|
|
74
|
+
async deleteWordpress(wpId, data) {
|
|
75
|
+
return this.delete(`${this.serverPath()}/wp/${enc(wpId)}`, data);
|
|
76
|
+
}
|
|
77
|
+
// ================================================================
|
|
78
|
+
// メールアカウント
|
|
79
|
+
// ================================================================
|
|
80
|
+
async listMail(params) {
|
|
81
|
+
return this.get(`${this.serverPath()}/mail`, params);
|
|
82
|
+
}
|
|
83
|
+
async getMail(mailAccount) {
|
|
84
|
+
return this.get(`${this.serverPath()}/mail/${enc(mailAccount)}`);
|
|
85
|
+
}
|
|
86
|
+
async addMail(data) {
|
|
87
|
+
return this.post(`${this.serverPath()}/mail`, data);
|
|
88
|
+
}
|
|
89
|
+
async updateMail(mailAccount, data) {
|
|
90
|
+
return this.put(`${this.serverPath()}/mail/${enc(mailAccount)}`, data);
|
|
91
|
+
}
|
|
92
|
+
async deleteMail(mailAccount) {
|
|
93
|
+
return this.delete(`${this.serverPath()}/mail/${enc(mailAccount)}`);
|
|
94
|
+
}
|
|
95
|
+
async getMailForwarding(mailAccount) {
|
|
96
|
+
return this.get(`${this.serverPath()}/mail/${enc(mailAccount)}/forwarding`);
|
|
97
|
+
}
|
|
98
|
+
async updateMailForwarding(mailAccount, data) {
|
|
99
|
+
return this.put(`${this.serverPath()}/mail/${enc(mailAccount)}/forwarding`, data);
|
|
100
|
+
}
|
|
101
|
+
// ================================================================
|
|
102
|
+
// メール振り分け
|
|
103
|
+
// ================================================================
|
|
104
|
+
async listMailFilter(params) {
|
|
105
|
+
return this.get(`${this.serverPath()}/mail-filter`, params);
|
|
106
|
+
}
|
|
107
|
+
async addMailFilter(data) {
|
|
108
|
+
return this.post(`${this.serverPath()}/mail-filter`, data);
|
|
109
|
+
}
|
|
110
|
+
async deleteMailFilter(filterId) {
|
|
111
|
+
return this.delete(`${this.serverPath()}/mail-filter/${enc(filterId)}`);
|
|
112
|
+
}
|
|
113
|
+
// ================================================================
|
|
114
|
+
// FTP
|
|
115
|
+
// ================================================================
|
|
116
|
+
async listFtp(params) {
|
|
117
|
+
return this.get(`${this.serverPath()}/ftp`, params);
|
|
118
|
+
}
|
|
119
|
+
async addFtp(data) {
|
|
120
|
+
return this.post(`${this.serverPath()}/ftp`, data);
|
|
121
|
+
}
|
|
122
|
+
async updateFtp(ftpAccount, data) {
|
|
123
|
+
return this.put(`${this.serverPath()}/ftp/${enc(ftpAccount)}`, data);
|
|
124
|
+
}
|
|
125
|
+
async deleteFtp(ftpAccount) {
|
|
126
|
+
return this.delete(`${this.serverPath()}/ftp/${enc(ftpAccount)}`);
|
|
127
|
+
}
|
|
128
|
+
// ================================================================
|
|
129
|
+
// MySQL
|
|
130
|
+
// ================================================================
|
|
131
|
+
async listDb() {
|
|
132
|
+
return this.get(`${this.serverPath()}/db`);
|
|
133
|
+
}
|
|
134
|
+
async addDb(data) {
|
|
135
|
+
return this.post(`${this.serverPath()}/db`, data);
|
|
136
|
+
}
|
|
137
|
+
async updateDb(dbName, data) {
|
|
138
|
+
return this.put(`${this.serverPath()}/db/${enc(dbName)}`, data);
|
|
139
|
+
}
|
|
140
|
+
async deleteDb(dbName) {
|
|
141
|
+
return this.delete(`${this.serverPath()}/db/${enc(dbName)}`);
|
|
142
|
+
}
|
|
143
|
+
async listDbUser() {
|
|
144
|
+
return this.get(`${this.serverPath()}/db/user`);
|
|
145
|
+
}
|
|
146
|
+
async addDbUser(data) {
|
|
147
|
+
return this.post(`${this.serverPath()}/db/user`, data);
|
|
148
|
+
}
|
|
149
|
+
async updateDbUser(dbUser, data) {
|
|
150
|
+
return this.put(`${this.serverPath()}/db/user/${enc(dbUser)}`, data);
|
|
151
|
+
}
|
|
152
|
+
async deleteDbUser(dbUser) {
|
|
153
|
+
return this.delete(`${this.serverPath()}/db/user/${enc(dbUser)}`);
|
|
154
|
+
}
|
|
155
|
+
async listDbUserGrant(dbUser) {
|
|
156
|
+
return this.get(`${this.serverPath()}/db/user/${enc(dbUser)}/grant`);
|
|
157
|
+
}
|
|
158
|
+
async addDbUserGrant(dbUser, data) {
|
|
159
|
+
return this.post(`${this.serverPath()}/db/user/${enc(dbUser)}/grant`, data);
|
|
160
|
+
}
|
|
161
|
+
async deleteDbUserGrant(dbUser, data) {
|
|
162
|
+
return this.delete(`${this.serverPath()}/db/user/${enc(dbUser)}/grant`, data);
|
|
163
|
+
}
|
|
164
|
+
// ================================================================
|
|
165
|
+
// PHP バージョン
|
|
166
|
+
// ================================================================
|
|
167
|
+
async getPhpVersion(params) {
|
|
168
|
+
return this.get(`${this.serverPath()}/php-version`, params);
|
|
169
|
+
}
|
|
170
|
+
async updatePhpVersion(domain, data) {
|
|
171
|
+
return this.put(`${this.serverPath()}/php-version/${enc(domain)}`, data);
|
|
172
|
+
}
|
|
173
|
+
// ================================================================
|
|
174
|
+
// ドメイン(サーバーパネル)
|
|
175
|
+
// ================================================================
|
|
176
|
+
async listDomain() {
|
|
177
|
+
return this.get(`${this.serverPath()}/domain`);
|
|
178
|
+
}
|
|
179
|
+
async getDomain(domain) {
|
|
180
|
+
return this.get(`${this.serverPath()}/domain/${enc(domain)}`);
|
|
181
|
+
}
|
|
182
|
+
async addDomain(data) {
|
|
183
|
+
return this.post(`${this.serverPath()}/domain`, data);
|
|
184
|
+
}
|
|
185
|
+
async updateDomain(domain, data) {
|
|
186
|
+
return this.put(`${this.serverPath()}/domain/${enc(domain)}`, data);
|
|
187
|
+
}
|
|
188
|
+
async deleteDomain(domain, data) {
|
|
189
|
+
return this.delete(`${this.serverPath()}/domain/${enc(domain)}`, data);
|
|
190
|
+
}
|
|
191
|
+
async resetDomain(domain, data) {
|
|
192
|
+
return this.post(`${this.serverPath()}/domain/${enc(domain)}/reset`, data);
|
|
193
|
+
}
|
|
194
|
+
// ================================================================
|
|
195
|
+
// サブドメイン
|
|
196
|
+
// ================================================================
|
|
197
|
+
async listSubdomain(params) {
|
|
198
|
+
return this.get(`${this.serverPath()}/subdomain`, params);
|
|
199
|
+
}
|
|
200
|
+
async addSubdomain(data) {
|
|
201
|
+
return this.post(`${this.serverPath()}/subdomain`, data);
|
|
202
|
+
}
|
|
203
|
+
async updateSubdomain(subdomain, data) {
|
|
204
|
+
return this.put(`${this.serverPath()}/subdomain/${enc(subdomain)}`, data);
|
|
205
|
+
}
|
|
206
|
+
async deleteSubdomain(subdomain, data) {
|
|
207
|
+
return this.delete(`${this.serverPath()}/subdomain/${enc(subdomain)}`, data);
|
|
208
|
+
}
|
|
209
|
+
// ================================================================
|
|
210
|
+
// SSL
|
|
211
|
+
// ================================================================
|
|
212
|
+
async listSsl(params) {
|
|
213
|
+
return this.get(`${this.serverPath()}/ssl`, params);
|
|
214
|
+
}
|
|
215
|
+
async installSsl(data) {
|
|
216
|
+
return this.post(`${this.serverPath()}/ssl`, data);
|
|
217
|
+
}
|
|
218
|
+
async uninstallSsl(commonName) {
|
|
219
|
+
return this.delete(`${this.serverPath()}/ssl/${enc(commonName)}`);
|
|
220
|
+
}
|
|
221
|
+
// ================================================================
|
|
222
|
+
// DNS(サーバーパネル)
|
|
223
|
+
// ================================================================
|
|
224
|
+
async listDns(params) {
|
|
225
|
+
return this.get(`${this.serverPath()}/dns`, params);
|
|
226
|
+
}
|
|
227
|
+
async addDns(data) {
|
|
228
|
+
return this.post(`${this.serverPath()}/dns`, data);
|
|
229
|
+
}
|
|
230
|
+
async updateDns(dnsId, data) {
|
|
231
|
+
return this.put(`${this.serverPath()}/dns/${enc(dnsId)}`, data);
|
|
232
|
+
}
|
|
233
|
+
async deleteDns(dnsId, data) {
|
|
234
|
+
return this.delete(`${this.serverPath()}/dns/${enc(dnsId)}`, data);
|
|
235
|
+
}
|
|
236
|
+
// ================================================================
|
|
237
|
+
// SSH
|
|
238
|
+
// ================================================================
|
|
239
|
+
async getSsh() {
|
|
240
|
+
return this.get(`${this.serverPath()}/ssh`);
|
|
241
|
+
}
|
|
242
|
+
async updateSsh(data) {
|
|
243
|
+
return this.put(`${this.serverPath()}/ssh`, data);
|
|
244
|
+
}
|
|
245
|
+
async listSshKey() {
|
|
246
|
+
return this.get(`${this.serverPath()}/ssh/key`);
|
|
247
|
+
}
|
|
248
|
+
async addSshKey(data) {
|
|
249
|
+
return this.post(`${this.serverPath()}/ssh/key`, data);
|
|
250
|
+
}
|
|
251
|
+
async updateSshKey(keyId, data) {
|
|
252
|
+
return this.put(`${this.serverPath()}/ssh/key/${enc(keyId)}`, data);
|
|
253
|
+
}
|
|
254
|
+
async deleteSshKey(keyId) {
|
|
255
|
+
return this.delete(`${this.serverPath()}/ssh/key/${enc(keyId)}`);
|
|
256
|
+
}
|
|
257
|
+
// ================================================================
|
|
258
|
+
// ログ
|
|
259
|
+
// ================================================================
|
|
260
|
+
async getAccessLog(params) {
|
|
261
|
+
return this.get(`${this.serverPath()}/access-log`, params);
|
|
262
|
+
}
|
|
263
|
+
async getErrorLog(params) {
|
|
264
|
+
return this.get(`${this.serverPath()}/error-log`, params);
|
|
265
|
+
}
|
|
266
|
+
// ================================================================
|
|
267
|
+
// APIキー情報
|
|
268
|
+
// ================================================================
|
|
269
|
+
async getMe() {
|
|
270
|
+
return this.get("/v1/me");
|
|
271
|
+
}
|
|
272
|
+
// ================================================================
|
|
273
|
+
// HTTP 基盤
|
|
274
|
+
// ================================================================
|
|
275
|
+
async get(path2, params) {
|
|
276
|
+
let url = `${this.apiBase}${path2}`;
|
|
277
|
+
if (params && Object.keys(params).length > 0) {
|
|
278
|
+
url += "?" + new URLSearchParams(params).toString();
|
|
279
|
+
}
|
|
280
|
+
return this.request("GET", url);
|
|
281
|
+
}
|
|
282
|
+
async post(path2, data) {
|
|
283
|
+
return this.request("POST", `${this.apiBase}${path2}`, data);
|
|
284
|
+
}
|
|
285
|
+
async put(path2, data) {
|
|
286
|
+
return this.request("PUT", `${this.apiBase}${path2}`, data);
|
|
287
|
+
}
|
|
288
|
+
async delete(path2, data) {
|
|
289
|
+
return this.request("DELETE", `${this.apiBase}${path2}`, data);
|
|
290
|
+
}
|
|
291
|
+
async request(method, url, body) {
|
|
292
|
+
const headers = {
|
|
293
|
+
"Authorization": `Bearer ${this.apiKey}`,
|
|
294
|
+
"Accept": "application/json"
|
|
295
|
+
};
|
|
296
|
+
const init = {
|
|
297
|
+
method,
|
|
298
|
+
headers,
|
|
299
|
+
signal: AbortSignal.timeout(DEFAULT_TIMEOUT_MS)
|
|
300
|
+
};
|
|
301
|
+
if (body && method !== "GET") {
|
|
302
|
+
headers["Content-Type"] = "application/json";
|
|
303
|
+
init.body = JSON.stringify(body);
|
|
304
|
+
}
|
|
305
|
+
if (this.debug) {
|
|
306
|
+
const dbg = (msg) => process.stderr.write(`[DEBUG] ${msg}
|
|
307
|
+
`);
|
|
308
|
+
dbg(`${method} ${url}`);
|
|
309
|
+
if (init.body)
|
|
310
|
+
dbg(`Body: ${init.body}`);
|
|
311
|
+
}
|
|
312
|
+
let response;
|
|
313
|
+
try {
|
|
314
|
+
response = await fetch(url, init);
|
|
315
|
+
} catch (err) {
|
|
316
|
+
throw new Error(`\u901A\u4FE1\u30A8\u30E9\u30FC: ${err instanceof Error ? err.message : String(err)}`);
|
|
317
|
+
}
|
|
318
|
+
if (this.debug) {
|
|
319
|
+
const dbg = (msg) => process.stderr.write(`[DEBUG] ${msg}
|
|
320
|
+
`);
|
|
321
|
+
dbg(`HTTP ${response.status} ${response.statusText}`);
|
|
322
|
+
const debugHeaders = ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-concurrent-limit", "x-concurrent-remaining", "content-type"];
|
|
323
|
+
for (const h of debugHeaders) {
|
|
324
|
+
const v = response.headers.get(h);
|
|
325
|
+
if (v !== null)
|
|
326
|
+
dbg(` ${h}: ${v}`);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
const rateLimitHeader = response.headers.get("x-ratelimit-limit");
|
|
330
|
+
if (rateLimitHeader) {
|
|
331
|
+
this.lastRateLimit = {
|
|
332
|
+
limit: parseInt(rateLimitHeader, 10),
|
|
333
|
+
remaining: parseInt(response.headers.get("x-ratelimit-remaining") || "0", 10),
|
|
334
|
+
reset: parseInt(response.headers.get("x-ratelimit-reset") || "0", 10)
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
const text = await response.text();
|
|
338
|
+
let data;
|
|
339
|
+
try {
|
|
340
|
+
data = JSON.parse(text);
|
|
341
|
+
} catch {
|
|
342
|
+
if (this.debug) {
|
|
343
|
+
process.stderr.write(`[DEBUG] Raw response: ${text.substring(0, 500)}
|
|
344
|
+
`);
|
|
345
|
+
}
|
|
346
|
+
throw new ApiError(`Response parse error (HTTP ${response.status})`, response.status, "PARSE_ERROR", []);
|
|
347
|
+
}
|
|
348
|
+
if (!response.ok) {
|
|
349
|
+
const err = data;
|
|
350
|
+
const errorCode = err?.error?.code || "UNKNOWN_ERROR";
|
|
351
|
+
const errorMessage = err?.error?.message || "\u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F";
|
|
352
|
+
const errors = err?.error?.errors || [];
|
|
353
|
+
throw new ApiError(errorMessage, response.status, errorCode, errors);
|
|
354
|
+
}
|
|
355
|
+
return data;
|
|
356
|
+
}
|
|
357
|
+
};
|
|
358
|
+
function enc(s) {
|
|
359
|
+
return encodeURIComponent(s);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
// ../core/dist/commands/auth/login.js
|
|
363
|
+
import { password } from "@inquirer/prompts";
|
|
364
|
+
|
|
365
|
+
// ../core/dist/lib/config.js
|
|
366
|
+
import fs from "fs";
|
|
367
|
+
import path from "path";
|
|
368
|
+
import os from "os";
|
|
369
|
+
function getConfigDir(brand) {
|
|
370
|
+
const home = os.homedir();
|
|
371
|
+
return path.join(home, ".config", brand.configDir);
|
|
372
|
+
}
|
|
373
|
+
function getConfigPath(brand) {
|
|
374
|
+
return path.join(getConfigDir(brand), "config.json");
|
|
375
|
+
}
|
|
376
|
+
function loadConfig(brand) {
|
|
377
|
+
const configPath = getConfigPath(brand);
|
|
378
|
+
if (!fs.existsSync(configPath)) {
|
|
379
|
+
return { defaultProfile: "default", profiles: {} };
|
|
380
|
+
}
|
|
381
|
+
const raw = fs.readFileSync(configPath, "utf-8");
|
|
382
|
+
return JSON.parse(raw);
|
|
383
|
+
}
|
|
384
|
+
function saveConfig(brand, config) {
|
|
385
|
+
const configDir = getConfigDir(brand);
|
|
386
|
+
fs.mkdirSync(configDir, { recursive: true });
|
|
387
|
+
const configPath = getConfigPath(brand);
|
|
388
|
+
fs.writeFileSync(configPath, JSON.stringify(config, null, 2) + "\n", "utf-8");
|
|
389
|
+
}
|
|
390
|
+
function getActiveProfile(brand, profileName) {
|
|
391
|
+
const envPrefix = brand.brand.toUpperCase();
|
|
392
|
+
const envApiKey = process.env[`${envPrefix}_API_KEY`] || process.env["XSERVER_API_KEY"];
|
|
393
|
+
const envServername = process.env[`${envPrefix}_SERVERNAME`] || process.env["XSERVER_SERVERNAME"];
|
|
394
|
+
if (envApiKey) {
|
|
395
|
+
return {
|
|
396
|
+
apiKey: envApiKey,
|
|
397
|
+
servername: envServername
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
const config = loadConfig(brand);
|
|
401
|
+
const name = profileName || config.defaultProfile || "default";
|
|
402
|
+
return config.profiles[name] || null;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
// ../core/dist/lib/command-helper.js
|
|
406
|
+
import { confirm } from "@inquirer/prompts";
|
|
407
|
+
|
|
408
|
+
// ../core/dist/lib/output.js
|
|
409
|
+
function formatOutput(data, format) {
|
|
410
|
+
if (format === "json") {
|
|
411
|
+
return JSON.stringify(data, null, 2);
|
|
412
|
+
}
|
|
413
|
+
return formatTable(data);
|
|
414
|
+
}
|
|
415
|
+
function formatTable(data) {
|
|
416
|
+
if (data === null || data === void 0) {
|
|
417
|
+
return "(\u30C7\u30FC\u30BF\u306A\u3057)";
|
|
418
|
+
}
|
|
419
|
+
if (Array.isArray(data)) {
|
|
420
|
+
if (data.length === 0)
|
|
421
|
+
return "(\u30C7\u30FC\u30BF\u306A\u3057)";
|
|
422
|
+
return renderArrayTable(data);
|
|
423
|
+
}
|
|
424
|
+
if (typeof data === "object") {
|
|
425
|
+
const obj = data;
|
|
426
|
+
const arrayEntry = Object.entries(obj).find(([, v]) => Array.isArray(v) && (v.length === 0 || typeof v[0] === "object" && v[0] !== null));
|
|
427
|
+
if (arrayEntry) {
|
|
428
|
+
const scalarEntries = Object.entries(obj).filter(([k]) => k !== arrayEntry[0]);
|
|
429
|
+
const parts = [];
|
|
430
|
+
if (scalarEntries.length > 0) {
|
|
431
|
+
parts.push(renderKeyValueTable(Object.fromEntries(scalarEntries)));
|
|
432
|
+
parts.push("");
|
|
433
|
+
}
|
|
434
|
+
parts.push(renderArrayTable(arrayEntry[1]));
|
|
435
|
+
return parts.join("\n");
|
|
436
|
+
}
|
|
437
|
+
return renderKeyValueTable(obj);
|
|
438
|
+
}
|
|
439
|
+
return String(data);
|
|
440
|
+
}
|
|
441
|
+
function renderKeyValueTable(obj) {
|
|
442
|
+
const entries = Object.entries(obj).map(([key, value]) => ({
|
|
443
|
+
key,
|
|
444
|
+
value: formatValue(value)
|
|
445
|
+
}));
|
|
446
|
+
const maxKeyLen = Math.max(...entries.map((e) => displayWidth(e.key)));
|
|
447
|
+
const lines = entries.map((e) => `${padRight(e.key, maxKeyLen)} ${e.value}`);
|
|
448
|
+
return lines.join("\n");
|
|
449
|
+
}
|
|
450
|
+
function renderArrayTable(items) {
|
|
451
|
+
if (items.length === 0)
|
|
452
|
+
return "(\u30C7\u30FC\u30BF\u306A\u3057)";
|
|
453
|
+
const keys = Object.keys(items[0]);
|
|
454
|
+
const colWidths = keys.map((key) => {
|
|
455
|
+
const headerWidth = displayWidth(key);
|
|
456
|
+
const maxDataWidth = Math.max(...items.map((item) => displayWidth(formatValue(item[key]))));
|
|
457
|
+
return Math.max(headerWidth, maxDataWidth);
|
|
458
|
+
});
|
|
459
|
+
const header = keys.map((key, i) => padRight(key, colWidths[i])).join(" ");
|
|
460
|
+
const separator = colWidths.map((w) => "-".repeat(w)).join(" ");
|
|
461
|
+
const rows = items.map((item) => keys.map((key, i) => padRight(formatValue(item[key]), colWidths[i])).join(" "));
|
|
462
|
+
return [header, separator, ...rows].join("\n");
|
|
463
|
+
}
|
|
464
|
+
function formatValue(value) {
|
|
465
|
+
if (value === null || value === void 0)
|
|
466
|
+
return "-";
|
|
467
|
+
if (typeof value === "object")
|
|
468
|
+
return JSON.stringify(value);
|
|
469
|
+
return String(value);
|
|
470
|
+
}
|
|
471
|
+
function displayWidth(str) {
|
|
472
|
+
let width = 0;
|
|
473
|
+
for (const char of str) {
|
|
474
|
+
const code = char.codePointAt(0);
|
|
475
|
+
if (code >= 4352 && code <= 4447 || code >= 11904 && code <= 42191 || code >= 44032 && code <= 55215 || code >= 63744 && code <= 64255 || code >= 65040 && code <= 65135 || code >= 65281 && code <= 65376 || code >= 65504 && code <= 65510 || code >= 131072 && code <= 196605 || code >= 196608 && code <= 262141) {
|
|
476
|
+
width += 2;
|
|
477
|
+
} else {
|
|
478
|
+
width += 1;
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
return width;
|
|
482
|
+
}
|
|
483
|
+
function padRight(str, targetWidth) {
|
|
484
|
+
const currentWidth = displayWidth(str);
|
|
485
|
+
const padding = Math.max(0, targetWidth - currentWidth);
|
|
486
|
+
return str + " ".repeat(padding);
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
// ../core/dist/lib/command-helper.js
|
|
490
|
+
function findRoot(cmd) {
|
|
491
|
+
let root = cmd;
|
|
492
|
+
while (root.parent)
|
|
493
|
+
root = root.parent;
|
|
494
|
+
return root;
|
|
495
|
+
}
|
|
496
|
+
function resolveClient(cmd, brand) {
|
|
497
|
+
const root = findRoot(cmd);
|
|
498
|
+
const rootOpts = root.opts();
|
|
499
|
+
const profile = getActiveProfile(brand, rootOpts.profile);
|
|
500
|
+
if (!profile) {
|
|
501
|
+
console.error(`\u8A8D\u8A3C\u8A2D\u5B9A\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3002\`${brand.commandName} auth login\` \u3092\u5B9F\u884C\u3057\u3066\u304F\u3060\u3055\u3044\u3002`);
|
|
502
|
+
process.exit(1);
|
|
503
|
+
}
|
|
504
|
+
const debug = !!(rootOpts.debug || process.env.XSERVER_DEBUG === "1");
|
|
505
|
+
const servername = resolveServername(cmd) ?? profile.servername;
|
|
506
|
+
return new ApiClient({
|
|
507
|
+
apiKey: profile.apiKey,
|
|
508
|
+
apiBase: brand.apiBase,
|
|
509
|
+
servername,
|
|
510
|
+
debug
|
|
511
|
+
});
|
|
512
|
+
}
|
|
513
|
+
function resolveServername(cmd) {
|
|
514
|
+
let current = cmd;
|
|
515
|
+
while (current) {
|
|
516
|
+
const val = current.opts()?.servername;
|
|
517
|
+
if (val)
|
|
518
|
+
return val;
|
|
519
|
+
current = current.parent;
|
|
520
|
+
}
|
|
521
|
+
return void 0;
|
|
522
|
+
}
|
|
523
|
+
function getFormat(cmd) {
|
|
524
|
+
const root = findRoot(cmd);
|
|
525
|
+
return root.opts().format || "table";
|
|
526
|
+
}
|
|
527
|
+
function printResult(data, format) {
|
|
528
|
+
console.log(formatOutput(data, format));
|
|
529
|
+
}
|
|
530
|
+
async function confirmDestructiveAction(cmd, message) {
|
|
531
|
+
const root = findRoot(cmd);
|
|
532
|
+
if (root.opts().yes || process.argv.includes("--yes") || process.argv.includes("-y"))
|
|
533
|
+
return;
|
|
534
|
+
const ok = await confirm({ message, default: false });
|
|
535
|
+
if (!ok) {
|
|
536
|
+
console.error("\u30AD\u30E3\u30F3\u30BB\u30EB\u3057\u307E\u3057\u305F");
|
|
537
|
+
process.exit(1);
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
function pickDefined(obj) {
|
|
541
|
+
const result = {};
|
|
542
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
543
|
+
if (value !== void 0)
|
|
544
|
+
result[key] = value;
|
|
545
|
+
}
|
|
546
|
+
return result;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
// ../core/dist/commands/auth/login.js
|
|
550
|
+
function maskApiKey(apiKey) {
|
|
551
|
+
return `${apiKey.substring(0, 8)}...`;
|
|
552
|
+
}
|
|
553
|
+
function registerAuthCommands(program, brand) {
|
|
554
|
+
const auth = program.command("auth").description("\u8A8D\u8A3C\u8A2D\u5B9A");
|
|
555
|
+
auth.command("login").description("API\u30AD\u30FC\u3092\u8A2D\u5B9A\uFF08\u30B5\u30FC\u30D0\u30FC\u540D\u306F\u81EA\u52D5\u691C\u51FA\uFF09").option("--api-key <key>", "API\u30AD\u30FC").option("--servername <name>", "\u30B5\u30FC\u30D0\u30FC\u540D\uFF08\u81EA\u52D5\u691C\u51FA\u3092\u4E0A\u66F8\u304D\uFF09").action(async (opts, cmd) => {
|
|
556
|
+
const profileName = cmd.optsWithGlobals().profile ?? "default";
|
|
557
|
+
let apiKey = opts.apiKey;
|
|
558
|
+
let servername = opts.servername;
|
|
559
|
+
if (!apiKey) {
|
|
560
|
+
apiKey = await password({ message: "API\u30AD\u30FC\u3092\u5165\u529B:", mask: true });
|
|
561
|
+
}
|
|
562
|
+
if (!apiKey) {
|
|
563
|
+
console.error("\u30A8\u30E9\u30FC: API\u30AD\u30FC\u306F\u5FC5\u9808\u3067\u3059");
|
|
564
|
+
process.exit(1);
|
|
565
|
+
}
|
|
566
|
+
console.error("\u8A8D\u8A3C\u60C5\u5831\u3092\u691C\u8A3C\u4E2D...");
|
|
567
|
+
const client = new ApiClient({ apiKey, apiBase: brand.apiBase });
|
|
568
|
+
let meData;
|
|
569
|
+
try {
|
|
570
|
+
meData = await client.getMe();
|
|
571
|
+
} catch (err) {
|
|
572
|
+
if (err instanceof ApiError && err.errorCode === "UNAUTHORIZED") {
|
|
573
|
+
console.error("\u30A8\u30E9\u30FC: API\u30AD\u30FC\u304C\u7121\u52B9\u3067\u3059\u3002\u6B63\u3057\u3044API\u30AD\u30FC\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\u3002");
|
|
574
|
+
process.exit(1);
|
|
575
|
+
}
|
|
576
|
+
throw err;
|
|
577
|
+
}
|
|
578
|
+
console.error("\u2713 \u8A8D\u8A3C\u306B\u6210\u529F\u3057\u307E\u3057\u305F");
|
|
579
|
+
if (!servername && meData.servername) {
|
|
580
|
+
servername = meData.servername;
|
|
581
|
+
console.error(` \u30B5\u30FC\u30D0\u30FC\u540D\u3092\u81EA\u52D5\u691C\u51FA\u3057\u307E\u3057\u305F: ${servername}`);
|
|
582
|
+
}
|
|
583
|
+
const config = loadConfig(brand);
|
|
584
|
+
config.profiles[profileName] = {
|
|
585
|
+
apiKey,
|
|
586
|
+
...servername ? { servername } : {}
|
|
587
|
+
};
|
|
588
|
+
if (!config.defaultProfile) {
|
|
589
|
+
config.defaultProfile = profileName;
|
|
590
|
+
}
|
|
591
|
+
saveConfig(brand, config);
|
|
592
|
+
console.error(`\u2713 \u30D7\u30ED\u30D5\u30A1\u30A4\u30EB "${profileName}" \u3092\u4FDD\u5B58\u3057\u307E\u3057\u305F`);
|
|
593
|
+
console.error(` \u8A2D\u5B9A\u30D5\u30A1\u30A4\u30EB: ~/.config/${brand.configDir}/config.json`);
|
|
594
|
+
});
|
|
595
|
+
auth.command("status").description("\u73FE\u5728\u306E\u8A8D\u8A3C\u72B6\u614B\u3092\u8868\u793A").action((_opts, cmd) => {
|
|
596
|
+
const format = getFormat(cmd);
|
|
597
|
+
const config = loadConfig(brand);
|
|
598
|
+
const profileName = cmd.optsWithGlobals().profile || config.defaultProfile || "default";
|
|
599
|
+
const profile = config.profiles[profileName];
|
|
600
|
+
if (!profile) {
|
|
601
|
+
if (format === "json") {
|
|
602
|
+
printResult({
|
|
603
|
+
authenticated: false,
|
|
604
|
+
profile: profileName,
|
|
605
|
+
message: `\u30D7\u30ED\u30D5\u30A1\u30A4\u30EB "${profileName}" \u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093`
|
|
606
|
+
}, format);
|
|
607
|
+
} else {
|
|
608
|
+
console.error(`\u30D7\u30ED\u30D5\u30A1\u30A4\u30EB "${profileName}" \u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093`);
|
|
609
|
+
console.error(`\`${brand.commandName} auth login\` \u3067\u8A8D\u8A3C\u8A2D\u5B9A\u3092\u884C\u3063\u3066\u304F\u3060\u3055\u3044`);
|
|
610
|
+
}
|
|
611
|
+
process.exit(1);
|
|
612
|
+
}
|
|
613
|
+
if (format === "json") {
|
|
614
|
+
printResult({
|
|
615
|
+
authenticated: true,
|
|
616
|
+
profile: profileName,
|
|
617
|
+
api_key: maskApiKey(profile.apiKey),
|
|
618
|
+
servername: profile.servername ?? null,
|
|
619
|
+
api_base: brand.apiBase
|
|
620
|
+
}, format);
|
|
621
|
+
return;
|
|
622
|
+
}
|
|
623
|
+
console.log(`\u30D7\u30ED\u30D5\u30A1\u30A4\u30EB: ${profileName}`);
|
|
624
|
+
console.log(`API\u30AD\u30FC: ${maskApiKey(profile.apiKey)}`);
|
|
625
|
+
if (profile.servername) {
|
|
626
|
+
console.log(`\u30B5\u30FC\u30D0\u30FC\u540D: ${profile.servername}`);
|
|
627
|
+
}
|
|
628
|
+
console.log(`API\u30A8\u30F3\u30C9\u30DD\u30A4\u30F3\u30C8: ${brand.apiBase}`);
|
|
629
|
+
});
|
|
630
|
+
auth.command("profiles").description("\u30D7\u30ED\u30D5\u30A1\u30A4\u30EB\u4E00\u89A7\u3092\u8868\u793A").action((_opts, cmd) => {
|
|
631
|
+
const format = getFormat(cmd);
|
|
632
|
+
const config = loadConfig(brand);
|
|
633
|
+
const profiles = Object.keys(config.profiles);
|
|
634
|
+
if (profiles.length === 0) {
|
|
635
|
+
if (format === "json") {
|
|
636
|
+
printResult({
|
|
637
|
+
default_profile: config.defaultProfile || null,
|
|
638
|
+
profiles: [],
|
|
639
|
+
message: "\u30D7\u30ED\u30D5\u30A1\u30A4\u30EB\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093"
|
|
640
|
+
}, format);
|
|
641
|
+
} else {
|
|
642
|
+
console.error("\u30D7\u30ED\u30D5\u30A1\u30A4\u30EB\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093");
|
|
643
|
+
console.error(`\`${brand.commandName} auth login\` \u3067\u8A8D\u8A3C\u8A2D\u5B9A\u3092\u884C\u3063\u3066\u304F\u3060\u3055\u3044`);
|
|
644
|
+
}
|
|
645
|
+
process.exit(1);
|
|
646
|
+
}
|
|
647
|
+
const rows = profiles.map((name) => {
|
|
648
|
+
const p = config.profiles[name];
|
|
649
|
+
return {
|
|
650
|
+
name,
|
|
651
|
+
default: name === config.defaultProfile,
|
|
652
|
+
api_key: maskApiKey(p.apiKey),
|
|
653
|
+
servername: p.servername ?? null
|
|
654
|
+
};
|
|
655
|
+
});
|
|
656
|
+
if (format === "json") {
|
|
657
|
+
printResult({
|
|
658
|
+
default_profile: config.defaultProfile || null,
|
|
659
|
+
profiles: rows
|
|
660
|
+
}, format);
|
|
661
|
+
return;
|
|
662
|
+
}
|
|
663
|
+
for (const name of profiles) {
|
|
664
|
+
const marker = name === config.defaultProfile ? " (default)" : "";
|
|
665
|
+
const p = config.profiles[name];
|
|
666
|
+
const key = maskApiKey(p.apiKey);
|
|
667
|
+
const sv = p.servername ? ` servername=${p.servername}` : "";
|
|
668
|
+
console.log(`${name}${marker}: key=${key}${sv}`);
|
|
669
|
+
}
|
|
670
|
+
});
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
// ../core/dist/commands/server/info.js
|
|
674
|
+
function registerServerInfoCommands(parent, brand) {
|
|
675
|
+
parent.command("info").description("\u30B5\u30FC\u30D0\u30FC\u60C5\u5831\u3092\u53D6\u5F97").action(async () => {
|
|
676
|
+
const client = resolveClient(parent, brand);
|
|
677
|
+
printResult(await client.getServerInfo(), getFormat(parent));
|
|
678
|
+
});
|
|
679
|
+
parent.command("usage").description("\u30B5\u30FC\u30D0\u30FC\u5229\u7528\u72B6\u6CC1\u3092\u53D6\u5F97").action(async () => {
|
|
680
|
+
const client = resolveClient(parent, brand);
|
|
681
|
+
printResult(await client.getServerUsage(), getFormat(parent));
|
|
682
|
+
});
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
// ../core/dist/commands/server/cron/index.js
|
|
686
|
+
function registerCronCommands(parent, brand) {
|
|
687
|
+
const cron = parent.command("cron").description("Cron\u8A2D\u5B9A");
|
|
688
|
+
cron.command("list").description("Cron\u4E00\u89A7\u3092\u53D6\u5F97").action(async () => {
|
|
689
|
+
const client = resolveClient(parent, brand);
|
|
690
|
+
printResult(await client.listCron(), getFormat(parent));
|
|
691
|
+
});
|
|
692
|
+
cron.command("add").description("Cron\u3092\u65B0\u898F\u8FFD\u52A0").requiredOption("--minute <value>", "\u5206\uFF08\u4F8B: */5, 0, *\uFF09").requiredOption("--hour <value>", "\u6642\uFF08\u4F8B: *, 3, 0-6\uFF09").requiredOption("--command <value>", "\u5B9F\u884C\u30B3\u30DE\u30F3\u30C9").option("--day <value>", "\u65E5", "*").option("--month <value>", "\u6708", "*").option("--weekday <value>", "\u66DC\u65E5", "*").option("--comment <value>", "\u30E1\u30E2").action(async (opts) => {
|
|
693
|
+
const client = resolveClient(parent, brand);
|
|
694
|
+
const data = pickDefined({
|
|
695
|
+
minute: opts.minute,
|
|
696
|
+
hour: opts.hour,
|
|
697
|
+
day: opts.day,
|
|
698
|
+
month: opts.month,
|
|
699
|
+
weekday: opts.weekday,
|
|
700
|
+
command: opts.command,
|
|
701
|
+
comment: opts.comment
|
|
702
|
+
});
|
|
703
|
+
printResult(await client.addCron(data), getFormat(parent));
|
|
704
|
+
});
|
|
705
|
+
cron.command("update <cronId>").description("Cron\u3092\u66F4\u65B0").option("--minute <value>", "\u5206").option("--hour <value>", "\u6642").option("--day <value>", "\u65E5").option("--month <value>", "\u6708").option("--weekday <value>", "\u66DC\u65E5").option("--command <value>", "\u5B9F\u884C\u30B3\u30DE\u30F3\u30C9").option("--comment <value>", "\u30E1\u30E2").option("--enabled <value>", "\u6709\u52B9/\u7121\u52B9 (true/false)").action(async (cronId, opts) => {
|
|
706
|
+
const client = resolveClient(parent, brand);
|
|
707
|
+
const data = pickDefined({
|
|
708
|
+
minute: opts.minute,
|
|
709
|
+
hour: opts.hour,
|
|
710
|
+
day: opts.day,
|
|
711
|
+
month: opts.month,
|
|
712
|
+
weekday: opts.weekday,
|
|
713
|
+
command: opts.command,
|
|
714
|
+
comment: opts.comment
|
|
715
|
+
});
|
|
716
|
+
if (opts.enabled !== void 0)
|
|
717
|
+
data.enabled = opts.enabled === "true";
|
|
718
|
+
printResult(await client.updateCron(cronId, data), getFormat(parent));
|
|
719
|
+
});
|
|
720
|
+
cron.command("delete <cronId>").description("Cron\u3092\u524A\u9664").option("-y, --yes", "\u78BA\u8A8D\u30D7\u30ED\u30F3\u30D7\u30C8\u3092\u30B9\u30AD\u30C3\u30D7").action(async (cronId) => {
|
|
721
|
+
await confirmDestructiveAction(parent, `Cron "${cronId}" \u3092\u524A\u9664\u3057\u307E\u3059\u3002\u3088\u308D\u3057\u3044\u3067\u3059\u304B\uFF1F`);
|
|
722
|
+
const client = resolveClient(parent, brand);
|
|
723
|
+
printResult(await client.deleteCron(cronId), getFormat(parent));
|
|
724
|
+
});
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
// ../core/dist/commands/server/wp/index.js
|
|
728
|
+
function registerWpCommands(parent, brand) {
|
|
729
|
+
const wp = parent.command("wp").description("WordPress\u7C21\u5358\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB");
|
|
730
|
+
wp.command("list").description("WordPress\u4E00\u89A7\u3092\u53D6\u5F97").option("--domain <domain>", "\u30C9\u30E1\u30A4\u30F3\u3067\u7D5E\u308A\u8FBC\u307F").action(async (opts) => {
|
|
731
|
+
const client = resolveClient(parent, brand);
|
|
732
|
+
const params = {};
|
|
733
|
+
if (opts.domain)
|
|
734
|
+
params.domain = opts.domain;
|
|
735
|
+
printResult(await client.listWordpress(params), getFormat(parent));
|
|
736
|
+
});
|
|
737
|
+
wp.command("add").description("WordPress\u3092\u65B0\u898F\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB").requiredOption("--url <url>", "\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB\u5148URL\uFF08\u4F8B: example.com/blog\uFF09").requiredOption("--title <title>", "\u30B5\u30A4\u30C8\u30BF\u30A4\u30C8\u30EB").requiredOption("--admin-username <username>", "\u7BA1\u7406\u8005\u30E6\u30FC\u30B6\u30FC\u540D").requiredOption("--admin-password <password>", "\u7BA1\u7406\u8005\u30D1\u30B9\u30EF\u30FC\u30C9").requiredOption("--admin-email <email>", "\u7BA1\u7406\u8005\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9").option("--memo <value>", "\u30E1\u30E2").action(async (opts) => {
|
|
738
|
+
const client = resolveClient(parent, brand);
|
|
739
|
+
const data = pickDefined({
|
|
740
|
+
url: opts.url,
|
|
741
|
+
title: opts.title,
|
|
742
|
+
admin_username: opts.adminUsername,
|
|
743
|
+
admin_password: opts.adminPassword,
|
|
744
|
+
admin_email: opts.adminEmail,
|
|
745
|
+
memo: opts.memo
|
|
746
|
+
});
|
|
747
|
+
printResult(await client.addWordpress(data), getFormat(parent));
|
|
748
|
+
});
|
|
749
|
+
wp.command("update <wpId>").description("WordPress\u8A2D\u5B9A\u3092\u5909\u66F4").option("--memo <value>", "\u30E1\u30E2").action(async (wpId, opts) => {
|
|
750
|
+
const client = resolveClient(parent, brand);
|
|
751
|
+
printResult(await client.updateWordpress(wpId, pickDefined({ memo: opts.memo })), getFormat(parent));
|
|
752
|
+
});
|
|
753
|
+
wp.command("delete <wpId>").description("WordPress\u3092\u524A\u9664").option("--delete-db <value>", "\u95A2\u9023\u3059\u308BMySQL\u30C7\u30FC\u30BF\u30D9\u30FC\u30B9\u3082\u524A\u9664\u3059\u308B\u304B\uFF08\u30C7\u30D5\u30A9\u30EB\u30C8: true\uFF09").option("--delete-db-user <value>", "\u95A2\u9023\u3059\u308BMySQL\u30E6\u30FC\u30B6\u30FC\u3082\u524A\u9664\u3059\u308B\u304B\uFF08\u30C7\u30D5\u30A9\u30EB\u30C8: false\uFF09").option("--delete-cron <value>", "\u30AD\u30E3\u30C3\u30B7\u30E5\u81EA\u52D5\u524A\u9664Cron\u3082\u524A\u9664\u3059\u308B\u304B\uFF08\u30C7\u30D5\u30A9\u30EB\u30C8: true\uFF09").option("-y, --yes", "\u78BA\u8A8D\u30D7\u30ED\u30F3\u30D7\u30C8\u3092\u30B9\u30AD\u30C3\u30D7").action(async (wpId, opts) => {
|
|
754
|
+
await confirmDestructiveAction(parent, `WordPress "${wpId}" \u3092\u524A\u9664\u3057\u307E\u3059\u3002\u3088\u308D\u3057\u3044\u3067\u3059\u304B\uFF1F`);
|
|
755
|
+
const client = resolveClient(parent, brand);
|
|
756
|
+
const data = pickDefined({
|
|
757
|
+
delete_db: opts.deleteDb !== void 0 ? opts.deleteDb === "true" : void 0,
|
|
758
|
+
delete_db_user: opts.deleteDbUser !== void 0 ? opts.deleteDbUser === "true" : void 0,
|
|
759
|
+
delete_cron: opts.deleteCron !== void 0 ? opts.deleteCron === "true" : void 0
|
|
760
|
+
});
|
|
761
|
+
printResult(await client.deleteWordpress(wpId, data), getFormat(parent));
|
|
762
|
+
});
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
// ../core/dist/commands/server/mail/index.js
|
|
766
|
+
function registerMailCommands(parent, brand) {
|
|
767
|
+
const mail = parent.command("mail").description("\u30E1\u30FC\u30EB\u30A2\u30AB\u30A6\u30F3\u30C8\u8A2D\u5B9A");
|
|
768
|
+
mail.command("list").description("\u30E1\u30FC\u30EB\u30A2\u30AB\u30A6\u30F3\u30C8\u4E00\u89A7\u3092\u53D6\u5F97").option("--domain <domain>", "\u30C9\u30E1\u30A4\u30F3\u3067\u7D5E\u308A\u8FBC\u307F").action(async (opts) => {
|
|
769
|
+
const client = resolveClient(parent, brand);
|
|
770
|
+
const params = {};
|
|
771
|
+
if (opts.domain)
|
|
772
|
+
params.domain = opts.domain;
|
|
773
|
+
printResult(await client.listMail(params), getFormat(parent));
|
|
774
|
+
});
|
|
775
|
+
mail.command("get <mailAccount>").description("\u30E1\u30FC\u30EB\u30A2\u30AB\u30A6\u30F3\u30C8\u8A73\u7D30\u3092\u53D6\u5F97").action(async (mailAccount) => {
|
|
776
|
+
const client = resolveClient(parent, brand);
|
|
777
|
+
printResult(await client.getMail(mailAccount), getFormat(parent));
|
|
778
|
+
});
|
|
779
|
+
mail.command("add <mailAddress>").description("\u30E1\u30FC\u30EB\u30A2\u30AB\u30A6\u30F3\u30C8\u3092\u65B0\u898F\u8FFD\u52A0").requiredOption("--password <password>", "\u30D1\u30B9\u30EF\u30FC\u30C9").option("--quota-mb <mb>", "\u5BB9\u91CF\uFF08MB\uFF09").option("--memo <value>", "\u30E1\u30E2").action(async (mailAddress, opts) => {
|
|
780
|
+
const client = resolveClient(parent, brand);
|
|
781
|
+
const data = pickDefined({
|
|
782
|
+
mail_address: mailAddress,
|
|
783
|
+
password: opts.password,
|
|
784
|
+
quota_mb: opts.quotaMb !== void 0 ? parseInt(opts.quotaMb, 10) : void 0,
|
|
785
|
+
memo: opts.memo
|
|
786
|
+
});
|
|
787
|
+
printResult(await client.addMail(data), getFormat(parent));
|
|
788
|
+
});
|
|
789
|
+
mail.command("update <mailAccount>").description("\u30E1\u30FC\u30EB\u30A2\u30AB\u30A6\u30F3\u30C8\u8A2D\u5B9A\u3092\u5909\u66F4").option("--password <password>", "\u30D1\u30B9\u30EF\u30FC\u30C9").option("--quota-mb <mb>", "\u5BB9\u91CF\uFF08MB\uFF09").option("--memo <value>", "\u30E1\u30E2").action(async (mailAccount, opts) => {
|
|
790
|
+
const client = resolveClient(parent, brand);
|
|
791
|
+
printResult(await client.updateMail(mailAccount, pickDefined({
|
|
792
|
+
password: opts.password,
|
|
793
|
+
quota_mb: opts.quotaMb !== void 0 ? parseInt(opts.quotaMb, 10) : void 0,
|
|
794
|
+
memo: opts.memo
|
|
795
|
+
})), getFormat(parent));
|
|
796
|
+
});
|
|
797
|
+
mail.command("delete <mailAccount>").description("\u30E1\u30FC\u30EB\u30A2\u30AB\u30A6\u30F3\u30C8\u3092\u524A\u9664").option("-y, --yes", "\u78BA\u8A8D\u30D7\u30ED\u30F3\u30D7\u30C8\u3092\u30B9\u30AD\u30C3\u30D7").action(async (mailAccount) => {
|
|
798
|
+
await confirmDestructiveAction(parent, `\u30E1\u30FC\u30EB\u30A2\u30AB\u30A6\u30F3\u30C8 "${mailAccount}" \u3092\u524A\u9664\u3057\u307E\u3059\u3002\u3088\u308D\u3057\u3044\u3067\u3059\u304B\uFF1F`);
|
|
799
|
+
const client = resolveClient(parent, brand);
|
|
800
|
+
printResult(await client.deleteMail(mailAccount), getFormat(parent));
|
|
801
|
+
});
|
|
802
|
+
mail.command("forwarding-get <mailAccount>").description("\u30E1\u30FC\u30EB\u8EE2\u9001\u8A2D\u5B9A\u3092\u53D6\u5F97").action(async (mailAccount) => {
|
|
803
|
+
const client = resolveClient(parent, brand);
|
|
804
|
+
printResult(await client.getMailForwarding(mailAccount), getFormat(parent));
|
|
805
|
+
});
|
|
806
|
+
mail.command("forwarding-update <mailAccount>").description("\u30E1\u30FC\u30EB\u8EE2\u9001\u8A2D\u5B9A\u3092\u66F4\u65B0").option("--forwarding-addresses <addresses>", "\u8EE2\u9001\u5148\u30A2\u30C9\u30EC\u30B9\uFF08\u30AB\u30F3\u30DE\u533A\u5207\u308A\uFF09").option("--keep-in-mailbox <value>", "\u8EE2\u9001\u5F8C\u3082\u30E1\u30FC\u30EB\u30DC\u30C3\u30AF\u30B9\u306B\u6B8B\u3059\u304B\uFF08true/false\uFF09").action(async (mailAccount, opts) => {
|
|
807
|
+
const client = resolveClient(parent, brand);
|
|
808
|
+
const data = {};
|
|
809
|
+
if (opts.forwardingAddresses)
|
|
810
|
+
data.forwarding_addresses = opts.forwardingAddresses.split(",").map((a) => a.trim());
|
|
811
|
+
if (opts.keepInMailbox !== void 0)
|
|
812
|
+
data.keep_in_mailbox = opts.keepInMailbox === "true";
|
|
813
|
+
printResult(await client.updateMailForwarding(mailAccount, data), getFormat(parent));
|
|
814
|
+
});
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
// ../core/dist/commands/server/mail-filter/index.js
|
|
818
|
+
function registerMailFilterCommands(parent, brand) {
|
|
819
|
+
const mailFilter = parent.command("mail-filter").description("\u30E1\u30FC\u30EB\u632F\u308A\u5206\u3051\u8A2D\u5B9A");
|
|
820
|
+
mailFilter.command("list").description("\u30E1\u30FC\u30EB\u632F\u308A\u5206\u3051\u8A2D\u5B9A\u306E\u4E00\u89A7\u3092\u53D6\u5F97").option("--domain <domain>", "\u30C9\u30E1\u30A4\u30F3\u3067\u7D5E\u308A\u8FBC\u307F").action(async (opts) => {
|
|
821
|
+
const client = resolveClient(parent, brand);
|
|
822
|
+
const params = {};
|
|
823
|
+
if (opts.domain)
|
|
824
|
+
params.domain = opts.domain;
|
|
825
|
+
printResult(await client.listMailFilter(params), getFormat(parent));
|
|
826
|
+
});
|
|
827
|
+
mailFilter.command("add").description("\u30E1\u30FC\u30EB\u632F\u308A\u5206\u3051\u8A2D\u5B9A\u3092\u65B0\u898F\u8FFD\u52A0").requiredOption("--domain <domain>", "\u5BFE\u8C61\u30C9\u30E1\u30A4\u30F3").requiredOption("--condition-keyword <keyword>", "\u6761\u4EF6\u30AD\u30FC\u30EF\u30FC\u30C9").requiredOption("--condition-field <field>", "\u6761\u4EF6\u5BFE\u8C61\uFF08subject / from / to / body / header\uFF09").option("--condition-match-type <type>", "\u4E00\u81F4\u6761\u4EF6\uFF08contain / match / start_from\u3002\u30C7\u30D5\u30A9\u30EB\u30C8: contain\uFF09").requiredOption("--action-type <type>", "\u30A2\u30AF\u30B7\u30E7\u30F3\u7A2E\u5225\uFF08mail_address / spam_folder / trash / delete\uFF09").option("--action-target <target>", "\u8EE2\u9001\u5148\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9\uFF08action-type\u304Cmail_address\u306E\u5834\u5408\uFF09").option("--action-method <method>", "\u51E6\u7406\u65B9\u6CD5\uFF08move / copy\u3002\u30C7\u30D5\u30A9\u30EB\u30C8: move\uFF09").action(async (opts) => {
|
|
828
|
+
const client = resolveClient(parent, brand);
|
|
829
|
+
const data = {
|
|
830
|
+
domain: opts.domain,
|
|
831
|
+
conditions: [{
|
|
832
|
+
keyword: opts.conditionKeyword,
|
|
833
|
+
field: opts.conditionField,
|
|
834
|
+
match_type: opts.conditionMatchType || "contain"
|
|
835
|
+
}],
|
|
836
|
+
action: {
|
|
837
|
+
type: opts.actionType,
|
|
838
|
+
target: opts.actionTarget || "",
|
|
839
|
+
method: opts.actionMethod || "move"
|
|
840
|
+
}
|
|
841
|
+
};
|
|
842
|
+
printResult(await client.addMailFilter(data), getFormat(parent));
|
|
843
|
+
});
|
|
844
|
+
mailFilter.command("delete <filterId>").description("\u30E1\u30FC\u30EB\u632F\u308A\u5206\u3051\u8A2D\u5B9A\u3092\u524A\u9664").option("-y, --yes", "\u78BA\u8A8D\u30D7\u30ED\u30F3\u30D7\u30C8\u3092\u30B9\u30AD\u30C3\u30D7").action(async (filterId) => {
|
|
845
|
+
await confirmDestructiveAction(parent, `\u30E1\u30FC\u30EB\u632F\u308A\u5206\u3051\u8A2D\u5B9A "${filterId}" \u3092\u524A\u9664\u3057\u307E\u3059\u3002\u3088\u308D\u3057\u3044\u3067\u3059\u304B\uFF1F`);
|
|
846
|
+
const client = resolveClient(parent, brand);
|
|
847
|
+
printResult(await client.deleteMailFilter(filterId), getFormat(parent));
|
|
848
|
+
});
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
// ../core/dist/commands/server/ftp/index.js
|
|
852
|
+
function registerFtpCommands(parent, brand) {
|
|
853
|
+
const ftp = parent.command("ftp").description("FTP\u30A2\u30AB\u30A6\u30F3\u30C8\u8A2D\u5B9A");
|
|
854
|
+
ftp.command("list").description("FTP\u30A2\u30AB\u30A6\u30F3\u30C8\u4E00\u89A7\u3092\u53D6\u5F97").option("--domain <domain>", "\u30C9\u30E1\u30A4\u30F3\u3067\u7D5E\u308A\u8FBC\u307F").action(async (opts) => {
|
|
855
|
+
const client = resolveClient(parent, brand);
|
|
856
|
+
const params = {};
|
|
857
|
+
if (opts.domain)
|
|
858
|
+
params.domain = opts.domain;
|
|
859
|
+
printResult(await client.listFtp(params), getFormat(parent));
|
|
860
|
+
});
|
|
861
|
+
ftp.command("add <ftpAccount>").description("FTP\u30A2\u30AB\u30A6\u30F3\u30C8\u3092\u65B0\u898F\u8FFD\u52A0").requiredOption("--password <password>", "\u30D1\u30B9\u30EF\u30FC\u30C9").option("--directory <dir>", "\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA").option("--quota <mb>", "\u5BB9\u91CF\u5236\u9650\uFF08MB\u30020\u3067\u7121\u5236\u9650\uFF09").option("--memo <value>", "\u30E1\u30E2").action(async (ftpAccount, opts) => {
|
|
862
|
+
const client = resolveClient(parent, brand);
|
|
863
|
+
const data = pickDefined({
|
|
864
|
+
ftp_account: ftpAccount,
|
|
865
|
+
password: opts.password,
|
|
866
|
+
directory: opts.directory,
|
|
867
|
+
quota_mb: opts.quota !== void 0 ? parseInt(opts.quota, 10) : void 0,
|
|
868
|
+
memo: opts.memo
|
|
869
|
+
});
|
|
870
|
+
printResult(await client.addFtp(data), getFormat(parent));
|
|
871
|
+
});
|
|
872
|
+
ftp.command("update <ftpAccount>").description("FTP\u30A2\u30AB\u30A6\u30F3\u30C8\u8A2D\u5B9A\u3092\u5909\u66F4").option("--password <password>", "\u30D1\u30B9\u30EF\u30FC\u30C9").option("--directory <dir>", "\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA").option("--quota <mb>", "\u5BB9\u91CF\u5236\u9650\uFF08MB\uFF09").option("--memo <value>", "\u30E1\u30E2").action(async (ftpAccount, opts) => {
|
|
873
|
+
const client = resolveClient(parent, brand);
|
|
874
|
+
printResult(await client.updateFtp(ftpAccount, pickDefined({
|
|
875
|
+
password: opts.password,
|
|
876
|
+
directory: opts.directory,
|
|
877
|
+
quota_mb: opts.quota !== void 0 ? parseInt(opts.quota, 10) : void 0,
|
|
878
|
+
memo: opts.memo
|
|
879
|
+
})), getFormat(parent));
|
|
880
|
+
});
|
|
881
|
+
ftp.command("delete <ftpAccount>").description("FTP\u30A2\u30AB\u30A6\u30F3\u30C8\u3092\u524A\u9664").option("-y, --yes", "\u78BA\u8A8D\u30D7\u30ED\u30F3\u30D7\u30C8\u3092\u30B9\u30AD\u30C3\u30D7").action(async (ftpAccount) => {
|
|
882
|
+
await confirmDestructiveAction(parent, `FTP\u30A2\u30AB\u30A6\u30F3\u30C8 "${ftpAccount}" \u3092\u524A\u9664\u3057\u307E\u3059\u3002\u3088\u308D\u3057\u3044\u3067\u3059\u304B\uFF1F`);
|
|
883
|
+
const client = resolveClient(parent, brand);
|
|
884
|
+
printResult(await client.deleteFtp(ftpAccount), getFormat(parent));
|
|
885
|
+
});
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
// ../core/dist/commands/server/db/index.js
|
|
889
|
+
function registerDbCommands(parent, brand) {
|
|
890
|
+
const db = parent.command("db").description("MySQL\u8A2D\u5B9A");
|
|
891
|
+
db.command("list").description("\u30C7\u30FC\u30BF\u30D9\u30FC\u30B9\u4E00\u89A7\u3092\u53D6\u5F97").action(async () => {
|
|
892
|
+
const client = resolveClient(parent, brand);
|
|
893
|
+
printResult(await client.listDb(), getFormat(parent));
|
|
894
|
+
});
|
|
895
|
+
db.command("add <nameSuffix>").description("\u30C7\u30FC\u30BF\u30D9\u30FC\u30B9\u3092\u65B0\u898F\u4F5C\u6210").option("--character-set <charset>", "\u6587\u5B57\u30B3\u30FC\u30C9\uFF08utf8mb4 / UTF-8 / EUC-JP / SHIFT-JIS / Binary\u3002\u30C7\u30D5\u30A9\u30EB\u30C8: utf8mb4\uFF09").option("--memo <value>", "\u30E1\u30E2").action(async (nameSuffix, opts) => {
|
|
896
|
+
const client = resolveClient(parent, brand);
|
|
897
|
+
printResult(await client.addDb(pickDefined({
|
|
898
|
+
name_suffix: nameSuffix,
|
|
899
|
+
character_set: opts.characterSet,
|
|
900
|
+
memo: opts.memo
|
|
901
|
+
})), getFormat(parent));
|
|
902
|
+
});
|
|
903
|
+
db.command("update <dbName>").description("\u30C7\u30FC\u30BF\u30D9\u30FC\u30B9\u306E\u30E1\u30E2\u3092\u66F4\u65B0").option("--memo <value>", "\u30E1\u30E2").action(async (dbName, opts) => {
|
|
904
|
+
const client = resolveClient(parent, brand);
|
|
905
|
+
printResult(await client.updateDb(dbName, pickDefined({
|
|
906
|
+
memo: opts.memo
|
|
907
|
+
})), getFormat(parent));
|
|
908
|
+
});
|
|
909
|
+
db.command("delete <dbName>").description("\u30C7\u30FC\u30BF\u30D9\u30FC\u30B9\u3092\u524A\u9664").option("-y, --yes", "\u78BA\u8A8D\u30D7\u30ED\u30F3\u30D7\u30C8\u3092\u30B9\u30AD\u30C3\u30D7").action(async (dbName) => {
|
|
910
|
+
await confirmDestructiveAction(parent, `\u30C7\u30FC\u30BF\u30D9\u30FC\u30B9 "${dbName}" \u3092\u524A\u9664\u3057\u307E\u3059\u3002\u3088\u308D\u3057\u3044\u3067\u3059\u304B\uFF1F`);
|
|
911
|
+
const client = resolveClient(parent, brand);
|
|
912
|
+
printResult(await client.deleteDb(dbName), getFormat(parent));
|
|
913
|
+
});
|
|
914
|
+
db.command("user-list").description("MySQL\u30E6\u30FC\u30B6\u30FC\u4E00\u89A7\u3092\u53D6\u5F97").action(async () => {
|
|
915
|
+
const client = resolveClient(parent, brand);
|
|
916
|
+
printResult(await client.listDbUser(), getFormat(parent));
|
|
917
|
+
});
|
|
918
|
+
db.command("user-add <nameSuffix>").description("MySQL\u30E6\u30FC\u30B6\u30FC\u3092\u65B0\u898F\u4F5C\u6210").requiredOption("--password <password>", "\u30D1\u30B9\u30EF\u30FC\u30C9").option("--memo <value>", "\u30E1\u30E2").action(async (nameSuffix, opts) => {
|
|
919
|
+
const client = resolveClient(parent, brand);
|
|
920
|
+
printResult(await client.addDbUser(pickDefined({
|
|
921
|
+
name_suffix: nameSuffix,
|
|
922
|
+
password: opts.password,
|
|
923
|
+
memo: opts.memo
|
|
924
|
+
})), getFormat(parent));
|
|
925
|
+
});
|
|
926
|
+
db.command("user-update <dbUser>").description("MySQL\u30E6\u30FC\u30B6\u30FC\u8A2D\u5B9A\u3092\u5909\u66F4").option("--password <password>", "\u30D1\u30B9\u30EF\u30FC\u30C9").option("--memo <value>", "\u30E1\u30E2").action(async (dbUser, opts) => {
|
|
927
|
+
const client = resolveClient(parent, brand);
|
|
928
|
+
printResult(await client.updateDbUser(dbUser, pickDefined({
|
|
929
|
+
password: opts.password,
|
|
930
|
+
memo: opts.memo
|
|
931
|
+
})), getFormat(parent));
|
|
932
|
+
});
|
|
933
|
+
db.command("user-delete <dbUser>").description("MySQL\u30E6\u30FC\u30B6\u30FC\u3092\u524A\u9664").option("-y, --yes", "\u78BA\u8A8D\u30D7\u30ED\u30F3\u30D7\u30C8\u3092\u30B9\u30AD\u30C3\u30D7").action(async (dbUser) => {
|
|
934
|
+
await confirmDestructiveAction(parent, `MySQL\u30E6\u30FC\u30B6\u30FC "${dbUser}" \u3092\u524A\u9664\u3057\u307E\u3059\u3002\u3088\u308D\u3057\u3044\u3067\u3059\u304B\uFF1F`);
|
|
935
|
+
const client = resolveClient(parent, brand);
|
|
936
|
+
printResult(await client.deleteDbUser(dbUser), getFormat(parent));
|
|
937
|
+
});
|
|
938
|
+
db.command("grant-list <dbUser>").description("MySQL\u30E6\u30FC\u30B6\u30FC\u306E\u6A29\u9650\u4E00\u89A7\u3092\u53D6\u5F97").action(async (dbUser) => {
|
|
939
|
+
const client = resolveClient(parent, brand);
|
|
940
|
+
printResult(await client.listDbUserGrant(dbUser), getFormat(parent));
|
|
941
|
+
});
|
|
942
|
+
db.command("grant-add <dbUser>").description("MySQL\u30E6\u30FC\u30B6\u30FC\u306B\u6A29\u9650\u3092\u8FFD\u52A0").requiredOption("--db-name <dbName>", "\u5BFE\u8C61\u30C7\u30FC\u30BF\u30D9\u30FC\u30B9\u540D").action(async (dbUser, opts) => {
|
|
943
|
+
const client = resolveClient(parent, brand);
|
|
944
|
+
printResult(await client.addDbUserGrant(dbUser, { db_name: opts.dbName }), getFormat(parent));
|
|
945
|
+
});
|
|
946
|
+
db.command("grant-delete <dbUser>").description("MySQL\u30E6\u30FC\u30B6\u30FC\u306E\u6A29\u9650\u3092\u524A\u9664").requiredOption("--db-name <dbName>", "\u5BFE\u8C61\u30C7\u30FC\u30BF\u30D9\u30FC\u30B9\u540D").option("-y, --yes", "\u78BA\u8A8D\u30D7\u30ED\u30F3\u30D7\u30C8\u3092\u30B9\u30AD\u30C3\u30D7").action(async (dbUser, opts) => {
|
|
947
|
+
await confirmDestructiveAction(parent, `MySQL\u30E6\u30FC\u30B6\u30FC "${dbUser}" \u306E\u30C7\u30FC\u30BF\u30D9\u30FC\u30B9 "${opts.dbName}" \u3078\u306E\u6A29\u9650\u3092\u524A\u9664\u3057\u307E\u3059\u3002\u3088\u308D\u3057\u3044\u3067\u3059\u304B\uFF1F`);
|
|
948
|
+
const client = resolveClient(parent, brand);
|
|
949
|
+
printResult(await client.deleteDbUserGrant(dbUser, { db_name: opts.dbName }), getFormat(parent));
|
|
950
|
+
});
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
// ../core/dist/commands/server/php-version/index.js
|
|
954
|
+
function registerPhpVersionCommands(parent, brand) {
|
|
955
|
+
const phpVer = parent.command("php-version").description("PHP\u30D0\u30FC\u30B8\u30E7\u30F3\u8A2D\u5B9A");
|
|
956
|
+
phpVer.command("get").description("PHP\u30D0\u30FC\u30B8\u30E7\u30F3\u78BA\u8A8D").option("--domain <domain>", "\u30C9\u30E1\u30A4\u30F3\u3067\u7D5E\u308A\u8FBC\u307F").action(async (opts) => {
|
|
957
|
+
const client = resolveClient(parent, brand);
|
|
958
|
+
const params = {};
|
|
959
|
+
if (opts.domain)
|
|
960
|
+
params.domain = opts.domain;
|
|
961
|
+
printResult(await client.getPhpVersion(params), getFormat(parent));
|
|
962
|
+
});
|
|
963
|
+
phpVer.command("update <domain>").description("PHP\u30D0\u30FC\u30B8\u30E7\u30F3\u3092\u5909\u66F4").requiredOption("--php <version>", "PHP\u30D0\u30FC\u30B8\u30E7\u30F3\uFF08\u4F8B: 8.2\uFF09").action(async (domain, opts) => {
|
|
964
|
+
const client = resolveClient(parent, brand);
|
|
965
|
+
printResult(await client.updatePhpVersion(domain, { version: opts.php }), getFormat(parent));
|
|
966
|
+
});
|
|
967
|
+
}
|
|
968
|
+
|
|
969
|
+
// ../core/dist/commands/server/domain/index.js
|
|
970
|
+
function registerServerDomainCommands(parent, brand) {
|
|
971
|
+
const domain = parent.command("domain").description("\u30C9\u30E1\u30A4\u30F3\u8A2D\u5B9A");
|
|
972
|
+
domain.command("list").description("\u30C9\u30E1\u30A4\u30F3\u8A2D\u5B9A\u4E00\u89A7\u3092\u53D6\u5F97").action(async () => {
|
|
973
|
+
const client = resolveClient(parent, brand);
|
|
974
|
+
printResult(await client.listDomain(), getFormat(parent));
|
|
975
|
+
});
|
|
976
|
+
domain.command("get <domain>").description("\u30C9\u30E1\u30A4\u30F3\u8A2D\u5B9A\u8A73\u7D30\u3092\u53D6\u5F97").action(async (domainName) => {
|
|
977
|
+
const client = resolveClient(parent, brand);
|
|
978
|
+
printResult(await client.getDomain(domainName), getFormat(parent));
|
|
979
|
+
});
|
|
980
|
+
domain.command("add <domain>").description("\u30C9\u30E1\u30A4\u30F3\u8A2D\u5B9A\u3092\u65B0\u898F\u8FFD\u52A0").option("--ssl <value>", "SSL\u8A2D\u5B9A\uFF08\u30C7\u30D5\u30A9\u30EB\u30C8: true\uFF09").option("--redirect-https <value>", "HTTPS\u8EE2\u9001\u8A2D\u5B9A\uFF08\u30C7\u30D5\u30A9\u30EB\u30C8: ssl\u3068\u540C\u3058\u5024\uFF09").option("--ai-crawler-block <value>", "AI\u30AF\u30ED\u30FC\u30E9\u30FC\u906E\u65AD\u8A2D\u5B9A\uFF08\u30C7\u30D5\u30A9\u30EB\u30C8: true\uFF09").option("--memo <value>", "\u30E1\u30E2").action(async (domainName, opts) => {
|
|
981
|
+
const client = resolveClient(parent, brand);
|
|
982
|
+
const data = { domain: domainName };
|
|
983
|
+
if (opts.ssl !== void 0)
|
|
984
|
+
data.ssl = opts.ssl === "true";
|
|
985
|
+
if (opts.redirectHttps !== void 0)
|
|
986
|
+
data.redirect_https = opts.redirectHttps === "true";
|
|
987
|
+
if (opts.aiCrawlerBlock !== void 0)
|
|
988
|
+
data.ai_crawler_block_enabled = opts.aiCrawlerBlock === "true";
|
|
989
|
+
if (opts.memo !== void 0)
|
|
990
|
+
data.memo = opts.memo;
|
|
991
|
+
printResult(await client.addDomain(data), getFormat(parent));
|
|
992
|
+
});
|
|
993
|
+
domain.command("update <domain>").description("\u30C9\u30E1\u30A4\u30F3\u8A2D\u5B9A\u3092\u5909\u66F4").option("--memo <value>", "\u30E1\u30E2").action(async (domainName, opts) => {
|
|
994
|
+
const client = resolveClient(parent, brand);
|
|
995
|
+
printResult(await client.updateDomain(domainName, pickDefined({
|
|
996
|
+
memo: opts.memo
|
|
997
|
+
})), getFormat(parent));
|
|
998
|
+
});
|
|
999
|
+
domain.command("delete <domain>").description("\u30C9\u30E1\u30A4\u30F3\u8A2D\u5B9A\u3092\u524A\u9664").option("--delete-files", "\u30E6\u30FC\u30B6\u30FC\u516C\u958B\u9818\u57DF\u306E\u30C9\u30E1\u30A4\u30F3\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u3082\u524A\u9664\u3059\u308B").option("-y, --yes", "\u78BA\u8A8D\u30D7\u30ED\u30F3\u30D7\u30C8\u3092\u30B9\u30AD\u30C3\u30D7").action(async (domainName, opts) => {
|
|
1000
|
+
const suffix = opts.deleteFiles ? "\uFF08\u95A2\u9023\u30D5\u30A1\u30A4\u30EB\u3082\u524A\u9664\u3057\u307E\u3059\uFF09" : "";
|
|
1001
|
+
await confirmDestructiveAction(parent, `\u30C9\u30E1\u30A4\u30F3\u8A2D\u5B9A "${domainName}" \u3092\u524A\u9664\u3057\u307E\u3059${suffix}\u3002\u3088\u308D\u3057\u3044\u3067\u3059\u304B\uFF1F`);
|
|
1002
|
+
const client = resolveClient(parent, brand);
|
|
1003
|
+
const data = {};
|
|
1004
|
+
if (opts.deleteFiles)
|
|
1005
|
+
data.delete_files = true;
|
|
1006
|
+
printResult(await client.deleteDomain(domainName, data), getFormat(parent));
|
|
1007
|
+
});
|
|
1008
|
+
domain.command("reset <domain>").description("\u30C9\u30E1\u30A4\u30F3\u8A2D\u5B9A\u3092\u521D\u671F\u5316").requiredOption("--type <type>", "\u30EA\u30BB\u30C3\u30C8\u7A2E\u5225\uFF08all: \u5168\u521D\u671F\u5316 / web: Web\u9818\u57DF\u306E\u307F / other: Web\u4EE5\u5916\uFF09").option("-y, --yes", "\u78BA\u8A8D\u30D7\u30ED\u30F3\u30D7\u30C8\u3092\u30B9\u30AD\u30C3\u30D7").action(async (domainName, opts) => {
|
|
1009
|
+
await confirmDestructiveAction(parent, `\u30C9\u30E1\u30A4\u30F3\u8A2D\u5B9A "${domainName}" \u3092 "${opts.type}" \u3067\u521D\u671F\u5316\u3057\u307E\u3059\u3002\u3088\u308D\u3057\u3044\u3067\u3059\u304B\uFF1F`);
|
|
1010
|
+
const client = resolveClient(parent, brand);
|
|
1011
|
+
printResult(await client.resetDomain(domainName, { type: opts.type }), getFormat(parent));
|
|
1012
|
+
});
|
|
1013
|
+
}
|
|
1014
|
+
|
|
1015
|
+
// ../core/dist/commands/server/subdomain/index.js
|
|
1016
|
+
function registerSubdomainCommands(parent, brand) {
|
|
1017
|
+
const subdomain = parent.command("subdomain").description("\u30B5\u30D6\u30C9\u30E1\u30A4\u30F3\u8A2D\u5B9A");
|
|
1018
|
+
subdomain.command("list").description("\u30B5\u30D6\u30C9\u30E1\u30A4\u30F3\u8A2D\u5B9A\u4E00\u89A7\u3092\u53D6\u5F97").option("--domain <domain>", "\u30C9\u30E1\u30A4\u30F3\u3067\u7D5E\u308A\u8FBC\u307F").action(async (opts) => {
|
|
1019
|
+
const client = resolveClient(parent, brand);
|
|
1020
|
+
const params = {};
|
|
1021
|
+
if (opts.domain)
|
|
1022
|
+
params.domain = opts.domain;
|
|
1023
|
+
printResult(await client.listSubdomain(params), getFormat(parent));
|
|
1024
|
+
});
|
|
1025
|
+
subdomain.command("add <subdomain>").description("\u30B5\u30D6\u30C9\u30E1\u30A4\u30F3\u3092\u65B0\u898F\u8FFD\u52A0").option("--document-root-type <type>", "\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u30EB\u30FC\u30C8\u7A2E\u5225\uFF08subdomain_only: /public_html/sub, full_subdomain: /public_html/sub.example.com\uFF09").option("--ssl <value>", "SSL\u8A2D\u5B9A\uFF08\u30C7\u30D5\u30A9\u30EB\u30C8: true\uFF09").option("--memo <value>", "\u30E1\u30E2").action(async (subdomainName, opts) => {
|
|
1026
|
+
const client = resolveClient(parent, brand);
|
|
1027
|
+
const data = { subdomain: subdomainName };
|
|
1028
|
+
if (opts.documentRootType !== void 0)
|
|
1029
|
+
data.document_root_type = opts.documentRootType;
|
|
1030
|
+
if (opts.ssl !== void 0)
|
|
1031
|
+
data.ssl = opts.ssl === "true";
|
|
1032
|
+
if (opts.memo !== void 0)
|
|
1033
|
+
data.memo = opts.memo;
|
|
1034
|
+
printResult(await client.addSubdomain(data), getFormat(parent));
|
|
1035
|
+
});
|
|
1036
|
+
subdomain.command("update <subdomain>").description("\u30B5\u30D6\u30C9\u30E1\u30A4\u30F3\u306E\u30E1\u30E2\u3092\u66F4\u65B0").option("--memo <value>", "\u30E1\u30E2").action(async (subdomainName, opts) => {
|
|
1037
|
+
const client = resolveClient(parent, brand);
|
|
1038
|
+
printResult(await client.updateSubdomain(subdomainName, pickDefined({
|
|
1039
|
+
memo: opts.memo
|
|
1040
|
+
})), getFormat(parent));
|
|
1041
|
+
});
|
|
1042
|
+
subdomain.command("delete <subdomain>").description("\u30B5\u30D6\u30C9\u30E1\u30A4\u30F3\u3092\u524A\u9664").option("--delete-files", "\u95A2\u9023\u30D5\u30A1\u30A4\u30EB\u3082\u524A\u9664\u3059\u308B").option("-y, --yes", "\u78BA\u8A8D\u30D7\u30ED\u30F3\u30D7\u30C8\u3092\u30B9\u30AD\u30C3\u30D7").action(async (subdomainName, opts) => {
|
|
1043
|
+
const suffix = opts.deleteFiles ? "\uFF08\u95A2\u9023\u30D5\u30A1\u30A4\u30EB\u3082\u524A\u9664\u3057\u307E\u3059\uFF09" : "";
|
|
1044
|
+
await confirmDestructiveAction(parent, `\u30B5\u30D6\u30C9\u30E1\u30A4\u30F3 "${subdomainName}" \u3092\u524A\u9664\u3057\u307E\u3059${suffix}\u3002\u3088\u308D\u3057\u3044\u3067\u3059\u304B\uFF1F`);
|
|
1045
|
+
const client = resolveClient(parent, brand);
|
|
1046
|
+
const data = {};
|
|
1047
|
+
if (opts.deleteFiles)
|
|
1048
|
+
data.delete_files = true;
|
|
1049
|
+
printResult(await client.deleteSubdomain(subdomainName, data), getFormat(parent));
|
|
1050
|
+
});
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
// ../core/dist/commands/server/ssl/index.js
|
|
1054
|
+
function registerSslCommands(parent, brand) {
|
|
1055
|
+
const ssl = parent.command("ssl").description("SSL\u8A2D\u5B9A");
|
|
1056
|
+
ssl.command("list").description("SSL\u8A2D\u5B9A\u306E\u4E00\u89A7\u3092\u53D6\u5F97").option("--domain <domain>", "\u30C9\u30E1\u30A4\u30F3\u3067\u7D5E\u308A\u8FBC\u307F").action(async (opts) => {
|
|
1057
|
+
const client = resolveClient(parent, brand);
|
|
1058
|
+
const params = {};
|
|
1059
|
+
if (opts.domain)
|
|
1060
|
+
params.domain = opts.domain;
|
|
1061
|
+
printResult(await client.listSsl(params), getFormat(parent));
|
|
1062
|
+
});
|
|
1063
|
+
ssl.command("install <commonName>").description("\u7121\u6599SSL\u3092\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB").action(async (commonName) => {
|
|
1064
|
+
const client = resolveClient(parent, brand);
|
|
1065
|
+
printResult(await client.installSsl(pickDefined({
|
|
1066
|
+
common_name: commonName
|
|
1067
|
+
})), getFormat(parent));
|
|
1068
|
+
});
|
|
1069
|
+
ssl.command("uninstall <commonName>").description("\u7121\u6599SSL\u3092\u30A2\u30F3\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB").option("-y, --yes", "\u78BA\u8A8D\u30D7\u30ED\u30F3\u30D7\u30C8\u3092\u30B9\u30AD\u30C3\u30D7").action(async (commonName) => {
|
|
1070
|
+
await confirmDestructiveAction(parent, `\u7121\u6599SSL "${commonName}" \u3092\u30A2\u30F3\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB\u3057\u307E\u3059\u3002\u3088\u308D\u3057\u3044\u3067\u3059\u304B\uFF1F`);
|
|
1071
|
+
const client = resolveClient(parent, brand);
|
|
1072
|
+
printResult(await client.uninstallSsl(commonName), getFormat(parent));
|
|
1073
|
+
});
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
// ../core/dist/commands/server/dns/index.js
|
|
1077
|
+
function registerDnsCommands(parent, brand) {
|
|
1078
|
+
const dns = parent.command("dns").description("DNS\u30EC\u30B3\u30FC\u30C9\u8A2D\u5B9A");
|
|
1079
|
+
dns.command("list").description("DNS\u30EC\u30B3\u30FC\u30C9\u4E00\u89A7\u3092\u53D6\u5F97").option("--domain <domain>", "\u30C9\u30E1\u30A4\u30F3\u3067\u7D5E\u308A\u8FBC\u307F").action(async (opts) => {
|
|
1080
|
+
const client = resolveClient(parent, brand);
|
|
1081
|
+
const params = {};
|
|
1082
|
+
if (opts.domain)
|
|
1083
|
+
params.domain = opts.domain;
|
|
1084
|
+
printResult(await client.listDns(params), getFormat(parent));
|
|
1085
|
+
});
|
|
1086
|
+
dns.command("add").description("DNS\u30EC\u30B3\u30FC\u30C9\u3092\u65B0\u898F\u8FFD\u52A0").requiredOption("--domain <domain>", "\u5BFE\u8C61\u30C9\u30E1\u30A4\u30F3").requiredOption("--host <host>", "\u30DB\u30B9\u30C8\u540D\uFF08@\u3067apex\uFF09").requiredOption("--type <type>", "\u30EC\u30B3\u30FC\u30C9\u30BF\u30A4\u30D7\uFF08A / AAAA / CNAME / MX / TXT / SRV / CAA\uFF09").requiredOption("--content <content>", "\u30EC\u30B3\u30FC\u30C9\u5024").option("--ttl <ttl>", "TTL\uFF0860-86400\u3002\u30C7\u30D5\u30A9\u30EB\u30C8: 3600\uFF09").option("--priority <priority>", "\u512A\u5148\u5EA6\uFF08MX/SRV\u30EC\u30B3\u30FC\u30C9\u7528\uFF09").action(async (opts) => {
|
|
1087
|
+
const client = resolveClient(parent, brand);
|
|
1088
|
+
printResult(await client.addDns(pickDefined({
|
|
1089
|
+
domain: opts.domain,
|
|
1090
|
+
host: opts.host,
|
|
1091
|
+
type: opts.type,
|
|
1092
|
+
content: opts.content,
|
|
1093
|
+
ttl: opts.ttl !== void 0 ? parseInt(opts.ttl, 10) : void 0,
|
|
1094
|
+
priority: opts.priority !== void 0 ? parseInt(opts.priority, 10) : void 0
|
|
1095
|
+
})), getFormat(parent));
|
|
1096
|
+
});
|
|
1097
|
+
dns.command("update <dnsId>").description("DNS\u30EC\u30B3\u30FC\u30C9\u3092\u66F4\u65B0").option("--domain <domain>", "\u30C9\u30E1\u30A4\u30F3").option("--host <host>", "\u30DB\u30B9\u30C8\u540D").option("--type <type>", "\u30EC\u30B3\u30FC\u30C9\u30BF\u30A4\u30D7").option("--content <content>", "\u30EC\u30B3\u30FC\u30C9\u5024").option("--ttl <ttl>", "TTL\uFF0860-86400\uFF09").option("--priority <priority>", "\u512A\u5148\u5EA6").action(async (dnsId, opts) => {
|
|
1098
|
+
const client = resolveClient(parent, brand);
|
|
1099
|
+
printResult(await client.updateDns(dnsId, pickDefined({
|
|
1100
|
+
domain: opts.domain,
|
|
1101
|
+
host: opts.host,
|
|
1102
|
+
type: opts.type,
|
|
1103
|
+
content: opts.content,
|
|
1104
|
+
ttl: opts.ttl !== void 0 ? parseInt(opts.ttl, 10) : void 0,
|
|
1105
|
+
priority: opts.priority !== void 0 ? parseInt(opts.priority, 10) : void 0
|
|
1106
|
+
})), getFormat(parent));
|
|
1107
|
+
});
|
|
1108
|
+
dns.command("delete <dnsId>").description("DNS\u30EC\u30B3\u30FC\u30C9\u3092\u524A\u9664").option("-y, --yes", "\u78BA\u8A8D\u30D7\u30ED\u30F3\u30D7\u30C8\u3092\u30B9\u30AD\u30C3\u30D7").action(async (dnsId) => {
|
|
1109
|
+
await confirmDestructiveAction(parent, `DNS\u30EC\u30B3\u30FC\u30C9 "${dnsId}" \u3092\u524A\u9664\u3057\u307E\u3059\u3002\u3088\u308D\u3057\u3044\u3067\u3059\u304B\uFF1F`);
|
|
1110
|
+
const client = resolveClient(parent, brand);
|
|
1111
|
+
printResult(await client.deleteDns(dnsId), getFormat(parent));
|
|
1112
|
+
});
|
|
1113
|
+
}
|
|
1114
|
+
|
|
1115
|
+
// ../core/dist/commands/server/ssh/index.js
|
|
1116
|
+
function registerSshCommands(parent, brand) {
|
|
1117
|
+
const ssh = parent.command("ssh").description("SSH\u8A2D\u5B9A");
|
|
1118
|
+
ssh.command("show").description("SSH\u8A2D\u5B9A\u3092\u53D6\u5F97").action(async () => {
|
|
1119
|
+
const client = resolveClient(parent, brand);
|
|
1120
|
+
printResult(await client.getSsh(), getFormat(parent));
|
|
1121
|
+
});
|
|
1122
|
+
ssh.command("update").description("SSH\u8A2D\u5B9A\u3092\u5909\u66F4").option("--ssh-enabled <value>", "SSH\u63A5\u7D9A\u306E\u6709\u52B9/\u7121\u52B9\uFF08true/false\uFF09").option("--abroad-access-restriction <value>", "\u56FD\u5916\u30A2\u30AF\u30BB\u30B9\u5236\u9650\u306E\u6709\u52B9/\u7121\u52B9\uFF08true/false\uFF09").action(async (opts) => {
|
|
1123
|
+
const client = resolveClient(parent, brand);
|
|
1124
|
+
const data = {};
|
|
1125
|
+
if (opts.sshEnabled !== void 0)
|
|
1126
|
+
data.ssh_enabled = opts.sshEnabled === "true";
|
|
1127
|
+
if (opts.abroadAccessRestriction !== void 0)
|
|
1128
|
+
data.abroad_access_restriction = opts.abroadAccessRestriction === "true";
|
|
1129
|
+
printResult(await client.updateSsh(data), getFormat(parent));
|
|
1130
|
+
});
|
|
1131
|
+
const key = ssh.command("key").description("SSH\u516C\u958B\u9375\u7BA1\u7406");
|
|
1132
|
+
key.command("list").description("SSH\u516C\u958B\u9375\u4E00\u89A7\u3092\u53D6\u5F97").action(async () => {
|
|
1133
|
+
const client = resolveClient(parent, brand);
|
|
1134
|
+
printResult(await client.listSshKey(), getFormat(parent));
|
|
1135
|
+
});
|
|
1136
|
+
key.command("add").description("SSH\u516C\u958B\u9375\u3092\u767B\u9332").option("--public-key <key>", "\u516C\u958B\u9375\uFF08\u624B\u52D5\u767B\u9332\u6642\uFF09").option("--generate", "\u30B5\u30FC\u30D0\u30FC\u5074\u3067\u9375\u30DA\u30A2\u3092\u81EA\u52D5\u751F\u6210").option("--passphrase <value>", "\u30D1\u30B9\u30D5\u30EC\u30FC\u30BA\uFF08\u81EA\u52D5\u751F\u6210\u6642\uFF09").requiredOption("--label <value>", "\u30E9\u30D9\u30EB").action(async (opts) => {
|
|
1137
|
+
const client = resolveClient(parent, brand);
|
|
1138
|
+
const data = { label: opts.label };
|
|
1139
|
+
if (opts.generate) {
|
|
1140
|
+
data.generate = true;
|
|
1141
|
+
if (opts.passphrase !== void 0)
|
|
1142
|
+
data.passphrase = opts.passphrase;
|
|
1143
|
+
} else {
|
|
1144
|
+
if (opts.publicKey)
|
|
1145
|
+
data.public_key = opts.publicKey;
|
|
1146
|
+
}
|
|
1147
|
+
printResult(await client.addSshKey(data), getFormat(parent));
|
|
1148
|
+
});
|
|
1149
|
+
key.command("update <keyId>").description("SSH\u516C\u958B\u9375\u3092\u66F4\u65B0").option("--label <value>", "\u30E9\u30D9\u30EB").option("--status <value>", "\u30B9\u30C6\u30FC\u30BF\u30B9\uFF08on/off\uFF09").action(async (keyId, opts) => {
|
|
1150
|
+
const client = resolveClient(parent, brand);
|
|
1151
|
+
printResult(await client.updateSshKey(keyId, pickDefined({
|
|
1152
|
+
label: opts.label,
|
|
1153
|
+
status: opts.status
|
|
1154
|
+
})), getFormat(parent));
|
|
1155
|
+
});
|
|
1156
|
+
key.command("delete <keyId>").description("SSH\u516C\u958B\u9375\u3092\u524A\u9664").option("-y, --yes", "\u78BA\u8A8D\u30D7\u30ED\u30F3\u30D7\u30C8\u3092\u30B9\u30AD\u30C3\u30D7").action(async (keyId) => {
|
|
1157
|
+
await confirmDestructiveAction(parent, `SSH\u516C\u958B\u9375 "${keyId}" \u3092\u524A\u9664\u3057\u307E\u3059\u3002\u3088\u308D\u3057\u3044\u3067\u3059\u304B\uFF1F`);
|
|
1158
|
+
const client = resolveClient(parent, brand);
|
|
1159
|
+
printResult(await client.deleteSshKey(keyId), getFormat(parent));
|
|
1160
|
+
});
|
|
1161
|
+
}
|
|
1162
|
+
|
|
1163
|
+
// ../core/dist/commands/server/log/index.js
|
|
1164
|
+
function registerLogCommands(parent, brand) {
|
|
1165
|
+
const log = parent.command("log").description("\u30ED\u30B0");
|
|
1166
|
+
log.command("access").description("\u30A2\u30AF\u30BB\u30B9\u30ED\u30B0\u3092\u53D6\u5F97").requiredOption("--domain <domain>", "\u5BFE\u8C61\u30C9\u30E1\u30A4\u30F3").option("--lines <n>", "\u53D6\u5F97\u884C\u6570").option("--keyword <keyword>", "\u30AD\u30FC\u30EF\u30FC\u30C9\u691C\u7D22").action(async (opts) => {
|
|
1167
|
+
const client = resolveClient(parent, brand);
|
|
1168
|
+
const params = { domain: opts.domain };
|
|
1169
|
+
if (opts.lines)
|
|
1170
|
+
params.lines = opts.lines;
|
|
1171
|
+
if (opts.keyword)
|
|
1172
|
+
params.keyword = opts.keyword;
|
|
1173
|
+
printResult(await client.getAccessLog(params), getFormat(parent));
|
|
1174
|
+
});
|
|
1175
|
+
log.command("error").description("\u30A8\u30E9\u30FC\u30ED\u30B0\u3092\u53D6\u5F97").requiredOption("--domain <domain>", "\u5BFE\u8C61\u30C9\u30E1\u30A4\u30F3").option("--lines <n>", "\u53D6\u5F97\u884C\u6570").option("--keyword <keyword>", "\u30AD\u30FC\u30EF\u30FC\u30C9\u691C\u7D22").action(async (opts) => {
|
|
1176
|
+
const client = resolveClient(parent, brand);
|
|
1177
|
+
const params = { domain: opts.domain };
|
|
1178
|
+
if (opts.lines)
|
|
1179
|
+
params.lines = opts.lines;
|
|
1180
|
+
if (opts.keyword)
|
|
1181
|
+
params.keyword = opts.keyword;
|
|
1182
|
+
printResult(await client.getErrorLog(params), getFormat(parent));
|
|
1183
|
+
});
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1186
|
+
// ../core/dist/commands/me/index.js
|
|
1187
|
+
function registerMeCommand(program, brand) {
|
|
1188
|
+
program.command("me").description("\u73FE\u5728\u306EAPI\u30AD\u30FC\u60C5\u5831\u3092\u8868\u793A").action(async (_opts, cmd) => {
|
|
1189
|
+
const root = cmd.parent;
|
|
1190
|
+
const rootOpts = root.opts();
|
|
1191
|
+
const profile = getActiveProfile(brand, rootOpts.profile);
|
|
1192
|
+
if (!profile) {
|
|
1193
|
+
console.error(`\u8A8D\u8A3C\u8A2D\u5B9A\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3002\`${brand.commandName} auth login\` \u3092\u5B9F\u884C\u3057\u3066\u304F\u3060\u3055\u3044\u3002`);
|
|
1194
|
+
process.exit(1);
|
|
1195
|
+
}
|
|
1196
|
+
const debug = !!(rootOpts.debug || process.env.XSERVER_DEBUG === "1");
|
|
1197
|
+
const client = new ApiClient({
|
|
1198
|
+
apiKey: profile.apiKey,
|
|
1199
|
+
apiBase: brand.apiBase,
|
|
1200
|
+
servername: profile.servername,
|
|
1201
|
+
debug
|
|
1202
|
+
});
|
|
1203
|
+
printResult(await client.getMe(), getFormat(cmd));
|
|
1204
|
+
});
|
|
1205
|
+
}
|
|
1206
|
+
|
|
1207
|
+
// ../core/dist/index.js
|
|
1208
|
+
function run(brand, version = "0.0.0") {
|
|
1209
|
+
const program = new Command();
|
|
1210
|
+
program.name(brand.commandName).description(`${brand.displayName} CLI`).version(version).option("--format <format>", "\u51FA\u529B\u5F62\u5F0F (json, table)", (value) => {
|
|
1211
|
+
if (!["json", "table"].includes(value)) {
|
|
1212
|
+
throw new Error(`--format \u306F json \u307E\u305F\u306F table \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u5165\u529B\u5024: ${value}\uFF09`);
|
|
1213
|
+
}
|
|
1214
|
+
return value;
|
|
1215
|
+
}, "table").option("--profile <name>", "\u4F7F\u7528\u3059\u308B\u30D7\u30ED\u30D5\u30A1\u30A4\u30EB").option("-y, --yes", "\u78BA\u8A8D\u30D7\u30ED\u30F3\u30D7\u30C8\u3092\u30B9\u30AD\u30C3\u30D7").option("--debug", "\u30C7\u30D0\u30C3\u30B0\u51FA\u529B\u3092\u6709\u52B9\u5316\uFF08\u30EA\u30AF\u30A8\u30B9\u30C8URL\u30FB\u30EC\u30B9\u30DD\u30F3\u30B9\u30D8\u30C3\u30C0\u3092\u8868\u793A\uFF09");
|
|
1216
|
+
registerAuthCommands(program, brand);
|
|
1217
|
+
registerMeCommand(program, brand);
|
|
1218
|
+
const server = program.command("server").description("\u30B5\u30FC\u30D0\u30FC\u7BA1\u7406API\uFF08WordPress\u30FB\u30E1\u30FC\u30EB\u30FBDB\u306A\u3069\uFF09").option("--servername <name>", "\u30B5\u30FC\u30D0\u30FC\u540D\uFF08\u30D7\u30ED\u30D5\u30A1\u30A4\u30EB\u306E\u30C7\u30D5\u30A9\u30EB\u30C8\u3092\u4E0A\u66F8\u304D\uFF09");
|
|
1219
|
+
registerServerInfoCommands(server, brand);
|
|
1220
|
+
registerCronCommands(server, brand);
|
|
1221
|
+
registerSshCommands(server, brand);
|
|
1222
|
+
registerWpCommands(server, brand);
|
|
1223
|
+
registerMailCommands(server, brand);
|
|
1224
|
+
registerMailFilterCommands(server, brand);
|
|
1225
|
+
registerFtpCommands(server, brand);
|
|
1226
|
+
registerDbCommands(server, brand);
|
|
1227
|
+
registerPhpVersionCommands(server, brand);
|
|
1228
|
+
registerServerDomainCommands(server, brand);
|
|
1229
|
+
registerSubdomainCommands(server, brand);
|
|
1230
|
+
registerSslCommands(server, brand);
|
|
1231
|
+
registerDnsCommands(server, brand);
|
|
1232
|
+
registerLogCommands(server, brand);
|
|
1233
|
+
program.parseAsync(process.argv).catch((err) => {
|
|
1234
|
+
if (err instanceof ApiError) {
|
|
1235
|
+
console.error(`\u30A8\u30E9\u30FC [${err.errorCode}]: ${err.message}`);
|
|
1236
|
+
if (err.errors.length > 0) {
|
|
1237
|
+
for (const e of err.errors) {
|
|
1238
|
+
console.error(` - ${e}`);
|
|
1239
|
+
}
|
|
1240
|
+
}
|
|
1241
|
+
process.exit(1);
|
|
1242
|
+
}
|
|
1243
|
+
if (err instanceof Error) {
|
|
1244
|
+
console.error(`\u30A8\u30E9\u30FC: ${err.message}`);
|
|
1245
|
+
process.exit(1);
|
|
1246
|
+
}
|
|
1247
|
+
console.error("\u4E88\u671F\u3057\u306A\u3044\u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F");
|
|
1248
|
+
process.exit(1);
|
|
1249
|
+
});
|
|
1250
|
+
}
|
|
1251
|
+
|
|
1252
|
+
// package.json
|
|
1253
|
+
var package_default = {
|
|
1254
|
+
name: "xserver-cli",
|
|
1255
|
+
version: "1.0.2",
|
|
1256
|
+
description: "Official CLI for XServer API \u2014 manage your XServer hosting from the terminal",
|
|
1257
|
+
type: "module",
|
|
1258
|
+
bin: {
|
|
1259
|
+
xserver: "./dist/index.js"
|
|
1260
|
+
},
|
|
1261
|
+
files: [
|
|
1262
|
+
"dist"
|
|
1263
|
+
],
|
|
1264
|
+
scripts: {
|
|
1265
|
+
build: "tsup",
|
|
1266
|
+
dev: "tsup --watch",
|
|
1267
|
+
tsc: "tsc --noEmit",
|
|
1268
|
+
prepublishOnly: "tsup"
|
|
1269
|
+
},
|
|
1270
|
+
keywords: [
|
|
1271
|
+
"xserver",
|
|
1272
|
+
"cli",
|
|
1273
|
+
"api",
|
|
1274
|
+
"hosting",
|
|
1275
|
+
"server",
|
|
1276
|
+
"webhosting"
|
|
1277
|
+
],
|
|
1278
|
+
author: "Xserver Inc.",
|
|
1279
|
+
license: "MIT",
|
|
1280
|
+
homepage: "https://developer.xserver.ne.jp",
|
|
1281
|
+
publishConfig: {
|
|
1282
|
+
access: "public"
|
|
1283
|
+
},
|
|
1284
|
+
dependencies: {
|
|
1285
|
+
"@inquirer/prompts": "^7.10.1",
|
|
1286
|
+
commander: "^13.0.0"
|
|
1287
|
+
},
|
|
1288
|
+
devDependencies: {
|
|
1289
|
+
"xnp-cli-core": "*",
|
|
1290
|
+
"xnp-shared": "*"
|
|
1291
|
+
},
|
|
1292
|
+
engines: {
|
|
1293
|
+
node: ">=18.0.0"
|
|
1294
|
+
}
|
|
1295
|
+
};
|
|
1296
|
+
|
|
1297
|
+
// src/index.ts
|
|
1298
|
+
run({
|
|
1299
|
+
brand: "xserver",
|
|
1300
|
+
apiBase: "https://api.xserver.ne.jp",
|
|
1301
|
+
displayName: "XServer API",
|
|
1302
|
+
commandName: "xserver",
|
|
1303
|
+
configDir: "xserver-cli"
|
|
1304
|
+
}, package_default.version);
|
|
1305
|
+
//# sourceMappingURL=index.js.map
|