@fastly/compute-js-static-publish 8.1.0-beta.3 → 8.1.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +601 -0
- package/DOCUMENTATION.md +16 -9
- package/build/cli/cli/commands/manage/deploy.d.ts.map +1 -1
- package/build/cli/cli/commands/manage/deploy.js +22 -3
- package/build/cli/cli/commands/manage/publish-content.d.ts.map +1 -1
- package/build/cli/cli/commands/manage/publish-content.js +5 -3
- package/build/cli/cli/commands/manage/template/init.js +6 -6
- package/build/cli/cli/commands/scaffold/generate-app.d.ts +2 -0
- package/build/cli/cli/commands/scaffold/generate-app.d.ts.map +1 -1
- package/build/cli/cli/commands/scaffold/generate-app.js +6 -0
- package/build/cli/cli/commands/scaffold/index.d.ts.map +1 -1
- package/build/cli/cli/commands/scaffold/index.js +12 -6
- package/build/cli/cli/managed/project-file.d.ts.map +1 -1
- package/build/cli/cli/managed/project-file.js +9 -1
- package/build/cli/cli/managed/template-init.d.ts.map +1 -1
- package/build/cli/cli/managed/template-init.js +3 -1
- package/build/cli/cli/util/collection-selection-flags.d.ts +1 -1
- package/build/cli/cli/util/collection-selection-flags.d.ts.map +1 -1
- package/build/cli/cli/util/collection-selection-flags.js +31 -5
- package/build/cli/cli/util/fastly-options.d.ts +2 -0
- package/build/cli/cli/util/fastly-options.d.ts.map +1 -0
- package/build/cli/cli/util/fastly-options.js +52 -0
- package/build/cli/cli/util/package.d.ts.map +1 -1
- package/build/cli/cli/util/package.js +10 -4
- package/build/cli/models/config/collection-selection.d.ts +2 -0
- package/build/cli/models/config/collection-selection.d.ts.map +1 -1
- package/build/cli/models/config/collection-selection.js +48 -8
- package/build/cli/models/config/s3-storage-config.d.ts +1 -0
- package/build/cli/models/config/s3-storage-config.d.ts.map +1 -1
- package/build/cli/models/config/s3-storage-config.js +1 -0
- package/build/cli/models/config/static-publish-rc.d.ts +1 -0
- package/build/cli/models/config/static-publish-rc.d.ts.map +1 -1
- package/build/cli/models/config/static-publish-rc.js +3 -1
- package/build/server/hono/extensions.d.ts.map +1 -1
- package/build/server/hono/extensions.js +12 -7
- package/build/server/models/config/collection-selection.d.ts +2 -0
- package/build/server/models/config/collection-selection.d.ts.map +1 -1
- package/build/server/models/config/collection-selection.js +48 -8
- package/build/server/models/config/s3-storage-config.d.ts +1 -0
- package/build/server/models/config/s3-storage-config.d.ts.map +1 -1
- package/build/server/models/config/s3-storage-config.js +1 -0
- package/build/server/models/config/static-publish-rc.d.ts +1 -0
- package/build/server/models/config/static-publish-rc.d.ts.map +1 -1
- package/build/server/models/config/static-publish-rc.js +3 -1
- package/build/server/server/collection-selection/index.d.ts.map +1 -1
- package/build/server/server/collection-selection/index.js +16 -6
- package/build/server/server/storage/s3-storage-provider.d.ts +2 -1
- package/build/server/server/storage/s3-storage-provider.d.ts.map +1 -1
- package/build/server/server/storage/s3-storage-provider.js +15 -7
- package/package.json +2 -1
- package/resources/app/fastly.toml.njk +8 -8
- package/resources/app/static-publish.project.js.njk +6 -0
- package/resources/app/static-publish.rc.js.njk +6 -0
- package/resources/template-init/hono/gitignore +1 -0
- package/resources/templates/hono/src/index.ts +0 -1
package/DOCUMENTATION.md
CHANGED
|
@@ -184,7 +184,7 @@ Ready to go live? All you need is a [free Fastly account](https://www.fastly.com
|
|
|
184
184
|
npm run fastly:deploy
|
|
185
185
|
```
|
|
186
186
|
|
|
187
|
-
The app reads the S3 credentials from the Secret Store that has the resource link name `S3_CREDENTIALS` on your service.
|
|
187
|
+
The app reads the S3 credentials from the Secret Store that has the resource link name `S3_CREDENTIALS` on your service. To use another resource link name, for example a link that your service already has, set `s3.secretStoreLinkName` in `static-publish.rc.js` (in a managed project, in `static-publish.project.js`), and build the app again. `setSecretStoreForS3Credentials()` in the code of the app also sets the name, and is used in place of `s3.secretStoreLinkName`. In the same way, `s3.fastlyBackendName` sets the name of the backend of the S3 endpoint (default `s3_storage`).
|
|
188
188
|
|
|
189
189
|
When the Fastly CLI creates a new service, it creates a Secret Store named `S3_CREDENTIALS`, links it to the service with the same name, and prompts you for the values `S3_ACCESS_KEY_ID` and `S3_SECRET_ACCESS_KEY`.
|
|
190
190
|
|
|
@@ -234,13 +234,13 @@ An **ejected app** is in the repo, and you own its code. Every app that `scaffol
|
|
|
234
234
|
|
|
235
235
|
#### Managed projects
|
|
236
236
|
|
|
237
|
-
`scaffold --managed` writes only one file, `static-publish.project.js`, in the current directory (the project dir), and adds `.static-publish
|
|
237
|
+
`scaffold --managed` writes only one file, `static-publish.project.js`, in the current directory (the project dir), and adds `node_modules/`, `.static-publish/`, and the working directory to the `.gitignore` there, if they are not in it:
|
|
238
238
|
|
|
239
239
|
```
|
|
240
240
|
my-site/
|
|
241
241
|
├── static-publish.project.js # Commit this: the only config file
|
|
242
242
|
├── public/ # Your static site files
|
|
243
|
-
├── .gitignore # Ignores .static-publish
|
|
243
|
+
├── .gitignore # Ignores node_modules/, .static-publish/, and static-publisher/
|
|
244
244
|
└── static-publisher/ # ⚠️ Do not commit - the working directory
|
|
245
245
|
```
|
|
246
246
|
|
|
@@ -252,6 +252,8 @@ The project file has the settings that an ejected app has in its two files:
|
|
|
252
252
|
|
|
253
253
|
Paths in the project file are relative to it. The name of the file marks the mode: a directory with `static-publish.project.js` is a managed project, and a directory with `static-publish.rc.js` is an ejected app. A directory with both is an error.
|
|
254
254
|
|
|
255
|
+
The project file is a JavaScript module, and the CLI loads it with `import()`. Thus the `type` field of the nearest `package.json` decides its module format. The file that `scaffold --managed` writes uses `export default`, which needs an ES module. In a directory whose `package.json` has `"type": "commonjs"`, change `export default` to `module.exports =`. The other contents of the file stay the same.
|
|
256
|
+
|
|
255
257
|
`publish-content`, `collections`, and `clean` run in the project dir (or with `--project-dir`), and read the project file. `publish-content` purges the service of `managed.serviceId`, after `--fastly-service-id` and `FASTLY_SERVICE_ID`.
|
|
256
258
|
|
|
257
259
|
To run the app on your computer:
|
|
@@ -281,7 +283,7 @@ managed: {
|
|
|
281
283
|
```
|
|
282
284
|
|
|
283
285
|
- Only `local_server` and `setup` can be added. The CLI writes the other parts of `fastly.toml`.
|
|
284
|
-
- The CLI also writes some resources: the KV Store of the content, and in S3 mode, the `S3_CREDENTIALS` Secret Store and the `s3_storage` backend. A resource with one of these names is an error.
|
|
286
|
+
- The CLI also writes some resources: the KV Store of the content, and in S3 mode, the `S3_CREDENTIALS` Secret Store and the `s3_storage` backend (other names with `s3.secretStoreLinkName` and `s3.fastlyBackendName`). A resource with one of these names is an error.
|
|
285
287
|
- Do not put a secret in the project file: in `local_server`, read it from an environment variable (`env`) or a file (`file`) that is not committed.
|
|
286
288
|
- `local_server` does not change the fingerprint, because it is only for `fastly compute serve`. `setup` changes it.
|
|
287
289
|
- `eject` writes the sections into the `fastly.toml` of the ejected app.
|
|
@@ -300,7 +302,7 @@ To deploy the app:
|
|
|
300
302
|
npx @fastly/compute-js-static-publish@beta deploy
|
|
301
303
|
```
|
|
302
304
|
|
|
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`).
|
|
305
|
+
`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`). Options after `--` go to `fastly compute deploy`, for example `deploy -- --status-check-timeout=180`. `deploy` refuses `--comment`, `--service-id` (`-s`), `--token` (`-t`), `--package` (`-p`), `--dir` (`-C`), and `--env` there, because it sets them, or they deploy something else.
|
|
304
306
|
|
|
305
307
|
- **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
308
|
- **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.
|
|
@@ -620,6 +622,7 @@ const rc = {
|
|
|
620
622
|
// Tried in order. The first source that gives a collection wins.
|
|
621
623
|
// If no source gives a collection, the default collection is used.
|
|
622
624
|
sources: [
|
|
625
|
+
{ type: 'host', pattern: 'stag.example.com', value: 'staging' },
|
|
623
626
|
{ type: 'host', pattern: '{collection}.preview.example.com' },
|
|
624
627
|
{ type: 'path', prefix: '/_preview/{collection}', sticky: 'cookie' },
|
|
625
628
|
{ type: 'query', param: 'collection', sticky: 'cookie' },
|
|
@@ -640,14 +643,15 @@ const rc = {
|
|
|
640
643
|
|
|
641
644
|
| Source | Reads | Notes |
|
|
642
645
|
|--------|-------|-------|
|
|
643
|
-
| `host` | The hostname, matched against `pattern` | Needs a wildcard domain and TLS for it. The pattern has one `{collection}` in one label, with fixed text around it if you want (`branch-{collection}.preview.example.com`). A host label has at most 63 characters. Make sure that your production hostname does not match the pattern. |
|
|
644
|
-
| `path` | A path prefix, which is removed before the file lookup | Works on `*.edgecompute.app`. Links that start with `/` lose the prefix, so use it with `sticky: 'cookie'`, or for a site with relative links. The links in HTML do not change. |
|
|
646
|
+
| `host` | The hostname, matched against `pattern` | Needs a wildcard domain and TLS for it. The pattern has one `{collection}` in one label, with fixed text around it if you want (`branch-{collection}.preview.example.com`). A host label has at most 63 characters. Make sure that your production hostname does not match the pattern. With `value`, `pattern` is one hostname without `{collection}`, and selects the collection in `value` (`stag.example.com` → `staging`). |
|
|
647
|
+
| `path` | A path prefix, which is removed before the file lookup | Works on `*.edgecompute.app`. Links that start with `/` lose the prefix, so use it with `sticky: 'cookie'`, or for a site with relative links. The links in HTML do not change. With `value`, `prefix` has no `{collection}`, and selects the collection in `value` (`/_staging` → `staging`). |
|
|
645
648
|
| `query` | A query parameter | Only the request that has it. Usually used with `sticky: 'cookie'`. |
|
|
646
649
|
| `cookie` | A cookie | Also serves the activate path (`/activate?collection=<name>&redirectTo=<path>`) and the reset path. |
|
|
647
650
|
| `header` | A request header | For tests, CI checks, and API clients. |
|
|
648
651
|
|
|
649
652
|
- `sticky: 'cookie'` on a `path` or `query` source: when the source matches, set the cookie of the `cookie` source, and redirect (`308`) to the URL without the prefix or the parameter. It needs a `cookie` source.
|
|
650
653
|
- A name must follow the [collection name rule](#-collections-publish-preview-promote) and match `allow`. Otherwise the source is skipped.
|
|
654
|
+
- A `value` must also follow the collection name rule, and match `allow` if it is set. Otherwise the config is not valid, and the CLI and the app show an error.
|
|
651
655
|
- Redirects go only to a path on the same site. `redirectTo` with another site redirects to `/`.
|
|
652
656
|
- The responses of a selected collection (not the default collection) get `X-Robots-Tag: noindex` (unless `noindex` is `false`). They get `Cache-Control: private` if the URL does not name the collection. See [Shared caches](#shared-caches).
|
|
653
657
|
- To find out if a selected collection exists, `PublisherServer` reads its index, also when the [response cache](#️-caching-responses-with-the-core-cache) has the response.
|
|
@@ -1189,6 +1193,7 @@ npx @fastly/compute-js-static-publish@beta template init
|
|
|
1189
1193
|
hono-extensions/
|
|
1190
1194
|
├── package.json # Your dependencies, and the peer dependencies on the packages that the app provides
|
|
1191
1195
|
├── tsconfig.json # For your editor
|
|
1196
|
+
├── .gitignore # Ignores node_modules/
|
|
1192
1197
|
├── 10-auth.ts # A module
|
|
1193
1198
|
├── api.ts # A module
|
|
1194
1199
|
├── _example.ts # An example, not a module (the name starts with _)
|
|
@@ -1256,14 +1261,14 @@ templateOptions: {
|
|
|
1256
1261
|
|
|
1257
1262
|
**Errors** in a module stop the build, and the message names the file: a default export that is not `defineExtension()`, an object with no phase, a key that is not a phase, or a phase that is not a function.
|
|
1258
1263
|
|
|
1259
|
-
**The build** bundles the modules into `src/hono-extensions.generated.js` of the app (the `prebuild` [template hook](#-template-hooks)). The packages that the app provides stay imports, so that the app has one copy of each: the dependencies of the app (for example `hono` and `@fastly/hono-fastly-compute`), this package, and `fastly:*`. Thus, do not
|
|
1264
|
+
**The build** bundles the modules into `src/hono-extensions.generated.js` of the app (the `prebuild` [template hook](#-template-hooks)). The packages that the app provides stay imports, so that the app has one copy of each: the dependencies of the app (for example `hono` and `@fastly/hono-fastly-compute`), this package, and `fastly:*`. Thus, do not add them to the `dependencies` of the folder. `template init` writes them as peer dependencies in `hono-extensions/package.json`, with the versions that the app has. `npm install` in `hono-extensions/` installs them too, because npm 7 and later install peer dependencies. These copies are only for your editor and the type checker. The build always uses the copies of the app. Install other packages in the folder, and the build bundles them.
|
|
1260
1265
|
|
|
1261
1266
|
- `build.hono.extensionsDir` sets another folder, relative to the project file (or to `static-publish.rc.js`). The default is `./hono-extensions`.
|
|
1262
1267
|
- Without the folder, or without modules, the app has no extensions. `dev` and `deploy` of a managed project then show how to make the folder.
|
|
1263
1268
|
- In a managed project, the files of the folder (without `node_modules/`) are part of the fingerprint, so a change to a module makes `deploy` deploy again.
|
|
1264
1269
|
- Keep the code of the extensions in the folder. A module can import a file from outside the folder, and the build bundles it, but a change to that file does not change the fingerprint, and the watcher does not see it.
|
|
1265
1270
|
|
|
1266
|
-
**`template init`** makes the folder with `package.json`, `tsconfig.json`, and the example. In a folder that exists, it updates only the peer dependencies, and adds the starter files that are missing. It never changes your modules. `--reset` writes the starter files again (it asks first, or needs `--force` with `--non-interactive`). `--check` changes nothing, and fails with `template-init-needed` if the folder is out of date, for example after an upgrade of this package; use it in CI.
|
|
1271
|
+
**`template init`** makes the folder with `package.json`, `tsconfig.json`, `.gitignore` (for `node_modules/`), and the example. In a folder that exists, it updates only the peer dependencies, and adds the starter files that are missing. It never changes your modules. `--reset` writes the starter files again (it asks first, or needs `--force` with `--non-interactive`). `--check` changes nothing, and fails with `template-init-needed` if the folder is out of date, for example after an upgrade of this package; use it in CI.
|
|
1267
1272
|
|
|
1268
1273
|
**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.
|
|
1269
1274
|
|
|
@@ -1630,7 +1635,9 @@ npx @fastly/compute-js-static-publish@beta \
|
|
|
1630
1635
|
**Collection selection** (written as `collectionSelection` in `static-publish.rc.js`; see [Previews: Collection Selection](#-previews-collection-selection)):
|
|
1631
1636
|
- `--collection-selection`: A source. Can be repeated; the sources are tried in the order of the flags.
|
|
1632
1637
|
- `host:<pattern>`, for example `host:{collection}.preview.example.com`
|
|
1638
|
+
- `host:<hostname>,value=<collection>`, for example `host:stag.example.com,value=staging`
|
|
1633
1639
|
- `path:<prefix>[,sticky]`, for example `path:/_preview/{collection},sticky`
|
|
1640
|
+
- `path:<prefix>,value=<collection>[,sticky]`, for example `path:/_staging,value=staging`
|
|
1634
1641
|
- `query:<param>[,sticky]`, for example `query:collection,sticky`
|
|
1635
1642
|
- `cookie[:<cookieName>][,maxAge=<seconds>][,activatePath=<path>][,resetPath=<path>]`
|
|
1636
1643
|
- `header:<name>`, for example `header:x-publisher-collection`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/manage/deploy.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/manage/deploy.ts"],"names":[],"mappings":"AAiFA,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,iBAqMhD"}
|
|
@@ -13,6 +13,7 @@ import { writeBackServiceId } from '../../managed/project-edit.js';
|
|
|
13
13
|
import { loadApiToken } from '../../util/api-token.js';
|
|
14
14
|
import { parseCommandLine } from '../../util/args.js';
|
|
15
15
|
import { detectProjectMode } from '../../util/config.js';
|
|
16
|
+
import { findRefusedFastlyOption } from '../../util/fastly-options.js';
|
|
16
17
|
import { readServiceId } from '../../util/fastly-toml.js';
|
|
17
18
|
import { cliCommand, getOwnPackageDir, getOwnVersion } from '../../util/package.js';
|
|
18
19
|
import { appFastlyCommand } from '../run-dev-watch.js';
|
|
@@ -24,7 +25,7 @@ function help() {
|
|
|
24
25
|
console.log(`\
|
|
25
26
|
|
|
26
27
|
Usage:
|
|
27
|
-
${cliCommand()} deploy [options]
|
|
28
|
+
${cliCommand()} deploy [options] [-- <options for the Fastly CLI>]
|
|
28
29
|
|
|
29
30
|
Description:
|
|
30
31
|
Deploys the app of a managed project, only if it changed: generates the app,
|
|
@@ -50,6 +51,12 @@ Options:
|
|
|
50
51
|
managed.serviceId. Without one, the Fastly CLI
|
|
51
52
|
makes a new service.
|
|
52
53
|
--fastly-api-token=<token> Default: FASTLY_API_TOKEN.
|
|
54
|
+
-- <options> Options for 'fastly compute deploy' (in an ejected app,
|
|
55
|
+
'fastly compute publish'), for example
|
|
56
|
+
-- --status-check-timeout=180. Not allowed: --comment,
|
|
57
|
+
--service-id (-s), --token (-t), --package (-p),
|
|
58
|
+
--dir (-C), and --env, because deploy sets them, or
|
|
59
|
+
they deploy something else.
|
|
53
60
|
|
|
54
61
|
Global Options:
|
|
55
62
|
-h, --help Show this help message and exit.
|
|
@@ -66,6 +73,10 @@ function runFastly(appDir, args, apiToken) {
|
|
|
66
73
|
});
|
|
67
74
|
}
|
|
68
75
|
export async function action(actionArgs) {
|
|
76
|
+
// Options after -- go to the Fastly CLI.
|
|
77
|
+
const separator = actionArgs.indexOf('--');
|
|
78
|
+
const fastlyArgs = separator === -1 ? [] : actionArgs.slice(separator + 1);
|
|
79
|
+
const ownArgs = separator === -1 ? actionArgs : actionArgs.slice(0, separator);
|
|
69
80
|
const optionDefinitions = [
|
|
70
81
|
{ name: 'force', type: Boolean },
|
|
71
82
|
{ name: 'auto-upgrade', type: Boolean },
|
|
@@ -73,7 +84,7 @@ export async function action(actionArgs) {
|
|
|
73
84
|
{ name: 'fastly-service-id', type: String },
|
|
74
85
|
{ name: 'fastly-api-token', type: String },
|
|
75
86
|
];
|
|
76
|
-
const parsed = parseCommandLine(
|
|
87
|
+
const parsed = parseCommandLine(ownArgs, optionDefinitions);
|
|
77
88
|
if (parsed.needHelp) {
|
|
78
89
|
if (parsed.error != null) {
|
|
79
90
|
console.error(String(parsed.error));
|
|
@@ -84,6 +95,11 @@ export async function action(actionArgs) {
|
|
|
84
95
|
return;
|
|
85
96
|
}
|
|
86
97
|
const { force, ['auto-upgrade']: autoUpgrade, comment, ['fastly-service-id']: fastlyServiceId, ['fastly-api-token']: fastlyApiToken, } = parsed.commandLineOptions;
|
|
98
|
+
const refused = findRefusedFastlyOption(fastlyArgs);
|
|
99
|
+
if (refused != null) {
|
|
100
|
+
fail('usage', refused);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
87
103
|
if (detectProjectMode() === 'ejected') {
|
|
88
104
|
if (isJsonMode()) {
|
|
89
105
|
fail('json-not-supported', `--json is not supported for 'deploy' in an ejected app.`);
|
|
@@ -107,6 +123,7 @@ export async function action(actionArgs) {
|
|
|
107
123
|
if (isNonInteractive()) {
|
|
108
124
|
publishArgs.push('--non-interactive');
|
|
109
125
|
}
|
|
126
|
+
publishArgs.push(...fastlyArgs);
|
|
110
127
|
const env = typeof fastlyApiToken === 'string' && fastlyApiToken !== '' ?
|
|
111
128
|
{ ...process.env, FASTLY_API_TOKEN: fastlyApiToken } :
|
|
112
129
|
process.env;
|
|
@@ -167,7 +184,8 @@ export async function action(actionArgs) {
|
|
|
167
184
|
reason: 'up-to-date',
|
|
168
185
|
serviceId,
|
|
169
186
|
version: active.number,
|
|
170
|
-
|
|
187
|
+
// Only the JSON result has the domain, so get it only in JSON mode.
|
|
188
|
+
domain: isJsonMode() ? (await getVersionDomains(context, serviceId, active.number))[0] ?? null : null,
|
|
171
189
|
fingerprint,
|
|
172
190
|
staticPublishVersion,
|
|
173
191
|
});
|
|
@@ -187,6 +205,7 @@ export async function action(actionArgs) {
|
|
|
187
205
|
if (isNonInteractive()) {
|
|
188
206
|
deployArgs.push('--non-interactive');
|
|
189
207
|
}
|
|
208
|
+
deployArgs.push(...fastlyArgs);
|
|
190
209
|
const deploy = runFastly(appDir, deployArgs, apiToken.apiToken);
|
|
191
210
|
if (deploy.error != null || deploy.status !== 0) {
|
|
192
211
|
fail('deploy-failed', `'fastly compute deploy' failed.`);
|
|
@@ -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,
|
|
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,iBA0mBhD"}
|
|
@@ -499,11 +499,13 @@ export async function action(actionArgs) {
|
|
|
499
499
|
}
|
|
500
500
|
console.log(`✅ Scan complete.`);
|
|
501
501
|
console.log(` | ${Object.keys(assetsIndex).length} file(s) in the index, ${hiddenCount} of them hidden.`);
|
|
502
|
+
// Counted before applyBatch(), which can split the entries into chunks.
|
|
503
|
+
const uploadedVariantCount = batch.storageProviderBatchEntries.length;
|
|
502
504
|
if (existingKeys != null) {
|
|
503
|
-
console.log(` | ${existingVariantCount} variant(s) already in storage, ${
|
|
505
|
+
console.log(` | ${existingVariantCount} variant(s) already in storage, ${uploadedVariantCount} to upload.`);
|
|
504
506
|
}
|
|
505
507
|
else {
|
|
506
|
-
console.log(` | ${
|
|
508
|
+
console.log(` | ${uploadedVariantCount} variant(s) to upload.`);
|
|
507
509
|
}
|
|
508
510
|
await storageProvider.applyBatch(batch, { existingKeys, verbose });
|
|
509
511
|
// #### INDEX FILE
|
|
@@ -606,7 +608,7 @@ export async function action(actionArgs) {
|
|
|
606
608
|
},
|
|
607
609
|
// Each file, and each compressed variant that is kept.
|
|
608
610
|
storageItems: {
|
|
609
|
-
uploaded:
|
|
611
|
+
uploaded: uploadedVariantCount,
|
|
610
612
|
reused: existingVariantCount,
|
|
611
613
|
},
|
|
612
614
|
expiresAt: expirationTime != null ? new Date(expirationTime * 1000).toISOString() : null,
|
|
@@ -27,14 +27,14 @@ Description:
|
|
|
27
27
|
The template is managed.template in ${PROJECT_FILE_NAME}, or
|
|
28
28
|
generatedFrom.template in ${RC_FILE_NAME}.
|
|
29
29
|
|
|
30
|
-
A new folder gets package.json, tsconfig.json, and inactive
|
|
31
|
-
folder that exists, it updates only the peer dependencies on
|
|
32
|
-
that the app provides, and adds the starter files that are
|
|
33
|
-
changes your modules. Then run npm install in the folder.
|
|
30
|
+
A new folder gets package.json, tsconfig.json, .gitignore, and an inactive
|
|
31
|
+
example. In a folder that exists, it updates only the peer dependencies on
|
|
32
|
+
the packages that the app provides, and adds the starter files that are
|
|
33
|
+
missing. It never changes your modules. Then run npm install in the folder.
|
|
34
34
|
|
|
35
35
|
Options:
|
|
36
|
-
--reset Also write the starter files again (tsconfig.json
|
|
37
|
-
and the
|
|
36
|
+
--reset Also write the starter files again (tsconfig.json,
|
|
37
|
+
.gitignore, and the example). Asks before it replaces a file,
|
|
38
38
|
or needs --force in non-interactive mode.
|
|
39
39
|
--force With --reset: replace without a question.
|
|
40
40
|
--check Change nothing. Fail (template-init-needed) if
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-app.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/scaffold/generate-app.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,gDAAgD,CAAC;AAC1F,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,kDAAkD,CAAC;AAC3F,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,4BAA4B,EAAE,MAAM,6CAA6C,CAAC;AAGpH,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,mBA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ndpointHostname;
|
|
85
|
+
let s3BackendName;
|
|
86
|
+
let s3SecretStoreLinkName;
|
|
85
87
|
if (storage.mode === 'kv-store') {
|
|
86
88
|
localServerKvStorePath = dotRelative(computeJsDir, path.resolve(staticPublisherWorkingDir, 'kvstore.json'));
|
|
87
89
|
// kvstore.json
|
|
@@ -91,6 +93,8 @@ export function generateApp(config) {
|
|
|
91
93
|
const url = new URL(storage.endpointUrl);
|
|
92
94
|
s3EndpointUrl = String(url);
|
|
93
95
|
s3EndpointHostname = url.hostname;
|
|
96
|
+
s3BackendName = storage.fastlyBackendName ?? 's3_storage';
|
|
97
|
+
s3SecretStoreLinkName = storage.secretStoreLinkName ?? 'S3_CREDENTIALS';
|
|
94
98
|
}
|
|
95
99
|
resourceFiles['fastly.toml'] = addFastlyTomlSections(renderAppResource('fastly.toml', {
|
|
96
100
|
author,
|
|
@@ -101,6 +105,8 @@ export function generateApp(config) {
|
|
|
101
105
|
localServerKvStorePath,
|
|
102
106
|
s3EndpointUrl,
|
|
103
107
|
s3EndpointHostname,
|
|
108
|
+
s3BackendName,
|
|
109
|
+
s3SecretStoreLinkName,
|
|
104
110
|
}), fastlyToml);
|
|
105
111
|
// static-publish.rc.js
|
|
106
112
|
resourceFiles['static-publish.rc.js'] = renderAppResource('static-publish.rc.js', {
|
|
@@ -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,MAAM,GAA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S,CAAC;IAC9B,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,qBAAqB,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1C,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AA2UF,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,iBA4iBhD;AASD,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,EAAE,CAAA;CAAE,CAehH"}
|
|
@@ -839,6 +839,7 @@ To build and deploy to your Compute service:
|
|
|
839
839
|
|
|
840
840
|
The application reads the S3 credentials from the Secret Store that has the resource
|
|
841
841
|
link name 'S3_CREDENTIALS' on the service. The Secret Store can have a different name.
|
|
842
|
+
To use another resource link name, set s3.secretStoreLinkName in static-publish.rc.js.
|
|
842
843
|
|
|
843
844
|
To deploy to an existing service, do these steps first:
|
|
844
845
|
1. Create a Secret Store with the values 'S3_ACCESS_KEY_ID' and 'S3_SECRET_ACCESS_KEY'.
|
|
@@ -857,8 +858,8 @@ To build and deploy to your Compute service:
|
|
|
857
858
|
|
|
858
859
|
If a Secret Store named 'S3_CREDENTIALS' already exists, the Fastly CLI asks for a
|
|
859
860
|
different name. If you leave it empty, it uses the existing Secret Store. If you give
|
|
860
|
-
a different name, the Fastly CLI uses it for the resource link too. Then
|
|
861
|
-
|
|
861
|
+
a different name, the Fastly CLI uses it for the resource link too. Then set
|
|
862
|
+
s3.secretStoreLinkName in static-publish.rc.js to that name, and deploy again.
|
|
862
863
|
|
|
863
864
|
After the deploy, fastly.toml has the service ID, so s3:publish also purges the
|
|
864
865
|
service's cache. For this purge, s3:publish needs FASTLY_API_TOKEN too.
|
|
@@ -868,9 +869,12 @@ To build and deploy to your Compute service:
|
|
|
868
869
|
}
|
|
869
870
|
// The lines that scaffold --managed adds to the .gitignore of the project dir.
|
|
870
871
|
const GITIGNORE_COMMENT = '# @fastly/compute-js-static-publish';
|
|
872
|
+
// A line is present also without its leading or trailing '/': for example,
|
|
873
|
+
// 'node_modules' in the file also ignores the directory of '/node_modules/'.
|
|
874
|
+
const gitignoreKey = (line) => line.trim().replace(/^\//, '').replace(/\/$/, '');
|
|
871
875
|
export function addGitignoreLines(existing, lines) {
|
|
872
|
-
const present = new Set((existing ?? '').split(/\r?\n/).map(
|
|
873
|
-
const added = lines.filter(line => !present.has(line));
|
|
876
|
+
const present = new Set((existing ?? '').split(/\r?\n/).map(gitignoreKey));
|
|
877
|
+
const added = lines.filter(line => !present.has(gitignoreKey(line)));
|
|
874
878
|
if (added.length === 0) {
|
|
875
879
|
return { content: existing ?? '', added };
|
|
876
880
|
}
|
|
@@ -888,11 +892,13 @@ function writeManagedProject(appConfig, projectDir) {
|
|
|
888
892
|
const projectFilePath = path.resolve(projectDir, PROJECT_FILE_NAME);
|
|
889
893
|
fs.writeFileSync(projectFilePath, renderProjectFile(appConfig, projectDir, getOwnVersion()), 'utf-8');
|
|
890
894
|
console.log(`🚀 Managed project created: ${rootRelative(projectFilePath)}`);
|
|
891
|
-
// Ignore the
|
|
895
|
+
// Ignore the node_modules of the project (this package can be a dev
|
|
896
|
+
// dependency of the project), the generated app, and the working dir. Never
|
|
897
|
+
// change the customer's lines.
|
|
892
898
|
const gitignorePath = path.resolve(projectDir, '.gitignore');
|
|
893
899
|
const existing = fs.existsSync(gitignorePath) ? fs.readFileSync(gitignorePath, 'utf-8') : null;
|
|
894
900
|
const workingDir = path.relative(projectDir, appConfig.staticPublisherWorkingDir).split(path.sep).join('/');
|
|
895
|
-
const lines = ['/.static-publish/'];
|
|
901
|
+
const lines = ['/node_modules/', '/.static-publish/'];
|
|
896
902
|
if (!workingDir.startsWith('..')) {
|
|
897
903
|
lines.push(`/${workingDir}/`);
|
|
898
904
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project-file.d.ts","sourceRoot":"","sources":["../../../../src/cli/managed/project-file.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,KAAK,8BAA8B,EAAE,MAAM,+CAA+C,CAAC;AACpG,OAAO,EAAE,KAAK,2BAA2B,EAAE,MAAM,+CAA+C,CAAC;AACjG,OAAO,EAAE,KAAK,eAAe,EAA0D,MAAM,0CAA0C,CAAC;AAGxI,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAE,KAAK,SAAS,EAAoB,MAAM,sCAAsC,CAAC;AAMxF,eAAO,MAAM,2BAA2B,8BAA8B,CAAC;AAKvE,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,oBAAoB,EAAE,MAAM,GAAG,MAAM,CAyC7G;AAED,MAAM,MAAM,2BAA2B,GAAG;IACxC,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,wBAAwB,EAAE,MAAM,CAAC;IACjC,QAAQ,EAAE,WAAW,CAAC;IAGtB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAIF,wBAAgB,oBAAoB,CAClC,EAAE,EAAE,eAAe,EACnB,cAAc,EAAE,8BAA8B,EAC9C,OAAO,EAAE,2BAA2B,EACpC,OAAO,EAAE,2BAA2B,GACnC,SAAS,
|
|
1
|
+
{"version":3,"file":"project-file.d.ts","sourceRoot":"","sources":["../../../../src/cli/managed/project-file.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,KAAK,8BAA8B,EAAE,MAAM,+CAA+C,CAAC;AACpG,OAAO,EAAE,KAAK,2BAA2B,EAAE,MAAM,+CAA+C,CAAC;AACjG,OAAO,EAAE,KAAK,eAAe,EAA0D,MAAM,0CAA0C,CAAC;AAGxI,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAE,KAAK,SAAS,EAAoB,MAAM,sCAAsC,CAAC;AAMxF,eAAO,MAAM,2BAA2B,8BAA8B,CAAC;AAKvE,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,oBAAoB,EAAE,MAAM,GAAG,MAAM,CAyC7G;AAED,MAAM,MAAM,2BAA2B,GAAG;IACxC,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,wBAAwB,EAAE,MAAM,CAAC;IACjC,QAAQ,EAAE,WAAW,CAAC;IAGtB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAIF,wBAAgB,oBAAoB,CAClC,EAAE,EAAE,eAAe,EACnB,cAAc,EAAE,8BAA8B,EAC9C,OAAO,EAAE,2BAA2B,EACpC,OAAO,EAAE,2BAA2B,GACnC,SAAS,CAqEX"}
|
|
@@ -78,7 +78,15 @@ export function appConfigFromProject(rc, publishContent, managed, options) {
|
|
|
78
78
|
else {
|
|
79
79
|
throw new Error('The S3 endpoint of the project is not resolved.');
|
|
80
80
|
}
|
|
81
|
-
storage = {
|
|
81
|
+
storage = {
|
|
82
|
+
mode: 's3',
|
|
83
|
+
region: rc.s3.region,
|
|
84
|
+
bucket: rc.s3.bucket,
|
|
85
|
+
endpointUrl,
|
|
86
|
+
endpointGenerated: rc.s3.endpoint == null,
|
|
87
|
+
...(rc.s3.fastlyBackendName != null ? { fastlyBackendName: rc.s3.fastlyBackendName } : {}),
|
|
88
|
+
...(rc.s3.secretStoreLinkName != null ? { secretStoreLinkName: rc.s3.secretStoreLinkName } : {}),
|
|
89
|
+
};
|
|
82
90
|
}
|
|
83
91
|
else {
|
|
84
92
|
storage = { mode: 'kv-store', kvStoreName: getKvStoreConfigFromRc(rc).kvStoreName };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template-init.d.ts","sourceRoot":"","sources":["../../../../src/cli/managed/template-init.ts"],"names":[],"mappings":"AAoBA,wBAAgB,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAE7D;
|
|
1
|
+
{"version":3,"file":"template-init.d.ts","sourceRoot":"","sources":["../../../../src/cli/managed/template-init.ts"],"names":[],"mappings":"AAoBA,wBAAgB,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAE7D;AA0BD,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,GAAG,SAAS,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAexI;AAED,MAAM,MAAM,gBAAgB,GAAG;IAE7B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAE9B,OAAO,EAAE,MAAM,EAAE,CAAC;IAElB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC;AAKF,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE;IAAE,KAAK,EAAE,OAAO,CAAA;CAAE,GAAG,gBAAgB,CAsDzJ;AAGD,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAgB,QAM1E"}
|
|
@@ -17,6 +17,8 @@ export function templateHasInit(templateName) {
|
|
|
17
17
|
return fs.existsSync(path.resolve(resourcesDir, 'template-init', templateName));
|
|
18
18
|
}
|
|
19
19
|
// The starter files of a template, keyed by the path relative to its folder.
|
|
20
|
+
// The file 'gitignore' is written as '.gitignore', because npm leaves a file
|
|
21
|
+
// named .gitignore out of the published package.
|
|
20
22
|
function starterFiles(templateName) {
|
|
21
23
|
const dir = path.resolve(resourcesDir, 'template-init', templateName);
|
|
22
24
|
const files = {};
|
|
@@ -27,7 +29,7 @@ function starterFiles(templateName) {
|
|
|
27
29
|
walk(rel);
|
|
28
30
|
}
|
|
29
31
|
else {
|
|
30
|
-
files[rel] = fs.readFileSync(path.resolve(dir, rel), 'utf-8');
|
|
32
|
+
files[rel === 'gitignore' ? '.gitignore' : rel] = fs.readFileSync(path.resolve(dir, rel), 'utf-8');
|
|
31
33
|
}
|
|
32
34
|
}
|
|
33
35
|
};
|
|
@@ -5,7 +5,7 @@ export type CollectionSelectionFlags = {
|
|
|
5
5
|
onMissing?: string;
|
|
6
6
|
noindex?: string;
|
|
7
7
|
};
|
|
8
|
-
export declare const COLLECTION_SELECTION_FLAGS_HELP = " --collection-selection <source> Select the collection of a request, for example for\n previews. Can be repeated; the sources are tried in order.\n host:<pattern> host:{collection}.preview.example.com\n path:<prefix>[,sticky] path:/_preview/{collection},sticky\n query:<param>[,sticky] query:collection,sticky\n cookie[:<name>][,maxAge=<seconds>][,activatePath=<path>][,resetPath=<path>]\n header:<name> header:x-publisher-collection\n 'sticky' also sets the cookie of the cookie source, so it needs a cookie source.\n --collection-allow <patterns> The collections that can be selected, for example \"pr-*,staging\".\n Default: any collection.\n --collection-on-missing <value> When the selected collection is not published or has\n expired: 'not-found' (default: a 404 response) or\n 'default' (serve the default collection).\n --collection-noindex <true|false> Add 'X-Robots-Tag: noindex' to the responses of a collection\n that is not the default collection. Default: true.";
|
|
8
|
+
export declare const COLLECTION_SELECTION_FLAGS_HELP = " --collection-selection <source> Select the collection of a request, for example for\n previews. Can be repeated; the sources are tried in order.\n host:<pattern> host:{collection}.preview.example.com\n host:<host>,value=<name> host:stag.example.com,value=staging\n path:<prefix>[,sticky] path:/_preview/{collection},sticky\n path:<prefix>,value=<name> path:/_staging,value=staging,sticky\n query:<param>[,sticky] query:collection,sticky\n cookie[:<name>][,maxAge=<seconds>][,activatePath=<path>][,resetPath=<path>]\n header:<name> header:x-publisher-collection\n 'sticky' also sets the cookie of the cookie source, so it needs a cookie source.\n 'value' gives one collection for a hostname or a prefix without {collection}.\n --collection-allow <patterns> The collections that can be selected, for example \"pr-*,staging\".\n Default: any collection.\n --collection-on-missing <value> When the selected collection is not published or has\n expired: 'not-found' (default: a 404 response) or\n 'default' (serve the default collection).\n --collection-noindex <true|false> Add 'X-Robots-Tag: noindex' to the responses of a collection\n that is not the default collection. Default: true.";
|
|
9
9
|
export declare function collectionSelectionFromFlags(flags: CollectionSelectionFlags): {
|
|
10
10
|
collectionSelection: CollectionSelection | undefined;
|
|
11
11
|
errors: string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collection-selection-flags.d.ts","sourceRoot":"","sources":["../../../../src/cli/util/collection-selection-flags.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,KAAK,mBAAmB,EAIzB,MAAM,6CAA6C,CAAC;AAcrD,MAAM,MAAM,wBAAwB,GAAG;IACrC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,eAAO,MAAM,+BAA+B,
|
|
1
|
+
{"version":3,"file":"collection-selection-flags.d.ts","sourceRoot":"","sources":["../../../../src/cli/util/collection-selection-flags.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,KAAK,mBAAmB,EAIzB,MAAM,6CAA6C,CAAC;AAcrD,MAAM,MAAM,wBAAwB,GAAG;IACrC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,eAAO,MAAM,+BAA+B,oxDAkB+C,CAAC;AA+F5F,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,wBAAwB,GAAG;IAC7E,mBAAmB,EAAE,mBAAmB,GAAG,SAAS,CAAC;IACrD,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAqCA"}
|
|
@@ -7,11 +7,14 @@ export const COLLECTION_SELECTION_FLAGS_HELP = `\
|
|
|
7
7
|
--collection-selection <source> Select the collection of a request, for example for
|
|
8
8
|
previews. Can be repeated; the sources are tried in order.
|
|
9
9
|
host:<pattern> host:{collection}.preview.example.com
|
|
10
|
+
host:<host>,value=<name> host:stag.example.com,value=staging
|
|
10
11
|
path:<prefix>[,sticky] path:/_preview/{collection},sticky
|
|
12
|
+
path:<prefix>,value=<name> path:/_staging,value=staging,sticky
|
|
11
13
|
query:<param>[,sticky] query:collection,sticky
|
|
12
14
|
cookie[:<name>][,maxAge=<seconds>][,activatePath=<path>][,resetPath=<path>]
|
|
13
15
|
header:<name> header:x-publisher-collection
|
|
14
16
|
'sticky' also sets the cookie of the cookie source, so it needs a cookie source.
|
|
17
|
+
'value' gives one collection for a hostname or a prefix without {collection}.
|
|
15
18
|
--collection-allow <patterns> The collections that can be selected, for example "pr-*,staging".
|
|
16
19
|
Default: any collection.
|
|
17
20
|
--collection-on-missing <value> When the selected collection is not published or has
|
|
@@ -31,6 +34,23 @@ function parseSource(spec, errors) {
|
|
|
31
34
|
}
|
|
32
35
|
return true;
|
|
33
36
|
};
|
|
37
|
+
// The options of a host or path source: value=<collection>, and sticky
|
|
38
|
+
// (only if allowSticky).
|
|
39
|
+
const valueAndSticky = (allowSticky) => {
|
|
40
|
+
const result = {};
|
|
41
|
+
for (const option of options) {
|
|
42
|
+
if (allowSticky && option === 'sticky') {
|
|
43
|
+
result.sticky = 'cookie';
|
|
44
|
+
}
|
|
45
|
+
else if (option.startsWith('value=')) {
|
|
46
|
+
result.value = option.slice('value='.length);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
errors.push(`--collection-selection ${type}: unknown option '${option}'.`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return result;
|
|
53
|
+
};
|
|
34
54
|
const sticky = () => {
|
|
35
55
|
let result;
|
|
36
56
|
for (const option of options) {
|
|
@@ -49,12 +69,18 @@ function parseSource(spec, errors) {
|
|
|
49
69
|
}
|
|
50
70
|
};
|
|
51
71
|
switch (type) {
|
|
52
|
-
case 'host':
|
|
53
|
-
|
|
54
|
-
return needValue('pattern') ? { type, pattern: value } : null;
|
|
72
|
+
case 'host': {
|
|
73
|
+
const o = valueAndSticky(false);
|
|
74
|
+
return needValue('pattern') ? { type, pattern: value, ...(o.value != null ? { value: o.value } : {}) } : null;
|
|
75
|
+
}
|
|
55
76
|
case 'path': {
|
|
56
|
-
const
|
|
57
|
-
return needValue('prefix') ? {
|
|
77
|
+
const o = valueAndSticky(true);
|
|
78
|
+
return needValue('prefix') ? {
|
|
79
|
+
type,
|
|
80
|
+
prefix: value,
|
|
81
|
+
...(o.value != null ? { value: o.value } : {}),
|
|
82
|
+
...(o.sticky != null ? { sticky: o.sticky } : {}),
|
|
83
|
+
} : null;
|
|
58
84
|
}
|
|
59
85
|
case 'query': {
|
|
60
86
|
const s = sticky();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fastly-options.d.ts","sourceRoot":"","sources":["../../../../src/cli/util/fastly-options.ts"],"names":[],"mappings":"AAiCA,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,IAAI,CAqBrE"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright Fastly, Inc.
|
|
3
|
+
* Licensed under the MIT license. See LICENSE file for details.
|
|
4
|
+
*/
|
|
5
|
+
// The options after -- of deploy, which go to 'fastly compute deploy' (or
|
|
6
|
+
// 'fastly compute publish' in an ejected app). deploy refuses the options that
|
|
7
|
+
// it sets itself, and the options that make the Fastly CLI deploy another
|
|
8
|
+
// package, from another directory, or with another manifest or token.
|
|
9
|
+
const REFUSED = new Map([
|
|
10
|
+
['comment', `deploy sets the comment of the service version. Use the --comment option of deploy (before --).`],
|
|
11
|
+
['service-id', `Use --fastly-service-id or FASTLY_SERVICE_ID.`],
|
|
12
|
+
['token', `Use --fastly-api-token or FASTLY_API_TOKEN.`],
|
|
13
|
+
['package', `deploy deploys the package that it builds.`],
|
|
14
|
+
['dir', `deploy deploys the app of the project.`],
|
|
15
|
+
['env', `deploy uses the fastly.toml of the app.`],
|
|
16
|
+
]);
|
|
17
|
+
// The short forms of the refused options. In 'fastly compute deploy' and
|
|
18
|
+
// 'fastly compute publish', these are the only short options that take a
|
|
19
|
+
// value. The other short options (-i, -y, -d, -v, -q, -h) take no value, so a
|
|
20
|
+
// group such as -is is -i and then -s.
|
|
21
|
+
const REFUSED_SHORT = new Map([
|
|
22
|
+
['s', 'service-id'],
|
|
23
|
+
['t', 'token'],
|
|
24
|
+
['p', 'package'],
|
|
25
|
+
['C', 'dir'],
|
|
26
|
+
]);
|
|
27
|
+
// Returns the error message for the first refused option in args, or null if
|
|
28
|
+
// args has none. A value that starts with '-' (for example --service-name -s)
|
|
29
|
+
// looks like an option, so it can also be refused.
|
|
30
|
+
export function findRefusedFastlyOption(args) {
|
|
31
|
+
for (const arg of args) {
|
|
32
|
+
if (arg.startsWith('--')) {
|
|
33
|
+
const name = arg.slice(2).split('=')[0];
|
|
34
|
+
const reason = REFUSED.get(name);
|
|
35
|
+
if (reason != null) {
|
|
36
|
+
return `--${name} cannot be given to the Fastly CLI. ${reason}`;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
else if (arg.startsWith('-') && arg.length > 1) {
|
|
40
|
+
for (const letter of arg.slice(1)) {
|
|
41
|
+
if (letter === '=') {
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
const name = REFUSED_SHORT.get(letter);
|
|
45
|
+
if (name != null) {
|
|
46
|
+
return `-${letter} (--${name}) cannot be given to the Fastly CLI. ${REFUSED.get(name)}`;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package.d.ts","sourceRoot":"","sources":["../../../../src/cli/util/package.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC1C,CAAC;AAGF,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAGD,wBAAgB,kBAAkB,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAExD;AAGD,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAKD,wBAAgB,WAAW,CAAC,GAAG,GAAE,MAAsB,GAAG,OAAO,CAoBhE;AAWD,wBAAgB,UAAU,CACxB,OAAO,GAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAO,EAClC,OAAO,GAAE,MAAwB,EACjC,SAAS,GAAE,OAAuB,GACjC,MAAM,
|
|
1
|
+
{"version":3,"file":"package.d.ts","sourceRoot":"","sources":["../../../../src/cli/util/package.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC1C,CAAC;AAGF,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAGD,wBAAgB,kBAAkB,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAExD;AAGD,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAKD,wBAAgB,WAAW,CAAC,GAAG,GAAE,MAAsB,GAAG,OAAO,CAoBhE;AAWD,wBAAgB,UAAU,CACxB,OAAO,GAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAO,EAClC,OAAO,GAAE,MAAwB,EACjC,SAAS,GAAE,OAAuB,GACjC,MAAM,CAaR;AAED,wBAAgB,mCAAmC,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI,UA8ClF"}
|
|
@@ -45,19 +45,25 @@ export function isLocalCopy(dir = process.cwd()) {
|
|
|
45
45
|
// The npx command of this package, for the messages of the CLI.
|
|
46
46
|
// - If a plain npx runs this copy (it is installed in the project or the app),
|
|
47
47
|
// the command has no dist-tag. A dist-tag makes npx get the version of that
|
|
48
|
-
// tag from npm, which can be
|
|
48
|
+
// tag from npm, which can be a different version from the installed one.
|
|
49
49
|
// - Else, the version of a prerelease (for example 8.1.0-beta.1) gives the
|
|
50
50
|
// dist-tag of the prerelease (@beta), because npx without a dist-tag runs
|
|
51
51
|
// the latest stable version, which does not have the features of the
|
|
52
52
|
// prerelease. A stable version gives no dist-tag, or @latest with
|
|
53
53
|
// { latest: true } (the command that makes a new app).
|
|
54
54
|
export function cliCommand(options = {}, version = getOwnVersion(), localCopy = isLocalCopy()) {
|
|
55
|
+
const command = 'npx @fastly/compute-js-static-publish';
|
|
55
56
|
if (localCopy) {
|
|
56
|
-
return
|
|
57
|
+
return command;
|
|
57
58
|
}
|
|
58
59
|
const prerelease = /^\d+\.\d+\.\d+-([a-z][a-z0-9-]*)/.exec(version)?.[1];
|
|
59
|
-
|
|
60
|
-
|
|
60
|
+
if (prerelease != null) {
|
|
61
|
+
return `${command}@${prerelease}`;
|
|
62
|
+
}
|
|
63
|
+
if (options.latest) {
|
|
64
|
+
return `${command}@latest`;
|
|
65
|
+
}
|
|
66
|
+
return command;
|
|
61
67
|
}
|
|
62
68
|
export function findComputeJsStaticPublisherVersion(packageJson) {
|
|
63
69
|
// Get the current compute js static publisher version.
|