dxfl 0.4.1 → 0.4.2-alpha
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 +4 -0
- package/dist/deploy.js +9 -5
- package/dist/index.js +1 -1
- package/dist/website_config.js +18 -15
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
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, } from "./bucket.js";
|
|
14
14
|
import { ErrorMsg } from "./error.js";
|
|
15
15
|
import { confirmationPrompt, filterMap, formatBytesHuman, formatCount, getFileMd5, sum, } from "./utils.js";
|
|
16
|
-
import { equalBucketRedirect,
|
|
16
|
+
import { equalBucketRedirect, getBucketConfig, putBucketWebsiteConfig, readConfigFile, } from "./website_config.js";
|
|
17
17
|
// Walks through the local directory at path `dir`, and for each file it contains, returns :
|
|
18
18
|
// - `localPath`: its path on the local filesystem (includes `dir`). On windows, this path
|
|
19
19
|
// will typically use `\` as separator.
|
|
@@ -189,7 +189,11 @@ function printPlan(plan, details) {
|
|
|
189
189
|
const oredirects_updated = plan.redirects.filter(r => r.action == "update");
|
|
190
190
|
const oredirects_deleted = plan.redirects.filter(r => r.action == "delete");
|
|
191
191
|
// check whether CORS rules changed
|
|
192
|
-
const cors_changed = !equalCorsRules(
|
|
192
|
+
// const cors_changed = !equalCorsRules(
|
|
193
|
+
// plan.cors_rules.from,
|
|
194
|
+
// plan.cors_rules.to,
|
|
195
|
+
// );
|
|
196
|
+
const cors_changed = false;
|
|
193
197
|
// print
|
|
194
198
|
if (details == "summary") {
|
|
195
199
|
const sizeRemote = sum([...plan.remoteFiles.values()].map(f => { var _a; return (_a = f.size) !== null && _a !== void 0 ? _a : 0; }));
|
|
@@ -313,9 +317,9 @@ function applyDeployPlan(bucket, plan) {
|
|
|
313
317
|
// Apply bucket redirects & global config
|
|
314
318
|
yield putBucketWebsiteConfig(bucket, plan.index_page.to, plan.error_page.to, plan.bucket_redirects.to);
|
|
315
319
|
// Apply CORS rules
|
|
316
|
-
if (!equalCorsRules(plan.cors_rules.from, plan.cors_rules.to)) {
|
|
317
|
-
|
|
318
|
-
}
|
|
320
|
+
// if (!equalCorsRules(plan.cors_rules.from, plan.cors_rules.to)) {
|
|
321
|
+
// await putCorsRules(bucket, plan.cors_rules.to);
|
|
322
|
+
// }
|
|
319
323
|
});
|
|
320
324
|
}
|
|
321
325
|
export function deploy(website, localFolder, options) {
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ 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.4.
|
|
9
|
+
program.name("dxfl").description("Deuxfleurs CLI tool").version("0.4.2-alpha");
|
|
10
10
|
program
|
|
11
11
|
.command("login")
|
|
12
12
|
.description("Link your Deuxfleurs account with this tool.")
|
package/dist/website_config.js
CHANGED
|
@@ -12,7 +12,7 @@ import TOML from "smol-toml";
|
|
|
12
12
|
import URI from "fast-uri";
|
|
13
13
|
import { z as zod } from "zod";
|
|
14
14
|
import { fromError as zodError } from "zod-validation-error";
|
|
15
|
-
import {
|
|
15
|
+
import { GetBucketWebsiteCommand, PutBucketWebsiteCommand, PutBucketCorsCommand, } from "@aws-sdk/client-s3";
|
|
16
16
|
import { ErrorMsg, withErrorMsg, wrapS3Call } from "./error.js";
|
|
17
17
|
import { getBucketFilesDetails } from "./bucket.js";
|
|
18
18
|
////////////// Utilities
|
|
@@ -324,12 +324,14 @@ export function getBucketConfig(bucket, files) {
|
|
|
324
324
|
// - A Head command for each file in the bucket to collect object redirects.
|
|
325
325
|
// (This can become relatively slow for buckets with thousands of files,
|
|
326
326
|
// but I don't know of a better way.)
|
|
327
|
-
var _a, _b
|
|
328
|
-
const [website,
|
|
327
|
+
var _a, _b;
|
|
328
|
+
const [website, details] = yield Promise.all([
|
|
329
329
|
// 204 "No Content" is returned when there is no existing website config
|
|
330
330
|
wrapS3Call(`read the bucket website config`, [200, 204], () => bucket.client.send(new GetBucketWebsiteCommand({ Bucket: bucket.name }))),
|
|
331
331
|
// 204 "No Content" is returned when there are no existing CORS rules
|
|
332
|
-
wrapS3Call(`read the bucket CORS config`, [200, 204], () =>
|
|
332
|
+
// wrapS3Call(`read the bucket CORS config`, [200, 204], () =>
|
|
333
|
+
// bucket.client.send(new GetBucketCorsCommand({ Bucket: bucket.name })),
|
|
334
|
+
// ),
|
|
333
335
|
getBucketFilesDetails(bucket, files),
|
|
334
336
|
]);
|
|
335
337
|
// Collect object redirects
|
|
@@ -340,7 +342,8 @@ export function getBucketConfig(bucket, files) {
|
|
|
340
342
|
}
|
|
341
343
|
}
|
|
342
344
|
// Interpret bucket redirects
|
|
343
|
-
if (website.RedirectAllRequestsTo
|
|
345
|
+
if (website.RedirectAllRequestsTo &&
|
|
346
|
+
"HostName" in website.RedirectAllRequestsTo) {
|
|
344
347
|
// NB: garage does not currently support RedirectAllRequestsTo so this should never happen
|
|
345
348
|
throw new ErrorMsg(`remote website configuration: RedirectAllRequestsTo is specified; ` +
|
|
346
349
|
`this is currently unsupported by dxfl`);
|
|
@@ -414,16 +417,16 @@ export function getBucketConfig(bucket, files) {
|
|
|
414
417
|
}
|
|
415
418
|
// Interpret CORS rules
|
|
416
419
|
let cors_rules = [];
|
|
417
|
-
if (cors.CORSRules) {
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
}
|
|
420
|
+
// if (cors.CORSRules) {
|
|
421
|
+
// for (const rule of cors.CORSRules) {
|
|
422
|
+
// cors_rules.push({
|
|
423
|
+
// allowed_origins: rule.AllowedOrigins ?? [],
|
|
424
|
+
// allowed_methods: rule.AllowedMethods ?? [],
|
|
425
|
+
// allowed_headers: rule.AllowedHeaders ?? [],
|
|
426
|
+
// expose_headers: rule.ExposeHeaders ?? [],
|
|
427
|
+
// });
|
|
428
|
+
// }
|
|
429
|
+
// }
|
|
427
430
|
return {
|
|
428
431
|
index_page,
|
|
429
432
|
error_page,
|