@fastly/compute-js-static-publish 8.1.0-beta.2 → 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 (50) hide show
  1. package/DOCUMENTATION.md +12 -10
  2. package/README.md +18 -5
  3. package/README.short.md +18 -5
  4. package/build/cli/cli/commands/manage/collections/list.d.ts.map +1 -1
  5. package/build/cli/cli/commands/manage/collections/list.js +8 -10
  6. package/build/cli/cli/commands/manage/deploy.d.ts.map +1 -1
  7. package/build/cli/cli/commands/manage/deploy.js +46 -9
  8. package/build/cli/cli/commands/manage/eject.d.ts.map +1 -1
  9. package/build/cli/cli/commands/manage/eject.js +22 -5
  10. package/build/cli/cli/commands/manage/publish-content.d.ts.map +1 -1
  11. package/build/cli/cli/commands/manage/publish-content.js +4 -1
  12. package/build/cli/cli/commands/manage/status.d.ts.map +1 -1
  13. package/build/cli/cli/commands/manage/status.js +6 -0
  14. package/build/cli/cli/commands/run-dev-watch.d.ts +1 -0
  15. package/build/cli/cli/commands/run-dev-watch.d.ts.map +1 -1
  16. package/build/cli/cli/commands/run-dev-watch.js +45 -9
  17. package/build/cli/cli/commands/scaffold/generate-app.d.ts +8 -3
  18. package/build/cli/cli/commands/scaffold/generate-app.d.ts.map +1 -1
  19. package/build/cli/cli/commands/scaffold/generate-app.js +11 -1
  20. package/build/cli/cli/commands/scaffold/index.d.ts +3 -3
  21. package/build/cli/cli/commands/scaffold/index.d.ts.map +1 -1
  22. package/build/cli/cli/commands/scaffold/index.js +15 -18
  23. package/build/cli/cli/managed/app.d.ts +1 -1
  24. package/build/cli/cli/managed/app.d.ts.map +1 -1
  25. package/build/cli/cli/managed/app.js +5 -3
  26. package/build/cli/cli/managed/lockfile.js +1 -1
  27. package/build/cli/cli/managed/project-file.d.ts.map +1 -1
  28. package/build/cli/cli/managed/project-file.js +4 -3
  29. package/build/cli/cli/util/config.d.ts.map +1 -1
  30. package/build/cli/cli/util/config.js +9 -0
  31. package/build/cli/cli/util/global-options.js +1 -1
  32. package/build/cli/cli/util/package.d.ts +2 -1
  33. package/build/cli/cli/util/package.d.ts.map +1 -1
  34. package/build/cli/cli/util/package.js +39 -7
  35. package/build/cli/cli/util/s3.d.ts +10 -4
  36. package/build/cli/cli/util/s3.d.ts.map +1 -1
  37. package/build/cli/cli/util/s3.js +13 -35
  38. package/build/cli/models/config/publish-content-config.d.ts +1 -0
  39. package/build/cli/models/config/publish-content-config.d.ts.map +1 -1
  40. package/build/cli/models/server/index.d.ts +2 -0
  41. package/build/cli/models/server/index.d.ts.map +1 -1
  42. package/build/cli/models/server/index.js +13 -1
  43. package/build/server/models/config/publish-content-config.d.ts +1 -0
  44. package/build/server/models/config/publish-content-config.d.ts.map +1 -1
  45. package/build/server/models/server/index.d.ts +2 -0
  46. package/build/server/models/server/index.d.ts.map +1 -1
  47. package/build/server/models/server/index.js +13 -1
  48. package/package.json +1 -1
  49. package/resources/app/publish-content.config.js.njk +1 -0
  50. package/resources/templates/plain/src/index.js +12 -2
package/DOCUMENTATION.md CHANGED
@@ -303,7 +303,7 @@ npx @fastly/compute-js-static-publish@beta deploy
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
 
@@ -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) {
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>
@@ -31,6 +31,14 @@ If the storage needs a custom endpoint, as Fastly Object Storage does, add `--s3
31
31
 
32
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
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
+ ```
41
+
34
42
  ### 🔧 Local Preview
35
43
 
36
44
  ```sh
@@ -73,11 +81,16 @@ If the app uses S3-compatible storage, your files are already in the bucket afte
73
81
 
74
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))
75
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))
76
- - **Hidden files:** publish files that the server does not serve for a request, for your own code to read. ([Hidden files](https://github.com/fastly/compute-js-static-publish/blob/beta/8.1/README.md#hidden-files))
77
- - **Hono:** the `hono` template, 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))
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))
78
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))
79
87
 
80
- Before you upgrade, read [CHANGELOG.md](https://github.com/fastly/compute-js-static-publish/blob/beta/8.1/CHANGELOG.md): collection names now must be DNS labels (lowercase letters, digits, and `-`), and a usage or config error now exits with `2`.
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.
81
94
 
82
95
  ## Features
83
96
 
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>
@@ -31,6 +31,14 @@ If the storage needs a custom endpoint, as Fastly Object Storage does, add `--s3
31
31
 
32
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
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
+ ```
41
+
34
42
  ### 🔧 Local Preview
35
43
 
36
44
  ```sh
@@ -73,11 +81,16 @@ If the app uses S3-compatible storage, your files are already in the bucket afte
73
81
 
74
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))
75
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))
76
- - **Hidden files:** publish files that the server does not serve for a request, for your own code to read. ([Hidden files](https://github.com/fastly/compute-js-static-publish/blob/beta/8.1/README.md#hidden-files))
77
- - **Hono:** the `hono` template, 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))
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))
78
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))
79
87
 
80
- Before you upgrade, read [CHANGELOG.md](https://github.com/fastly/compute-js-static-publish/blob/beta/8.1/CHANGELOG.md): collection names now must be DNS labels (lowercase letters, digits, and `-`), and a usage or config error now exits with `2`.
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.
81
94
 
82
95
  ## Features
83
96
 
@@ -1 +1 @@
1
- {"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../../../../src/cli/commands/manage/collections/list.ts"],"names":[],"mappings":"AAqDA,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,7 +2,6 @@
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';
@@ -124,7 +123,8 @@ export async function action(actionArgs) {
124
123
  console.log(` ${collection}`);
125
124
  }
126
125
  const indexKey = indexesPrefix + collection;
127
- const indexEntryInfo = await storageProvider.getStorageEntry(indexKey);
126
+ // Only the metadata: the index itself can be large.
127
+ const indexEntryInfo = await storageProvider.getStorageEntryInfo(indexKey);
128
128
  if (indexEntryInfo == null) {
129
129
  throw new Error(`❌ Can't load storage entry ${indexesPrefix + collection}`);
130
130
  }
@@ -161,15 +161,13 @@ export async function action(actionArgs) {
161
161
  else {
162
162
  console.log(` Published : ${new Date(indexMetadata.publishedTime * 1000)}`);
163
163
  }
164
- try {
165
- const assetEntryMap = (await new Response(indexEntryInfo.data).json());
166
- const fileCount = Object.keys(assetEntryMap).length;
167
- info.files = fileCount;
168
- info.hidden = countHiddenEntries(assetEntryMap);
169
- 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)`);
170
168
  }
171
- catch {
172
- console.log(' Files : unknown (cannot read the index)');
169
+ else {
170
+ console.log(' Files : unknown (published with an older version)');
173
171
  }
174
172
  if (indexMetadata.requires != null) {
175
173
  console.log(` Requires : ${indexMetadata.requires.join(', ')}`);
@@ -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"}
@@ -15,6 +15,7 @@ import { parseCommandLine } from '../../util/args.js';
15
15
  import { detectProjectMode } from '../../util/config.js';
16
16
  import { readServiceId } from '../../util/fastly-toml.js';
17
17
  import { cliCommand, getOwnPackageDir, getOwnVersion } from '../../util/package.js';
18
+ import { appFastlyCommand } from '../run-dev-watch.js';
18
19
  import { fail, isJsonMode, isNonInteractive, recordFailure, setJsonResult } from '../../util/output.js';
19
20
  import { loadServiceId } from '../../util/service-id.js';
20
21
  import { isS3StorageConfigRc } from '../../../models/config/static-publish-rc.js';
@@ -31,10 +32,13 @@ Description:
31
32
  'fastly compute deploy'. The comment of the new service version has the
32
33
  fingerprint of the app, so that 'status' and the next deploy can compare it.
33
34
 
34
- After the first deploy, the Service ID is written into managed.serviceId in
35
- ${PROJECT_FILE_NAME}.
35
+ After the first deploy, which makes a new service, the Service ID is written
36
+ into managed.serviceId in ${PROJECT_FILE_NAME}. A Service ID from
37
+ --fastly-service-id or FASTLY_SERVICE_ID does not change the file.
36
38
 
37
- In an ejected app, this runs 'fastly compute publish'.
39
+ In an ejected app, this runs 'fastly compute publish', with --comment,
40
+ --fastly-service-id (as --service-id), and --fastly-api-token. --force and
41
+ --auto-upgrade are only for a managed project.
38
42
 
39
43
  Options:
40
44
  --force Deploy also when the fingerprint did not change.
@@ -52,8 +56,7 @@ Global Options:
52
56
  `);
53
57
  }
54
58
  function runFastly(appDir, args, apiToken) {
55
- const appFastly = path.resolve(appDir, 'node_modules/.bin/fastly');
56
- const fastly = fs.existsSync(appFastly) ? appFastly : 'fastly';
59
+ const fastly = appFastlyCommand(appDir);
57
60
  console.log(`▶️ fastly ${args.join(' ')}`);
58
61
  return child_process.spawnSync(fastly, args, {
59
62
  cwd: appDir,
@@ -86,7 +89,32 @@ export async function action(actionArgs) {
86
89
  fail('json-not-supported', `--json is not supported for 'deploy' in an ejected app.`);
87
90
  return;
88
91
  }
89
- const result = child_process.spawnSync('fastly', ['compute', 'publish'], { stdio: 'inherit' });
92
+ // fastly compute publish always builds and deploys, and an ejected app has
93
+ // no managed.staticPublishVersion.
94
+ for (const [option, value] of [['--force', force], ['--auto-upgrade', autoUpgrade]]) {
95
+ if (value) {
96
+ fail('usage', `${option} is only for a managed project. In an ejected app, deploy runs 'fastly compute publish', which always deploys.`);
97
+ return;
98
+ }
99
+ }
100
+ const publishArgs = ['compute', 'publish'];
101
+ if (typeof comment === 'string' && comment !== '') {
102
+ publishArgs.push('--comment', comment);
103
+ }
104
+ if (typeof fastlyServiceId === 'string' && fastlyServiceId !== '') {
105
+ publishArgs.push('--service-id', fastlyServiceId);
106
+ }
107
+ if (isNonInteractive()) {
108
+ publishArgs.push('--non-interactive');
109
+ }
110
+ const env = typeof fastlyApiToken === 'string' && fastlyApiToken !== '' ?
111
+ { ...process.env, FASTLY_API_TOKEN: fastlyApiToken } :
112
+ process.env;
113
+ console.log(`▶️ fastly ${publishArgs.join(' ')}`);
114
+ const result = child_process.spawnSync(appFastlyCommand(path.resolve()), publishArgs, {
115
+ env,
116
+ stdio: [isNonInteractive() ? 'ignore' : 'inherit', 'inherit', 'inherit'],
117
+ });
90
118
  if (result.error != null || result.status !== 0) {
91
119
  fail('deploy-failed', `'fastly compute publish' failed.`);
92
120
  }
@@ -126,7 +154,8 @@ export async function action(actionArgs) {
126
154
  console.warn(`⚠️ This CLI runs from the npx cache. The paths of the cache (in your home directory) go into the deployed Wasm binary.`);
127
155
  console.warn(` * Add @fastly/compute-js-static-publish as a dev dependency of the project, and run it from there.`);
128
156
  }
129
- const { fingerprint } = await managedAppState(path.resolve(), project);
157
+ const state = await managedAppState(path.resolve(), project);
158
+ const { fingerprint } = state;
130
159
  const staticPublishVersion = getOwnVersion();
131
160
  if (serviceId != null && !force) {
132
161
  const active = await getActiveVersion(context, serviceId);
@@ -145,7 +174,7 @@ export async function action(actionArgs) {
145
174
  return;
146
175
  }
147
176
  }
148
- const { appDir } = await prepareManagedApp(path.resolve(), project);
177
+ const { appDir } = await prepareManagedApp(path.resolve(), project, state);
149
178
  const build = runFastly(appDir, ['compute', 'build'], apiToken.apiToken);
150
179
  if (build.error != null || build.status !== 0) {
151
180
  fail('deploy-failed', `'fastly compute build' failed.`);
@@ -169,7 +198,15 @@ export async function action(actionArgs) {
169
198
  fail('deploy-failed', 'The deploy finished, but the Service ID is not known.');
170
199
  return;
171
200
  }
172
- if (project.managed.serviceId == null) {
201
+ // Write the Service ID into the project file only when it is the service of
202
+ // the project: a new service, or the one in the fastly.toml of the generated
203
+ // app. A Service ID from --fastly-service-id or FASTLY_SERVICE_ID is for this
204
+ // deploy only, so it does not change the committed file.
205
+ const oneOff = serviceIdResult?.source === 'commandline' || serviceIdResult?.source === 'env';
206
+ if (project.managed.serviceId == null && oneOff) {
207
+ console.log(` * managed.serviceId is not set. The Service ID ${serviceId} came from ${serviceIdResult.source === 'env' ? 'FASTLY_SERVICE_ID' : '--fastly-service-id'}, so ${PROJECT_FILE_NAME} was not changed.`);
208
+ }
209
+ if (project.managed.serviceId == null && !oneOff) {
173
210
  const projectFilePath = path.resolve(PROJECT_FILE_NAME);
174
211
  const updated = writeBackServiceId(fs.readFileSync(projectFilePath, 'utf-8'), serviceId);
175
212
  if (updated != null) {
@@ -1 +1 @@
1
- {"version":3,"file":"eject.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/manage/eject.ts"],"names":[],"mappings":"AA+DA,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,iBAoHhD"}
1
+ {"version":3,"file":"eject.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/manage/eject.ts"],"names":[],"mappings":"AAyEA,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,iBA6HhD"}
@@ -18,8 +18,8 @@ import { cliCommand, getOwnVersion } from '../../util/package.js';
18
18
  import { MANAGED_APP_DIR, PROJECT_FILE_NAME, RC_FILE_NAME } from '../../../models/config/static-publish-project.js';
19
19
  // An environment variable for the tests of this package only. The tests run a
20
20
  // version that is not on npm, so they give here the spec of this package for
21
- // the ejected app.
22
- const PACKAGE_SPEC_ENV = 'CJSP_TEST_EJECT_PACKAGE_SPEC';
21
+ // the ejected app. eject shows a warning when it is set.
22
+ const PACKAGE_SPEC_ENV = 'CJSP_TEST_ONLY_EJECT_PACKAGE_SPEC';
23
23
  function help() {
24
24
  console.log(`\
25
25
 
@@ -49,6 +49,14 @@ Global Options:
49
49
  -h, --help Show this help message and exit.
50
50
  `);
51
51
  }
52
+ // True if dir is a directory in parent (not parent itself).
53
+ function isInside(dir, parent) {
54
+ const relative = path.relative(parent, dir);
55
+ return relative !== '' && !relative.startsWith('..') && !path.isAbsolute(relative);
56
+ }
57
+ function isSameOrInside(dir, parent) {
58
+ return dir === parent || isInside(dir, parent);
59
+ }
52
60
  function isPublished(version) {
53
61
  const result = child_process.spawnSync('npm', ['view', `${THIS_PACKAGE}@${version}`, 'version'], { encoding: 'utf-8' });
54
62
  return result.status === 0 && result.stdout.trim() === version;
@@ -80,10 +88,15 @@ export async function action(actionArgs) {
80
88
  }
81
89
  const projectDir = path.resolve();
82
90
  const appDir = path.resolve(dirValue ?? './compute-js');
83
- if (appDir === projectDir || !appDir.startsWith(projectDir + path.sep) || appDir.startsWith(path.resolve(MANAGED_APP_DIR))) {
91
+ const workingDir = path.resolve(project.rc.staticPublisherWorkingDir);
92
+ if (!isInside(appDir, projectDir) || isSameOrInside(appDir, path.resolve(MANAGED_APP_DIR))) {
84
93
  fail('usage', `--dir must be a directory in the project dir, and not in ${MANAGED_APP_DIR}.`);
85
94
  return;
86
95
  }
96
+ if (isSameOrInside(appDir, workingDir)) {
97
+ fail('usage', `--dir must not be the working directory (${rootRelative(workingDir)}) or a directory in it. Use another --dir, or change staticPublisherWorkingDir.`);
98
+ return;
99
+ }
87
100
  if (fs.existsSync(appDir) && !force) {
88
101
  fail('usage', `${rootRelative(appDir)} exists. Use --force to write into it.`);
89
102
  return;
@@ -100,6 +113,9 @@ export async function action(actionArgs) {
100
113
  fail('version-not-published', `Eject needs a version of ${THIS_PACKAGE} that is published on npm. ${version} is not.`);
101
114
  return;
102
115
  }
116
+ if (testSpec != null) {
117
+ console.warn(`⚠️ ${PACKAGE_SPEC_ENV} is set (for the tests of this package only): the ejected app gets ${THIS_PACKAGE} ${testSpec}, and the check that ${version} is on npm is skipped.`);
118
+ }
103
119
  const packageSpec = testSpec ?? `^${version}`;
104
120
  const serviceId = (typeof fastlyServiceId === 'string' && fastlyServiceId !== '' ? fastlyServiceId : undefined) ??
105
121
  (process.env.FASTLY_SERVICE_ID || undefined) ??
@@ -131,10 +147,11 @@ export async function action(actionArgs) {
131
147
  files['package-lock.json'] = JSON.stringify(lock, undefined, 2) + '\n';
132
148
  console.log(`📦 Writing the app into ${rootRelative(appDir)}...`);
133
149
  writeManagedAppFiles(appDir, files);
134
- // Pin this package: "^<version>" stays in package.json, and the lockfile gets exactly <version>.
150
+ // Pin this package: "^<version>" stays in the dependencies of package.json,
151
+ // and the lockfile gets exactly <version>.
135
152
  const installArgs = testSpec != null ?
136
153
  ['install', '--no-audit', '--no-fund'] :
137
- ['install', '--save-dev', `${THIS_PACKAGE}@${version}`, '--no-audit', '--no-fund'];
154
+ ['install', '--save-prod', `${THIS_PACKAGE}@${version}`, '--no-audit', '--no-fund'];
138
155
  console.log(`npm ${installArgs.join(' ')}`);
139
156
  const install = child_process.spawnSync('npm', installArgs, { cwd: appDir, stdio: ['ignore', process.stderr, 'inherit'] });
140
157
  if (install.error != null || install.status !== 0) {
@@ -1 +1 @@
1
- {"version":3,"file":"publish-content.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/manage/publish-content.ts"],"names":[],"mappings":"AAiJA,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,iBAqmBhD"}
1
+ {"version":3,"file":"publish-content.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/manage/publish-content.ts"],"names":[],"mappings":"AAiJA,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,iBAwmBhD"}
@@ -290,7 +290,7 @@ export async function action(actionArgs) {
290
290
  console.warn(`⚠️ Cannot parse hiddenItems item index ${i}: '${x}', skipping...`);
291
291
  });
292
292
  if (hiddenItems.length > 0) {
293
- console.log(`✔️ Hidden items: ${publishContentConfig.hiddenItems.join(', ')}`);
293
+ console.log(`✔️ Hidden items: ${publishContentConfig.hiddenItemsAsWritten.join(', ')}`);
294
294
  }
295
295
  // ### Collection name that we're currently publishing
296
296
  // for example, live, staging
@@ -514,6 +514,9 @@ export async function action(actionArgs) {
514
514
  expirationTime: expirationTime ?? undefined,
515
515
  // A server that does not support hidden files must not serve this collection.
516
516
  requires: hiddenCount > 0 ? [HIDDEN_INDEX_FEATURE] : undefined,
517
+ // For collections list, which then reads only the metadata.
518
+ fileCount: Object.keys(assetsIndex).length,
519
+ hiddenFileCount: hiddenCount,
517
520
  };
518
521
  const indexFileName = `index_${collectionName}.json`;
519
522
  const indexFilePath = path.resolve(storageContentDir, indexFileName);
@@ -1 +1 @@
1
- {"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/manage/status.ts"],"names":[],"mappings":"AAgDA,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,iBAiIhD"}
1
+ {"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/manage/status.ts"],"names":[],"mappings":"AAgDA,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,iBAsIhD"}
@@ -115,6 +115,12 @@ export async function action(actionArgs) {
115
115
  reasons.push(deployed.staticPublishVersion !== running ?
116
116
  `The version of this package changed: ${deployed.staticPublishVersion} → ${running}.` :
117
117
  'The generated app changed.');
118
+ if (versionCheck.result === 'newer-cli' || versionCheck.result === 'missing') {
119
+ reasons.push(`Run 'upgrade' first, or deploy with --auto-upgrade: managed.staticPublishVersion (${versionCheck.recorded ?? 'missing'}) is not the version that runs (${running}).`);
120
+ }
121
+ else if (versionCheck.result !== 'same') {
122
+ reasons.push(`deploy refuses: this project uses a newer version (${versionCheck.recorded}) than the version that runs (${running}).`);
123
+ }
118
124
  }
119
125
  }
120
126
  }
@@ -1,3 +1,4 @@
1
+ export declare function appFastlyCommand(appDir: string): string;
1
2
  export type ServeResult = {
2
3
  status: number | null;
3
4
  signal: NodeJS.Signals | null;
@@ -1 +1 @@
1
- {"version":3,"file":"run-dev-watch.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/run-dev-watch.ts"],"names":[],"mappings":"AAWA,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC;IAC9B,KAAK,CAAC,EAAE,KAAK,CAAC;CACf,CAAC;AAOF,wBAAsB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC,CAiBxF;AAKD,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAQjE"}
1
+ {"version":3,"file":"run-dev-watch.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/run-dev-watch.ts"],"names":[],"mappings":"AAaA,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAGvD;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC;IAC9B,KAAK,CAAC,EAAE,KAAK,CAAC;CACf,CAAC;AAOF,wBAAsB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC,CA8CxF;AAKD,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAQjE"}
@@ -6,26 +6,62 @@ import * as child_process from 'node:child_process';
6
6
  import * as fs from 'node:fs';
7
7
  import * as path from 'node:path';
8
8
  import { TEMPLATE_WATCH_SCRIPT } from './scaffold/generate-app.js';
9
+ // The Fastly CLI of the app (its node_modules/.bin/fastly) if it has one, or
10
+ // else fastly from the PATH.
11
+ export function appFastlyCommand(appDir) {
12
+ const appFastly = path.resolve(appDir, 'node_modules/.bin/fastly');
13
+ return fs.existsSync(appFastly) ? appFastly : 'fastly';
14
+ }
9
15
  // Runs `fastly compute serve` in the app dir. With --watch, the watch script
10
16
  // (if the app has one) runs next to it, until the Fastly CLI stops. The script
11
17
  // can watch files outside the app dir: when they change, it writes a file in
12
18
  // the app dir, and then the Fastly CLI builds the app again. The Fastly CLI of
13
19
  // the app is used, if it has one.
14
20
  export async function serveApp(appDir, serveArgs) {
15
- const appFastly = path.resolve(appDir, 'node_modules/.bin/fastly');
16
- const fastly = fs.existsSync(appFastly) ? appFastly : 'fastly';
21
+ const fastly = appFastlyCommand(appDir);
17
22
  const watchScript = path.resolve(appDir, TEMPLATE_WATCH_SCRIPT);
18
23
  const watcher = serveArgs.includes('--watch') && fs.existsSync(watchScript) ?
19
24
  child_process.spawn(process.execPath, [watchScript], { cwd: appDir, stdio: 'inherit' }) :
20
25
  undefined;
21
- console.log(`▶️ fastly compute serve ${serveArgs.join(' ')}`);
22
- const result = await new Promise(resolve => {
23
- const child = child_process.spawn(fastly, ['compute', 'serve', ...serveArgs], { cwd: appDir, stdio: 'inherit' });
24
- child.on('error', error => resolve({ status: null, signal: null, error }));
25
- child.on('exit', (status, signal) => resolve({ status, signal }));
26
+ watcher?.on('error', error => {
27
+ console.error(`❌ Could not run ${TEMPLATE_WATCH_SCRIPT}: ${String(error)}`);
26
28
  });
27
- watcher?.kill();
28
- return result;
29
+ console.log(`▶️ fastly compute serve ${serveArgs.join(' ')}`);
30
+ // The Fastly CLI of the app is a Node.js wrapper that starts the fastly
31
+ // binary, which starts Viceroy. The wrapper does not forward signals. Thus
32
+ // the Fastly CLI runs in its own process group, and a signal goes to the
33
+ // whole group.
34
+ const child = child_process.spawn(fastly, ['compute', 'serve', ...serveArgs], { cwd: appDir, stdio: 'inherit', detached: true });
35
+ // A signal to this process (for example SIGTERM from a process manager, or
36
+ // SIGINT from Ctrl+C) goes to the Fastly CLI and to the watch script, so that
37
+ // nothing stays running. This process waits until the Fastly CLI stops.
38
+ const forward = (signal) => {
39
+ if (child.pid != null) {
40
+ try {
41
+ process.kill(-child.pid, signal);
42
+ }
43
+ catch {
44
+ // The process group has already stopped.
45
+ }
46
+ }
47
+ watcher?.kill(signal);
48
+ };
49
+ const signals = ['SIGINT', 'SIGTERM', 'SIGHUP'];
50
+ for (const signal of signals) {
51
+ process.on(signal, forward);
52
+ }
53
+ try {
54
+ return await new Promise(resolve => {
55
+ child.on('error', error => resolve({ status: null, signal: null, error }));
56
+ child.on('exit', (status, signal) => resolve({ status, signal }));
57
+ });
58
+ }
59
+ finally {
60
+ for (const signal of signals) {
61
+ process.off(signal, forward);
62
+ }
63
+ watcher?.kill();
64
+ }
29
65
  }
30
66
  // The dev:watch script of every app calls this: `fastly compute serve --watch`
31
67
  // in the current directory, with the watch script of the app. The arguments
@@ -4,9 +4,9 @@ import { type GeneratedFrom, type StaticPublishTemplateOptions } from '../../../
4
4
  import { type AppTemplate } from './app-template.js';
5
5
  export type AppConfig = {
6
6
  appDir: string;
7
- name: string | undefined;
8
- author: string | undefined;
9
- description: string | undefined;
7
+ name: string;
8
+ author: string;
9
+ description: string;
10
10
  serviceId: string | undefined;
11
11
  storage: {
12
12
  mode: 'kv-store';
@@ -43,5 +43,10 @@ export type AppConfig = {
43
43
  };
44
44
  export declare const TEMPLATE_HOOKS: readonly ['prebuild', 'postbuild', 'postinstall'];
45
45
  export declare const TEMPLATE_WATCH_SCRIPT = "scripts/template_watch.js";
46
+ export declare const DEFAULT_APP_INFO: {
47
+ name: string;
48
+ author: string;
49
+ description: string;
50
+ };
46
51
  export declare function generateApp(config: AppConfig): Record<string, string>;
47
52
  //# sourceMappingURL=generate-app.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"generate-app.d.ts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;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,iBAAiB,EAAE,OAAO,CAAA;KAAE,CAAC;IACpG,SAAS,EAAE,MAAM,CAAC;IAClB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,yBAAyB,EAAE,MAAM,CAAC;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,oBAAoB,EAAE,MAAM,GAAG,SAAS,CAAC;IACzC,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,OAAO,EAAE,MAAM,EAAE,CAAC;IAElB,wBAAwB,EAAE,MAAM,CAAC;IAEjC,QAAQ,EAAE,WAAW,CAAC;IAEtB,aAAa,EAAE,aAAa,GAAG,SAAS,CAAC;IAEzC,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;IAE1C,UAAU,CAAC,EAAE,kBAAkB,CAAC;IAGhC,KAAK,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE;YAAE,aAAa,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,CAAC;IAG7C,eAAe,CAAC,EAAE,4BAA4B,CAAC;IAE/C,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAIF,eAAO,MAAM,cAAc,YAAK,UAAU,EAAE,WAAW,EAAE,aAAa,CAAW,CAAC;AAKlF,eAAO,MAAM,qBAAqB,8BAA8B,CAAC;AAIjE,eAAO,MAAM,gBAAgB;IAC3B,IAAI;IACJ,MAAM;IACN,WAAW;CACZ,CAAC;AAKF,wBAAgB,WAAW,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAyLrE"}
@@ -14,6 +14,13 @@ export const TEMPLATE_HOOKS = ['prebuild', 'postbuild', 'postinstall'];
14
14
  // `fastly compute serve --watch` (npm run dev:watch, or dev -- --watch), until
15
15
  // it is stopped.
16
16
  export const TEMPLATE_WATCH_SCRIPT = 'scripts/template_watch.js';
17
+ // The name, author, and description of an app when the flags or the project
18
+ // file do not give them.
19
+ export const DEFAULT_APP_INFO = {
20
+ name: 'compute-js-static-site',
21
+ author: 'you@example.com',
22
+ description: 'Fastly Compute static site',
23
+ };
17
24
  // Makes the files of the app, keyed by the path relative to the app dir.
18
25
  // It does not write files or use the network, so that tests can compare its
19
26
  // output. It reads only the resources/ directory of this package.
@@ -54,10 +61,13 @@ export function generateApp(config) {
54
61
  type: 'module',
55
62
  devDependencies: {
56
63
  ...template.devDependencies,
57
- '@fastly/compute-js-static-publish': staticPublishVersionSpec,
58
64
  },
65
+ // This package is a dependency, not a dev dependency: the code of the app
66
+ // imports it, and the postinstall script runs it, also with
67
+ // npm ci --omit=dev.
59
68
  dependencies: {
60
69
  ...template.dependencies,
70
+ '@fastly/compute-js-static-publish': staticPublishVersionSpec,
61
71
  },
62
72
  engines: {
63
73
  node: '>=20.11.0',
@@ -8,9 +8,9 @@ export type InitAppOptions = {
8
8
  notFoundPage: string | undefined;
9
9
  autoIndex: string[];
10
10
  autoExt: string[];
11
- name: string | undefined;
12
- author: string | undefined;
13
- description: string | undefined;
11
+ name: string;
12
+ author: string;
13
+ description: string;
14
14
  serviceId: string | undefined;
15
15
  publishId: string | undefined;
16
16
  defaultCollectionName: string | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/scaffold/index.ts"],"names":[],"mappings":"AAoGA,MAAM,MAAM,cAAc,GAAG;IAC3B,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,yBAAyB,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9C,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,YAAY,EAAE,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