@fastly/compute-js-static-publish 8.1.0-beta.1 → 8.1.0-beta.3

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.
Files changed (71) hide show
  1. package/DOCUMENTATION.md +38 -36
  2. package/README.md +26 -3
  3. package/README.short.md +26 -3
  4. package/build/cli/cli/commands/manage/clean.d.ts.map +1 -1
  5. package/build/cli/cli/commands/manage/clean.js +2 -1
  6. package/build/cli/cli/commands/manage/collections/delete.d.ts.map +1 -1
  7. package/build/cli/cli/commands/manage/collections/delete.js +3 -2
  8. package/build/cli/cli/commands/manage/collections/index.d.ts.map +1 -1
  9. package/build/cli/cli/commands/manage/collections/index.js +4 -3
  10. package/build/cli/cli/commands/manage/collections/list.d.ts.map +1 -1
  11. package/build/cli/cli/commands/manage/collections/list.js +10 -11
  12. package/build/cli/cli/commands/manage/collections/promote.d.ts.map +1 -1
  13. package/build/cli/cli/commands/manage/collections/promote.js +2 -1
  14. package/build/cli/cli/commands/manage/collections/update-expiration.d.ts.map +1 -1
  15. package/build/cli/cli/commands/manage/collections/update-expiration.js +2 -1
  16. package/build/cli/cli/commands/manage/deploy.d.ts.map +1 -1
  17. package/build/cli/cli/commands/manage/deploy.js +48 -11
  18. package/build/cli/cli/commands/manage/dev.d.ts.map +1 -1
  19. package/build/cli/cli/commands/manage/dev.js +2 -1
  20. package/build/cli/cli/commands/manage/eject.d.ts.map +1 -1
  21. package/build/cli/cli/commands/manage/eject.js +24 -7
  22. package/build/cli/cli/commands/manage/index.d.ts.map +1 -1
  23. package/build/cli/cli/commands/manage/index.js +6 -5
  24. package/build/cli/cli/commands/manage/publish-content.d.ts.map +1 -1
  25. package/build/cli/cli/commands/manage/publish-content.js +9 -5
  26. package/build/cli/cli/commands/manage/status.d.ts.map +1 -1
  27. package/build/cli/cli/commands/manage/status.js +8 -2
  28. package/build/cli/cli/commands/manage/template/index.d.ts.map +1 -1
  29. package/build/cli/cli/commands/manage/template/index.js +2 -1
  30. package/build/cli/cli/commands/manage/template/init.js +3 -3
  31. package/build/cli/cli/commands/manage/upgrade.js +2 -2
  32. package/build/cli/cli/commands/run-dev-watch.d.ts +1 -0
  33. package/build/cli/cli/commands/run-dev-watch.d.ts.map +1 -1
  34. package/build/cli/cli/commands/run-dev-watch.js +45 -9
  35. package/build/cli/cli/commands/scaffold/generate-app.d.ts +8 -3
  36. package/build/cli/cli/commands/scaffold/generate-app.d.ts.map +1 -1
  37. package/build/cli/cli/commands/scaffold/generate-app.js +11 -1
  38. package/build/cli/cli/commands/scaffold/index.d.ts +3 -3
  39. package/build/cli/cli/commands/scaffold/index.d.ts.map +1 -1
  40. package/build/cli/cli/commands/scaffold/index.js +18 -21
  41. package/build/cli/cli/hono/build.d.ts.map +1 -1
  42. package/build/cli/cli/hono/build.js +2 -1
  43. package/build/cli/cli/managed/app.d.ts +1 -1
  44. package/build/cli/cli/managed/app.d.ts.map +1 -1
  45. package/build/cli/cli/managed/app.js +5 -3
  46. package/build/cli/cli/managed/command-helpers.js +2 -2
  47. package/build/cli/cli/managed/lockfile.js +1 -1
  48. package/build/cli/cli/managed/project-file.d.ts.map +1 -1
  49. package/build/cli/cli/managed/project-file.js +4 -3
  50. package/build/cli/cli/util/config.d.ts.map +1 -1
  51. package/build/cli/cli/util/config.js +9 -0
  52. package/build/cli/cli/util/global-options.js +1 -1
  53. package/build/cli/cli/util/package.d.ts +4 -0
  54. package/build/cli/cli/util/package.d.ts.map +1 -1
  55. package/build/cli/cli/util/package.js +43 -0
  56. package/build/cli/cli/util/s3.d.ts +10 -4
  57. package/build/cli/cli/util/s3.d.ts.map +1 -1
  58. package/build/cli/cli/util/s3.js +13 -35
  59. package/build/cli/models/config/publish-content-config.d.ts +1 -0
  60. package/build/cli/models/config/publish-content-config.d.ts.map +1 -1
  61. package/build/cli/models/server/index.d.ts +2 -0
  62. package/build/cli/models/server/index.d.ts.map +1 -1
  63. package/build/cli/models/server/index.js +13 -1
  64. package/build/server/models/config/publish-content-config.d.ts +1 -0
  65. package/build/server/models/config/publish-content-config.d.ts.map +1 -1
  66. package/build/server/models/server/index.d.ts +2 -0
  67. package/build/server/models/server/index.d.ts.map +1 -1
  68. package/build/server/models/server/index.js +13 -1
  69. package/package.json +1 -1
  70. package/resources/app/publish-content.config.js.njk +1 -0
  71. package/resources/templates/plain/src/index.js +12 -2
package/DOCUMENTATION.md CHANGED
@@ -257,8 +257,8 @@ Paths in the project file are relative to it. The name of the file marks the mod
257
257
  To run the app on your computer:
258
258
 
259
259
  ```sh
260
- npx @fastly/compute-js-static-publish publish-content --local
261
- npx @fastly/compute-js-static-publish dev
260
+ npx @fastly/compute-js-static-publish@beta publish-content --local
261
+ npx @fastly/compute-js-static-publish@beta dev
262
262
  ```
263
263
 
264
264
  `dev` generates the app in `.static-publish/app/`, installs its dependencies with `npm ci` if they changed, and runs `fastly compute serve` in it. Options after `--` go to `fastly compute serve`, for example `dev -- --addr=127.0.0.1:8080`. With `dev -- --watch`, a change in the app builds and restarts it, and the watch script of the template (`scripts/template_watch.js`, see [Template hooks](#-template-hooks)), if it has one, runs next to `fastly compute serve`. The app serves the content of the local KV Store, `kvstore.json` in the working directory.
@@ -297,13 +297,13 @@ npm install --save-dev @fastly/compute-js-static-publish
297
297
  To deploy the app:
298
298
 
299
299
  ```sh
300
- npx @fastly/compute-js-static-publish deploy
300
+ npx @fastly/compute-js-static-publish@beta deploy
301
301
  ```
302
302
 
303
303
  `deploy` generates the app, installs it if necessary, and runs `fastly compute build` and `fastly compute deploy`, only if the app changed. It needs a Fastly API token (`FASTLY_API_TOKEN` or `--fastly-api-token`).
304
304
 
305
305
  - **The fingerprint** is a SHA-256 of the generated app and the version of this package. It does not depend on the content, on `publishContent`, on the Service ID, or on the path of this package on your computer. `deploy` writes it into the comment of the new service version (`static-publish <version> fp:<fingerprint>`, then ` | <text>` with `--comment <text>`, for example a commit SHA). The next `deploy` reads the comment of the active version, and does nothing if the fingerprint is the same. `--force` deploys anyway.
306
- - **The first deploy** makes a new service (the Fastly CLI asks for its name and domain, unless `--non-interactive`), and writes its ID into `managed.serviceId`. Commit the project file then. To deploy to a service that exists, use `--fastly-service-id` or `FASTLY_SERVICE_ID`. With S3 storage, the first deploy must be done on your computer, because the Fastly CLI asks for the S3 credentials of the Secret Store; with `--non-interactive`, it is an error.
306
+ - **The first deploy** makes a new service (the Fastly CLI asks for its name and domain, unless `--non-interactive`), and writes its ID into `managed.serviceId`. Commit the project file then. To deploy to a service that exists, use `--fastly-service-id` or `FASTLY_SERVICE_ID`. These do not change `managed.serviceId`: to make a service that exists the service of the project, set `managed.serviceId` in the project file. With S3 storage, the first deploy must be done on your computer, because the Fastly CLI asks for the S3 credentials of the Secret Store; with `--non-interactive`, it is an error.
307
307
  - `status` shows the fingerprint of the app, the fingerprint of the active version, and if a deploy is necessary, and the preview URLs of [collection selection](#-previews-collection-selection). Without an API token, the deployed fingerprint is unknown.
308
308
 
309
309
  **The version of this package.** `managed.staticPublishVersion` records the version of this package that the project uses. `dev` and `deploy` compare it with the version that runs:
@@ -361,7 +361,7 @@ The app also has a `dev:watch` script:
361
361
  "dev:watch": "compute-js-static-publish run-dev-watch"
362
362
  ```
363
363
 
364
- `npm run dev:watch` runs `fastly compute serve --watch`, which builds and restarts the app when a file in the app directory changes. Options after `--` go to `fastly compute serve`, for example `npm run dev:watch -- --addr=127.0.0.1:8080`. If the app has `scripts/template_watch.js`, that file runs with Node.js next to the Fastly CLI, until the Fastly CLI stops. Use it to watch files outside the app directory: when they change, write a file in the app directory, and the Fastly CLI builds the app again.
364
+ `npm run dev:watch` runs `fastly compute serve --watch`, which builds and restarts the app when a file in the app directory changes. Options after `--` go to `fastly compute serve`, for example `npm run dev:watch -- --addr=127.0.0.1:8080`. If the app has `scripts/template_watch.js`, that file runs with Node.js next to the Fastly CLI, until the Fastly CLI stops. Use it to watch files outside the app directory: when they change, write a file in the app directory, and the Fastly CLI builds the app again. `dev:watch` does not work on Windows.
365
365
 
366
366
  ## ⚙️ Configuring `static-publish.rc.js`
367
367
 
@@ -550,7 +550,7 @@ Collections are a powerful feature that allow you to publish and manage multiple
550
550
  Collections are published using a `--collection-name`, and can be reused, updated, or deleted independently. For example, you can create a staging version of your site using:
551
551
 
552
552
  ```sh
553
- npx @fastly/compute-js-static-publish publish-content \
553
+ npx @fastly/compute-js-static-publish@beta publish-content \
554
554
  --collection-name=staging \
555
555
  --expires-in=7d \
556
556
  --config=./publish-content.config.js
@@ -733,7 +733,7 @@ jobs:
733
733
  with:
734
734
  node-version: 24
735
735
  - run: npm ci
736
- - run: npx @fastly/compute-js-static-publish publish-content --collection-name=pr-${{ github.event.number }} --expires-in=7d
736
+ - run: npx @fastly/compute-js-static-publish@beta publish-content --collection-name=pr-${{ github.event.number }} --expires-in=7d
737
737
 
738
738
  remove:
739
739
  if: github.event.action == 'closed'
@@ -750,8 +750,8 @@ jobs:
750
750
  with:
751
751
  node-version: 24
752
752
  - run: npm ci
753
- - run: npx @fastly/compute-js-static-publish collections delete --collection-name=pr-${{ github.event.number }}
754
- - run: npx @fastly/compute-js-static-publish clean --delete-expired-collections
753
+ - run: npx @fastly/compute-js-static-publish@beta collections delete --collection-name=pr-${{ github.event.number }}
754
+ - run: npx @fastly/compute-js-static-publish@beta clean --delete-expired-collections
755
755
  ```
756
756
 
757
757
  For a pull request that never published, `collections delete` finds no collection and deletes nothing.
@@ -795,7 +795,7 @@ collectionSelector.fromConfigStore('my-config-store', 'collection-key');
795
795
  If you're happy with a preview or staging collection and want to make it live, use the `collections promote` command:
796
796
 
797
797
  ```sh
798
- npx @fastly/compute-js-static-publish collections promote \
798
+ npx @fastly/compute-js-static-publish@beta collections promote \
799
799
  --collection-name=staging
800
800
  --to=live
801
801
  ```
@@ -805,7 +805,7 @@ This copies all content and server settings from the `staging` collection to `li
805
805
  You can also specify a new expiration:
806
806
 
807
807
  ```sh
808
- npx @fastly/compute-js-static-publish collections promote \
808
+ npx @fastly/compute-js-static-publish@beta collections promote \
809
809
  --collection-name=preview-42 \
810
810
  --to=staging \
811
811
  --expires-in=7d
@@ -975,7 +975,7 @@ npm run fastly:clean
975
975
 
976
976
  These scripts run against the local and Fastly KV Stores respectively, and run the following command:
977
977
  ```
978
- npx @fastly/compute-js-static-publish clean --delete-expired-collections
978
+ npx @fastly/compute-js-static-publish@beta clean --delete-expired-collections
979
979
  ```
980
980
 
981
981
  This removes:
@@ -992,7 +992,7 @@ This removes:
992
992
  Preview what will be deleted without making changes:
993
993
 
994
994
  ```sh
995
- npx @fastly/compute-js-static-publish clean --dry-run
995
+ npx @fastly/compute-js-static-publish@beta clean --dry-run
996
996
  ```
997
997
 
998
998
  > ⚠️ Cleanup never deletes the default collection and never deletes content that’s still in use.
@@ -1014,7 +1014,9 @@ Assets are stored in multiple formats (uncompressed + compressed) if configured.
1014
1014
 
1015
1015
  ## 🧩 Using PublisherServer in Custom Apps
1016
1016
 
1017
- You can combine PublisherServer with custom logic to support APIs, authentication, redirects, or A/B testing. `PublisherServer` returns `null` when it cannot handle a request, allowing you to chain in your own logic.
1017
+ You can combine PublisherServer with custom logic to support APIs, authentication, redirects, or A/B testing. Handle your own routes before you call `serveRequest()`.
1018
+
1019
+ `serveRequest()` returns `null` for a method other than `GET` or `HEAD`, and when no file matches and no SPA file or 404 page applies. If `publish-content.config.js` sets a 404 page or an SPA file, `serveRequest()` serves that page for each path that has no file. Thus, code after `serveRequest()` does not run for those requests.
1018
1020
 
1019
1021
  ```js
1020
1022
  import { PublisherServer } from '@fastly/compute-js-static-publish';
@@ -1027,12 +1029,7 @@ addEventListener("fetch", event => {
1027
1029
  });
1028
1030
 
1029
1031
  async function handleRequest(request) {
1030
- const response = await publisherServer.serveRequest(request);
1031
- if (response) {
1032
- return response;
1033
- }
1034
-
1035
- // Add your custom logic here
1032
+ // Add your custom logic here, before serveRequest()
1036
1033
  const url = new URL(request.url);
1037
1034
  if (url.pathname === '/api/hello') {
1038
1035
  return new Response(JSON.stringify({ greeting: "hi" }), {
@@ -1040,6 +1037,11 @@ async function handleRequest(request) {
1040
1037
  });
1041
1038
  }
1042
1039
 
1040
+ const response = await publisherServer.serveRequest(request);
1041
+ if (response != null) {
1042
+ return response;
1043
+ }
1044
+
1043
1045
  return new Response("Not Found", { status: 404 });
1044
1046
  }
1045
1047
  ```
@@ -1057,7 +1059,7 @@ async function handleRequest(request) {
1057
1059
 
1058
1060
  `serveRequest()` returns `null` for a method other than `GET` and `HEAD`, and when there is no response (no file matches, and there is no fallback page or `fallback` is `false`). If the default collection has no settings in storage, the response is `500`. A collection other than the default collection that is not published, or that expired, gets a plain-text `404` that names it.
1059
1061
 
1060
- `serveFallback(request, { collectionName })` serves the SPA file (`200`) or the 404 page (`404`) of the collection, as `serveRequest()` does when no file matches. It returns `null` for a method other than `GET` and `HEAD`, for a client that does not accept HTML, or when the collection has no fallback page. Use it with `fallback: false`, to run your own logic between the files and the fallback page:
1062
+ `serveFallback(request, { collectionName })` serves the SPA file (`200`) or the 404 page (`404`) of the collection, as `serveRequest()` does when no file matches. It returns `null` for a method other than `GET` and `HEAD`, for a client that does not accept HTML, or when the collection has no fallback page. Use it with `fallback: false`, to run your own logic between the files and the fallback page. The scaffolded app (`src/index.js`) uses this order:
1061
1063
 
1062
1064
  ```js
1063
1065
  async function handleRequest(request) {
@@ -1180,7 +1182,7 @@ To add your own middleware and routes to the `hono` template, put modules in the
1180
1182
  `scaffold --template hono` makes the folder next to the project file (managed) or next to `compute-js/` (ejected). To make it later, or to update it, run:
1181
1183
 
1182
1184
  ```sh
1183
- npx @fastly/compute-js-static-publish template init
1185
+ npx @fastly/compute-js-static-publish@beta template init
1184
1186
  ```
1185
1187
 
1186
1188
  ```
@@ -1265,10 +1267,10 @@ templateOptions: {
1265
1267
 
1266
1268
  **Watch:** `dev -- --watch` (managed) and `npm run dev:watch` (ejected) also watch the extensions folder, also if it does not exist yet. A change in the folder bundles the modules again, and then the Fastly CLI builds and restarts the app. If a module has an error, the watcher shows it and the app keeps the last modules that built.
1267
1269
 
1268
- **Examples** in [`examples/hono/`](https://github.com/fastly/compute-js-static-publish/tree/main/examples/hono) show complete extensions. They are not part of the npm package, and you cannot scaffold an app with them: for a new project, copy the `hono-extensions/` folder of an example into your project, and set it up as the README of the example shows. The README also shows how to add an example to a project that exists.
1270
+ **Examples** in [`examples/hono/`](https://github.com/fastly/compute-js-static-publish/tree/beta/8.1/examples/hono) show complete extensions. They are not part of the npm package, and you cannot scaffold an app with them: for a new project, copy the `hono-extensions/` folder of an example into your project, and set it up as the README of the example shows. The README also shows how to add an example to a project that exists.
1269
1271
 
1270
- - [`grip`](https://github.com/fastly/compute-js-static-publish/tree/main/examples/hono/grip): realtime streams and Server-Sent Events with Fastly Fanout, and a publish endpoint with a shared key. One module with two phases: the `middleware` phase hands off only `/events/*` to Fanout, and the `beforeFiles` phase has the endpoints.
1271
- - [`oauth`](https://github.com/fastly/compute-js-static-publish/tree/main/examples/hono/oauth): a login with GitHub or Google in front of some paths of the site (`protect`), with a signed session cookie.
1272
+ - [`grip`](https://github.com/fastly/compute-js-static-publish/tree/beta/8.1/examples/hono/grip): realtime streams and Server-Sent Events with Fastly Fanout, and a publish endpoint with a shared key. One module with two phases: the `middleware` phase hands off only `/events/*` to Fanout, and the `beforeFiles` phase has the endpoints.
1273
+ - [`oauth`](https://github.com/fastly/compute-js-static-publish/tree/beta/8.1/examples/hono/oauth): a login with GitHub or Google in front of some paths of the site (`protect`), with a signed session cookie.
1272
1274
 
1273
1275
  Each example takes its secrets from a Secret Store. For `dev`, `managed.fastlyToml` adds a local Secret Store that reads environment variables.
1274
1276
 
@@ -1423,7 +1425,7 @@ These rules are for tools that run the CLI with no person present, for example a
1423
1425
  **`--json`:** `publish-content`, `collections list`, `collections delete`, `collections promote`, `status`, `deploy` (in a managed project), and `--version` can write their result as one JSON object to stdout, at the end. All log lines then go to stderr, so that they still show in the CI log. With another command, `--json` is an error (`json-not-supported`).
1424
1426
 
1425
1427
  ```sh
1426
- npx @fastly/compute-js-static-publish publish-content \
1428
+ npx @fastly/compute-js-static-publish@beta publish-content \
1427
1429
  --project-dir=./compute-js --collection-name=pr-42 --json > result.json
1428
1430
  ```
1429
1431
 
@@ -1643,14 +1645,14 @@ Once you're in the scaffolded Compute app directory (with `static-publish.rc.js`
1643
1645
  To run a subcommand from another directory, for example the root of your repo in CI, give the app directory with `--project-dir`:
1644
1646
 
1645
1647
  ```sh
1646
- npx @fastly/compute-js-static-publish publish-content \
1648
+ npx @fastly/compute-js-static-publish@beta publish-content \
1647
1649
  --project-dir=./compute-js \
1648
1650
  --collection-name=staging
1649
1651
  ```
1650
1652
 
1651
1653
  With `--project-dir`, all relative paths are relative to that directory: the paths in `static-publish.rc.js` and `publish-content.config.js`, and also the paths in the other options (for example `--config` and `--root-dir`). The directory must have a `static-publish.rc.js` (an app) or a `static-publish.project.js` (a [managed project](#managed-projects)). To scaffold an app in another directory, use `--output`.
1652
1654
 
1653
- To print the version of this package, run `npx @fastly/compute-js-static-publish --version`. It works in any directory.
1655
+ To print the version of this package, run `npx @fastly/compute-js-static-publish@beta --version`. It works in any directory.
1654
1656
 
1655
1657
  With `--non-interactive`, or when the `CI` environment variable is set, the CLI never asks for input: missing input is an error. `deploy` then also runs the Fastly CLI with `--non-interactive`. The output never shows the values of `--fastly-api-token`, `--s3-secret-access-key`, `FASTLY_API_TOKEN`, and `S3_SECRET_ACCESS_KEY`.
1656
1658
 
@@ -1659,7 +1661,7 @@ For `--json`, the exit codes, and the error codes, see [Using the CLI in CI](#-u
1659
1661
  #### `publish-content`
1660
1662
 
1661
1663
  ```sh
1662
- npx @fastly/compute-js-static-publish publish-content \
1664
+ npx @fastly/compute-js-static-publish@beta publish-content \
1663
1665
  [--root-dir=./public] \
1664
1666
  [--collection-name=preview-42] \
1665
1667
  [--config=./publish-content.config.js] \
@@ -1717,7 +1719,7 @@ After this process is complete, the PublisherServer object in the Compute applic
1717
1719
  #### `clean`
1718
1720
 
1719
1721
  ```sh
1720
- npx @fastly/compute-js-static-publish clean \
1722
+ npx @fastly/compute-js-static-publish@beta clean \
1721
1723
  [--delete-expired-collections] \
1722
1724
  [--dry-run]
1723
1725
  ```
@@ -1743,7 +1745,7 @@ This can include expired collection indexes and orphaned content assets.
1743
1745
  #### `collections list`
1744
1746
 
1745
1747
  ```sh
1746
- npx @fastly/compute-js-static-publish collections list
1748
+ npx @fastly/compute-js-static-publish@beta collections list
1747
1749
  ```
1748
1750
  Lists all collections currently published in storage.
1749
1751
 
@@ -1762,7 +1764,7 @@ Lists all collections currently published in storage.
1762
1764
  #### `collections promote`
1763
1765
 
1764
1766
  ```sh
1765
- npx @fastly/compute-js-static-publish collections promote \
1767
+ npx @fastly/compute-js-static-publish@beta collections promote \
1766
1768
  --collection-name=preview-42 \
1767
1769
  --to=live \
1768
1770
  [--expires-in=7d | --expires-at=2025-06-01T00:00Z | --expires-never]
@@ -1802,7 +1804,7 @@ If a Service ID is found, the command then purges the surrogate key `<publishId>
1802
1804
  #### `collections update-expiration`
1803
1805
 
1804
1806
  ```sh
1805
- npx @fastly/compute-js-static-publish collections update-expiration \
1807
+ npx @fastly/compute-js-static-publish@beta collections update-expiration \
1806
1808
  --collection-name=preview-42 \
1807
1809
  --expires-in=3d | --expires-at=2025-06-01T00:00Z | --expires-never
1808
1810
  ```
@@ -1832,13 +1834,13 @@ Sets or updates the expiration time of an existing collection.
1832
1834
  #### `collections delete`
1833
1835
 
1834
1836
  ```sh
1835
- npx @fastly/compute-js-static-publish collections delete \
1837
+ npx @fastly/compute-js-static-publish@beta collections delete \
1836
1838
  --collection-name=preview-42
1837
1839
  ```
1838
1840
 
1839
1841
  Deletes a collection index from storage. The content files will remain as they may still be referenced by other collection indexes.
1840
1842
 
1841
- Use the `npx @fastly/compute-js-static-publish clean` command afterward to remove content files that are no longer referenced by any collection.
1843
+ Use the `npx @fastly/compute-js-static-publish@beta clean` command afterward to remove content files that are no longer referenced by any collection.
1842
1844
 
1843
1845
  If a Service ID is found, the command then purges the surrogate key `<publishId>-<collectionName>`, so that the service stops serving cached responses of the deleted collection. This uses the same options as [`publish-content`](#publish-content).
1844
1846
 
@@ -1959,7 +1961,7 @@ async function handleRequest(event) {
1959
1961
 
1960
1962
  ## 📚 Next Steps
1961
1963
 
1962
- - View CLI command help: `npx @fastly/compute-js-static-publish --help`
1964
+ - View CLI command help: `npx @fastly/compute-js-static-publish@beta --help`
1963
1965
  - Use in CI to automate branch previews
1964
1966
  - Visit [https://developer.fastly.com](https://developer.fastly.com) for Compute platform docs
1965
1967
 
package/README.md CHANGED
@@ -6,7 +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
+ - 🎁 Since v8: Support for S3-compatible storage such as Fastly Object Storage (Beta)
10
10
  - 🗂 Publish to named collections (`live`, `preview-42`, etc.)
11
11
  - 🔄 Switch between collections at runtime
12
12
  - 🧹 Clean up old or expired assets
@@ -21,7 +21,7 @@ Create a directory for your project, place your static files in `./public`, then
21
21
  npx @fastly/compute-js-static-publish@beta --root-dir=./public --kv-store-name=site-content
22
22
  ```
23
23
 
24
- **New in v8:** S3-compatible storage (such as Fastly Object Storage) is also supported (Beta). To use this mode, type:
24
+ **Since v8:** S3-compatible storage (such as Fastly Object Storage) is also supported (Beta). To use this mode, type:
25
25
 
26
26
  ```sh
27
27
  npx @fastly/compute-js-static-publish@beta --root-dir=./public --storage-mode=s3 --s3-region=<region> --s3-bucket=<bucket-name>
@@ -29,7 +29,15 @@ npx @fastly/compute-js-static-publish@beta --root-dir=./public --storage-mode=s3
29
29
 
30
30
  If the storage needs a custom endpoint, as Fastly Object Storage does, add `--s3-endpoint=<endpoint>` (for example, `--s3-endpoint=https://us-east-1.object.fastlystorage.app`).
31
31
 
32
- For more details, see the [S3-compatible storage](https://github.com/fastly/compute-js-static-publish/blob/main/README.md#-using-s3-compatible-storage-beta) section in the full documentation.
32
+ For more details, see the [S3-compatible storage](https://github.com/fastly/compute-js-static-publish/blob/beta/8.1/README.md#-using-s3-compatible-storage-beta) section in the full documentation.
33
+
34
+ **New in 8.1:** a managed project has only one file in your repo, `static-publish.project.js`, and the CLI generates the app. Add `--template=hono` for a Hono app:
35
+
36
+ ```sh
37
+ npx @fastly/compute-js-static-publish@beta --managed --root-dir=./public --kv-store-name=site-content
38
+ npx @fastly/compute-js-static-publish@beta publish-content --local
39
+ npx @fastly/compute-js-static-publish@beta dev
40
+ ```
33
41
 
34
42
  ### 🔧 Local Preview
35
43
 
@@ -69,6 +77,21 @@ npm run fastly:publish # upload your static files
69
77
 
70
78
  If the app uses S3-compatible storage, your files are already in the bucket after `npm run s3:publish`. Run `npm run fastly:deploy` to deploy the app, and use `npm run s3:publish` to upload updates. After the deploy, `fastly.toml` has the service ID, so `s3:publish` also purges the service's cache. For this purge, set `FASTLY_API_TOKEN` too. Without it, `s3:publish` stops with an error before it uploads files.
71
79
 
80
+ ## New in 8.1
81
+
82
+ - **Managed projects:** keep only `static-publish.project.js` in your repo. The CLI generates the app, and `dev`, `deploy`, `status`, `upgrade`, and `eject` work with it. ([Managed and ejected apps](https://github.com/fastly/compute-js-static-publish/blob/beta/8.1/README.md#managed-and-ejected-apps))
83
+ - **Previews:** serve another collection for a request, selected by host, path, query, cookie, or header. ([Previews](https://github.com/fastly/compute-js-static-publish/blob/beta/8.1/README.md#-previews-collection-selection))
84
+ - **Hidden files:** publish files that the server does not serve for a request, for your own code to read. Deploy your app with 8.1 before you publish hidden files: an app built with 8.0 does not serve a collection that has hidden files. ([Hidden files](https://github.com/fastly/compute-js-static-publish/blob/beta/8.1/README.md#hidden-files))
85
+ - **Hono:** the `hono` template (`--template=hono`), with your own middleware and routes in `hono-extensions/`, and examples for GRIP streaming and OAuth login. For your own Hono app, `@fastly/compute-js-static-publish/hono` replaces `@fastly/hono-compute-js-static-publish`. ([Using Hono](https://github.com/fastly/compute-js-static-publish/blob/beta/8.1/README.md#-using-hono))
86
+ - **CI:** `--json` output, exit codes, error codes, `--project-dir`, and `--non-interactive`. ([Using the CLI in CI](https://github.com/fastly/compute-js-static-publish/blob/beta/8.1/README.md#-using-the-cli-in-ci))
87
+
88
+ Before you upgrade, read [CHANGELOG.md](https://github.com/fastly/compute-js-static-publish/blob/beta/8.1/CHANGELOG.md). These changes can break something:
89
+
90
+ - The name of a new collection must be a DNS label: lowercase `a-z`, `0-9`, and `-`, from 1 to 63 characters, with no `-` at the start or the end. A collection that exists continues to work with another name, with a warning.
91
+ - A usage or config error exits with `2`. Before, every error exited with `1`.
92
+ - `collectionSelector.fromCookie()`: the activate and reset paths redirect with `308`. Before, they used `302`.
93
+ - `PublisherServer`: the fields `serverTiming`, `settingsCached`, and `assetEntryMapCache` are read-only (deprecated). Code that assigns to them gets a TypeScript error.
94
+
72
95
  ## Features
73
96
 
74
97
  - Named collections for previews, staging, production
package/README.short.md CHANGED
@@ -6,7 +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
+ - 🎁 Since v8: Support for S3-compatible storage such as Fastly Object Storage (Beta)
10
10
  - 🗂 Publish to named collections (`live`, `preview-42`, etc.)
11
11
  - 🔄 Switch between collections at runtime
12
12
  - 🧹 Clean up old or expired assets
@@ -21,7 +21,7 @@ Create a directory for your project, place your static files in `./public`, then
21
21
  npx @fastly/compute-js-static-publish@beta --root-dir=./public --kv-store-name=site-content
22
22
  ```
23
23
 
24
- **New in v8:** S3-compatible storage (such as Fastly Object Storage) is also supported (Beta). To use this mode, type:
24
+ **Since v8:** S3-compatible storage (such as Fastly Object Storage) is also supported (Beta). To use this mode, type:
25
25
 
26
26
  ```sh
27
27
  npx @fastly/compute-js-static-publish@beta --root-dir=./public --storage-mode=s3 --s3-region=<region> --s3-bucket=<bucket-name>
@@ -29,7 +29,15 @@ npx @fastly/compute-js-static-publish@beta --root-dir=./public --storage-mode=s3
29
29
 
30
30
  If the storage needs a custom endpoint, as Fastly Object Storage does, add `--s3-endpoint=<endpoint>` (for example, `--s3-endpoint=https://us-east-1.object.fastlystorage.app`).
31
31
 
32
- For more details, see the [S3-compatible storage](https://github.com/fastly/compute-js-static-publish/blob/main/README.md#-using-s3-compatible-storage-beta) section in the full documentation.
32
+ For more details, see the [S3-compatible storage](https://github.com/fastly/compute-js-static-publish/blob/beta/8.1/README.md#-using-s3-compatible-storage-beta) section in the full documentation.
33
+
34
+ **New in 8.1:** a managed project has only one file in your repo, `static-publish.project.js`, and the CLI generates the app. Add `--template=hono` for a Hono app:
35
+
36
+ ```sh
37
+ npx @fastly/compute-js-static-publish@beta --managed --root-dir=./public --kv-store-name=site-content
38
+ npx @fastly/compute-js-static-publish@beta publish-content --local
39
+ npx @fastly/compute-js-static-publish@beta dev
40
+ ```
33
41
 
34
42
  ### 🔧 Local Preview
35
43
 
@@ -69,6 +77,21 @@ npm run fastly:publish # upload your static files
69
77
 
70
78
  If the app uses S3-compatible storage, your files are already in the bucket after `npm run s3:publish`. Run `npm run fastly:deploy` to deploy the app, and use `npm run s3:publish` to upload updates. After the deploy, `fastly.toml` has the service ID, so `s3:publish` also purges the service's cache. For this purge, set `FASTLY_API_TOKEN` too. Without it, `s3:publish` stops with an error before it uploads files.
71
79
 
80
+ ## New in 8.1
81
+
82
+ - **Managed projects:** keep only `static-publish.project.js` in your repo. The CLI generates the app, and `dev`, `deploy`, `status`, `upgrade`, and `eject` work with it. ([Managed and ejected apps](https://github.com/fastly/compute-js-static-publish/blob/beta/8.1/README.md#managed-and-ejected-apps))
83
+ - **Previews:** serve another collection for a request, selected by host, path, query, cookie, or header. ([Previews](https://github.com/fastly/compute-js-static-publish/blob/beta/8.1/README.md#-previews-collection-selection))
84
+ - **Hidden files:** publish files that the server does not serve for a request, for your own code to read. Deploy your app with 8.1 before you publish hidden files: an app built with 8.0 does not serve a collection that has hidden files. ([Hidden files](https://github.com/fastly/compute-js-static-publish/blob/beta/8.1/README.md#hidden-files))
85
+ - **Hono:** the `hono` template (`--template=hono`), with your own middleware and routes in `hono-extensions/`, and examples for GRIP streaming and OAuth login. For your own Hono app, `@fastly/compute-js-static-publish/hono` replaces `@fastly/hono-compute-js-static-publish`. ([Using Hono](https://github.com/fastly/compute-js-static-publish/blob/beta/8.1/README.md#-using-hono))
86
+ - **CI:** `--json` output, exit codes, error codes, `--project-dir`, and `--non-interactive`. ([Using the CLI in CI](https://github.com/fastly/compute-js-static-publish/blob/beta/8.1/README.md#-using-the-cli-in-ci))
87
+
88
+ Before you upgrade, read [CHANGELOG.md](https://github.com/fastly/compute-js-static-publish/blob/beta/8.1/CHANGELOG.md). These changes can break something:
89
+
90
+ - The name of a new collection must be a DNS label: lowercase `a-z`, `0-9`, and `-`, from 1 to 63 characters, with no `-` at the start or the end. A collection that exists continues to work with another name, with a warning.
91
+ - A usage or config error exits with `2`. Before, every error exited with `1`.
92
+ - `collectionSelector.fromCookie()`: the activate and reset paths redirect with `308`. Before, they used `302`.
93
+ - `PublisherServer`: the fields `serverTiming`, `settingsCached`, and `assetEntryMapCache` are read-only (deprecated). Code that assigns to them gets a TypeScript error.
94
+
72
95
  ## Features
73
96
 
74
97
  - Named collections for previews, staging, production
@@ -1 +1 @@
1
- {"version":3,"file":"clean.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/manage/clean.ts"],"names":[],"mappings":"AA+DA,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,iBA0NhD"}
1
+ {"version":3,"file":"clean.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/manage/clean.ts"],"names":[],"mappings":"AAgEA,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,iBA0NhD"}
@@ -8,11 +8,12 @@ import { parseCommandLine } from '../../util/args.js';
8
8
  import { errorCodeOf, recordFailure } from '../../util/output.js';
9
9
  import { LoadConfigError, configFileName, getComputeAppDir, loadStaticPublisherRcFile, } from '../../util/config.js';
10
10
  import { loadStorageProviderFromStaticPublishRc } from '../../storage/storage-provider.js';
11
+ import { cliCommand } from '../../util/package.js';
11
12
  function help() {
12
13
  console.log(`\
13
14
 
14
15
  Usage:
15
- npx @fastly/compute-js-static-publish clean [options]
16
+ ${cliCommand()} clean [options]
16
17
 
17
18
  Description:
18
19
  Cleans up expired or unreferenced items in storage.
@@ -1 +1 @@
1
- {"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../../../../src/cli/commands/manage/collections/delete.ts"],"names":[],"mappings":"AAuEA,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,iBAiLhD"}
1
+ {"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../../../../src/cli/commands/manage/collections/delete.ts"],"names":[],"mappings":"AAwEA,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,iBAiLhD"}
@@ -7,17 +7,18 @@ import { errorCodeOf, fail, recordFailure, setJsonResult } from '../../../util/o
7
7
  import { LoadConfigError, configFileName, getComputeAppDir, loadStaticPublisherRcFile, } from '../../../util/config.js';
8
8
  import { loadStorageProviderFromStaticPublishRc } from '../../../storage/storage-provider.js';
9
9
  import { loadPurgeTarget, purgeCollection } from '../../../util/purge.js';
10
+ import { cliCommand } from '../../../util/package.js';
10
11
  function help() {
11
12
  console.log(`\
12
13
 
13
14
  Usage:
14
- npx @fastly/compute-js-static-publish collections delete --collection-name=<name> [options]
15
+ ${cliCommand()} collections delete --collection-name=<name> [options]
15
16
 
16
17
  Description:
17
18
  Deletes a collection index from storage. The content files will remain as they may still
18
19
  be referenced by other collection indexes.
19
20
 
20
- Use the 'npx @fastly/compute-js-static-publish clean' command afterward to remove content
21
+ Use the '${cliCommand()} clean' command afterward to remove content
21
22
  files that are no longer referenced by any collection.
22
23
 
23
24
  If a Service ID is found, the tool then purges the cached responses of the collection
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/cli/commands/manage/collections/index.ts"],"names":[],"mappings":"AAqDA,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,iBA8BhD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/cli/commands/manage/collections/index.ts"],"names":[],"mappings":"AAsDA,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,iBA8BhD"}
@@ -8,11 +8,12 @@ import * as deleteCommand from './delete.js';
8
8
  import * as listCommand from './list.js';
9
9
  import * as promoteCommand from './promote.js';
10
10
  import * as updateExpirationCommand from './update-expiration.js';
11
+ import { cliCommand } from '../../../util/package.js';
11
12
  function help() {
12
13
  console.log(`\
13
14
 
14
15
  Usage:
15
- npx @fastly/compute-js-static-publish collections <sub-command> [options]
16
+ ${cliCommand()} collections <sub-command> [options]
16
17
 
17
18
  Description:
18
19
  Manage named collections within a Compute application built with @fastly/compute-js-static-publish.
@@ -44,8 +45,8 @@ Global Options:
44
45
  -h, --help Show this help message and exit.
45
46
 
46
47
  Examples:
47
- npx @fastly/compute-js-static-publish collections list
48
- npx @fastly/compute-js-static-publish collections delete --collection-name=preview-42
48
+ ${cliCommand()} collections list
49
+ ${cliCommand()} collections delete --collection-name=preview-42
49
50
  `);
50
51
  }
51
52
  export async function action(actionArgs) {
@@ -1 +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,iBAoLhD"}
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,iBAmLhD"}
@@ -2,18 +2,18 @@
2
2
  * Copyright Fastly, Inc.
3
3
  * Licensed under the MIT license. See LICENSE file for details.
4
4
  */
5
- import { countHiddenEntries } from '../../../../models/assets/index.js';
6
5
  import { decodeIndexMetadata, getUnsupportedIndexFeatures } from '../../../../models/server/index.js';
7
6
  import { isExpired } from '../../../../models/time/index.js';
8
7
  import { parseCommandLine } from '../../../util/args.js';
9
8
  import { errorCodeOf, recordFailure, setJsonResult } from '../../../util/output.js';
10
9
  import { LoadConfigError, configFileName, getComputeAppDir, loadStaticPublisherRcFile, } from '../../../util/config.js';
11
10
  import { loadStorageProviderFromStaticPublishRc } from '../../../storage/storage-provider.js';
11
+ import { cliCommand } from '../../../util/package.js';
12
12
  function help() {
13
13
  console.log(`\
14
14
 
15
15
  Usage:
16
- npx @fastly/compute-js-static-publish collections list [options]
16
+ ${cliCommand()} collections list [options]
17
17
 
18
18
  Description:
19
19
  Lists all collections currently published in the KV Store.
@@ -123,7 +123,8 @@ export async function action(actionArgs) {
123
123
  console.log(` ${collection}`);
124
124
  }
125
125
  const indexKey = indexesPrefix + collection;
126
- const indexEntryInfo = await storageProvider.getStorageEntry(indexKey);
126
+ // Only the metadata: the index itself can be large.
127
+ const indexEntryInfo = await storageProvider.getStorageEntryInfo(indexKey);
127
128
  if (indexEntryInfo == null) {
128
129
  throw new Error(`❌ Can't load storage entry ${indexesPrefix + collection}`);
129
130
  }
@@ -160,15 +161,13 @@ export async function action(actionArgs) {
160
161
  else {
161
162
  console.log(` Published : ${new Date(indexMetadata.publishedTime * 1000)}`);
162
163
  }
163
- try {
164
- const assetEntryMap = (await new Response(indexEntryInfo.data).json());
165
- const fileCount = Object.keys(assetEntryMap).length;
166
- info.files = fileCount;
167
- info.hidden = countHiddenEntries(assetEntryMap);
168
- console.log(` Files : ${fileCount} (${countHiddenEntries(assetEntryMap)} hidden)`);
164
+ if (indexMetadata.fileCount != null) {
165
+ info.files = indexMetadata.fileCount;
166
+ info.hidden = indexMetadata.hiddenFileCount ?? 0;
167
+ console.log(` Files : ${indexMetadata.fileCount} (${indexMetadata.hiddenFileCount ?? 0} hidden)`);
169
168
  }
170
- catch {
171
- console.log(' Files : unknown (cannot read the index)');
169
+ else {
170
+ console.log(' Files : unknown (published with an older version)');
172
171
  }
173
172
  if (indexMetadata.requires != null) {
174
173
  console.log(` Requires : ${indexMetadata.requires.join(', ')}`);
@@ -1 +1 @@
1
- {"version":3,"file":"promote.d.ts","sourceRoot":"","sources":["../../../../../../src/cli/commands/manage/collections/promote.ts"],"names":[],"mappings":"AAyFA,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,iBA0NhD"}
1
+ {"version":3,"file":"promote.d.ts","sourceRoot":"","sources":["../../../../../../src/cli/commands/manage/collections/promote.ts"],"names":[],"mappings":"AA0FA,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,iBA0NhD"}
@@ -11,12 +11,13 @@ import { parseCommandLine } from '../../../util/args.js';
11
11
  import { errorCodeOf, fail, recordFailure, setJsonResult } from '../../../util/output.js';
12
12
  import { checkCollectionNameForWrite } from '../../../util/collection-name.js';
13
13
  import { loadStorageProviderFromStaticPublishRc } from '../../../storage/storage-provider.js';
14
+ import { cliCommand } from '../../../util/package.js';
14
15
  import { loadPurgeTarget, purgeCollection } from '../../../util/purge.js';
15
16
  function help() {
16
17
  console.log(`\
17
18
 
18
19
  Usage:
19
- npx @fastly/compute-js-static-publish collections promote
20
+ ${cliCommand()} collections promote
20
21
  --collection-name=<name> \\
21
22
  --to=name> \\
22
23
  [options]
@@ -1 +1 @@
1
- {"version":3,"file":"update-expiration.d.ts","sourceRoot":"","sources":["../../../../../../src/cli/commands/manage/collections/update-expiration.ts"],"names":[],"mappings":"AAqEA,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,iBAwJhD"}
1
+ {"version":3,"file":"update-expiration.d.ts","sourceRoot":"","sources":["../../../../../../src/cli/commands/manage/collections/update-expiration.ts"],"names":[],"mappings":"AAsEA,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,iBAwJhD"}
@@ -10,11 +10,12 @@ import { LoadConfigError, configFileName, getComputeAppDir, loadStaticPublisherR
10
10
  import { parseCommandLine } from '../../../util/args.js';
11
11
  import { errorCodeOf, fail, recordFailure } from '../../../util/output.js';
12
12
  import { loadStorageProviderFromStaticPublishRc } from '../../../storage/storage-provider.js';
13
+ import { cliCommand } from '../../../util/package.js';
13
14
  function help() {
14
15
  console.log(`\
15
16
 
16
17
  Usage:
17
- npx @fastly/compute-js-static-publish collections update-expiration \\
18
+ ${cliCommand()} collections update-expiration \\
18
19
  --collection-name=<name> \\
19
20
  [options]
20
21
 
@@ -1 +1 @@
1
- {"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/manage/deploy.ts"],"names":[],"mappings":"AAuEA,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,iBAqJhD"}
1
+ {"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/manage/deploy.ts"],"names":[],"mappings":"AA0EA,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,iBAuLhD"}