@fastly/compute-js-static-publish 7.0.0-beta.0 → 7.0.0-beta.2
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/README.md +2 -2
- package/README.short.md +2 -2
- package/build/cli/commands/manage/clean.d.ts +2 -0
- package/build/cli/commands/manage/clean.d.ts.map +1 -0
- package/build/cli/commands/manage/clean.js +201 -0
- package/build/cli/commands/manage/collections/delete.d.ts +2 -0
- package/build/cli/commands/manage/collections/delete.d.ts.map +1 -0
- package/build/cli/commands/{collections → manage/collections}/delete.js +56 -25
- package/build/cli/commands/manage/collections/index.d.ts.map +1 -0
- package/build/cli/commands/{collections → manage/collections}/index.js +27 -22
- package/build/cli/commands/manage/collections/list.d.ts +2 -0
- package/build/cli/commands/manage/collections/list.d.ts.map +1 -0
- package/build/cli/commands/manage/collections/list.js +133 -0
- package/build/cli/commands/manage/collections/promote.d.ts +2 -0
- package/build/cli/commands/manage/collections/promote.d.ts.map +1 -0
- package/build/cli/commands/manage/collections/promote.js +153 -0
- package/build/cli/commands/manage/collections/update-expiration.d.ts +2 -0
- package/build/cli/commands/manage/collections/update-expiration.d.ts.map +1 -0
- package/build/cli/commands/manage/collections/update-expiration.js +129 -0
- package/build/cli/commands/manage/index.d.ts.map +1 -0
- package/build/cli/commands/{index.js → manage/index.js} +26 -29
- package/build/cli/commands/manage/publish-content.d.ts +2 -0
- package/build/cli/commands/manage/publish-content.d.ts.map +1 -0
- package/build/cli/commands/{publish-content.js → manage/publish-content.js} +142 -56
- package/build/cli/commands/{init-app.d.ts → scaffold/index.d.ts} +2 -2
- package/build/cli/commands/scaffold/index.d.ts.map +1 -0
- package/build/cli/commands/{init-app.js → scaffold/index.js} +79 -25
- package/build/cli/fastly-api/api-token.d.ts.map +1 -1
- package/build/cli/fastly-api/api-token.js +7 -1
- package/build/cli/fastly-api/kv-store.d.ts +2 -2
- package/build/cli/fastly-api/kv-store.d.ts.map +1 -1
- package/build/cli/fastly-api/kv-store.js +2 -2
- package/build/cli/index.js +11 -3
- package/build/cli/util/args.d.ts +16 -2
- package/build/cli/util/args.d.ts.map +1 -1
- package/build/cli/util/args.js +32 -6
- package/build/cli/util/fastly-toml.d.ts +2 -0
- package/build/cli/util/fastly-toml.d.ts.map +1 -0
- package/build/cli/util/fastly-toml.js +15 -0
- package/build/cli/util/kv-store-items.d.ts +3 -2
- package/build/cli/util/kv-store-items.d.ts.map +1 -1
- package/build/cli/util/kv-store-items.js +6 -12
- package/build/cli/util/node.d.ts +2 -0
- package/build/cli/util/node.d.ts.map +1 -0
- package/build/cli/util/node.js +10 -0
- package/build/models/server/index.d.ts +5 -0
- package/build/models/server/index.d.ts.map +1 -0
- package/build/models/server/index.js +1 -0
- package/build/models/time/index.d.ts +7 -0
- package/build/models/time/index.d.ts.map +1 -0
- package/build/models/time/index.js +51 -0
- package/build/server/publisher-server/index.d.ts +2 -0
- package/build/server/publisher-server/index.d.ts.map +1 -1
- package/build/server/publisher-server/index.js +38 -4
- package/package.json +3 -2
- package/build/cli/commands/clean.d.ts +0 -2
- package/build/cli/commands/clean.d.ts.map +0 -1
- package/build/cli/commands/clean.js +0 -121
- package/build/cli/commands/collections/delete.d.ts +0 -2
- package/build/cli/commands/collections/delete.d.ts.map +0 -1
- package/build/cli/commands/collections/index.d.ts.map +0 -1
- package/build/cli/commands/collections/list.d.ts +0 -2
- package/build/cli/commands/collections/list.d.ts.map +0 -1
- package/build/cli/commands/collections/list.js +0 -62
- package/build/cli/commands/index.d.ts.map +0 -1
- package/build/cli/commands/init-app.d.ts.map +0 -1
- package/build/cli/commands/publish-content.d.ts +0 -2
- package/build/cli/commands/publish-content.d.ts.map +0 -1
- /package/build/cli/commands/{collections → manage/collections}/index.d.ts +0 -0
- /package/build/cli/commands/{index.d.ts → manage/index.d.ts} +0 -0
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright Fastly, Inc.
|
|
3
|
+
* Licensed under the MIT license. See LICENSE file for details.
|
|
4
|
+
*/
|
|
5
|
+
import { calcExpirationTime } from '../../../../models/time/index.js';
|
|
6
|
+
import { LoadConfigError, loadStaticPublisherRcFile } from '../../../util/config.js';
|
|
7
|
+
import { getKvStoreEntry, kvStoreSubmitEntry, } from '../../../fastly-api/kv-store.js';
|
|
8
|
+
import { loadApiToken } from '../../../fastly-api/api-token.js';
|
|
9
|
+
import { parseCommandLine } from '../../../util/args.js';
|
|
10
|
+
function help() {
|
|
11
|
+
console.log(`\
|
|
12
|
+
|
|
13
|
+
Usage:
|
|
14
|
+
npx @fastly/compute-js-static-publish collections promote \\
|
|
15
|
+
--collection-name <name> \\
|
|
16
|
+
--to <name> \\
|
|
17
|
+
[options]
|
|
18
|
+
|
|
19
|
+
Description:
|
|
20
|
+
Copies an existing collection (content + config) to a new collection name.
|
|
21
|
+
|
|
22
|
+
Options:
|
|
23
|
+
--collection-name <name> (Required) The name of the collection to promote
|
|
24
|
+
--to <name> (Required) The name of the new (target) collection to create or overwrite
|
|
25
|
+
--expires-in <duration> Set new expiration relative to now (e.g., 7d, 1h).
|
|
26
|
+
--expires-at <timestamp> Set new expiration using an absolute ISO 8601 timestamp.
|
|
27
|
+
|
|
28
|
+
--fastly-api-token <token> Fastly API token used for KV Store access. If not provided,
|
|
29
|
+
the tool will try:
|
|
30
|
+
1. FASTLY_API_TOKEN environment variable
|
|
31
|
+
2. fastly profile token (via CLI)
|
|
32
|
+
-h, --help Show help for this command.
|
|
33
|
+
`);
|
|
34
|
+
}
|
|
35
|
+
export async function action(actionArgs) {
|
|
36
|
+
const optionDefinitions = [
|
|
37
|
+
{ name: 'verbose', type: Boolean },
|
|
38
|
+
{ name: 'collection-name', type: String },
|
|
39
|
+
{ name: 'to', type: String },
|
|
40
|
+
{ name: 'expires-in', type: String },
|
|
41
|
+
{ name: 'expires-at', type: String },
|
|
42
|
+
{ name: 'fastly-api-token', type: String, },
|
|
43
|
+
];
|
|
44
|
+
const parsed = parseCommandLine(actionArgs, optionDefinitions);
|
|
45
|
+
if (parsed.needHelp) {
|
|
46
|
+
if (parsed.error != null) {
|
|
47
|
+
console.error(String(parsed.error));
|
|
48
|
+
console.error();
|
|
49
|
+
process.exitCode = 1;
|
|
50
|
+
}
|
|
51
|
+
help();
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const { verbose, ['collection-name']: collectionNameValue, ['to']: toCollectionNameValue, ['expires-in']: expiresIn, ['expires-at']: expiresAt, ['fastly-api-token']: fastlyApiToken, } = parsed.commandLineOptions;
|
|
55
|
+
if (collectionNameValue == null) {
|
|
56
|
+
console.error("❌ Required argument '--collection-name' not specified.");
|
|
57
|
+
process.exitCode = 1;
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (toCollectionNameValue == null) {
|
|
61
|
+
console.error("❌ Required argument '--to' not specified.");
|
|
62
|
+
process.exitCode = 1;
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const apiTokenResult = loadApiToken({ commandLine: fastlyApiToken });
|
|
66
|
+
if (apiTokenResult == null) {
|
|
67
|
+
console.error("❌ Fastly API Token not provided.");
|
|
68
|
+
console.error("Set the FASTLY_API_TOKEN environment variable to an API token that has write access to the KV Store.");
|
|
69
|
+
process.exitCode = 1;
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
const fastlyApiContext = { apiToken: apiTokenResult.apiToken };
|
|
73
|
+
console.log(`✔️ Fastly API Token: ${fastlyApiContext.apiToken.slice(0, 4)}${'*'.repeat(fastlyApiContext.apiToken.length - 4)} from '${apiTokenResult.source}'`);
|
|
74
|
+
// #### load config
|
|
75
|
+
let staticPublisherRc;
|
|
76
|
+
try {
|
|
77
|
+
staticPublisherRc = await loadStaticPublisherRcFile();
|
|
78
|
+
}
|
|
79
|
+
catch (err) {
|
|
80
|
+
console.error("❌ Can't load static-publish.rc.js");
|
|
81
|
+
console.error("Run this from a compute-js-static-publish compute-js directory.");
|
|
82
|
+
if (err instanceof LoadConfigError) {
|
|
83
|
+
for (const error of err.errors) {
|
|
84
|
+
console.error(error);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
process.exitCode = 1;
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
let expirationTime;
|
|
91
|
+
try {
|
|
92
|
+
expirationTime = calcExpirationTime({ expiresIn, expiresAt });
|
|
93
|
+
}
|
|
94
|
+
catch (err) {
|
|
95
|
+
console.error(`❌ Cannot process expiration time`);
|
|
96
|
+
console.error(String(err));
|
|
97
|
+
process.exitCode = 1;
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
const publishId = staticPublisherRc.publishId;
|
|
101
|
+
console.log(` | Publish ID: ${publishId}`);
|
|
102
|
+
const kvStoreName = staticPublisherRc.kvStoreName;
|
|
103
|
+
console.log(` | Using KV Store: ${kvStoreName}`);
|
|
104
|
+
const defaultCollectionName = staticPublisherRc.defaultCollectionName;
|
|
105
|
+
console.log(` | Default Collection Name: ${defaultCollectionName}`);
|
|
106
|
+
const sourceCollectionName = collectionNameValue;
|
|
107
|
+
console.log(`✔️ Collection to copy: ${sourceCollectionName}`);
|
|
108
|
+
const targetCollectionName = toCollectionNameValue;
|
|
109
|
+
console.log(`✔️ Collection to promote to: ${targetCollectionName}`);
|
|
110
|
+
if (expirationTime != null) {
|
|
111
|
+
console.log(`✔️ Updating expiration timestamp: ${new Date(expirationTime * 1000).toISOString()}`);
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
console.log(`✔️ Not updating expiration timestamp.`);
|
|
115
|
+
}
|
|
116
|
+
if (targetCollectionName === defaultCollectionName && expirationTime != null) {
|
|
117
|
+
console.log(` ⚠️ NOTE: Expiration time not enforced for default collection.`);
|
|
118
|
+
}
|
|
119
|
+
const sourceCollectionIndexKey = `${publishId}_index_${sourceCollectionName}`;
|
|
120
|
+
const targetCollectionIndexKey = `${publishId}_index_${targetCollectionName}`;
|
|
121
|
+
const sourceCollectionSettingsKey = `${publishId}_settings_${collectionNameValue}`;
|
|
122
|
+
const targetCollectionSettingsKey = `${publishId}_settings_${targetCollectionName}`;
|
|
123
|
+
const [indexEntryInfo, settingsEntryInfo] = await Promise.all([
|
|
124
|
+
getKvStoreEntry(fastlyApiContext, kvStoreName, sourceCollectionIndexKey),
|
|
125
|
+
getKvStoreEntry(fastlyApiContext, kvStoreName, sourceCollectionSettingsKey),
|
|
126
|
+
]);
|
|
127
|
+
if (!indexEntryInfo) {
|
|
128
|
+
throw new Error(`Error querying index for '${collectionNameValue}' in KV Store`);
|
|
129
|
+
}
|
|
130
|
+
if (!settingsEntryInfo) {
|
|
131
|
+
throw new Error(`Error querying settings for '${collectionNameValue}' in KV Store`);
|
|
132
|
+
}
|
|
133
|
+
let indexMetadata = {};
|
|
134
|
+
if (indexEntryInfo.metadata != null) {
|
|
135
|
+
try {
|
|
136
|
+
indexMetadata = JSON.parse(indexEntryInfo.metadata);
|
|
137
|
+
}
|
|
138
|
+
catch {
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
if (indexMetadata.publishedTime == null) {
|
|
142
|
+
indexMetadata.publishedTime = Math.floor(Date.now() / 1000);
|
|
143
|
+
}
|
|
144
|
+
if (expirationTime != null) {
|
|
145
|
+
indexMetadata.expirationTime = expirationTime;
|
|
146
|
+
}
|
|
147
|
+
console.log(`Uploading to KV Store: '${targetCollectionName}'`);
|
|
148
|
+
await Promise.all([
|
|
149
|
+
kvStoreSubmitEntry(fastlyApiContext, kvStoreName, targetCollectionIndexKey, indexEntryInfo.response.body, JSON.stringify(indexMetadata)),
|
|
150
|
+
kvStoreSubmitEntry(fastlyApiContext, kvStoreName, targetCollectionSettingsKey, settingsEntryInfo.response.body, undefined),
|
|
151
|
+
]);
|
|
152
|
+
console.log("✅ Completed.");
|
|
153
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-expiration.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/manage/collections/update-expiration.ts"],"names":[],"mappings":"AAuCA,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,iBAuHhD"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright Fastly, Inc.
|
|
3
|
+
* Licensed under the MIT license. See LICENSE file for details.
|
|
4
|
+
*/
|
|
5
|
+
import { calcExpirationTime } from '../../../../models/time/index.js';
|
|
6
|
+
import { LoadConfigError, loadStaticPublisherRcFile } from '../../../util/config.js';
|
|
7
|
+
import { getKvStoreEntry, kvStoreSubmitEntry, } from '../../../fastly-api/kv-store.js';
|
|
8
|
+
import { loadApiToken } from '../../../fastly-api/api-token.js';
|
|
9
|
+
import { parseCommandLine } from '../../../util/args.js';
|
|
10
|
+
function help() {
|
|
11
|
+
console.log(`\
|
|
12
|
+
|
|
13
|
+
Usage:
|
|
14
|
+
npx @fastly/compute-js-static-publish collections update-expiration [options]
|
|
15
|
+
|
|
16
|
+
Description:
|
|
17
|
+
Updates the expiration time of an existing collection.
|
|
18
|
+
|
|
19
|
+
Options:
|
|
20
|
+
--collection-name <name> (Required) The name of the collection to modify
|
|
21
|
+
--expires-in <duration> Set new expiration relative to now (e.g., 7d, 1h)
|
|
22
|
+
--expires-at <timestamp> Set new expiration using an absolute ISO 8601 timestamp
|
|
23
|
+
|
|
24
|
+
--fastly-api-token <token> Fastly API token used for KV Store access. If not provided,
|
|
25
|
+
the tool will try:
|
|
26
|
+
1. FASTLY_API_TOKEN environment variable
|
|
27
|
+
2. fastly profile token (via CLI)
|
|
28
|
+
-h, --help Show help for this command.
|
|
29
|
+
`);
|
|
30
|
+
}
|
|
31
|
+
export async function action(actionArgs) {
|
|
32
|
+
const optionDefinitions = [
|
|
33
|
+
{ name: 'verbose', type: Boolean },
|
|
34
|
+
{ name: 'collection-name', type: String, },
|
|
35
|
+
{ name: 'expires-in', type: String },
|
|
36
|
+
{ name: 'expires-at', type: String },
|
|
37
|
+
{ name: 'fastly-api-token', type: String, },
|
|
38
|
+
];
|
|
39
|
+
const parsed = parseCommandLine(actionArgs, optionDefinitions);
|
|
40
|
+
if (parsed.needHelp) {
|
|
41
|
+
if (parsed.error != null) {
|
|
42
|
+
console.error(String(parsed.error));
|
|
43
|
+
console.error();
|
|
44
|
+
process.exitCode = 1;
|
|
45
|
+
}
|
|
46
|
+
help();
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const { verbose, ['collection-name']: collectionNameValue, ['expires-in']: expiresIn, ['expires-at']: expiresAt, ['fastly-api-token']: fastlyApiToken, } = parsed.commandLineOptions;
|
|
50
|
+
if (collectionNameValue == null) {
|
|
51
|
+
console.error("❌ Required argument '--collection-name' not specified.");
|
|
52
|
+
process.exitCode = 1;
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const apiTokenResult = loadApiToken({ commandLine: fastlyApiToken });
|
|
56
|
+
if (apiTokenResult == null) {
|
|
57
|
+
console.error("❌ Fastly API Token not provided.");
|
|
58
|
+
console.error("Set the FASTLY_API_TOKEN environment variable to an API token that has write access to the KV Store.");
|
|
59
|
+
process.exitCode = 1;
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const fastlyApiContext = { apiToken: apiTokenResult.apiToken };
|
|
63
|
+
console.log(`✔️ Fastly API Token: ${fastlyApiContext.apiToken.slice(0, 4)}${'*'.repeat(fastlyApiContext.apiToken.length - 4)} from '${apiTokenResult.source}'`);
|
|
64
|
+
// #### load config
|
|
65
|
+
let staticPublisherRc;
|
|
66
|
+
try {
|
|
67
|
+
staticPublisherRc = await loadStaticPublisherRcFile();
|
|
68
|
+
}
|
|
69
|
+
catch (err) {
|
|
70
|
+
console.error("❌ Can't load static-publish.rc.js");
|
|
71
|
+
console.error("Run this from a compute-js-static-publish compute-js directory.");
|
|
72
|
+
if (err instanceof LoadConfigError) {
|
|
73
|
+
for (const error of err.errors) {
|
|
74
|
+
console.error(error);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
process.exitCode = 1;
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
let expirationTime;
|
|
81
|
+
try {
|
|
82
|
+
expirationTime = calcExpirationTime({ expiresIn, expiresAt });
|
|
83
|
+
}
|
|
84
|
+
catch (err) {
|
|
85
|
+
console.error(`❌ Cannot process expiration time`);
|
|
86
|
+
console.error(String(err));
|
|
87
|
+
process.exitCode = 1;
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
const publishId = staticPublisherRc.publishId;
|
|
91
|
+
console.log(` | Publish ID: ${publishId}`);
|
|
92
|
+
const kvStoreName = staticPublisherRc.kvStoreName;
|
|
93
|
+
console.log(` | Using KV Store: ${kvStoreName}`);
|
|
94
|
+
const defaultCollectionName = staticPublisherRc.defaultCollectionName;
|
|
95
|
+
console.log(` | Default Collection Name: ${defaultCollectionName}`);
|
|
96
|
+
const collectionName = collectionNameValue;
|
|
97
|
+
console.log(`✔️ Collection to update: ${collectionName}`);
|
|
98
|
+
if (expirationTime != null) {
|
|
99
|
+
console.log(`✔️ Updating expiration timestamp: ${new Date(expirationTime * 1000).toISOString()}`);
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
console.log(`✔️ Not updating expiration timestamp.`);
|
|
103
|
+
}
|
|
104
|
+
if (collectionName === defaultCollectionName && expirationTime != null) {
|
|
105
|
+
console.log(` ⚠️ NOTE: Expiration time not enforced for default collection.`);
|
|
106
|
+
}
|
|
107
|
+
const collectionIndexKey = `${publishId}_index_${collectionName}`;
|
|
108
|
+
const indexEntryInfo = await getKvStoreEntry(fastlyApiContext, kvStoreName, collectionIndexKey);
|
|
109
|
+
if (!indexEntryInfo) {
|
|
110
|
+
throw new Error(`Error querying index for '${collectionNameValue}' in KV Store`);
|
|
111
|
+
}
|
|
112
|
+
let indexMetadata = {};
|
|
113
|
+
if (indexEntryInfo.metadata != null) {
|
|
114
|
+
try {
|
|
115
|
+
indexMetadata = JSON.parse(indexEntryInfo.metadata);
|
|
116
|
+
}
|
|
117
|
+
catch {
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
if (indexMetadata.publishedTime == null) {
|
|
121
|
+
indexMetadata.publishedTime = Math.floor(Date.now() / 1000);
|
|
122
|
+
}
|
|
123
|
+
if (expirationTime != null) {
|
|
124
|
+
indexMetadata.expirationTime = expirationTime;
|
|
125
|
+
}
|
|
126
|
+
console.log(`Uploading to KV Store: '${collectionName}'`);
|
|
127
|
+
await kvStoreSubmitEntry(fastlyApiContext, kvStoreName, collectionIndexKey, indexEntryInfo.response.body, JSON.stringify(indexMetadata));
|
|
128
|
+
console.log("✅ Completed.");
|
|
129
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/manage/index.ts"],"names":[],"mappings":"AA+CA,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,iBAyBhD"}
|
|
@@ -2,34 +2,10 @@
|
|
|
2
2
|
* Copyright Fastly, Inc.
|
|
3
3
|
* Licensed under the MIT license. See LICENSE file for details.
|
|
4
4
|
*/
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import * as
|
|
8
|
-
import * as
|
|
9
|
-
import * as collections from './collections/index.js';
|
|
10
|
-
export async function action(actionArgs) {
|
|
11
|
-
if (!fs.existsSync('./static-publish.rc.js')) {
|
|
12
|
-
await initApp.action(actionArgs);
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
const modes = {
|
|
16
|
-
'publish-content': publishContent,
|
|
17
|
-
'collections': collections,
|
|
18
|
-
};
|
|
19
|
-
const commandAndArgs = getCommandAndArgs(actionArgs, Object.keys(modes));
|
|
20
|
-
if (commandAndArgs.needHelp) {
|
|
21
|
-
if (commandAndArgs.command != null) {
|
|
22
|
-
console.error(`Unknown command: ${commandAndArgs.command}`);
|
|
23
|
-
console.error(`Specify one of: ${Object.keys(modes).join(', ')}`);
|
|
24
|
-
console.error();
|
|
25
|
-
process.exitCode = 1;
|
|
26
|
-
}
|
|
27
|
-
help();
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
const { command, argv, } = commandAndArgs;
|
|
31
|
-
await modes[command].action(argv);
|
|
32
|
-
}
|
|
5
|
+
import { getCommandAndArgs } from '../../util/args.js';
|
|
6
|
+
import * as cleanCommand from './clean.js';
|
|
7
|
+
import * as publishContentCommand from './publish-content.js';
|
|
8
|
+
import * as collectionsCommands from './collections/index.js';
|
|
33
9
|
function help() {
|
|
34
10
|
console.log(`\
|
|
35
11
|
|
|
@@ -38,7 +14,8 @@ Usage:
|
|
|
38
14
|
|
|
39
15
|
Description:
|
|
40
16
|
Manage and publish static content to Fastly Compute using KV Store-backed collections.
|
|
41
|
-
|
|
17
|
+
|
|
18
|
+
Note: If run outside a scaffolded project, this tool will automatically enter scaffolding mode.
|
|
42
19
|
|
|
43
20
|
Available Commands:
|
|
44
21
|
publish-content Publish static files to the KV Store under a named collection
|
|
@@ -65,3 +42,23 @@ Examples:
|
|
|
65
42
|
npx @fastly/compute-js-static-publish clean --dry-run
|
|
66
43
|
`);
|
|
67
44
|
}
|
|
45
|
+
export async function action(actionArgs) {
|
|
46
|
+
const modes = {
|
|
47
|
+
'clean': cleanCommand,
|
|
48
|
+
'publish-content': publishContentCommand,
|
|
49
|
+
'collections': collectionsCommands,
|
|
50
|
+
};
|
|
51
|
+
const commandAndArgs = getCommandAndArgs(actionArgs, modes);
|
|
52
|
+
if (commandAndArgs.needHelp) {
|
|
53
|
+
if (commandAndArgs.command != null) {
|
|
54
|
+
console.error(`Unknown command: ${commandAndArgs.command}`);
|
|
55
|
+
console.error(`Specify one of: ${Object.keys(modes).join(', ')}`);
|
|
56
|
+
console.error();
|
|
57
|
+
process.exitCode = 1;
|
|
58
|
+
}
|
|
59
|
+
help();
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const { command, argv, } = commandAndArgs;
|
|
63
|
+
await modes[command].action(argv);
|
|
64
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publish-content.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/manage/publish-content.ts"],"names":[],"mappings":"AAuEA,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,iBAomBhD"}
|