dxfl 0.2.2 → 0.3.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/CHANGELOG.md +9 -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/dist/website_config.js +11 -11
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
# v0.3.1
|
|
2
|
+
|
|
3
|
+
- fix `deuxfleurs.toml`: always pass the user-provided value of index_page to garage
|
|
4
|
+
|
|
5
|
+
# v0.3.0
|
|
6
|
+
|
|
7
|
+
- improve `list` presentation
|
|
8
|
+
- add `inspect` command to show a website details
|
|
9
|
+
|
|
1
10
|
# v0.2.2
|
|
2
11
|
|
|
3
12
|
- add color on prefixes from error/warning messages
|
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.1");
|
|
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
|
}
|
package/dist/website_config.js
CHANGED
|
@@ -143,8 +143,8 @@ function unescape(s) {
|
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
145
|
function interpConfig(rawcfg) {
|
|
146
|
-
var _a, _b, _c, _d, _e;
|
|
147
|
-
function interpRedirect(
|
|
146
|
+
var _a, _b, _c, _d, _e, _f;
|
|
147
|
+
function interpRedirect(r) {
|
|
148
148
|
var _a, _b;
|
|
149
149
|
const rfrom = withErrorMsg(() => unescape(r.from), msg => `from: ${msg}`);
|
|
150
150
|
const rto = withErrorMsg(() => unescape(r.to), msg => `to: ${msg}`);
|
|
@@ -264,7 +264,7 @@ function interpConfig(rawcfg) {
|
|
|
264
264
|
return s !== null && s !== void 0 ? s : def;
|
|
265
265
|
};
|
|
266
266
|
// use index.html as default index page
|
|
267
|
-
const index_page =
|
|
267
|
+
const index_page = (_a = rawcfg.index_page) !== null && _a !== void 0 ? _a : "index.html";
|
|
268
268
|
// use error.html as default error page
|
|
269
269
|
const error_page = withDefault(rawcfg.error_page, "error.html");
|
|
270
270
|
let cfg = {
|
|
@@ -274,9 +274,9 @@ function interpConfig(rawcfg) {
|
|
|
274
274
|
object_redirects: new Map(),
|
|
275
275
|
cors_rules: [],
|
|
276
276
|
};
|
|
277
|
-
for (const [i, raw] of ((
|
|
277
|
+
for (const [i, raw] of ((_b = rawcfg.redirects) !== null && _b !== void 0 ? _b : []).entries()) {
|
|
278
278
|
// `i+1` is only used for display: start counting redirects from 1 instead of 0
|
|
279
|
-
const r = withErrorMsg(() => interpRedirect(
|
|
279
|
+
const r = withErrorMsg(() => interpRedirect(raw), msg => `Redirect ${i + 1}: ${msg}`);
|
|
280
280
|
if (r.kind == "bucket") {
|
|
281
281
|
cfg.bucket_redirects.push(r.r);
|
|
282
282
|
}
|
|
@@ -287,15 +287,15 @@ function interpConfig(rawcfg) {
|
|
|
287
287
|
cfg.object_redirects.set(r.from, r.to);
|
|
288
288
|
}
|
|
289
289
|
}
|
|
290
|
-
for (const [_, raw] of ((
|
|
290
|
+
for (const [_, raw] of ((_c = rawcfg.cors) !== null && _c !== void 0 ? _c : []).entries()) {
|
|
291
291
|
const interpRawArray = (x) => {
|
|
292
292
|
return typeof x === "string" ? [x] : x;
|
|
293
293
|
};
|
|
294
294
|
cfg.cors_rules.push({
|
|
295
295
|
allowed_origins: interpRawArray(raw.allowed_origins),
|
|
296
|
-
allowed_methods: interpRawArray((
|
|
297
|
-
allowed_headers: interpRawArray((
|
|
298
|
-
expose_headers: interpRawArray((
|
|
296
|
+
allowed_methods: interpRawArray((_d = raw.allowed_methods) !== null && _d !== void 0 ? _d : ["GET", "HEAD"]),
|
|
297
|
+
allowed_headers: interpRawArray((_e = raw.allowed_methods) !== null && _e !== void 0 ? _e : []),
|
|
298
|
+
expose_headers: interpRawArray((_f = raw.expose_headers) !== null && _f !== void 0 ? _f : []),
|
|
299
299
|
});
|
|
300
300
|
}
|
|
301
301
|
return cfg;
|
|
@@ -431,10 +431,10 @@ export function putBucketWebsiteConfig(bucket, index_page, error_page, bucket_re
|
|
|
431
431
|
return __awaiter(this, void 0, void 0, function* () {
|
|
432
432
|
// TODO: printing to show what changes are being applied?
|
|
433
433
|
const WebsiteConfiguration = {};
|
|
434
|
-
if (error_page) {
|
|
434
|
+
if (error_page != undefined) {
|
|
435
435
|
WebsiteConfiguration.ErrorDocument = { Key: error_page };
|
|
436
436
|
}
|
|
437
|
-
if (index_page) {
|
|
437
|
+
if (index_page != undefined) {
|
|
438
438
|
WebsiteConfiguration.IndexDocument = { Suffix: index_page };
|
|
439
439
|
}
|
|
440
440
|
if (bucket_redirects.length > 0) {
|