star8-cli 1.4.0 → 1.5.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/dist/index.js +443 -18
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -16,6 +16,21 @@ function redactSensitiveValues(value) {
|
|
|
16
16
|
SENSITIVE_FIELD_PATTERN.test(key) ? "[REDACTED]" : redactSensitiveValues(child)
|
|
17
17
|
]));
|
|
18
18
|
}
|
|
19
|
+
function retryAfterSeconds(response) {
|
|
20
|
+
if (response.status !== 429)
|
|
21
|
+
return void 0;
|
|
22
|
+
const value = response.headers.get("retry-after");
|
|
23
|
+
if (value === null || !/^\d+$/.test(value))
|
|
24
|
+
return void 0;
|
|
25
|
+
const seconds = Number(value);
|
|
26
|
+
if (!Number.isSafeInteger(seconds))
|
|
27
|
+
return void 0;
|
|
28
|
+
return seconds;
|
|
29
|
+
}
|
|
30
|
+
function retryAfterGuidance(response) {
|
|
31
|
+
const seconds = retryAfterSeconds(response);
|
|
32
|
+
return seconds === void 0 ? void 0 : `\u518D\u8A66\u884C\u307E\u3067\u306E\u76EE\u5B89: ${seconds}\u79D2`;
|
|
33
|
+
}
|
|
19
34
|
var ApiError = class extends Error {
|
|
20
35
|
httpStatus;
|
|
21
36
|
errorCode;
|
|
@@ -761,6 +776,78 @@ var ApiClient = class {
|
|
|
761
776
|
return this.put(`${this.wphostingSitePath(contractId2, servername2)}/security/${enc(key)}`, data);
|
|
762
777
|
}
|
|
763
778
|
// ================================================================
|
|
779
|
+
// VPS API(/v1/vps)
|
|
780
|
+
// ================================================================
|
|
781
|
+
vpsServerPath(uuid) {
|
|
782
|
+
return `/v1/vps/servers/${enc(uuid)}`;
|
|
783
|
+
}
|
|
784
|
+
async listVpsServers() {
|
|
785
|
+
return this.get("/v1/vps/servers");
|
|
786
|
+
}
|
|
787
|
+
async getVpsServer(uuid) {
|
|
788
|
+
return this.get(this.vpsServerPath(uuid));
|
|
789
|
+
}
|
|
790
|
+
async updateVpsMemo(uuid, data) {
|
|
791
|
+
return this.put(`${this.vpsServerPath(uuid)}/memo`, data);
|
|
792
|
+
}
|
|
793
|
+
async updateVpsName(uuid, data) {
|
|
794
|
+
return this.put(`${this.vpsServerPath(uuid)}/name`, data);
|
|
795
|
+
}
|
|
796
|
+
async updateVpsReverseDns(uuid, data) {
|
|
797
|
+
return this.put(`${this.vpsServerPath(uuid)}/reverse-dns`, data);
|
|
798
|
+
}
|
|
799
|
+
async getVpsPower(uuid) {
|
|
800
|
+
return this.get(`${this.vpsServerPath(uuid)}/power`);
|
|
801
|
+
}
|
|
802
|
+
async startVpsPower(uuid) {
|
|
803
|
+
return this.post(`${this.vpsServerPath(uuid)}/power/start`);
|
|
804
|
+
}
|
|
805
|
+
async rebootVpsPower(uuid, data) {
|
|
806
|
+
return this.post(`${this.vpsServerPath(uuid)}/power/reboot`, data);
|
|
807
|
+
}
|
|
808
|
+
async stopVpsPower(uuid) {
|
|
809
|
+
return this.post(`${this.vpsServerPath(uuid)}/power/stop`);
|
|
810
|
+
}
|
|
811
|
+
async getVpsPacketFilter(uuid) {
|
|
812
|
+
return this.get(`${this.vpsServerPath(uuid)}/packet-filter`);
|
|
813
|
+
}
|
|
814
|
+
async updateVpsPacketFilter(uuid, data) {
|
|
815
|
+
return this.put(`${this.vpsServerPath(uuid)}/packet-filter`, data);
|
|
816
|
+
}
|
|
817
|
+
async addVpsPacketFilterRule(uuid, data) {
|
|
818
|
+
return this.post(`${this.vpsServerPath(uuid)}/packet-filter/rules`, data);
|
|
819
|
+
}
|
|
820
|
+
async updateVpsPacketFilterRule(uuid, ruleId, data) {
|
|
821
|
+
return this.put(`${this.vpsServerPath(uuid)}/packet-filter/rules/${enc(ruleId)}`, data);
|
|
822
|
+
}
|
|
823
|
+
async deleteVpsPacketFilterRule(uuid, ruleId) {
|
|
824
|
+
return this.delete(`${this.vpsServerPath(uuid)}/packet-filter/rules/${enc(ruleId)}`);
|
|
825
|
+
}
|
|
826
|
+
async listVpsOsImages(uuid) {
|
|
827
|
+
return this.get(`${this.vpsServerPath(uuid)}/os-images`);
|
|
828
|
+
}
|
|
829
|
+
async reinstallVpsOs(uuid, data) {
|
|
830
|
+
return this.post(`${this.vpsServerPath(uuid)}/os-reinstall`, data);
|
|
831
|
+
}
|
|
832
|
+
async getVpsOsReinstall(uuid) {
|
|
833
|
+
return this.get(`${this.vpsServerPath(uuid)}/os-reinstall`);
|
|
834
|
+
}
|
|
835
|
+
async getVpsProtection(uuid) {
|
|
836
|
+
return this.get(`${this.vpsServerPath(uuid)}/protection`);
|
|
837
|
+
}
|
|
838
|
+
async updateVpsProtection(uuid, data) {
|
|
839
|
+
return this.put(`${this.vpsServerPath(uuid)}/protection`, data);
|
|
840
|
+
}
|
|
841
|
+
async listVpsPlans() {
|
|
842
|
+
return this.get("/v1/vps/plans");
|
|
843
|
+
}
|
|
844
|
+
async registerVps(data, idempotencyKey) {
|
|
845
|
+
return this.post("/v1/vps/servers", data, idempotencyHeaders(idempotencyKey));
|
|
846
|
+
}
|
|
847
|
+
async getVpsSignupStatus(id) {
|
|
848
|
+
return this.get(`/v1/vps/signup-status/${enc(id)}`);
|
|
849
|
+
}
|
|
850
|
+
// ================================================================
|
|
764
851
|
// HTTP 基盤
|
|
765
852
|
// ================================================================
|
|
766
853
|
async get(path2, params) {
|
|
@@ -811,12 +898,23 @@ var ApiClient = class {
|
|
|
811
898
|
const dbg = (msg) => process.stderr.write(`[DEBUG] ${msg}
|
|
812
899
|
`);
|
|
813
900
|
dbg(`HTTP ${response.status} ${response.statusText}`);
|
|
814
|
-
const debugHeaders = [
|
|
901
|
+
const debugHeaders = [
|
|
902
|
+
"x-ratelimit-limit",
|
|
903
|
+
"x-ratelimit-remaining",
|
|
904
|
+
"x-ratelimit-reset",
|
|
905
|
+
"x-concurrent-limit",
|
|
906
|
+
"x-concurrent-remaining",
|
|
907
|
+
"content-type",
|
|
908
|
+
"location"
|
|
909
|
+
];
|
|
815
910
|
for (const h of debugHeaders) {
|
|
816
911
|
const v = response.headers.get(h);
|
|
817
912
|
if (v !== null)
|
|
818
913
|
dbg(` ${h}: ${v}`);
|
|
819
914
|
}
|
|
915
|
+
const retryAfter = retryAfterSeconds(response);
|
|
916
|
+
if (retryAfter !== void 0)
|
|
917
|
+
dbg(` retry-after: ${retryAfter}`);
|
|
820
918
|
}
|
|
821
919
|
const rateLimitHeader = response.headers.get("x-ratelimit-limit");
|
|
822
920
|
if (rateLimitHeader) {
|
|
@@ -827,12 +925,17 @@ var ApiClient = class {
|
|
|
827
925
|
};
|
|
828
926
|
}
|
|
829
927
|
const text = await response.text();
|
|
928
|
+
if (response.status === 202 && text.trim() === "") {
|
|
929
|
+
const location = response.headers.get("location");
|
|
930
|
+
return { accepted: true, location };
|
|
931
|
+
}
|
|
830
932
|
let data;
|
|
831
933
|
try {
|
|
832
934
|
data = JSON.parse(text);
|
|
833
935
|
} catch {
|
|
834
936
|
if (this.debug) {
|
|
835
|
-
|
|
937
|
+
const bodyBytes = Buffer.byteLength(text, "utf8");
|
|
938
|
+
process.stderr.write(`[DEBUG] Response body omitted because it is not valid JSON (${bodyBytes} bytes)
|
|
836
939
|
`);
|
|
837
940
|
}
|
|
838
941
|
throw new ApiError(`Response parse error (HTTP ${response.status})`, response.status, "PARSE_ERROR", []);
|
|
@@ -841,7 +944,10 @@ var ApiClient = class {
|
|
|
841
944
|
const err = data;
|
|
842
945
|
const errorCode = err?.error?.code || "UNKNOWN_ERROR";
|
|
843
946
|
const errorMessage = err?.error?.message || "\u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F";
|
|
844
|
-
const errors = err?.error?.errors || [];
|
|
947
|
+
const errors = [...err?.error?.errors || []];
|
|
948
|
+
const retryGuidance = retryAfterGuidance(response);
|
|
949
|
+
if (retryGuidance)
|
|
950
|
+
errors.push(retryGuidance);
|
|
845
951
|
throw new ApiError(errorMessage, response.status, errorCode, errors);
|
|
846
952
|
}
|
|
847
953
|
return data;
|
|
@@ -933,6 +1039,13 @@ function compactDetails(details) {
|
|
|
933
1039
|
|
|
934
1040
|
// ../../shared/dist/brand-config.js
|
|
935
1041
|
function resolveServerPlanBrand(brand, service, planId) {
|
|
1042
|
+
if (service === "vps") {
|
|
1043
|
+
return {
|
|
1044
|
+
serviceName: brand.vpsServiceName,
|
|
1045
|
+
termsUrl: brand.vpsTermsUrl,
|
|
1046
|
+
privacyUrl: brand.vpsPrivacyUrl
|
|
1047
|
+
};
|
|
1048
|
+
}
|
|
936
1049
|
if (service === "server" && planId !== void 0) {
|
|
937
1050
|
const override = brand.serverPlanOverrides?.find((o) => planId.startsWith(o.planIdPrefix));
|
|
938
1051
|
if (override !== void 0) {
|
|
@@ -1347,6 +1460,62 @@ async function confirmDestructiveAction(cmd, message) {
|
|
|
1347
1460
|
process.exit(1);
|
|
1348
1461
|
}
|
|
1349
1462
|
}
|
|
1463
|
+
function osReinstallPhrase(uuid) {
|
|
1464
|
+
return `${uuid} \u306EOS\u518D\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB\u3092\u627F\u8A8D`;
|
|
1465
|
+
}
|
|
1466
|
+
function vpsOsImageName(response, imageId) {
|
|
1467
|
+
const images = Array.isArray(response) ? response : typeof response === "object" && response !== null ? response.os_images : void 0;
|
|
1468
|
+
if (!Array.isArray(images))
|
|
1469
|
+
return void 0;
|
|
1470
|
+
const image = images.find((candidate) => typeof candidate === "object" && candidate !== null && candidate.image_id === imageId);
|
|
1471
|
+
return typeof image?.name === "string" && image.name.length > 0 ? image.name : void 0;
|
|
1472
|
+
}
|
|
1473
|
+
function osReinstallConfirmationMessage(uuid, imageId, imageName) {
|
|
1474
|
+
const phrase = osReinstallPhrase(uuid);
|
|
1475
|
+
return [
|
|
1476
|
+
"OS\u518D\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB\u306F\u30B5\u30FC\u30D0\u30FC\u5185\u306E\u30C7\u30FC\u30BF\u30FB\u8A2D\u5B9A\u3092\u3059\u3079\u3066\u524A\u9664\u3057\u307E\u3059\u3002",
|
|
1477
|
+
`\u5BFE\u8C61 uuid: ${uuid}`,
|
|
1478
|
+
`\u30A4\u30E1\u30FC\u30B8ID: ${imageId}`,
|
|
1479
|
+
`OS\u30A4\u30E1\u30FC\u30B8: ${imageName}`,
|
|
1480
|
+
"\u8AA4\u64CD\u4F5C\u9632\u6B62: vps protection get/set \u3067 API \u304B\u3089\u306E\u518D\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB\u3092\u62D2\u5426\u3067\u304D\u307E\u3059\u3002",
|
|
1481
|
+
`\u7D9A\u884C\u3059\u308B\u5834\u5408\u306F\u6B21\u3092\u6B63\u78BA\u306B\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044: ${phrase}`,
|
|
1482
|
+
""
|
|
1483
|
+
].join("\n");
|
|
1484
|
+
}
|
|
1485
|
+
function isInteractiveTerminal() {
|
|
1486
|
+
return !!(input.isTTY && output.isTTY);
|
|
1487
|
+
}
|
|
1488
|
+
function hasYesFlag(cmd) {
|
|
1489
|
+
const root = findRoot(cmd);
|
|
1490
|
+
return !!(root.opts().yes || process.argv.includes("--yes") || process.argv.includes("-y"));
|
|
1491
|
+
}
|
|
1492
|
+
async function confirmOsReinstall(cmd, uuid, confirmReinstall, imageId, imageName, io = { input, output }) {
|
|
1493
|
+
if (!confirmReinstall) {
|
|
1494
|
+
throw new Error("OS\u518D\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB\u306B\u306F --confirm-reinstall \u304C\u5FC5\u8981\u3067\u3059\uFF08--yes \u5358\u72EC\u3067\u306F\u5B9F\u884C\u3067\u304D\u307E\u305B\u3093\uFF09\u3002\u8AA4\u64CD\u4F5C\u9632\u6B62\u306B\u306F vps protection set \u3067 os_reinstall \u3092\u6709\u52B9\u306B\u3067\u304D\u307E\u3059\u3002");
|
|
1495
|
+
}
|
|
1496
|
+
const tty = !!(io.input.isTTY && io.output.isTTY);
|
|
1497
|
+
if (!tty) {
|
|
1498
|
+
if (!hasYesFlag(cmd)) {
|
|
1499
|
+
throw new Error("\u975E\u5BFE\u8A71\u3067\u306EOS\u518D\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB\u306B\u306F --yes \u3068 --confirm-reinstall \u306E\u4E21\u65B9\u304C\u5FC5\u8981\u3067\u3059\u3002");
|
|
1500
|
+
}
|
|
1501
|
+
return;
|
|
1502
|
+
}
|
|
1503
|
+
const phrase = osReinstallPhrase(uuid);
|
|
1504
|
+
io.output.write(osReinstallConfirmationMessage(uuid, imageId, imageName));
|
|
1505
|
+
const rl = createInterface({
|
|
1506
|
+
input: io.input,
|
|
1507
|
+
output: io.output,
|
|
1508
|
+
terminal: true
|
|
1509
|
+
});
|
|
1510
|
+
try {
|
|
1511
|
+
const answer = (await rl.question("> ")).trim();
|
|
1512
|
+
if (answer !== phrase) {
|
|
1513
|
+
throw new BillingCancelledError("\u78BA\u8A8D\u6587\u5B57\u5217\u304C\u4E00\u81F4\u3057\u306A\u3044\u305F\u3081\u3001OS\u518D\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB\u3092\u4E2D\u6B62\u3057\u307E\u3057\u305F\u3002");
|
|
1514
|
+
}
|
|
1515
|
+
} finally {
|
|
1516
|
+
rl.close();
|
|
1517
|
+
}
|
|
1518
|
+
}
|
|
1350
1519
|
var defaultBillingConfirmationIo = { input, output };
|
|
1351
1520
|
function billingPurchasePhrase(subject, totalPrice) {
|
|
1352
1521
|
return `${subject} \u3092\u7A0E\u8FBC${formatYen(totalPrice)}\u3067\u627F\u8A8D`;
|
|
@@ -1485,11 +1654,19 @@ function pickDefined(obj) {
|
|
|
1485
1654
|
return result;
|
|
1486
1655
|
}
|
|
1487
1656
|
|
|
1657
|
+
// ../core/dist/lib/terminal-output.js
|
|
1658
|
+
import { stripVTControlCharacters } from "util";
|
|
1659
|
+
var LINE_BREAK_PATTERN = /[\r\n\u2028\u2029]+/g;
|
|
1660
|
+
var CONTROL_CHARACTER_PATTERN = /[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u009f]/g;
|
|
1661
|
+
function sanitizeTerminalText(value) {
|
|
1662
|
+
return stripVTControlCharacters(String(value)).replace(LINE_BREAK_PATTERN, " ").replace(CONTROL_CHARACTER_PATTERN, "");
|
|
1663
|
+
}
|
|
1664
|
+
|
|
1488
1665
|
// ../core/dist/commands/auth/login.js
|
|
1489
1666
|
import { password, select } from "@inquirer/prompts";
|
|
1490
1667
|
|
|
1491
1668
|
// ../core/dist/lib/auth-service-info.js
|
|
1492
|
-
var SERVICE_ORDER = ["server", "domain", "wphosting"];
|
|
1669
|
+
var SERVICE_ORDER = ["server", "domain", "wphosting", "vps"];
|
|
1493
1670
|
var NO_DEFAULT_SERVER = "__XSERVER_NO_DEFAULT_SERVER__";
|
|
1494
1671
|
function servernameChoices(targets) {
|
|
1495
1672
|
return [
|
|
@@ -1525,6 +1702,9 @@ function parseAuthApiKeyInfo(meData) {
|
|
|
1525
1702
|
if (name === "domain" && typeof block.allow_acquisition === "boolean") {
|
|
1526
1703
|
service.allowAcquisition = block.allow_acquisition;
|
|
1527
1704
|
}
|
|
1705
|
+
if ((name === "server" || name === "wphosting" || name === "vps") && typeof block.allow_signup === "boolean") {
|
|
1706
|
+
service.allowSignup = block.allow_signup;
|
|
1707
|
+
}
|
|
1528
1708
|
if (name === "wphosting") {
|
|
1529
1709
|
service.siteTargetMode = stringValue(block.site_target_mode, "unknown");
|
|
1530
1710
|
service.sites = strings(block.sites);
|
|
@@ -1548,19 +1728,30 @@ function permissionLabel(value) {
|
|
|
1548
1728
|
return "\u30AB\u30B9\u30BF\u30E0";
|
|
1549
1729
|
return value === "unknown" ? "\u4E0D\u660E" : value;
|
|
1550
1730
|
}
|
|
1731
|
+
function serviceLabel(name) {
|
|
1732
|
+
if (name === "server")
|
|
1733
|
+
return "Server";
|
|
1734
|
+
if (name === "domain")
|
|
1735
|
+
return "Domain";
|
|
1736
|
+
if (name === "wphosting")
|
|
1737
|
+
return "XServer for WordPress";
|
|
1738
|
+
return "VPS";
|
|
1739
|
+
}
|
|
1740
|
+
function targetLabel(name) {
|
|
1741
|
+
if (name === "server")
|
|
1742
|
+
return "\u5BFE\u8C61\u30B5\u30FC\u30D0\u30FC";
|
|
1743
|
+
if (name === "wphosting")
|
|
1744
|
+
return "\u5BFE\u8C61\u5951\u7D04";
|
|
1745
|
+
if (name === "vps")
|
|
1746
|
+
return "\u5BFE\u8C61VPS";
|
|
1747
|
+
return "\u5BFE\u8C61\u30C9\u30E1\u30A4\u30F3";
|
|
1748
|
+
}
|
|
1551
1749
|
function targetLines(service) {
|
|
1552
|
-
|
|
1553
|
-
if (service.targetMode === "all")
|
|
1554
|
-
return [" \u5BFE\u8C61\u5951\u7D04: \u3059\u3079\u3066"];
|
|
1555
|
-
return [" \u5BFE\u8C61\u5951\u7D04:", ...service.targets.map((target) => ` - ${target}`)];
|
|
1556
|
-
}
|
|
1557
|
-
const label = service.name === "server" ? "\u5BFE\u8C61\u30B5\u30FC\u30D0\u30FC" : "\u5BFE\u8C61\u30C9\u30E1\u30A4\u30F3";
|
|
1750
|
+
const label = targetLabel(service.name);
|
|
1558
1751
|
if (service.targetMode === "all") {
|
|
1559
1752
|
return [` ${label}: \u3059\u3079\u3066`];
|
|
1560
1753
|
}
|
|
1561
|
-
|
|
1562
|
-
lines.push(...service.targets.map((target) => ` - ${target}`));
|
|
1563
|
-
return lines;
|
|
1754
|
+
return [` ${label}:`, ...service.targets.map((target) => ` - ${target}`)];
|
|
1564
1755
|
}
|
|
1565
1756
|
function siteTargetLines(service) {
|
|
1566
1757
|
if (service.name !== "wphosting")
|
|
@@ -1576,14 +1767,16 @@ function formatAuthApiKeyInfo(info) {
|
|
|
1576
1767
|
lines.push(" \u306A\u3057");
|
|
1577
1768
|
}
|
|
1578
1769
|
for (const service of info.services) {
|
|
1579
|
-
|
|
1580
|
-
lines.push(` ${label}`);
|
|
1770
|
+
lines.push(` ${serviceLabel(service.name)}`);
|
|
1581
1771
|
lines.push(` \u6A29\u9650: ${permissionLabel(service.permissionType)}`);
|
|
1582
1772
|
lines.push(...targetLines(service));
|
|
1583
1773
|
lines.push(...siteTargetLines(service));
|
|
1584
1774
|
if (service.name === "domain" && service.allowAcquisition !== void 0) {
|
|
1585
1775
|
lines.push(` \u53D6\u5F97\u30FB\u79FB\u7BA1\u30FB\u66F4\u65B0: ${service.allowAcquisition ? "\u8A31\u53EF\u3055\u308C\u3066\u3044\u307E\u3059" : "\u8A31\u53EF\u3055\u308C\u3066\u3044\u307E\u305B\u3093"}`);
|
|
1586
1776
|
}
|
|
1777
|
+
if (service.allowSignup !== void 0) {
|
|
1778
|
+
lines.push(` \u65B0\u898F\u304A\u7533\u3057\u8FBC\u307F: ${service.allowSignup ? "\u8A31\u53EF\u3055\u308C\u3066\u3044\u307E\u3059" : "\u8A31\u53EF\u3055\u308C\u3066\u3044\u307E\u305B\u3093"}`);
|
|
1779
|
+
}
|
|
1587
1780
|
}
|
|
1588
1781
|
if (info.expiresAt) {
|
|
1589
1782
|
lines.push("", `API\u30AD\u30FC\u6709\u52B9\u671F\u9650: ${info.expiresAt}`);
|
|
@@ -3965,6 +4158,234 @@ function registerWphostingAccountCommands(parent, brand) {
|
|
|
3965
4158
|
});
|
|
3966
4159
|
}
|
|
3967
4160
|
|
|
4161
|
+
// ../core/dist/lib/vps-validation.js
|
|
4162
|
+
var UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
4163
|
+
var PACKET_FILTER_TYPES = [
|
|
4164
|
+
"ssh",
|
|
4165
|
+
"web",
|
|
4166
|
+
"web_http",
|
|
4167
|
+
"mysql",
|
|
4168
|
+
"postgresql",
|
|
4169
|
+
"mail",
|
|
4170
|
+
"rdp",
|
|
4171
|
+
"custom"
|
|
4172
|
+
];
|
|
4173
|
+
var PACKET_FILTER_PROTOCOLS = ["tcp", "udp", "icmp"];
|
|
4174
|
+
function isVpsSupportedBrand(brand) {
|
|
4175
|
+
return brand.brand === "xserver" || brand.brand === "shincloud";
|
|
4176
|
+
}
|
|
4177
|
+
function validateVpsUuid(value, optionName = "uuid") {
|
|
4178
|
+
if (!UUID_PATTERN.test(value)) {
|
|
4179
|
+
throw new Error(`${optionName} \u306F uuid\uFF088-4-4-4-12 \u306E\u5341\u516D\u9032\uFF09\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044`);
|
|
4180
|
+
}
|
|
4181
|
+
return value;
|
|
4182
|
+
}
|
|
4183
|
+
function validateVpsSignupId(value) {
|
|
4184
|
+
if (!/^[1-9]\d*$/.test(value)) {
|
|
4185
|
+
throw new Error("\u7533\u8FBC\u72B6\u6CC1\u306E id \u306F\u6B63\u306E\u6574\u6570\uFF08\u30B5\u30FC\u30D3\u30B9\u30B3\u30FC\u30C9\uFF09\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
4186
|
+
}
|
|
4187
|
+
return value;
|
|
4188
|
+
}
|
|
4189
|
+
function validateVpsRuleId(value) {
|
|
4190
|
+
if (!/^[1-9]\d*$/.test(value)) {
|
|
4191
|
+
throw new Error("rule_id \u306F\u6B63\u306E\u6574\u6570\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
4192
|
+
}
|
|
4193
|
+
return value;
|
|
4194
|
+
}
|
|
4195
|
+
function parseVpsBoolean(value, optionName) {
|
|
4196
|
+
return parseStrictBoolean(value, optionName);
|
|
4197
|
+
}
|
|
4198
|
+
function validateVpsPacketFilterType(value) {
|
|
4199
|
+
if (!PACKET_FILTER_TYPES.includes(value)) {
|
|
4200
|
+
throw new Error(`--type \u306F ${PACKET_FILTER_TYPES.join(" / ")} \u306E\u3044\u305A\u308C\u304B\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044`);
|
|
4201
|
+
}
|
|
4202
|
+
return value;
|
|
4203
|
+
}
|
|
4204
|
+
function validateVpsPacketFilterProtocol(value) {
|
|
4205
|
+
if (!PACKET_FILTER_PROTOCOLS.includes(value)) {
|
|
4206
|
+
throw new Error("--protocol \u306F tcp / udp / icmp \u306E\u3044\u305A\u308C\u304B\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
4207
|
+
}
|
|
4208
|
+
return value;
|
|
4209
|
+
}
|
|
4210
|
+
function validateVpsLength(value, optionName, maximum, minimum = 1) {
|
|
4211
|
+
if (value.length < minimum || value.length > maximum) {
|
|
4212
|
+
throw new Error(`${optionName} \u306F${minimum}\uFF5E${maximum}\u6587\u5B57\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044`);
|
|
4213
|
+
}
|
|
4214
|
+
return value;
|
|
4215
|
+
}
|
|
4216
|
+
|
|
4217
|
+
// ../core/dist/commands/vps/index.js
|
|
4218
|
+
function uuidArg(uuid) {
|
|
4219
|
+
return validateVpsUuid(uuid);
|
|
4220
|
+
}
|
|
4221
|
+
function registerVpsCommands(parent, brand) {
|
|
4222
|
+
parent.command("list").description("VPS\u4E00\u89A7\u3092\u53D6\u5F97").action(async () => {
|
|
4223
|
+
printResult(await resolveClient(parent, brand).listVpsServers(), getFormat(parent));
|
|
4224
|
+
});
|
|
4225
|
+
parent.command("info <uuid>").description("VPS\u8A73\u7D30\u3092\u53D6\u5F97").action(async (uuid) => {
|
|
4226
|
+
printResult(await resolveClient(parent, brand).getVpsServer(uuidArg(uuid)), getFormat(parent));
|
|
4227
|
+
});
|
|
4228
|
+
const memo = parent.command("memo").description("VPS\u30E1\u30E2");
|
|
4229
|
+
memo.command("update <uuid>").description("\u30E1\u30E2\u3092\u5909\u66F4\uFF08\u7A7A\u6587\u5B57\u3067\u524A\u9664\uFF09").requiredOption("--memo <memo>", "\u30E1\u30E2\uFF08\u6700\u5927500\u6587\u5B57\uFF09").action(async (uuid, opts) => {
|
|
4230
|
+
printResult(await resolveClient(parent, brand).updateVpsMemo(uuidArg(uuid), {
|
|
4231
|
+
memo: validateVpsLength(opts.memo, "--memo", 500, 0)
|
|
4232
|
+
}), getFormat(parent));
|
|
4233
|
+
});
|
|
4234
|
+
const name = parent.command("name").description("VPS\u30B5\u30FC\u30D0\u30FC\u540D");
|
|
4235
|
+
name.command("update <uuid>").description("\u30B5\u30FC\u30D0\u30FC\u540D\u3092\u5909\u66F4").requiredOption("--name <name>", "\u30B5\u30FC\u30D0\u30FC\u540D\uFF08\u6700\u592750\u6587\u5B57\uFF09").action(async (uuid, opts) => {
|
|
4236
|
+
printResult(await resolveClient(parent, brand).updateVpsName(uuidArg(uuid), {
|
|
4237
|
+
name: validateVpsLength(opts.name, "--name", 50)
|
|
4238
|
+
}), getFormat(parent));
|
|
4239
|
+
});
|
|
4240
|
+
const reverseDns = parent.command("reverse-dns").description("\u9006\u5F15\u304D\u30DB\u30B9\u30C8\u540D");
|
|
4241
|
+
reverseDns.command("update <uuid>").description("\u9006\u5F15\u304D\u30DB\u30B9\u30C8\u540D\u3092\u5909\u66F4").requiredOption("--hostname <hostname>", "\u9006\u5F15\u304D\u30DB\u30B9\u30C8\u540D").action(async (uuid, opts) => {
|
|
4242
|
+
printResult(await resolveClient(parent, brand).updateVpsReverseDns(uuidArg(uuid), {
|
|
4243
|
+
hostname: validateVpsLength(opts.hostname, "--hostname", 253)
|
|
4244
|
+
}), getFormat(parent));
|
|
4245
|
+
});
|
|
4246
|
+
const power = parent.command("power").description("\u96FB\u6E90\u64CD\u4F5C\uFF08start/reboot/stop \u306F 202 Accepted\u3002\u9032\u6357\u306F power status \u3067\u78BA\u8A8D\uFF09");
|
|
4247
|
+
power.command("status <uuid>").description("\u96FB\u6E90\u72B6\u614B\u3092\u53D6\u5F97").action(async (uuid) => {
|
|
4248
|
+
printResult(await resolveClient(parent, brand).getVpsPower(uuidArg(uuid)), getFormat(parent));
|
|
4249
|
+
});
|
|
4250
|
+
power.command("start <uuid>").description("VPS\u3092\u8D77\u52D5").action(async (uuid) => {
|
|
4251
|
+
printResult(await resolveClient(parent, brand).startVpsPower(uuidArg(uuid)), getFormat(parent));
|
|
4252
|
+
});
|
|
4253
|
+
power.command("reboot <uuid>").description("VPS\u3092\u518D\u8D77\u52D5").option("--force", "\u5F37\u5236\u518D\u8D77\u52D5\uFF08\u96FB\u6E90\u65AD\u76F8\u5F53\u3002\u901A\u5E38\u306E\u518D\u8D77\u52D5\u3067\u5FDC\u7B54\u304C\u306A\u3044\u5834\u5408\uFF09").action(async (uuid, opts) => {
|
|
4254
|
+
const id = uuidArg(uuid);
|
|
4255
|
+
if (opts.force) {
|
|
4256
|
+
await confirmDestructiveAction(parent, `VPS ${id} \u3092\u5F37\u5236\u518D\u8D77\u52D5\u3057\u307E\u3059\uFF08\u96FB\u6E90\u65AD\u76F8\u5F53\uFF09\u3002\u3088\u308D\u3057\u3044\u3067\u3059\u304B\uFF1F`);
|
|
4257
|
+
}
|
|
4258
|
+
printResult(await resolveClient(parent, brand).rebootVpsPower(id, opts.force ? { force: true } : void 0), getFormat(parent));
|
|
4259
|
+
});
|
|
4260
|
+
power.command("stop <uuid>").description("VPS\u3092\u505C\u6B62").action(async (uuid) => {
|
|
4261
|
+
printResult(await resolveClient(parent, brand).stopVpsPower(uuidArg(uuid)), getFormat(parent));
|
|
4262
|
+
});
|
|
4263
|
+
const packetFilter = parent.command("packet-filter").description("\u30D1\u30B1\u30C3\u30C8\u30D5\u30A3\u30EB\u30BF\u30FC");
|
|
4264
|
+
packetFilter.command("get <uuid>").description("\u30D1\u30B1\u30C3\u30C8\u30D5\u30A3\u30EB\u30BF\u30FC\u8A2D\u5B9A\u3092\u53D6\u5F97").action(async (uuid) => {
|
|
4265
|
+
printResult(await resolveClient(parent, brand).getVpsPacketFilter(uuidArg(uuid)), getFormat(parent));
|
|
4266
|
+
});
|
|
4267
|
+
packetFilter.command("update <uuid>").description("\u30D1\u30B1\u30C3\u30C8\u30D5\u30A3\u30EB\u30BF\u30FC\u306E\u6709\u52B9/\u7121\u52B9\u3092\u5207\u66FF").requiredOption("--enabled <bool>", "true \u3067\u6709\u52B9 / false \u3067\u7121\u52B9").action(async (uuid, opts) => {
|
|
4268
|
+
printResult(await resolveClient(parent, brand).updateVpsPacketFilter(uuidArg(uuid), {
|
|
4269
|
+
enabled: parseVpsBoolean(opts.enabled, "--enabled")
|
|
4270
|
+
}), getFormat(parent));
|
|
4271
|
+
});
|
|
4272
|
+
packetFilter.command("add-rule <uuid>").description("\u30EB\u30FC\u30EB\u3092\u8FFD\u52A0").requiredOption("--type <type>", "ssh / web / web_http / mysql / postgresql / mail / rdp / custom").option("--protocol <protocol>", "tcp / udp / icmp\uFF08custom \u306F\u5FC5\u9808\uFF09").option("--port <port>", "\u30DD\u30FC\u30C8\u307E\u305F\u306F\u7BC4\u56F2\uFF08custom \u306F icmp \u4EE5\u5916\u3067\u5FC5\u9808\uFF09").option("--allowed-ip <cidr>", "\u8A31\u53EF\u3059\u308B\u63A5\u7D9A\u5143\uFF08custom \u306E\u307F\uFF09").option("--memo <memo>", "\u30E1\u30E2\uFF08custom \u306E\u307F\uFF09").action(async (uuid, opts) => {
|
|
4273
|
+
printResult(await resolveClient(parent, brand).addVpsPacketFilterRule(uuidArg(uuid), {
|
|
4274
|
+
type: validateVpsPacketFilterType(opts.type),
|
|
4275
|
+
...pickDefined({
|
|
4276
|
+
protocol: opts.protocol === void 0 ? void 0 : validateVpsPacketFilterProtocol(opts.protocol),
|
|
4277
|
+
port: opts.port,
|
|
4278
|
+
allowed_ip: opts.allowedIp,
|
|
4279
|
+
memo: opts.memo
|
|
4280
|
+
})
|
|
4281
|
+
}), getFormat(parent));
|
|
4282
|
+
});
|
|
4283
|
+
packetFilter.command("update-rule <uuid> <ruleId>").description("\u30EB\u30FC\u30EB\u3092\u5909\u66F4").option("--protocol <protocol>", "tcp / udp / icmp").option("--port <port>", "\u30DD\u30FC\u30C8\u307E\u305F\u306F\u7BC4\u56F2").option("--allowed-ip <cidr>", "\u8A31\u53EF\u3059\u308B\u63A5\u7D9A\u5143").option("--memo <memo>", "\u30E1\u30E2").action(async (uuid, ruleId, opts) => {
|
|
4284
|
+
const data = pickDefined({
|
|
4285
|
+
protocol: opts.protocol === void 0 ? void 0 : validateVpsPacketFilterProtocol(opts.protocol),
|
|
4286
|
+
port: opts.port,
|
|
4287
|
+
allowed_ip: opts.allowedIp,
|
|
4288
|
+
memo: opts.memo
|
|
4289
|
+
});
|
|
4290
|
+
if (Object.keys(data).length === 0) {
|
|
4291
|
+
throw new Error("\u66F4\u65B0\u9805\u76EE\u30921\u3064\u4EE5\u4E0A\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
4292
|
+
}
|
|
4293
|
+
printResult(await resolveClient(parent, brand).updateVpsPacketFilterRule(uuidArg(uuid), validateVpsRuleId(ruleId), data), getFormat(parent));
|
|
4294
|
+
});
|
|
4295
|
+
packetFilter.command("delete-rule <uuid> <ruleId>").description("\u30EB\u30FC\u30EB\u3092\u524A\u9664").action(async (uuid, ruleId) => {
|
|
4296
|
+
const id = validateVpsRuleId(ruleId);
|
|
4297
|
+
await confirmDestructiveAction(parent, `\u30D1\u30B1\u30C3\u30C8\u30D5\u30A3\u30EB\u30BF\u30FC\u306E\u30EB\u30FC\u30EB ${id} \u3092\u524A\u9664\u3057\u307E\u3059\u3002\u3088\u308D\u3057\u3044\u3067\u3059\u304B\uFF1F`);
|
|
4298
|
+
printResult(await resolveClient(parent, brand).deleteVpsPacketFilterRule(uuidArg(uuid), id), getFormat(parent));
|
|
4299
|
+
});
|
|
4300
|
+
parent.command("os-images").description("\u518D\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB\u3067\u304D\u308B\u30A4\u30E1\u30FC\u30B8\u4E00\u89A7\u3092\u53D6\u5F97").argument("<uuid>", "VPS\u306E uuid").action(async (uuid) => {
|
|
4301
|
+
printResult(await resolveClient(parent, brand).listVpsOsImages(uuidArg(uuid)), getFormat(parent));
|
|
4302
|
+
});
|
|
4303
|
+
const osReinstall = parent.command("os-reinstall").description("OS\u518D\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB\uFF08\u30C7\u30FC\u30BF\u5168\u6D88\u53BB\u3002protection \u3067\u62D2\u5426\u3067\u304D\u307E\u3059\uFF09");
|
|
4304
|
+
osReinstall.command("run <uuid>").description("OS\u3092\u518D\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB\uFF08\u505C\u6B62\u4E2D\u306EVPS\u304C\u5BFE\u8C61\u3002--yes \u5358\u72EC\u3067\u306F\u5B9F\u884C\u4E0D\u53EF\uFF09").requiredOption("--image-id <id>", "\u30A4\u30E1\u30FC\u30B8ID\uFF08os-images \u306E image_id\uFF09").requiredOption("--root-password <password>", "\u7BA1\u7406\u8005\u30D1\u30B9\u30EF\u30FC\u30C9\uFF089\u301C70\u6587\u5B57\uFF09").option("--ssh-key-name <name>", "\u767B\u9332\u6E08\u307FSSH\u30AD\u30FC\u540D").option("--ssh-public-key <key>", "\u767B\u9332\u3059\u308B\u516C\u958B\u9375\uFF08ssh-key-name \u3068\u4F75\u7528\uFF09").option("--basic-password <password>", "\u7BA1\u7406\u30C4\u30FC\u30EBBasic\u8A8D\u8A3C\uFF08requires_basic_password \u306E\u30A4\u30E1\u30FC\u30B8\u306E\u307F\uFF09").option("--confirm-reinstall", "\u30C7\u30FC\u30BF\u5168\u6D88\u53BB\u3092\u627F\u8A8D\uFF08\u5FC5\u9808\u3002--yes \u3067\u306F\u7701\u7565\u4E0D\u53EF\uFF09").action(async (uuid, opts) => {
|
|
4305
|
+
const id = uuidArg(uuid);
|
|
4306
|
+
const rootPassword = validateVpsLength(opts.rootPassword, "--root-password", 70, 9);
|
|
4307
|
+
const client2 = resolveClient(parent, brand);
|
|
4308
|
+
let imageName = opts.imageId;
|
|
4309
|
+
if (opts.confirmReinstall === true && isInteractiveTerminal()) {
|
|
4310
|
+
imageName = vpsOsImageName(await client2.listVpsOsImages(id), opts.imageId) ?? "";
|
|
4311
|
+
if (!imageName) {
|
|
4312
|
+
throw new Error(`--image-id ${opts.imageId} \u306EOS\u30A4\u30E1\u30FC\u30B8\u540D\u3092\u53D6\u5F97\u3067\u304D\u306A\u3044\u305F\u3081\u3001\u518D\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB\u3092\u4E2D\u6B62\u3057\u307E\u3057\u305F\u3002`);
|
|
4313
|
+
}
|
|
4314
|
+
}
|
|
4315
|
+
await confirmOsReinstall(parent, id, opts.confirmReinstall === true, opts.imageId, imageName);
|
|
4316
|
+
printResult(await client2.reinstallVpsOs(id, {
|
|
4317
|
+
image_id: opts.imageId,
|
|
4318
|
+
root_password: rootPassword,
|
|
4319
|
+
...pickDefined({
|
|
4320
|
+
ssh_key_name: opts.sshKeyName,
|
|
4321
|
+
ssh_public_key: opts.sshPublicKey,
|
|
4322
|
+
basic_password: opts.basicPassword
|
|
4323
|
+
})
|
|
4324
|
+
}), getFormat(parent));
|
|
4325
|
+
});
|
|
4326
|
+
osReinstall.command("status <uuid>").description("OS\u518D\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB\u306E\u72B6\u6CC1\u3092\u78BA\u8A8D").action(async (uuid) => {
|
|
4327
|
+
printResult(await resolveClient(parent, brand).getVpsOsReinstall(uuidArg(uuid)), getFormat(parent));
|
|
4328
|
+
});
|
|
4329
|
+
const protection = parent.command("protection").description("\u64CD\u4F5C\u4FDD\u8B77\uFF08API\u304B\u3089\u306EOS\u518D\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB\u3092VPS\u5358\u4F4D\u3067\u62D2\u5426\uFF09");
|
|
4330
|
+
protection.command("get <uuid>").description("\u64CD\u4F5C\u4FDD\u8B77\u306E\u8A2D\u5B9A\u3092\u53D6\u5F97").action(async (uuid) => {
|
|
4331
|
+
printResult(await resolveClient(parent, brand).getVpsProtection(uuidArg(uuid)), getFormat(parent));
|
|
4332
|
+
});
|
|
4333
|
+
protection.command("set <uuid>").description("\u64CD\u4F5C\u4FDD\u8B77\u306E\u8A2D\u5B9A\u3092\u5909\u66F4").requiredOption("--os-reinstall <bool>", "true \u3067\u518D\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB\u3092\u62D2\u5426 / false \u3067\u89E3\u9664").action(async (uuid, opts) => {
|
|
4334
|
+
printResult(await resolveClient(parent, brand).updateVpsProtection(uuidArg(uuid), {
|
|
4335
|
+
os_reinstall: parseVpsBoolean(opts.osReinstall, "--os-reinstall")
|
|
4336
|
+
}), getFormat(parent));
|
|
4337
|
+
});
|
|
4338
|
+
parent.command("plans").description("\u304A\u7533\u3057\u8FBC\u307F\u53EF\u80FD\u306A\u30D7\u30E9\u30F3\u30FB\u6599\u91D1\u3092\u53D6\u5F97").action(async () => {
|
|
4339
|
+
printResult(await resolveClient(parent, brand).listVpsPlans(), getFormat(parent));
|
|
4340
|
+
});
|
|
4341
|
+
parent.command("signup-status <id>").description("\u304A\u7533\u3057\u8FBC\u307F\u72B6\u6CC1\u3092\u78BA\u8A8D\uFF08id \u306F\u7533\u8FBC\u5FDC\u7B54\u306E\u30B5\u30FC\u30D3\u30B9\u30B3\u30FC\u30C9\uFF09").action(async (id) => {
|
|
4342
|
+
printResult(await resolveClient(parent, brand).getVpsSignupStatus(validateVpsSignupId(id)), getFormat(parent));
|
|
4343
|
+
});
|
|
4344
|
+
parent.command("signup").description(brand.brand === "shincloud" ? "\u30B7\u30F3VPS\u3092\u65B0\u898F\u304A\u7533\u3057\u8FBC\u307F\uFF08\u30B9\u30BF\u30F3\u30C0\u30FC\u30C9\u30FB\u5927\u5BB9\u91CF\u30E1\u30E2\u30EA\u3002\u30D7\u30EA\u30DA\u30A4\u30C9\u306E\u307F\uFF09" : "VPS\u3092\u65B0\u898F\u304A\u7533\u3057\u8FBC\u307F\uFF08VPS\u30FB\u30D3\u30B8\u30CD\u30B9VPS\u3002\u30D7\u30EA\u30DA\u30A4\u30C9\u306E\u307F\uFF09").requiredOption("--plan-id <id>", brand.brand === "shincloud" ? "\u30D7\u30E9\u30F3ID\uFF08vps-2gb / vps-highmem-4gb \u306A\u3069\uFF09" : "\u30D7\u30E9\u30F3ID\uFF08vps-4gb / business-4gb \u306A\u3069\uFF09").requiredOption("--period <months>", "\u5951\u7D04\u671F\u9593\uFF08\u6708\u6570\u3002plans \u304C\u8FD4\u3057\u305F months \u304B\u3089\u6307\u5B9A\uFF09").requiredOption("--image-id <id>", "OS\u30A4\u30E1\u30FC\u30B8ID\uFF08plans \u306E os_images[].image_id\uFF09").requiredOption("--root-password <password>", "root\u30D1\u30B9\u30EF\u30FC\u30C9\uFF089\u301C70\u6587\u5B57\uFF09").requiredOption("--expected-total-price <yen>", "plans \u304C\u8FD4\u3057\u305F\u7A0E\u8FBC\u5408\u8A08\u91D1\u984D").option("--name <name>", "\u30B5\u30FC\u30D0\u30FC\u540D").option("--ssh-key-name <name>", "\u767B\u9332\u6E08\u307FSSH\u30AD\u30FC\u540D").option("--ssh-public-key <key>", "\u767B\u9332\u3059\u308B\u516C\u958B\u9375\uFF08ssh-key-name \u3068\u4F75\u7528\uFF09").option("--partner-code <code>", "\u304A\u53D6\u6B21\u5E97\u30B3\u30FC\u30C9").option("--auto-renew <bool>", "\u81EA\u52D5\u66F4\u65B0\uFF08true / false\u3002\u7701\u7565\u6642\u306F true\uFF09").option("--dry-run", "\u30D7\u30EC\u30D3\u30E5\u30FC\u306E\u307F\u5B9F\u884C").option("--confirm-purchase", "\u8AB2\u91D1\u3092\u4F34\u3046\u7533\u8ACB\u3092\u660E\u793A\u7684\u306B\u78BA\u8A8D").option("--agree-to-terms", "\u5229\u7528\u898F\u7D04\u306B\u540C\u610F").option("--idempotency-key <key>", "\u5B9F\u7533\u8ACB\u306E\u51AA\u7B49\u6027\u30AD\u30FC\uFF08\u82F1\u6570\u5B57\u30FB_\u30FB-\u306E8\uFF5E64\u6587\u5B57\uFF09").action(async (opts) => {
|
|
4345
|
+
const expectedTotalPrice = parseInteger(opts.expectedTotalPrice, "--expected-total-price", 0);
|
|
4346
|
+
const period = parseSignupPeriod(opts.period);
|
|
4347
|
+
const partnerCode = opts.partnerCode === void 0 ? void 0 : validatePartnerCode(opts.partnerCode);
|
|
4348
|
+
const autoRenew = opts.autoRenew === void 0 ? void 0 : parseAutoRenew(opts.autoRenew);
|
|
4349
|
+
const baseData = {
|
|
4350
|
+
plan_id: opts.planId,
|
|
4351
|
+
period,
|
|
4352
|
+
image_id: opts.imageId,
|
|
4353
|
+
root_password: validateVpsLength(opts.rootPassword, "--root-password", 70, 9),
|
|
4354
|
+
expected_total_price: expectedTotalPrice,
|
|
4355
|
+
agree_to_terms: true,
|
|
4356
|
+
...pickDefined({
|
|
4357
|
+
name: opts.name,
|
|
4358
|
+
ssh_key_name: opts.sshKeyName,
|
|
4359
|
+
ssh_public_key: opts.sshPublicKey,
|
|
4360
|
+
partner_code: partnerCode,
|
|
4361
|
+
auto_renew: autoRenew
|
|
4362
|
+
})
|
|
4363
|
+
};
|
|
4364
|
+
const client2 = resolveClient(parent, brand);
|
|
4365
|
+
await runBillingPurchase({
|
|
4366
|
+
format: getFormat(parent),
|
|
4367
|
+
options: opts,
|
|
4368
|
+
operation: signupOperationName(brand, "vps", opts.planId),
|
|
4369
|
+
targetLabel: "\u7533\u8FBC\u5185\u5BB9",
|
|
4370
|
+
resolveTarget: async () => {
|
|
4371
|
+
const planName = await resolvePlanName(() => client2.listVpsPlans(), opts.planId);
|
|
4372
|
+
return {
|
|
4373
|
+
target: `${planLabel(opts.planId, planName)} / \u5951\u7D04\u671F\u9593 ${period}\u304B\u6708 / ${opts.imageId}`,
|
|
4374
|
+
confirmSubject: `${planName ?? opts.planId} ${period}\u304B\u6708`
|
|
4375
|
+
};
|
|
4376
|
+
},
|
|
4377
|
+
details: compactDetails([
|
|
4378
|
+
autoRenewDetail(autoRenew ?? true, { fromDefault: autoRenew === void 0 }),
|
|
4379
|
+
partnerCodeDetail(partnerCode)
|
|
4380
|
+
]),
|
|
4381
|
+
legalNoticeLines: signupLegalNoticeLines(brand, "vps", opts.planId),
|
|
4382
|
+
statusCommand: `${brand.commandName} vps signup-status <id>`,
|
|
4383
|
+
preview: () => client2.registerVps({ ...baseData, dry_run: true }),
|
|
4384
|
+
execute: (idempotencyKey) => client2.registerVps({ ...baseData, dry_run: false }, idempotencyKey)
|
|
4385
|
+
});
|
|
4386
|
+
});
|
|
4387
|
+
}
|
|
4388
|
+
|
|
3968
4389
|
// ../core/dist/index.js
|
|
3969
4390
|
function createProgram(brand, version = "0.0.0") {
|
|
3970
4391
|
const program = new Command();
|
|
@@ -3981,6 +4402,10 @@ function createProgram(brand, version = "0.0.0") {
|
|
|
3981
4402
|
registerWphostingAccountCommands(wphosting, brand);
|
|
3982
4403
|
registerWphostingCommands(wphosting, brand);
|
|
3983
4404
|
}
|
|
4405
|
+
if (isVpsSupportedBrand(brand)) {
|
|
4406
|
+
const vps = program.command("vps").description(brand.brand === "shincloud" ? "VPS API\uFF08\u30B7\u30F3VPS\uFF09" : "VPS API\uFF08XServer VPS\uFF09");
|
|
4407
|
+
registerVpsCommands(vps, brand);
|
|
4408
|
+
}
|
|
3984
4409
|
const domain = program.command("domain").description("\u30C9\u30E1\u30A4\u30F3\u30B5\u30FC\u30D3\u30B9API\uFF08\u53D6\u5F97\u30FB\u5951\u7D04\u30FBDNS\u30FBWhois\u306A\u3069\uFF09");
|
|
3985
4410
|
registerDomainCommands(domain, brand);
|
|
3986
4411
|
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");
|
|
@@ -4029,10 +4454,10 @@ function run(brand, version = "0.0.0") {
|
|
|
4029
4454
|
}
|
|
4030
4455
|
};
|
|
4031
4456
|
if (err instanceof ApiError) {
|
|
4032
|
-
console.error(`\u30A8\u30E9\u30FC [${err.errorCode}]: ${err.message}`);
|
|
4457
|
+
console.error(`\u30A8\u30E9\u30FC [${sanitizeTerminalText(err.errorCode)}]: ${sanitizeTerminalText(err.message)}`);
|
|
4033
4458
|
if (err.errors.length > 0) {
|
|
4034
4459
|
for (const e of err.errors) {
|
|
4035
|
-
console.error(` - ${e}`);
|
|
4460
|
+
console.error(` - ${sanitizeTerminalText(e)}`);
|
|
4036
4461
|
}
|
|
4037
4462
|
}
|
|
4038
4463
|
printResendGuidance();
|
|
@@ -4059,7 +4484,7 @@ function run(brand, version = "0.0.0") {
|
|
|
4059
4484
|
// package.json
|
|
4060
4485
|
var package_default = {
|
|
4061
4486
|
name: "star8-cli",
|
|
4062
|
-
version: "1.
|
|
4487
|
+
version: "1.5.0",
|
|
4063
4488
|
description: "Official CLI for Star8 API \u2014 manage your Star8 hosting from the terminal",
|
|
4064
4489
|
type: "module",
|
|
4065
4490
|
bin: {
|