cfdns 2.1.1 → 2.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cfdns.js +17 -15
- package/package.json +17 -14
package/cfdns.js
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
import minimist from "minimist";
|
|
3
|
+
import request from "request-promise-native";
|
|
4
|
+
import chalk from "chalk";
|
|
5
|
+
import fs from "fs-extra";
|
|
6
|
+
import {join} from "node:path";
|
|
7
|
+
import {homedir} from "node:os";
|
|
8
|
+
import {readFileSync} from "node:fs";
|
|
3
9
|
|
|
4
|
-
const
|
|
10
|
+
const pkg = JSON.parse(readFileSync(new URL("package.json", import.meta.url)));
|
|
11
|
+
|
|
12
|
+
const args = minimist(process.argv.slice(2), {
|
|
5
13
|
boolean: [
|
|
6
14
|
"c", "color",
|
|
7
15
|
"h", "help",
|
|
@@ -25,7 +33,7 @@ function exit(err) {
|
|
|
25
33
|
}
|
|
26
34
|
|
|
27
35
|
if (args.version) {
|
|
28
|
-
console.info(
|
|
36
|
+
console.info(pkg.version);
|
|
29
37
|
exit();
|
|
30
38
|
}
|
|
31
39
|
|
|
@@ -64,9 +72,6 @@ if (!cmd || args.help || !Object.keys(cmds).includes(cmd) || !paramLengthOkay) {
|
|
|
64
72
|
exit();
|
|
65
73
|
}
|
|
66
74
|
|
|
67
|
-
const request = require("request-promise-native");
|
|
68
|
-
const chalk = require("chalk");
|
|
69
|
-
|
|
70
75
|
let email, key;
|
|
71
76
|
|
|
72
77
|
async function req(method, path, body) {
|
|
@@ -83,8 +88,7 @@ async function req(method, path, body) {
|
|
|
83
88
|
}
|
|
84
89
|
|
|
85
90
|
(async () => {
|
|
86
|
-
const
|
|
87
|
-
const rcfile = require("path").join(require("os").homedir(), ".cfdnsrc");
|
|
91
|
+
const rcfile = join(homedir(), ".cfdnsrc");
|
|
88
92
|
|
|
89
93
|
if (cmd === "login" || cmd === "logout") {
|
|
90
94
|
if (cmd === "login") {
|
|
@@ -96,7 +100,7 @@ async function req(method, path, body) {
|
|
|
96
100
|
try {
|
|
97
101
|
await fs.unlink(rcfile);
|
|
98
102
|
console.info("login data deleted");
|
|
99
|
-
} catch
|
|
103
|
+
} catch {
|
|
100
104
|
console.info("no login data found");
|
|
101
105
|
}
|
|
102
106
|
}
|
|
@@ -104,7 +108,7 @@ async function req(method, path, body) {
|
|
|
104
108
|
} else {
|
|
105
109
|
try {
|
|
106
110
|
({email, key} = JSON.parse(await fs.readFile(rcfile)));
|
|
107
|
-
} catch
|
|
111
|
+
} catch {
|
|
108
112
|
exit("login data not found, please log in first.");
|
|
109
113
|
}
|
|
110
114
|
}
|
|
@@ -136,11 +140,9 @@ async function req(method, path, body) {
|
|
|
136
140
|
});
|
|
137
141
|
console.info(`created ${chalk.magenta(name)} ${ttl} IN ${type} ${chalk.green(content)}`);
|
|
138
142
|
}
|
|
139
|
-
} else if (cmd === "del") {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
console.info(`deleted ${chalk.magenta(name)} ${record.ttl} IN ${type} ${chalk.green(record.content)}`);
|
|
143
|
-
}
|
|
143
|
+
} else if (cmd === "del" && record) {
|
|
144
|
+
await req("delete", `zones/${zone.id}/dns_records/${record.id}`);
|
|
145
|
+
console.info(`deleted ${chalk.magenta(name)} ${record.ttl} IN ${type} ${chalk.green(record.content)}`);
|
|
144
146
|
}
|
|
145
147
|
exit();
|
|
146
148
|
})();
|
package/package.json
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cfdns",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.2",
|
|
4
4
|
"description": "CLI to modify DNS records hosted on Cloudflare",
|
|
5
5
|
"author": "silverwind <me@silverwind.io>",
|
|
6
6
|
"repository": "silverwind/cfdns",
|
|
7
|
+
"type": "module",
|
|
7
8
|
"license": "BSD-2-Clause",
|
|
8
|
-
"scripts": {
|
|
9
|
-
"test": "make test"
|
|
10
|
-
},
|
|
11
9
|
"engines": {
|
|
12
10
|
"node": ">=8"
|
|
13
11
|
},
|
|
@@ -26,16 +24,21 @@
|
|
|
26
24
|
"ddns"
|
|
27
25
|
],
|
|
28
26
|
"dependencies": {
|
|
29
|
-
"chalk": "
|
|
30
|
-
"fs-extra": "^
|
|
31
|
-
"minimist": "^1.2.
|
|
32
|
-
"request": "^2.88.
|
|
33
|
-
"request-promise-native": "^1.0.
|
|
34
|
-
"ver": "
|
|
27
|
+
"chalk": "5.6.2",
|
|
28
|
+
"fs-extra": "^11.3.3",
|
|
29
|
+
"minimist": "^1.2.8",
|
|
30
|
+
"request": "^2.88.2",
|
|
31
|
+
"request-promise-native": "^1.0.9",
|
|
32
|
+
"ver": "6.0.2"
|
|
35
33
|
},
|
|
36
34
|
"devDependencies": {
|
|
37
|
-
"eslint": "^
|
|
38
|
-
"eslint-config-silverwind": "^
|
|
39
|
-
"
|
|
35
|
+
"eslint": "^9.39.2",
|
|
36
|
+
"eslint-config-silverwind": "^121.0.5",
|
|
37
|
+
"typescript-config-silverwind": "15.0.0",
|
|
38
|
+
"updates": "^17.5.2",
|
|
39
|
+
"updates-config-silverwind": "1.0.3"
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"test": "make test"
|
|
40
43
|
}
|
|
41
|
-
}
|
|
44
|
+
}
|