@fastly/compute-js-static-publish 7.0.2 → 8.0.0-beta.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/README.md +13 -4
- package/README.short.md +13 -4
- package/build/cli/cli/commands/manage/clean.d.ts.map +1 -0
- package/build/cli/{commands → cli/commands}/manage/clean.js +62 -108
- package/build/cli/cli/commands/manage/collections/delete.d.ts.map +1 -0
- package/build/cli/{commands → cli/commands}/manage/collections/delete.js +50 -72
- package/build/cli/cli/commands/manage/collections/index.d.ts.map +1 -0
- package/build/cli/{commands → cli/commands}/manage/collections/index.js +15 -1
- package/build/cli/cli/commands/manage/collections/list.d.ts.map +1 -0
- package/build/cli/{commands → cli/commands}/manage/collections/list.js +45 -73
- package/build/cli/cli/commands/manage/collections/promote.d.ts.map +1 -0
- package/build/cli/{commands → cli/commands}/manage/collections/promote.js +56 -93
- package/build/cli/cli/commands/manage/collections/update-expiration.d.ts.map +1 -0
- package/build/cli/{commands → cli/commands}/manage/collections/update-expiration.js +48 -77
- package/build/cli/cli/commands/manage/index.d.ts.map +1 -0
- package/build/cli/{commands → cli/commands}/manage/index.js +15 -1
- package/build/cli/cli/commands/manage/publish-content.d.ts.map +1 -0
- package/build/cli/{commands → cli/commands}/manage/publish-content.js +90 -187
- package/build/cli/{commands → cli/commands}/scaffold/index.d.ts +4 -0
- package/build/cli/cli/commands/scaffold/index.d.ts.map +1 -0
- package/build/cli/{commands → cli/commands}/scaffold/index.js +262 -38
- package/build/cli/cli/compression/brotli.d.ts.map +1 -0
- package/build/cli/cli/compression/gzip.d.ts.map +1 -0
- package/build/cli/cli/compression/index.d.ts.map +1 -0
- package/build/cli/{index.d.ts.map → cli/index.d.ts.map} +1 -1
- package/build/cli/{index.js → cli/index.js} +8 -0
- package/build/cli/cli/storage/kv-store-local-provider.d.ts +20 -0
- package/build/cli/cli/storage/kv-store-local-provider.d.ts.map +1 -0
- package/build/cli/cli/storage/kv-store-local-provider.js +86 -0
- package/build/cli/cli/storage/kv-store-provider.d.ts +24 -0
- package/build/cli/cli/storage/kv-store-provider.d.ts.map +1 -0
- package/build/cli/cli/storage/kv-store-provider.js +182 -0
- package/build/cli/cli/storage/s3-storage-provider.d.ts +30 -0
- package/build/cli/cli/storage/s3-storage-provider.d.ts.map +1 -0
- package/build/cli/cli/storage/s3-storage-provider.js +201 -0
- package/build/cli/cli/storage/storage-provider.d.ts +44 -0
- package/build/cli/cli/storage/storage-provider.d.ts.map +1 -0
- package/build/cli/cli/storage/storage-provider.js +26 -0
- package/build/cli/cli/util/api-token.d.ts.map +1 -0
- package/build/cli/cli/util/args.d.ts.map +1 -0
- package/build/cli/cli/util/aws-credentials.d.ts +12 -0
- package/build/cli/cli/util/aws-credentials.d.ts.map +1 -0
- package/build/cli/cli/util/aws-credentials.js +67 -0
- package/build/cli/{util → cli/util}/config.d.ts +1 -1
- package/build/cli/cli/util/config.d.ts.map +1 -0
- package/build/cli/{util → cli/util}/config.js +36 -20
- package/build/cli/cli/util/content-types.d.ts.map +1 -0
- package/build/cli/cli/util/data.d.ts.map +1 -0
- package/build/cli/cli/util/fastly-toml.d.ts.map +1 -0
- package/build/cli/cli/util/files.d.ts.map +1 -0
- package/build/cli/cli/util/kv-store-items.d.ts +5 -0
- package/build/cli/cli/util/kv-store-items.d.ts.map +1 -0
- package/build/cli/{util → cli/util}/kv-store-items.js +3 -42
- package/build/cli/{util → cli/util}/kv-store-local-server.d.ts +4 -7
- package/build/cli/cli/util/kv-store-local-server.d.ts.map +1 -0
- package/build/cli/{util → cli/util}/kv-store.d.ts +7 -10
- package/build/cli/cli/util/kv-store.d.ts.map +1 -0
- package/build/cli/cli/util/node.d.ts.map +1 -0
- package/build/cli/cli/util/package.d.ts.map +1 -0
- package/build/cli/{util → cli/util}/package.js +1 -1
- package/build/cli/{util → cli/util}/retryable.d.ts +3 -0
- package/build/cli/cli/util/retryable.d.ts.map +1 -0
- package/build/cli/cli/util/retryable.js +76 -0
- package/build/cli/cli/util/s3.d.ts +7 -0
- package/build/cli/cli/util/s3.d.ts.map +1 -0
- package/build/cli/cli/util/s3.js +43 -0
- package/build/cli/cli/util/variants.d.ts.map +1 -0
- package/build/{models/assets/kvstore-assets.d.ts → cli/models/assets/index.d.ts} +5 -5
- package/build/cli/models/assets/index.d.ts.map +1 -0
- package/build/cli/models/assets/index.js +33 -0
- package/build/cli/models/compression/index.d.ts.map +1 -0
- package/build/cli/models/config/kv-store-config.d.ts +6 -0
- package/build/cli/models/config/kv-store-config.d.ts.map +1 -0
- package/build/cli/models/config/kv-store-config.js +15 -0
- package/build/{models → cli/models}/config/publish-content-config.d.ts +4 -3
- package/build/cli/models/config/publish-content-config.d.ts.map +1 -0
- package/build/cli/models/config/publisher-server-config.d.ts.map +1 -0
- package/build/cli/models/config/s3-storage-config.d.ts +8 -0
- package/build/cli/models/config/s3-storage-config.d.ts.map +1 -0
- package/build/cli/models/config/s3-storage-config.js +11 -0
- package/build/cli/models/config/static-publish-rc.d.ts +31 -0
- package/build/cli/models/config/static-publish-rc.d.ts.map +1 -0
- package/build/cli/models/config/static-publish-rc.js +39 -0
- package/build/cli/models/metadata/index.d.ts +2 -0
- package/build/cli/models/metadata/index.d.ts.map +1 -0
- package/build/cli/models/metadata/index.js +8 -0
- package/build/cli/models/server/index.d.ts +7 -0
- package/build/cli/models/server/index.d.ts.map +1 -0
- package/build/cli/models/server/index.js +26 -0
- package/build/cli/models/time/index.d.ts.map +1 -0
- package/build/{models → cli/models}/time/index.js +5 -5
- package/build/server/models/assets/index.d.ts +17 -0
- package/build/server/models/assets/index.d.ts.map +1 -0
- package/build/server/models/assets/index.js +33 -0
- package/build/server/models/compression/index.d.ts +4 -0
- package/build/server/models/compression/index.d.ts.map +1 -0
- package/build/server/models/compression/index.js +11 -0
- package/build/server/models/config/kv-store-config.d.ts +6 -0
- package/build/server/models/config/kv-store-config.d.ts.map +1 -0
- package/build/server/models/config/kv-store-config.js +15 -0
- package/build/server/models/config/publish-content-config.d.ts +40 -0
- package/build/server/models/config/publish-content-config.d.ts.map +1 -0
- package/build/server/models/config/publisher-server-config.d.ts +20 -0
- package/build/server/models/config/publisher-server-config.d.ts.map +1 -0
- package/build/server/models/config/s3-storage-config.d.ts +8 -0
- package/build/server/models/config/s3-storage-config.d.ts.map +1 -0
- package/build/server/models/config/s3-storage-config.js +11 -0
- package/build/server/models/config/static-publish-rc.d.ts +31 -0
- package/build/server/models/config/static-publish-rc.d.ts.map +1 -0
- package/build/server/models/config/static-publish-rc.js +39 -0
- package/build/server/models/metadata/index.d.ts +2 -0
- package/build/server/models/metadata/index.d.ts.map +1 -0
- package/build/server/models/metadata/index.js +8 -0
- package/build/server/models/server/index.d.ts +7 -0
- package/build/server/models/server/index.d.ts.map +1 -0
- package/build/server/models/server/index.js +26 -0
- package/build/server/models/time/index.d.ts +8 -0
- package/build/server/models/time/index.d.ts.map +1 -0
- package/build/server/models/time/index.js +54 -0
- package/build/server/server/collection-selector/from-config-store.d.ts.map +1 -0
- package/build/server/server/collection-selector/from-cookie.d.ts.map +1 -0
- package/build/server/server/collection-selector/from-request.d.ts.map +1 -0
- package/build/server/server/collection-selector/index.d.ts.map +1 -0
- package/build/server/server/collection-selector/request-collection-selector.d.ts.map +1 -0
- package/build/server/server/collection-selector/request-collection-selector.js +5 -0
- package/build/server/server/index.d.ts +8 -0
- package/build/server/server/index.d.ts.map +1 -0
- package/build/server/server/index.js +15 -0
- package/build/server/{publisher-server → server/publisher-server}/index.d.ts +14 -14
- package/build/server/server/publisher-server/index.d.ts.map +1 -0
- package/build/server/{publisher-server → server/publisher-server}/index.js +60 -61
- package/build/server/server/publisher-server/serve-preconditions/if-modified-since.d.ts.map +1 -0
- package/build/server/server/publisher-server/serve-preconditions/if-none-match.d.ts.map +1 -0
- package/build/server/server/storage/kv-store-provider.d.ts +8 -0
- package/build/server/server/storage/kv-store-provider.d.ts.map +1 -0
- package/build/server/server/storage/kv-store-provider.js +24 -0
- package/build/server/server/storage/s3-storage-provider.d.ts +26 -0
- package/build/server/server/storage/s3-storage-provider.d.ts.map +1 -0
- package/build/server/server/storage/s3-storage-provider.js +110 -0
- package/build/server/server/storage/storage-provider.d.ts +48 -0
- package/build/server/server/storage/storage-provider.d.ts.map +1 -0
- package/build/server/{util/kv-store.js → server/storage/storage-provider.js} +17 -39
- package/build/server/server/util/cookies.d.ts.map +1 -0
- package/build/server/server/util/kv-store.d.ts.map +1 -0
- package/build/server/server/util/kv-store.js +40 -0
- package/package.json +9 -5
- package/build/cli/commands/manage/clean.d.ts.map +0 -1
- package/build/cli/commands/manage/collections/delete.d.ts.map +0 -1
- package/build/cli/commands/manage/collections/index.d.ts.map +0 -1
- package/build/cli/commands/manage/collections/list.d.ts.map +0 -1
- package/build/cli/commands/manage/collections/promote.d.ts.map +0 -1
- package/build/cli/commands/manage/collections/update-expiration.d.ts.map +0 -1
- package/build/cli/commands/manage/index.d.ts.map +0 -1
- package/build/cli/commands/manage/publish-content.d.ts.map +0 -1
- package/build/cli/commands/scaffold/index.d.ts.map +0 -1
- package/build/cli/compression/brotli.d.ts.map +0 -1
- package/build/cli/compression/gzip.d.ts.map +0 -1
- package/build/cli/compression/index.d.ts.map +0 -1
- package/build/cli/util/api-token.d.ts.map +0 -1
- package/build/cli/util/args.d.ts.map +0 -1
- package/build/cli/util/config.d.ts.map +0 -1
- package/build/cli/util/content-types.d.ts.map +0 -1
- package/build/cli/util/data.d.ts.map +0 -1
- package/build/cli/util/fastly-toml.d.ts.map +0 -1
- package/build/cli/util/files.d.ts.map +0 -1
- package/build/cli/util/kv-store-items.d.ts +0 -13
- package/build/cli/util/kv-store-items.d.ts.map +0 -1
- package/build/cli/util/kv-store-local-server.d.ts.map +0 -1
- package/build/cli/util/kv-store.d.ts.map +0 -1
- package/build/cli/util/node.d.ts.map +0 -1
- package/build/cli/util/package.d.ts.map +0 -1
- package/build/cli/util/retryable.d.ts.map +0 -1
- package/build/cli/util/retryable.js +0 -43
- package/build/cli/util/variants.d.ts.map +0 -1
- package/build/index.d.ts +0 -6
- package/build/index.d.ts.map +0 -1
- package/build/index.js +0 -7
- package/build/models/assets/kvstore-assets.d.ts.map +0 -1
- package/build/models/assets/kvstore-assets.js +0 -28
- package/build/models/compression/index.d.ts.map +0 -1
- package/build/models/config/publish-content-config.d.ts.map +0 -1
- package/build/models/config/publisher-server-config.d.ts.map +0 -1
- package/build/models/config/static-publish-rc.d.ts +0 -7
- package/build/models/config/static-publish-rc.d.ts.map +0 -1
- package/build/models/server/index.d.ts +0 -5
- package/build/models/server/index.d.ts.map +0 -1
- package/build/models/server/index.js +0 -1
- package/build/models/time/index.d.ts.map +0 -1
- package/build/server/collection-selector/from-config-store.d.ts.map +0 -1
- package/build/server/collection-selector/from-cookie.d.ts.map +0 -1
- package/build/server/collection-selector/from-request.d.ts.map +0 -1
- package/build/server/collection-selector/index.d.ts.map +0 -1
- package/build/server/collection-selector/request-collection-selector.d.ts.map +0 -1
- package/build/server/publisher-server/index.d.ts.map +0 -1
- package/build/server/publisher-server/serve-preconditions/if-modified-since.d.ts.map +0 -1
- package/build/server/publisher-server/serve-preconditions/if-none-match.d.ts.map +0 -1
- package/build/server/util/cookies.d.ts.map +0 -1
- package/build/server/util/kv-store.d.ts.map +0 -1
- /package/build/cli/{commands → cli/commands}/manage/clean.d.ts +0 -0
- /package/build/cli/{commands → cli/commands}/manage/collections/delete.d.ts +0 -0
- /package/build/cli/{commands → cli/commands}/manage/collections/index.d.ts +0 -0
- /package/build/cli/{commands → cli/commands}/manage/collections/list.d.ts +0 -0
- /package/build/cli/{commands → cli/commands}/manage/collections/promote.d.ts +0 -0
- /package/build/cli/{commands → cli/commands}/manage/collections/update-expiration.d.ts +0 -0
- /package/build/cli/{commands → cli/commands}/manage/index.d.ts +0 -0
- /package/build/cli/{commands → cli/commands}/manage/publish-content.d.ts +0 -0
- /package/build/cli/{compression → cli/compression}/brotli.d.ts +0 -0
- /package/build/cli/{compression → cli/compression}/brotli.js +0 -0
- /package/build/cli/{compression → cli/compression}/gzip.d.ts +0 -0
- /package/build/cli/{compression → cli/compression}/gzip.js +0 -0
- /package/build/cli/{compression → cli/compression}/index.d.ts +0 -0
- /package/build/cli/{compression → cli/compression}/index.js +0 -0
- /package/build/cli/{index.d.ts → cli/index.d.ts} +0 -0
- /package/build/cli/{util → cli/util}/api-token.d.ts +0 -0
- /package/build/cli/{util → cli/util}/api-token.js +0 -0
- /package/build/cli/{util → cli/util}/args.d.ts +0 -0
- /package/build/cli/{util → cli/util}/args.js +0 -0
- /package/build/cli/{util → cli/util}/content-types.d.ts +0 -0
- /package/build/cli/{util → cli/util}/content-types.js +0 -0
- /package/build/cli/{util → cli/util}/data.d.ts +0 -0
- /package/build/cli/{util → cli/util}/data.js +0 -0
- /package/build/cli/{util → cli/util}/fastly-toml.d.ts +0 -0
- /package/build/cli/{util → cli/util}/fastly-toml.js +0 -0
- /package/build/cli/{util → cli/util}/files.d.ts +0 -0
- /package/build/cli/{util → cli/util}/files.js +0 -0
- /package/build/cli/{util → cli/util}/kv-store-local-server.js +0 -0
- /package/build/cli/{util → cli/util}/kv-store.js +0 -0
- /package/build/cli/{util → cli/util}/node.d.ts +0 -0
- /package/build/cli/{util → cli/util}/node.js +0 -0
- /package/build/cli/{util → cli/util}/package.d.ts +0 -0
- /package/build/cli/{util → cli/util}/variants.d.ts +0 -0
- /package/build/cli/{util → cli/util}/variants.js +0 -0
- /package/build/{models → cli/models}/compression/index.d.ts +0 -0
- /package/build/{models → cli/models}/compression/index.js +0 -0
- /package/build/{models → cli/models}/config/publish-content-config.js +0 -0
- /package/build/{models → cli/models}/config/publisher-server-config.d.ts +0 -0
- /package/build/{models → cli/models}/config/publisher-server-config.js +0 -0
- /package/build/{models → cli/models}/time/index.d.ts +0 -0
- /package/build/{models/config/static-publish-rc.js → server/models/config/publish-content-config.js} +0 -0
- /package/build/server/{collection-selector/request-collection-selector.js → models/config/publisher-server-config.js} +0 -0
- /package/build/server/{collection-selector → server/collection-selector}/from-config-store.d.ts +0 -0
- /package/build/server/{collection-selector → server/collection-selector}/from-config-store.js +0 -0
- /package/build/server/{collection-selector → server/collection-selector}/from-cookie.d.ts +0 -0
- /package/build/server/{collection-selector → server/collection-selector}/from-cookie.js +0 -0
- /package/build/server/{collection-selector → server/collection-selector}/from-request.d.ts +0 -0
- /package/build/server/{collection-selector → server/collection-selector}/from-request.js +0 -0
- /package/build/server/{collection-selector → server/collection-selector}/index.d.ts +0 -0
- /package/build/server/{collection-selector → server/collection-selector}/index.js +0 -0
- /package/build/server/{collection-selector → server/collection-selector}/request-collection-selector.d.ts +0 -0
- /package/build/server/{publisher-server → server/publisher-server}/serve-preconditions/if-modified-since.d.ts +0 -0
- /package/build/server/{publisher-server → server/publisher-server}/serve-preconditions/if-modified-since.js +0 -0
- /package/build/server/{publisher-server → server/publisher-server}/serve-preconditions/if-none-match.d.ts +0 -0
- /package/build/server/{publisher-server → server/publisher-server}/serve-preconditions/if-none-match.js +0 -0
- /package/build/server/{util → server/util}/cookies.d.ts +0 -0
- /package/build/server/{util → server/util}/cookies.js +0 -0
- /package/build/server/{util → server/util}/kv-store.d.ts +0 -0
package/README.md
CHANGED
|
@@ -6,6 +6,7 @@ This CLI tool helps you:
|
|
|
6
6
|
|
|
7
7
|
- ✅ Deploy static sites to Fastly Compute with zero backend
|
|
8
8
|
- 📦 Store files in Fastly KV Store efficiently
|
|
9
|
+
- 🎁 New in v8: Support for S3-compatible storage such as Fastly Object Storage (Beta)
|
|
9
10
|
- 🗂 Publish to named collections (`live`, `preview-42`, etc.)
|
|
10
11
|
- 🔄 Switch between collections at runtime
|
|
11
12
|
- 🧹 Clean up old or expired assets
|
|
@@ -17,19 +18,27 @@ This CLI tool helps you:
|
|
|
17
18
|
Create a directory for your project, place your static files in `./public`, then type:
|
|
18
19
|
|
|
19
20
|
```sh
|
|
20
|
-
npx @fastly/compute-js-static-publish@latest --root-dir=./public --kv-store-name=site-content
|
|
21
|
+
npx @fastly/compute-js-static-publish@latest --root-dir=./public --storage-mode=kv-store --kv-store-name=site-content
|
|
21
22
|
```
|
|
22
23
|
|
|
24
|
+
**New in v8:** S3-compatible storage (such as Fastly Object Storage) is also supported (Beta). To use this mode, type:
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
npx @fastly/compute-js-static-publish@latest --root-dir=./public --storage-mode=s3 --s3-region=<region> --s3-bucket-<bucket-name>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
For more details, see the [S3-compatible storage](https://github.com/fastly/compute-js-static-publish/blob/main/README.md#s3-compatible-storage) section in the full documentation.
|
|
31
|
+
|
|
23
32
|
### 🔧 Local Preview
|
|
24
33
|
|
|
25
34
|
```sh
|
|
26
35
|
cd compute-js
|
|
27
36
|
npm install
|
|
28
|
-
npm run dev:publish
|
|
29
|
-
npm run dev:start
|
|
37
|
+
npm run dev:publish # 'publish' your files to the simulated local KV Store or to the S3 bucket
|
|
38
|
+
npm run dev:start # preview locally
|
|
30
39
|
```
|
|
31
40
|
|
|
32
|
-
Serves your app at `http://127.0.0.1:7676
|
|
41
|
+
Serves your app at `http://127.0.0.1:7676`. If the app is using the KV Store, your content is served from a simulated KV Store managed by the development server.
|
|
33
42
|
|
|
34
43
|
### 🚀 Deploy to Production
|
|
35
44
|
|
package/README.short.md
CHANGED
|
@@ -6,6 +6,7 @@ This CLI tool helps you:
|
|
|
6
6
|
|
|
7
7
|
- ✅ Deploy static sites to Fastly Compute with zero backend
|
|
8
8
|
- 📦 Store files in Fastly KV Store efficiently
|
|
9
|
+
- 🎁 New in v8: Support for S3-compatible storage such as Fastly Object Storage (Beta)
|
|
9
10
|
- 🗂 Publish to named collections (`live`, `preview-42`, etc.)
|
|
10
11
|
- 🔄 Switch between collections at runtime
|
|
11
12
|
- 🧹 Clean up old or expired assets
|
|
@@ -17,19 +18,27 @@ This CLI tool helps you:
|
|
|
17
18
|
Create a directory for your project, place your static files in `./public`, then type:
|
|
18
19
|
|
|
19
20
|
```sh
|
|
20
|
-
npx @fastly/compute-js-static-publish@latest --root-dir=./public --kv-store-name=site-content
|
|
21
|
+
npx @fastly/compute-js-static-publish@latest --root-dir=./public --storage-mode=kv-store --kv-store-name=site-content
|
|
21
22
|
```
|
|
22
23
|
|
|
24
|
+
**New in v8:** S3-compatible storage (such as Fastly Object Storage) is also supported (Beta). To use this mode, type:
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
npx @fastly/compute-js-static-publish@latest --root-dir=./public --storage-mode=s3 --s3-region=<region> --s3-bucket-<bucket-name>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
For more details, see the [S3-compatible storage](https://github.com/fastly/compute-js-static-publish/blob/main/README.md#s3-compatible-storage) section in the full documentation.
|
|
31
|
+
|
|
23
32
|
### 🔧 Local Preview
|
|
24
33
|
|
|
25
34
|
```sh
|
|
26
35
|
cd compute-js
|
|
27
36
|
npm install
|
|
28
|
-
npm run dev:publish
|
|
29
|
-
npm run dev:start
|
|
37
|
+
npm run dev:publish # 'publish' your files to the simulated local KV Store or to the S3 bucket
|
|
38
|
+
npm run dev:start # preview locally
|
|
30
39
|
```
|
|
31
40
|
|
|
32
|
-
Serves your app at `http://127.0.0.1:7676
|
|
41
|
+
Serves your app at `http://127.0.0.1:7676`. If the app is using the KV Store, your content is served from a simulated KV Store managed by the development server.
|
|
33
42
|
|
|
34
43
|
### 🚀 Deploy to Production
|
|
35
44
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clean.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/manage/clean.ts"],"names":[],"mappings":"AA2DA,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,iBAuNhD"}
|
|
@@ -3,15 +3,11 @@
|
|
|
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
7
|
import { isExpired } from '../../../models/time/index.js';
|
|
7
|
-
import { loadApiToken } from '../../util/api-token.js';
|
|
8
8
|
import { parseCommandLine } from '../../util/args.js';
|
|
9
9
|
import { LoadConfigError, loadStaticPublisherRcFile } from '../../util/config.js';
|
|
10
|
-
import {
|
|
11
|
-
import { getKvStoreEntry, getKVStoreKeys, kvStoreDeleteEntry, } from '../../util/kv-store.js';
|
|
12
|
-
import { doKvStoreItemsOperation } from '../../util/kv-store-items.js';
|
|
13
|
-
import { getLocalKvStoreEntry, getLocalKVStoreKeys, localKvStoreDeleteEntry, } from '../../util/kv-store-local-server.js';
|
|
14
|
-
import { isNodeError } from '../../util/node.js';
|
|
10
|
+
import { loadStorageProviderFromStaticPublishRc } from '../../storage/storage-provider.js';
|
|
15
11
|
function help() {
|
|
16
12
|
console.log(`\
|
|
17
13
|
|
|
@@ -19,7 +15,7 @@ Usage:
|
|
|
19
15
|
npx @fastly/compute-js-static-publish clean [options]
|
|
20
16
|
|
|
21
17
|
Description:
|
|
22
|
-
Cleans up expired or unreferenced items in
|
|
18
|
+
Cleans up expired or unreferenced items in storage.
|
|
23
19
|
This can include expired collection indexes and orphaned content assets.
|
|
24
20
|
|
|
25
21
|
Options:
|
|
@@ -27,7 +23,7 @@ Options:
|
|
|
27
23
|
|
|
28
24
|
--dry-run Show what would be deleted without performing any deletions.
|
|
29
25
|
|
|
30
|
-
|
|
26
|
+
KV Store Options:
|
|
31
27
|
--local Instead of working with the Fastly KV Store, operate on
|
|
32
28
|
local files that will be used to simulate the KV Store
|
|
33
29
|
with the local development environment.
|
|
@@ -37,6 +33,20 @@ Global Options:
|
|
|
37
33
|
1. FASTLY_API_TOKEN environment variable
|
|
38
34
|
2. Logged-in Fastly CLI profile
|
|
39
35
|
|
|
36
|
+
S3 Storage Options:
|
|
37
|
+
--aws-access-key-id=<key> AWS Access Key ID and Secret Access Key used to
|
|
38
|
+
--aws-secret-access-key=<key> interface with S3.
|
|
39
|
+
If not set, the tool will check:
|
|
40
|
+
1. AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY
|
|
41
|
+
environment variables
|
|
42
|
+
2. The aws credentials file, see below
|
|
43
|
+
|
|
44
|
+
--aws-profile=<profile> Profile within the aws credentials file.
|
|
45
|
+
If not set, the tool will check:
|
|
46
|
+
1. AWS_PROFILE environment variable
|
|
47
|
+
2. The default profile, if set
|
|
48
|
+
|
|
49
|
+
Global Options:
|
|
40
50
|
-h, --help Show this help message and exit.
|
|
41
51
|
`);
|
|
42
52
|
}
|
|
@@ -47,6 +57,9 @@ export async function action(actionArgs) {
|
|
|
47
57
|
{ name: 'dry-run', type: Boolean },
|
|
48
58
|
{ name: 'local', type: Boolean },
|
|
49
59
|
{ name: 'fastly-api-token', type: String, },
|
|
60
|
+
{ name: 'aws-profile', type: String, },
|
|
61
|
+
{ name: 'aws-access-key-id', type: String, },
|
|
62
|
+
{ name: 'aws-secret-access-key', type: String, },
|
|
50
63
|
];
|
|
51
64
|
const parsed = parseCommandLine(actionArgs, optionDefinitions);
|
|
52
65
|
if (parsed.needHelp) {
|
|
@@ -58,49 +71,11 @@ export async function action(actionArgs) {
|
|
|
58
71
|
help();
|
|
59
72
|
return;
|
|
60
73
|
}
|
|
61
|
-
const { verbose, ['delete-expired-collections']: deleteExpiredCollections, ['dry-run']: dryRun, local: localMode, ['fastly-api-token']: fastlyApiToken, } = parsed.commandLineOptions;
|
|
74
|
+
const { verbose, ['delete-expired-collections']: deleteExpiredCollections, ['dry-run']: dryRun, local: localMode, ['fastly-api-token']: fastlyApiToken, ['aws-profile']: awsProfile, ['aws-access-key-id']: awsAccessKeyId, ['aws-secret-access-key']: awsSecretAccessKey, } = parsed.commandLineOptions;
|
|
62
75
|
// compute-js-static-publisher cli is always run from the Compute application directory
|
|
63
76
|
// in other words, the directory that contains `fastly.toml`.
|
|
64
77
|
const computeAppDir = path.resolve();
|
|
65
|
-
|
|
66
|
-
// If we do NOT, then we do not use the KV Store.
|
|
67
|
-
let serviceId;
|
|
68
|
-
try {
|
|
69
|
-
serviceId = readServiceId(path.resolve(computeAppDir, './fastly.toml'));
|
|
70
|
-
}
|
|
71
|
-
catch (err) {
|
|
72
|
-
if (isNodeError(err) && err.code === 'ENOENT') {
|
|
73
|
-
console.warn(`❌ ERROR: can't find 'fastly.toml'.`);
|
|
74
|
-
process.exitCode = 1;
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
console.warn(`❌ ERROR: can't read or parse 'fastly.toml'.`);
|
|
78
|
-
process.exitCode = 1;
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
console.log(`🧹 Cleaning KV Store entries...`);
|
|
82
|
-
// Verify targets
|
|
83
|
-
let fastlyApiContext = undefined;
|
|
84
|
-
if (localMode) {
|
|
85
|
-
console.log(` Working on local simulated KV Store...`);
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
if (serviceId === null) {
|
|
89
|
-
console.log(`❌️ 'service_id' not set in 'fastly.toml' - Deploy your Compute app to Fastly before publishing.`);
|
|
90
|
-
process.exitCode = 1;
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
const apiTokenResult = loadApiToken({ commandLine: fastlyApiToken });
|
|
94
|
-
if (apiTokenResult == null) {
|
|
95
|
-
console.error("❌ Fastly API Token not provided.");
|
|
96
|
-
console.error("Set the FASTLY_API_TOKEN environment variable to an API token that has write access to the KV Store.");
|
|
97
|
-
process.exitCode = 1;
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
fastlyApiContext = { apiToken: apiTokenResult.apiToken };
|
|
101
|
-
console.log(`✔️ Fastly API Token: ${fastlyApiContext.apiToken.slice(0, 4)}${'*'.repeat(fastlyApiContext.apiToken.length - 4)} from '${apiTokenResult.source}'`);
|
|
102
|
-
console.log(` Working on the Fastly KV Store...`);
|
|
103
|
-
}
|
|
78
|
+
console.log(`🧹 Cleaning storage entries...`);
|
|
104
79
|
// #### load config
|
|
105
80
|
let staticPublisherRc;
|
|
106
81
|
try {
|
|
@@ -119,26 +94,35 @@ export async function action(actionArgs) {
|
|
|
119
94
|
}
|
|
120
95
|
const publishId = staticPublisherRc.publishId;
|
|
121
96
|
console.log(` | Publish ID: ${publishId}`);
|
|
122
|
-
const kvStoreName = staticPublisherRc.kvStoreName;
|
|
123
|
-
console.log(` | Using KV Store: ${kvStoreName}`);
|
|
124
97
|
const defaultCollectionName = staticPublisherRc.defaultCollectionName;
|
|
125
98
|
console.log(` | Default Collection Name: ${defaultCollectionName}`);
|
|
126
99
|
const staticPublisherWorkingDir = staticPublisherRc.staticPublisherWorkingDir;
|
|
127
100
|
console.log(` | Static publisher working directory: ${staticPublisherWorkingDir}`);
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
101
|
+
// Storage Provider
|
|
102
|
+
let storageProvider;
|
|
103
|
+
try {
|
|
104
|
+
storageProvider = await loadStorageProviderFromStaticPublishRc(staticPublisherRc, {
|
|
105
|
+
computeAppDir,
|
|
106
|
+
localMode,
|
|
107
|
+
fastlyApiToken,
|
|
108
|
+
awsProfile,
|
|
109
|
+
awsAccessKeyId,
|
|
110
|
+
awsSecretAccessKey,
|
|
111
|
+
});
|
|
136
112
|
}
|
|
137
|
-
|
|
138
|
-
|
|
113
|
+
catch (err) {
|
|
114
|
+
console.error(`❌ Could not instantiate store provider`);
|
|
115
|
+
console.error(String(err));
|
|
116
|
+
process.exitCode = 1;
|
|
117
|
+
return;
|
|
139
118
|
}
|
|
119
|
+
// ### Asset keys to delete
|
|
120
|
+
const assetKeysToDelete = new Set();
|
|
121
|
+
// ### List all indexes ###
|
|
122
|
+
const indexesPrefix = publishId + '_index_';
|
|
123
|
+
const indexKeys = await storageProvider.getStorageKeys(indexesPrefix);
|
|
140
124
|
if (indexKeys == null) {
|
|
141
|
-
throw new Error(`Can't query indexes in
|
|
125
|
+
throw new Error(`Can't query indexes in storage`);
|
|
142
126
|
}
|
|
143
127
|
// ### Go through the index files, make lists
|
|
144
128
|
const foundCollections = indexKeys.map(x => x.slice(indexesPrefix.length));
|
|
@@ -147,29 +131,16 @@ export async function action(actionArgs) {
|
|
|
147
131
|
// All asset keys (hashes) that we are keeping
|
|
148
132
|
const assetsIdsInUse = new Set();
|
|
149
133
|
console.log('Processing collections:');
|
|
150
|
-
await
|
|
134
|
+
await storageProvider.doConcurrentParallel(foundCollections.map(collection => ({
|
|
151
135
|
key: indexesPrefix + collection,
|
|
152
136
|
collection,
|
|
153
137
|
})), async ({ collection }, indexKey) => {
|
|
154
138
|
console.log(`Collection: ${collection}`);
|
|
155
|
-
|
|
156
|
-
if (
|
|
157
|
-
|
|
158
|
-
}
|
|
159
|
-
else {
|
|
160
|
-
kvAssetsIndexResponse = await getKvStoreEntry(fastlyApiContext, kvStoreName, indexKey);
|
|
161
|
-
}
|
|
162
|
-
if (!kvAssetsIndexResponse) {
|
|
163
|
-
throw new Error(`Can't load KV Store entry ${indexesPrefix + collection}`);
|
|
164
|
-
}
|
|
165
|
-
let indexMetadata = {};
|
|
166
|
-
if (kvAssetsIndexResponse.metadata != null) {
|
|
167
|
-
try {
|
|
168
|
-
indexMetadata = JSON.parse(kvAssetsIndexResponse.metadata);
|
|
169
|
-
}
|
|
170
|
-
catch {
|
|
171
|
-
}
|
|
139
|
+
const indexEntryInfo = await storageProvider.getStorageEntry(indexKey);
|
|
140
|
+
if (!indexEntryInfo) {
|
|
141
|
+
throw new Error(`Can't load storage entry ${indexesPrefix + collection}`);
|
|
172
142
|
}
|
|
143
|
+
let indexMetadata = decodeIndexMetadata(indexEntryInfo.metadata) ?? {};
|
|
173
144
|
let isLive = true;
|
|
174
145
|
if (indexMetadata.expirationTime == null) {
|
|
175
146
|
console.log(' Collection has no expiration time set');
|
|
@@ -185,7 +156,7 @@ export async function action(actionArgs) {
|
|
|
185
156
|
}
|
|
186
157
|
else {
|
|
187
158
|
console.log(` 🗑️ Marking expired collection for deletion.`);
|
|
188
|
-
|
|
159
|
+
assetKeysToDelete.add(indexKey);
|
|
189
160
|
isLive = false;
|
|
190
161
|
}
|
|
191
162
|
}
|
|
@@ -194,7 +165,7 @@ export async function action(actionArgs) {
|
|
|
194
165
|
return;
|
|
195
166
|
}
|
|
196
167
|
liveCollections.add(collection);
|
|
197
|
-
const kvAssetsIndex = (await
|
|
168
|
+
const kvAssetsIndex = (await new Response(indexEntryInfo.data).json());
|
|
198
169
|
for (const [_assetKey, assetEntry] of Object.entries(kvAssetsIndex)) {
|
|
199
170
|
if (assetEntry.key.startsWith('sha256:')) {
|
|
200
171
|
assetsIdsInUse.add(`sha256_${assetEntry.key.slice('sha256:'.length)}`);
|
|
@@ -205,15 +176,9 @@ export async function action(actionArgs) {
|
|
|
205
176
|
// ### List all settings ###
|
|
206
177
|
console.log('Enumerating settings:');
|
|
207
178
|
const settingsPrefix = publishId + '_settings_';
|
|
208
|
-
|
|
209
|
-
if (localMode) {
|
|
210
|
-
settingsKeys = await getLocalKVStoreKeys(storeFile, settingsPrefix);
|
|
211
|
-
}
|
|
212
|
-
else {
|
|
213
|
-
settingsKeys = await getKVStoreKeys(fastlyApiContext, kvStoreName, settingsPrefix);
|
|
214
|
-
}
|
|
179
|
+
const settingsKeys = await storageProvider.getStorageKeys(settingsPrefix);
|
|
215
180
|
if (settingsKeys == null) {
|
|
216
|
-
throw new Error(`Can't query settings in
|
|
181
|
+
throw new Error(`Can't query settings in storage`);
|
|
217
182
|
}
|
|
218
183
|
// If a settings object is found that doesn't match a live collection name then
|
|
219
184
|
// mark it for deletion
|
|
@@ -222,20 +187,14 @@ export async function action(actionArgs) {
|
|
|
222
187
|
console.log(`Settings: ${foundSettings.name}`);
|
|
223
188
|
if (!liveCollections.has(foundSettings.name)) {
|
|
224
189
|
console.log(` 🗑️ Does not match a live index, marking for deletion.`);
|
|
225
|
-
|
|
190
|
+
assetKeysToDelete.add(foundSettings.key);
|
|
226
191
|
}
|
|
227
192
|
}
|
|
228
193
|
console.log('');
|
|
229
|
-
// ### Obtain the assets in
|
|
194
|
+
// ### Obtain the assets in storage and find the ones that are not in use
|
|
230
195
|
console.log('Enumerating assets:');
|
|
231
196
|
const assetPrefix = publishId + '_files_';
|
|
232
|
-
|
|
233
|
-
if (localMode) {
|
|
234
|
-
assetKeys = await getLocalKVStoreKeys(storeFile, assetPrefix);
|
|
235
|
-
}
|
|
236
|
-
else {
|
|
237
|
-
assetKeys = await getKVStoreKeys(fastlyApiContext, kvStoreName, assetPrefix);
|
|
238
|
-
}
|
|
197
|
+
const assetKeys = await storageProvider.getStorageKeys(assetPrefix);
|
|
239
198
|
if (assetKeys == null) {
|
|
240
199
|
throw new Error(`Can't query assets in KV Store`);
|
|
241
200
|
}
|
|
@@ -252,25 +211,20 @@ export async function action(actionArgs) {
|
|
|
252
211
|
console.log(` ${assetId}: in use`);
|
|
253
212
|
}
|
|
254
213
|
else {
|
|
255
|
-
|
|
214
|
+
assetKeysToDelete.add(assetKey);
|
|
256
215
|
console.log(` ${assetId}: not in use - ✅ marking for deletion`);
|
|
257
216
|
}
|
|
258
217
|
}
|
|
259
218
|
console.log('');
|
|
260
219
|
// ### Delete items that have been flagged
|
|
261
|
-
const items = [...
|
|
262
|
-
await
|
|
220
|
+
const items = [...assetKeysToDelete].map(key => ({ key }));
|
|
221
|
+
await storageProvider.doConcurrentParallel(items, async (_, key) => {
|
|
263
222
|
if (dryRun) {
|
|
264
223
|
console.log(`[DRY RUN] Deleting item: ${key}`);
|
|
265
224
|
}
|
|
266
225
|
else {
|
|
267
|
-
console.log(`Deleting
|
|
268
|
-
|
|
269
|
-
await localKvStoreDeleteEntry(storeFile, key);
|
|
270
|
-
}
|
|
271
|
-
else {
|
|
272
|
-
await kvStoreDeleteEntry(fastlyApiContext, kvStoreName, key);
|
|
273
|
-
}
|
|
226
|
+
console.log(`Deleting key from storage: ${key}`);
|
|
227
|
+
await storageProvider.deleteStorageEntry(key);
|
|
274
228
|
}
|
|
275
229
|
});
|
|
276
230
|
console.log('✅ Completed.');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../../../../src/cli/commands/manage/collections/delete.ts"],"names":[],"mappings":"AAyDA,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,iBAwIhD"}
|
|
@@ -3,14 +3,9 @@
|
|
|
3
3
|
* Licensed under the MIT license. See LICENSE file for details.
|
|
4
4
|
*/
|
|
5
5
|
import path from 'node:path';
|
|
6
|
-
import {
|
|
7
|
-
import { parseCommandLine } from "../../../util/args.js";
|
|
6
|
+
import { parseCommandLine } from '../../../util/args.js';
|
|
8
7
|
import { LoadConfigError, loadStaticPublisherRcFile } from '../../../util/config.js';
|
|
9
|
-
import {
|
|
10
|
-
import { getKVStoreKeys, kvStoreDeleteEntry } from '../../../util/kv-store.js';
|
|
11
|
-
import { doKvStoreItemsOperation } from '../../../util/kv-store-items.js';
|
|
12
|
-
import { getLocalKVStoreKeys, localKvStoreDeleteEntry } from '../../../util/kv-store-local-server.js';
|
|
13
|
-
import { isNodeError } from '../../../util/node.js';
|
|
8
|
+
import { loadStorageProviderFromStaticPublishRc } from '../../../storage/storage-provider.js';
|
|
14
9
|
function help() {
|
|
15
10
|
console.log(`\
|
|
16
11
|
|
|
@@ -18,7 +13,7 @@ Usage:
|
|
|
18
13
|
npx @fastly/compute-js-static-publish collections delete --collection-name=<name> [options]
|
|
19
14
|
|
|
20
15
|
Description:
|
|
21
|
-
Deletes a collection index from
|
|
16
|
+
Deletes a collection index from storage. The content files will remain as they may still
|
|
22
17
|
be referenced by other collection indexes.
|
|
23
18
|
|
|
24
19
|
Use the 'npx @fastly/compute-js-static-publish clean' command afterward to remove content
|
|
@@ -27,7 +22,7 @@ Description:
|
|
|
27
22
|
Required:
|
|
28
23
|
--collection-name=<name> The name of the collection to delete
|
|
29
24
|
|
|
30
|
-
|
|
25
|
+
KV Store Options:
|
|
31
26
|
--local Instead of working with the Fastly KV Store, operate on
|
|
32
27
|
local files that will be used to simulate the KV Store
|
|
33
28
|
with the local development environment.
|
|
@@ -37,6 +32,20 @@ Global Options:
|
|
|
37
32
|
1. FASTLY_API_TOKEN environment variable
|
|
38
33
|
2. Logged-in Fastly CLI profile
|
|
39
34
|
|
|
35
|
+
S3 Storage Options:
|
|
36
|
+
--aws-access-key-id=<key> AWS Access Key ID and Secret Access Key used to
|
|
37
|
+
--aws-secret-access-key=<key> interface with S3.
|
|
38
|
+
If not set, the tool will check:
|
|
39
|
+
1. AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY
|
|
40
|
+
environment variables
|
|
41
|
+
2. The aws credentials file, see below
|
|
42
|
+
|
|
43
|
+
--aws-profile=<profile> Profile within the aws credentials file.
|
|
44
|
+
If not set, the tool will check:
|
|
45
|
+
1. AWS_PROFILE environment variable
|
|
46
|
+
2. The default profile, if set
|
|
47
|
+
|
|
48
|
+
Global Options:
|
|
40
49
|
-h, --help Show this help message and exit.
|
|
41
50
|
`);
|
|
42
51
|
}
|
|
@@ -46,6 +55,9 @@ export async function action(actionArgs) {
|
|
|
46
55
|
{ name: 'collection-name', type: String },
|
|
47
56
|
{ name: 'local', type: Boolean },
|
|
48
57
|
{ name: 'fastly-api-token', type: String, },
|
|
58
|
+
{ name: 'aws-profile', type: String, },
|
|
59
|
+
{ name: 'aws-access-key-id', type: String, },
|
|
60
|
+
{ name: 'aws-secret-access-key', type: String, },
|
|
49
61
|
];
|
|
50
62
|
const parsed = parseCommandLine(actionArgs, optionDefinitions);
|
|
51
63
|
if (parsed.needHelp) {
|
|
@@ -57,7 +69,7 @@ export async function action(actionArgs) {
|
|
|
57
69
|
help();
|
|
58
70
|
return;
|
|
59
71
|
}
|
|
60
|
-
const { verbose, ['collection-name']: collectionNameValue, ['fastly-api-token']: fastlyApiToken, local: localMode, } = parsed.commandLineOptions;
|
|
72
|
+
const { verbose, ['collection-name']: collectionNameValue, ['fastly-api-token']: fastlyApiToken, local: localMode, ['aws-profile']: awsProfile, ['aws-access-key-id']: awsAccessKeyId, ['aws-secret-access-key']: awsSecretAccessKey, } = parsed.commandLineOptions;
|
|
61
73
|
// compute-js-static-publisher cli is always run from the Compute application directory
|
|
62
74
|
// in other words, the directory that contains `fastly.toml`.
|
|
63
75
|
const computeAppDir = path.resolve();
|
|
@@ -66,45 +78,7 @@ export async function action(actionArgs) {
|
|
|
66
78
|
process.exitCode = 1;
|
|
67
79
|
return;
|
|
68
80
|
}
|
|
69
|
-
|
|
70
|
-
// If we do NOT, then we do not use the KV Store.
|
|
71
|
-
let serviceId;
|
|
72
|
-
try {
|
|
73
|
-
serviceId = readServiceId(path.resolve(computeAppDir, './fastly.toml'));
|
|
74
|
-
}
|
|
75
|
-
catch (err) {
|
|
76
|
-
if (isNodeError(err) && err.code === 'ENOENT') {
|
|
77
|
-
console.warn(`❌ ERROR: can't find 'fastly.toml'.`);
|
|
78
|
-
process.exitCode = 1;
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
console.warn(`❌ ERROR: can't read or parse 'fastly.toml'.`);
|
|
82
|
-
process.exitCode = 1;
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
console.log(`🧹 Cleaning KV Store entries...`);
|
|
86
|
-
// Verify targets
|
|
87
|
-
let fastlyApiContext = undefined;
|
|
88
|
-
if (localMode) {
|
|
89
|
-
console.log(` Working on local simulated KV Store...`);
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
if (serviceId === null) {
|
|
93
|
-
console.log(`❌️ 'service_id' not set in 'fastly.toml' - Deploy your Compute app to Fastly before publishing.`);
|
|
94
|
-
process.exitCode = 1;
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
const apiTokenResult = loadApiToken({ commandLine: fastlyApiToken });
|
|
98
|
-
if (apiTokenResult == null) {
|
|
99
|
-
console.error("❌ Fastly API Token not provided.");
|
|
100
|
-
console.error("Set the FASTLY_API_TOKEN environment variable to an API token that has write access to the KV Store.");
|
|
101
|
-
process.exitCode = 1;
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
fastlyApiContext = { apiToken: apiTokenResult.apiToken };
|
|
105
|
-
console.log(`✔️ Fastly API Token: ${fastlyApiContext.apiToken.slice(0, 4)}${'*'.repeat(fastlyApiContext.apiToken.length - 4)} from '${apiTokenResult.source}'`);
|
|
106
|
-
console.log(` Working on the Fastly KV Store...`);
|
|
107
|
-
}
|
|
81
|
+
console.log(`🧹 Deleting storage collection...`);
|
|
108
82
|
// #### load config
|
|
109
83
|
let staticPublisherRc;
|
|
110
84
|
try {
|
|
@@ -123,13 +97,28 @@ export async function action(actionArgs) {
|
|
|
123
97
|
}
|
|
124
98
|
const publishId = staticPublisherRc.publishId;
|
|
125
99
|
console.log(` | Publish ID: ${publishId}`);
|
|
126
|
-
const kvStoreName = staticPublisherRc.kvStoreName;
|
|
127
|
-
console.log(` | Using KV Store: ${kvStoreName}`);
|
|
128
100
|
const defaultCollectionName = staticPublisherRc.defaultCollectionName;
|
|
129
101
|
console.log(` | Default Collection Name: ${defaultCollectionName}`);
|
|
130
102
|
const staticPublisherWorkingDir = staticPublisherRc.staticPublisherWorkingDir;
|
|
131
103
|
console.log(` | Static publisher working directory: ${staticPublisherWorkingDir}`);
|
|
132
|
-
|
|
104
|
+
// Storage Provider
|
|
105
|
+
let storageProvider;
|
|
106
|
+
try {
|
|
107
|
+
storageProvider = await loadStorageProviderFromStaticPublishRc(staticPublisherRc, {
|
|
108
|
+
computeAppDir,
|
|
109
|
+
localMode,
|
|
110
|
+
fastlyApiToken,
|
|
111
|
+
awsProfile,
|
|
112
|
+
awsAccessKeyId,
|
|
113
|
+
awsSecretAccessKey,
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
catch (err) {
|
|
117
|
+
console.error(`❌ Could not instantiate store provider`);
|
|
118
|
+
console.error(String(err));
|
|
119
|
+
process.exitCode = 1;
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
133
122
|
const collectionName = collectionNameValue;
|
|
134
123
|
if (collectionName === defaultCollectionName) {
|
|
135
124
|
console.error(`❌ Cannot delete default collection: ${collectionName}`);
|
|
@@ -137,19 +126,13 @@ export async function action(actionArgs) {
|
|
|
137
126
|
return;
|
|
138
127
|
}
|
|
139
128
|
console.log(`✔️ Collection to delete: ${collectionName}`);
|
|
140
|
-
// ###
|
|
141
|
-
const
|
|
129
|
+
// ### Asset Keys to delete
|
|
130
|
+
const assetKeysToDelete = new Set();
|
|
142
131
|
// ### List all indexes ###
|
|
143
132
|
const indexesPrefix = publishId + '_index_';
|
|
144
|
-
|
|
145
|
-
if (localMode) {
|
|
146
|
-
indexKeys = await getLocalKVStoreKeys(storeFile, indexesPrefix);
|
|
147
|
-
}
|
|
148
|
-
else {
|
|
149
|
-
indexKeys = await getKVStoreKeys(fastlyApiContext, kvStoreName, indexesPrefix);
|
|
150
|
-
}
|
|
133
|
+
const indexKeys = await storageProvider.getStorageKeys(indexesPrefix);
|
|
151
134
|
if (indexKeys == null) {
|
|
152
|
-
throw new Error(`Can't query indexes in
|
|
135
|
+
throw new Error(`Can't query indexes in storage`);
|
|
153
136
|
}
|
|
154
137
|
// ### Found collections ###
|
|
155
138
|
const foundCollections = indexKeys.map(key => ({ key, name: key.slice(indexesPrefix.length), }));
|
|
@@ -161,20 +144,15 @@ export async function action(actionArgs) {
|
|
|
161
144
|
for (const collection of foundCollections) {
|
|
162
145
|
if (collection.name === collectionName) {
|
|
163
146
|
console.log(`Flagging collection '${collection.name}' for deletion: ${collection.key}`);
|
|
164
|
-
|
|
147
|
+
assetKeysToDelete.add(collection.key);
|
|
165
148
|
}
|
|
166
149
|
}
|
|
167
150
|
}
|
|
168
151
|
// ### Delete items that have been flagged
|
|
169
|
-
const items = [...
|
|
170
|
-
await
|
|
171
|
-
console.log(`Deleting key from
|
|
172
|
-
|
|
173
|
-
await localKvStoreDeleteEntry(storeFile, key);
|
|
174
|
-
}
|
|
175
|
-
else {
|
|
176
|
-
await kvStoreDeleteEntry(fastlyApiContext, kvStoreName, key);
|
|
177
|
-
}
|
|
152
|
+
const items = [...assetKeysToDelete].map(key => ({ key }));
|
|
153
|
+
await storageProvider.doConcurrentParallel(items, async (_, key) => {
|
|
154
|
+
console.log(`Deleting key from storage: ${key}`);
|
|
155
|
+
await storageProvider.deleteStorageEntry(key);
|
|
178
156
|
});
|
|
179
157
|
console.log("✅ Completed.");
|
|
180
158
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/cli/commands/manage/collections/index.ts"],"names":[],"mappings":"AA2DA,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,iBA0BhD"}
|
|
@@ -23,7 +23,7 @@ Available Subcommands:
|
|
|
23
23
|
to a new collection name
|
|
24
24
|
update-expiration Modify expiration time for an existing collection
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
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.
|
|
@@ -33,6 +33,20 @@ Global Options:
|
|
|
33
33
|
1. FASTLY_API_TOKEN environment variable
|
|
34
34
|
2. Logged-in Fastly CLI profile
|
|
35
35
|
|
|
36
|
+
S3 Storage Options:
|
|
37
|
+
--aws-access-key-id=<key> AWS Access Key ID and Secret Access Key used to
|
|
38
|
+
--aws-secret-access-key=<key> interface with S3.
|
|
39
|
+
If not set, the tool will check:
|
|
40
|
+
1. AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY
|
|
41
|
+
environment variables
|
|
42
|
+
2. The aws credentials file, see below
|
|
43
|
+
|
|
44
|
+
--aws-profile=<profile> Profile within the aws credentials file.
|
|
45
|
+
If not set, the tool will check:
|
|
46
|
+
1. AWS_PROFILE environment variable
|
|
47
|
+
2. The default profile, if set
|
|
48
|
+
|
|
49
|
+
Global Options:
|
|
36
50
|
-h, --help Show this help message and exit.
|
|
37
51
|
|
|
38
52
|
Examples:
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../../../../src/cli/commands/manage/collections/list.ts"],"names":[],"mappings":"AAoDA,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,iBAsIhD"}
|