@fastly/compute-js-static-publish 8.0.0-rc.1 → 8.0.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/build/cli/cli/commands/manage/clean.d.ts.map +1 -1
- package/build/cli/cli/commands/manage/clean.js +1 -0
- package/build/cli/cli/commands/manage/collections/delete.d.ts.map +1 -1
- package/build/cli/cli/commands/manage/collections/delete.js +39 -2
- package/build/cli/cli/commands/manage/collections/index.d.ts.map +1 -1
- package/build/cli/cli/commands/manage/collections/index.js +1 -0
- package/build/cli/cli/commands/manage/collections/list.d.ts.map +1 -1
- package/build/cli/cli/commands/manage/collections/list.js +10 -1
- package/build/cli/cli/commands/manage/collections/promote.d.ts.map +1 -1
- package/build/cli/cli/commands/manage/collections/promote.js +1 -0
- package/build/cli/cli/commands/manage/collections/update-expiration.d.ts.map +1 -1
- package/build/cli/cli/commands/manage/collections/update-expiration.js +1 -0
- package/build/cli/cli/commands/manage/index.d.ts.map +1 -1
- package/build/cli/cli/commands/manage/index.js +1 -0
- package/build/cli/cli/commands/manage/publish-content.d.ts.map +1 -1
- package/build/cli/cli/commands/manage/publish-content.js +69 -74
- package/build/cli/cli/commands/scaffold/index.d.ts.map +1 -1
- package/build/cli/cli/commands/scaffold/index.js +32 -13
- package/build/cli/cli/storage/s3-storage-provider.d.ts +1 -0
- package/build/cli/cli/storage/s3-storage-provider.d.ts.map +1 -1
- package/build/cli/cli/storage/s3-storage-provider.js +8 -4
- package/build/cli/cli/util/purge.d.ts +1 -0
- package/build/cli/cli/util/purge.d.ts.map +1 -1
- package/build/cli/cli/util/purge.js +21 -6
- package/build/cli/cli/util/service-id.js +1 -1
- package/build/cli/cli/util/variants.d.ts +7 -0
- package/build/cli/cli/util/variants.d.ts.map +1 -1
- package/build/cli/cli/util/variants.js +17 -0
- package/build/cli/models/config/publisher-server-config.d.ts +1 -0
- package/build/cli/models/config/publisher-server-config.d.ts.map +1 -1
- package/build/cli/models/server/index.d.ts +4 -0
- package/build/cli/models/server/index.d.ts.map +1 -1
- package/build/cli/models/server/index.js +34 -1
- package/build/server/models/config/publisher-server-config.d.ts +1 -0
- package/build/server/models/config/publisher-server-config.d.ts.map +1 -1
- package/build/server/models/server/index.d.ts +4 -0
- package/build/server/models/server/index.d.ts.map +1 -1
- package/build/server/models/server/index.js +34 -1
- package/build/server/server/collection-selector/from-cookie.d.ts.map +1 -1
- package/build/server/server/collection-selector/from-cookie.js +28 -2
- package/build/server/server/publisher-server/index.d.ts +0 -1
- package/build/server/server/publisher-server/index.d.ts.map +1 -1
- package/build/server/server/publisher-server/index.js +62 -52
- package/build/server/server/publisher-server/response-cache.d.ts +13 -0
- package/build/server/server/publisher-server/response-cache.d.ts.map +1 -1
- package/build/server/server/publisher-server/response-cache.js +54 -0
- package/build/server/server/storage/s3-storage-provider.d.ts +6 -1
- package/build/server/server/storage/s3-storage-provider.d.ts.map +1 -1
- package/build/server/server/storage/s3-storage-provider.js +12 -7
- package/build/server/server/util/body-length.d.ts +5 -0
- package/build/server/server/util/body-length.d.ts.map +1 -0
- package/build/server/server/util/body-length.js +63 -0
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clean.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/manage/clean.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"clean.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/manage/clean.ts"],"names":[],"mappings":"AAoDA,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,iBA0NhD"}
|
|
@@ -27,6 +27,7 @@ KV Store Options:
|
|
|
27
27
|
--local Instead of working with the Fastly KV Store, operate on
|
|
28
28
|
local files that will be used to simulate the KV Store
|
|
29
29
|
with the local development environment.
|
|
30
|
+
KV Store mode only. In S3 mode, --local is an error.
|
|
30
31
|
|
|
31
32
|
--fastly-api-token=<token> Fastly API token for KV Store access.
|
|
32
33
|
If not set, the tool uses the FASTLY_API_TOKEN
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../../../../src/cli/commands/manage/collections/delete.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../../../../src/cli/commands/manage/collections/delete.ts"],"names":[],"mappings":"AAiEA,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,iBA+JhD"}
|
|
@@ -6,6 +6,7 @@ import path from 'node:path';
|
|
|
6
6
|
import { parseCommandLine } from '../../../util/args.js';
|
|
7
7
|
import { LoadConfigError, loadStaticPublisherRcFile } from '../../../util/config.js';
|
|
8
8
|
import { loadStorageProviderFromStaticPublishRc } from '../../../storage/storage-provider.js';
|
|
9
|
+
import { loadPurgeTarget, purgeCollection } from '../../../util/purge.js';
|
|
9
10
|
function help() {
|
|
10
11
|
console.log(`\
|
|
11
12
|
|
|
@@ -19,6 +20,9 @@ Description:
|
|
|
19
20
|
Use the 'npx @fastly/compute-js-static-publish clean' command afterward to remove content
|
|
20
21
|
files that are no longer referenced by any collection.
|
|
21
22
|
|
|
23
|
+
If a Service ID is found, the tool then purges the cached responses of the collection
|
|
24
|
+
from that service.
|
|
25
|
+
|
|
22
26
|
Required:
|
|
23
27
|
--collection-name=<name> The name of the collection to delete
|
|
24
28
|
|
|
@@ -26,11 +30,23 @@ KV Store Options:
|
|
|
26
30
|
--local Instead of working with the Fastly KV Store, operate on
|
|
27
31
|
local files that will be used to simulate the KV Store
|
|
28
32
|
with the local development environment.
|
|
33
|
+
KV Store mode only. In S3 mode, --local is an error.
|
|
29
34
|
|
|
30
|
-
--fastly-api-token=<token> Fastly API token for KV Store access.
|
|
35
|
+
--fastly-api-token=<token> Fastly API token for KV Store or cache access.
|
|
31
36
|
If not set, the tool uses the FASTLY_API_TOKEN
|
|
32
37
|
environment variable.
|
|
33
38
|
|
|
39
|
+
Purge Options:
|
|
40
|
+
--fastly-service-id=<id> Fastly Service ID to purge after deleting (not with --local).
|
|
41
|
+
If not set, the tool will check:
|
|
42
|
+
1. FASTLY_SERVICE_ID environment variable
|
|
43
|
+
2. service_id in fastly.toml
|
|
44
|
+
If none is found, the purge is skipped.
|
|
45
|
+
|
|
46
|
+
--purge-environment=<env> Environment to purge: production, staging, or a
|
|
47
|
+
comma-separated list of both. Can be repeated.
|
|
48
|
+
Default: production
|
|
49
|
+
|
|
34
50
|
S3 Storage Options (BETA):
|
|
35
51
|
--s3-access-key-id=<id> Access Key ID and Secret Access Key used to
|
|
36
52
|
--s3-secret-access-key=<key> interface with S3 or compatible storage.
|
|
@@ -47,6 +63,8 @@ export async function action(actionArgs) {
|
|
|
47
63
|
{ name: 'collection-name', type: String },
|
|
48
64
|
{ name: 'local', type: Boolean },
|
|
49
65
|
{ name: 'fastly-api-token', type: String, },
|
|
66
|
+
{ name: 'fastly-service-id', type: String, },
|
|
67
|
+
{ name: 'purge-environment', type: String, multiple: true, },
|
|
50
68
|
{ name: 's3-access-key-id', type: String, },
|
|
51
69
|
{ name: 's3-secret-access-key', type: String, },
|
|
52
70
|
];
|
|
@@ -60,7 +78,7 @@ export async function action(actionArgs) {
|
|
|
60
78
|
help();
|
|
61
79
|
return;
|
|
62
80
|
}
|
|
63
|
-
const { verbose, ['collection-name']: collectionNameValue, ['fastly-api-token']: fastlyApiToken, local: localMode, ['s3-access-key-id']: s3AccessKeyId, ['s3-secret-access-key']: s3SecretAccessKey, } = parsed.commandLineOptions;
|
|
81
|
+
const { verbose, ['collection-name']: collectionNameValue, ['fastly-api-token']: fastlyApiToken, ['fastly-service-id']: fastlyServiceId, ['purge-environment']: purgeEnvironmentValues, local: localMode, ['s3-access-key-id']: s3AccessKeyId, ['s3-secret-access-key']: s3SecretAccessKey, } = parsed.commandLineOptions;
|
|
64
82
|
// compute-js-static-publisher cli is always run from the Compute application directory
|
|
65
83
|
// in other words, the directory that contains `fastly.toml`.
|
|
66
84
|
const computeAppDir = path.resolve();
|
|
@@ -116,6 +134,22 @@ export async function action(actionArgs) {
|
|
|
116
134
|
return;
|
|
117
135
|
}
|
|
118
136
|
console.log(`✔️ Collection to delete: ${collectionName}`);
|
|
137
|
+
// Purge target: checked now, so that a missing API token fails before anything is deleted.
|
|
138
|
+
let purgeTarget;
|
|
139
|
+
try {
|
|
140
|
+
purgeTarget = loadPurgeTarget({
|
|
141
|
+
localMode: localMode ?? false,
|
|
142
|
+
computeAppDir,
|
|
143
|
+
fastlyServiceId,
|
|
144
|
+
fastlyApiToken,
|
|
145
|
+
purgeEnvironments: purgeEnvironmentValues,
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
catch (err) {
|
|
149
|
+
console.error(String(err));
|
|
150
|
+
process.exitCode = 1;
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
119
153
|
// ### Asset Keys to delete
|
|
120
154
|
const assetKeysToDelete = new Set();
|
|
121
155
|
// ### List all indexes ###
|
|
@@ -144,5 +178,8 @@ export async function action(actionArgs) {
|
|
|
144
178
|
console.log(`Deleting key from storage: ${key}`);
|
|
145
179
|
await storageProvider.deleteStorageEntry(key);
|
|
146
180
|
}, undefined, true);
|
|
181
|
+
if (purgeTarget != null) {
|
|
182
|
+
await purgeCollection(purgeTarget, publishId, collectionName);
|
|
183
|
+
}
|
|
147
184
|
console.log("✅ Completed.");
|
|
148
185
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/cli/commands/manage/collections/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/cli/commands/manage/collections/index.ts"],"names":[],"mappings":"AAoDA,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,iBA0BhD"}
|
|
@@ -27,6 +27,7 @@ KV Store Options:
|
|
|
27
27
|
--local Instead of working with the Fastly KV Store, operate on
|
|
28
28
|
local files that will be used to simulate the KV Store
|
|
29
29
|
with the local development environment.
|
|
30
|
+
KV Store mode only. In S3 mode, --local is an error.
|
|
30
31
|
|
|
31
32
|
--fastly-api-token=<token> Fastly API token for KV Store access.
|
|
32
33
|
If not set, the tool uses the FASTLY_API_TOKEN
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../../../../src/cli/commands/manage/collections/list.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../../../../src/cli/commands/manage/collections/list.ts"],"names":[],"mappings":"AA6CA,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,iBA4IhD"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT license. See LICENSE file for details.
|
|
4
4
|
*/
|
|
5
5
|
import path from 'node:path';
|
|
6
|
-
import { decodeIndexMetadata } from '../../../../models/server/index.js';
|
|
6
|
+
import { decodeIndexMetadata, getUnsupportedIndexFeatures } from '../../../../models/server/index.js';
|
|
7
7
|
import { isExpired } from '../../../../models/time/index.js';
|
|
8
8
|
import { parseCommandLine } from '../../../util/args.js';
|
|
9
9
|
import { LoadConfigError, loadStaticPublisherRcFile } from '../../../util/config.js';
|
|
@@ -21,6 +21,7 @@ KV Store Options:
|
|
|
21
21
|
--local Instead of working with the Fastly KV Store, operate on
|
|
22
22
|
local files that will be used to simulate the KV Store
|
|
23
23
|
with the local development environment.
|
|
24
|
+
KV Store mode only. In S3 mode, --local is an error.
|
|
24
25
|
|
|
25
26
|
--fastly-api-token=<token> Fastly API token for KV Store access.
|
|
26
27
|
If not set, the tool uses the FASTLY_API_TOKEN
|
|
@@ -134,6 +135,14 @@ export async function action(actionArgs) {
|
|
|
134
135
|
else {
|
|
135
136
|
console.log(` Published : ${new Date(indexMetadata.publishedTime * 1000)}`);
|
|
136
137
|
}
|
|
138
|
+
if (indexMetadata.requires != null) {
|
|
139
|
+
console.log(` Requires : ${indexMetadata.requires.join(', ')}`);
|
|
140
|
+
const unsupportedFeatures = getUnsupportedIndexFeatures(indexMetadata);
|
|
141
|
+
if (unsupportedFeatures.length > 0) {
|
|
142
|
+
console.log(` ⚠️ This version does not support ${unsupportedFeatures.join(', ')}. An application`);
|
|
143
|
+
console.log(` that is built with this version will not serve this collection.`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
137
146
|
if (indexMetadata.expirationTime == null) {
|
|
138
147
|
console.log(' Expiration : not set');
|
|
139
148
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"promote.d.ts","sourceRoot":"","sources":["../../../../../../src/cli/commands/manage/collections/promote.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"promote.d.ts","sourceRoot":"","sources":["../../../../../../src/cli/commands/manage/collections/promote.ts"],"names":[],"mappings":"AAmEA,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,iBAuLhD"}
|
|
@@ -43,6 +43,7 @@ KV Store Options:
|
|
|
43
43
|
--local Instead of working with the Fastly KV Store, operate on
|
|
44
44
|
local files that will be used to simulate the KV Store
|
|
45
45
|
with the local development environment.
|
|
46
|
+
KV Store mode only. In S3 mode, --local is an error.
|
|
46
47
|
|
|
47
48
|
--fastly-api-token=<token> Fastly API token for KV Store access.
|
|
48
49
|
If not set, the tool uses the FASTLY_API_TOKEN
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-expiration.d.ts","sourceRoot":"","sources":["../../../../../../src/cli/commands/manage/collections/update-expiration.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"update-expiration.d.ts","sourceRoot":"","sources":["../../../../../../src/cli/commands/manage/collections/update-expiration.ts"],"names":[],"mappings":"AA+DA,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,iBA0JhD"}
|
|
@@ -39,6 +39,7 @@ KV Store Options:
|
|
|
39
39
|
--local Instead of working with the Fastly KV Store, operate on
|
|
40
40
|
local files that will be used to simulate the KV Store
|
|
41
41
|
with the local development environment.
|
|
42
|
+
KV Store mode only. In S3 mode, --local is an error.
|
|
42
43
|
|
|
43
44
|
--fastly-api-token=<token> Fastly API token for KV Store access.
|
|
44
45
|
If not set, the tool uses the FASTLY_API_TOKEN
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/manage/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/manage/index.ts"],"names":[],"mappings":"AA2DA,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,iBAyBhD"}
|
|
@@ -29,6 +29,7 @@ KV Store Options:
|
|
|
29
29
|
--local Instead of working with the Fastly KV Store, operate on
|
|
30
30
|
local files that will be used to simulate the KV Store
|
|
31
31
|
with the local development environment.
|
|
32
|
+
KV Store mode only. In S3 mode, --local is an error.
|
|
32
33
|
|
|
33
34
|
--fastly-api-token=<token> Fastly API token for KV Store access.
|
|
34
35
|
If not set, the tool uses the FASTLY_API_TOKEN
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publish-content.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/manage/publish-content.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"publish-content.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/manage/publish-content.ts"],"names":[],"mappings":"AA0HA,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,iBA2jBhD"}
|
|
@@ -11,9 +11,9 @@ import { mergeContentTypes, testFileContentType } from '../../util/content-types
|
|
|
11
11
|
import { LoadConfigError, loadPublishContentConfigFile, loadStaticPublisherRcFile } from '../../util/config.js';
|
|
12
12
|
import { applyDefaults } from '../../util/data.js';
|
|
13
13
|
import { calculateFileSizeAndHash, enumerateFiles, rootRelative } from '../../util/files.js';
|
|
14
|
-
import { ensureVariantFileExists } from '../../util/variants.js';
|
|
14
|
+
import { ensureVariantFileExists, OncePerKey } from '../../util/variants.js';
|
|
15
15
|
import { concurrentMap } from '../../util/retryable.js';
|
|
16
|
-
import { loadPurgeTarget,
|
|
16
|
+
import { loadPurgeTarget, purgeCollection } from '../../util/purge.js';
|
|
17
17
|
import { getStorageKeysByHexPrefix, loadStorageProviderFromStaticPublishRc, StorageProviderBatch, } from '../../storage/storage-provider.js';
|
|
18
18
|
// Storage key format:
|
|
19
19
|
// <publishId>_index_<preview_id>.json
|
|
@@ -80,6 +80,7 @@ KV Store Options:
|
|
|
80
80
|
--local Instead of working with the Fastly KV Store, operate on
|
|
81
81
|
local files that will be used to simulate the KV Store
|
|
82
82
|
with the local development environment.
|
|
83
|
+
KV Store mode only. In S3 mode, --local is an error.
|
|
83
84
|
|
|
84
85
|
--kv-overwrite Alias for --overwrite-existing.
|
|
85
86
|
|
|
@@ -306,7 +307,11 @@ export async function action(actionArgs) {
|
|
|
306
307
|
const batch = new StorageProviderBatch();
|
|
307
308
|
// Assets included in the publishing, keyed by asset key
|
|
308
309
|
const assetsIndex = {};
|
|
309
|
-
|
|
310
|
+
// For each variant that we know about during this publishing, true if the
|
|
311
|
+
// index keeps the variant. Keyed on the variant's storage key. Files with the
|
|
312
|
+
// same content have the same keys, so the first of them prepares each variant
|
|
313
|
+
// one time, and the other files await its result.
|
|
314
|
+
const variantKeeps = new OncePerKey();
|
|
310
315
|
// #### Keys that are already in storage
|
|
311
316
|
// The key of a file is the hash of its content. If the key exists, storage
|
|
312
317
|
// already has the same content. Thus we do not compress, hash, or upload it again.
|
|
@@ -369,12 +374,6 @@ export async function action(actionArgs) {
|
|
|
369
374
|
console.log(`📄 File '${rootRelative(file)}' - ${baseSize} bytes, sha256: ${baseHash}`);
|
|
370
375
|
const stats = fs.statSync(file);
|
|
371
376
|
const lastModifiedTime = Math.floor((stats.mtime).getTime() / 1000);
|
|
372
|
-
// #### Keep flag per variant
|
|
373
|
-
let variantKeeps = baseHashToVariantKeepMap.get(baseHash);
|
|
374
|
-
if (variantKeeps == null) {
|
|
375
|
-
variantKeeps = new Map();
|
|
376
|
-
baseHashToVariantKeepMap.set(baseHash, variantKeeps);
|
|
377
|
-
}
|
|
378
377
|
// We know the number of chunks of the original before we read it. For a
|
|
379
378
|
// compressed variant, we know it only if the original fits in one chunk.
|
|
380
379
|
const baseNumChunks = storageProvider.calculateNumChunks(baseSize);
|
|
@@ -384,21 +383,10 @@ export async function action(actionArgs) {
|
|
|
384
383
|
...contentCompression,
|
|
385
384
|
];
|
|
386
385
|
const batchItems = [];
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
if (variant
|
|
391
|
-
variantKey = `${variantKey}_${variant}`;
|
|
392
|
-
variantFilename = `${variantFilename}_${variant}`;
|
|
393
|
-
}
|
|
394
|
-
const variantFilePath = path.resolve(storageContentDir, variantFilename);
|
|
395
|
-
let keep = variantKeeps.get(variant);
|
|
396
|
-
if (keep != null) {
|
|
397
|
-
if (verbose) {
|
|
398
|
-
console.log(` 🏃♂️ Asset "${variantKey}" is identical to an item we already know about, reusing existing copy.`);
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
else if ((variant === 'original' || baseNumChunks === 1) &&
|
|
386
|
+
// Finds the variant in storage, or prepares it and adds it to batchItems.
|
|
387
|
+
// Returns true if the index keeps the variant.
|
|
388
|
+
async function prepareVariant(variant, variantKey, variantFilePath) {
|
|
389
|
+
if ((variant === 'original' || baseNumChunks === 1) &&
|
|
402
390
|
isVariantInStorage(variantKey, variant === 'original' ? baseNumChunks : 1)) {
|
|
403
391
|
if (verbose) {
|
|
404
392
|
console.log(` ・ Asset found in storage with key "${variantKey}".`);
|
|
@@ -406,48 +394,59 @@ export async function action(actionArgs) {
|
|
|
406
394
|
existingVariantCount++;
|
|
407
395
|
// We upload a compressed variant only if it is smaller than the
|
|
408
396
|
// original. Thus if it is in storage, the index keeps it.
|
|
409
|
-
|
|
410
|
-
|
|
397
|
+
return true;
|
|
398
|
+
}
|
|
399
|
+
await ensureVariantFileExists(variantFilePath, variant, file, verbose, { brotliQuality: publishContentConfig.brotliQuality });
|
|
400
|
+
let contentEncoding, hash, size;
|
|
401
|
+
if (variant === 'original') {
|
|
402
|
+
contentEncoding = undefined;
|
|
403
|
+
hash = baseHash;
|
|
404
|
+
size = baseSize;
|
|
411
405
|
}
|
|
412
406
|
else {
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
variantKeeps.set(variant, keep);
|
|
428
|
-
if (keep) {
|
|
429
|
-
const numChunks = storageProvider.calculateNumChunks(size);
|
|
430
|
-
const metadataJson = {
|
|
431
|
-
size: String(size),
|
|
432
|
-
hash,
|
|
433
|
-
};
|
|
434
|
-
if (contentEncoding != null) {
|
|
435
|
-
metadataJson.contentEncoding = contentEncoding;
|
|
436
|
-
}
|
|
437
|
-
if (numChunks > 1) {
|
|
438
|
-
metadataJson.numChunks = String(numChunks);
|
|
439
|
-
}
|
|
440
|
-
batchItems.push({
|
|
441
|
-
size,
|
|
442
|
-
key: variantKey,
|
|
443
|
-
filePath: variantFilePath,
|
|
444
|
-
metadataJson,
|
|
445
|
-
});
|
|
407
|
+
contentEncoding = variant;
|
|
408
|
+
({ hash, size } = await calculateFileSizeAndHash(variantFilePath));
|
|
409
|
+
}
|
|
410
|
+
// Only keep variants whose file size actually ends up smaller than
|
|
411
|
+
// what we started with. Do not upload the other variants.
|
|
412
|
+
const keep = variant === 'original' || size < baseSize;
|
|
413
|
+
if (keep) {
|
|
414
|
+
const numChunks = storageProvider.calculateNumChunks(size);
|
|
415
|
+
const metadataJson = {
|
|
416
|
+
size: String(size),
|
|
417
|
+
hash,
|
|
418
|
+
};
|
|
419
|
+
if (contentEncoding != null) {
|
|
420
|
+
metadataJson.contentEncoding = contentEncoding;
|
|
446
421
|
}
|
|
447
|
-
|
|
448
|
-
|
|
422
|
+
if (numChunks > 1) {
|
|
423
|
+
metadataJson.numChunks = String(numChunks);
|
|
449
424
|
}
|
|
425
|
+
batchItems.push({
|
|
426
|
+
size,
|
|
427
|
+
key: variantKey,
|
|
428
|
+
filePath: variantFilePath,
|
|
429
|
+
metadataJson,
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
else if (verbose) {
|
|
433
|
+
console.log(` ・ Variant "${variantKey}" is not smaller than the original, not uploading.`);
|
|
450
434
|
}
|
|
435
|
+
return keep;
|
|
436
|
+
}
|
|
437
|
+
for (const variant of variants) {
|
|
438
|
+
let variantKey = `${publishId}_files_sha256_${baseHash}`;
|
|
439
|
+
let variantFilename = `${baseHash}`;
|
|
440
|
+
if (variant !== 'original') {
|
|
441
|
+
variantKey = `${variantKey}_${variant}`;
|
|
442
|
+
variantFilename = `${variantFilename}_${variant}`;
|
|
443
|
+
}
|
|
444
|
+
const variantFilePath = path.resolve(storageContentDir, variantFilename);
|
|
445
|
+
const { promise, first } = variantKeeps.run(variantKey, () => prepareVariant(variant, variantKey, variantFilePath));
|
|
446
|
+
if (!first && verbose) {
|
|
447
|
+
console.log(` 🏃♂️ Asset "${variantKey}" is identical to an item we already know about, reusing existing copy.`);
|
|
448
|
+
}
|
|
449
|
+
const keep = await promise;
|
|
451
450
|
if (variant !== 'original' && keep) {
|
|
452
451
|
variantsToKeep.push(variant);
|
|
453
452
|
}
|
|
@@ -477,6 +476,9 @@ export async function action(actionArgs) {
|
|
|
477
476
|
if (existingKeys != null) {
|
|
478
477
|
console.log(` | ${existingVariantCount} variant(s) already in storage, ${batch.storageProviderBatchEntries.length} to upload.`);
|
|
479
478
|
}
|
|
479
|
+
else {
|
|
480
|
+
console.log(` | ${batch.storageProviderBatchEntries.length} variant(s) to upload.`);
|
|
481
|
+
}
|
|
480
482
|
await storageProvider.applyBatch(batch, { existingKeys });
|
|
481
483
|
// #### INDEX FILE
|
|
482
484
|
console.log(`🗂️ Saving Index...`);
|
|
@@ -502,7 +504,11 @@ export async function action(actionArgs) {
|
|
|
502
504
|
autoIndex: [],
|
|
503
505
|
});
|
|
504
506
|
let publicDirPrefix = server.publicDirPrefix;
|
|
505
|
-
|
|
507
|
+
if (publicDirPrefix !== '') {
|
|
508
|
+
console.log(` ✔️ Server public dir prefix '${publicDirPrefix}'.`);
|
|
509
|
+
console.log(` ⚠️ Warning: server.publicDirPrefix is deprecated, and a future version will remove it.`);
|
|
510
|
+
console.log(` * To stop using it, see https://github.com/fastly/compute-js-static-publish/blob/main/MIGRATING.md`);
|
|
511
|
+
}
|
|
506
512
|
let staticItems = server.staticItems;
|
|
507
513
|
let allowedEncodings = server.allowedEncodings;
|
|
508
514
|
let spaFile = server.spaFile;
|
|
@@ -554,18 +560,7 @@ export async function action(actionArgs) {
|
|
|
554
560
|
await storageProvider.submitStorageEntry(settingsFileKey, settingsFilePath, JSON.stringify(serverSettings));
|
|
555
561
|
console.log(`✅ Settings have been saved.`);
|
|
556
562
|
if (purgeTarget != null) {
|
|
557
|
-
|
|
558
|
-
for (const environment of purgeTarget.environments) {
|
|
559
|
-
console.log(`Purging surrogate key [${surrogateKey}] on service [${purgeTarget.serviceId}] (${environment})...`);
|
|
560
|
-
const purged = await purgeSurrogateKey(purgeTarget.fastlyApiContext, purgeTarget.serviceId, surrogateKey, true, environment);
|
|
561
|
-
if (purged) {
|
|
562
|
-
console.log('Purged');
|
|
563
|
-
}
|
|
564
|
-
else {
|
|
565
|
-
// The content is published. Only the cached copies may be stale until they expire.
|
|
566
|
-
console.warn(`⚠️ Warning: Failed purging (${environment}). Cached copies may be served until they expire.`);
|
|
567
|
-
}
|
|
568
|
-
}
|
|
563
|
+
await purgeCollection(purgeTarget, publishId, collectionName);
|
|
569
564
|
}
|
|
570
565
|
console.log(`🎉 Completed.`);
|
|
571
566
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/scaffold/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AAG,SAAS,CAAC;IAC9C,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;CAChC,CAAC;AA0TF,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,iBA6rBhD"}
|
|
@@ -50,7 +50,7 @@ Compute Service Metadata:
|
|
|
50
50
|
--service-id <id> (optional) Fastly service ID
|
|
51
51
|
|
|
52
52
|
Server Config:
|
|
53
|
-
--public-dir <path> Base dir for content (default: root-dir)
|
|
53
|
+
--public-dir <path> Deprecated. Base dir for content (default: root-dir)
|
|
54
54
|
--static-dir <path>,<path...> Directory served with long TTL (can repeat)
|
|
55
55
|
--spa <file> SPA fallback file (e.g., /index.html)
|
|
56
56
|
--not-found-page <file> 404 fallback file (e.g., /404.html)
|
|
@@ -440,6 +440,10 @@ export async function action(actionArgs) {
|
|
|
440
440
|
process.exitCode = 1;
|
|
441
441
|
return;
|
|
442
442
|
}
|
|
443
|
+
if (options.publicDir != null) {
|
|
444
|
+
console.log(`⚠️ Warning: --public-dir is deprecated, and a future version will remove it.`);
|
|
445
|
+
console.log(` * Use only --root-dir. Requests then map to the files under --root-dir.`);
|
|
446
|
+
}
|
|
443
447
|
// Resolve the public dir as well. If it's not specified, we use the root directory.
|
|
444
448
|
const PUBLIC_DIR = options.publicDir ?? ROOT_DIR;
|
|
445
449
|
const publicDir = path.resolve(PUBLIC_DIR);
|
|
@@ -738,10 +742,10 @@ port = 443
|
|
|
738
742
|
[setup.secret_stores]
|
|
739
743
|
[setup.secret_stores.S3_CREDENTIALS]
|
|
740
744
|
description = "Credentials for S3 storage"
|
|
741
|
-
[setup.secret_stores.S3_CREDENTIALS.
|
|
742
|
-
[setup.secret_stores.S3_CREDENTIALS.
|
|
745
|
+
[setup.secret_stores.S3_CREDENTIALS.entries]
|
|
746
|
+
[setup.secret_stores.S3_CREDENTIALS.entries.S3_ACCESS_KEY_ID]
|
|
743
747
|
description = "Access Key ID"
|
|
744
|
-
[setup.secret_stores.S3_CREDENTIALS.
|
|
748
|
+
[setup.secret_stores.S3_CREDENTIALS.entries.S3_SECRET_ACCESS_KEY]
|
|
745
749
|
description = "Secret Access Key"
|
|
746
750
|
`;
|
|
747
751
|
}
|
|
@@ -808,7 +812,7 @@ export default rc;
|
|
|
808
812
|
// We've already established publicDir.startsWith(rootDir)
|
|
809
813
|
let publicDirPrefix = '';
|
|
810
814
|
if (rootDir !== publicDir) {
|
|
811
|
-
publicDirPrefix =
|
|
815
|
+
publicDirPrefix = publicDir.slice(rootDir.length);
|
|
812
816
|
}
|
|
813
817
|
// staticItems - specified as prefixes, relative to publicDir
|
|
814
818
|
const staticItems = [];
|
|
@@ -856,8 +860,8 @@ const config = {
|
|
|
856
860
|
// ],
|
|
857
861
|
|
|
858
862
|
// Server settings are saved to storage per collection
|
|
859
|
-
server: {
|
|
860
|
-
publicDirPrefix: ${JSON.stringify(publicDirPrefix)}
|
|
863
|
+
server: {${publicDirPrefix !== '' ? `
|
|
864
|
+
publicDirPrefix: ${JSON.stringify(publicDirPrefix)},` : ''}
|
|
861
865
|
staticItems: ${JSON.stringify(staticItems)},
|
|
862
866
|
allowedEncodings: [ 'br', 'gzip' ],
|
|
863
867
|
spaFile: ${JSON.stringify(spaFile)},
|
|
@@ -918,8 +922,8 @@ To run your Compute application locally:
|
|
|
918
922
|
To build and deploy to your Compute service:
|
|
919
923
|
|
|
920
924
|
cd ${COMPUTE_JS_DIR}
|
|
925
|
+
npm run fastly:deploy
|
|
921
926
|
npm run fastly:publish
|
|
922
|
-
npm run fastly:start
|
|
923
927
|
|
|
924
928
|
`);
|
|
925
929
|
}
|
|
@@ -944,13 +948,28 @@ To run your Compute application locally
|
|
|
944
948
|
|
|
945
949
|
To build and deploy to your Compute service:
|
|
946
950
|
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
+
The application reads the S3 credentials from the Secret Store that has the resource
|
|
952
|
+
link name 'S3_CREDENTIALS' on the service. The Secret Store can have a different name.
|
|
953
|
+
|
|
954
|
+
To deploy to an existing service, do these steps first:
|
|
955
|
+
1. Create a Secret Store with the values 'S3_ACCESS_KEY_ID' and 'S3_SECRET_ACCESS_KEY'.
|
|
956
|
+
Give it a name that tells what it is for.
|
|
957
|
+
2. Link the Secret Store to the service, with the resource link name 'S3_CREDENTIALS'.
|
|
958
|
+
If the service already has a link with this name, make sure that it points to
|
|
959
|
+
this Secret Store.
|
|
960
|
+
|
|
951
961
|
Run the following commands:
|
|
952
962
|
cd ${COMPUTE_JS_DIR}
|
|
953
|
-
npm run fastly:
|
|
963
|
+
npm run fastly:deploy
|
|
964
|
+
|
|
965
|
+
When the Fastly CLI creates a new service, it creates a Secret Store named
|
|
966
|
+
'S3_CREDENTIALS', links it to the service with the same name, and prompts you for
|
|
967
|
+
the values 'S3_ACCESS_KEY_ID' and 'S3_SECRET_ACCESS_KEY'.
|
|
968
|
+
|
|
969
|
+
If a Secret Store named 'S3_CREDENTIALS' already exists, the Fastly CLI asks for a
|
|
970
|
+
different name. If you leave it empty, it uses the existing Secret Store. If you give
|
|
971
|
+
a different name, the Fastly CLI uses it for the resource link too. Then call
|
|
972
|
+
setSecretStoreForS3Credentials() with that name in src/index.js, and deploy again.
|
|
954
973
|
|
|
955
974
|
`);
|
|
956
975
|
}
|
|
@@ -3,6 +3,7 @@ import { type Command, type HttpHandlerOptions } from '@aws-sdk/types';
|
|
|
3
3
|
import { type StorageEntry, type StorageProvider, type StorageProviderBuilder, type StorageProviderBatch, type ApplyBatchOptions } from './storage-provider.js';
|
|
4
4
|
type CommandOutput<C> = C extends Command<any, any, any, infer O, any> ? O : never;
|
|
5
5
|
export declare const DEFAULT_S3_UPLOAD_CONCURRENCY = 64;
|
|
6
|
+
export declare const S3_LOCAL_MODE_ERROR = "--local is available only in KV Store mode. In S3 mode, the commands always use the bucket in static-publish.rc.js.";
|
|
6
7
|
export declare const buildStoreProvider: StorageProviderBuilder;
|
|
7
8
|
export declare class S3StorageProvider implements StorageProvider {
|
|
8
9
|
constructor(s3Region: string, accessKeyId: string, secretAccessKey: string, s3Bucket: string, s3Endpoint?: string, uploadConcurrency?: number);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"s3-storage-provider.d.ts","sourceRoot":"","sources":["../../../../src/cli/storage/s3-storage-provider.ts"],"names":[],"mappings":"AAQA,OAAO,EAUL,QAAQ,EAIT,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,kBAAkB,EACxB,MAAM,gBAAgB,CAAC;AASxB,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAE3B,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EACvB,MAAM,uBAAuB,CAAC;AAa/B,KAAK,aAAa,CAAC,CAAC,IAAI,CAAC,SAAS,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAKnF,eAAO,MAAM,6BAA6B,KAAK,CAAC;AAEhD,eAAO,MAAM,kBAAkB,EAAE,
|
|
1
|
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ests, and each request mostly waits for the network. In a test with small
|
|
17
17
|
// objects, 64 was approximately 4 times faster than 12.
|
|
18
18
|
export const DEFAULT_S3_UPLOAD_CONCURRENCY = 64;
|
|
19
|
+
export const S3_LOCAL_MODE_ERROR = '--local is available only in KV Store mode. In S3 mode, the commands always use the bucket in static-publish.rc.js.';
|
|
19
20
|
export const buildStoreProvider = async (config, context) => {
|
|
20
|
-
if (isS3StorageConfigRc(config)) {
|
|
21
|
-
console.log(` Working on S3 (or compatible) storage (BETA)...`);
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
21
|
+
if (!isS3StorageConfigRc(config)) {
|
|
24
22
|
return null;
|
|
25
23
|
}
|
|
24
|
+
// There is no local simulation of S3 storage. Stop before the command
|
|
25
|
+
// connects to the bucket.
|
|
26
|
+
if (context.localMode) {
|
|
27
|
+
throw new Error(S3_LOCAL_MODE_ERROR);
|
|
28
|
+
}
|
|
29
|
+
console.log(` Working on S3 (or compatible) storage (BETA)...`);
|
|
26
30
|
const { region, bucket, endpoint, } = getS3StorageConfigFromRc(config);
|
|
27
31
|
console.log(` | Using S3 storage (BETA)`);
|
|
28
32
|
console.log(` Region : ${region}`);
|
|
@@ -16,4 +16,5 @@ export type LoadPurgeTargetParams = {
|
|
|
16
16
|
};
|
|
17
17
|
export declare function loadPurgeTarget(params: LoadPurgeTargetParams): PurgeTarget | null;
|
|
18
18
|
export declare function purgeSurrogateKey(fastlyApiContext: FastlyApiContext, fastlyServiceId: string, surrogateKey: string, softPurge?: boolean, environment?: PurgeEnvironment): Promise<boolean>;
|
|
19
|
+
export declare function purgeCollection(purgeTarget: PurgeTarget, publishId: string, collectionName: string): Promise<void>;
|
|
19
20
|
//# sourceMappingURL=purge.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"purge.d.ts","sourceRoot":"","sources":["../../../../src/cli/util/purge.ts"],"names":[],"mappings":"AAOA,OAAO,EAAiB,KAAK,gBAAgB,EAA4B,MAAM,gBAAgB,CAAC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