@fastly/compute-js-static-publish 8.1.0-beta.1 → 8.1.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DOCUMENTATION.md +38 -36
- package/README.md +26 -3
- package/README.short.md +26 -3
- package/build/cli/cli/commands/manage/clean.d.ts.map +1 -1
- package/build/cli/cli/commands/manage/clean.js +2 -1
- package/build/cli/cli/commands/manage/collections/delete.d.ts.map +1 -1
- package/build/cli/cli/commands/manage/collections/delete.js +3 -2
- package/build/cli/cli/commands/manage/collections/index.d.ts.map +1 -1
- package/build/cli/cli/commands/manage/collections/index.js +4 -3
- package/build/cli/cli/commands/manage/collections/list.d.ts.map +1 -1
- package/build/cli/cli/commands/manage/collections/list.js +10 -11
- package/build/cli/cli/commands/manage/collections/promote.d.ts.map +1 -1
- package/build/cli/cli/commands/manage/collections/promote.js +2 -1
- package/build/cli/cli/commands/manage/collections/update-expiration.d.ts.map +1 -1
- package/build/cli/cli/commands/manage/collections/update-expiration.js +2 -1
- package/build/cli/cli/commands/manage/deploy.d.ts.map +1 -1
- package/build/cli/cli/commands/manage/deploy.js +48 -11
- package/build/cli/cli/commands/manage/dev.d.ts.map +1 -1
- package/build/cli/cli/commands/manage/dev.js +2 -1
- package/build/cli/cli/commands/manage/eject.d.ts.map +1 -1
- package/build/cli/cli/commands/manage/eject.js +24 -7
- package/build/cli/cli/commands/manage/index.d.ts.map +1 -1
- package/build/cli/cli/commands/manage/index.js +6 -5
- package/build/cli/cli/commands/manage/publish-content.d.ts.map +1 -1
- package/build/cli/cli/commands/manage/publish-content.js +9 -5
- package/build/cli/cli/commands/manage/status.d.ts.map +1 -1
- package/build/cli/cli/commands/manage/status.js +8 -2
- package/build/cli/cli/commands/manage/template/index.d.ts.map +1 -1
- package/build/cli/cli/commands/manage/template/index.js +2 -1
- package/build/cli/cli/commands/manage/template/init.js +3 -3
- package/build/cli/cli/commands/manage/upgrade.js +2 -2
- package/build/cli/cli/commands/run-dev-watch.d.ts +1 -0
- package/build/cli/cli/commands/run-dev-watch.d.ts.map +1 -1
- package/build/cli/cli/commands/run-dev-watch.js +45 -9
- package/build/cli/cli/commands/scaffold/generate-app.d.ts +8 -3
- package/build/cli/cli/commands/scaffold/generate-app.d.ts.map +1 -1
- package/build/cli/cli/commands/scaffold/generate-app.js +11 -1
- package/build/cli/cli/commands/scaffold/index.d.ts +3 -3
- package/build/cli/cli/commands/scaffold/index.d.ts.map +1 -1
- package/build/cli/cli/commands/scaffold/index.js +18 -21
- package/build/cli/cli/hono/build.d.ts.map +1 -1
- package/build/cli/cli/hono/build.js +2 -1
- package/build/cli/cli/managed/app.d.ts +1 -1
- package/build/cli/cli/managed/app.d.ts.map +1 -1
- package/build/cli/cli/managed/app.js +5 -3
- package/build/cli/cli/managed/command-helpers.js +2 -2
- package/build/cli/cli/managed/lockfile.js +1 -1
- package/build/cli/cli/managed/project-file.d.ts.map +1 -1
- package/build/cli/cli/managed/project-file.js +4 -3
- package/build/cli/cli/util/config.d.ts.map +1 -1
- package/build/cli/cli/util/config.js +9 -0
- package/build/cli/cli/util/global-options.js +1 -1
- package/build/cli/cli/util/package.d.ts +4 -0
- package/build/cli/cli/util/package.d.ts.map +1 -1
- package/build/cli/cli/util/package.js +43 -0
- package/build/cli/cli/util/s3.d.ts +10 -4
- package/build/cli/cli/util/s3.d.ts.map +1 -1
- package/build/cli/cli/util/s3.js +13 -35
- package/build/cli/models/config/publish-content-config.d.ts +1 -0
- package/build/cli/models/config/publish-content-config.d.ts.map +1 -1
- package/build/cli/models/server/index.d.ts +2 -0
- package/build/cli/models/server/index.d.ts.map +1 -1
- package/build/cli/models/server/index.js +13 -1
- package/build/server/models/config/publish-content-config.d.ts +1 -0
- package/build/server/models/config/publish-content-config.d.ts.map +1 -1
- package/build/server/models/server/index.d.ts +2 -0
- package/build/server/models/server/index.d.ts.map +1 -1
- package/build/server/models/server/index.js +13 -1
- package/package.json +1 -1
- package/resources/app/publish-content.config.js.njk +1 -0
- package/resources/templates/plain/src/index.js +12 -2
|
@@ -12,13 +12,13 @@ import * as fs from 'node:fs';
|
|
|
12
12
|
import { parseCommandLine } from '../../util/args.js';
|
|
13
13
|
import { fail, recordFailure } from '../../util/output.js';
|
|
14
14
|
import { rootRelative } from '../../util/files.js';
|
|
15
|
-
import { findComputeJsStaticPublisherVersion, getOwnVersion } from '../../util/package.js';
|
|
15
|
+
import { cliCommand, findComputeJsStaticPublisherVersion, getOwnVersion } from '../../util/package.js';
|
|
16
16
|
import { runTemplateInit } from '../manage/template/init.js';
|
|
17
17
|
import { templateHasInit } from '../../managed/template-init.js';
|
|
18
18
|
import { findHostnameForAwsS3RegionAndBucket } from '../../util/s3.js';
|
|
19
19
|
import { APP_TEMPLATE_NAMES, DEFAULT_APP_TEMPLATE_NAME, isAppTemplateName, loadAppTemplate, } from './app-template.js';
|
|
20
20
|
import { COLLECTION_SELECTION_FLAGS_HELP, collectionSelectionFromFlags } from '../../util/collection-selection-flags.js';
|
|
21
|
-
import { generateApp } from './generate-app.js';
|
|
21
|
+
import { DEFAULT_APP_INFO, generateApp } from './generate-app.js';
|
|
22
22
|
import { renderProjectFile } from '../../managed/project-file.js';
|
|
23
23
|
import { dotRelative } from '../../util/files.js';
|
|
24
24
|
import { checkStaticPublisherWorkingDir } from '../../../models/config/static-publish-rc.js';
|
|
@@ -28,7 +28,7 @@ function help() {
|
|
|
28
28
|
console.log(`\
|
|
29
29
|
|
|
30
30
|
Usage:
|
|
31
|
-
|
|
31
|
+
${cliCommand({ latest: true })} [options]
|
|
32
32
|
|
|
33
33
|
Description:
|
|
34
34
|
Scaffold a new Compute app configured for static publishing.
|
|
@@ -96,9 +96,9 @@ const defaultOptions = {
|
|
|
96
96
|
notFoundPage: undefined,
|
|
97
97
|
autoIndex: ['index.html', 'index.htm'],
|
|
98
98
|
autoExt: ['.html', '.htm'],
|
|
99
|
-
author:
|
|
100
|
-
name:
|
|
101
|
-
description:
|
|
99
|
+
author: DEFAULT_APP_INFO.author,
|
|
100
|
+
name: DEFAULT_APP_INFO.name,
|
|
101
|
+
description: DEFAULT_APP_INFO.description,
|
|
102
102
|
serviceId: undefined,
|
|
103
103
|
publishId: undefined,
|
|
104
104
|
defaultCollectionName: undefined,
|
|
@@ -115,13 +115,14 @@ function buildOptions(packageJson, commandLineOptions) {
|
|
|
115
115
|
// 2. package.json
|
|
116
116
|
// 3. command-line args
|
|
117
117
|
const options = structuredClone(defaultOptions);
|
|
118
|
-
|
|
118
|
+
// Only string values: in a package.json, author can also be an object.
|
|
119
|
+
if (typeof packageJson?.name === 'string') {
|
|
119
120
|
options.name = packageJson.name;
|
|
120
121
|
}
|
|
121
|
-
if (packageJson?.author
|
|
122
|
+
if (typeof packageJson?.author === 'string') {
|
|
122
123
|
options.author = packageJson.author;
|
|
123
124
|
}
|
|
124
|
-
if (packageJson?.description
|
|
125
|
+
if (typeof packageJson?.description === 'string') {
|
|
125
126
|
options.description = packageJson.description;
|
|
126
127
|
}
|
|
127
128
|
{
|
|
@@ -655,18 +656,15 @@ export async function action(actionArgs) {
|
|
|
655
656
|
}
|
|
656
657
|
let s3Endpoint = options.s3Endpoint;
|
|
657
658
|
if (s3Endpoint == null || s3Endpoint === '') {
|
|
658
|
-
//
|
|
659
|
-
//
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
if (s3Endpoint) {
|
|
664
|
-
console.log('✅ S3 endpoint resolved:', s3Endpoint);
|
|
665
|
-
}
|
|
666
|
-
else {
|
|
667
|
-
fail('failed', `Unable to resolve S3 endpoint from region '${s3Region}' and bucket '${s3Bucket}'.`);
|
|
659
|
+
// Without an endpoint, the bucket is on AWS. The app needs its host name
|
|
660
|
+
// for the backend in the Compute service.
|
|
661
|
+
const hostname = findHostnameForAwsS3RegionAndBucket(s3Region, s3Bucket);
|
|
662
|
+
if (hostname == null) {
|
|
663
|
+
fail('usage', `The bucket name '${s3Bucket}' has a dot, so it cannot be a host name of AWS S3 under HTTPS. Set --s3-endpoint, for example --s3-endpoint=https://s3.${s3Region}.amazonaws.com. Then the bucket is in the path of the URL.`);
|
|
668
664
|
return;
|
|
669
665
|
}
|
|
666
|
+
s3Endpoint = hostname;
|
|
667
|
+
console.log('✅ S3 endpoint resolved:', s3Endpoint);
|
|
670
668
|
s3EndpointUrl = new URL(`https://${s3Endpoint}/`);
|
|
671
669
|
s3EndpointGenerated = true;
|
|
672
670
|
}
|
|
@@ -776,7 +774,6 @@ export async function action(actionArgs) {
|
|
|
776
774
|
}
|
|
777
775
|
console.log("Initializing Compute Application in " + computeJsDir + "...");
|
|
778
776
|
fs.mkdirSync(computeJsDir);
|
|
779
|
-
fs.mkdirSync(path.resolve(computeJsDir, './src'));
|
|
780
777
|
const resourceFiles = generateApp(appConfig);
|
|
781
778
|
// Write out the files
|
|
782
779
|
for (const [filename, content] of Object.entries(resourceFiles)) {
|
|
@@ -910,6 +907,6 @@ Commit ${PROJECT_FILE_NAME}. Do not commit .static-publish/.
|
|
|
910
907
|
|
|
911
908
|
To publish your content from this directory:
|
|
912
909
|
|
|
913
|
-
|
|
910
|
+
${cliCommand()} publish-content --local
|
|
914
911
|
`);
|
|
915
912
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../../src/cli/hono/build.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../../src/cli/hono/build.ts"],"names":[],"mappings":"AAmBA,eAAO,MAAM,wBAAwB,qCAAqC,CAAC;AAI3E,eAAO,MAAM,2BAA2B,sBAAsB,CAAC;AAK/D,MAAM,MAAM,mBAAmB,GAAG;IAGhC,IAAI,EAAE,MAAM,CAAC;IAEb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAMF,wBAAgB,wBAAwB,CAAC,aAAa,EAAE,MAAM,GAAG,mBAAmB,EAAE,CAsBrF;AAUD,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,MAAM,GAAG,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url';
|
|
13
13
|
import { compareVersions } from '../managed/version-check.js';
|
|
14
|
+
import { cliCommand } from '../util/package.js';
|
|
14
15
|
// The file that the build writes into the app, and that src/index.ts imports.
|
|
15
16
|
export const HONO_EXTENSIONS_MANIFEST = 'src/hono-extensions.generated.js';
|
|
16
17
|
// The extensions folder when build.hono.extensionsDir is not set, relative to
|
|
@@ -155,7 +156,7 @@ export function checkProvidedVersions(appDir, extensionsDir) {
|
|
|
155
156
|
const version = readJson(installed).version;
|
|
156
157
|
if (satisfiesRange(version, range) === false) {
|
|
157
158
|
warnings.push(`hono-extensions/package.json expects ${name} ${range}, but the app provides ${version}. ` +
|
|
158
|
-
`The build uses the app's ${name}. Run:
|
|
159
|
+
`The build uses the app's ${name}. Run: ${cliCommand()} template init`);
|
|
159
160
|
}
|
|
160
161
|
}
|
|
161
162
|
return warnings;
|
|
@@ -11,7 +11,7 @@ export declare function managedAppState(projectDir: string, project: StaticPubli
|
|
|
11
11
|
files: Record<string, string>;
|
|
12
12
|
fingerprint: string;
|
|
13
13
|
}>;
|
|
14
|
-
export declare function prepareManagedApp(projectDir: string, project: StaticPublishProjectNormalized): Promise<{
|
|
14
|
+
export declare function prepareManagedApp(projectDir: string, project: StaticPublishProjectNormalized, state?: Awaited<ReturnType<typeof managedAppState>>): Promise<{
|
|
15
15
|
appDir: string;
|
|
16
16
|
appConfig: AppConfig;
|
|
17
17
|
files: Record<string, string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../../../src/cli/managed/app.ts"],"names":[],"mappings":"AAUA,OAAO,EAAiC,KAAK,8BAA8B,EAAE,MAAM,mBAAmB,CAAC;AAGvG,OAAO,EAAE,KAAK,SAAS,EAAe,MAAM,sCAAsC,CAAC;AAYnF,wBAAsB,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,8BAA8B,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,C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AM,EAAE,OAAO,EAAE,8BAA8B;;;;;GAqBhG;AAMD,wBAAsB,iBAAiB,CACrC,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,8BAA8B,EACvC,KAAK,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC;;;;;;GAUpD"}
|
|
@@ -149,9 +149,11 @@ export async function managedAppState(projectDir, project) {
|
|
|
149
149
|
return { appDir: appConfig.appDir, appConfig, files, fingerprint };
|
|
150
150
|
}
|
|
151
151
|
// Generate the app of a managed project in .static-publish/app, and install
|
|
152
|
-
// its dependencies if necessary.
|
|
153
|
-
|
|
154
|
-
|
|
152
|
+
// its dependencies if necessary. A command that already has the result of
|
|
153
|
+
// managedAppState() passes it, so that it is not computed again (in S3 mode
|
|
154
|
+
// without s3.endpoint, that is a network lookup).
|
|
155
|
+
export async function prepareManagedApp(projectDir, project, state) {
|
|
156
|
+
const { appConfig, files, fingerprint } = state ?? await managedAppState(projectDir, project);
|
|
155
157
|
console.log(`🛠️ Generating the app in ${MANAGED_APP_DIR}...`);
|
|
156
158
|
const written = writeManagedAppFiles(appConfig.appDir, files);
|
|
157
159
|
if (written.length > 0) {
|
|
@@ -6,7 +6,7 @@ import fs from 'node:fs';
|
|
|
6
6
|
import path from 'node:path';
|
|
7
7
|
import { PROJECT_FILE_NAME } from '../../models/config/static-publish-project.js';
|
|
8
8
|
import { LoadConfigError, detectProjectMode, loadProjectFile } from '../util/config.js';
|
|
9
|
-
import { getOwnVersion } from '../util/package.js';
|
|
9
|
+
import { cliCommand, getOwnVersion } from '../util/package.js';
|
|
10
10
|
import { DEFAULT_APP_TEMPLATE_NAME } from '../commands/scaffold/app-template.js';
|
|
11
11
|
import { DEFAULT_HONO_EXTENSIONS_DIR } from '../hono/build.js';
|
|
12
12
|
import { writeBackStaticPublishVersion } from './project-edit.js';
|
|
@@ -43,7 +43,7 @@ export function showTemplateFolderHint(project) {
|
|
|
43
43
|
}
|
|
44
44
|
const extensionsDir = project.rc.build?.hono?.extensionsDir ?? DEFAULT_HONO_EXTENSIONS_DIR;
|
|
45
45
|
if (!fs.existsSync(path.resolve(extensionsDir))) {
|
|
46
|
-
console.log(`💡 No ${extensionsDir} folder. To add your own Hono middleware and routes, run:
|
|
46
|
+
console.log(`💡 No ${extensionsDir} folder. To add your own Hono middleware and routes, run: ${cliCommand()} template init`);
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
// Check managed.staticPublishVersion against the running CLI. With
|
|
@@ -43,7 +43,7 @@ export function buildManagedLockfile(templateLock, options) {
|
|
|
43
43
|
root.name = options.appName;
|
|
44
44
|
}
|
|
45
45
|
root.version = options.appVersion;
|
|
46
|
-
root.
|
|
46
|
+
root.dependencies = { ...root.dependencies, [THIS_PACKAGE]: spec };
|
|
47
47
|
lock.packages[''] = root;
|
|
48
48
|
lock.packages[`node_modules/${THIS_PACKAGE}`] = {
|
|
49
49
|
resolved: linkPath,
|
|
@@ -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,
|
|
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,CA6DX"}
|
|
@@ -6,6 +6,7 @@ import * as path from 'node:path';
|
|
|
6
6
|
import { isS3StorageConfigRc } from '../../models/config/static-publish-rc.js';
|
|
7
7
|
import { DEFAULT_HONO_EXTENSIONS_DIR } from '../hono/build.js';
|
|
8
8
|
import { getKvStoreConfigFromRc } from '../../models/config/kv-store-config.js';
|
|
9
|
+
import { DEFAULT_APP_INFO } from '../commands/scaffold/generate-app.js';
|
|
9
10
|
import { renderAppResource } from '../commands/scaffold/render.js';
|
|
10
11
|
import { dotRelative } from '../util/files.js';
|
|
11
12
|
// The line in the managed section that deploy replaces with the service ID
|
|
@@ -84,9 +85,9 @@ export function appConfigFromProject(rc, publishContent, managed, options) {
|
|
|
84
85
|
}
|
|
85
86
|
return {
|
|
86
87
|
appDir,
|
|
87
|
-
name: managed.name,
|
|
88
|
-
author: managed.authors?.[0],
|
|
89
|
-
description: managed.description,
|
|
88
|
+
name: managed.name ?? DEFAULT_APP_INFO.name,
|
|
89
|
+
author: managed.authors?.[0] ?? DEFAULT_APP_INFO.author,
|
|
90
|
+
description: managed.description ?? DEFAULT_APP_INFO.description,
|
|
90
91
|
serviceId: managed.serviceId,
|
|
91
92
|
storage,
|
|
92
93
|
publishId: rc.publishId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../../src/cli/util/config.ts"],"names":[],"mappings":"AAWA,OAAO,EACL,KAAK,eAAe,EAKrB,MAAM,0CAA0C,CAAC;AAClD,OAAO,EACL,KAAK,2BAA2B,EAIjC,MAAM,+CAA+C,CAAC;AAWvD,OAAO,EACL,KAAK,8BAA8B,EAEpC,MAAM,+CAA+C,CAAC;AAOvD,OAAO,EAAE,KAAK,+BAA+B,EAAE,MAAM,gDAAgD,CAAC;AAEtG,qBAAa,eAAgB,SAAQ,KAAK;IACxC,MAAM,EAAE,MAAM,EAAE,CAAC;IAEjB,YAAY,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,EAGnD;CACF;AAGD,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,SAAS,GAAG,UAAU,GAAG,UAAU,CAAC;AAE1E,wBAAgB,iBAAiB,CAAC,GAAG,GAAE,MAAY,GAAG,WAAW,CAOhE;AAKD,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAGD,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED,MAAM,MAAM,8BAA8B,GAAG;IAC3C,EAAE,EAAE,eAAe,CAAC;IAEpB,cAAc,EAAE,OAAO,CAAC;IACxB,OAAO,EAAE,2BAA2B,CAAC;CACtC,CAAC;AAsBF,eAAO,MAAM,uBAAuB,yEAoBlC,CAAC;AAGH,wBAAsB,eAAe,IAAI,OAAO,CAAC,8BAA8B,CAAC,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../../src/cli/util/config.ts"],"names":[],"mappings":"AAWA,OAAO,EACL,KAAK,eAAe,EAKrB,MAAM,0CAA0C,CAAC;AACl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Raw) || configRaw.publishContent == null || typeof configRaw.publishContent !== 'object') {
|
|
90
90
|
errors.push('publishContent must be specified.');
|
|
91
91
|
}
|
|
92
|
+
else {
|
|
93
|
+
// Checked here, so that each command shows the errors in the same way.
|
|
94
|
+
const publishContentErrors = [];
|
|
95
|
+
normalizePublishContentConfig(configRaw.publishContent, publishContentErrors);
|
|
96
|
+
errors.push(...publishContentErrors.map(error => `publishContent: ${error}`));
|
|
97
|
+
}
|
|
92
98
|
let managed = {};
|
|
93
99
|
if ('managed' in configRaw && configRaw.managed != null) {
|
|
94
100
|
managed = normalizeProjectManaged(configRaw.managed, errors);
|
|
@@ -407,10 +413,12 @@ export const normalizePublishContentConfig = buildNormalizeFunctionForObject((co
|
|
|
407
413
|
else {
|
|
408
414
|
errors.push('assetInclusionTest, if specified, must be null or a function.');
|
|
409
415
|
}
|
|
416
|
+
let hiddenItemsAsWritten = [];
|
|
410
417
|
if (!isSpecified(config, 'hiddenItems')) {
|
|
411
418
|
hiddenItems = [];
|
|
412
419
|
}
|
|
413
420
|
else {
|
|
421
|
+
hiddenItemsAsWritten = (Array.isArray(hiddenItems) ? hiddenItems : [hiddenItems]).filter((x) => typeof x === 'string');
|
|
414
422
|
hiddenItems = normalizeItemList('hiddenItems', hiddenItems, errors);
|
|
415
423
|
}
|
|
416
424
|
if (!isSpecified(config, 'contentCompression')) {
|
|
@@ -479,6 +487,7 @@ export const normalizePublishContentConfig = buildNormalizeFunctionForObject((co
|
|
|
479
487
|
includeWellKnown,
|
|
480
488
|
assetInclusionTest,
|
|
481
489
|
hiddenItems,
|
|
490
|
+
hiddenItemsAsWritten,
|
|
482
491
|
contentCompression,
|
|
483
492
|
brotliQuality,
|
|
484
493
|
contentTypes,
|
|
@@ -22,7 +22,7 @@ export function parseGlobalOptions(args, env = {}) {
|
|
|
22
22
|
if (arg.startsWith(`${option}=`)) {
|
|
23
23
|
secrets.push(arg.slice(option.length + 1));
|
|
24
24
|
}
|
|
25
|
-
else if (arg === option && args[i + 1] != null) {
|
|
25
|
+
else if (arg === option && args[i + 1] != null && !args[i + 1].startsWith('-')) {
|
|
26
26
|
secrets.push(args[i + 1]);
|
|
27
27
|
}
|
|
28
28
|
}
|
|
@@ -8,5 +8,9 @@ export type PackageJson = {
|
|
|
8
8
|
export declare function getOwnPackageDir(): string;
|
|
9
9
|
export declare function readOwnPackageJson(): Record<string, any>;
|
|
10
10
|
export declare function getOwnVersion(): string;
|
|
11
|
+
export declare function isLocalCopy(dir?: string): boolean;
|
|
12
|
+
export declare function cliCommand(options?: {
|
|
13
|
+
latest?: boolean;
|
|
14
|
+
}, version?: string, localCopy?: boolean): string;
|
|
11
15
|
export declare function findComputeJsStaticPublisherVersion(packageJson: PackageJson | null): string;
|
|
12
16
|
//# sourceMappingURL=package.d.ts.map
|
|
@@ -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;AAED,wBAAgB,mCAAmC,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI,UA8ClF"}
|
|
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,CAOR;AAED,wBAAgB,mCAAmC,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI,UA8ClF"}
|
|
@@ -16,6 +16,49 @@ export function readOwnPackageJson() {
|
|
|
16
16
|
export function getOwnVersion() {
|
|
17
17
|
return readOwnPackageJson().version;
|
|
18
18
|
}
|
|
19
|
+
// True if this copy of the package is the one that a plain `npx
|
|
20
|
+
// @fastly/compute-js-static-publish` runs in the directory: the nearest
|
|
21
|
+
// node_modules/@fastly/compute-js-static-publish, from the directory upwards.
|
|
22
|
+
export function isLocalCopy(dir = process.cwd()) {
|
|
23
|
+
let ownDir;
|
|
24
|
+
try {
|
|
25
|
+
ownDir = fs.realpathSync(getOwnPackageDir());
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
for (let current = path.resolve(dir);; current = path.dirname(current)) {
|
|
31
|
+
const candidate = path.join(current, 'node_modules', '@fastly', 'compute-js-static-publish');
|
|
32
|
+
if (fs.existsSync(candidate)) {
|
|
33
|
+
try {
|
|
34
|
+
return fs.realpathSync(candidate) === ownDir;
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (path.dirname(current) === current) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
// The npx command of this package, for the messages of the CLI.
|
|
46
|
+
// - If a plain npx runs this copy (it is installed in the project or the app),
|
|
47
|
+
// the command has no dist-tag. A dist-tag makes npx get the version of that
|
|
48
|
+
// tag from npm, which can be another version than the installed one.
|
|
49
|
+
// - Else, the version of a prerelease (for example 8.1.0-beta.1) gives the
|
|
50
|
+
// dist-tag of the prerelease (@beta), because npx without a dist-tag runs
|
|
51
|
+
// the latest stable version, which does not have the features of the
|
|
52
|
+
// prerelease. A stable version gives no dist-tag, or @latest with
|
|
53
|
+
// { latest: true } (the command that makes a new app).
|
|
54
|
+
export function cliCommand(options = {}, version = getOwnVersion(), localCopy = isLocalCopy()) {
|
|
55
|
+
if (localCopy) {
|
|
56
|
+
return 'npx @fastly/compute-js-static-publish';
|
|
57
|
+
}
|
|
58
|
+
const prerelease = /^\d+\.\d+\.\d+-([a-z][a-z0-9-]*)/.exec(version)?.[1];
|
|
59
|
+
const distTag = prerelease ?? (options.latest ? 'latest' : undefined);
|
|
60
|
+
return `npx @fastly/compute-js-static-publish${distTag != null ? `@${distTag}` : ''}`;
|
|
61
|
+
}
|
|
19
62
|
export function findComputeJsStaticPublisherVersion(packageJson) {
|
|
20
63
|
// Get the current compute js static publisher version.
|
|
21
64
|
let computeJsStaticPublisherVersion = null;
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* The AWS S3 host name of a bucket, for the backend of the app:
|
|
3
|
+
* <bucket>.s3.<region>.amazonaws.com. The server uses the same host name for a
|
|
4
|
+
* bucket without an endpoint (see objectUrl() in
|
|
5
|
+
* src/server/storage/s3-storage-provider.ts). It needs no credentials and no
|
|
6
|
+
* network.
|
|
7
|
+
*
|
|
8
|
+
* Returns null for a bucket name with a dot: under HTTPS, such a name does not
|
|
9
|
+
* match the certificate of *.s3.<region>.amazonaws.com. Such a bucket needs
|
|
10
|
+
* an endpoint, so that the bucket is in the path of the URL.
|
|
5
11
|
*/
|
|
6
|
-
export declare function findHostnameForAwsS3RegionAndBucket(region: string, bucket: string):
|
|
12
|
+
export declare function findHostnameForAwsS3RegionAndBucket(region: string, bucket: string): string | null;
|
|
7
13
|
//# sourceMappingURL=s3.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"s3.d.ts","sourceRoot":"","sources":["../../../../src/cli/util/s3.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"s3.d.ts","sourceRoot":"","sources":["../../../../src/cli/util/s3.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;GAUG;AACH,wBAAgB,mCAAmC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAKjG"}
|
package/build/cli/cli/util/s3.js
CHANGED
|
@@ -2,42 +2,20 @@
|
|
|
2
2
|
* Copyright Fastly, Inc.
|
|
3
3
|
* Licensed under the MIT license. See LICENSE file for details.
|
|
4
4
|
*/
|
|
5
|
-
import { S3Client, HeadObjectCommand } from '@aws-sdk/client-s3';
|
|
6
|
-
const DUMMY_KEY = 'dummy.dat'; // placeholder, never sent over the network
|
|
7
5
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
6
|
+
* The AWS S3 host name of a bucket, for the backend of the app:
|
|
7
|
+
* <bucket>.s3.<region>.amazonaws.com. The server uses the same host name for a
|
|
8
|
+
* bucket without an endpoint (see objectUrl() in
|
|
9
|
+
* src/server/storage/s3-storage-provider.ts). It needs no credentials and no
|
|
10
|
+
* network.
|
|
11
|
+
*
|
|
12
|
+
* Returns null for a bucket name with a dot: under HTTPS, such a name does not
|
|
13
|
+
* match the certificate of *.s3.<region>.amazonaws.com. Such a bucket needs
|
|
14
|
+
* an endpoint, so that the bucket is in the path of the URL.
|
|
11
15
|
*/
|
|
12
|
-
export
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const captureHostname = (_next) => async (args) => {
|
|
16
|
-
if (typeof args.request === 'object' &&
|
|
17
|
-
args.request != null &&
|
|
18
|
-
'hostname' in args.request &&
|
|
19
|
-
typeof args.request['hostname'] === 'string') {
|
|
20
|
-
hostname = args.request['hostname'];
|
|
21
|
-
}
|
|
22
|
-
const err = new Error('SHORT_CIRCUIT');
|
|
23
|
-
err.name = 'SHORT_CIRCUIT';
|
|
24
|
-
throw err; // short-circuit before auth/send
|
|
25
|
-
};
|
|
26
|
-
client.middlewareStack.add(captureHostname, {
|
|
27
|
-
name: 'captureS3Hostname',
|
|
28
|
-
step: 'build',
|
|
29
|
-
priority: 'high', // run early in build
|
|
30
|
-
});
|
|
31
|
-
try {
|
|
32
|
-
await client.send(new HeadObjectCommand({ Bucket: bucket, Key: DUMMY_KEY }));
|
|
16
|
+
export function findHostnameForAwsS3RegionAndBucket(region, bucket) {
|
|
17
|
+
if (bucket.includes('.')) {
|
|
18
|
+
return null;
|
|
33
19
|
}
|
|
34
|
-
|
|
35
|
-
if (typeof e !== 'object' ||
|
|
36
|
-
e == null ||
|
|
37
|
-
!('name' in e) ||
|
|
38
|
-
e.name !== 'SHORT_CIRCUIT') {
|
|
39
|
-
throw e;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return hostname;
|
|
20
|
+
return `${bucket}.s3.${region}.amazonaws.com`;
|
|
43
21
|
}
|
|
@@ -39,6 +39,7 @@ export type PublishContentConfigNormalized = {
|
|
|
39
39
|
includeWellKnown: boolean;
|
|
40
40
|
assetInclusionTest: AssetInclusionTest | null;
|
|
41
41
|
hiddenItems: string[];
|
|
42
|
+
hiddenItemsAsWritten: string[];
|
|
42
43
|
contentCompression: ContentCompressionTypes[];
|
|
43
44
|
brotliQuality: number | undefined;
|
|
44
45
|
contentTypes: ContentTypeDef[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publish-content-config.d.ts","sourceRoot":"","sources":["../../../../src/models/config/publish-content-config.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,+BAA+B,EACrC,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,KAAK,uBAAuB,EAC7B,MAAM,yBAAyB,CAAC;AAEjC,MAAM,MAAM,eAAe,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;AAGxD,MAAM,MAAM,cAAc,GAAG;IAE3B,IAAI,EAAE,MAAM,GAAG,eAAe,CAAC;IAG/B,WAAW,EAAE,MAAM,CAAC;IAIpB,IAAI,CAAC,EAAE,OAAO,CAAC;IAIf,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,OAAO,CAAC;IACd,gBAAgB,EAAE,OAAO,CAAC;CAC3B,CAAC;AAEF,MAAM,WAAW,cAAc;IAC7B,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;CAC7B;AAID,MAAM,MAAM,wBAAwB,GAAG,OAAO,GAAG;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAEtE,MAAM,MAAM,kBAAkB,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,KAAK,wBAAwB,CAAC;AAEtG,MAAM,MAAM,oBAAoB,GAAG;IAEjC,OAAO,EAAE,MAAM,CAAC;IAMhB,WAAW,CAAC,EAAE,CAAC,MAAM,GAAG,cAAc,CAAC,EAAE,GAAG,MAAM,GAAG,cAAc,GAAG,IAAI,CAAC;IAI3E,eAAe,CAAC,EAAE,OAAO,CAAC;I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AI,CAAC;IAC9C,WAAW,EAAE,MAAM,EAAE,CAAC;IAGtB,oBAAoB,EAAE,MAAM,EAAE,CAAC;IAC/B,kBAAkB,EAAE,uBAAuB,EAAE,CAAC;IAC9C,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,YAAY,EAAE,cAAc,EAAE,CAAC;IAC/B,MAAM,EAAE,+BAA+B,GAAG,IAAI,CAAC;CAChD,CAAC"}
|
|
@@ -2,6 +2,8 @@ export type IndexMetadata = {
|
|
|
2
2
|
publishedTime?: number;
|
|
3
3
|
expirationTime?: number;
|
|
4
4
|
requires?: string[];
|
|
5
|
+
fileCount?: number;
|
|
6
|
+
hiddenFileCount?: number;
|
|
5
7
|
otherFields?: Record<string, string>;
|
|
6
8
|
};
|
|
7
9
|
export declare const SUPPORTED_INDEX_FEATURES: readonly string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/models/server/index.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,aAAa,GAAG;IAC1B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;IAIxB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IAGpB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACtC,CAAC;AAMF,eAAO,MAAM,wBAAwB,EAAE,SAAS,MAAM,EAGrD,CAAC;AAIF,wBAAgB,mBAAmB,CAAC,aAAa,EAAE,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/models/server/index.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,aAAa,GAAG;IAC1B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;IAIxB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IAGpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;IAGzB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACtC,CAAC;AAMF,eAAO,MAAM,wBAAwB,EAAE,SAAS,MAAM,EAGrD,CAAC;AAIF,wBAAgB,mBAAmB,CAAC,aAAa,EAAE,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA4BxF;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,GAAG,aAAa,GAAG,IAAI,CAkCjG;AAGD,wBAAgB,2BAA2B,CACzC,aAAa,EAAE,aAAa,EAC5B,iBAAiB,GAAE,SAAS,MAAM,EAA6B,GAC9D,MAAM,EAAE,CAEV"}
|
|
@@ -12,7 +12,7 @@ export const SUPPORTED_INDEX_FEATURES = [
|
|
|
12
12
|
// Hidden files: index keys that start with 'hidden:'.
|
|
13
13
|
HIDDEN_INDEX_FEATURE,
|
|
14
14
|
];
|
|
15
|
-
const KNOWN_FIELDS = ['publishedTime', 'expirationTime', 'requires'];
|
|
15
|
+
const KNOWN_FIELDS = ['publishedTime', 'expirationTime', 'requires', 'fileCount', 'hiddenFileCount'];
|
|
16
16
|
export function encodeIndexMetadata(indexMetadata) {
|
|
17
17
|
const result = { ...indexMetadata.otherFields };
|
|
18
18
|
if (indexMetadata.publishedTime != null && !isNaN(indexMetadata.publishedTime)) {
|
|
@@ -29,6 +29,12 @@ export function encodeIndexMetadata(indexMetadata) {
|
|
|
29
29
|
}
|
|
30
30
|
result['requires'] = indexMetadata.requires.join(',');
|
|
31
31
|
}
|
|
32
|
+
for (const field of ['fileCount', 'hiddenFileCount']) {
|
|
33
|
+
const value = indexMetadata[field];
|
|
34
|
+
if (value != null && Number.isInteger(value) && value >= 0) {
|
|
35
|
+
result[field] = String(value);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
32
38
|
return result;
|
|
33
39
|
}
|
|
34
40
|
export function decodeIndexMetadata(obj) {
|
|
@@ -50,10 +56,16 @@ export function decodeIndexMetadata(obj) {
|
|
|
50
56
|
otherFields[key] = String(value);
|
|
51
57
|
}
|
|
52
58
|
}
|
|
59
|
+
const count = (field) => {
|
|
60
|
+
const value = getMetadataFieldValue(obj, field);
|
|
61
|
+
return value != null && /^\d+$/.test(String(value)) ? Number(value) : undefined;
|
|
62
|
+
};
|
|
53
63
|
return {
|
|
54
64
|
publishedTime: !isNaN(publishedTime) ? publishedTime : undefined,
|
|
55
65
|
expirationTime: !isNaN(expirationTime) ? expirationTime : undefined,
|
|
56
66
|
requires: requires.length > 0 ? requires : undefined,
|
|
67
|
+
fileCount: count('fileCount'),
|
|
68
|
+
hiddenFileCount: count('hiddenFileCount'),
|
|
57
69
|
otherFields,
|
|
58
70
|
};
|
|
59
71
|
}
|
|
@@ -39,6 +39,7 @@ export type PublishContentConfigNormalized = {
|
|
|
39
39
|
includeWellKnown: boolean;
|
|
40
40
|
assetInclusionTest: AssetInclusionTest | null;
|
|
41
41
|
hiddenItems: string[];
|
|
42
|
+
hiddenItemsAsWritten: string[];
|
|
42
43
|
contentCompression: ContentCompressionTypes[];
|
|
43
44
|
brotliQuality: number | undefined;
|
|
44
45
|
contentTypes: ContentTypeDef[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publish-content-config.d.ts","sourceRoot":"","sources":["../../../../src/models/config/publish-content-config.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,+BAA+B,EACrC,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,KAAK,uBAAuB,EAC7B,MAAM,yBAAyB,CAAC;AAEjC,MAAM,MAAM,eAAe,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;AAGxD,MAAM,MAAM,cAAc,GAAG;IAE3B,IAAI,EAAE,MAAM,GAAG,eAAe,CAAC;I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AM,GAAG,cAAc,CAAC,EAAE,GAAG,MAAM,GAAG,cAAc,GAAG,IAAI,CAAC;IAI3E,eAAe,CAAC,EAAE,OAAO,CAAC;IAI1B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAK3B,kBAAkB,CAAC,EAAE,kBAAkB,GAAG,IAAI,CAAC;IAQ/C,WAAW,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,KAAK,GAAG,IAAI,CAAC;IAI/C,yBAAyB,CAAC,EAAE,kBAAkB,GAAG,IAAI,CAAC;IAItD,kBAAkB,CAAC,EAAE,CAAC,IAAI,GAAG,MAAM,CAAC,EAAE,CAAC;IAIvC,aAAa,CAAC,EAAE,MAAM,CAAC;IAGvB,YAAY,CAAC,EAAE,cAAc,EAAE,CAAC;IAGhC,MAAM,CAAC,EAAE,qBAAqB,GAAG,IAAI,CAAC;CACvC,CAAC;AAEF,MAAM,MAAM,8BAA8B,GAAG;IAC3C,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,cAAc,EAAE,CAAC;IAC9B,eAAe,EAAE,OAAO,CAAC;IACzB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,kBAAkB,EAAE,kBAAkB,GAAG,IAAI,CAAC;IAC9C,WAAW,EAAE,MAAM,EAAE,CAAC;IAGtB,oBAAoB,EAAE,MAAM,EAAE,CAAC;IAC/B,kBAAkB,EAAE,uBAAuB,EAAE,CAAC;IAC9C,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,YAAY,EAAE,cAAc,EAAE,CAAC;IAC/B,MAAM,EAAE,+BAA+B,GAAG,IAAI,CAAC;CAChD,CAAC"}
|
|
@@ -2,6 +2,8 @@ export type IndexMetadata = {
|
|
|
2
2
|
publishedTime?: number;
|
|
3
3
|
expirationTime?: number;
|
|
4
4
|
requires?: string[];
|
|
5
|
+
fileCount?: number;
|
|
6
|
+
hiddenFileCount?: number;
|
|
5
7
|
otherFields?: Record<string, string>;
|
|
6
8
|
};
|
|
7
9
|
export declare const SUPPORTED_INDEX_FEATURES: readonly string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/models/server/index.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,aAAa,GAAG;IAC1B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;IAIxB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IAGpB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACtC,CAAC;AAMF,eAAO,MAAM,wBAAwB,EAAE,SAAS,MAAM,EAGrD,CAAC;AAIF,wBAAgB,mBAAmB,CAAC,aAAa,EAAE,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/models/server/index.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,aAAa,GAAG;IAC1B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;IAIxB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IAGpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;IAGzB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACtC,CAAC;AAMF,eAAO,MAAM,wBAAwB,EAAE,SAAS,MAAM,EAGrD,CAAC;AAIF,wBAAgB,mBAAmB,CAAC,aAAa,EAAE,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA4BxF;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,GAAG,aAAa,GAAG,IAAI,CAkCjG;AAGD,wBAAgB,2BAA2B,CACzC,aAAa,EAAE,aAAa,EAC5B,iBAAiB,GAAE,SAAS,MAAM,EAA6B,GAC9D,MAAM,EAAE,CAEV"}
|
|
@@ -12,7 +12,7 @@ export const SUPPORTED_INDEX_FEATURES = [
|
|
|
12
12
|
// Hidden files: index keys that start with 'hidden:'.
|
|
13
13
|
HIDDEN_INDEX_FEATURE,
|
|
14
14
|
];
|
|
15
|
-
const KNOWN_FIELDS = ['publishedTime', 'expirationTime', 'requires'];
|
|
15
|
+
const KNOWN_FIELDS = ['publishedTime', 'expirationTime', 'requires', 'fileCount', 'hiddenFileCount'];
|
|
16
16
|
export function encodeIndexMetadata(indexMetadata) {
|
|
17
17
|
const result = { ...indexMetadata.otherFields };
|
|
18
18
|
if (indexMetadata.publishedTime != null && !isNaN(indexMetadata.publishedTime)) {
|
|
@@ -29,6 +29,12 @@ export function encodeIndexMetadata(indexMetadata) {
|
|
|
29
29
|
}
|
|
30
30
|
result['requires'] = indexMetadata.requires.join(',');
|
|
31
31
|
}
|
|
32
|
+
for (const field of ['fileCount', 'hiddenFileCount']) {
|
|
33
|
+
const value = indexMetadata[field];
|
|
34
|
+
if (value != null && Number.isInteger(value) && value >= 0) {
|
|
35
|
+
result[field] = String(value);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
32
38
|
return result;
|
|
33
39
|
}
|
|
34
40
|
export function decodeIndexMetadata(obj) {
|
|
@@ -50,10 +56,16 @@ export function decodeIndexMetadata(obj) {
|
|
|
50
56
|
otherFields[key] = String(value);
|
|
51
57
|
}
|
|
52
58
|
}
|
|
59
|
+
const count = (field) => {
|
|
60
|
+
const value = getMetadataFieldValue(obj, field);
|
|
61
|
+
return value != null && /^\d+$/.test(String(value)) ? Number(value) : undefined;
|
|
62
|
+
};
|
|
53
63
|
return {
|
|
54
64
|
publishedTime: !isNaN(publishedTime) ? publishedTime : undefined,
|
|
55
65
|
expirationTime: !isNaN(expirationTime) ? expirationTime : undefined,
|
|
56
66
|
requires: requires.length > 0 ? requires : undefined,
|
|
67
|
+
fileCount: count('fileCount'),
|
|
68
|
+
hiddenFileCount: count('hiddenFileCount'),
|
|
57
69
|
otherFields,
|
|
58
70
|
};
|
|
59
71
|
}
|
package/package.json
CHANGED
|
@@ -19,16 +19,26 @@ async function handleRequest(event) {
|
|
|
19
19
|
return selection.response;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
// Code that must run before the published files goes here.
|
|
23
|
+
|
|
24
|
+
// Serve the published file for the request. With fallback: false, a path
|
|
25
|
+
// that has no file does not get the SPA file or the 404 page here.
|
|
22
26
|
const response = await publisherServer.serveRequest(request, {
|
|
23
27
|
collectionName: selection.collectionName,
|
|
24
28
|
pathname: selection.pathname,
|
|
29
|
+
fallback: false,
|
|
25
30
|
});
|
|
26
31
|
if (response != null) {
|
|
27
32
|
return response;
|
|
28
33
|
}
|
|
29
34
|
|
|
30
35
|
// Do custom things here!
|
|
31
|
-
// Handle API requests, serve non-static responses, etc.
|
|
36
|
+
// Handle API requests, serve non-static responses, etc. This code runs only
|
|
37
|
+
// for the requests that no published file matches.
|
|
32
38
|
|
|
33
|
-
|
|
39
|
+
// When nothing else matches, serve the SPA file or the 404 page.
|
|
40
|
+
const fallback = await publisherServer.serveFallback(request, {
|
|
41
|
+
collectionName: selection.collectionName,
|
|
42
|
+
});
|
|
43
|
+
return fallback ?? new Response('Not found', { status: 404 });
|
|
34
44
|
}
|