dxfl 0.2.2 → 0.3.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/CHANGELOG.md +5 -0
- package/README.md +6 -0
- package/dist/guichet.js +2 -2
- package/dist/index.js +8 -1
- package/dist/inspect.js +40 -0
- package/dist/utils.js +12 -0
- package/dist/vhosts.js +16 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -46,6 +46,12 @@ Use the `empty` command to delete all files from a website (required before dele
|
|
|
46
46
|
dxfl empty example.com
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
+
Use the `inspect` command to show more detailed informations about a website
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
dxfl inspect example.com
|
|
53
|
+
```
|
|
54
|
+
|
|
49
55
|
## Website configuration
|
|
50
56
|
|
|
51
57
|
`dxfl deploy` reads a `deuxfleurs.toml` configuration file (if it exists in the current directory).
|
package/dist/guichet.js
CHANGED
|
@@ -8,7 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { WebsiteApi, } from "guichet-sdk-ts";
|
|
11
|
-
import
|
|
11
|
+
import { textWarn } from "./utils.js";
|
|
12
12
|
import { ErrorGuichet } from "./error.js";
|
|
13
13
|
// The GuichetApi class wraps WebsiteApi (from the guichet sdk). It catches
|
|
14
14
|
// errors that can happen in normal use, and it turn them into a dedicated error type
|
|
@@ -45,7 +45,7 @@ export class GuichetApi {
|
|
|
45
45
|
// the migration of websites *.web.deuxfleurs.fr to bucket
|
|
46
46
|
// names with the full domain name.
|
|
47
47
|
// We just warn that this is a working but deprecated name.
|
|
48
|
-
console.log(`${
|
|
48
|
+
console.log(`${textWarn("Warning")}: the name "${vhost}" is now deprecated for this website,` +
|
|
49
49
|
` you should use "${vhost}.web.deuxfleurs.fr" instead.`);
|
|
50
50
|
}
|
|
51
51
|
return websiteInfo;
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,8 @@ import { login, logout } from "./auth.js";
|
|
|
5
5
|
import { deploy } from "./deploy.js";
|
|
6
6
|
import { empty } from "./empty.js";
|
|
7
7
|
import { vhostsList } from "./vhosts.js";
|
|
8
|
-
|
|
8
|
+
import { inspect } from "./inspect.js";
|
|
9
|
+
program.name("dxfl").description("Deuxfleurs CLI tool").version("0.3.0");
|
|
9
10
|
program
|
|
10
11
|
.command("login")
|
|
11
12
|
.description("Link your Deuxfleurs account with this tool.")
|
|
@@ -15,6 +16,12 @@ program
|
|
|
15
16
|
.command("list")
|
|
16
17
|
.description("List all your websites")
|
|
17
18
|
.action(() => withHandleErrors(vhostsList));
|
|
19
|
+
program
|
|
20
|
+
.command("inspect")
|
|
21
|
+
.description("Show your website details")
|
|
22
|
+
.argument("<website>", "selected website")
|
|
23
|
+
.option("--secret", "reveal your S3 secret access key")
|
|
24
|
+
.action((website, options) => withHandleErrors(() => inspect(website, options)));
|
|
18
25
|
program
|
|
19
26
|
.command("deploy")
|
|
20
27
|
.description("Deploy your website")
|
package/dist/inspect.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { WebsiteApi } from "guichet-sdk-ts";
|
|
11
|
+
import { openApiConf } from "./auth.js";
|
|
12
|
+
import { formatBytesHuman, separator, textGreen, textGrey, } from "./utils.js";
|
|
13
|
+
import clc from "cli-color";
|
|
14
|
+
export function inspect(website, options) {
|
|
15
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
+
var _a, _b, _c;
|
|
17
|
+
const conf = yield openApiConf();
|
|
18
|
+
const web = new WebsiteApi(conf);
|
|
19
|
+
let siteData = yield web.getWebsite({ vhost: website });
|
|
20
|
+
const q = siteData.quotaSize;
|
|
21
|
+
const v = siteData.vhost;
|
|
22
|
+
const kId = siteData === null || siteData === void 0 ? void 0 : siteData.accessKeyId;
|
|
23
|
+
let kSecret = siteData === null || siteData === void 0 ? void 0 : siteData.secretAccessKey;
|
|
24
|
+
if (!options.secret) {
|
|
25
|
+
kSecret =
|
|
26
|
+
`**** ` +
|
|
27
|
+
textGrey.italic(`(use \`dxfl inspect ${v === null || v === void 0 ? void 0 : v.name} --secret\` to reveal it)`);
|
|
28
|
+
}
|
|
29
|
+
console.log(textGreen.bold(`${v === null || v === void 0 ? void 0 : v.name} details`));
|
|
30
|
+
console.log(separator());
|
|
31
|
+
console.log(` ${clc.bold("id")}: ${v === null || v === void 0 ? void 0 : v.name}`);
|
|
32
|
+
console.log(` ${clc.bold("url")}: ${clc.underline("https://" + (v === null || v === void 0 ? void 0 : v.domain))}`);
|
|
33
|
+
console.log(` ${clc.bold("usage")}:`, `${formatBytesHuman((_a = q === null || q === void 0 ? void 0 : q.current) !== null && _a !== void 0 ? _a : 0)} / ${formatBytesHuman((_b = q === null || q === void 0 ? void 0 : q.max) !== null && _b !== void 0 ? _b : 0)}`, `(${Math.round(((_c = q === null || q === void 0 ? void 0 : q.ratio) !== null && _c !== void 0 ? _c : 0) * 100)}%)`);
|
|
34
|
+
console.log(` ${clc.bold("S3 keys")}:`);
|
|
35
|
+
console.log(` ${clc.bold("access_key_id")}: ${kId}`);
|
|
36
|
+
console.log(` ${clc.bold("secret_access_key")}: ${kSecret}`);
|
|
37
|
+
console.log(separator());
|
|
38
|
+
console.log(textGrey.italic(`→ For more information and features, you can visit the web UI:`, `${clc.underline("https://guichet.deuxfleurs.fr/website/inspect/" + (v === null || v === void 0 ? void 0 : v.name))}`));
|
|
39
|
+
});
|
|
40
|
+
}
|
package/dist/utils.js
CHANGED
|
@@ -19,6 +19,11 @@ import crypto from "crypto";
|
|
|
19
19
|
import { stdin, stdout } from "process";
|
|
20
20
|
import readline from "readline/promises";
|
|
21
21
|
import { ErrorMsg } from "./error.js";
|
|
22
|
+
import clc from "cli-color";
|
|
23
|
+
export const textGreen = clc.green;
|
|
24
|
+
export const textWarn = clc.yellow;
|
|
25
|
+
export const textError = clc.red;
|
|
26
|
+
export const textGrey = clc.xterm(242);
|
|
22
27
|
export function getFileMd5(file) {
|
|
23
28
|
return __awaiter(this, void 0, void 0, function* () {
|
|
24
29
|
var _a, e_1, _b, _c;
|
|
@@ -122,3 +127,10 @@ export function filterMap(a, f) {
|
|
|
122
127
|
return y ? [y] : [];
|
|
123
128
|
});
|
|
124
129
|
}
|
|
130
|
+
export function separator(size = 42) {
|
|
131
|
+
let dashes = "";
|
|
132
|
+
for (let i = 0; i < size; i++) {
|
|
133
|
+
dashes += "-";
|
|
134
|
+
}
|
|
135
|
+
return textGrey(dashes);
|
|
136
|
+
}
|
package/dist/vhosts.js
CHANGED
|
@@ -9,12 +9,25 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import { WebsiteApi } from "guichet-sdk-ts";
|
|
11
11
|
import { openApiConf } from "./auth.js";
|
|
12
|
+
import { separator, textGreen } from "./utils.js";
|
|
13
|
+
import clc from "cli-color";
|
|
12
14
|
export function vhostsList() {
|
|
13
15
|
return __awaiter(this, void 0, void 0, function* () {
|
|
14
|
-
var _a;
|
|
16
|
+
var _a, _b, _c;
|
|
15
17
|
const conf = yield openApiConf();
|
|
16
18
|
const web = new WebsiteApi(conf);
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
+
const sitesData = yield web.listWebsites();
|
|
20
|
+
// Counter
|
|
21
|
+
console.log(`${((_a = sitesData.quotaWebsiteCount) === null || _a === void 0 ? void 0 : _a.current) || 0} websites`, `(out of ${(_b = sitesData.quotaWebsiteCount) === null || _b === void 0 ? void 0 : _b.max}):`);
|
|
22
|
+
// List
|
|
23
|
+
(_c = sitesData.vhosts) === null || _c === void 0 ? void 0 : _c.forEach((v, i) => {
|
|
24
|
+
if (i === 0) {
|
|
25
|
+
console.log(separator());
|
|
26
|
+
}
|
|
27
|
+
console.log(textGreen(v.name));
|
|
28
|
+
console.log(` ${clc.bold("id")}: ${v.name}`);
|
|
29
|
+
console.log(` ${clc.bold("url")}: ${clc.underline("https://" + v.domain)}`);
|
|
30
|
+
console.log(separator());
|
|
31
|
+
});
|
|
19
32
|
});
|
|
20
33
|
}
|