@fastly/compute-js-static-publish 8.0.1 → 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 +779 -22
- package/README.md +2 -2
- package/README.short.md +2 -2
- 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 +78 -33
- 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 +208 -290
- 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 +1 -0
- package/build/cli/cli/storage/kv-store-provider.d.ts.map +1 -1
- package/build/cli/cli/storage/kv-store-provider.js +9 -1
- 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 +4 -0
- package/build/cli/cli/storage/storage-provider.d.ts +3 -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.map +1 -1
- 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.map +1 -1
- package/build/cli/cli/util/purge.d.ts +6 -2
- package/build/cli/cli/util/purge.d.ts.map +1 -1
- package/build/cli/cli/util/purge.js +7 -2
- 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 -7
- package/build/server/server/publisher-server/index.d.ts.map +1 -1
- package/build/server/server/publisher-server/index.js +362 -145
- 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 +21 -3
- 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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/manage/deploy.ts"],"names":[],"mappings":"AAuEA,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,iBAqJhD"}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright Fastly, Inc.
|
|
3
|
+
* Licensed under the MIT license. See LICENSE file for details.
|
|
4
|
+
*/
|
|
5
|
+
import child_process from 'node:child_process';
|
|
6
|
+
import fs from 'node:fs';
|
|
7
|
+
import path from 'node:path';
|
|
8
|
+
import { managedAppState, prepareManagedApp } from '../../managed/app.js';
|
|
9
|
+
import { checkVersionForCommand, loadManagedProject, showTemplateFolderHint } from '../../managed/command-helpers.js';
|
|
10
|
+
import { getActiveVersion, getVersionDomains } from '../../managed/fastly-service.js';
|
|
11
|
+
import { formatVersionComment, parseVersionComment } from '../../managed/fingerprint.js';
|
|
12
|
+
import { writeBackServiceId } from '../../managed/project-edit.js';
|
|
13
|
+
import { loadApiToken } from '../../util/api-token.js';
|
|
14
|
+
import { parseCommandLine } from '../../util/args.js';
|
|
15
|
+
import { detectProjectMode } from '../../util/config.js';
|
|
16
|
+
import { readServiceId } from '../../util/fastly-toml.js';
|
|
17
|
+
import { getOwnPackageDir, getOwnVersion } from '../../util/package.js';
|
|
18
|
+
import { fail, isJsonMode, isNonInteractive, recordFailure, setJsonResult } from '../../util/output.js';
|
|
19
|
+
import { loadServiceId } from '../../util/service-id.js';
|
|
20
|
+
import { isS3StorageConfigRc } from '../../../models/config/static-publish-rc.js';
|
|
21
|
+
import { PROJECT_FILE_NAME } from '../../../models/config/static-publish-project.js';
|
|
22
|
+
function help() {
|
|
23
|
+
console.log(`\
|
|
24
|
+
|
|
25
|
+
Usage:
|
|
26
|
+
npx @fastly/compute-js-static-publish deploy [options]
|
|
27
|
+
|
|
28
|
+
Description:
|
|
29
|
+
Deploys the app of a managed project, only if it changed: generates the app,
|
|
30
|
+
installs its dependencies if necessary, and runs 'fastly compute build' and
|
|
31
|
+
'fastly compute deploy'. The comment of the new service version has the
|
|
32
|
+
fingerprint of the app, so that 'status' and the next deploy can compare it.
|
|
33
|
+
|
|
34
|
+
After the first deploy, the Service ID is written into managed.serviceId in
|
|
35
|
+
${PROJECT_FILE_NAME}.
|
|
36
|
+
|
|
37
|
+
In an ejected app, this runs 'fastly compute publish'.
|
|
38
|
+
|
|
39
|
+
Options:
|
|
40
|
+
--force Deploy also when the fingerprint did not change.
|
|
41
|
+
--auto-upgrade If the CLI is newer than managed.staticPublishVersion,
|
|
42
|
+
set it to the version that runs, and continue.
|
|
43
|
+
--comment=<text> Added to the comment of the service version,
|
|
44
|
+
for example a commit SHA.
|
|
45
|
+
--fastly-service-id=<id> The service. Default: FASTLY_SERVICE_ID, then
|
|
46
|
+
managed.serviceId. Without one, the Fastly CLI
|
|
47
|
+
makes a new service.
|
|
48
|
+
--fastly-api-token=<token> Default: FASTLY_API_TOKEN.
|
|
49
|
+
|
|
50
|
+
Global Options:
|
|
51
|
+
-h, --help Show this help message and exit.
|
|
52
|
+
`);
|
|
53
|
+
}
|
|
54
|
+
function runFastly(appDir, args, apiToken) {
|
|
55
|
+
const appFastly = path.resolve(appDir, 'node_modules/.bin/fastly');
|
|
56
|
+
const fastly = fs.existsSync(appFastly) ? appFastly : 'fastly';
|
|
57
|
+
console.log(`▶️ fastly ${args.join(' ')}`);
|
|
58
|
+
return child_process.spawnSync(fastly, args, {
|
|
59
|
+
cwd: appDir,
|
|
60
|
+
env: { ...process.env, FASTLY_API_TOKEN: apiToken },
|
|
61
|
+
// With --json, stdout is for the JSON object only.
|
|
62
|
+
stdio: [isNonInteractive() ? 'ignore' : 'inherit', isJsonMode() ? process.stderr : 'inherit', 'inherit'],
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
export async function action(actionArgs) {
|
|
66
|
+
const optionDefinitions = [
|
|
67
|
+
{ name: 'force', type: Boolean },
|
|
68
|
+
{ name: 'auto-upgrade', type: Boolean },
|
|
69
|
+
{ name: 'comment', type: String },
|
|
70
|
+
{ name: 'fastly-service-id', type: String },
|
|
71
|
+
{ name: 'fastly-api-token', type: String },
|
|
72
|
+
];
|
|
73
|
+
const parsed = parseCommandLine(actionArgs, optionDefinitions);
|
|
74
|
+
if (parsed.needHelp) {
|
|
75
|
+
if (parsed.error != null) {
|
|
76
|
+
console.error(String(parsed.error));
|
|
77
|
+
console.error();
|
|
78
|
+
recordFailure('usage', String(parsed.error));
|
|
79
|
+
}
|
|
80
|
+
help();
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const { force, ['auto-upgrade']: autoUpgrade, comment, ['fastly-service-id']: fastlyServiceId, ['fastly-api-token']: fastlyApiToken, } = parsed.commandLineOptions;
|
|
84
|
+
if (detectProjectMode() === 'ejected') {
|
|
85
|
+
if (isJsonMode()) {
|
|
86
|
+
fail('json-not-supported', `--json is not supported for 'deploy' in an ejected app.`);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
const result = child_process.spawnSync('fastly', ['compute', 'publish'], { stdio: 'inherit' });
|
|
90
|
+
if (result.error != null || result.status !== 0) {
|
|
91
|
+
fail('deploy-failed', `'fastly compute publish' failed.`);
|
|
92
|
+
}
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const project = await loadManagedProject('deploy', '');
|
|
96
|
+
if (project == null) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
showTemplateFolderHint(project);
|
|
100
|
+
if (!checkVersionForCommand(project, autoUpgrade === true)) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
const apiToken = loadApiToken({ commandLine: fastlyApiToken });
|
|
104
|
+
if (apiToken == null) {
|
|
105
|
+
fail('credentials-missing', 'Fastly API Token not provided. Set the FASTLY_API_TOKEN environment variable to an API token that can deploy the service.');
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
const context = { apiToken: apiToken.apiToken };
|
|
109
|
+
const serviceIdResult = loadServiceId({
|
|
110
|
+
commandLine: fastlyServiceId,
|
|
111
|
+
fastlyTomlPath: path.resolve('.static-publish/app/fastly.toml'),
|
|
112
|
+
projectServiceId: project.managed.serviceId,
|
|
113
|
+
});
|
|
114
|
+
let serviceId = serviceIdResult?.serviceId ?? null;
|
|
115
|
+
if (serviceId != null) {
|
|
116
|
+
console.log(`✔️ Service ID from ${serviceIdResult.source}: ${serviceId}`);
|
|
117
|
+
}
|
|
118
|
+
// The Fastly CLI cannot make the Secret Store of an S3 app without prompts.
|
|
119
|
+
if (serviceId == null && isS3StorageConfigRc(project.rc) && isNonInteractive()) {
|
|
120
|
+
fail('first-deploy-manual', 'The first deploy of an app with S3 storage must be done by hand: run deploy on your computer (the Fastly CLI asks for the S3 credentials), ' +
|
|
121
|
+
'or give the ID of a service that is already set up (--fastly-service-id, FASTLY_SERVICE_ID, or managed.serviceId).');
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
// A CLI run from the npx cache puts paths of the home directory into the Wasm binary.
|
|
125
|
+
if (getOwnPackageDir().includes(`${path.sep}_npx${path.sep}`)) {
|
|
126
|
+
console.warn(`⚠️ This CLI runs from the npx cache. The paths of the cache (in your home directory) go into the deployed Wasm binary.`);
|
|
127
|
+
console.warn(` * Add @fastly/compute-js-static-publish as a dev dependency of the project, and run it from there.`);
|
|
128
|
+
}
|
|
129
|
+
const { fingerprint } = await managedAppState(path.resolve(), project);
|
|
130
|
+
const staticPublishVersion = getOwnVersion();
|
|
131
|
+
if (serviceId != null && !force) {
|
|
132
|
+
const active = await getActiveVersion(context, serviceId);
|
|
133
|
+
const deployed = parseVersionComment(active?.comment);
|
|
134
|
+
if (active != null && deployed?.fingerprint === fingerprint) {
|
|
135
|
+
console.log(`✅ The active version ${active.number} already has this app (fingerprint ${fingerprint}). Nothing to deploy. Use --force to deploy anyway.`);
|
|
136
|
+
setJsonResult({
|
|
137
|
+
deployed: false,
|
|
138
|
+
reason: 'up-to-date',
|
|
139
|
+
serviceId,
|
|
140
|
+
version: active.number,
|
|
141
|
+
domain: (await getVersionDomains(context, serviceId, active.number))[0] ?? null,
|
|
142
|
+
fingerprint,
|
|
143
|
+
staticPublishVersion,
|
|
144
|
+
});
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
const { appDir } = await prepareManagedApp(path.resolve(), project);
|
|
149
|
+
const build = runFastly(appDir, ['compute', 'build'], apiToken.apiToken);
|
|
150
|
+
if (build.error != null || build.status !== 0) {
|
|
151
|
+
fail('deploy-failed', `'fastly compute build' failed.`);
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
const deployArgs = ['compute', 'deploy', '--comment', formatVersionComment(staticPublishVersion, fingerprint, comment)];
|
|
155
|
+
if (serviceId != null) {
|
|
156
|
+
deployArgs.push('--service-id', serviceId);
|
|
157
|
+
}
|
|
158
|
+
if (isNonInteractive()) {
|
|
159
|
+
deployArgs.push('--non-interactive');
|
|
160
|
+
}
|
|
161
|
+
const deploy = runFastly(appDir, deployArgs, apiToken.apiToken);
|
|
162
|
+
if (deploy.error != null || deploy.status !== 0) {
|
|
163
|
+
fail('deploy-failed', `'fastly compute deploy' failed.`);
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
// After the first deploy, the Fastly CLI has written service_id into fastly.toml.
|
|
167
|
+
serviceId ??= readServiceId(path.resolve(appDir, 'fastly.toml')) ?? null;
|
|
168
|
+
if (serviceId == null) {
|
|
169
|
+
fail('deploy-failed', 'The deploy finished, but the Service ID is not known.');
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
if (project.managed.serviceId == null) {
|
|
173
|
+
const projectFilePath = path.resolve(PROJECT_FILE_NAME);
|
|
174
|
+
const updated = writeBackServiceId(fs.readFileSync(projectFilePath, 'utf-8'), serviceId);
|
|
175
|
+
if (updated != null) {
|
|
176
|
+
fs.writeFileSync(projectFilePath, updated, 'utf-8');
|
|
177
|
+
console.log(`✔️ Wrote managed.serviceId "${serviceId}" into ${PROJECT_FILE_NAME}. Commit it.`);
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
console.log(`⚠️ Set managed.serviceId to "${serviceId}" in ${PROJECT_FILE_NAME}. (The line 'serviceId: undefined,' was not found, so the CLI did not change the file.)`);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
const active = await getActiveVersion(context, serviceId);
|
|
184
|
+
const domain = active != null ? (await getVersionDomains(context, serviceId, active.number))[0] ?? null : null;
|
|
185
|
+
console.log(`🎉 Deployed ${serviceId}${active != null ? ` version ${active.number}` : ''}${domain != null ? ` (https://${domain}/)` : ''}.`);
|
|
186
|
+
setJsonResult({
|
|
187
|
+
deployed: true,
|
|
188
|
+
serviceId,
|
|
189
|
+
version: active?.number ?? null,
|
|
190
|
+
domain,
|
|
191
|
+
fingerprint,
|
|
192
|
+
staticPublishVersion,
|
|
193
|
+
});
|
|
194
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/manage/dev.ts"],"names":[],"mappings":"AA+CA,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,iBAwChD"}
|
|
@@ -0,0 +1,77 @@
|
|
|
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 { prepareManagedApp } from '../../managed/app.js';
|
|
7
|
+
import { parseCommandLine } from '../../util/args.js';
|
|
8
|
+
import { fail, recordFailure } from '../../util/output.js';
|
|
9
|
+
import { checkVersionForCommand, loadManagedProject, showTemplateFolderHint } from '../../managed/command-helpers.js';
|
|
10
|
+
import { PROJECT_FILE_NAME } from '../../../models/config/static-publish-project.js';
|
|
11
|
+
import { serveApp } from '../run-dev-watch.js';
|
|
12
|
+
function help() {
|
|
13
|
+
console.log(`\
|
|
14
|
+
|
|
15
|
+
Usage:
|
|
16
|
+
npx @fastly/compute-js-static-publish dev [-- <options of fastly compute serve>]
|
|
17
|
+
|
|
18
|
+
Description:
|
|
19
|
+
Runs the app of a managed project on your computer. Generates the app in
|
|
20
|
+
.static-publish/app from ${PROJECT_FILE_NAME}, installs its dependencies
|
|
21
|
+
if they changed, and runs 'fastly compute serve' in it.
|
|
22
|
+
|
|
23
|
+
The app serves the content of the local KV Store. To publish content to it,
|
|
24
|
+
run 'publish-content --local' first.
|
|
25
|
+
|
|
26
|
+
Only in a managed project. In an ejected app, run 'npm run dev:start', or
|
|
27
|
+
'npm run dev:watch' (fastly compute serve --watch).
|
|
28
|
+
|
|
29
|
+
Options:
|
|
30
|
+
--auto-upgrade If the CLI is newer than managed.staticPublishVersion,
|
|
31
|
+
set it to the version that runs, and continue.
|
|
32
|
+
-- <options> Options after -- go to 'fastly compute serve',
|
|
33
|
+
for example: dev -- --addr=127.0.0.1:8080
|
|
34
|
+
With -- --watch, a change in the app builds and
|
|
35
|
+
restarts it. If the template has a watch script,
|
|
36
|
+
it runs next to 'fastly compute serve'.
|
|
37
|
+
|
|
38
|
+
Global Options:
|
|
39
|
+
-h, --help Show this help message and exit.
|
|
40
|
+
`);
|
|
41
|
+
}
|
|
42
|
+
export async function action(actionArgs) {
|
|
43
|
+
// Options after -- go to fastly compute serve.
|
|
44
|
+
const separator = actionArgs.indexOf('--');
|
|
45
|
+
const serveArgs = separator === -1 ? [] : actionArgs.slice(separator + 1);
|
|
46
|
+
const ownArgs = separator === -1 ? actionArgs : actionArgs.slice(0, separator);
|
|
47
|
+
const optionDefinitions = [
|
|
48
|
+
{ name: 'auto-upgrade', type: Boolean },
|
|
49
|
+
];
|
|
50
|
+
const parsed = parseCommandLine(ownArgs, optionDefinitions);
|
|
51
|
+
if (parsed.needHelp) {
|
|
52
|
+
if (parsed.error != null) {
|
|
53
|
+
console.error(String(parsed.error));
|
|
54
|
+
console.error();
|
|
55
|
+
recordFailure('usage', String(parsed.error));
|
|
56
|
+
}
|
|
57
|
+
help();
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const project = await loadManagedProject('dev', `In an ejected app, run 'npm run dev:start'.`);
|
|
61
|
+
if (project == null) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
showTemplateFolderHint(project);
|
|
65
|
+
if (!checkVersionForCommand(project, parsed.commandLineOptions['auto-upgrade'] === true)) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const { appDir } = await prepareManagedApp(path.resolve(), project);
|
|
69
|
+
const result = await serveApp(appDir, serveArgs);
|
|
70
|
+
if (result.error != null) {
|
|
71
|
+
fail('failed', `Could not run 'fastly compute serve': ${String(result.error)}`);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
if (result.status !== 0 && result.signal == null) {
|
|
75
|
+
fail('failed', `'fastly compute serve' exited with ${result.status}.`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eject.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/manage/eject.ts"],"names":[],"mappings":"AA+DA,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,iBAoHhD"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright Fastly, Inc.
|
|
3
|
+
* Licensed under the MIT license. See LICENSE file for details.
|
|
4
|
+
*/
|
|
5
|
+
import child_process from 'node:child_process';
|
|
6
|
+
import fs from 'node:fs';
|
|
7
|
+
import path from 'node:path';
|
|
8
|
+
import { generateApp } from '../scaffold/generate-app.js';
|
|
9
|
+
import { managedAppConfig, writeManagedAppFiles } from '../../managed/app.js';
|
|
10
|
+
import { loadManagedProject } from '../../managed/command-helpers.js';
|
|
11
|
+
import { findNonDataPaths, isScaffoldedPublishContent, renderPublishContentConfig } from '../../managed/eject.js';
|
|
12
|
+
import { THIS_PACKAGE, readTemplateLockfile } from '../../managed/lockfile.js';
|
|
13
|
+
import { parseCommandLine } from '../../util/args.js';
|
|
14
|
+
import { detectProjectMode } from '../../util/config.js';
|
|
15
|
+
import { rootRelative } from '../../util/files.js';
|
|
16
|
+
import { fail, recordFailure } from '../../util/output.js';
|
|
17
|
+
import { getOwnVersion } from '../../util/package.js';
|
|
18
|
+
import { MANAGED_APP_DIR, PROJECT_FILE_NAME, RC_FILE_NAME } from '../../../models/config/static-publish-project.js';
|
|
19
|
+
// An environment variable for the tests of this package only. The tests run a
|
|
20
|
+
// version that is not on npm, so they give here the spec of this package for
|
|
21
|
+
// the ejected app.
|
|
22
|
+
const PACKAGE_SPEC_ENV = 'CJSP_TEST_EJECT_PACKAGE_SPEC';
|
|
23
|
+
function help() {
|
|
24
|
+
console.log(`\
|
|
25
|
+
|
|
26
|
+
Usage:
|
|
27
|
+
npx @fastly/compute-js-static-publish eject [options]
|
|
28
|
+
|
|
29
|
+
Description:
|
|
30
|
+
Converts a managed project into an ejected app, which you own and change:
|
|
31
|
+
- Writes the app that deploy would deploy into ./compute-js (or --dir).
|
|
32
|
+
- Splits ${PROJECT_FILE_NAME} into ${RC_FILE_NAME} and
|
|
33
|
+
publish-content.config.js in that directory, with the paths written again
|
|
34
|
+
so that they point at the same directories. Then deletes ${PROJECT_FILE_NAME}.
|
|
35
|
+
- Pins this package to the version that runs: "^<version>" in package.json,
|
|
36
|
+
exactly <version> in package-lock.json (one 'npm install', which needs the
|
|
37
|
+
npm registry). The version must be published on npm.
|
|
38
|
+
|
|
39
|
+
Eject can copy publishContent only if it is data. If it has functions or
|
|
40
|
+
regular expressions (for example assetInclusionTest), eject stops.
|
|
41
|
+
|
|
42
|
+
Options:
|
|
43
|
+
--dir=<dir> The directory of the ejected app. Default: ./compute-js
|
|
44
|
+
--force Write into the directory also if it exists.
|
|
45
|
+
--fastly-service-id=<id> Written as service_id into fastly.toml. Default:
|
|
46
|
+
FASTLY_SERVICE_ID, then managed.serviceId.
|
|
47
|
+
|
|
48
|
+
Global Options:
|
|
49
|
+
-h, --help Show this help message and exit.
|
|
50
|
+
`);
|
|
51
|
+
}
|
|
52
|
+
function isPublished(version) {
|
|
53
|
+
const result = child_process.spawnSync('npm', ['view', `${THIS_PACKAGE}@${version}`, 'version'], { encoding: 'utf-8' });
|
|
54
|
+
return result.status === 0 && result.stdout.trim() === version;
|
|
55
|
+
}
|
|
56
|
+
export async function action(actionArgs) {
|
|
57
|
+
const optionDefinitions = [
|
|
58
|
+
{ name: 'dir', type: String },
|
|
59
|
+
{ name: 'force', type: Boolean },
|
|
60
|
+
{ name: 'fastly-service-id', type: String },
|
|
61
|
+
];
|
|
62
|
+
const parsed = parseCommandLine(actionArgs, optionDefinitions);
|
|
63
|
+
if (parsed.needHelp) {
|
|
64
|
+
if (parsed.error != null) {
|
|
65
|
+
console.error(String(parsed.error));
|
|
66
|
+
console.error();
|
|
67
|
+
recordFailure('usage', String(parsed.error));
|
|
68
|
+
}
|
|
69
|
+
help();
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
const { dir: dirValue, force, ['fastly-service-id']: fastlyServiceId, } = parsed.commandLineOptions;
|
|
73
|
+
if (detectProjectMode() === 'ejected') {
|
|
74
|
+
fail('usage', 'This app is already ejected.');
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const project = await loadManagedProject('eject', '');
|
|
78
|
+
if (project == null) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const projectDir = path.resolve();
|
|
82
|
+
const appDir = path.resolve(dirValue ?? './compute-js');
|
|
83
|
+
if (appDir === projectDir || !appDir.startsWith(projectDir + path.sep) || appDir.startsWith(path.resolve(MANAGED_APP_DIR))) {
|
|
84
|
+
fail('usage', `--dir must be a directory in the project dir, and not in ${MANAGED_APP_DIR}.`);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
if (fs.existsSync(appDir) && !force) {
|
|
88
|
+
fail('usage', `${rootRelative(appDir)} exists. Use --force to write into it.`);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const nonData = findNonDataPaths(project.publishContent);
|
|
92
|
+
if (nonData.length > 0) {
|
|
93
|
+
fail('usage', `Eject cannot copy functions or regular expressions from publishContent: ${nonData.join(', ')}. ` +
|
|
94
|
+
`Remove them from ${PROJECT_FILE_NAME}, eject, and then add them to publish-content.config.js of the ejected app by hand.`);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
const version = getOwnVersion();
|
|
98
|
+
const testSpec = process.env[PACKAGE_SPEC_ENV];
|
|
99
|
+
if (testSpec == null && !isPublished(version)) {
|
|
100
|
+
fail('version-not-published', `Eject needs a version of ${THIS_PACKAGE} that is published on npm. ${version} is not.`);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
const packageSpec = testSpec ?? `^${version}`;
|
|
104
|
+
const serviceId = (typeof fastlyServiceId === 'string' && fastlyServiceId !== '' ? fastlyServiceId : undefined) ??
|
|
105
|
+
(process.env.FASTLY_SERVICE_ID || undefined) ??
|
|
106
|
+
project.managed.serviceId;
|
|
107
|
+
const managedConfig = await managedAppConfig(projectDir, project, appDir);
|
|
108
|
+
const appConfig = {
|
|
109
|
+
...managedConfig,
|
|
110
|
+
serviceId,
|
|
111
|
+
staticPublishVersionSpec: packageSpec,
|
|
112
|
+
packageLock: undefined,
|
|
113
|
+
generatedFrom: {
|
|
114
|
+
template: managedConfig.template.name,
|
|
115
|
+
staticPublishVersion: version,
|
|
116
|
+
generatedAt: new Date().toISOString().slice(0, 10),
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
const files = generateApp(appConfig);
|
|
120
|
+
// The publish settings: the same file as an ejected scaffold, if the section
|
|
121
|
+
// is what scaffold --managed wrote; else the data of the section.
|
|
122
|
+
if (!isScaffoldedPublishContent(project.publishContent, appConfig, projectDir)) {
|
|
123
|
+
files['publish-content.config.js'] = renderPublishContentConfig(project.publishContent, projectDir, appDir);
|
|
124
|
+
}
|
|
125
|
+
// The template's lockfile, without this package. npm install adds it.
|
|
126
|
+
const lock = readTemplateLockfile(managedConfig.template.name);
|
|
127
|
+
if (appConfig.name != null) {
|
|
128
|
+
lock.name = appConfig.name;
|
|
129
|
+
lock.packages[''] = { ...lock.packages[''], name: appConfig.name };
|
|
130
|
+
}
|
|
131
|
+
files['package-lock.json'] = JSON.stringify(lock, undefined, 2) + '\n';
|
|
132
|
+
console.log(`📦 Writing the app into ${rootRelative(appDir)}...`);
|
|
133
|
+
writeManagedAppFiles(appDir, files);
|
|
134
|
+
// Pin this package: "^<version>" stays in package.json, and the lockfile gets exactly <version>.
|
|
135
|
+
const installArgs = testSpec != null ?
|
|
136
|
+
['install', '--no-audit', '--no-fund'] :
|
|
137
|
+
['install', '--save-dev', `${THIS_PACKAGE}@${version}`, '--no-audit', '--no-fund'];
|
|
138
|
+
console.log(`npm ${installArgs.join(' ')}`);
|
|
139
|
+
const install = child_process.spawnSync('npm', installArgs, { cwd: appDir, stdio: ['ignore', process.stderr, 'inherit'] });
|
|
140
|
+
if (install.error != null || install.status !== 0) {
|
|
141
|
+
fail('failed', `npm install failed in ${rootRelative(appDir)}. ${PROJECT_FILE_NAME} was not changed. Fix the problem, and run eject again with --force.`);
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
fs.rmSync(path.resolve(projectDir, PROJECT_FILE_NAME));
|
|
145
|
+
console.log(`
|
|
146
|
+
🎉 Ejected into ${rootRelative(appDir)}. You now own the app and its upgrades (see MIGRATING.md).
|
|
147
|
+
|
|
148
|
+
- ${PROJECT_FILE_NAME} is deleted. ${rootRelative(appDir)}/${RC_FILE_NAME} and publish-content.config.js have its settings.
|
|
149
|
+
Commit ${rootRelative(appDir)}.
|
|
150
|
+
- Run the commands of this CLI in ${rootRelative(appDir)} now.
|
|
151
|
+
- You can delete ${MANAGED_APP_DIR}/. The line '/.static-publish/' in .gitignore is not needed any more.
|
|
152
|
+
- The working directory stays where it was. Run 'publish-content --local' again before 'npm run dev:start',
|
|
153
|
+
because the local KV Store has paths relative to the app.
|
|
154
|
+
`);
|
|
155
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/manage/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/manage/index.ts"],"names":[],"mappings":"AAqFA,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,iBAmChD"}
|
|
@@ -3,7 +3,14 @@
|
|
|
3
3
|
* Licensed under the MIT license. See LICENSE file for details.
|
|
4
4
|
*/
|
|
5
5
|
import { getCommandAndArgs } from '../../util/args.js';
|
|
6
|
+
import { fail, isJsonMode, recordFailure } from '../../util/output.js';
|
|
6
7
|
import * as cleanCommand from './clean.js';
|
|
8
|
+
import * as deployCommand from './deploy.js';
|
|
9
|
+
import * as devCommand from './dev.js';
|
|
10
|
+
import * as ejectCommand from './eject.js';
|
|
11
|
+
import * as statusCommand from './status.js';
|
|
12
|
+
import * as templateCommands from './template/index.js';
|
|
13
|
+
import * as upgradeCommand from './upgrade.js';
|
|
7
14
|
import * as publishContentCommand from './publish-content.js';
|
|
8
15
|
import * as collectionsCommands from './collections/index.js';
|
|
9
16
|
function help() {
|
|
@@ -24,6 +31,13 @@ Available Commands:
|
|
|
24
31
|
collections delete Delete a specific collection index
|
|
25
32
|
collections promote Copy a collection to another name
|
|
26
33
|
collections update-expiration Modify expiration time for an existing collection
|
|
34
|
+
dev Run the app of a managed project locally
|
|
35
|
+
status Show the state of the app, and if a deploy is necessary
|
|
36
|
+
deploy Deploy the app of a managed project, if it changed
|
|
37
|
+
upgrade Move a managed project to the version of this CLI
|
|
38
|
+
eject Convert a managed project into an ejected app
|
|
39
|
+
template init Make or update the folder of the app's template
|
|
40
|
+
(for the hono template: hono-extensions/)
|
|
27
41
|
|
|
28
42
|
KV Store Options:
|
|
29
43
|
--local Instead of working with the Fastly KV Store, operate on
|
|
@@ -42,6 +56,17 @@ S3 Storage Options (BETA):
|
|
|
42
56
|
and S3_SECRET_ACCESS_KEY environment variables.
|
|
43
57
|
|
|
44
58
|
Global Options:
|
|
59
|
+
--project-dir=<dir> Run the command for the app in <dir>, the directory
|
|
60
|
+
that has static-publish.rc.js or static-publish.project.js.
|
|
61
|
+
Relative paths, also in other options, are then
|
|
62
|
+
relative to <dir>.
|
|
63
|
+
--version Print the version of this package and exit.
|
|
64
|
+
--non-interactive Never ask a question. Missing input is an error.
|
|
65
|
+
This is also on when the CI environment variable is set.
|
|
66
|
+
--json Write the result as one JSON object to stdout, and
|
|
67
|
+
the log to stderr. For publish-content,
|
|
68
|
+
collections list/delete/promote, status, deploy,
|
|
69
|
+
and --version.
|
|
45
70
|
-h, --help Show this help message and exit.
|
|
46
71
|
|
|
47
72
|
Automatic Project Initialization:
|
|
@@ -52,13 +77,20 @@ Examples:
|
|
|
52
77
|
npx @fastly/compute-js-static-publish publish-content --collection-name=live
|
|
53
78
|
npx @fastly/compute-js-static-publish collections list
|
|
54
79
|
npx @fastly/compute-js-static-publish clean --dry-run
|
|
80
|
+
npx @fastly/compute-js-static-publish publish-content --project-dir=./compute-js
|
|
55
81
|
`);
|
|
56
82
|
}
|
|
57
83
|
export async function action(actionArgs) {
|
|
58
84
|
const modes = {
|
|
59
85
|
'clean': cleanCommand,
|
|
86
|
+
'deploy': deployCommand,
|
|
87
|
+
'dev': devCommand,
|
|
88
|
+
'eject': ejectCommand,
|
|
89
|
+
'status': statusCommand,
|
|
90
|
+
'upgrade': upgradeCommand,
|
|
60
91
|
'publish-content': publishContentCommand,
|
|
61
92
|
'collections': collectionsCommands,
|
|
93
|
+
'template': templateCommands,
|
|
62
94
|
};
|
|
63
95
|
const commandAndArgs = getCommandAndArgs(actionArgs, modes);
|
|
64
96
|
if (commandAndArgs.needHelp) {
|
|
@@ -66,11 +98,15 @@ export async function action(actionArgs) {
|
|
|
66
98
|
console.error(commandAndArgs.error);
|
|
67
99
|
console.error(`Specify one of the following commands: ${Object.keys(modes).join(', ')}`);
|
|
68
100
|
console.error();
|
|
69
|
-
|
|
101
|
+
recordFailure('usage', commandAndArgs.error);
|
|
70
102
|
}
|
|
71
103
|
help();
|
|
72
104
|
return;
|
|
73
105
|
}
|
|
74
106
|
const { command, argv, } = commandAndArgs;
|
|
107
|
+
if (isJsonMode() && !['publish-content', 'collections', 'status', 'deploy'].includes(command)) {
|
|
108
|
+
fail('json-not-supported', `--json is not supported for '${command}'.`);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
75
111
|
await modes[command].action(argv);
|
|
76
112
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publish-content.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/manage/publish-content.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"publish-content.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/manage/publish-content.ts"],"names":[],"mappings":"AAgJA,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,iBAqmBhD"}
|