@inblog/cli 0.2.0 → 0.2.1
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/bin/inblog.js +155 -8
- package/dist/bin/inblog.js.map +1 -1
- package/dist/sdk/index.d.mts +1 -1
- package/dist/sdk/index.d.ts +1 -1
- package/dist/sdk/index.js +3 -3
- package/dist/sdk/index.js.map +1 -1
- package/dist/sdk/index.mjs +3 -3
- package/dist/sdk/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/bin/inblog.js
CHANGED
|
@@ -712,11 +712,11 @@ var BlogsEndpoint = class {
|
|
|
712
712
|
async me() {
|
|
713
713
|
return this.client.get("/v1/blogs/me");
|
|
714
714
|
}
|
|
715
|
-
async update(
|
|
715
|
+
async update(input) {
|
|
716
716
|
return this.client.update(
|
|
717
|
-
|
|
717
|
+
"/v1/blogs/me",
|
|
718
718
|
"blogs",
|
|
719
|
-
|
|
719
|
+
"me",
|
|
720
720
|
input
|
|
721
721
|
);
|
|
722
722
|
}
|
|
@@ -1556,6 +1556,123 @@ function registerAuthorsCommands(program2) {
|
|
|
1556
1556
|
|
|
1557
1557
|
// src/commands/blogs.ts
|
|
1558
1558
|
var import_prompts2 = require("@inquirer/prompts");
|
|
1559
|
+
|
|
1560
|
+
// src/utils/domain.ts
|
|
1561
|
+
var import_promises = __toESM(require("dns/promises"));
|
|
1562
|
+
var MULTI_PART_TLDS = [
|
|
1563
|
+
".co.uk",
|
|
1564
|
+
".co.kr",
|
|
1565
|
+
".co.jp",
|
|
1566
|
+
".co.nz",
|
|
1567
|
+
".co.za",
|
|
1568
|
+
".co.in",
|
|
1569
|
+
".co.id",
|
|
1570
|
+
".com.au",
|
|
1571
|
+
".com.br",
|
|
1572
|
+
".com.cn",
|
|
1573
|
+
".com.mx",
|
|
1574
|
+
".com.tw",
|
|
1575
|
+
".com.sg",
|
|
1576
|
+
".net.au",
|
|
1577
|
+
".net.br",
|
|
1578
|
+
".net.cn",
|
|
1579
|
+
".org.uk",
|
|
1580
|
+
".org.au",
|
|
1581
|
+
".org.br",
|
|
1582
|
+
".ac.uk",
|
|
1583
|
+
".ac.kr",
|
|
1584
|
+
".ac.jp",
|
|
1585
|
+
".ne.jp",
|
|
1586
|
+
".or.jp",
|
|
1587
|
+
".or.kr",
|
|
1588
|
+
".gov.uk",
|
|
1589
|
+
".gov.au",
|
|
1590
|
+
".gov.br",
|
|
1591
|
+
".edu.au",
|
|
1592
|
+
".edu.cn"
|
|
1593
|
+
];
|
|
1594
|
+
function getRootDomain(domain) {
|
|
1595
|
+
const lower = domain.toLowerCase();
|
|
1596
|
+
const multiTld = MULTI_PART_TLDS.find((tld) => lower.endsWith(tld));
|
|
1597
|
+
if (multiTld) {
|
|
1598
|
+
const withoutTld = lower.slice(0, -multiTld.length);
|
|
1599
|
+
const parts2 = withoutTld.split(".").filter(Boolean);
|
|
1600
|
+
return parts2[parts2.length - 1] + multiTld;
|
|
1601
|
+
}
|
|
1602
|
+
const parts = lower.split(".");
|
|
1603
|
+
return parts.slice(-2).join(".");
|
|
1604
|
+
}
|
|
1605
|
+
function isSubdomain(domain) {
|
|
1606
|
+
if (!domain) return false;
|
|
1607
|
+
const lower = domain.toLowerCase();
|
|
1608
|
+
const multiTld = MULTI_PART_TLDS.find((tld) => lower.endsWith(tld));
|
|
1609
|
+
if (multiTld) {
|
|
1610
|
+
const withoutTld = lower.slice(0, -multiTld.length);
|
|
1611
|
+
return withoutTld.includes(".");
|
|
1612
|
+
}
|
|
1613
|
+
return domain.split(".").length > 2;
|
|
1614
|
+
}
|
|
1615
|
+
async function lookupNameservers(domain) {
|
|
1616
|
+
const rootDomain = getRootDomain(domain);
|
|
1617
|
+
try {
|
|
1618
|
+
return await import_promises.default.resolveNs(rootDomain);
|
|
1619
|
+
} catch {
|
|
1620
|
+
return [];
|
|
1621
|
+
}
|
|
1622
|
+
}
|
|
1623
|
+
var DNS_PROVIDER_MAP = [
|
|
1624
|
+
[["godaddy", "domaincontrol"], "GoDaddy"],
|
|
1625
|
+
[["namecheap", "registrar-servers.com"], "Namecheap"],
|
|
1626
|
+
[["cloudflare"], "Cloudflare"],
|
|
1627
|
+
[["googledomains", "google.com"], "Google Domains"],
|
|
1628
|
+
[["awsdns", "amazon"], "AWS (Route 53)"],
|
|
1629
|
+
[["bluehost"], "Bluehost"],
|
|
1630
|
+
[["siteground"], "SiteGround"],
|
|
1631
|
+
[["hostgator"], "HostGator"],
|
|
1632
|
+
[["dreamhost"], "DreamHost"],
|
|
1633
|
+
[["name.com"], "Name.com"],
|
|
1634
|
+
[["gandi"], "Gandi"],
|
|
1635
|
+
[["gabia"], "Gabia"],
|
|
1636
|
+
[["whois"], "Whois"],
|
|
1637
|
+
[["cafe24"], "Cafe24"],
|
|
1638
|
+
[["imweb"], "Imweb"],
|
|
1639
|
+
[["xinnet"], "Xinnet"],
|
|
1640
|
+
[["aliyun", "alidns"], "Aliyun"],
|
|
1641
|
+
[["dnspod", "qcloud"], "Tencent Cloud"]
|
|
1642
|
+
];
|
|
1643
|
+
function detectDnsProvider(nameservers) {
|
|
1644
|
+
if (nameservers.length === 0) return null;
|
|
1645
|
+
const nsString = nameservers.join(",").toLowerCase();
|
|
1646
|
+
for (const [keywords, provider] of DNS_PROVIDER_MAP) {
|
|
1647
|
+
if (keywords.some((kw) => nsString.includes(kw))) return provider;
|
|
1648
|
+
}
|
|
1649
|
+
return null;
|
|
1650
|
+
}
|
|
1651
|
+
var DNS_PROVIDER_GUIDES = {
|
|
1652
|
+
GoDaddy: "https://www.godaddy.com/help/add-a-cname-record-19236",
|
|
1653
|
+
Namecheap: "https://www.namecheap.com/support/knowledgebase/article.aspx/434/2237/how-do-i-set-up-host-records-for-a-domain/",
|
|
1654
|
+
Cloudflare: "https://developers.cloudflare.com/dns/manage-dns-records/how-to/create-dns-records/",
|
|
1655
|
+
"Google Domains": "https://support.google.com/domains/answer/3290350",
|
|
1656
|
+
"AWS (Route 53)": "https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/resource-record-sets-creating.html",
|
|
1657
|
+
Bluehost: "https://www.bluehost.com/help/article/dns-management-add-edit-or-delete-dns-entries",
|
|
1658
|
+
SiteGround: "https://www.siteground.com/kb/how_to_manage_dns_records/",
|
|
1659
|
+
HostGator: "https://www.hostgator.com/help/article/how-to-change-dns-zones-mx-cname-and-a-records",
|
|
1660
|
+
DreamHost: "https://help.dreamhost.com/hc/en-us/articles/215413857-DreamHost-DNS-overview",
|
|
1661
|
+
"Name.com": "https://www.name.com/support/articles/205934458-Adding-a-CNAME-Record",
|
|
1662
|
+
Gandi: "https://docs.gandi.net/en/domain_names/common_operations/dns_records.html",
|
|
1663
|
+
Gabia: "https://customer.gabia.com/manual/dns/3041/3040",
|
|
1664
|
+
Whois: "https://cs.whois.co.kr/manual/?p=view&page=1&number=435&keyfield=sub_cont&keyword=dns",
|
|
1665
|
+
Cafe24: "https://help.cafe24.com/docs/domain/domain-hosting-external-service-connection/",
|
|
1666
|
+
Imweb: "https://imweb.me/qna?mode=faq&q=71897",
|
|
1667
|
+
Xinnet: "http://www.xinnet.com/service/cjwt/yuming/guanli/1485.html",
|
|
1668
|
+
Aliyun: "https://www.alibabacloud.com/help/en/dns/user-guide/add-a-dns-record",
|
|
1669
|
+
"Tencent Cloud": "https://www.tencentcloud.com/document/product/302/3446"
|
|
1670
|
+
};
|
|
1671
|
+
function getDnsProviderGuide(provider) {
|
|
1672
|
+
return DNS_PROVIDER_GUIDES[provider] || null;
|
|
1673
|
+
}
|
|
1674
|
+
|
|
1675
|
+
// src/commands/blogs.ts
|
|
1559
1676
|
function registerBlogsCommands(program2) {
|
|
1560
1677
|
const blogs = program2.command("blogs").description("Manage blogs \u2014 list, switch, view, and update blog settings");
|
|
1561
1678
|
blogs.command("me").description("Show blog info (title, subdomain, plan, domain)").action(async function() {
|
|
@@ -1710,7 +1827,6 @@ function registerBlogsCommands(program2) {
|
|
|
1710
1827
|
try {
|
|
1711
1828
|
const opts = this.opts();
|
|
1712
1829
|
const ctx = createClientFromCommand(this);
|
|
1713
|
-
const { data: blog } = await ctx.blogs.me();
|
|
1714
1830
|
const input = {};
|
|
1715
1831
|
if (opts.title) input.title = opts.title;
|
|
1716
1832
|
if (opts.description) input.description = opts.description;
|
|
@@ -1723,7 +1839,7 @@ function registerBlogsCommands(program2) {
|
|
|
1723
1839
|
if (Object.keys(input).length === 0) {
|
|
1724
1840
|
throw new Error("No fields to update. Provide at least one option.");
|
|
1725
1841
|
}
|
|
1726
|
-
const { data } = await ctx.blogs.update(
|
|
1842
|
+
const { data } = await ctx.blogs.update(input);
|
|
1727
1843
|
if (json) {
|
|
1728
1844
|
printJson(data);
|
|
1729
1845
|
} else {
|
|
@@ -1734,22 +1850,53 @@ function registerBlogsCommands(program2) {
|
|
|
1734
1850
|
}
|
|
1735
1851
|
});
|
|
1736
1852
|
const domain = blogs.command("domain").description("Manage custom domain");
|
|
1737
|
-
domain.command("connect <domain>").description("Connect a custom domain").action(async function(domainArg) {
|
|
1853
|
+
domain.command("connect <domain>").description("Connect a custom domain (with DNS provider detection)").action(async function(domainArg) {
|
|
1738
1854
|
const json = isJsonMode(this);
|
|
1739
1855
|
try {
|
|
1740
1856
|
const ctx = createClientFromCommand(this);
|
|
1741
1857
|
const result = await ctx.blogs.domainConnect(domainArg);
|
|
1858
|
+
const nameservers = await lookupNameservers(domainArg);
|
|
1859
|
+
const provider = detectDnsProvider(nameservers);
|
|
1860
|
+
const guide = provider ? getDnsProviderGuide(provider) : null;
|
|
1861
|
+
const isSub = isSubdomain(domainArg);
|
|
1742
1862
|
if (json) {
|
|
1743
|
-
printJson(
|
|
1863
|
+
printJson({
|
|
1864
|
+
...result,
|
|
1865
|
+
nameservers,
|
|
1866
|
+
dns_provider: provider,
|
|
1867
|
+
dns_provider_guide: guide,
|
|
1868
|
+
is_subdomain: isSub
|
|
1869
|
+
});
|
|
1744
1870
|
} else {
|
|
1745
1871
|
printSuccess(`Custom domain requested: ${domainArg}`);
|
|
1872
|
+
if (provider) {
|
|
1873
|
+
console.log(`
|
|
1874
|
+
DNS Provider: ${provider}`);
|
|
1875
|
+
if (nameservers.length > 0) {
|
|
1876
|
+
console.log(` Nameservers: ${nameservers.join(", ")}`);
|
|
1877
|
+
}
|
|
1878
|
+
} else if (nameservers.length > 0) {
|
|
1879
|
+
console.log(`
|
|
1880
|
+
Nameservers: ${nameservers.join(", ")}`);
|
|
1881
|
+
}
|
|
1882
|
+
console.log("\n DNS \uC124\uC815:");
|
|
1883
|
+
if (isSub) {
|
|
1884
|
+
console.log(` \u2192 CNAME ${domainArg} \u2192 cname.inblog.ai`);
|
|
1885
|
+
} else {
|
|
1886
|
+
console.log(` \u2192 A ${domainArg} \u2192 76.76.21.21`);
|
|
1887
|
+
}
|
|
1746
1888
|
if (result.dns_records && result.dns_records.length > 0) {
|
|
1889
|
+
console.log("");
|
|
1747
1890
|
printTable(
|
|
1748
1891
|
["Type", "Name", "Value"],
|
|
1749
1892
|
result.dns_records.map((r) => [r.type, r.name, r.value])
|
|
1750
1893
|
);
|
|
1751
1894
|
}
|
|
1752
|
-
|
|
1895
|
+
if (guide) {
|
|
1896
|
+
console.log(`
|
|
1897
|
+
${provider} DNS \uC124\uC815 \uAC00\uC774\uB4DC: ${guide}`);
|
|
1898
|
+
}
|
|
1899
|
+
printWarning("\nDNS \uC804\uD30C \uD6C4 `inblog blogs domain status`\uB85C \uD655\uC778\uD558\uC138\uC694.");
|
|
1753
1900
|
}
|
|
1754
1901
|
} catch (error) {
|
|
1755
1902
|
handleError(error, json);
|