@fastly/compute-js-static-publish 8.0.0-beta.20 → 8.0.0-beta.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cli/cli/commands/manage/publish-content.js +2 -2
- package/build/cli/cli/util/purge.js +1 -1
- package/build/cli/cli/util/service-id.d.ts.map +1 -1
- package/build/cli/cli/util/service-id.js +7 -6
- package/build/server/server/publisher-server/index.d.ts +1 -1
- package/build/server/server/publisher-server/index.d.ts.map +1 -1
- package/build/server/server/publisher-server/index.js +11 -2
- package/package.json +1 -1
|
@@ -50,8 +50,8 @@ Optional:
|
|
|
50
50
|
|
|
51
51
|
--fastly-service-id=<id> Fastly Service ID to purge after publishing (not with --local).
|
|
52
52
|
If not set, the tool will check:
|
|
53
|
-
1.
|
|
54
|
-
2.
|
|
53
|
+
1. FASTLY_SERVICE_ID environment variable
|
|
54
|
+
2. service_id in fastly.toml
|
|
55
55
|
If none is found, the purge is skipped.
|
|
56
56
|
|
|
57
57
|
--purge-environment=<env> Environment to purge: production, staging, or a
|
|
@@ -43,7 +43,7 @@ export function loadPurgeTarget(params) {
|
|
|
43
43
|
fastlyTomlPath: path.resolve(params.computeAppDir, 'fastly.toml'),
|
|
44
44
|
});
|
|
45
45
|
if (serviceIdResult == null) {
|
|
46
|
-
console.log(`- Service ID not found (--fastly-service-id,
|
|
46
|
+
console.log(`- Service ID not found (--fastly-service-id, FASTLY_SERVICE_ID, or fastly.toml). Will skip purge step after publish.`);
|
|
47
47
|
return null;
|
|
48
48
|
}
|
|
49
49
|
console.log(`✔️ Service ID from ${serviceIdResult.source}: ${serviceIdResult.serviceId}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-id.d.ts","sourceRoot":"","sources":["../../../../src/cli/util/service-id.ts"],"names":[],"mappings":"AASA,MAAM,MAAM,mBAAmB,GAAG;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,WAAW,EAAE,OAAO,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;
|
|
1
|
+
{"version":3,"file":"service-id.d.ts","sourceRoot":"","sources":["../../../../src/cli/util/service-id.ts"],"names":[],"mappings":"AASA,MAAM,MAAM,mBAAmB,GAAG;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,WAAW,EAAE,OAAO,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAOF,wBAAgB,aAAa,CAAC,MAAM,EAAE,mBAAmB,GAAG,mBAAmB,GAAG,IAAI,CAmBrF"}
|
|
@@ -6,21 +6,22 @@ import fs from 'node:fs';
|
|
|
6
6
|
import { readServiceId } from './fastly-toml.js';
|
|
7
7
|
// Finds the Fastly Service ID to purge after publishing. Checks, in order:
|
|
8
8
|
// 1. The command line (--fastly-service-id)
|
|
9
|
-
// 2.
|
|
10
|
-
// 3.
|
|
9
|
+
// 2. The FASTLY_SERVICE_ID environment variable
|
|
10
|
+
// 3. service_id in fastly.toml
|
|
11
|
+
// This is the same order as the Fastly CLI's --service-id.
|
|
11
12
|
export function loadServiceId(params) {
|
|
12
13
|
if (typeof params.commandLine === 'string' && params.commandLine.trim() !== '') {
|
|
13
14
|
return { serviceId: params.commandLine.trim(), source: 'commandline' };
|
|
14
15
|
}
|
|
16
|
+
const envServiceId = process.env.FASTLY_SERVICE_ID?.trim();
|
|
17
|
+
if (envServiceId) {
|
|
18
|
+
return { serviceId: envServiceId, source: 'env' };
|
|
19
|
+
}
|
|
15
20
|
if (fs.existsSync(params.fastlyTomlPath)) {
|
|
16
21
|
const serviceId = readServiceId(params.fastlyTomlPath);
|
|
17
22
|
if (serviceId != null) {
|
|
18
23
|
return { serviceId, source: 'fastly.toml' };
|
|
19
24
|
}
|
|
20
25
|
}
|
|
21
|
-
const envServiceId = process.env.FASTLY_SERVICE_ID?.trim();
|
|
22
|
-
if (envServiceId) {
|
|
23
|
-
return { serviceId: envServiceId, source: 'env' };
|
|
24
|
-
}
|
|
25
26
|
return null;
|
|
26
27
|
}
|
|
@@ -27,7 +27,7 @@ export declare class PublisherServer {
|
|
|
27
27
|
responseCache: ResponseCacheOptions | null;
|
|
28
28
|
settingsCached: PublisherServerConfigNormalized | null | undefined;
|
|
29
29
|
assetEntryMapCache: AssetEntryMap | null | undefined;
|
|
30
|
-
setActiveCollectionName(collectionName: string): void;
|
|
30
|
+
setActiveCollectionName(collectionName: string | null): void;
|
|
31
31
|
setCollectionNameHeader(collectionHeader: string | null): void;
|
|
32
32
|
setServerTimingRequestHeader(requestHeader: string | null): void;
|
|
33
33
|
setResponseCache(options: ResponseCacheOptions | null): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/server/publisher-server/index.ts"],"names":[],"mappings":"AAUA,OAAO,EACL,KAAK,eAAe,EACrB,MAAM,0CAA0C,CAAC;AAClD,OAAO,EACL,KAAK,+BAA+B,EACrC,MAAM,gDAAgD,CAAC;AACxD,OAAO,EACL,KAAK,uBAAuB,EAC7B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,KAAK,oBAAoB,EAE1B,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,eAAe,EAErB,MAAM,gCAAgC,CAAC;AAGxC,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAEL,KAAK,oBAAoB,EAO1B,MAAM,qBAAqB,CAAC;AAE7B,KAAK,YAAY,GAAG;IAClB,YAAY,EAAE,YAAY,CAAC;CAC5B,GAAG,oBAAoB,CAAC;AAEzB,wBAAgB,kBAAkB,CAAC,eAAe,EAAE,OAAO,EAAE,IAAI,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PublisherServer(config.publishId, storeProvider, config.defaultCollectionName);
|
|
55
55
|
}
|
|
56
|
+
// null selects the default collection. A sandbox can be reused for more than
|
|
57
|
+
// one request, so call this for each request, also when no collection is
|
|
58
|
+
// selected. Otherwise, the collection of the previous request stays active.
|
|
56
59
|
setActiveCollectionName(collectionName) {
|
|
57
|
-
this.activeCollectionName = collectionName;
|
|
60
|
+
this.activeCollectionName = collectionName ?? this.defaultCollectionName;
|
|
58
61
|
this.settingsCached = undefined;
|
|
59
62
|
this.assetEntryMapCache = undefined;
|
|
60
63
|
}
|
|
@@ -76,14 +79,20 @@ export class PublisherServer {
|
|
|
76
79
|
}
|
|
77
80
|
// Start handling a new request. serveRequest() calls this. If you call
|
|
78
81
|
// getMatchingAsset() and serveAsset() directly, call this first.
|
|
82
|
+
// A sandbox can be reused for more than one request, so this also clears the
|
|
83
|
+
// settings and the index that a previous request read. Without this, a reused
|
|
84
|
+
// sandbox serves an old index after a publish, and serves an expired collection.
|
|
79
85
|
beginRequest(request) {
|
|
86
|
+
this.settingsCached = undefined;
|
|
87
|
+
this.assetEntryMapCache = undefined;
|
|
80
88
|
const header = this.serverTimingRequestHeader;
|
|
81
89
|
this.serverTiming = header != null && request.headers.has(header) ? new ServerTiming() : null;
|
|
82
90
|
}
|
|
83
91
|
timed(name, fn) {
|
|
84
92
|
return this.serverTiming != null ? this.serverTiming.measure(name, fn) : fn();
|
|
85
93
|
}
|
|
86
|
-
// Server config is obtained from storage, and cached
|
|
94
|
+
// Server config is obtained from storage, and cached until the next beginRequest()
|
|
95
|
+
// or setActiveCollectionName().
|
|
87
96
|
async getServerConfig() {
|
|
88
97
|
if (this.settingsCached !== undefined) {
|
|
89
98
|
return this.settingsCached;
|
package/package.json
CHANGED