@fastly/compute-js-static-publish 7.0.0-beta.3 → 7.0.0-beta.5

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.
@@ -1 +1 @@
1
- {"version":3,"file":"clean.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/manage/clean.ts"],"names":[],"mappings":"AAsDA,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,iBA6ShD"}
1
+ {"version":3,"file":"clean.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/manage/clean.ts"],"names":[],"mappings":"AA0DA,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,iBA6ShD"}
@@ -4,14 +4,14 @@
4
4
  */
5
5
  import path from 'node:path';
6
6
  import { isExpired } from '../../../models/time/index.js';
7
- import { LoadConfigError, loadStaticPublisherRcFile } from '../../util/config.js';
8
- import { getKvStoreEntry, getKVStoreKeys, kvStoreDeleteEntry } from '../../util/kv-store.js';
9
7
  import { loadApiToken } from '../../util/api-token.js';
10
8
  import { parseCommandLine } from '../../util/args.js';
9
+ import { LoadConfigError, loadStaticPublisherRcFile } from '../../util/config.js';
11
10
  import { readServiceId } from '../../util/fastly-toml.js';
12
- import { doKvStoreItemsOperation } from "../../util/kv-store-items.js";
11
+ import { getKvStoreEntry, getKVStoreKeys, kvStoreDeleteEntry, } from '../../util/kv-store.js';
12
+ import { doKvStoreItemsOperation } from '../../util/kv-store-items.js';
13
+ import { getLocalKvStoreEntry, getLocalKVStoreKeys, localKvStoreDeleteEntry, } from '../../util/kv-store-local-server.js';
13
14
  import { isNodeError } from '../../util/node.js';
14
- import { getLocalKvStoreEntry, getLocalKVStoreKeys, localKvStoreDeleteEntry } from "../../util/kv-store-local-server.js";
15
15
  function help() {
16
16
  console.log(`\
17
17
 
@@ -20,7 +20,7 @@ Usage:
20
20
 
21
21
  Description:
22
22
  Cleans up expired or unreferenced items in the Fastly KV Store.
23
- This includes expired collection indexes and orphaned content assets.
23
+ This can include expired collection indexes and orphaned content assets.
24
24
 
25
25
  Options:
26
26
  --delete-expired-collections If set, expired collection index files will be deleted.
@@ -18,8 +18,8 @@ Usage:
18
18
  npx @fastly/compute-js-static-publish collections delete --collection-name=<name> [options]
19
19
 
20
20
  Description:
21
- Deletes a collection index from the KV Store. The content files will remain but will no
22
- longer be referenced.
21
+ Deletes a collection index from the KV Store. The content files will remain as they may still
22
+ be referenced by other collection indexes.
23
23
 
24
24
  Use the 'npx @fastly/compute-js-static-publish clean' command afterward to remove content
25
25
  files that are no longer referenced by any collection.
@@ -49,9 +49,9 @@ export async function action(actionArgs) {
49
49
  };
50
50
  const commandAndArgs = getCommandAndArgs(actionArgs, modes);
51
51
  if (commandAndArgs.needHelp) {
52
- if (commandAndArgs.command != null) {
53
- console.error(`Unknown subcommand: ${commandAndArgs.command}`);
54
- console.error(`Specify one of: ${Object.keys(modes).join(', ')}`);
52
+ if (commandAndArgs.error != null) {
53
+ console.error(commandAndArgs.error);
54
+ console.error(`Specify one of the following sub-commands: ${Object.keys(modes).join(', ')}`);
55
55
  console.error();
56
56
  process.exitCode = 1;
57
57
  }
@@ -1 +1 @@
1
- {"version":3,"file":"promote.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/manage/collections/promote.ts"],"names":[],"mappings":"AAkEA,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,iBAyOhD"}
1
+ {"version":3,"file":"promote.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/manage/collections/promote.ts"],"names":[],"mappings":"AAmEA,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,iBAyOhD"}
@@ -2,6 +2,7 @@
2
2
  * Copyright Fastly, Inc.
3
3
  * Licensed under the MIT license. See LICENSE file for details.
4
4
  */
5
+ import fs from 'node:fs';
5
6
  import { calcExpirationTime } from '../../../../models/time/index.js';
6
7
  import { LoadConfigError, loadStaticPublisherRcFile } from '../../../util/config.js';
7
8
  import { getKvStoreEntry, kvStoreSubmitEntry, } from '../../../util/kv-store.js';
@@ -11,7 +12,6 @@ import path from "node:path";
11
12
  import { readServiceId } from "../../../util/fastly-toml.js";
12
13
  import { isNodeError } from "../../../util/node.js";
13
14
  import { getLocalKvStoreEntry, localKvStoreSubmitEntry } from "../../../util/kv-store-local-server.js";
14
- import fs from "node:fs";
15
15
  function help() {
16
16
  console.log(`\
17
17
 
@@ -1 +1 @@
1
- {"version":3,"file":"update-expiration.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/manage/collections/update-expiration.ts"],"names":[],"mappings":"AA8DA,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,iBA2MhD"}
1
+ {"version":3,"file":"update-expiration.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/manage/collections/update-expiration.ts"],"names":[],"mappings":"AAkEA,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,iBA2MhD"}
@@ -2,16 +2,16 @@
2
2
  * Copyright Fastly, Inc.
3
3
  * Licensed under the MIT license. See LICENSE file for details.
4
4
  */
5
+ import fs from 'node:fs';
6
+ import path from 'node:path';
5
7
  import { calcExpirationTime } from '../../../../models/time/index.js';
6
- import { LoadConfigError, loadStaticPublisherRcFile } from '../../../util/config.js';
7
- import { getKvStoreEntry, kvStoreSubmitEntry, } from '../../../util/kv-store.js';
8
8
  import { loadApiToken } from '../../../util/api-token.js';
9
+ import { LoadConfigError, loadStaticPublisherRcFile } from '../../../util/config.js';
9
10
  import { parseCommandLine } from '../../../util/args.js';
10
- import { readServiceId } from "../../../util/fastly-toml.js";
11
- import { isNodeError } from "../../../util/node.js";
12
- import path from "node:path";
13
- import fs from "node:fs";
14
- import { getLocalKvStoreEntry, localKvStoreSubmitEntry } from "../../../util/kv-store-local-server.js";
11
+ import { readServiceId } from '../../../util/fastly-toml.js';
12
+ import { getKvStoreEntry, kvStoreSubmitEntry, } from '../../../util/kv-store.js';
13
+ import { getLocalKvStoreEntry, localKvStoreSubmitEntry, } from '../../../util/kv-store-local-server.js';
14
+ import { isNodeError } from '../../../util/node.js';
15
15
  function help() {
16
16
  console.log(`\
17
17
 
@@ -21,7 +21,7 @@ Usage:
21
21
  [options]
22
22
 
23
23
  Description:
24
- Updates the expiration time of an existing collection.
24
+ Sets or updates the expiration time of an existing collection.
25
25
 
26
26
  Required:
27
27
  --collection-name=<name> The name of the collection to modify
@@ -55,9 +55,9 @@ export async function action(actionArgs) {
55
55
  };
56
56
  const commandAndArgs = getCommandAndArgs(actionArgs, modes);
57
57
  if (commandAndArgs.needHelp) {
58
- if (commandAndArgs.command != null) {
59
- console.error(`Unknown command: ${commandAndArgs.command}`);
60
- console.error(`Specify one of: ${Object.keys(modes).join(', ')}`);
58
+ if (commandAndArgs.error != null) {
59
+ console.error(commandAndArgs.error);
60
+ console.error(`Specify one of the following commands: ${Object.keys(modes).join(', ')}`);
61
61
  console.error();
62
62
  process.exitCode = 1;
63
63
  }
@@ -1 +1 @@
1
- {"version":3,"file":"publish-content.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/manage/publish-content.ts"],"names":[],"mappings":"AAsGA,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,iBA+kBhD"}
1
+ {"version":3,"file":"publish-content.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/manage/publish-content.ts"],"names":[],"mappings":"AAyGA,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,iBAmlBhD"}
@@ -13,9 +13,9 @@ import { mergeContentTypes, testFileContentType } from '../../util/content-types
13
13
  import { LoadConfigError, loadPublishContentConfigFile, loadStaticPublisherRcFile } from '../../util/config.js';
14
14
  import { applyDefaults } from '../../util/data.js';
15
15
  import { readServiceId } from '../../util/fastly-toml.js';
16
- import { calculateFileSizeAndHash, enumerateFiles, getFileSize, rootRelative } from '../../util/files.js';
16
+ import { calculateFileSizeAndHash, enumerateFiles, rootRelative } from '../../util/files.js';
17
17
  import { applyKVStoreEntriesChunks, doKvStoreItemsOperation, } from '../../util/kv-store-items.js';
18
- import { writeKVStoreEntriesForLocal } from '../../util/kv-store-local-server.js';
18
+ import { localKvStoreSubmitEntry, writeKVStoreEntriesForLocal, } from '../../util/kv-store-local-server.js';
19
19
  import { isNodeError } from '../../util/node.js';
20
20
  import { ensureVariantFileExists } from '../../util/variants.js';
21
21
  // KV Store key format:
@@ -234,12 +234,6 @@ export async function action(actionArgs) {
234
234
  // for example, live, staging
235
235
  const collectionName = collectionNameValue ?? process.env.PUBLISHER_COLLECTION_NAME ?? defaultCollectionName;
236
236
  console.log(`✔️ Collection Name: ${collectionName}`);
237
- if (expirationTime != null) {
238
- console.log(`✔️ Publishing with expiration timestamp: ${new Date(expirationTime * 1000).toISOString()}`);
239
- }
240
- else {
241
- console.log(`✔️ Publishing with no expiration timestamp.`);
242
- }
243
237
  if (expirationTime == null) {
244
238
  // includes null and undefined
245
239
  console.log(`✔️ Publishing with no expiration timestamp.`);
@@ -456,29 +450,40 @@ export async function action(actionArgs) {
456
450
  };
457
451
  }
458
452
  console.log(`✅ Scan complete.`);
459
- // TODO: fix this bug:
460
- // Technically it's a bug to WRITE the index and settings json files to the
461
- // staticPublisherKvStoreContent dir when target === 'fastly'.
462
- // For these files we should not be creating the files using
463
- // kvStoreItemDescriptions, but rather creating them directly.
453
+ console.log(`🍪 Chunking large files...`);
454
+ await applyKVStoreEntriesChunks(kvStoreItemDescriptions, KV_STORE_CHUNK_SIZE);
455
+ console.log(`✅ Large files have been chunked.`);
456
+ if (localMode) {
457
+ console.log(`📝 Writing local server KV Store entries.`);
458
+ writeKVStoreEntriesForLocal(storeFile, computeAppDir, kvStoreItemDescriptions);
459
+ console.log(`✅ Wrote KV Store entries for local server.`);
460
+ }
461
+ else {
462
+ console.log(`📤 Uploading entries to KV Store.`);
463
+ // fastlyApiContext is non-null if useKvStore is true
464
+ await doKvStoreItemsOperation(kvStoreItemDescriptions.filter(x => x.write), async ({ filePath, metadataJson }, key) => {
465
+ const fileBytes = fs.readFileSync(filePath);
466
+ await kvStoreSubmitEntry(fastlyApiContext, kvStoreName, key, fileBytes, metadataJson != null ? JSON.stringify(metadataJson) : undefined);
467
+ console.log(` 🌐 Submitted asset "${rootRelative(filePath)}" to KV Store with key "${key}".`);
468
+ });
469
+ console.log(`✅ Uploaded entries to KV Store.`);
470
+ }
464
471
  // #### INDEX FILE
465
- console.log(`🗂️ Creating Index...`);
466
- const indexFileName = `index_${collectionName}.json`;
472
+ console.log(`🗂️ Saving Index...`);
467
473
  const indexFileKey = `${publishId}_index_${collectionName}`;
468
- const indexFilePath = path.resolve(staticPublisherKvStoreContent, indexFileName);
469
- fs.writeFileSync(indexFilePath, JSON.stringify(kvAssetsIndex));
470
- const indexFileSize = getFileSize(indexFilePath);
471
474
  const indexMetadata = {
472
475
  publishedTime: Math.floor(Date.now() / 1000),
473
476
  expirationTime: expirationTime ?? undefined,
474
477
  };
475
- kvStoreItemDescriptions.push({
476
- write: true,
477
- size: indexFileSize,
478
- key: indexFileKey,
479
- filePath: indexFilePath,
480
- metadataJson: indexMetadata,
481
- });
478
+ if (localMode) {
479
+ const indexFileName = `index_${collectionName}.json`;
480
+ const indexFilePath = path.resolve(staticPublisherKvStoreContent, indexFileName);
481
+ fs.writeFileSync(indexFilePath, JSON.stringify(kvAssetsIndex));
482
+ await localKvStoreSubmitEntry(storeFile, indexFileKey, path.relative(computeAppDir, indexFilePath), JSON.stringify(indexMetadata));
483
+ }
484
+ else {
485
+ await kvStoreSubmitEntry(fastlyApiContext, kvStoreName, indexFileKey, JSON.stringify(kvAssetsIndex), JSON.stringify(indexMetadata));
486
+ }
482
487
  console.log(`✅ Index has been saved.`);
483
488
  // #### SERVER SETTINGS
484
489
  // These are saved to KV Store
@@ -539,35 +544,16 @@ export async function action(actionArgs) {
539
544
  autoExt,
540
545
  autoIndex,
541
546
  };
542
- const settingsFileName = `settings_${collectionName}.json`;
543
547
  const settingsFileKey = `${publishId}_settings_${collectionName}`;
544
- const settingsFilePath = path.resolve(staticPublisherKvStoreContent, settingsFileName);
545
- fs.writeFileSync(settingsFilePath, JSON.stringify(serverSettings));
546
- const settingsFileSize = getFileSize(settingsFilePath);
547
- kvStoreItemDescriptions.push({
548
- write: true,
549
- size: settingsFileSize,
550
- key: settingsFileKey,
551
- filePath: settingsFilePath,
552
- });
553
- console.log(`✅ Settings have been saved.`);
554
- console.log(`🍪 Chunking large files...`);
555
- await applyKVStoreEntriesChunks(kvStoreItemDescriptions, KV_STORE_CHUNK_SIZE);
556
- console.log(`✅ Large files have been chunked.`);
557
548
  if (localMode) {
558
- console.log(`📝 Writing local server KV Store entries.`);
559
- writeKVStoreEntriesForLocal(storeFile, computeAppDir, kvStoreItemDescriptions);
560
- console.log(`✅ Wrote KV Store entries for local server.`);
549
+ const settingsFileName = `settings_${collectionName}.json`;
550
+ const settingsFilePath = path.resolve(staticPublisherKvStoreContent, settingsFileName);
551
+ fs.writeFileSync(settingsFilePath, JSON.stringify(serverSettings));
552
+ await localKvStoreSubmitEntry(storeFile, settingsFileKey, path.relative(computeAppDir, settingsFilePath), undefined);
561
553
  }
562
554
  else {
563
- console.log(`📤 Uploading entries to KV Store.`);
564
- // fastlyApiContext is non-null if useKvStore is true
565
- await doKvStoreItemsOperation(kvStoreItemDescriptions.filter(x => x.write), async ({ filePath, metadataJson }, key) => {
566
- const fileBytes = fs.readFileSync(filePath);
567
- await kvStoreSubmitEntry(fastlyApiContext, kvStoreName, key, fileBytes, metadataJson != null ? JSON.stringify(metadataJson) : undefined);
568
- console.log(` 🌐 Submitted asset "${rootRelative(filePath)}" to KV Store with key "${key}".`);
569
- });
570
- console.log(`✅ Uploaded entries to KV Store.`);
555
+ await kvStoreSubmitEntry(fastlyApiContext, kvStoreName, settingsFileKey, JSON.stringify(serverSettings), undefined);
571
556
  }
557
+ console.log(`✅ Settings have been saved.`);
572
558
  console.log(`🎉 Completed.`);
573
559
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/scaffold/index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;IAClB,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;CACjC,CAAC;AA0QF,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,iBAwehD"}
@@ -9,9 +9,9 @@
9
9
  import * as child_process from 'node:child_process';
10
10
  import * as path from 'node:path';
11
11
  import * as fs from 'node:fs';
12
+ import { parseCommandLine } from '../../util/args.js';
12
13
  import { dotRelative, rootRelative } from '../../util/files.js';
13
14
  import { findComputeJsStaticPublisherVersion } from '../../util/package.js';
14
- import { parseCommandLine } from "../../util/args.js";
15
15
  function help() {
16
16
  console.log(`\
17
17
 
@@ -1 +1 @@
1
- {"version":3,"file":"api-token.d.ts","sourceRoot":"","sources":["../../../src/cli/util/api-token.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,WAAW,EAAE,GAAG,CAAC;CAClB,CAAC;AAEF,wBAAgB,YAAY,CAAC,MAAM,EAAE,aAAa,GAAG,kBAAkB,GAAG,IAAI,CAwC7E;AAaD,qBAAa,UAAW,SAAQ,KAAK;gBACvB,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAK3C,MAAM,EAAE,MAAM,CAAC;CAChB;AAWD,wBAAsB,aAAa,CACjC,gBAAgB,EAAE,gBAAgB,EAClC,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,MAAM,EACrB,WAAW,CAAC,EAAE,eAAe,GAAG,IAAI,EACpC,WAAW,CAAC,EAAE,WAAW,GACxB,OAAO,CAAC,QAAQ,CAAC,CAqCnB"}
1
+ {"version":3,"file":"api-token.d.ts","sourceRoot":"","sources":["../../../src/cli/util/api-token.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,WAAW,EAAE,GAAG,CAAC;CAClB,CAAC;AAEF,wBAAgB,YAAY,CAAC,MAAM,EAAE,aAAa,GAAG,kBAAkB,GAAG,IAAI,CAiD7E;AAaD,qBAAa,UAAW,SAAQ,KAAK;gBACvB,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAK3C,MAAM,EAAE,MAAM,CAAC;CAChB;AAWD,wBAAsB,aAAa,CACjC,gBAAgB,EAAE,gBAAgB,EAClC,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,MAAM,EACrB,WAAW,CAAC,EAAE,eAAe,GAAG,IAAI,EACpC,WAAW,CAAC,EAAE,WAAW,GACxB,OAAO,CAAC,QAAQ,CAAC,CAqCnB"}
@@ -23,10 +23,21 @@ export function loadApiToken(params) {
23
23
  // Try fastly cli
24
24
  if (apiToken == null) {
25
25
  try {
26
- const { stdout, error } = spawnSync(cli, ['profile', 'token', '--quiet'], {
26
+ const { stdout, error, status } = spawnSync(cli, ['profile', 'token', '--quiet'], {
27
27
  encoding: 'utf-8',
28
28
  });
29
- apiToken = error ? null : stdout.trim();
29
+ if (status != null && status !== 0) {
30
+ console.warn(`⚠️ Warning: 'fastly profile token' returned a non-zero status code.`);
31
+ apiToken = null;
32
+ }
33
+ else if (error) {
34
+ console.warn(`⚠️ Warning: 'fastly profile token' returned an error:`);
35
+ console.warn(String(error));
36
+ apiToken = null;
37
+ }
38
+ else {
39
+ apiToken = stdout.trim();
40
+ }
30
41
  }
31
42
  catch {
32
43
  apiToken = null;
@@ -13,7 +13,7 @@ export type CommandAndArgs<T> = {
13
13
  };
14
14
  export type CommandAndArgsHelp = {
15
15
  needHelp: true;
16
- command: string | null;
16
+ error: string | null;
17
17
  };
18
18
  export type CommandAndArgsResult<T> = CommandAndArgs<T> | CommandAndArgsHelp;
19
19
  export declare function getCommandAndArgs<T extends string>(argv: string[], actions: ActionTable<T>): CommandAndArgsResult<T>;
@@ -1 +1 @@
1
- {"version":3,"file":"args.d.ts","sourceRoot":"","sources":["../../../src/cli/util/args.ts"],"names":[],"mappings":"AAKA,OAAwB,EAAE,KAAK,kBAAkB,EAAE,KAAK,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAEpG,MAAM,MAAM,UAAU,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAClE,MAAM,MAAM,YAAY,GAAG;IAAE,MAAM,EAAE,UAAU,CAAA;CAAE,CAAC;AAClD,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,MAAM,IAAI,MAAM,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;AAMpE,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,WAKxC;AAED,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,GAAG,IAAI,EAAE,MAAM,EAAE,CAAC,CAepF;AAED,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI;IAC9B,QAAQ,EAAE,KAAK,CAAC;IAChB,OAAO,EAAE,CAAC,CAAC;IACX,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,EAAE,IAAI,CAAC;IACf,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB,CAAA;AA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AE,CAAC,CAepF;AAED,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI;IAC9B,QAAQ,EAAE,KAAK,CAAC;IAChB,OAAO,EAAE,CAAC,CAAC;IACX,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,EAAE,IAAI,CAAC;IACf,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB,CAAA;AAED,MAAM,MAAM,oBAAoB,CAAC,CAAC,IAAI,cAAc,CAAC,CAAC,CAAC,GAAG,kBAAkB,CAAC;AAE7E,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,MAAM,EAChD,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC,GACtB,oBAAoB,CAAC,CAAC,CAAC,CAsCzB;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,EAAE,KAAK,CAAC;IAChB,kBAAkB,EAAE,kBAAkB,CAAC;CACxC,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,EAAE,IAAI,CAAC;IACf,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,iBAAiB,GAAG,eAAe,CAAC;AAEpE,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,MAAM,EAAE,EACd,iBAAiB,EAAE,gBAAgB,EAAE,GACpC,iBAAiB,CA0BnB"}
@@ -26,7 +26,7 @@ export function getCommandAndArgs(argv, actions) {
26
26
  if (isHelpArgs(argv)) {
27
27
  return {
28
28
  needHelp: true,
29
- command: null,
29
+ error: null,
30
30
  };
31
31
  }
32
32
  const result = findMainCommandNameAndArgs(argv);
@@ -41,16 +41,21 @@ export function getCommandAndArgs(argv, actions) {
41
41
  };
42
42
  }
43
43
  }
44
+ return {
45
+ needHelp: true,
46
+ error: `Unknown command: ${command}`,
47
+ };
44
48
  }
49
+ let error = null;
45
50
  try {
46
51
  commandLineArgs([], { argv: actionArgv });
47
52
  }
48
53
  catch (err) {
49
- console.log(String(err));
54
+ error = String(err);
50
55
  }
51
56
  return {
52
57
  needHelp: true,
53
- command,
58
+ error,
54
59
  };
55
60
  }
56
61
  export function parseCommandLine(argv, optionDefinitions) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@fastly/compute-js-static-publish",
3
3
  "type": "module",
4
- "version": "7.0.0-beta.3",
4
+ "version": "7.0.0-beta.5",
5
5
  "description": "Static Publisher for Fastly Compute JavaScript",
6
6
  "main": "build/index.js",
7
7
  "exports": {