@fastly/compute-js-static-publish 8.0.0 → 8.1.0-beta.1
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 +1984 -0
- package/README.md +11 -4
- package/README.short.md +11 -4
- package/build/cli/cli/commands/manage/clean.d.ts.map +1 -1
- package/build/cli/cli/commands/manage/clean.js +12 -7
- package/build/cli/cli/commands/manage/collections/delete.d.ts.map +1 -1
- package/build/cli/cli/commands/manage/collections/delete.js +29 -13
- package/build/cli/cli/commands/manage/collections/index.d.ts.map +1 -1
- package/build/cli/cli/commands/manage/collections/index.js +6 -1
- package/build/cli/cli/commands/manage/collections/list.d.ts.map +1 -1
- package/build/cli/cli/commands/manage/collections/list.js +47 -7
- package/build/cli/cli/commands/manage/collections/promote.d.ts.map +1 -1
- package/build/cli/cli/commands/manage/collections/promote.js +67 -20
- package/build/cli/cli/commands/manage/collections/update-expiration.d.ts.map +1 -1
- package/build/cli/cli/commands/manage/collections/update-expiration.js +10 -11
- package/build/cli/cli/commands/manage/deploy.d.ts +2 -0
- package/build/cli/cli/commands/manage/deploy.d.ts.map +1 -0
- package/build/cli/cli/commands/manage/deploy.js +194 -0
- package/build/cli/cli/commands/manage/dev.d.ts +2 -0
- package/build/cli/cli/commands/manage/dev.d.ts.map +1 -0
- package/build/cli/cli/commands/manage/dev.js +77 -0
- package/build/cli/cli/commands/manage/eject.d.ts +2 -0
- package/build/cli/cli/commands/manage/eject.d.ts.map +1 -0
- package/build/cli/cli/commands/manage/eject.js +155 -0
- package/build/cli/cli/commands/manage/index.d.ts.map +1 -1
- package/build/cli/cli/commands/manage/index.js +37 -1
- package/build/cli/cli/commands/manage/publish-content.d.ts.map +1 -1
- package/build/cli/cli/commands/manage/publish-content.js +85 -35
- package/build/cli/cli/commands/manage/status.d.ts +2 -0
- package/build/cli/cli/commands/manage/status.d.ts.map +1 -0
- package/build/cli/cli/commands/manage/status.js +162 -0
- package/build/cli/cli/commands/manage/template/index.d.ts +2 -0
- package/build/cli/cli/commands/manage/template/index.d.ts.map +1 -0
- package/build/cli/cli/commands/manage/template/index.js +42 -0
- package/build/cli/cli/commands/manage/template/init.d.ts +13 -0
- package/build/cli/cli/commands/manage/template/init.d.ts.map +1 -0
- package/build/cli/cli/commands/manage/template/init.js +172 -0
- package/build/cli/cli/commands/manage/upgrade.d.ts +2 -0
- package/build/cli/cli/commands/manage/upgrade.d.ts.map +1 -0
- package/build/cli/cli/commands/manage/upgrade.js +59 -0
- package/build/cli/cli/commands/run-dev-watch.d.ts +8 -0
- package/build/cli/cli/commands/run-dev-watch.d.ts.map +1 -0
- package/build/cli/cli/commands/run-dev-watch.js +41 -0
- package/build/cli/cli/commands/run-template-hook.d.ts +2 -0
- package/build/cli/cli/commands/run-template-hook.d.ts.map +1 -0
- package/build/cli/cli/commands/run-template-hook.js +28 -0
- package/build/cli/cli/commands/scaffold/app-template.d.ts +17 -0
- package/build/cli/cli/commands/scaffold/app-template.d.ts.map +1 -0
- package/build/cli/cli/commands/scaffold/app-template.js +54 -0
- package/build/cli/cli/commands/scaffold/fastly-toml-sections.d.ts +5 -0
- package/build/cli/cli/commands/scaffold/fastly-toml-sections.d.ts.map +1 -0
- package/build/cli/cli/commands/scaffold/fastly-toml-sections.js +154 -0
- package/build/cli/cli/commands/scaffold/generate-app.d.ts +47 -0
- package/build/cli/cli/commands/scaffold/generate-app.d.ts.map +1 -0
- package/build/cli/cli/commands/scaffold/generate-app.js +164 -0
- package/build/cli/cli/commands/scaffold/index.d.ts +6 -0
- package/build/cli/cli/commands/scaffold/index.d.ts.map +1 -1
- package/build/cli/cli/commands/scaffold/index.js +239 -300
- package/build/cli/cli/commands/scaffold/render.d.ts +7 -0
- package/build/cli/cli/commands/scaffold/render.d.ts.map +1 -0
- package/build/cli/cli/commands/scaffold/render.js +72 -0
- package/build/cli/cli/hono/build.d.ts +43 -0
- package/build/cli/cli/hono/build.d.ts.map +1 -0
- package/build/cli/cli/hono/build.js +297 -0
- package/build/cli/cli/index.js +98 -5
- package/build/cli/cli/managed/app.d.ts +21 -0
- package/build/cli/cli/managed/app.d.ts.map +1 -0
- package/build/cli/cli/managed/app.js +162 -0
- package/build/cli/cli/managed/command-helpers.d.ts +6 -0
- package/build/cli/cli/managed/command-helpers.d.ts.map +1 -0
- package/build/cli/cli/managed/command-helpers.js +81 -0
- package/build/cli/cli/managed/eject.d.ts +6 -0
- package/build/cli/cli/managed/eject.d.ts.map +1 -0
- package/build/cli/cli/managed/eject.js +68 -0
- package/build/cli/cli/managed/fastly-service.d.ts +8 -0
- package/build/cli/cli/managed/fastly-service.d.ts.map +1 -0
- package/build/cli/cli/managed/fastly-service.js +21 -0
- package/build/cli/cli/managed/fingerprint.d.ts +13 -0
- package/build/cli/cli/managed/fingerprint.d.ts.map +1 -0
- package/build/cli/cli/managed/fingerprint.js +60 -0
- package/build/cli/cli/managed/lockfile.d.ts +31 -0
- package/build/cli/cli/managed/lockfile.d.ts.map +1 -0
- package/build/cli/cli/managed/lockfile.js +62 -0
- package/build/cli/cli/managed/project-edit.d.ts +3 -0
- package/build/cli/cli/managed/project-edit.d.ts.map +1 -0
- package/build/cli/cli/managed/project-edit.js +35 -0
- package/build/cli/cli/managed/project-file.d.ts +16 -0
- package/build/cli/cli/managed/project-file.d.ts.map +1 -0
- package/build/cli/cli/managed/project-file.js +119 -0
- package/build/cli/cli/managed/template-init.d.ts +12 -0
- package/build/cli/cli/managed/template-init.d.ts.map +1 -0
- package/build/cli/cli/managed/template-init.js +120 -0
- package/build/cli/cli/managed/version-check.d.ts +25 -0
- package/build/cli/cli/managed/version-check.d.ts.map +1 -0
- package/build/cli/cli/managed/version-check.js +84 -0
- package/build/cli/cli/storage/kv-store-local-provider.d.ts +1 -0
- package/build/cli/cli/storage/kv-store-local-provider.d.ts.map +1 -1
- package/build/cli/cli/storage/kv-store-local-provider.js +6 -3
- package/build/cli/cli/storage/kv-store-provider.d.ts +2 -1
- package/build/cli/cli/storage/kv-store-provider.d.ts.map +1 -1
- package/build/cli/cli/storage/kv-store-provider.js +17 -6
- package/build/cli/cli/storage/s3-storage-provider.d.ts +1 -0
- package/build/cli/cli/storage/s3-storage-provider.d.ts.map +1 -1
- package/build/cli/cli/storage/s3-storage-provider.js +8 -2
- package/build/cli/cli/storage/storage-provider.d.ts +4 -0
- package/build/cli/cli/storage/storage-provider.d.ts.map +1 -1
- package/build/cli/cli/storage/storage-provider.js +32 -0
- package/build/cli/cli/util/api-token.d.ts +2 -1
- package/build/cli/cli/util/api-token.d.ts.map +1 -1
- package/build/cli/cli/util/api-token.js +38 -3
- package/build/cli/cli/util/collection-name.d.ts +3 -0
- package/build/cli/cli/util/collection-name.d.ts.map +1 -0
- package/build/cli/cli/util/collection-name.js +24 -0
- package/build/cli/cli/util/collection-selection-flags.d.ts +13 -0
- package/build/cli/cli/util/collection-selection-flags.d.ts.map +1 -0
- package/build/cli/cli/util/collection-selection-flags.js +131 -0
- package/build/cli/cli/util/config.d.ts +13 -0
- package/build/cli/cli/util/config.d.ts.map +1 -1
- package/build/cli/cli/util/config.js +172 -38
- package/build/cli/cli/util/data.d.ts.map +1 -1
- package/build/cli/cli/util/global-options.d.ts +13 -0
- package/build/cli/cli/util/global-options.d.ts.map +1 -0
- package/build/cli/cli/util/global-options.js +53 -0
- package/build/cli/cli/util/kv-store-items.d.ts +1 -0
- package/build/cli/cli/util/kv-store-items.d.ts.map +1 -1
- package/build/cli/cli/util/kv-store-items.js +16 -40
- package/build/cli/cli/util/kv-store-local-server.d.ts +1 -1
- package/build/cli/cli/util/kv-store-local-server.d.ts.map +1 -1
- package/build/cli/cli/util/kv-store-local-server.js +4 -2
- package/build/cli/cli/util/output.d.ts +31 -0
- package/build/cli/cli/util/output.d.ts.map +1 -0
- package/build/cli/cli/util/output.js +139 -0
- package/build/cli/cli/util/package.d.ts +3 -0
- package/build/cli/cli/util/package.d.ts.map +1 -1
- package/build/cli/cli/util/package.js +12 -0
- package/build/cli/cli/util/progress.d.ts +11 -0
- package/build/cli/cli/util/progress.d.ts.map +1 -0
- package/build/cli/cli/util/progress.js +32 -0
- package/build/cli/cli/util/purge.d.ts +15 -3
- package/build/cli/cli/util/purge.d.ts.map +1 -1
- package/build/cli/cli/util/purge.js +23 -10
- package/build/cli/cli/util/resources.d.ts +2 -0
- package/build/cli/cli/util/resources.d.ts.map +1 -0
- package/build/cli/cli/util/resources.js +8 -0
- package/build/cli/cli/util/service-id.d.ts +1 -0
- package/build/cli/cli/util/service-id.d.ts.map +1 -1
- package/build/cli/cli/util/service-id.js +5 -1
- package/build/cli/cli/util/variants.d.ts.map +1 -1
- package/build/cli/models/assets/index.d.ts +6 -0
- package/build/cli/models/assets/index.d.ts.map +1 -1
- package/build/cli/models/assets/index.js +24 -0
- package/build/cli/models/collections/index.d.ts +3 -0
- package/build/cli/models/collections/index.d.ts.map +1 -0
- package/build/cli/models/collections/index.js +15 -0
- package/build/cli/models/compression/index.d.ts +1 -1
- package/build/cli/models/compression/index.d.ts.map +1 -1
- package/build/cli/models/config/collection-selection.d.ts +55 -0
- package/build/cli/models/config/collection-selection.d.ts.map +1 -0
- package/build/cli/models/config/collection-selection.js +238 -0
- package/build/cli/models/config/item-patterns.d.ts +4 -0
- package/build/cli/models/config/item-patterns.d.ts.map +1 -0
- package/build/cli/models/config/item-patterns.js +43 -0
- package/build/cli/models/config/publish-content-config.d.ts +6 -1
- package/build/cli/models/config/publish-content-config.d.ts.map +1 -1
- package/build/cli/models/config/static-publish-project.d.ts +23 -0
- package/build/cli/models/config/static-publish-project.d.ts.map +1 -0
- package/build/cli/models/config/static-publish-project.js +11 -0
- package/build/cli/models/config/static-publish-rc.d.ts +25 -0
- package/build/cli/models/config/static-publish-rc.d.ts.map +1 -1
- package/build/cli/models/config/static-publish-rc.js +31 -0
- package/build/cli/models/config/template-settings.d.ts +10 -0
- package/build/cli/models/config/template-settings.d.ts.map +1 -0
- package/build/cli/models/config/template-settings.js +72 -0
- package/build/cli/models/server/index.d.ts.map +1 -1
- package/build/cli/models/server/index.js +6 -2
- package/build/server/hono/extensions.d.ts +48 -0
- package/build/server/hono/extensions.d.ts.map +1 -0
- package/build/server/hono/extensions.js +65 -0
- package/build/server/hono/index.d.ts +30 -0
- package/build/server/hono/index.d.ts.map +1 -0
- package/build/server/hono/index.js +72 -0
- package/build/server/hono/path.d.ts +7 -0
- package/build/server/hono/path.d.ts.map +1 -0
- package/build/server/hono/path.js +32 -0
- package/build/server/models/assets/index.d.ts +6 -0
- package/build/server/models/assets/index.d.ts.map +1 -1
- package/build/server/models/assets/index.js +24 -0
- package/build/server/models/collections/index.d.ts +3 -0
- package/build/server/models/collections/index.d.ts.map +1 -0
- package/build/server/models/collections/index.js +15 -0
- package/build/server/models/compression/index.d.ts +1 -1
- package/build/server/models/compression/index.d.ts.map +1 -1
- package/build/server/models/config/collection-selection.d.ts +55 -0
- package/build/server/models/config/collection-selection.d.ts.map +1 -0
- package/build/server/models/config/collection-selection.js +238 -0
- package/build/server/models/config/item-patterns.d.ts +4 -0
- package/build/server/models/config/item-patterns.d.ts.map +1 -0
- package/build/server/models/config/item-patterns.js +43 -0
- package/build/server/models/config/publish-content-config.d.ts +6 -1
- package/build/server/models/config/publish-content-config.d.ts.map +1 -1
- package/build/server/models/config/static-publish-project.d.ts +23 -0
- package/build/server/models/config/static-publish-project.d.ts.map +1 -0
- package/build/server/models/config/static-publish-project.js +11 -0
- package/build/server/models/config/static-publish-rc.d.ts +25 -0
- package/build/server/models/config/static-publish-rc.d.ts.map +1 -1
- package/build/server/models/config/static-publish-rc.js +31 -0
- package/build/server/models/server/index.d.ts.map +1 -1
- package/build/server/models/server/index.js +6 -2
- package/build/server/server/collection-selection/index.d.ts +11 -0
- package/build/server/server/collection-selection/index.d.ts.map +1 -0
- package/build/server/server/collection-selection/index.js +192 -0
- package/build/server/server/collection-selector/from-cookie.d.ts.map +1 -1
- package/build/server/server/collection-selector/from-cookie.js +6 -8
- package/build/server/server/collection-selector/from-request.d.ts.map +1 -1
- package/build/server/server/index.d.ts +4 -1
- package/build/server/server/index.d.ts.map +1 -1
- package/build/server/server/index.js +3 -1
- package/build/server/server/publisher-server/accept-html.d.ts +2 -0
- package/build/server/server/publisher-server/accept-html.d.ts.map +1 -0
- package/build/server/server/publisher-server/accept-html.js +50 -0
- package/build/server/server/publisher-server/index.d.ts +59 -6
- package/build/server/server/publisher-server/index.d.ts.map +1 -1
- package/build/server/server/publisher-server/index.js +370 -131
- package/build/server/server/publisher-server/response-cache.d.ts +3 -0
- package/build/server/server/publisher-server/response-cache.d.ts.map +1 -1
- package/build/server/server/publisher-server/response-cache.js +24 -1
- package/build/server/server/storage/kv-store-provider.d.ts.map +1 -1
- package/build/server/server/storage/s3-storage-provider.d.ts.map +1 -1
- package/build/server/server/storage/storage-provider.d.ts.map +1 -1
- package/build/server/server/util/body-length.d.ts.map +1 -1
- package/build/server/server/util/server-timing.d.ts.map +1 -1
- package/package.json +23 -4
- package/resources/app/fastly.toml.njk +58 -0
- package/resources/app/gitignore.njk +9 -0
- package/resources/app/publish-content.config.from-project.js.njk +9 -0
- package/resources/app/publish-content.config.js.njk +35 -0
- package/resources/app/static-publish.project.js.njk +83 -0
- package/resources/app/static-publish.rc.js.njk +43 -0
- package/resources/template-init/hono/_example.ts +22 -0
- package/resources/template-init/hono/tsconfig.json +17 -0
- package/resources/templates/hono/package-lock.json +4123 -0
- package/resources/templates/hono/package.json +15 -0
- package/resources/templates/hono/scripts/template_postinstall.js +10 -0
- package/resources/templates/hono/scripts/template_prebuild.js +8 -0
- package/resources/templates/hono/scripts/template_watch.js +15 -0
- package/resources/templates/hono/src/hono-extensions.generated.d.ts +5 -0
- package/resources/templates/hono/src/index.ts +53 -0
- package/resources/templates/hono/tsconfig.json +17 -0
- package/resources/templates/plain/package-lock.json +4088 -0
- package/resources/templates/plain/package.json +10 -0
- package/resources/templates/plain/src/index.js +34 -0
|
@@ -4,17 +4,23 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import * as fs from 'node:fs';
|
|
6
6
|
import * as path from 'node:path';
|
|
7
|
+
import { HIDDEN_INDEX_FEATURE, findAssetEntry, hiddenIndexKey, } from '../../../models/assets/index.js';
|
|
8
|
+
import { parseItemPatterns, testItemPatterns } from '../../../models/config/item-patterns.js';
|
|
7
9
|
import { encodeIndexMetadata } from '../../../models/server/index.js';
|
|
8
10
|
import { calcExpirationTime } from '../../../models/time/index.js';
|
|
9
11
|
import { parseCommandLine } from '../../util/args.js';
|
|
12
|
+
import { errorCodeOf, fail, recordFailure, setJsonResult } from '../../util/output.js';
|
|
13
|
+
import { checkCollectionNameForWrite } from '../../util/collection-name.js';
|
|
10
14
|
import { mergeContentTypes, testFileContentType } from '../../util/content-types.js';
|
|
11
|
-
import { LoadConfigError,
|
|
15
|
+
import { LoadConfigError, configFileName, detectProjectMode, getComputeAppDir, loadProjectFile, loadPublishContentConfig, loadStaticPublisherRcFile, } from '../../util/config.js';
|
|
16
|
+
import { PROJECT_FILE_NAME } from '../../../models/config/static-publish-project.js';
|
|
12
17
|
import { applyDefaults } from '../../util/data.js';
|
|
13
18
|
import { calculateFileSizeAndHash, enumerateFiles, rootRelative } from '../../util/files.js';
|
|
14
19
|
import { ensureVariantFileExists, OncePerKey } from '../../util/variants.js';
|
|
15
20
|
import { concurrentMap } from '../../util/retryable.js';
|
|
21
|
+
import { ProgressLog } from '../../util/progress.js';
|
|
16
22
|
import { loadPurgeTarget, purgeCollection } from '../../util/purge.js';
|
|
17
|
-
import { getStorageKeysByHexPrefix, loadStorageProviderFromStaticPublishRc, StorageProviderBatch, } from '../../storage/storage-provider.js';
|
|
23
|
+
import { getStorageKeysByHexPrefix, isVariantInStorage, loadStorageProviderFromStaticPublishRc, StorageProviderBatch, } from '../../storage/storage-provider.js';
|
|
18
24
|
// Storage key format:
|
|
19
25
|
// <publishId>_index_<preview_id>.json
|
|
20
26
|
// <publishId>_settings_<preview_id>.json
|
|
@@ -94,6 +100,9 @@ S3 Storage Options (BETA):
|
|
|
94
100
|
Default: 64
|
|
95
101
|
|
|
96
102
|
Global Options:
|
|
103
|
+
--verbose Verbose mode. Logs each file and each upload.
|
|
104
|
+
Without this, the log shows the progress after
|
|
105
|
+
each 1000 files or uploads.
|
|
97
106
|
-h, --help Show this help message and exit.
|
|
98
107
|
|
|
99
108
|
Examples:
|
|
@@ -105,7 +114,7 @@ Examples:
|
|
|
105
114
|
}
|
|
106
115
|
export async function action(actionArgs) {
|
|
107
116
|
const optionDefinitions = [
|
|
108
|
-
{ name: 'verbose', type: Boolean },
|
|
117
|
+
{ name: 'verbose', type: Boolean, defaultValue: false },
|
|
109
118
|
{ name: 'config', type: String },
|
|
110
119
|
{ name: 'collection-name', type: String, },
|
|
111
120
|
{ name: 'root-dir', type: String, },
|
|
@@ -128,7 +137,7 @@ export async function action(actionArgs) {
|
|
|
128
137
|
if (parsed.error != null) {
|
|
129
138
|
console.error(String(parsed.error));
|
|
130
139
|
console.error();
|
|
131
|
-
|
|
140
|
+
recordFailure('usage', String(parsed.error));
|
|
132
141
|
}
|
|
133
142
|
help();
|
|
134
143
|
return;
|
|
@@ -138,8 +147,7 @@ export async function action(actionArgs) {
|
|
|
138
147
|
if (s3UploadConcurrencyValue !== undefined) {
|
|
139
148
|
if (typeof s3UploadConcurrencyValue !== 'string' || !/^\d+$/.test(s3UploadConcurrencyValue) ||
|
|
140
149
|
Number(s3UploadConcurrencyValue) < 1 || Number(s3UploadConcurrencyValue) > 256) {
|
|
141
|
-
|
|
142
|
-
process.exitCode = 1;
|
|
150
|
+
fail('usage', `--s3-upload-concurrency must be an integer from 1 to 256.`);
|
|
143
151
|
return;
|
|
144
152
|
}
|
|
145
153
|
s3UploadConcurrency = Number(s3UploadConcurrencyValue);
|
|
@@ -147,7 +155,7 @@ export async function action(actionArgs) {
|
|
|
147
155
|
const overwriteExisting = _overwriteExisting ?? _kvOverwrite;
|
|
148
156
|
// compute-js-static-publisher cli is always run from the Compute application directory
|
|
149
157
|
// in other words, the directory that contains `fastly.toml`.
|
|
150
|
-
const computeAppDir =
|
|
158
|
+
const computeAppDir = getComputeAppDir();
|
|
151
159
|
console.log(`🚀 Publishing content...`);
|
|
152
160
|
// #### load config
|
|
153
161
|
let staticPublisherRc;
|
|
@@ -155,20 +163,22 @@ export async function action(actionArgs) {
|
|
|
155
163
|
staticPublisherRc = await loadStaticPublisherRcFile();
|
|
156
164
|
}
|
|
157
165
|
catch (err) {
|
|
158
|
-
console.error(
|
|
166
|
+
console.error(`❌ Can't load ${configFileName()}`);
|
|
159
167
|
console.error("Run this from a compute-js-static-publish compute-js directory.");
|
|
160
168
|
if (err instanceof LoadConfigError) {
|
|
161
169
|
for (const error of err.errors) {
|
|
162
170
|
console.error(error);
|
|
163
171
|
}
|
|
164
172
|
}
|
|
165
|
-
|
|
173
|
+
recordFailure('config-invalid', `Can't load ${configFileName()}.`);
|
|
166
174
|
return;
|
|
167
175
|
}
|
|
168
|
-
|
|
176
|
+
// In a managed project, the default is the publishContent section of the project file.
|
|
177
|
+
const managedProject = detectProjectMode() === 'managed' ? await loadProjectFile() : null;
|
|
178
|
+
const configFilePath = configFilePathValue ?? (managedProject != null ? `${PROJECT_FILE_NAME} (publishContent)` : './publish-content.config.js');
|
|
169
179
|
let publishContentConfig;
|
|
170
180
|
try {
|
|
171
|
-
publishContentConfig = await
|
|
181
|
+
publishContentConfig = await loadPublishContentConfig(configFilePathValue);
|
|
172
182
|
}
|
|
173
183
|
catch (err) {
|
|
174
184
|
console.error(`❌ Can't load ${configFilePath}`);
|
|
@@ -177,15 +187,14 @@ export async function action(actionArgs) {
|
|
|
177
187
|
console.error(error);
|
|
178
188
|
}
|
|
179
189
|
}
|
|
180
|
-
|
|
190
|
+
recordFailure('config-invalid', `Can't load ${configFilePath}.`);
|
|
181
191
|
return;
|
|
182
192
|
}
|
|
183
193
|
// --brotli-quality overrides brotliQuality in the config file.
|
|
184
194
|
let brotliQualitySource = 'config';
|
|
185
195
|
if (brotliQualityValue !== undefined) {
|
|
186
196
|
if (typeof brotliQualityValue !== 'string' || !/^\d+$/.test(brotliQualityValue) || Number(brotliQualityValue) > 11) {
|
|
187
|
-
|
|
188
|
-
process.exitCode = 1;
|
|
197
|
+
fail('usage', `--brotli-quality must be an integer from 0 to 11.`);
|
|
189
198
|
return;
|
|
190
199
|
}
|
|
191
200
|
publishContentConfig.brotliQuality = Number(brotliQualityValue);
|
|
@@ -206,7 +215,7 @@ export async function action(actionArgs) {
|
|
|
206
215
|
catch (err) {
|
|
207
216
|
console.error(`❌ Cannot process expiration time`);
|
|
208
217
|
console.error(String(err));
|
|
209
|
-
process
|
|
218
|
+
recordFailure('usage', `Cannot process expiration time: ${String(err)}`);
|
|
210
219
|
return;
|
|
211
220
|
}
|
|
212
221
|
console.log(`✔️ Public directory '${rootRelative(publicDirRoot)}'.`);
|
|
@@ -234,7 +243,7 @@ export async function action(actionArgs) {
|
|
|
234
243
|
catch (err) {
|
|
235
244
|
console.error(`❌ Could not instantiate store provider`);
|
|
236
245
|
console.error(String(err));
|
|
237
|
-
|
|
246
|
+
recordFailure(errorCodeOf(err), String(err));
|
|
238
247
|
return;
|
|
239
248
|
}
|
|
240
249
|
// Purge target: checked now, so that a missing API token fails before anything is uploaded.
|
|
@@ -244,13 +253,14 @@ export async function action(actionArgs) {
|
|
|
244
253
|
localMode: localMode ?? false,
|
|
245
254
|
computeAppDir,
|
|
246
255
|
fastlyServiceId,
|
|
256
|
+
projectServiceId: managedProject?.managed.serviceId,
|
|
247
257
|
fastlyApiToken,
|
|
248
258
|
purgeEnvironments: purgeEnvironmentValues,
|
|
249
259
|
});
|
|
250
260
|
}
|
|
251
261
|
catch (err) {
|
|
252
262
|
console.error(String(err));
|
|
253
|
-
|
|
263
|
+
recordFailure(errorCodeOf(err), String(err));
|
|
254
264
|
return;
|
|
255
265
|
}
|
|
256
266
|
// Load content types
|
|
@@ -274,10 +284,20 @@ export async function action(actionArgs) {
|
|
|
274
284
|
if (includeWellKnown) {
|
|
275
285
|
console.log(`✔️ (.well-known is exempt from exclusion.)`);
|
|
276
286
|
}
|
|
287
|
+
// The files to publish as hidden files (see also assetInclusionTest).
|
|
288
|
+
const hiddenItems = parseItemPatterns(publishContentConfig.hiddenItems, (i, x) => {
|
|
289
|
+
console.warn(`⚠️ Cannot parse hiddenItems item index ${i}: '${x}', skipping...`);
|
|
290
|
+
});
|
|
291
|
+
if (hiddenItems.length > 0) {
|
|
292
|
+
console.log(`✔️ Hidden items: ${publishContentConfig.hiddenItems.join(', ')}`);
|
|
293
|
+
}
|
|
277
294
|
// ### Collection name that we're currently publishing
|
|
278
295
|
// for example, live, staging
|
|
279
296
|
const collectionName = collectionNameValue ?? process.env.PUBLISHER_COLLECTION_NAME ?? defaultCollectionName;
|
|
280
297
|
console.log(`✔️ Collection Name: ${collectionName}`);
|
|
298
|
+
if (!await checkCollectionNameForWrite(storageProvider, publishId, collectionName)) {
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
281
301
|
if (expirationTime == null) {
|
|
282
302
|
// includes null and undefined
|
|
283
303
|
console.log(`✔️ Publishing with no expiration timestamp.`);
|
|
@@ -315,6 +335,8 @@ export async function action(actionArgs) {
|
|
|
315
335
|
// #### Keys that are already in storage
|
|
316
336
|
// The key of a file is the hash of its content. If the key exists, storage
|
|
317
337
|
// already has the same content. Thus we do not compress, hash, or upload it again.
|
|
338
|
+
// For a file in more than one chunk, isVariantInStorage() also compares the
|
|
339
|
+
// stored size of each chunk.
|
|
318
340
|
// In local mode, a key can refer to a working file that was deleted, so we do not list.
|
|
319
341
|
// All the keys that the scan looks for start with `<publishId>_files_sha256_` and a hex
|
|
320
342
|
// hash, so we list them in 16 parts at the same time.
|
|
@@ -326,18 +348,8 @@ export async function action(actionArgs) {
|
|
|
326
348
|
console.log(`✅ Found ${existingKeys.size} key(s) in ${((Date.now() - listStart) / 1000).toFixed(1)} s.`);
|
|
327
349
|
}
|
|
328
350
|
let existingVariantCount = 0;
|
|
329
|
-
function isVariantInStorage(variantKey, numChunks) {
|
|
330
|
-
if (existingKeys == null || !existingKeys.has(variantKey)) {
|
|
331
|
-
return false;
|
|
332
|
-
}
|
|
333
|
-
for (let chunkIndex = 1; chunkIndex < numChunks; chunkIndex++) {
|
|
334
|
-
if (!existingKeys.has(`${variantKey}_${chunkIndex}`)) {
|
|
335
|
-
return false;
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
return true;
|
|
339
|
-
}
|
|
340
351
|
// #### Iterate files
|
|
352
|
+
const scanProgress = new ProgressLog('Files scanned', verbose);
|
|
341
353
|
const fileResults = await concurrentMap(files, async (file) => {
|
|
342
354
|
// #### asset key
|
|
343
355
|
const assetKey = file.slice(publicDirRoot.length)
|
|
@@ -369,9 +381,12 @@ export async function action(actionArgs) {
|
|
|
369
381
|
if (!includeAsset) {
|
|
370
382
|
return;
|
|
371
383
|
}
|
|
384
|
+
// A hidden file is published, but PublisherServer does not serve it for a request.
|
|
385
|
+
const hidden = (typeof includeAsset === 'object' && includeAsset.hidden === true) ||
|
|
386
|
+
testItemPatterns(hiddenItems, assetKey);
|
|
372
387
|
// #### Base file size, hash, last modified time
|
|
373
388
|
const { size: baseSize, hash: baseHash } = await calculateFileSizeAndHash(file);
|
|
374
|
-
|
|
389
|
+
scanProgress.add(1, () => `📄 File '${rootRelative(file)}' - ${baseSize} bytes, sha256: ${baseHash}${hidden ? ' (hidden)' : ''}`);
|
|
375
390
|
const stats = fs.statSync(file);
|
|
376
391
|
const lastModifiedTime = Math.floor((stats.mtime).getTime() / 1000);
|
|
377
392
|
// We know the number of chunks of the original before we read it. For a
|
|
@@ -387,7 +402,8 @@ export async function action(actionArgs) {
|
|
|
387
402
|
// Returns true if the index keeps the variant.
|
|
388
403
|
async function prepareVariant(variant, variantKey, variantFilePath) {
|
|
389
404
|
if ((variant === 'original' || baseNumChunks === 1) &&
|
|
390
|
-
|
|
405
|
+
existingKeys != null &&
|
|
406
|
+
await isVariantInStorage(storageProvider, existingKeys, variantKey, baseSize, variant === 'original' ? baseNumChunks : 1)) {
|
|
391
407
|
if (verbose) {
|
|
392
408
|
console.log(` ・ Asset found in storage with key "${variantKey}".`);
|
|
393
409
|
}
|
|
@@ -453,6 +469,7 @@ export async function action(actionArgs) {
|
|
|
453
469
|
}
|
|
454
470
|
return {
|
|
455
471
|
assetKey,
|
|
472
|
+
hidden,
|
|
456
473
|
asset: {
|
|
457
474
|
key: `sha256:${baseHash}`,
|
|
458
475
|
size: baseSize,
|
|
@@ -463,29 +480,39 @@ export async function action(actionArgs) {
|
|
|
463
480
|
batchItems,
|
|
464
481
|
};
|
|
465
482
|
});
|
|
483
|
+
let hiddenCount = 0;
|
|
466
484
|
for (const result of fileResults) {
|
|
467
485
|
if (result == null) {
|
|
468
486
|
continue;
|
|
469
487
|
}
|
|
470
|
-
|
|
488
|
+
if (result.hidden) {
|
|
489
|
+
assetsIndex[hiddenIndexKey(result.assetKey)] = result.asset;
|
|
490
|
+
hiddenCount++;
|
|
491
|
+
}
|
|
492
|
+
else {
|
|
493
|
+
assetsIndex[result.assetKey] = result.asset;
|
|
494
|
+
}
|
|
471
495
|
for (const batchItem of result.batchItems) {
|
|
472
496
|
batch.add(batchItem);
|
|
473
497
|
}
|
|
474
498
|
}
|
|
475
499
|
console.log(`✅ Scan complete.`);
|
|
500
|
+
console.log(` | ${Object.keys(assetsIndex).length} file(s) in the index, ${hiddenCount} of them hidden.`);
|
|
476
501
|
if (existingKeys != null) {
|
|
477
502
|
console.log(` | ${existingVariantCount} variant(s) already in storage, ${batch.storageProviderBatchEntries.length} to upload.`);
|
|
478
503
|
}
|
|
479
504
|
else {
|
|
480
505
|
console.log(` | ${batch.storageProviderBatchEntries.length} variant(s) to upload.`);
|
|
481
506
|
}
|
|
482
|
-
await storageProvider.applyBatch(batch, { existingKeys });
|
|
507
|
+
await storageProvider.applyBatch(batch, { existingKeys, verbose });
|
|
483
508
|
// #### INDEX FILE
|
|
484
509
|
console.log(`🗂️ Saving Index...`);
|
|
485
510
|
const indexFileKey = `${publishId}_index_${collectionName}`;
|
|
486
511
|
const indexMetadata = {
|
|
487
512
|
publishedTime: Math.floor(Date.now() / 1000),
|
|
488
513
|
expirationTime: expirationTime ?? undefined,
|
|
514
|
+
// A server that does not support hidden files must not serve this collection.
|
|
515
|
+
requires: hiddenCount > 0 ? [HIDDEN_INDEX_FEATURE] : undefined,
|
|
489
516
|
};
|
|
490
517
|
const indexFileName = `index_${collectionName}.json`;
|
|
491
518
|
const indexFilePath = path.resolve(storageContentDir, indexFileName);
|
|
@@ -514,7 +541,7 @@ export async function action(actionArgs) {
|
|
|
514
541
|
let spaFile = server.spaFile;
|
|
515
542
|
if (spaFile != null) {
|
|
516
543
|
console.log(` ✔️ Application SPA file '${spaFile}'.`);
|
|
517
|
-
const spaAsset = assetsIndex
|
|
544
|
+
const spaAsset = findAssetEntry(assetsIndex, spaFile, true);
|
|
518
545
|
if (spaAsset == null || spaAsset.contentType !== 'text/html') {
|
|
519
546
|
if (verbose) {
|
|
520
547
|
console.log(` ⚠️ Notice: '${spaFile}' does not exist or is not of type 'text/html'. Ignoring.`);
|
|
@@ -530,7 +557,7 @@ export async function action(actionArgs) {
|
|
|
530
557
|
let notFoundPageFile = server.notFoundPageFile;
|
|
531
558
|
if (notFoundPageFile != null) {
|
|
532
559
|
console.log(` ✔️ Application 'not found (404)' file '${notFoundPageFile}'.`);
|
|
533
|
-
const notFoundPageAsset = assetsIndex
|
|
560
|
+
const notFoundPageAsset = findAssetEntry(assetsIndex, notFoundPageFile, true);
|
|
534
561
|
if (notFoundPageAsset == null || notFoundPageAsset.contentType !== 'text/html') {
|
|
535
562
|
if (verbose) {
|
|
536
563
|
console.log(` ⚠️ Notice: '${notFoundPageFile}' does not exist or is not of type 'text/html'. Ignoring.`);
|
|
@@ -559,8 +586,31 @@ export async function action(actionArgs) {
|
|
|
559
586
|
const settingsFilePath = path.resolve(storageContentDir, settingsFileName);
|
|
560
587
|
await storageProvider.submitStorageEntry(settingsFileKey, settingsFilePath, JSON.stringify(serverSettings));
|
|
561
588
|
console.log(`✅ Settings have been saved.`);
|
|
589
|
+
// A failed purge is only a warning (exit 0), because the content is published.
|
|
590
|
+
const purgeResults = [];
|
|
562
591
|
if (purgeTarget != null) {
|
|
563
|
-
await purgeCollection(purgeTarget, publishId, collectionName);
|
|
592
|
+
purgeResults.push(...await purgeCollection(purgeTarget, publishId, collectionName));
|
|
564
593
|
}
|
|
565
594
|
console.log(`🎉 Completed.`);
|
|
595
|
+
setJsonResult({
|
|
596
|
+
collection: collectionName,
|
|
597
|
+
publishId,
|
|
598
|
+
// The files in the index.
|
|
599
|
+
files: {
|
|
600
|
+
total: Object.keys(assetsIndex).length,
|
|
601
|
+
hidden: hiddenCount,
|
|
602
|
+
},
|
|
603
|
+
// Each file, and each compressed variant that is kept.
|
|
604
|
+
storageItems: {
|
|
605
|
+
uploaded: batch.storageProviderBatchEntries.length,
|
|
606
|
+
reused: existingVariantCount,
|
|
607
|
+
},
|
|
608
|
+
expiresAt: expirationTime != null ? new Date(expirationTime * 1000).toISOString() : null,
|
|
609
|
+
// null: no purge (--local, or no Service ID).
|
|
610
|
+
purge: purgeTarget != null ? {
|
|
611
|
+
ok: purgeResults.every(x => x.result !== 'failed'),
|
|
612
|
+
serviceId: purgeTarget.serviceId,
|
|
613
|
+
environments: purgeResults,
|
|
614
|
+
} : null,
|
|
615
|
+
});
|
|
566
616
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/manage/status.ts"],"names":[],"mappings":"AAgDA,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,iBAiIhD"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright Fastly, Inc.
|
|
3
|
+
* Licensed under the MIT license. See LICENSE file for details.
|
|
4
|
+
*/
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import { managedAppState } from '../../managed/app.js';
|
|
7
|
+
import { loadManagedProject } from '../../managed/command-helpers.js';
|
|
8
|
+
import { getActiveVersion, getVersionDomains } from '../../managed/fastly-service.js';
|
|
9
|
+
import { parseVersionComment } from '../../managed/fingerprint.js';
|
|
10
|
+
import { checkProjectVersion } from '../../managed/version-check.js';
|
|
11
|
+
import { loadApiToken } from '../../util/api-token.js';
|
|
12
|
+
import { parseCommandLine } from '../../util/args.js';
|
|
13
|
+
import { recordFailure, setJsonResult } from '../../util/output.js';
|
|
14
|
+
import { detectProjectMode } from '../../util/config.js';
|
|
15
|
+
import { getOwnVersion } from '../../util/package.js';
|
|
16
|
+
import { loadServiceId } from '../../util/service-id.js';
|
|
17
|
+
import { previewUrlTemplates } from '../../../models/config/collection-selection.js';
|
|
18
|
+
import { MANAGED_APP_DIR } from '../../../models/config/static-publish-project.js';
|
|
19
|
+
import { DEFAULT_APP_TEMPLATE_NAME } from '../scaffold/app-template.js';
|
|
20
|
+
import { providedVersions } from '../../managed/template-init.js';
|
|
21
|
+
function help() {
|
|
22
|
+
console.log(`\
|
|
23
|
+
|
|
24
|
+
Usage:
|
|
25
|
+
npx @fastly/compute-js-static-publish status [options]
|
|
26
|
+
|
|
27
|
+
Description:
|
|
28
|
+
Shows the state of the app. In a managed project: the fingerprint of the app
|
|
29
|
+
that the project generates, the fingerprint of the active version of the
|
|
30
|
+
service, and if a deploy is necessary. In an ejected app: the Service ID.
|
|
31
|
+
|
|
32
|
+
Options:
|
|
33
|
+
--fastly-service-id=<id> The service. Default: FASTLY_SERVICE_ID, then
|
|
34
|
+
managed.serviceId (or service_id in fastly.toml).
|
|
35
|
+
--fastly-api-token=<token> Reads the active version of the service. Default:
|
|
36
|
+
FASTLY_API_TOKEN. Without a token, the deployed
|
|
37
|
+
fingerprint is unknown.
|
|
38
|
+
|
|
39
|
+
Global Options:
|
|
40
|
+
-h, --help Show this help message and exit.
|
|
41
|
+
`);
|
|
42
|
+
}
|
|
43
|
+
export async function action(actionArgs) {
|
|
44
|
+
const optionDefinitions = [
|
|
45
|
+
{ name: 'fastly-service-id', type: String },
|
|
46
|
+
{ name: 'fastly-api-token', type: String },
|
|
47
|
+
];
|
|
48
|
+
const parsed = parseCommandLine(actionArgs, optionDefinitions);
|
|
49
|
+
if (parsed.needHelp) {
|
|
50
|
+
if (parsed.error != null) {
|
|
51
|
+
console.error(String(parsed.error));
|
|
52
|
+
console.error();
|
|
53
|
+
recordFailure('usage', String(parsed.error));
|
|
54
|
+
}
|
|
55
|
+
help();
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const { ['fastly-service-id']: fastlyServiceId, ['fastly-api-token']: fastlyApiToken, } = parsed.commandLineOptions;
|
|
59
|
+
if (detectProjectMode() === 'ejected') {
|
|
60
|
+
const serviceIdResult = loadServiceId({ commandLine: fastlyServiceId, fastlyTomlPath: path.resolve('fastly.toml') });
|
|
61
|
+
console.log(`Mode : ejected`);
|
|
62
|
+
console.log(`Service ID : ${serviceIdResult?.serviceId ?? '(none)'}`);
|
|
63
|
+
setJsonResult({ mode: 'ejected', serviceId: serviceIdResult?.serviceId ?? null });
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const project = await loadManagedProject('status', '');
|
|
67
|
+
if (project == null) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const running = getOwnVersion();
|
|
71
|
+
const versionCheck = checkProjectVersion(project.managed.staticPublishVersion, running);
|
|
72
|
+
const { fingerprint } = await managedAppState(path.resolve(), project);
|
|
73
|
+
const serviceIdResult = loadServiceId({
|
|
74
|
+
commandLine: fastlyServiceId,
|
|
75
|
+
// After the first deploy, the Fastly CLI writes service_id here.
|
|
76
|
+
fastlyTomlPath: path.resolve(MANAGED_APP_DIR, 'fastly.toml'),
|
|
77
|
+
projectServiceId: project.managed.serviceId,
|
|
78
|
+
});
|
|
79
|
+
const serviceId = serviceIdResult?.serviceId ?? null;
|
|
80
|
+
const apiToken = loadApiToken({ commandLine: fastlyApiToken });
|
|
81
|
+
let deployedFingerprint = null;
|
|
82
|
+
let deployedStaticPublishVersion = null;
|
|
83
|
+
let activeVersion = null;
|
|
84
|
+
let domain = null;
|
|
85
|
+
let needsDeploy;
|
|
86
|
+
const reasons = [];
|
|
87
|
+
if (serviceId == null) {
|
|
88
|
+
needsDeploy = true;
|
|
89
|
+
reasons.push('The project has no service yet (no Service ID).');
|
|
90
|
+
}
|
|
91
|
+
else if (apiToken == null) {
|
|
92
|
+
needsDeploy = null;
|
|
93
|
+
reasons.push('Unknown: no API token, so the active version of the service cannot be read.');
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
const context = { apiToken: apiToken.apiToken };
|
|
97
|
+
const active = await getActiveVersion(context, serviceId);
|
|
98
|
+
if (active == null) {
|
|
99
|
+
needsDeploy = true;
|
|
100
|
+
reasons.push('The service has no active version.');
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
activeVersion = active.number;
|
|
104
|
+
domain = (await getVersionDomains(context, serviceId, active.number))[0] ?? null;
|
|
105
|
+
const deployed = parseVersionComment(active.comment);
|
|
106
|
+
if (deployed == null) {
|
|
107
|
+
needsDeploy = true;
|
|
108
|
+
reasons.push(`The active version (${active.number}) was not deployed by 'deploy' (its comment has no fingerprint).`);
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
deployedFingerprint = deployed.fingerprint;
|
|
112
|
+
deployedStaticPublishVersion = deployed.staticPublishVersion;
|
|
113
|
+
needsDeploy = deployed.fingerprint !== fingerprint;
|
|
114
|
+
if (needsDeploy) {
|
|
115
|
+
reasons.push(deployed.staticPublishVersion !== running ?
|
|
116
|
+
`The version of this package changed: ${deployed.staticPublishVersion} → ${running}.` :
|
|
117
|
+
'The generated app changed.');
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
const baseUrl = domain != null ? `https://${domain}` : 'https://<service domain>';
|
|
123
|
+
const previewUrls = project.rc.collectionSelection != null ? previewUrlTemplates(baseUrl, project.rc.collectionSelection) : [];
|
|
124
|
+
// The packages that the template provides to its folder (for example to the
|
|
125
|
+
// Hono extensions), with the versions of the generated app.
|
|
126
|
+
const templateName = project.managed.template ?? DEFAULT_APP_TEMPLATE_NAME;
|
|
127
|
+
const providedPackages = providedVersions(templateName, path.resolve(MANAGED_APP_DIR, 'node_modules'), running);
|
|
128
|
+
console.log(`Mode : managed`);
|
|
129
|
+
console.log(`Template : ${templateName}`);
|
|
130
|
+
console.log(`Service ID : ${serviceId ?? '(none)'}${serviceIdResult != null ? ` (from ${serviceIdResult.source})` : ''}`);
|
|
131
|
+
console.log(`Version of the project : ${versionCheck.recorded ?? '(missing)'}`);
|
|
132
|
+
console.log(`Version that runs : ${running}${versionCheck.result !== 'same' ? ` ⚠️ ${versionCheck.result}` : ''}`);
|
|
133
|
+
console.log(`Fingerprint : ${fingerprint}`);
|
|
134
|
+
console.log(`Deployed fingerprint : ${deployedFingerprint ?? '(unknown)'}${activeVersion != null ? ` (version ${activeVersion})` : ''}`);
|
|
135
|
+
console.log(`Deploy necessary : ${needsDeploy == null ? 'unknown' : needsDeploy ? 'yes' : 'no'}`);
|
|
136
|
+
for (const reason of reasons) {
|
|
137
|
+
console.log(` * ${reason}`);
|
|
138
|
+
}
|
|
139
|
+
for (const { type, url } of previewUrls) {
|
|
140
|
+
console.log(`Preview URL (${type})${' '.repeat(Math.max(0, 9 - type.length))}: ${url}`);
|
|
141
|
+
}
|
|
142
|
+
setJsonResult({
|
|
143
|
+
mode: 'managed',
|
|
144
|
+
template: { name: templateName, provides: providedPackages },
|
|
145
|
+
serviceId,
|
|
146
|
+
staticPublishVersion: {
|
|
147
|
+
recorded: versionCheck.recorded ?? null,
|
|
148
|
+
running,
|
|
149
|
+
check: versionCheck.result,
|
|
150
|
+
},
|
|
151
|
+
fingerprint: {
|
|
152
|
+
current: fingerprint,
|
|
153
|
+
deployed: deployedFingerprint,
|
|
154
|
+
deployedStaticPublishVersion,
|
|
155
|
+
},
|
|
156
|
+
activeVersion,
|
|
157
|
+
domain,
|
|
158
|
+
needsDeploy,
|
|
159
|
+
reasons,
|
|
160
|
+
previewUrls,
|
|
161
|
+
});
|
|
162
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/cli/commands/manage/template/index.ts"],"names":[],"mappings":"AA2BA,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,iBAuBhD"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright Fastly, Inc.
|
|
3
|
+
* Licensed under the MIT license. See LICENSE file for details.
|
|
4
|
+
*/
|
|
5
|
+
import { getCommandAndArgs } from '../../../util/args.js';
|
|
6
|
+
import { recordFailure } from '../../../util/output.js';
|
|
7
|
+
import * as initCommand from './init.js';
|
|
8
|
+
function help() {
|
|
9
|
+
console.log(`\
|
|
10
|
+
|
|
11
|
+
Usage:
|
|
12
|
+
npx @fastly/compute-js-static-publish template <sub-command> [options]
|
|
13
|
+
|
|
14
|
+
Description:
|
|
15
|
+
Commands for the template of the app.
|
|
16
|
+
|
|
17
|
+
Available Subcommands:
|
|
18
|
+
init Make or update the folder of the template
|
|
19
|
+
(for the hono template: hono-extensions/)
|
|
20
|
+
|
|
21
|
+
Global Options:
|
|
22
|
+
-h, --help Show this help message and exit.
|
|
23
|
+
`);
|
|
24
|
+
}
|
|
25
|
+
export async function action(actionArgs) {
|
|
26
|
+
const modes = {
|
|
27
|
+
'init': initCommand,
|
|
28
|
+
};
|
|
29
|
+
const commandAndArgs = getCommandAndArgs(actionArgs, modes);
|
|
30
|
+
if (commandAndArgs.needHelp) {
|
|
31
|
+
if (commandAndArgs.error != null) {
|
|
32
|
+
console.error(commandAndArgs.error);
|
|
33
|
+
console.error(`Specify one of the following sub-commands: ${Object.keys(modes).join(', ')}`);
|
|
34
|
+
console.error();
|
|
35
|
+
recordFailure('usage', commandAndArgs.error);
|
|
36
|
+
}
|
|
37
|
+
help();
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const { command, argv, } = commandAndArgs;
|
|
41
|
+
await modes[command].action(argv);
|
|
42
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type StaticPublishRc } from '../../../../models/config/static-publish-rc.js';
|
|
2
|
+
export type RunTemplateInitParams = {
|
|
3
|
+
templateName: string;
|
|
4
|
+
rc: Pick<StaticPublishRc, 'build'>;
|
|
5
|
+
baseDir: string;
|
|
6
|
+
appNodeModulesDir: string | undefined;
|
|
7
|
+
reset?: boolean;
|
|
8
|
+
force?: boolean;
|
|
9
|
+
check?: boolean;
|
|
10
|
+
};
|
|
11
|
+
export declare function runTemplateInit(params: RunTemplateInitParams): Promise<void>;
|
|
12
|
+
export declare function action(actionArgs: string[]): Promise<void>;
|
|
13
|
+
//# sourceMappingURL=init.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../../../../src/cli/commands/manage/template/init.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,gDAAgD,CAAC;AAyCtF,MAAM,MAAM,qBAAqB,GAAG;IAClC,YAAY,EAAE,MAAM,CAAC;IACrB,EAAE,EAAE,IAAI,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC;IAGnC,OAAO,EAAE,MAAM,CAAC;IAEhB,iBAAiB,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AASF,wBAAsB,eAAe,CAAC,MAAM,EAAE,qBAAqB,iBAqDlE;AAED,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,iBAsEhD"}
|