@fastly/compute-js-static-publish 7.0.0-beta.4 → 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.
- package/build/cli/commands/manage/clean.d.ts.map +1 -1
- package/build/cli/commands/manage/clean.js +4 -4
- package/build/cli/commands/manage/collections/index.js +3 -3
- package/build/cli/commands/manage/collections/promote.d.ts.map +1 -1
- package/build/cli/commands/manage/collections/promote.js +1 -1
- package/build/cli/commands/manage/collections/update-expiration.d.ts.map +1 -1
- package/build/cli/commands/manage/collections/update-expiration.js +7 -7
- package/build/cli/commands/manage/index.js +3 -3
- package/build/cli/commands/manage/publish-content.d.ts.map +1 -1
- package/build/cli/commands/manage/publish-content.js +36 -50
- package/build/cli/commands/scaffold/index.d.ts.map +1 -1
- package/build/cli/commands/scaffold/index.js +1 -1
- package/build/cli/util/api-token.d.ts.map +1 -1
- package/build/cli/util/api-token.js +13 -2
- package/build/cli/util/args.d.ts +1 -1
- package/build/cli/util/args.d.ts.map +1 -1
- package/build/cli/util/args.js +8 -3
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clean.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/manage/clean.ts"],"names":[],"mappings":"
|
|
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 {
|
|
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
|
|
|
@@ -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.
|
|
53
|
-
console.error(
|
|
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":"
|
|
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":"
|
|
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
|
|
11
|
-
import {
|
|
12
|
-
import
|
|
13
|
-
import
|
|
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
|
|
|
@@ -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.
|
|
59
|
-
console.error(
|
|
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":"
|
|
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,
|
|
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
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
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(`🗂️
|
|
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
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
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
|
-
|
|
559
|
-
|
|
560
|
-
|
|
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
|
-
|
|
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.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/scaffold/index.ts"],"names":[],"mappings":"AA4DA,MAAM,MAAM,cAAc,GAAG;IAC3B,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,yBAAyB,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9C,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,OAAO,EAAE,MAAM,EAAE,CAAC;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,
|
|
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
|
-
|
|
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;
|
package/build/cli/util/args.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export type CommandAndArgs<T> = {
|
|
|
13
13
|
};
|
|
14
14
|
export type CommandAndArgsHelp = {
|
|
15
15
|
needHelp: true;
|
|
16
|
-
|
|
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,
|
|
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,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"}
|
package/build/cli/util/args.js
CHANGED
|
@@ -26,7 +26,7 @@ export function getCommandAndArgs(argv, actions) {
|
|
|
26
26
|
if (isHelpArgs(argv)) {
|
|
27
27
|
return {
|
|
28
28
|
needHelp: true,
|
|
29
|
-
|
|
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
|
-
|
|
54
|
+
error = String(err);
|
|
50
55
|
}
|
|
51
56
|
return {
|
|
52
57
|
needHelp: true,
|
|
53
|
-
|
|
58
|
+
error,
|
|
54
59
|
};
|
|
55
60
|
}
|
|
56
61
|
export function parseCommandLine(argv, optionDefinitions) {
|