dxfl 0.5.5 → 0.6.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 +1 -1
- package/dist/_empty.js +64 -0
- package/dist/deploy.js +4 -2
- package/dist/empty.js +4 -2
- package/dist/index.js +3 -3
- package/dist/inspect.js +3 -2
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/utils.js +13 -0
- package/dist/vhosts.js +1 -1
- package/npm-shrinkwrap.json +2218 -0
- package/package.json +4 -9
- package/deuxfleurs.toml +0 -18
- package/dist/deploy_websiteconfig.js +0 -108
- package/dist/errors.js +0 -7
- package/public/TinyCorePure64-15.0.iso +0 -1
- package/public/d/b +0 -2
- package/public/d/c +0 -2
- package/public/d/dd/bla +0 -1
- package/public/d/dd/foo.txt +0 -1
- package/public/def +0 -2
- package/public/error.html +0 -1
- package/public/index.html +0 -1
- package/public/index.html~ +0 -1
- package/public/slt +0 -1
- package/public/test.html +0 -0
- package/public/toto.jpg +0 -0
- package/public/toto.txt +0 -1
- package/public/toto2.txt +0 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -220,7 +220,7 @@ Then to publish a release:
|
|
|
220
220
|
vim CHANGELOG.md # update the version and its content in this file
|
|
221
221
|
vim package.json # update the version in this file
|
|
222
222
|
vim index.ts # update the version in this file
|
|
223
|
-
npm install # update the version in the
|
|
223
|
+
npm install # update the version in the lock file
|
|
224
224
|
npm run prettier # fix potential coding style problem
|
|
225
225
|
git commit -a -m 'set version 0.1.5' # commit your change
|
|
226
226
|
git push # send update
|
package/dist/_empty.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// // TODO: Refacto the codebase global before integrate this feature
|
|
2
|
+
export {};
|
|
3
|
+
// export async function empty(
|
|
4
|
+
// vhost: string,
|
|
5
|
+
// options: { dryRun: boolean | undefined },
|
|
6
|
+
// ) {
|
|
7
|
+
// const conf = await openApiConf();
|
|
8
|
+
// // Get website info from guichet (bucket name and keys)
|
|
9
|
+
// const api = new WebsiteApi(conf);
|
|
10
|
+
// let vhostInfo = await api.getWebsite({ vhost }).catch(err => {
|
|
11
|
+
// if (err.response.status == 404) {
|
|
12
|
+
// console.error(`Error: website '${vhost}' does not exist`);
|
|
13
|
+
// } else {
|
|
14
|
+
// console.error(err);
|
|
15
|
+
// }
|
|
16
|
+
// process.exit(1);
|
|
17
|
+
// });
|
|
18
|
+
// // List the files currently stored in the bucket
|
|
19
|
+
// // @FIXME this info could be returned by the guichet API
|
|
20
|
+
// const s3client = new S3Client({
|
|
21
|
+
// endpoint: "https://garage.deuxfleurs.fr",
|
|
22
|
+
// region: "garage",
|
|
23
|
+
// forcePathStyle: true,
|
|
24
|
+
// credentials: {
|
|
25
|
+
// accessKeyId: vhostInfo.accessKeyId!,
|
|
26
|
+
// secretAccessKey: vhostInfo.secretAccessKey!,
|
|
27
|
+
// },
|
|
28
|
+
// });
|
|
29
|
+
// const Bucket = vhostInfo.vhost!.name!;
|
|
30
|
+
// const filesToDelete = [...(await getBucketFiles(s3client, Bucket))].map(
|
|
31
|
+
// ([name, { size }]) => ({
|
|
32
|
+
// name,
|
|
33
|
+
// size,
|
|
34
|
+
// }),
|
|
35
|
+
// );
|
|
36
|
+
// for (const file of filesToDelete) {
|
|
37
|
+
// process.stdout.write(`Deleting ${file.name}\n`);
|
|
38
|
+
// }
|
|
39
|
+
// // If not in dry-run mode, send the delete command
|
|
40
|
+
// if (!options.dryRun) {
|
|
41
|
+
// const resp = await deleteFiles(s3client, Bucket, filesToDelete);
|
|
42
|
+
// if (resp && resp!.$metadata.httpStatusCode != 200) {
|
|
43
|
+
// // TODO: better error handling?
|
|
44
|
+
// console.error(resp);
|
|
45
|
+
// process.exit(1);
|
|
46
|
+
// }
|
|
47
|
+
// }
|
|
48
|
+
// // Display a summary
|
|
49
|
+
// function sum(a: number[]) {
|
|
50
|
+
// return a.reduce((x, y) => x + y, 0);
|
|
51
|
+
// }
|
|
52
|
+
// function formatFiles(n: number) {
|
|
53
|
+
// if (n == 1) {
|
|
54
|
+
// return `${n} file `;
|
|
55
|
+
// } else {
|
|
56
|
+
// return `${n} files`;
|
|
57
|
+
// }
|
|
58
|
+
// }
|
|
59
|
+
// const sizeDeleted = sum(filesToDelete.map(f => f.size ?? 0));
|
|
60
|
+
// process.stdout.write("\nSummary:\n");
|
|
61
|
+
// process.stdout.write(
|
|
62
|
+
// `${formatFiles(filesToDelete.length)} deleted (${formatBytes(sizeDeleted)})\n`,
|
|
63
|
+
// );
|
|
64
|
+
// }
|
package/dist/deploy.js
CHANGED
|
@@ -13,7 +13,7 @@ import { PromisePool } from "@supercharge/promise-pool";
|
|
|
13
13
|
import { deleteBucketFile, deleteBucketFiles, getBucketCredentials, getBucket, getBucketFiles, putEmptyObjectRedirect, uploadFile, setObjectHeaders, } from "./bucket.js";
|
|
14
14
|
import { ErrorMsg } from "./error.js";
|
|
15
15
|
import { fileContentType, supportedHeaders, } from "./headers.js";
|
|
16
|
-
import { confirmationPrompt, filterMap, formatBytesHuman, formatCount, getFileMd5, gzipFile, mapEq, mkTmpDir, sum, } from "./utils.js";
|
|
16
|
+
import { confirmationPrompt, filterMap, formatBytesHuman, formatCount, getFileMd5, gzipFile, mapEq, mkTmpDir, sum, websiteIdBestEffort, } from "./utils.js";
|
|
17
17
|
import { evalHeadersRules, equalBucketRedirect, getBucketConfig, putBucketWebsiteConfig, readConfigFile, } from "./website_config.js";
|
|
18
18
|
// Walks through the local directory at path `dir`, and for each file it contains, returns :
|
|
19
19
|
// - `localPath`: its path on the local filesystem (includes `dir`). On windows, this path
|
|
@@ -429,13 +429,15 @@ export function deploy(website, localFolder, options) {
|
|
|
429
429
|
}
|
|
430
430
|
// Read and validate the local configuration file before doing anything else
|
|
431
431
|
const localWebsiteConfig = yield readConfigFile(options.configFile);
|
|
432
|
+
// Interpret the name of the website
|
|
433
|
+
const websiteId = websiteIdBestEffort(website);
|
|
432
434
|
process.stdout.write("Fetching the website configuration and metadata...\n");
|
|
433
435
|
const [localFiles, [bucket, remoteFiles, remoteWebsiteConfig]] = yield Promise.all([
|
|
434
436
|
// Get paths & size of the local files to deploy
|
|
435
437
|
getLocalFilesWithInfo(localFolder),
|
|
436
438
|
// Get the bucket, list of files stored in the bucket, and bucket website config
|
|
437
439
|
(() => __awaiter(this, void 0, void 0, function* () {
|
|
438
|
-
const bucket = yield getBucket(
|
|
440
|
+
const bucket = yield getBucket(websiteId, yield getBucketCredentials(websiteId));
|
|
439
441
|
const remoteFiles = yield getBucketFiles(bucket);
|
|
440
442
|
// This can be slow because it needs to query each object in the bucket.
|
|
441
443
|
const remoteWebsiteConfig = yield getBucketConfig(bucket, [
|
package/dist/empty.js
CHANGED
|
@@ -9,14 +9,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import { getBucket, getBucketCredentials, getBucketFiles, deleteBucketFiles, } from "./bucket.js";
|
|
11
11
|
import { ErrorMsg } from "./error.js";
|
|
12
|
-
import { confirmationPrompt, formatBytesHuman, formatCount, sum, } from "./utils.js";
|
|
12
|
+
import { confirmationPrompt, formatBytesHuman, formatCount, sum, websiteIdBestEffort, } from "./utils.js";
|
|
13
13
|
export function empty(website, options) {
|
|
14
14
|
return __awaiter(this, void 0, void 0, function* () {
|
|
15
15
|
if (options.dryRun && options.yes) {
|
|
16
16
|
throw new ErrorMsg("options --yes and --dry-run cannot be passed at the same time");
|
|
17
17
|
}
|
|
18
18
|
process.stdout.write("Fetching the website configuration and metadata...\n");
|
|
19
|
-
|
|
19
|
+
// Interpret the name of the website
|
|
20
|
+
const websiteId = websiteIdBestEffort(website);
|
|
21
|
+
const bucket = yield getBucket(websiteId, yield getBucketCredentials(websiteId));
|
|
20
22
|
const filesToDelete = [...(yield getBucketFiles(bucket))].map(([name, { size }]) => ({
|
|
21
23
|
name,
|
|
22
24
|
size,
|
package/dist/index.js
CHANGED
|
@@ -4,9 +4,9 @@ import { withHandleErrors } from "./error.js";
|
|
|
4
4
|
import { login, logout } from "./auth.js";
|
|
5
5
|
import { deploy } from "./deploy.js";
|
|
6
6
|
import { empty } from "./empty.js";
|
|
7
|
-
import {
|
|
7
|
+
import { list } from "./vhosts.js";
|
|
8
8
|
import { inspect } from "./inspect.js";
|
|
9
|
-
program.name("dxfl").description("Deuxfleurs CLI tool").version("0.
|
|
9
|
+
program.name("dxfl").description("Deuxfleurs CLI tool").version("0.6.1");
|
|
10
10
|
program
|
|
11
11
|
.command("login")
|
|
12
12
|
.description("Link your Deuxfleurs account with this tool.")
|
|
@@ -15,7 +15,7 @@ program
|
|
|
15
15
|
program
|
|
16
16
|
.command("list")
|
|
17
17
|
.description("List all your websites")
|
|
18
|
-
.action(() => withHandleErrors(
|
|
18
|
+
.action(() => withHandleErrors(list));
|
|
19
19
|
program
|
|
20
20
|
.command("inspect")
|
|
21
21
|
.description("Show your website details")
|
package/dist/inspect.js
CHANGED
|
@@ -9,14 +9,15 @@ 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 { formatBytesHuman, separator } from "./utils.js";
|
|
12
|
+
import { formatBytesHuman, separator, websiteIdBestEffort } from "./utils.js";
|
|
13
13
|
import { styleText } from "node:util";
|
|
14
14
|
export function inspect(website, options) {
|
|
15
15
|
return __awaiter(this, void 0, void 0, function* () {
|
|
16
16
|
var _a, _b, _c;
|
|
17
|
+
const websiteId = websiteIdBestEffort(website); // Interpret the name of the website
|
|
17
18
|
const conf = yield openApiConf();
|
|
18
19
|
const web = new WebsiteApi(conf);
|
|
19
|
-
let siteData = yield web.getWebsite({ vhost:
|
|
20
|
+
let siteData = yield web.getWebsite({ vhost: websiteId });
|
|
20
21
|
const q = siteData.quotaSize;
|
|
21
22
|
const v = siteData.vhost;
|
|
22
23
|
const kId = siteData === null || siteData === void 0 ? void 0 : siteData.accessKeyId;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"root":["../auth.ts","../bucket.ts","../deploy.ts","../empty.ts","../error.ts","../guichet.ts","../headers.ts","../index.ts","../inspect.ts","../utils.ts","../vhosts.ts","../website_config.ts"],"version":"5.9.3"}
|
package/dist/utils.js
CHANGED
|
@@ -23,6 +23,7 @@ import { pipeline } from "node:stream/promises";
|
|
|
23
23
|
import { styleText } from "node:util";
|
|
24
24
|
import zlib from "node:zlib";
|
|
25
25
|
import readline from "readline/promises";
|
|
26
|
+
import URI from "fast-uri";
|
|
26
27
|
import { ErrorMsg } from "./error.js";
|
|
27
28
|
export function getFileMd5(file) {
|
|
28
29
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -150,3 +151,15 @@ export function mapEq(m1, m2) {
|
|
|
150
151
|
return (m1.size === m2.size &&
|
|
151
152
|
Array.from(m1.keys()).every(key => m1.get(key) == m2.get(key)));
|
|
152
153
|
}
|
|
154
|
+
// Accept {http,https}://website{,/} as identifier for "website".
|
|
155
|
+
// (Useful to allow copy-pasting URLs into the terminal.)
|
|
156
|
+
export function websiteIdBestEffort(website) {
|
|
157
|
+
const asURI = URI.parse(website);
|
|
158
|
+
if (!asURI.error &&
|
|
159
|
+
asURI.host &&
|
|
160
|
+
(asURI.scheme == "http" || asURI.scheme == "https") &&
|
|
161
|
+
(asURI.path == "" || asURI.path == "/")) {
|
|
162
|
+
return asURI.host;
|
|
163
|
+
}
|
|
164
|
+
return website;
|
|
165
|
+
}
|
package/dist/vhosts.js
CHANGED
|
@@ -11,7 +11,7 @@ import { WebsiteApi } from "guichet-sdk-ts";
|
|
|
11
11
|
import { openApiConf } from "./auth.js";
|
|
12
12
|
import { separator } from "./utils.js";
|
|
13
13
|
import { styleText } from "node:util";
|
|
14
|
-
export function
|
|
14
|
+
export function list() {
|
|
15
15
|
return __awaiter(this, void 0, void 0, function* () {
|
|
16
16
|
var _a, _b, _c;
|
|
17
17
|
const conf = yield openApiConf();
|