xserver-cli 1.0.1 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -22
- package/dist/index.js +1583 -0
- package/dist/index.js.map +1 -0
- package/package.json +41 -18
- package/index.js +0 -47
package/dist/index.js
ADDED
|
@@ -0,0 +1,1583 @@
|
|
|
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
|
+
// 迷惑メールフィルタ設定
|
|
115
|
+
// ================================================================
|
|
116
|
+
async listSpamFilter(params) {
|
|
117
|
+
return this.get(`${this.serverPath()}/spam-filter`, params);
|
|
118
|
+
}
|
|
119
|
+
async updateSpamFilter(domain, data) {
|
|
120
|
+
return this.put(`${this.serverPath()}/spam-filter/${enc(domain)}`, data);
|
|
121
|
+
}
|
|
122
|
+
async updateSpamFilterDmarcReceiver(domain, data) {
|
|
123
|
+
return this.put(`${this.serverPath()}/spam-filter/${enc(domain)}/dmarc-receiver`, data);
|
|
124
|
+
}
|
|
125
|
+
// ================================================================
|
|
126
|
+
// 自動応答設定
|
|
127
|
+
// ================================================================
|
|
128
|
+
async listAutoReply(params) {
|
|
129
|
+
return this.get(`${this.serverPath()}/auto-reply`, params);
|
|
130
|
+
}
|
|
131
|
+
async getAutoReply(mailAddress) {
|
|
132
|
+
return this.get(`${this.serverPath()}/auto-reply/${enc(mailAddress)}`);
|
|
133
|
+
}
|
|
134
|
+
async addAutoReply(data) {
|
|
135
|
+
return this.post(`${this.serverPath()}/auto-reply`, data);
|
|
136
|
+
}
|
|
137
|
+
async updateAutoReply(mailAddress, data) {
|
|
138
|
+
return this.put(`${this.serverPath()}/auto-reply/${enc(mailAddress)}`, data);
|
|
139
|
+
}
|
|
140
|
+
async deleteAutoReply(mailAddress) {
|
|
141
|
+
return this.delete(`${this.serverPath()}/auto-reply/${enc(mailAddress)}`);
|
|
142
|
+
}
|
|
143
|
+
// ================================================================
|
|
144
|
+
// SMTP認証国外アクセス制限
|
|
145
|
+
// ================================================================
|
|
146
|
+
async listSmtpAbroadRestriction(params) {
|
|
147
|
+
return this.get(`${this.serverPath()}/smtp-abroad-restriction`, params);
|
|
148
|
+
}
|
|
149
|
+
async updateSmtpAbroadRestriction(domain, data) {
|
|
150
|
+
return this.put(`${this.serverPath()}/smtp-abroad-restriction/${enc(domain)}`, data);
|
|
151
|
+
}
|
|
152
|
+
// ================================================================
|
|
153
|
+
// DKIM設定
|
|
154
|
+
// ================================================================
|
|
155
|
+
async listDkim(params) {
|
|
156
|
+
return this.get(`${this.serverPath()}/dkim`, params);
|
|
157
|
+
}
|
|
158
|
+
async getDkim(fqdn) {
|
|
159
|
+
return this.get(`${this.serverPath()}/dkim/${enc(fqdn)}`);
|
|
160
|
+
}
|
|
161
|
+
async updateDkim(fqdn, data) {
|
|
162
|
+
return this.put(`${this.serverPath()}/dkim/${enc(fqdn)}`, data);
|
|
163
|
+
}
|
|
164
|
+
// ================================================================
|
|
165
|
+
// SPF設定
|
|
166
|
+
// ================================================================
|
|
167
|
+
async listSpf(params) {
|
|
168
|
+
return this.get(`${this.serverPath()}/spf`, params);
|
|
169
|
+
}
|
|
170
|
+
async addSpf(data) {
|
|
171
|
+
return this.post(`${this.serverPath()}/spf`, data);
|
|
172
|
+
}
|
|
173
|
+
async updateSpf(fqdn, data) {
|
|
174
|
+
return this.put(`${this.serverPath()}/spf/${enc(fqdn)}`, data);
|
|
175
|
+
}
|
|
176
|
+
async deleteSpf(fqdn) {
|
|
177
|
+
return this.delete(`${this.serverPath()}/spf/${enc(fqdn)}`);
|
|
178
|
+
}
|
|
179
|
+
// ================================================================
|
|
180
|
+
// DMARC設定(送信側)
|
|
181
|
+
// ================================================================
|
|
182
|
+
async listDmarc(params) {
|
|
183
|
+
return this.get(`${this.serverPath()}/dmarc`, params);
|
|
184
|
+
}
|
|
185
|
+
async updateDmarc(domain, data) {
|
|
186
|
+
return this.put(`${this.serverPath()}/dmarc/${enc(domain)}`, data);
|
|
187
|
+
}
|
|
188
|
+
// ================================================================
|
|
189
|
+
// FTP
|
|
190
|
+
// ================================================================
|
|
191
|
+
async listFtp(params) {
|
|
192
|
+
return this.get(`${this.serverPath()}/ftp`, params);
|
|
193
|
+
}
|
|
194
|
+
async addFtp(data) {
|
|
195
|
+
return this.post(`${this.serverPath()}/ftp`, data);
|
|
196
|
+
}
|
|
197
|
+
async updateFtp(ftpAccount, data) {
|
|
198
|
+
return this.put(`${this.serverPath()}/ftp/${enc(ftpAccount)}`, data);
|
|
199
|
+
}
|
|
200
|
+
async deleteFtp(ftpAccount) {
|
|
201
|
+
return this.delete(`${this.serverPath()}/ftp/${enc(ftpAccount)}`);
|
|
202
|
+
}
|
|
203
|
+
// ================================================================
|
|
204
|
+
// MySQL
|
|
205
|
+
// ================================================================
|
|
206
|
+
async listDb() {
|
|
207
|
+
return this.get(`${this.serverPath()}/db`);
|
|
208
|
+
}
|
|
209
|
+
async addDb(data) {
|
|
210
|
+
return this.post(`${this.serverPath()}/db`, data);
|
|
211
|
+
}
|
|
212
|
+
async updateDb(dbName, data) {
|
|
213
|
+
return this.put(`${this.serverPath()}/db/${enc(dbName)}`, data);
|
|
214
|
+
}
|
|
215
|
+
async deleteDb(dbName) {
|
|
216
|
+
return this.delete(`${this.serverPath()}/db/${enc(dbName)}`);
|
|
217
|
+
}
|
|
218
|
+
async listDbUser() {
|
|
219
|
+
return this.get(`${this.serverPath()}/db/user`);
|
|
220
|
+
}
|
|
221
|
+
async addDbUser(data) {
|
|
222
|
+
return this.post(`${this.serverPath()}/db/user`, data);
|
|
223
|
+
}
|
|
224
|
+
async updateDbUser(dbUser, data) {
|
|
225
|
+
return this.put(`${this.serverPath()}/db/user/${enc(dbUser)}`, data);
|
|
226
|
+
}
|
|
227
|
+
async deleteDbUser(dbUser) {
|
|
228
|
+
return this.delete(`${this.serverPath()}/db/user/${enc(dbUser)}`);
|
|
229
|
+
}
|
|
230
|
+
async listDbUserGrant(dbUser) {
|
|
231
|
+
return this.get(`${this.serverPath()}/db/user/${enc(dbUser)}/grant`);
|
|
232
|
+
}
|
|
233
|
+
async addDbUserGrant(dbUser, data) {
|
|
234
|
+
return this.post(`${this.serverPath()}/db/user/${enc(dbUser)}/grant`, data);
|
|
235
|
+
}
|
|
236
|
+
async deleteDbUserGrant(dbUser, data) {
|
|
237
|
+
return this.delete(`${this.serverPath()}/db/user/${enc(dbUser)}/grant`, data);
|
|
238
|
+
}
|
|
239
|
+
// ================================================================
|
|
240
|
+
// PHP バージョン
|
|
241
|
+
// ================================================================
|
|
242
|
+
async getPhpVersion(params) {
|
|
243
|
+
return this.get(`${this.serverPath()}/php-version`, params);
|
|
244
|
+
}
|
|
245
|
+
async updatePhpVersion(domain, data) {
|
|
246
|
+
return this.put(`${this.serverPath()}/php-version/${enc(domain)}`, data);
|
|
247
|
+
}
|
|
248
|
+
// ================================================================
|
|
249
|
+
// ドメイン(サーバーパネル)
|
|
250
|
+
// ================================================================
|
|
251
|
+
async listDomain() {
|
|
252
|
+
return this.get(`${this.serverPath()}/domain`);
|
|
253
|
+
}
|
|
254
|
+
async getDomain(domain) {
|
|
255
|
+
return this.get(`${this.serverPath()}/domain/${enc(domain)}`);
|
|
256
|
+
}
|
|
257
|
+
async addDomain(data) {
|
|
258
|
+
return this.post(`${this.serverPath()}/domain`, data);
|
|
259
|
+
}
|
|
260
|
+
async updateDomain(domain, data) {
|
|
261
|
+
return this.put(`${this.serverPath()}/domain/${enc(domain)}`, data);
|
|
262
|
+
}
|
|
263
|
+
async deleteDomain(domain, data) {
|
|
264
|
+
return this.delete(`${this.serverPath()}/domain/${enc(domain)}`, data);
|
|
265
|
+
}
|
|
266
|
+
async resetDomain(domain, data) {
|
|
267
|
+
return this.post(`${this.serverPath()}/domain/${enc(domain)}/reset`, data);
|
|
268
|
+
}
|
|
269
|
+
// ================================================================
|
|
270
|
+
// サブドメイン
|
|
271
|
+
// ================================================================
|
|
272
|
+
async listSubdomain(params) {
|
|
273
|
+
return this.get(`${this.serverPath()}/subdomain`, params);
|
|
274
|
+
}
|
|
275
|
+
async addSubdomain(data) {
|
|
276
|
+
return this.post(`${this.serverPath()}/subdomain`, data);
|
|
277
|
+
}
|
|
278
|
+
async updateSubdomain(subdomain, data) {
|
|
279
|
+
return this.put(`${this.serverPath()}/subdomain/${enc(subdomain)}`, data);
|
|
280
|
+
}
|
|
281
|
+
async deleteSubdomain(subdomain, data) {
|
|
282
|
+
return this.delete(`${this.serverPath()}/subdomain/${enc(subdomain)}`, data);
|
|
283
|
+
}
|
|
284
|
+
// ================================================================
|
|
285
|
+
// SSL
|
|
286
|
+
// ================================================================
|
|
287
|
+
async listSsl(params) {
|
|
288
|
+
return this.get(`${this.serverPath()}/ssl`, params);
|
|
289
|
+
}
|
|
290
|
+
async installSsl(data) {
|
|
291
|
+
return this.post(`${this.serverPath()}/ssl`, data);
|
|
292
|
+
}
|
|
293
|
+
async uninstallSsl(commonName) {
|
|
294
|
+
return this.delete(`${this.serverPath()}/ssl/${enc(commonName)}`);
|
|
295
|
+
}
|
|
296
|
+
// ================================================================
|
|
297
|
+
// DNS(サーバーパネル)
|
|
298
|
+
// ================================================================
|
|
299
|
+
async listDns(params) {
|
|
300
|
+
return this.get(`${this.serverPath()}/dns`, params);
|
|
301
|
+
}
|
|
302
|
+
async addDns(data) {
|
|
303
|
+
return this.post(`${this.serverPath()}/dns`, data);
|
|
304
|
+
}
|
|
305
|
+
async updateDns(dnsId, data) {
|
|
306
|
+
return this.put(`${this.serverPath()}/dns/${enc(dnsId)}`, data);
|
|
307
|
+
}
|
|
308
|
+
async deleteDns(dnsId, data) {
|
|
309
|
+
return this.delete(`${this.serverPath()}/dns/${enc(dnsId)}`, data);
|
|
310
|
+
}
|
|
311
|
+
// ================================================================
|
|
312
|
+
// SSH
|
|
313
|
+
// ================================================================
|
|
314
|
+
async getSsh() {
|
|
315
|
+
return this.get(`${this.serverPath()}/ssh`);
|
|
316
|
+
}
|
|
317
|
+
async updateSsh(data) {
|
|
318
|
+
return this.put(`${this.serverPath()}/ssh`, data);
|
|
319
|
+
}
|
|
320
|
+
async listSshKey() {
|
|
321
|
+
return this.get(`${this.serverPath()}/ssh/key`);
|
|
322
|
+
}
|
|
323
|
+
async addSshKey(data) {
|
|
324
|
+
return this.post(`${this.serverPath()}/ssh/key`, data);
|
|
325
|
+
}
|
|
326
|
+
async updateSshKey(keyId, data) {
|
|
327
|
+
return this.put(`${this.serverPath()}/ssh/key/${enc(keyId)}`, data);
|
|
328
|
+
}
|
|
329
|
+
async deleteSshKey(keyId) {
|
|
330
|
+
return this.delete(`${this.serverPath()}/ssh/key/${enc(keyId)}`);
|
|
331
|
+
}
|
|
332
|
+
// ================================================================
|
|
333
|
+
// ログ
|
|
334
|
+
// ================================================================
|
|
335
|
+
async getAccessLog(params) {
|
|
336
|
+
return this.get(`${this.serverPath()}/access-log`, params);
|
|
337
|
+
}
|
|
338
|
+
async getErrorLog(params) {
|
|
339
|
+
return this.get(`${this.serverPath()}/error-log`, params);
|
|
340
|
+
}
|
|
341
|
+
// ================================================================
|
|
342
|
+
// APIキー情報
|
|
343
|
+
// ================================================================
|
|
344
|
+
async getMe() {
|
|
345
|
+
return this.get("/v1/me");
|
|
346
|
+
}
|
|
347
|
+
// ================================================================
|
|
348
|
+
// HTTP 基盤
|
|
349
|
+
// ================================================================
|
|
350
|
+
async get(path2, params) {
|
|
351
|
+
let url = `${this.apiBase}${path2}`;
|
|
352
|
+
if (params && Object.keys(params).length > 0) {
|
|
353
|
+
url += "?" + new URLSearchParams(params).toString();
|
|
354
|
+
}
|
|
355
|
+
return this.request("GET", url);
|
|
356
|
+
}
|
|
357
|
+
async post(path2, data) {
|
|
358
|
+
return this.request("POST", `${this.apiBase}${path2}`, data);
|
|
359
|
+
}
|
|
360
|
+
async put(path2, data) {
|
|
361
|
+
return this.request("PUT", `${this.apiBase}${path2}`, data);
|
|
362
|
+
}
|
|
363
|
+
async delete(path2, data) {
|
|
364
|
+
return this.request("DELETE", `${this.apiBase}${path2}`, data);
|
|
365
|
+
}
|
|
366
|
+
async request(method, url, body) {
|
|
367
|
+
const headers = {
|
|
368
|
+
"Authorization": `Bearer ${this.apiKey}`,
|
|
369
|
+
"Accept": "application/json"
|
|
370
|
+
};
|
|
371
|
+
const init = {
|
|
372
|
+
method,
|
|
373
|
+
headers,
|
|
374
|
+
signal: AbortSignal.timeout(DEFAULT_TIMEOUT_MS)
|
|
375
|
+
};
|
|
376
|
+
if (body && method !== "GET") {
|
|
377
|
+
headers["Content-Type"] = "application/json";
|
|
378
|
+
init.body = JSON.stringify(body);
|
|
379
|
+
}
|
|
380
|
+
if (this.debug) {
|
|
381
|
+
const dbg = (msg) => process.stderr.write(`[DEBUG] ${msg}
|
|
382
|
+
`);
|
|
383
|
+
dbg(`${method} ${url}`);
|
|
384
|
+
if (init.body)
|
|
385
|
+
dbg(`Body: ${init.body}`);
|
|
386
|
+
}
|
|
387
|
+
let response;
|
|
388
|
+
try {
|
|
389
|
+
response = await fetch(url, init);
|
|
390
|
+
} catch (err) {
|
|
391
|
+
throw new Error(`\u901A\u4FE1\u30A8\u30E9\u30FC: ${err instanceof Error ? err.message : String(err)}`);
|
|
392
|
+
}
|
|
393
|
+
if (this.debug) {
|
|
394
|
+
const dbg = (msg) => process.stderr.write(`[DEBUG] ${msg}
|
|
395
|
+
`);
|
|
396
|
+
dbg(`HTTP ${response.status} ${response.statusText}`);
|
|
397
|
+
const debugHeaders = ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-concurrent-limit", "x-concurrent-remaining", "content-type"];
|
|
398
|
+
for (const h of debugHeaders) {
|
|
399
|
+
const v = response.headers.get(h);
|
|
400
|
+
if (v !== null)
|
|
401
|
+
dbg(` ${h}: ${v}`);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
const rateLimitHeader = response.headers.get("x-ratelimit-limit");
|
|
405
|
+
if (rateLimitHeader) {
|
|
406
|
+
this.lastRateLimit = {
|
|
407
|
+
limit: parseInt(rateLimitHeader, 10),
|
|
408
|
+
remaining: parseInt(response.headers.get("x-ratelimit-remaining") || "0", 10),
|
|
409
|
+
reset: parseInt(response.headers.get("x-ratelimit-reset") || "0", 10)
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
const text = await response.text();
|
|
413
|
+
let data;
|
|
414
|
+
try {
|
|
415
|
+
data = JSON.parse(text);
|
|
416
|
+
} catch {
|
|
417
|
+
if (this.debug) {
|
|
418
|
+
process.stderr.write(`[DEBUG] Raw response: ${text.substring(0, 500)}
|
|
419
|
+
`);
|
|
420
|
+
}
|
|
421
|
+
throw new ApiError(`Response parse error (HTTP ${response.status})`, response.status, "PARSE_ERROR", []);
|
|
422
|
+
}
|
|
423
|
+
if (!response.ok) {
|
|
424
|
+
const err = data;
|
|
425
|
+
const errorCode = err?.error?.code || "UNKNOWN_ERROR";
|
|
426
|
+
const errorMessage = err?.error?.message || "\u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F";
|
|
427
|
+
const errors = err?.error?.errors || [];
|
|
428
|
+
throw new ApiError(errorMessage, response.status, errorCode, errors);
|
|
429
|
+
}
|
|
430
|
+
return data;
|
|
431
|
+
}
|
|
432
|
+
};
|
|
433
|
+
function enc(s) {
|
|
434
|
+
return encodeURIComponent(s);
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
// ../core/dist/commands/auth/login.js
|
|
438
|
+
import { password } from "@inquirer/prompts";
|
|
439
|
+
|
|
440
|
+
// ../core/dist/lib/config.js
|
|
441
|
+
import fs from "fs";
|
|
442
|
+
import path from "path";
|
|
443
|
+
import os from "os";
|
|
444
|
+
function getConfigDir(brand) {
|
|
445
|
+
const home = os.homedir();
|
|
446
|
+
return path.join(home, ".config", brand.configDir);
|
|
447
|
+
}
|
|
448
|
+
function getConfigPath(brand) {
|
|
449
|
+
return path.join(getConfigDir(brand), "config.json");
|
|
450
|
+
}
|
|
451
|
+
function loadConfig(brand) {
|
|
452
|
+
const configPath = getConfigPath(brand);
|
|
453
|
+
if (!fs.existsSync(configPath)) {
|
|
454
|
+
return { defaultProfile: "default", profiles: {} };
|
|
455
|
+
}
|
|
456
|
+
const raw = fs.readFileSync(configPath, "utf-8");
|
|
457
|
+
return JSON.parse(raw);
|
|
458
|
+
}
|
|
459
|
+
function saveConfig(brand, config) {
|
|
460
|
+
const configDir = getConfigDir(brand);
|
|
461
|
+
fs.mkdirSync(configDir, { recursive: true });
|
|
462
|
+
const configPath = getConfigPath(brand);
|
|
463
|
+
fs.writeFileSync(configPath, JSON.stringify(config, null, 2) + "\n", "utf-8");
|
|
464
|
+
}
|
|
465
|
+
function getActiveProfile(brand, profileName) {
|
|
466
|
+
const envPrefix = brand.brand.toUpperCase();
|
|
467
|
+
const envApiKey = process.env[`${envPrefix}_API_KEY`] || process.env["XSERVER_API_KEY"];
|
|
468
|
+
const envServername = process.env[`${envPrefix}_SERVERNAME`] || process.env["XSERVER_SERVERNAME"];
|
|
469
|
+
if (envApiKey) {
|
|
470
|
+
return {
|
|
471
|
+
apiKey: envApiKey,
|
|
472
|
+
servername: envServername
|
|
473
|
+
};
|
|
474
|
+
}
|
|
475
|
+
const config = loadConfig(brand);
|
|
476
|
+
const name = profileName || config.defaultProfile || "default";
|
|
477
|
+
return config.profiles[name] || null;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
// ../core/dist/lib/command-helper.js
|
|
481
|
+
import { confirm } from "@inquirer/prompts";
|
|
482
|
+
|
|
483
|
+
// ../core/dist/lib/output.js
|
|
484
|
+
function formatOutput(data, format) {
|
|
485
|
+
if (format === "json") {
|
|
486
|
+
return JSON.stringify(data, null, 2);
|
|
487
|
+
}
|
|
488
|
+
return formatTable(data);
|
|
489
|
+
}
|
|
490
|
+
function formatTable(data) {
|
|
491
|
+
if (data === null || data === void 0) {
|
|
492
|
+
return "(\u30C7\u30FC\u30BF\u306A\u3057)";
|
|
493
|
+
}
|
|
494
|
+
if (Array.isArray(data)) {
|
|
495
|
+
if (data.length === 0)
|
|
496
|
+
return "(\u30C7\u30FC\u30BF\u306A\u3057)";
|
|
497
|
+
return renderArrayTable(data);
|
|
498
|
+
}
|
|
499
|
+
if (typeof data === "object") {
|
|
500
|
+
const obj = data;
|
|
501
|
+
const arrayEntry = Object.entries(obj).find(([, v]) => Array.isArray(v) && (v.length === 0 || typeof v[0] === "object" && v[0] !== null));
|
|
502
|
+
if (arrayEntry) {
|
|
503
|
+
const scalarEntries = Object.entries(obj).filter(([k]) => k !== arrayEntry[0]);
|
|
504
|
+
const parts = [];
|
|
505
|
+
if (scalarEntries.length > 0) {
|
|
506
|
+
parts.push(renderKeyValueTable(Object.fromEntries(scalarEntries)));
|
|
507
|
+
parts.push("");
|
|
508
|
+
}
|
|
509
|
+
parts.push(renderArrayTable(arrayEntry[1]));
|
|
510
|
+
return parts.join("\n");
|
|
511
|
+
}
|
|
512
|
+
return renderKeyValueTable(obj);
|
|
513
|
+
}
|
|
514
|
+
return String(data);
|
|
515
|
+
}
|
|
516
|
+
function renderKeyValueTable(obj) {
|
|
517
|
+
const entries = Object.entries(obj).map(([key, value]) => ({
|
|
518
|
+
key,
|
|
519
|
+
value: formatValue(value)
|
|
520
|
+
}));
|
|
521
|
+
const maxKeyLen = Math.max(...entries.map((e) => displayWidth(e.key)));
|
|
522
|
+
const lines = entries.map((e) => `${padRight(e.key, maxKeyLen)} ${e.value}`);
|
|
523
|
+
return lines.join("\n");
|
|
524
|
+
}
|
|
525
|
+
function renderArrayTable(items) {
|
|
526
|
+
if (items.length === 0)
|
|
527
|
+
return "(\u30C7\u30FC\u30BF\u306A\u3057)";
|
|
528
|
+
const keys = Object.keys(items[0]);
|
|
529
|
+
const colWidths = keys.map((key) => {
|
|
530
|
+
const headerWidth = displayWidth(key);
|
|
531
|
+
const maxDataWidth = Math.max(...items.map((item) => displayWidth(formatValue(item[key]))));
|
|
532
|
+
return Math.max(headerWidth, maxDataWidth);
|
|
533
|
+
});
|
|
534
|
+
const header = keys.map((key, i) => padRight(key, colWidths[i])).join(" ");
|
|
535
|
+
const separator = colWidths.map((w) => "-".repeat(w)).join(" ");
|
|
536
|
+
const rows = items.map((item) => keys.map((key, i) => padRight(formatValue(item[key]), colWidths[i])).join(" "));
|
|
537
|
+
return [header, separator, ...rows].join("\n");
|
|
538
|
+
}
|
|
539
|
+
function formatValue(value) {
|
|
540
|
+
if (value === null || value === void 0)
|
|
541
|
+
return "-";
|
|
542
|
+
if (typeof value === "object")
|
|
543
|
+
return JSON.stringify(value);
|
|
544
|
+
return String(value);
|
|
545
|
+
}
|
|
546
|
+
function displayWidth(str) {
|
|
547
|
+
let width = 0;
|
|
548
|
+
for (const char of str) {
|
|
549
|
+
const code = char.codePointAt(0);
|
|
550
|
+
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) {
|
|
551
|
+
width += 2;
|
|
552
|
+
} else {
|
|
553
|
+
width += 1;
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
return width;
|
|
557
|
+
}
|
|
558
|
+
function padRight(str, targetWidth) {
|
|
559
|
+
const currentWidth = displayWidth(str);
|
|
560
|
+
const padding = Math.max(0, targetWidth - currentWidth);
|
|
561
|
+
return str + " ".repeat(padding);
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
// ../core/dist/lib/command-helper.js
|
|
565
|
+
function findRoot(cmd) {
|
|
566
|
+
let root = cmd;
|
|
567
|
+
while (root.parent)
|
|
568
|
+
root = root.parent;
|
|
569
|
+
return root;
|
|
570
|
+
}
|
|
571
|
+
function resolveClient(cmd, brand) {
|
|
572
|
+
const root = findRoot(cmd);
|
|
573
|
+
const rootOpts = root.opts();
|
|
574
|
+
const profile = getActiveProfile(brand, rootOpts.profile);
|
|
575
|
+
if (!profile) {
|
|
576
|
+
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`);
|
|
577
|
+
process.exit(1);
|
|
578
|
+
}
|
|
579
|
+
const debug = !!(rootOpts.debug || process.env.XSERVER_DEBUG === "1");
|
|
580
|
+
const servername = resolveServername(cmd) ?? profile.servername;
|
|
581
|
+
return new ApiClient({
|
|
582
|
+
apiKey: profile.apiKey,
|
|
583
|
+
apiBase: brand.apiBase,
|
|
584
|
+
servername,
|
|
585
|
+
debug
|
|
586
|
+
});
|
|
587
|
+
}
|
|
588
|
+
function resolveServername(cmd) {
|
|
589
|
+
let current = cmd;
|
|
590
|
+
while (current) {
|
|
591
|
+
const val = current.opts()?.servername;
|
|
592
|
+
if (val)
|
|
593
|
+
return val;
|
|
594
|
+
current = current.parent;
|
|
595
|
+
}
|
|
596
|
+
return void 0;
|
|
597
|
+
}
|
|
598
|
+
function getFormat(cmd) {
|
|
599
|
+
const root = findRoot(cmd);
|
|
600
|
+
return root.opts().format || "table";
|
|
601
|
+
}
|
|
602
|
+
function printResult(data, format) {
|
|
603
|
+
console.log(formatOutput(data, format));
|
|
604
|
+
}
|
|
605
|
+
async function confirmDestructiveAction(cmd, message) {
|
|
606
|
+
const root = findRoot(cmd);
|
|
607
|
+
if (root.opts().yes || process.argv.includes("--yes") || process.argv.includes("-y"))
|
|
608
|
+
return;
|
|
609
|
+
const ok = await confirm({ message, default: false });
|
|
610
|
+
if (!ok) {
|
|
611
|
+
console.error("\u30AD\u30E3\u30F3\u30BB\u30EB\u3057\u307E\u3057\u305F");
|
|
612
|
+
process.exit(1);
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
function pickDefined(obj) {
|
|
616
|
+
const result = {};
|
|
617
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
618
|
+
if (value !== void 0)
|
|
619
|
+
result[key] = value;
|
|
620
|
+
}
|
|
621
|
+
return result;
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
// ../core/dist/commands/auth/login.js
|
|
625
|
+
function maskApiKey(apiKey) {
|
|
626
|
+
return `${apiKey.substring(0, 8)}...`;
|
|
627
|
+
}
|
|
628
|
+
function registerAuthCommands(program, brand) {
|
|
629
|
+
const auth = program.command("auth").description("\u8A8D\u8A3C\u8A2D\u5B9A");
|
|
630
|
+
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) => {
|
|
631
|
+
const profileName = cmd.optsWithGlobals().profile ?? "default";
|
|
632
|
+
let apiKey = opts.apiKey;
|
|
633
|
+
let servername = opts.servername;
|
|
634
|
+
if (!apiKey) {
|
|
635
|
+
apiKey = await password({ message: "API\u30AD\u30FC\u3092\u5165\u529B:", mask: true });
|
|
636
|
+
}
|
|
637
|
+
if (!apiKey) {
|
|
638
|
+
console.error("\u30A8\u30E9\u30FC: API\u30AD\u30FC\u306F\u5FC5\u9808\u3067\u3059");
|
|
639
|
+
process.exit(1);
|
|
640
|
+
}
|
|
641
|
+
console.error("\u8A8D\u8A3C\u60C5\u5831\u3092\u691C\u8A3C\u4E2D...");
|
|
642
|
+
const client = new ApiClient({ apiKey, apiBase: brand.apiBase });
|
|
643
|
+
let meData;
|
|
644
|
+
try {
|
|
645
|
+
meData = await client.getMe();
|
|
646
|
+
} catch (err) {
|
|
647
|
+
if (err instanceof ApiError && err.errorCode === "UNAUTHORIZED") {
|
|
648
|
+
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");
|
|
649
|
+
process.exit(1);
|
|
650
|
+
}
|
|
651
|
+
throw err;
|
|
652
|
+
}
|
|
653
|
+
console.error("\u2713 \u8A8D\u8A3C\u306B\u6210\u529F\u3057\u307E\u3057\u305F");
|
|
654
|
+
if (!servername && meData.servername) {
|
|
655
|
+
servername = meData.servername;
|
|
656
|
+
console.error(` \u30B5\u30FC\u30D0\u30FC\u540D\u3092\u81EA\u52D5\u691C\u51FA\u3057\u307E\u3057\u305F: ${servername}`);
|
|
657
|
+
}
|
|
658
|
+
const config = loadConfig(brand);
|
|
659
|
+
config.profiles[profileName] = {
|
|
660
|
+
apiKey,
|
|
661
|
+
...servername ? { servername } : {}
|
|
662
|
+
};
|
|
663
|
+
if (!config.defaultProfile) {
|
|
664
|
+
config.defaultProfile = profileName;
|
|
665
|
+
}
|
|
666
|
+
saveConfig(brand, config);
|
|
667
|
+
console.error(`\u2713 \u30D7\u30ED\u30D5\u30A1\u30A4\u30EB "${profileName}" \u3092\u4FDD\u5B58\u3057\u307E\u3057\u305F`);
|
|
668
|
+
console.error(` \u8A2D\u5B9A\u30D5\u30A1\u30A4\u30EB: ~/.config/${brand.configDir}/config.json`);
|
|
669
|
+
});
|
|
670
|
+
auth.command("status").description("\u73FE\u5728\u306E\u8A8D\u8A3C\u72B6\u614B\u3092\u8868\u793A").action((_opts, cmd) => {
|
|
671
|
+
const format = getFormat(cmd);
|
|
672
|
+
const config = loadConfig(brand);
|
|
673
|
+
const profileName = cmd.optsWithGlobals().profile || config.defaultProfile || "default";
|
|
674
|
+
const profile = config.profiles[profileName];
|
|
675
|
+
if (!profile) {
|
|
676
|
+
if (format === "json") {
|
|
677
|
+
printResult({
|
|
678
|
+
authenticated: false,
|
|
679
|
+
profile: profileName,
|
|
680
|
+
message: `\u30D7\u30ED\u30D5\u30A1\u30A4\u30EB "${profileName}" \u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093`
|
|
681
|
+
}, format);
|
|
682
|
+
} else {
|
|
683
|
+
console.error(`\u30D7\u30ED\u30D5\u30A1\u30A4\u30EB "${profileName}" \u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093`);
|
|
684
|
+
console.error(`\`${brand.commandName} auth login\` \u3067\u8A8D\u8A3C\u8A2D\u5B9A\u3092\u884C\u3063\u3066\u304F\u3060\u3055\u3044`);
|
|
685
|
+
}
|
|
686
|
+
process.exit(1);
|
|
687
|
+
}
|
|
688
|
+
if (format === "json") {
|
|
689
|
+
printResult({
|
|
690
|
+
authenticated: true,
|
|
691
|
+
profile: profileName,
|
|
692
|
+
api_key: maskApiKey(profile.apiKey),
|
|
693
|
+
servername: profile.servername ?? null,
|
|
694
|
+
api_base: brand.apiBase
|
|
695
|
+
}, format);
|
|
696
|
+
return;
|
|
697
|
+
}
|
|
698
|
+
console.log(`\u30D7\u30ED\u30D5\u30A1\u30A4\u30EB: ${profileName}`);
|
|
699
|
+
console.log(`API\u30AD\u30FC: ${maskApiKey(profile.apiKey)}`);
|
|
700
|
+
if (profile.servername) {
|
|
701
|
+
console.log(`\u30B5\u30FC\u30D0\u30FC\u540D: ${profile.servername}`);
|
|
702
|
+
}
|
|
703
|
+
console.log(`API\u30A8\u30F3\u30C9\u30DD\u30A4\u30F3\u30C8: ${brand.apiBase}`);
|
|
704
|
+
});
|
|
705
|
+
auth.command("profiles").description("\u30D7\u30ED\u30D5\u30A1\u30A4\u30EB\u4E00\u89A7\u3092\u8868\u793A").action((_opts, cmd) => {
|
|
706
|
+
const format = getFormat(cmd);
|
|
707
|
+
const config = loadConfig(brand);
|
|
708
|
+
const profiles = Object.keys(config.profiles);
|
|
709
|
+
if (profiles.length === 0) {
|
|
710
|
+
if (format === "json") {
|
|
711
|
+
printResult({
|
|
712
|
+
default_profile: config.defaultProfile || null,
|
|
713
|
+
profiles: [],
|
|
714
|
+
message: "\u30D7\u30ED\u30D5\u30A1\u30A4\u30EB\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093"
|
|
715
|
+
}, format);
|
|
716
|
+
} else {
|
|
717
|
+
console.error("\u30D7\u30ED\u30D5\u30A1\u30A4\u30EB\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093");
|
|
718
|
+
console.error(`\`${brand.commandName} auth login\` \u3067\u8A8D\u8A3C\u8A2D\u5B9A\u3092\u884C\u3063\u3066\u304F\u3060\u3055\u3044`);
|
|
719
|
+
}
|
|
720
|
+
process.exit(1);
|
|
721
|
+
}
|
|
722
|
+
const rows = profiles.map((name) => {
|
|
723
|
+
const p = config.profiles[name];
|
|
724
|
+
return {
|
|
725
|
+
name,
|
|
726
|
+
default: name === config.defaultProfile,
|
|
727
|
+
api_key: maskApiKey(p.apiKey),
|
|
728
|
+
servername: p.servername ?? null
|
|
729
|
+
};
|
|
730
|
+
});
|
|
731
|
+
if (format === "json") {
|
|
732
|
+
printResult({
|
|
733
|
+
default_profile: config.defaultProfile || null,
|
|
734
|
+
profiles: rows
|
|
735
|
+
}, format);
|
|
736
|
+
return;
|
|
737
|
+
}
|
|
738
|
+
for (const name of profiles) {
|
|
739
|
+
const marker = name === config.defaultProfile ? " (default)" : "";
|
|
740
|
+
const p = config.profiles[name];
|
|
741
|
+
const key = maskApiKey(p.apiKey);
|
|
742
|
+
const sv = p.servername ? ` servername=${p.servername}` : "";
|
|
743
|
+
console.log(`${name}${marker}: key=${key}${sv}`);
|
|
744
|
+
}
|
|
745
|
+
});
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
// ../core/dist/commands/server/info.js
|
|
749
|
+
function registerServerInfoCommands(parent, brand) {
|
|
750
|
+
parent.command("info").description("\u30B5\u30FC\u30D0\u30FC\u60C5\u5831\u3092\u53D6\u5F97").action(async () => {
|
|
751
|
+
const client = resolveClient(parent, brand);
|
|
752
|
+
printResult(await client.getServerInfo(), getFormat(parent));
|
|
753
|
+
});
|
|
754
|
+
parent.command("usage").description("\u30B5\u30FC\u30D0\u30FC\u5229\u7528\u72B6\u6CC1\u3092\u53D6\u5F97").action(async () => {
|
|
755
|
+
const client = resolveClient(parent, brand);
|
|
756
|
+
printResult(await client.getServerUsage(), getFormat(parent));
|
|
757
|
+
});
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
// ../core/dist/commands/server/cron/index.js
|
|
761
|
+
function registerCronCommands(parent, brand) {
|
|
762
|
+
const cron = parent.command("cron").description("Cron\u8A2D\u5B9A");
|
|
763
|
+
cron.command("list").description("Cron\u4E00\u89A7\u3092\u53D6\u5F97").action(async () => {
|
|
764
|
+
const client = resolveClient(parent, brand);
|
|
765
|
+
printResult(await client.listCron(), getFormat(parent));
|
|
766
|
+
});
|
|
767
|
+
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) => {
|
|
768
|
+
const client = resolveClient(parent, brand);
|
|
769
|
+
const data = pickDefined({
|
|
770
|
+
minute: opts.minute,
|
|
771
|
+
hour: opts.hour,
|
|
772
|
+
day: opts.day,
|
|
773
|
+
month: opts.month,
|
|
774
|
+
weekday: opts.weekday,
|
|
775
|
+
command: opts.command,
|
|
776
|
+
comment: opts.comment
|
|
777
|
+
});
|
|
778
|
+
printResult(await client.addCron(data), getFormat(parent));
|
|
779
|
+
});
|
|
780
|
+
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) => {
|
|
781
|
+
const client = resolveClient(parent, brand);
|
|
782
|
+
const data = pickDefined({
|
|
783
|
+
minute: opts.minute,
|
|
784
|
+
hour: opts.hour,
|
|
785
|
+
day: opts.day,
|
|
786
|
+
month: opts.month,
|
|
787
|
+
weekday: opts.weekday,
|
|
788
|
+
command: opts.command,
|
|
789
|
+
comment: opts.comment
|
|
790
|
+
});
|
|
791
|
+
if (opts.enabled !== void 0)
|
|
792
|
+
data.enabled = opts.enabled === "true";
|
|
793
|
+
printResult(await client.updateCron(cronId, data), getFormat(parent));
|
|
794
|
+
});
|
|
795
|
+
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) => {
|
|
796
|
+
await confirmDestructiveAction(parent, `Cron "${cronId}" \u3092\u524A\u9664\u3057\u307E\u3059\u3002\u3088\u308D\u3057\u3044\u3067\u3059\u304B\uFF1F`);
|
|
797
|
+
const client = resolveClient(parent, brand);
|
|
798
|
+
printResult(await client.deleteCron(cronId), getFormat(parent));
|
|
799
|
+
});
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
// ../core/dist/commands/server/wp/index.js
|
|
803
|
+
function registerWpCommands(parent, brand) {
|
|
804
|
+
const wp = parent.command("wp").description("WordPress\u7C21\u5358\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB");
|
|
805
|
+
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) => {
|
|
806
|
+
const client = resolveClient(parent, brand);
|
|
807
|
+
const params = {};
|
|
808
|
+
if (opts.domain)
|
|
809
|
+
params.domain = opts.domain;
|
|
810
|
+
printResult(await client.listWordpress(params), getFormat(parent));
|
|
811
|
+
});
|
|
812
|
+
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) => {
|
|
813
|
+
const client = resolveClient(parent, brand);
|
|
814
|
+
const data = pickDefined({
|
|
815
|
+
url: opts.url,
|
|
816
|
+
title: opts.title,
|
|
817
|
+
admin_username: opts.adminUsername,
|
|
818
|
+
admin_password: opts.adminPassword,
|
|
819
|
+
admin_email: opts.adminEmail,
|
|
820
|
+
memo: opts.memo
|
|
821
|
+
});
|
|
822
|
+
printResult(await client.addWordpress(data), getFormat(parent));
|
|
823
|
+
});
|
|
824
|
+
wp.command("update <wpId>").description("WordPress\u8A2D\u5B9A\u3092\u5909\u66F4").option("--memo <value>", "\u30E1\u30E2").action(async (wpId, opts) => {
|
|
825
|
+
const client = resolveClient(parent, brand);
|
|
826
|
+
printResult(await client.updateWordpress(wpId, pickDefined({ memo: opts.memo })), getFormat(parent));
|
|
827
|
+
});
|
|
828
|
+
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) => {
|
|
829
|
+
await confirmDestructiveAction(parent, `WordPress "${wpId}" \u3092\u524A\u9664\u3057\u307E\u3059\u3002\u3088\u308D\u3057\u3044\u3067\u3059\u304B\uFF1F`);
|
|
830
|
+
const client = resolveClient(parent, brand);
|
|
831
|
+
const data = pickDefined({
|
|
832
|
+
delete_db: opts.deleteDb !== void 0 ? opts.deleteDb === "true" : void 0,
|
|
833
|
+
delete_db_user: opts.deleteDbUser !== void 0 ? opts.deleteDbUser === "true" : void 0,
|
|
834
|
+
delete_cron: opts.deleteCron !== void 0 ? opts.deleteCron === "true" : void 0
|
|
835
|
+
});
|
|
836
|
+
printResult(await client.deleteWordpress(wpId, data), getFormat(parent));
|
|
837
|
+
});
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
// ../core/dist/commands/server/mail/index.js
|
|
841
|
+
function registerMailCommands(parent, brand) {
|
|
842
|
+
const mail = parent.command("mail").description("\u30E1\u30FC\u30EB\u30A2\u30AB\u30A6\u30F3\u30C8\u8A2D\u5B9A");
|
|
843
|
+
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) => {
|
|
844
|
+
const client = resolveClient(parent, brand);
|
|
845
|
+
const params = {};
|
|
846
|
+
if (opts.domain)
|
|
847
|
+
params.domain = opts.domain;
|
|
848
|
+
printResult(await client.listMail(params), getFormat(parent));
|
|
849
|
+
});
|
|
850
|
+
mail.command("get <mailAccount>").description("\u30E1\u30FC\u30EB\u30A2\u30AB\u30A6\u30F3\u30C8\u8A73\u7D30\u3092\u53D6\u5F97").action(async (mailAccount) => {
|
|
851
|
+
const client = resolveClient(parent, brand);
|
|
852
|
+
printResult(await client.getMail(mailAccount), getFormat(parent));
|
|
853
|
+
});
|
|
854
|
+
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) => {
|
|
855
|
+
const client = resolveClient(parent, brand);
|
|
856
|
+
const data = pickDefined({
|
|
857
|
+
mail_address: mailAddress,
|
|
858
|
+
password: opts.password,
|
|
859
|
+
quota_mb: opts.quotaMb !== void 0 ? parseInt(opts.quotaMb, 10) : void 0,
|
|
860
|
+
memo: opts.memo
|
|
861
|
+
});
|
|
862
|
+
printResult(await client.addMail(data), getFormat(parent));
|
|
863
|
+
});
|
|
864
|
+
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) => {
|
|
865
|
+
const client = resolveClient(parent, brand);
|
|
866
|
+
printResult(await client.updateMail(mailAccount, pickDefined({
|
|
867
|
+
password: opts.password,
|
|
868
|
+
quota_mb: opts.quotaMb !== void 0 ? parseInt(opts.quotaMb, 10) : void 0,
|
|
869
|
+
memo: opts.memo
|
|
870
|
+
})), getFormat(parent));
|
|
871
|
+
});
|
|
872
|
+
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) => {
|
|
873
|
+
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`);
|
|
874
|
+
const client = resolveClient(parent, brand);
|
|
875
|
+
printResult(await client.deleteMail(mailAccount), getFormat(parent));
|
|
876
|
+
});
|
|
877
|
+
mail.command("forwarding-get <mailAccount>").description("\u30E1\u30FC\u30EB\u8EE2\u9001\u8A2D\u5B9A\u3092\u53D6\u5F97").action(async (mailAccount) => {
|
|
878
|
+
const client = resolveClient(parent, brand);
|
|
879
|
+
printResult(await client.getMailForwarding(mailAccount), getFormat(parent));
|
|
880
|
+
});
|
|
881
|
+
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) => {
|
|
882
|
+
const client = resolveClient(parent, brand);
|
|
883
|
+
const data = {};
|
|
884
|
+
if (opts.forwardingAddresses)
|
|
885
|
+
data.forwarding_addresses = opts.forwardingAddresses.split(",").map((a) => a.trim());
|
|
886
|
+
if (opts.keepInMailbox !== void 0)
|
|
887
|
+
data.keep_in_mailbox = opts.keepInMailbox === "true";
|
|
888
|
+
printResult(await client.updateMailForwarding(mailAccount, data), getFormat(parent));
|
|
889
|
+
});
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
// ../core/dist/commands/server/spam-filter/index.js
|
|
893
|
+
function parseAddressList(value) {
|
|
894
|
+
if (value === "") {
|
|
895
|
+
return [];
|
|
896
|
+
}
|
|
897
|
+
return value.split(",").map((a) => a.trim()).filter((a) => a !== "");
|
|
898
|
+
}
|
|
899
|
+
function registerSpamFilterCommands(parent, brand) {
|
|
900
|
+
const spamFilter = parent.command("spam-filter").description("\u8FF7\u60D1\u30E1\u30FC\u30EB\u30D5\u30A3\u30EB\u30BF\u8A2D\u5B9A");
|
|
901
|
+
spamFilter.command("list").description("\u8FF7\u60D1\u30E1\u30FC\u30EB\u30D5\u30A3\u30EB\u30BF\u8A2D\u5B9A\u3092\u53D6\u5F97").option("--domain <domain>", "\u5BFE\u8C61\u30C9\u30E1\u30A4\u30F3\u3067\u7D5E\u308A\u8FBC\u307F").action(async (opts) => {
|
|
902
|
+
const client = resolveClient(parent, brand);
|
|
903
|
+
const params = {};
|
|
904
|
+
if (opts.domain)
|
|
905
|
+
params.domain = opts.domain;
|
|
906
|
+
printResult(await client.listSpamFilter(params), getFormat(parent));
|
|
907
|
+
});
|
|
908
|
+
spamFilter.command("update <domain>").description("\u8FF7\u60D1\u30E1\u30FC\u30EB\u30D5\u30A3\u30EB\u30BF\u8A2D\u5B9A\u3092\u66F4\u65B0\uFF08\u6307\u5B9A\u3057\u305F\u9805\u76EE\u306E\u307F\uFF09").option("--filter-type <value>", "\u8FF7\u60D1\u30E1\u30FC\u30EB\u30D5\u30A3\u30EB\u30BF\uFF08off / standard / cloudmark_authority\uFF09").option("--detection-action <action>", "\u691C\u77E5\u6642\u306E\u51E6\u7406\uFF08inbox / spam / trash / delete\uFF09").option("--white-list <addresses>", "\u30DB\u30EF\u30A4\u30C8\u30EA\u30B9\u30C8\uFF08\u30AB\u30F3\u30DE\u533A\u5207\u308A\u3002\u7A7A\u6587\u5B57\u3067\u30AF\u30EA\u30A2\uFF09").option("--black-list <addresses>", "\u30D6\u30E9\u30C3\u30AF\u30EA\u30B9\u30C8\uFF08\u30AB\u30F3\u30DE\u533A\u5207\u308A\u3002\u7A7A\u6587\u5B57\u3067\u30AF\u30EA\u30A2\uFF09").option("--spam-level <level>", "\u6A19\u6E96\u30B9\u30D1\u30E0\u30D5\u30A3\u30EB\u30BF\u5224\u5B9A\u57FA\u6E96\uFF08very_lenient / lenient / normal / strict / very_strict / strictest\uFF09").option("--strict-non-japanese-subject <value>", "\u65E5\u672C\u8A9E\u3092\u542B\u307E\u306A\u3044\u4EF6\u540D\u306B\u5BFE\u3057\u3066\u5224\u5B9A\u3092\u53B3\u3057\u304F\u3059\u308B\uFF08true/false\uFF09").option("--strict-html-mail <value>", "HTML\u30E1\u30FC\u30EB\u306B\u5BFE\u3057\u3066\u5224\u5B9A\u3092\u53B3\u3057\u304F\u3059\u308B\uFF08true/false\uFF09").action(async (domain, opts) => {
|
|
909
|
+
const data = {};
|
|
910
|
+
if (opts.filterType !== void 0)
|
|
911
|
+
data.filter_type = opts.filterType;
|
|
912
|
+
if (opts.detectionAction !== void 0)
|
|
913
|
+
data.detection_action = opts.detectionAction;
|
|
914
|
+
if (opts.whiteList !== void 0)
|
|
915
|
+
data.white_list = parseAddressList(opts.whiteList);
|
|
916
|
+
if (opts.blackList !== void 0)
|
|
917
|
+
data.black_list = parseAddressList(opts.blackList);
|
|
918
|
+
if (opts.spamLevel !== void 0)
|
|
919
|
+
data.spam_level = opts.spamLevel;
|
|
920
|
+
if (opts.strictNonJapaneseSubject !== void 0) {
|
|
921
|
+
data.strict_non_japanese_subject = opts.strictNonJapaneseSubject;
|
|
922
|
+
}
|
|
923
|
+
if (opts.strictHtmlMail !== void 0) {
|
|
924
|
+
data.strict_html_mail = opts.strictHtmlMail;
|
|
925
|
+
}
|
|
926
|
+
if (Object.keys(data).length === 0) {
|
|
927
|
+
throw new Error("\u66F4\u65B0\u3059\u308B\u30D5\u30A3\u30FC\u30EB\u30C9\u30921\u3064\u4EE5\u4E0A\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
928
|
+
}
|
|
929
|
+
const client = resolveClient(parent, brand);
|
|
930
|
+
printResult(await client.updateSpamFilter(domain, data), getFormat(parent));
|
|
931
|
+
});
|
|
932
|
+
spamFilter.command("dmarc-receiver-update <domain>").description("\u53D7\u4FE1\u5074DMARC\u8A2D\u5B9A\u3092\u66F4\u65B0").requiredOption("--dmarc-receiver <value>", "\u53D7\u4FE1\u5074DMARC\u8A2D\u5B9A\uFF08true/false\uFF09").action(async (domain, opts) => {
|
|
933
|
+
const client = resolveClient(parent, brand);
|
|
934
|
+
printResult(await client.updateSpamFilterDmarcReceiver(domain, {
|
|
935
|
+
dmarc_receiver: opts.dmarcReceiver
|
|
936
|
+
}), getFormat(parent));
|
|
937
|
+
});
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
// ../core/dist/commands/server/mail-filter/index.js
|
|
941
|
+
function registerMailFilterCommands(parent, brand) {
|
|
942
|
+
const mailFilter = parent.command("mail-filter").description("\u30E1\u30FC\u30EB\u632F\u308A\u5206\u3051\u8A2D\u5B9A");
|
|
943
|
+
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) => {
|
|
944
|
+
const client = resolveClient(parent, brand);
|
|
945
|
+
const params = {};
|
|
946
|
+
if (opts.domain)
|
|
947
|
+
params.domain = opts.domain;
|
|
948
|
+
printResult(await client.listMailFilter(params), getFormat(parent));
|
|
949
|
+
});
|
|
950
|
+
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) => {
|
|
951
|
+
const client = resolveClient(parent, brand);
|
|
952
|
+
const data = {
|
|
953
|
+
domain: opts.domain,
|
|
954
|
+
conditions: [{
|
|
955
|
+
keyword: opts.conditionKeyword,
|
|
956
|
+
field: opts.conditionField,
|
|
957
|
+
match_type: opts.conditionMatchType || "contain"
|
|
958
|
+
}],
|
|
959
|
+
action: {
|
|
960
|
+
type: opts.actionType,
|
|
961
|
+
target: opts.actionTarget || "",
|
|
962
|
+
method: opts.actionMethod || "move"
|
|
963
|
+
}
|
|
964
|
+
};
|
|
965
|
+
printResult(await client.addMailFilter(data), getFormat(parent));
|
|
966
|
+
});
|
|
967
|
+
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) => {
|
|
968
|
+
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`);
|
|
969
|
+
const client = resolveClient(parent, brand);
|
|
970
|
+
printResult(await client.deleteMailFilter(filterId), getFormat(parent));
|
|
971
|
+
});
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
// ../core/dist/commands/server/auto-reply/index.js
|
|
975
|
+
function registerAutoReplyCommands(parent, brand) {
|
|
976
|
+
const autoReply = parent.command("auto-reply").description("\u81EA\u52D5\u5FDC\u7B54\u8A2D\u5B9A");
|
|
977
|
+
autoReply.command("list").description("\u81EA\u52D5\u5FDC\u7B54\u8A2D\u5B9A\u306E\u4E00\u89A7\u3092\u53D6\u5F97").option("--domain <domain>", "\u30C9\u30E1\u30A4\u30F3\u3067\u7D5E\u308A\u8FBC\u307F").action(async (opts) => {
|
|
978
|
+
const client = resolveClient(parent, brand);
|
|
979
|
+
const params = {};
|
|
980
|
+
if (opts.domain)
|
|
981
|
+
params.domain = opts.domain;
|
|
982
|
+
printResult(await client.listAutoReply(params), getFormat(parent));
|
|
983
|
+
});
|
|
984
|
+
autoReply.command("get <mailAddress>").description("\u81EA\u52D5\u5FDC\u7B54\u8A2D\u5B9A\u306E\u8A73\u7D30\u3092\u53D6\u5F97").action(async (mailAccount) => {
|
|
985
|
+
const client = resolveClient(parent, brand);
|
|
986
|
+
printResult(await client.getAutoReply(mailAccount), getFormat(parent));
|
|
987
|
+
});
|
|
988
|
+
autoReply.command("add").description("\u81EA\u52D5\u5FDC\u7B54\u8A2D\u5B9A\u3092\u8FFD\u52A0").requiredOption("--domain <domain>", "\u5BFE\u8C61\u30C9\u30E1\u30A4\u30F3").requiredOption("--mail-address <address>", "\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9").requiredOption("--from-name <name>", "\u9001\u4FE1\u8005\u540D").requiredOption("--subject <subject>", "\u4EF6\u540D").requiredOption("--body <body>", "\u672C\u6587").requiredOption("--quote-incoming <value>", "\u53D7\u4FE1\u30E1\u30FC\u30EB\u306E\u5F15\u7528\uFF08true/false \u307E\u305F\u306F 1/0\uFF09").action(async (opts) => {
|
|
989
|
+
const client = resolveClient(parent, brand);
|
|
990
|
+
printResult(await client.addAutoReply({
|
|
991
|
+
domain: opts.domain,
|
|
992
|
+
mail_address: opts.mailAddress,
|
|
993
|
+
from_name: opts.fromName,
|
|
994
|
+
subject: opts.subject,
|
|
995
|
+
body: opts.body,
|
|
996
|
+
quote_incoming: opts.quoteIncoming
|
|
997
|
+
}), getFormat(parent));
|
|
998
|
+
});
|
|
999
|
+
autoReply.command("update <mailAddress>").description("\u81EA\u52D5\u5FDC\u7B54\u8A2D\u5B9A\u3092\u66F4\u65B0\uFF08\u6307\u5B9A\u3057\u305F\u9805\u76EE\u306E\u307F\uFF09").option("--from-name <name>", "\u9001\u4FE1\u8005\u540D").option("--subject <subject>", "\u4EF6\u540D").option("--body <body>", "\u672C\u6587").option("--quote-incoming <value>", "\u53D7\u4FE1\u30E1\u30FC\u30EB\u306E\u5F15\u7528\uFF08true/false \u307E\u305F\u306F 1/0\uFF09").action(async (mailAccount, opts) => {
|
|
1000
|
+
const data = {};
|
|
1001
|
+
if (opts.fromName !== void 0)
|
|
1002
|
+
data.from_name = opts.fromName;
|
|
1003
|
+
if (opts.subject !== void 0)
|
|
1004
|
+
data.subject = opts.subject;
|
|
1005
|
+
if (opts.body !== void 0)
|
|
1006
|
+
data.body = opts.body;
|
|
1007
|
+
if (opts.quoteIncoming !== void 0) {
|
|
1008
|
+
data.quote_incoming = opts.quoteIncoming;
|
|
1009
|
+
}
|
|
1010
|
+
if (Object.keys(data).length === 0) {
|
|
1011
|
+
throw new Error("\u66F4\u65B0\u3059\u308B\u30D5\u30A3\u30FC\u30EB\u30C9\u30921\u3064\u4EE5\u4E0A\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08--from-name / --subject / --body / --quote-incoming\uFF09");
|
|
1012
|
+
}
|
|
1013
|
+
const client = resolveClient(parent, brand);
|
|
1014
|
+
printResult(await client.updateAutoReply(mailAccount, data), getFormat(parent));
|
|
1015
|
+
});
|
|
1016
|
+
autoReply.command("delete <mailAddress>").description("\u81EA\u52D5\u5FDC\u7B54\u8A2D\u5B9A\u3092\u524A\u9664").option("-y, --yes", "\u78BA\u8A8D\u30D7\u30ED\u30F3\u30D7\u30C8\u3092\u30B9\u30AD\u30C3\u30D7").action(async (mailAccount) => {
|
|
1017
|
+
await confirmDestructiveAction(parent, `\u81EA\u52D5\u5FDC\u7B54\u8A2D\u5B9A "${mailAccount}" \u3092\u524A\u9664\u3057\u307E\u3059\u3002\u3088\u308D\u3057\u3044\u3067\u3059\u304B\uFF1F`);
|
|
1018
|
+
const client = resolveClient(parent, brand);
|
|
1019
|
+
printResult(await client.deleteAutoReply(mailAccount), getFormat(parent));
|
|
1020
|
+
});
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
// ../core/dist/commands/server/smtp-abroad-restriction/index.js
|
|
1024
|
+
function registerSmtpAbroadRestrictionCommands(parent, brand) {
|
|
1025
|
+
const smtpAbroadRestriction = parent.command("smtp-abroad-restriction").description("SMTP\u8A8D\u8A3C\u306E\u56FD\u5916\u30A2\u30AF\u30BB\u30B9\u5236\u9650\u8A2D\u5B9A");
|
|
1026
|
+
smtpAbroadRestriction.command("list").description("SMTP\u8A8D\u8A3C\u306E\u56FD\u5916\u30A2\u30AF\u30BB\u30B9\u5236\u9650\u8A2D\u5B9A\u3092\u53D6\u5F97").option("--domain <domain>", "\u5BFE\u8C61\u30C9\u30E1\u30A4\u30F3\u3067\u7D5E\u308A\u8FBC\u307F").action(async (opts) => {
|
|
1027
|
+
const client = resolveClient(parent, brand);
|
|
1028
|
+
const params = {};
|
|
1029
|
+
if (opts.domain)
|
|
1030
|
+
params.domain = opts.domain;
|
|
1031
|
+
printResult(await client.listSmtpAbroadRestriction(params), getFormat(parent));
|
|
1032
|
+
});
|
|
1033
|
+
smtpAbroadRestriction.command("update <domain>").description("SMTP\u8A8D\u8A3C\u306E\u56FD\u5916\u30A2\u30AF\u30BB\u30B9\u5236\u9650\u8A2D\u5B9A\u3092\u66F4\u65B0").requiredOption("--abroad-access-restriction <value>", "\u56FD\u5916\u30A2\u30AF\u30BB\u30B9\u5236\u9650\u306E\u6709\u52B9/\u7121\u52B9\uFF08true/false \u307E\u305F\u306F 1/0\uFF09").action(async (domain, opts) => {
|
|
1034
|
+
const client = resolveClient(parent, brand);
|
|
1035
|
+
printResult(await client.updateSmtpAbroadRestriction(domain, {
|
|
1036
|
+
abroad_access_restriction: opts.abroadAccessRestriction
|
|
1037
|
+
}), getFormat(parent));
|
|
1038
|
+
});
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
// ../core/dist/commands/server/dkim/index.js
|
|
1042
|
+
function registerDkimCommands(parent, brand) {
|
|
1043
|
+
const dkim = parent.command("dkim").description("DKIM\u8A2D\u5B9A");
|
|
1044
|
+
dkim.command("list").description("DKIM\u8A2D\u5B9A\u4E00\u89A7\u3092\u53D6\u5F97").option("--domain <domain>", "\u5BFE\u8C61\u30C9\u30E1\u30A4\u30F3\u3067\u7D5E\u308A\u8FBC\u307F").action(async (opts) => {
|
|
1045
|
+
const client = resolveClient(parent, brand);
|
|
1046
|
+
const params = {};
|
|
1047
|
+
if (opts.domain)
|
|
1048
|
+
params.domain = opts.domain;
|
|
1049
|
+
printResult(await client.listDkim(params), getFormat(parent));
|
|
1050
|
+
});
|
|
1051
|
+
dkim.command("get <fqdn>").description("DKIM\u8A2D\u5B9A\u306E\u8A73\u7D30\u3092\u53D6\u5F97").action(async (fqdn) => {
|
|
1052
|
+
const client = resolveClient(parent, brand);
|
|
1053
|
+
printResult(await client.getDkim(fqdn), getFormat(parent));
|
|
1054
|
+
});
|
|
1055
|
+
dkim.command("update <fqdn>").description("DKIM\u8A2D\u5B9A\u306E\u6709\u52B9/\u7121\u52B9\u3092\u5207\u308A\u66FF\u3048").requiredOption("--enabled <value>", "DKIM\u306E\u6709\u52B9/\u7121\u52B9\uFF08true/false \u307E\u305F\u306F 1/0\uFF09").action(async (fqdn, opts) => {
|
|
1056
|
+
const client = resolveClient(parent, brand);
|
|
1057
|
+
printResult(await client.updateDkim(fqdn, { enabled: opts.enabled }), getFormat(parent));
|
|
1058
|
+
});
|
|
1059
|
+
}
|
|
1060
|
+
|
|
1061
|
+
// ../core/dist/commands/server/dmarc/index.js
|
|
1062
|
+
function parseNotificationMailAddresses(value) {
|
|
1063
|
+
if (value === "") {
|
|
1064
|
+
return [];
|
|
1065
|
+
}
|
|
1066
|
+
return value.split(",").map((address) => address.trim()).filter((address) => address !== "");
|
|
1067
|
+
}
|
|
1068
|
+
function registerDmarcCommands(parent, brand) {
|
|
1069
|
+
const dmarc = parent.command("dmarc").description("\u9001\u4FE1\u5074DMARC\u8A2D\u5B9A");
|
|
1070
|
+
dmarc.command("list").description("\u9001\u4FE1\u5074DMARC\u8A2D\u5B9A\u3092\u53D6\u5F97").option("--domain <domain>", "\u5BFE\u8C61\u30C9\u30E1\u30A4\u30F3\u3067\u7D5E\u308A\u8FBC\u307F").action(async (opts) => {
|
|
1071
|
+
const client = resolveClient(parent, brand);
|
|
1072
|
+
const params = {};
|
|
1073
|
+
if (opts.domain)
|
|
1074
|
+
params.domain = opts.domain;
|
|
1075
|
+
printResult(await client.listDmarc(params), getFormat(parent));
|
|
1076
|
+
});
|
|
1077
|
+
dmarc.command("update <domain>").description("\u9001\u4FE1\u5074DMARC\u8A2D\u5B9A\u3092\u66F4\u65B0\uFF08\u6307\u5B9A\u3057\u305F\u9805\u76EE\u306E\u307F\uFF09").option("--policy <policy>", "DMARC\u30DD\u30EA\u30B7\u30FC\uFF08none / quarantine / reject\uFF09").option("--report-enabled <value>", "\u30EC\u30DD\u30FC\u30C8\u901A\u77E5\u306E\u6709\u52B9/\u7121\u52B9\uFF08true/false \u307E\u305F\u306F 1/0\uFF09\u3002false \u306E\u3068\u304D\u901A\u77E5\u5148\u306F\u81EA\u52D5\u7684\u306B\u7A7A\u306B\u306A\u308B").option("--notification-mail-addresses <addresses>", "\u30EC\u30DD\u30FC\u30C8\u901A\u77E5\u5148\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9\uFF08\u30AB\u30F3\u30DE\u533A\u5207\u308A\uFF09\u3002--report-enabled true \u306E\u3068\u304D\u306F1\u4EF6\u4EE5\u4E0A\u5FC5\u9808").action(async (domain, opts) => {
|
|
1078
|
+
const data = {};
|
|
1079
|
+
if (opts.policy !== void 0)
|
|
1080
|
+
data.policy = opts.policy;
|
|
1081
|
+
if (opts.reportEnabled !== void 0) {
|
|
1082
|
+
data.report_enabled = opts.reportEnabled;
|
|
1083
|
+
}
|
|
1084
|
+
if (opts.notificationMailAddresses !== void 0) {
|
|
1085
|
+
data.notification_mail_addresses = parseNotificationMailAddresses(opts.notificationMailAddresses);
|
|
1086
|
+
}
|
|
1087
|
+
if (Object.keys(data).length === 0) {
|
|
1088
|
+
throw new Error("\u66F4\u65B0\u3059\u308B\u30D5\u30A3\u30FC\u30EB\u30C9\u30921\u3064\u4EE5\u4E0A\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
1089
|
+
}
|
|
1090
|
+
const client = resolveClient(parent, brand);
|
|
1091
|
+
printResult(await client.updateDmarc(domain, data), getFormat(parent));
|
|
1092
|
+
});
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1095
|
+
// ../core/dist/commands/server/spf/index.js
|
|
1096
|
+
var UPDATE_ACTIONS = ["reset", "enable_gmail", "custom"];
|
|
1097
|
+
function registerSpfCommands(parent, brand) {
|
|
1098
|
+
const spf = parent.command("spf").description("SPF\u8A2D\u5B9A");
|
|
1099
|
+
spf.command("list").description("SPF\u8A2D\u5B9A\u4E00\u89A7\u3092\u53D6\u5F97").option("--domain <domain>", "\u5BFE\u8C61\u30C9\u30E1\u30A4\u30F3\u3067\u7D5E\u308A\u8FBC\u307F").action(async (opts) => {
|
|
1100
|
+
const client = resolveClient(parent, brand);
|
|
1101
|
+
const params = {};
|
|
1102
|
+
if (opts.domain)
|
|
1103
|
+
params.domain = opts.domain;
|
|
1104
|
+
printResult(await client.listSpf(params), getFormat(parent));
|
|
1105
|
+
});
|
|
1106
|
+
spf.command("add").description("SPF\u8A2D\u5B9A\u3092\u8FFD\u52A0").requiredOption("--fqdn <fqdn>", "FQDN\uFF08example.com \u307E\u305F\u306F sub.example.com\uFF09").action(async (opts) => {
|
|
1107
|
+
const client = resolveClient(parent, brand);
|
|
1108
|
+
printResult(await client.addSpf({ fqdn: opts.fqdn }), getFormat(parent));
|
|
1109
|
+
});
|
|
1110
|
+
spf.command("update <fqdn>").description("SPF\u8A2D\u5B9A\u3092\u66F4\u65B0\uFF08reset / enable_gmail / custom\uFF09").requiredOption("--action <action>", `\u64CD\u4F5C\u7A2E\u5225\uFF08${UPDATE_ACTIONS.join(" / ")}\uFF09`).option("--spf-record <record>", "\u30AB\u30B9\u30BF\u30E0SPF\u30EC\u30B3\u30FC\u30C9\uFF08action=custom \u306E\u3068\u304D\u5FC5\u9808\uFF09").action(async (fqdn, opts) => {
|
|
1111
|
+
const body = { action: opts.action };
|
|
1112
|
+
if (opts.spfRecord !== void 0)
|
|
1113
|
+
body.spf_record = opts.spfRecord;
|
|
1114
|
+
const client = resolveClient(parent, brand);
|
|
1115
|
+
printResult(await client.updateSpf(fqdn, body), getFormat(parent));
|
|
1116
|
+
});
|
|
1117
|
+
spf.command("delete <fqdn>").description("SPF\u8A2D\u5B9A\u3092\u524A\u9664").action(async (fqdn) => {
|
|
1118
|
+
const client = resolveClient(parent, brand);
|
|
1119
|
+
printResult(await client.deleteSpf(fqdn), getFormat(parent));
|
|
1120
|
+
});
|
|
1121
|
+
}
|
|
1122
|
+
|
|
1123
|
+
// ../core/dist/commands/server/ftp/index.js
|
|
1124
|
+
function registerFtpCommands(parent, brand) {
|
|
1125
|
+
const ftp = parent.command("ftp").description("FTP\u30A2\u30AB\u30A6\u30F3\u30C8\u8A2D\u5B9A");
|
|
1126
|
+
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) => {
|
|
1127
|
+
const client = resolveClient(parent, brand);
|
|
1128
|
+
const params = {};
|
|
1129
|
+
if (opts.domain)
|
|
1130
|
+
params.domain = opts.domain;
|
|
1131
|
+
printResult(await client.listFtp(params), getFormat(parent));
|
|
1132
|
+
});
|
|
1133
|
+
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) => {
|
|
1134
|
+
const client = resolveClient(parent, brand);
|
|
1135
|
+
const data = pickDefined({
|
|
1136
|
+
ftp_account: ftpAccount,
|
|
1137
|
+
password: opts.password,
|
|
1138
|
+
directory: opts.directory,
|
|
1139
|
+
quota_mb: opts.quota !== void 0 ? parseInt(opts.quota, 10) : void 0,
|
|
1140
|
+
memo: opts.memo
|
|
1141
|
+
});
|
|
1142
|
+
printResult(await client.addFtp(data), getFormat(parent));
|
|
1143
|
+
});
|
|
1144
|
+
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) => {
|
|
1145
|
+
const client = resolveClient(parent, brand);
|
|
1146
|
+
printResult(await client.updateFtp(ftpAccount, pickDefined({
|
|
1147
|
+
password: opts.password,
|
|
1148
|
+
directory: opts.directory,
|
|
1149
|
+
quota_mb: opts.quota !== void 0 ? parseInt(opts.quota, 10) : void 0,
|
|
1150
|
+
memo: opts.memo
|
|
1151
|
+
})), getFormat(parent));
|
|
1152
|
+
});
|
|
1153
|
+
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) => {
|
|
1154
|
+
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`);
|
|
1155
|
+
const client = resolveClient(parent, brand);
|
|
1156
|
+
printResult(await client.deleteFtp(ftpAccount), getFormat(parent));
|
|
1157
|
+
});
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1160
|
+
// ../core/dist/commands/server/db/index.js
|
|
1161
|
+
function registerDbCommands(parent, brand) {
|
|
1162
|
+
const db = parent.command("db").description("MySQL\u8A2D\u5B9A");
|
|
1163
|
+
db.command("list").description("\u30C7\u30FC\u30BF\u30D9\u30FC\u30B9\u4E00\u89A7\u3092\u53D6\u5F97").action(async () => {
|
|
1164
|
+
const client = resolveClient(parent, brand);
|
|
1165
|
+
printResult(await client.listDb(), getFormat(parent));
|
|
1166
|
+
});
|
|
1167
|
+
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) => {
|
|
1168
|
+
const client = resolveClient(parent, brand);
|
|
1169
|
+
printResult(await client.addDb(pickDefined({
|
|
1170
|
+
name_suffix: nameSuffix,
|
|
1171
|
+
character_set: opts.characterSet,
|
|
1172
|
+
memo: opts.memo
|
|
1173
|
+
})), getFormat(parent));
|
|
1174
|
+
});
|
|
1175
|
+
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) => {
|
|
1176
|
+
const client = resolveClient(parent, brand);
|
|
1177
|
+
printResult(await client.updateDb(dbName, pickDefined({
|
|
1178
|
+
memo: opts.memo
|
|
1179
|
+
})), getFormat(parent));
|
|
1180
|
+
});
|
|
1181
|
+
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) => {
|
|
1182
|
+
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`);
|
|
1183
|
+
const client = resolveClient(parent, brand);
|
|
1184
|
+
printResult(await client.deleteDb(dbName), getFormat(parent));
|
|
1185
|
+
});
|
|
1186
|
+
db.command("user-list").description("MySQL\u30E6\u30FC\u30B6\u30FC\u4E00\u89A7\u3092\u53D6\u5F97").action(async () => {
|
|
1187
|
+
const client = resolveClient(parent, brand);
|
|
1188
|
+
printResult(await client.listDbUser(), getFormat(parent));
|
|
1189
|
+
});
|
|
1190
|
+
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) => {
|
|
1191
|
+
const client = resolveClient(parent, brand);
|
|
1192
|
+
printResult(await client.addDbUser(pickDefined({
|
|
1193
|
+
name_suffix: nameSuffix,
|
|
1194
|
+
password: opts.password,
|
|
1195
|
+
memo: opts.memo
|
|
1196
|
+
})), getFormat(parent));
|
|
1197
|
+
});
|
|
1198
|
+
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) => {
|
|
1199
|
+
const client = resolveClient(parent, brand);
|
|
1200
|
+
printResult(await client.updateDbUser(dbUser, pickDefined({
|
|
1201
|
+
password: opts.password,
|
|
1202
|
+
memo: opts.memo
|
|
1203
|
+
})), getFormat(parent));
|
|
1204
|
+
});
|
|
1205
|
+
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) => {
|
|
1206
|
+
await confirmDestructiveAction(parent, `MySQL\u30E6\u30FC\u30B6\u30FC "${dbUser}" \u3092\u524A\u9664\u3057\u307E\u3059\u3002\u3088\u308D\u3057\u3044\u3067\u3059\u304B\uFF1F`);
|
|
1207
|
+
const client = resolveClient(parent, brand);
|
|
1208
|
+
printResult(await client.deleteDbUser(dbUser), getFormat(parent));
|
|
1209
|
+
});
|
|
1210
|
+
db.command("grant-list <dbUser>").description("MySQL\u30E6\u30FC\u30B6\u30FC\u306E\u6A29\u9650\u4E00\u89A7\u3092\u53D6\u5F97").action(async (dbUser) => {
|
|
1211
|
+
const client = resolveClient(parent, brand);
|
|
1212
|
+
printResult(await client.listDbUserGrant(dbUser), getFormat(parent));
|
|
1213
|
+
});
|
|
1214
|
+
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) => {
|
|
1215
|
+
const client = resolveClient(parent, brand);
|
|
1216
|
+
printResult(await client.addDbUserGrant(dbUser, { db_name: opts.dbName }), getFormat(parent));
|
|
1217
|
+
});
|
|
1218
|
+
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) => {
|
|
1219
|
+
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`);
|
|
1220
|
+
const client = resolveClient(parent, brand);
|
|
1221
|
+
printResult(await client.deleteDbUserGrant(dbUser, { db_name: opts.dbName }), getFormat(parent));
|
|
1222
|
+
});
|
|
1223
|
+
}
|
|
1224
|
+
|
|
1225
|
+
// ../core/dist/commands/server/php-version/index.js
|
|
1226
|
+
function registerPhpVersionCommands(parent, brand) {
|
|
1227
|
+
const phpVer = parent.command("php-version").description("PHP\u30D0\u30FC\u30B8\u30E7\u30F3\u8A2D\u5B9A");
|
|
1228
|
+
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) => {
|
|
1229
|
+
const client = resolveClient(parent, brand);
|
|
1230
|
+
const params = {};
|
|
1231
|
+
if (opts.domain)
|
|
1232
|
+
params.domain = opts.domain;
|
|
1233
|
+
printResult(await client.getPhpVersion(params), getFormat(parent));
|
|
1234
|
+
});
|
|
1235
|
+
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) => {
|
|
1236
|
+
const client = resolveClient(parent, brand);
|
|
1237
|
+
printResult(await client.updatePhpVersion(domain, { version: opts.php }), getFormat(parent));
|
|
1238
|
+
});
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1241
|
+
// ../core/dist/commands/server/domain/index.js
|
|
1242
|
+
function registerServerDomainCommands(parent, brand) {
|
|
1243
|
+
const domain = parent.command("domain").description("\u30C9\u30E1\u30A4\u30F3\u8A2D\u5B9A");
|
|
1244
|
+
domain.command("list").description("\u30C9\u30E1\u30A4\u30F3\u8A2D\u5B9A\u4E00\u89A7\u3092\u53D6\u5F97").action(async () => {
|
|
1245
|
+
const client = resolveClient(parent, brand);
|
|
1246
|
+
printResult(await client.listDomain(), getFormat(parent));
|
|
1247
|
+
});
|
|
1248
|
+
domain.command("get <domain>").description("\u30C9\u30E1\u30A4\u30F3\u8A2D\u5B9A\u8A73\u7D30\u3092\u53D6\u5F97").action(async (domainName) => {
|
|
1249
|
+
const client = resolveClient(parent, brand);
|
|
1250
|
+
printResult(await client.getDomain(domainName), getFormat(parent));
|
|
1251
|
+
});
|
|
1252
|
+
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) => {
|
|
1253
|
+
const client = resolveClient(parent, brand);
|
|
1254
|
+
const data = { domain: domainName };
|
|
1255
|
+
if (opts.ssl !== void 0)
|
|
1256
|
+
data.ssl = opts.ssl === "true";
|
|
1257
|
+
if (opts.redirectHttps !== void 0)
|
|
1258
|
+
data.redirect_https = opts.redirectHttps === "true";
|
|
1259
|
+
if (opts.aiCrawlerBlock !== void 0)
|
|
1260
|
+
data.ai_crawler_block_enabled = opts.aiCrawlerBlock === "true";
|
|
1261
|
+
if (opts.memo !== void 0)
|
|
1262
|
+
data.memo = opts.memo;
|
|
1263
|
+
printResult(await client.addDomain(data), getFormat(parent));
|
|
1264
|
+
});
|
|
1265
|
+
domain.command("update <domain>").description("\u30C9\u30E1\u30A4\u30F3\u8A2D\u5B9A\u3092\u5909\u66F4").option("--memo <value>", "\u30E1\u30E2").action(async (domainName, opts) => {
|
|
1266
|
+
const client = resolveClient(parent, brand);
|
|
1267
|
+
printResult(await client.updateDomain(domainName, pickDefined({
|
|
1268
|
+
memo: opts.memo
|
|
1269
|
+
})), getFormat(parent));
|
|
1270
|
+
});
|
|
1271
|
+
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) => {
|
|
1272
|
+
const suffix = opts.deleteFiles ? "\uFF08\u95A2\u9023\u30D5\u30A1\u30A4\u30EB\u3082\u524A\u9664\u3057\u307E\u3059\uFF09" : "";
|
|
1273
|
+
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`);
|
|
1274
|
+
const client = resolveClient(parent, brand);
|
|
1275
|
+
const data = {};
|
|
1276
|
+
if (opts.deleteFiles)
|
|
1277
|
+
data.delete_files = true;
|
|
1278
|
+
printResult(await client.deleteDomain(domainName, data), getFormat(parent));
|
|
1279
|
+
});
|
|
1280
|
+
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) => {
|
|
1281
|
+
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`);
|
|
1282
|
+
const client = resolveClient(parent, brand);
|
|
1283
|
+
printResult(await client.resetDomain(domainName, { type: opts.type }), getFormat(parent));
|
|
1284
|
+
});
|
|
1285
|
+
}
|
|
1286
|
+
|
|
1287
|
+
// ../core/dist/commands/server/subdomain/index.js
|
|
1288
|
+
function registerSubdomainCommands(parent, brand) {
|
|
1289
|
+
const subdomain = parent.command("subdomain").description("\u30B5\u30D6\u30C9\u30E1\u30A4\u30F3\u8A2D\u5B9A");
|
|
1290
|
+
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) => {
|
|
1291
|
+
const client = resolveClient(parent, brand);
|
|
1292
|
+
const params = {};
|
|
1293
|
+
if (opts.domain)
|
|
1294
|
+
params.domain = opts.domain;
|
|
1295
|
+
printResult(await client.listSubdomain(params), getFormat(parent));
|
|
1296
|
+
});
|
|
1297
|
+
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) => {
|
|
1298
|
+
const client = resolveClient(parent, brand);
|
|
1299
|
+
const data = { subdomain: subdomainName };
|
|
1300
|
+
if (opts.documentRootType !== void 0)
|
|
1301
|
+
data.document_root_type = opts.documentRootType;
|
|
1302
|
+
if (opts.ssl !== void 0)
|
|
1303
|
+
data.ssl = opts.ssl === "true";
|
|
1304
|
+
if (opts.memo !== void 0)
|
|
1305
|
+
data.memo = opts.memo;
|
|
1306
|
+
printResult(await client.addSubdomain(data), getFormat(parent));
|
|
1307
|
+
});
|
|
1308
|
+
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) => {
|
|
1309
|
+
const client = resolveClient(parent, brand);
|
|
1310
|
+
printResult(await client.updateSubdomain(subdomainName, pickDefined({
|
|
1311
|
+
memo: opts.memo
|
|
1312
|
+
})), getFormat(parent));
|
|
1313
|
+
});
|
|
1314
|
+
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) => {
|
|
1315
|
+
const suffix = opts.deleteFiles ? "\uFF08\u95A2\u9023\u30D5\u30A1\u30A4\u30EB\u3082\u524A\u9664\u3057\u307E\u3059\uFF09" : "";
|
|
1316
|
+
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`);
|
|
1317
|
+
const client = resolveClient(parent, brand);
|
|
1318
|
+
const data = {};
|
|
1319
|
+
if (opts.deleteFiles)
|
|
1320
|
+
data.delete_files = true;
|
|
1321
|
+
printResult(await client.deleteSubdomain(subdomainName, data), getFormat(parent));
|
|
1322
|
+
});
|
|
1323
|
+
}
|
|
1324
|
+
|
|
1325
|
+
// ../core/dist/commands/server/ssl/index.js
|
|
1326
|
+
function registerSslCommands(parent, brand) {
|
|
1327
|
+
const ssl = parent.command("ssl").description("SSL\u8A2D\u5B9A");
|
|
1328
|
+
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) => {
|
|
1329
|
+
const client = resolveClient(parent, brand);
|
|
1330
|
+
const params = {};
|
|
1331
|
+
if (opts.domain)
|
|
1332
|
+
params.domain = opts.domain;
|
|
1333
|
+
printResult(await client.listSsl(params), getFormat(parent));
|
|
1334
|
+
});
|
|
1335
|
+
ssl.command("install <commonName>").description("\u7121\u6599SSL\u3092\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB").action(async (commonName) => {
|
|
1336
|
+
const client = resolveClient(parent, brand);
|
|
1337
|
+
printResult(await client.installSsl(pickDefined({
|
|
1338
|
+
common_name: commonName
|
|
1339
|
+
})), getFormat(parent));
|
|
1340
|
+
});
|
|
1341
|
+
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) => {
|
|
1342
|
+
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`);
|
|
1343
|
+
const client = resolveClient(parent, brand);
|
|
1344
|
+
printResult(await client.uninstallSsl(commonName), getFormat(parent));
|
|
1345
|
+
});
|
|
1346
|
+
}
|
|
1347
|
+
|
|
1348
|
+
// ../core/dist/commands/server/dns/index.js
|
|
1349
|
+
function registerDnsCommands(parent, brand) {
|
|
1350
|
+
const dns = parent.command("dns").description("DNS\u30EC\u30B3\u30FC\u30C9\u8A2D\u5B9A");
|
|
1351
|
+
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) => {
|
|
1352
|
+
const client = resolveClient(parent, brand);
|
|
1353
|
+
const params = {};
|
|
1354
|
+
if (opts.domain)
|
|
1355
|
+
params.domain = opts.domain;
|
|
1356
|
+
printResult(await client.listDns(params), getFormat(parent));
|
|
1357
|
+
});
|
|
1358
|
+
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) => {
|
|
1359
|
+
const client = resolveClient(parent, brand);
|
|
1360
|
+
printResult(await client.addDns(pickDefined({
|
|
1361
|
+
domain: opts.domain,
|
|
1362
|
+
host: opts.host,
|
|
1363
|
+
type: opts.type,
|
|
1364
|
+
content: opts.content,
|
|
1365
|
+
ttl: opts.ttl !== void 0 ? parseInt(opts.ttl, 10) : void 0,
|
|
1366
|
+
priority: opts.priority !== void 0 ? parseInt(opts.priority, 10) : void 0
|
|
1367
|
+
})), getFormat(parent));
|
|
1368
|
+
});
|
|
1369
|
+
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) => {
|
|
1370
|
+
const client = resolveClient(parent, brand);
|
|
1371
|
+
printResult(await client.updateDns(dnsId, pickDefined({
|
|
1372
|
+
domain: opts.domain,
|
|
1373
|
+
host: opts.host,
|
|
1374
|
+
type: opts.type,
|
|
1375
|
+
content: opts.content,
|
|
1376
|
+
ttl: opts.ttl !== void 0 ? parseInt(opts.ttl, 10) : void 0,
|
|
1377
|
+
priority: opts.priority !== void 0 ? parseInt(opts.priority, 10) : void 0
|
|
1378
|
+
})), getFormat(parent));
|
|
1379
|
+
});
|
|
1380
|
+
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) => {
|
|
1381
|
+
await confirmDestructiveAction(parent, `DNS\u30EC\u30B3\u30FC\u30C9 "${dnsId}" \u3092\u524A\u9664\u3057\u307E\u3059\u3002\u3088\u308D\u3057\u3044\u3067\u3059\u304B\uFF1F`);
|
|
1382
|
+
const client = resolveClient(parent, brand);
|
|
1383
|
+
printResult(await client.deleteDns(dnsId), getFormat(parent));
|
|
1384
|
+
});
|
|
1385
|
+
}
|
|
1386
|
+
|
|
1387
|
+
// ../core/dist/commands/server/ssh/index.js
|
|
1388
|
+
function registerSshCommands(parent, brand) {
|
|
1389
|
+
const ssh = parent.command("ssh").description("SSH\u8A2D\u5B9A");
|
|
1390
|
+
ssh.command("show").description("SSH\u8A2D\u5B9A\u3092\u53D6\u5F97").action(async () => {
|
|
1391
|
+
const client = resolveClient(parent, brand);
|
|
1392
|
+
printResult(await client.getSsh(), getFormat(parent));
|
|
1393
|
+
});
|
|
1394
|
+
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) => {
|
|
1395
|
+
const client = resolveClient(parent, brand);
|
|
1396
|
+
const data = {};
|
|
1397
|
+
if (opts.sshEnabled !== void 0)
|
|
1398
|
+
data.ssh_enabled = opts.sshEnabled === "true";
|
|
1399
|
+
if (opts.abroadAccessRestriction !== void 0)
|
|
1400
|
+
data.abroad_access_restriction = opts.abroadAccessRestriction === "true";
|
|
1401
|
+
printResult(await client.updateSsh(data), getFormat(parent));
|
|
1402
|
+
});
|
|
1403
|
+
const key = ssh.command("key").description("SSH\u516C\u958B\u9375\u7BA1\u7406");
|
|
1404
|
+
key.command("list").description("SSH\u516C\u958B\u9375\u4E00\u89A7\u3092\u53D6\u5F97").action(async () => {
|
|
1405
|
+
const client = resolveClient(parent, brand);
|
|
1406
|
+
printResult(await client.listSshKey(), getFormat(parent));
|
|
1407
|
+
});
|
|
1408
|
+
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) => {
|
|
1409
|
+
const client = resolveClient(parent, brand);
|
|
1410
|
+
const data = { label: opts.label };
|
|
1411
|
+
if (opts.generate) {
|
|
1412
|
+
data.generate = true;
|
|
1413
|
+
if (opts.passphrase !== void 0)
|
|
1414
|
+
data.passphrase = opts.passphrase;
|
|
1415
|
+
} else {
|
|
1416
|
+
if (opts.publicKey)
|
|
1417
|
+
data.public_key = opts.publicKey;
|
|
1418
|
+
}
|
|
1419
|
+
printResult(await client.addSshKey(data), getFormat(parent));
|
|
1420
|
+
});
|
|
1421
|
+
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) => {
|
|
1422
|
+
const client = resolveClient(parent, brand);
|
|
1423
|
+
printResult(await client.updateSshKey(keyId, pickDefined({
|
|
1424
|
+
label: opts.label,
|
|
1425
|
+
status: opts.status
|
|
1426
|
+
})), getFormat(parent));
|
|
1427
|
+
});
|
|
1428
|
+
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) => {
|
|
1429
|
+
await confirmDestructiveAction(parent, `SSH\u516C\u958B\u9375 "${keyId}" \u3092\u524A\u9664\u3057\u307E\u3059\u3002\u3088\u308D\u3057\u3044\u3067\u3059\u304B\uFF1F`);
|
|
1430
|
+
const client = resolveClient(parent, brand);
|
|
1431
|
+
printResult(await client.deleteSshKey(keyId), getFormat(parent));
|
|
1432
|
+
});
|
|
1433
|
+
}
|
|
1434
|
+
|
|
1435
|
+
// ../core/dist/commands/server/log/index.js
|
|
1436
|
+
function registerLogCommands(parent, brand) {
|
|
1437
|
+
const log = parent.command("log").description("\u30ED\u30B0");
|
|
1438
|
+
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) => {
|
|
1439
|
+
const client = resolveClient(parent, brand);
|
|
1440
|
+
const params = { domain: opts.domain };
|
|
1441
|
+
if (opts.lines)
|
|
1442
|
+
params.lines = opts.lines;
|
|
1443
|
+
if (opts.keyword)
|
|
1444
|
+
params.keyword = opts.keyword;
|
|
1445
|
+
printResult(await client.getAccessLog(params), getFormat(parent));
|
|
1446
|
+
});
|
|
1447
|
+
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) => {
|
|
1448
|
+
const client = resolveClient(parent, brand);
|
|
1449
|
+
const params = { domain: opts.domain };
|
|
1450
|
+
if (opts.lines)
|
|
1451
|
+
params.lines = opts.lines;
|
|
1452
|
+
if (opts.keyword)
|
|
1453
|
+
params.keyword = opts.keyword;
|
|
1454
|
+
printResult(await client.getErrorLog(params), getFormat(parent));
|
|
1455
|
+
});
|
|
1456
|
+
}
|
|
1457
|
+
|
|
1458
|
+
// ../core/dist/commands/me/index.js
|
|
1459
|
+
function registerMeCommand(program, brand) {
|
|
1460
|
+
program.command("me").description("\u73FE\u5728\u306EAPI\u30AD\u30FC\u60C5\u5831\u3092\u8868\u793A").action(async (_opts, cmd) => {
|
|
1461
|
+
const root = cmd.parent;
|
|
1462
|
+
const rootOpts = root.opts();
|
|
1463
|
+
const profile = getActiveProfile(brand, rootOpts.profile);
|
|
1464
|
+
if (!profile) {
|
|
1465
|
+
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`);
|
|
1466
|
+
process.exit(1);
|
|
1467
|
+
}
|
|
1468
|
+
const debug = !!(rootOpts.debug || process.env.XSERVER_DEBUG === "1");
|
|
1469
|
+
const client = new ApiClient({
|
|
1470
|
+
apiKey: profile.apiKey,
|
|
1471
|
+
apiBase: brand.apiBase,
|
|
1472
|
+
servername: profile.servername,
|
|
1473
|
+
debug
|
|
1474
|
+
});
|
|
1475
|
+
printResult(await client.getMe(), getFormat(cmd));
|
|
1476
|
+
});
|
|
1477
|
+
}
|
|
1478
|
+
|
|
1479
|
+
// ../core/dist/index.js
|
|
1480
|
+
function run(brand, version = "0.0.0") {
|
|
1481
|
+
const program = new Command();
|
|
1482
|
+
program.name(brand.commandName).description(`${brand.displayName} CLI`).version(version).option("--format <format>", "\u51FA\u529B\u5F62\u5F0F (json, table)", (value) => {
|
|
1483
|
+
if (!["json", "table"].includes(value)) {
|
|
1484
|
+
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`);
|
|
1485
|
+
}
|
|
1486
|
+
return value;
|
|
1487
|
+
}, "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");
|
|
1488
|
+
registerAuthCommands(program, brand);
|
|
1489
|
+
registerMeCommand(program, brand);
|
|
1490
|
+
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");
|
|
1491
|
+
registerServerInfoCommands(server, brand);
|
|
1492
|
+
registerCronCommands(server, brand);
|
|
1493
|
+
registerSshCommands(server, brand);
|
|
1494
|
+
registerWpCommands(server, brand);
|
|
1495
|
+
registerMailCommands(server, brand);
|
|
1496
|
+
registerSpamFilterCommands(server, brand);
|
|
1497
|
+
registerMailFilterCommands(server, brand);
|
|
1498
|
+
registerAutoReplyCommands(server, brand);
|
|
1499
|
+
registerSmtpAbroadRestrictionCommands(server, brand);
|
|
1500
|
+
registerDkimCommands(server, brand);
|
|
1501
|
+
registerDmarcCommands(server, brand);
|
|
1502
|
+
registerSpfCommands(server, brand);
|
|
1503
|
+
registerFtpCommands(server, brand);
|
|
1504
|
+
registerDbCommands(server, brand);
|
|
1505
|
+
registerPhpVersionCommands(server, brand);
|
|
1506
|
+
registerServerDomainCommands(server, brand);
|
|
1507
|
+
registerSubdomainCommands(server, brand);
|
|
1508
|
+
registerSslCommands(server, brand);
|
|
1509
|
+
registerDnsCommands(server, brand);
|
|
1510
|
+
registerLogCommands(server, brand);
|
|
1511
|
+
program.parseAsync(process.argv).catch((err) => {
|
|
1512
|
+
if (err instanceof ApiError) {
|
|
1513
|
+
console.error(`\u30A8\u30E9\u30FC [${err.errorCode}]: ${err.message}`);
|
|
1514
|
+
if (err.errors.length > 0) {
|
|
1515
|
+
for (const e of err.errors) {
|
|
1516
|
+
console.error(` - ${e}`);
|
|
1517
|
+
}
|
|
1518
|
+
}
|
|
1519
|
+
process.exit(1);
|
|
1520
|
+
}
|
|
1521
|
+
if (err instanceof Error) {
|
|
1522
|
+
console.error(`\u30A8\u30E9\u30FC: ${err.message}`);
|
|
1523
|
+
process.exit(1);
|
|
1524
|
+
}
|
|
1525
|
+
console.error("\u4E88\u671F\u3057\u306A\u3044\u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F");
|
|
1526
|
+
process.exit(1);
|
|
1527
|
+
});
|
|
1528
|
+
}
|
|
1529
|
+
|
|
1530
|
+
// package.json
|
|
1531
|
+
var package_default = {
|
|
1532
|
+
name: "xserver-cli",
|
|
1533
|
+
version: "1.1.0",
|
|
1534
|
+
description: "Official CLI for XServer API \u2014 manage your XServer hosting from the terminal",
|
|
1535
|
+
type: "module",
|
|
1536
|
+
bin: {
|
|
1537
|
+
xserver: "./dist/index.js"
|
|
1538
|
+
},
|
|
1539
|
+
files: [
|
|
1540
|
+
"dist"
|
|
1541
|
+
],
|
|
1542
|
+
scripts: {
|
|
1543
|
+
build: "tsup",
|
|
1544
|
+
dev: "tsup --watch",
|
|
1545
|
+
tsc: "tsc --noEmit",
|
|
1546
|
+
prepublishOnly: "tsup"
|
|
1547
|
+
},
|
|
1548
|
+
keywords: [
|
|
1549
|
+
"xserver",
|
|
1550
|
+
"cli",
|
|
1551
|
+
"api",
|
|
1552
|
+
"hosting",
|
|
1553
|
+
"server",
|
|
1554
|
+
"webhosting"
|
|
1555
|
+
],
|
|
1556
|
+
author: "Xserver Inc.",
|
|
1557
|
+
license: "MIT",
|
|
1558
|
+
homepage: "https://developer.xserver.ne.jp",
|
|
1559
|
+
publishConfig: {
|
|
1560
|
+
access: "public"
|
|
1561
|
+
},
|
|
1562
|
+
dependencies: {
|
|
1563
|
+
"@inquirer/prompts": "^7.10.1",
|
|
1564
|
+
commander: "^13.0.0"
|
|
1565
|
+
},
|
|
1566
|
+
devDependencies: {
|
|
1567
|
+
"xnp-cli-core": "*",
|
|
1568
|
+
"xnp-shared": "*"
|
|
1569
|
+
},
|
|
1570
|
+
engines: {
|
|
1571
|
+
node: ">=18.0.0"
|
|
1572
|
+
}
|
|
1573
|
+
};
|
|
1574
|
+
|
|
1575
|
+
// src/index.ts
|
|
1576
|
+
run({
|
|
1577
|
+
brand: "xserver",
|
|
1578
|
+
apiBase: "https://api.xserver.ne.jp",
|
|
1579
|
+
displayName: "XServer API",
|
|
1580
|
+
commandName: "xserver",
|
|
1581
|
+
configDir: "xserver-cli"
|
|
1582
|
+
}, package_default.version);
|
|
1583
|
+
//# sourceMappingURL=index.js.map
|