@contentstack/cli-utilities 1.3.2 → 1.4.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/lib/auth-handler.js +1 -1
- package/lib/cli-ux.js +11 -0
- package/lib/config-handler.js +2 -1
- package/package.json +5 -4
- package/types/auth-handler.d.ts +36 -37
- package/types/cli-ux.d.ts +20 -14
- package/types/contentstack-management-sdk.d.ts +5 -5
- package/types/helpers.d.ts +1 -1
- package/types/http-client/client.d.ts +3 -0
- package/types/index.d.ts +2 -65
- package/types/interfaces/index.d.ts +34 -31
package/lib/auth-handler.js
CHANGED
|
@@ -338,7 +338,7 @@ class AuthHandler {
|
|
|
338
338
|
}
|
|
339
339
|
});
|
|
340
340
|
}
|
|
341
|
-
|
|
341
|
+
isAuthenticated() {
|
|
342
342
|
const authorizationType = config_handler_1.default.get(this.authorisationTypeKeyName);
|
|
343
343
|
return (authorizationType === this.authorisationTypeOAUTHValue || authorizationType === this.authorisationTypeAUTHValue);
|
|
344
344
|
}
|
package/lib/cli-ux.js
CHANGED
|
@@ -8,7 +8,9 @@ const core_1 = require("@oclif/core");
|
|
|
8
8
|
Object.defineProperty(exports, "Args", { enumerable: true, get: function () { return core_1.Args; } });
|
|
9
9
|
Object.defineProperty(exports, "Flags", { enumerable: true, get: function () { return core_1.Flags; } });
|
|
10
10
|
Object.defineProperty(exports, "Command", { enumerable: true, get: function () { return core_1.Command; } });
|
|
11
|
+
const ora_1 = tslib_1.__importDefault(require("ora"));
|
|
11
12
|
const message_handler_1 = tslib_1.__importDefault(require("./message-handler"));
|
|
13
|
+
inquirer_1.default.registerPrompt('table', require('inquirer-table-prompt'));
|
|
12
14
|
/**
|
|
13
15
|
* CLI Interface
|
|
14
16
|
*/
|
|
@@ -73,5 +75,14 @@ class CLIInterface {
|
|
|
73
75
|
progress(options) {
|
|
74
76
|
return core_1.ux.progress(options);
|
|
75
77
|
}
|
|
78
|
+
loaderV2(message = '', spinner) {
|
|
79
|
+
if (!spinner) {
|
|
80
|
+
return (0, ora_1.default)(message).start();
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
spinner.text = message;
|
|
84
|
+
spinner.stop();
|
|
85
|
+
}
|
|
86
|
+
}
|
|
76
87
|
}
|
|
77
88
|
exports.default = new CLIInterface();
|
package/lib/config-handler.js
CHANGED
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const conf_1 = tslib_1.__importDefault(require("conf"));
|
|
5
|
+
const has_1 = tslib_1.__importDefault(require("lodash/has"));
|
|
5
6
|
const uuid_1 = require("uuid");
|
|
6
7
|
const fs_1 = require("fs");
|
|
7
8
|
const ENC_KEY = process.env.ENC_KEY || 'encryptionKey';
|
|
8
|
-
const ENCRYPT_CONF = process.env.ENCRYPT_CONF === 'true'
|
|
9
|
+
const ENCRYPT_CONF = (0, has_1.default)(process.env, 'ENCRYPT_CONF') ? process.env.ENCRYPT_CONF === 'true' : true;
|
|
9
10
|
const CONFIG_NAME = process.env.CONFIG_NAME || 'contentstack_cli';
|
|
10
11
|
const ENC_CONFIG_NAME = process.env.ENC_CONFIG_NAME || 'contentstack_cli_obfuscate';
|
|
11
12
|
const OLD_CONFIG_BACKUP_FLAG = 'isOldConfigBackup';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentstack/cli-utilities",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"description": "Utilities for contentstack projects",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "./types/index.d.ts",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"author": "contentstack",
|
|
32
32
|
"license": "MIT",
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@contentstack/management": "^1.
|
|
35
|
-
"@oclif/core": "^2.
|
|
34
|
+
"@contentstack/management": "^1.8.0",
|
|
35
|
+
"@oclif/core": "^2.8.2",
|
|
36
36
|
"axios": "1.3.4",
|
|
37
37
|
"chalk": "^4.0.0",
|
|
38
38
|
"conf": "^10.1.2",
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
"inquirer": "8.2.4",
|
|
41
41
|
"inquirer-search-checkbox": "^1.0.0",
|
|
42
42
|
"inquirer-search-list": "^1.2.6",
|
|
43
|
+
"inquirer-table-prompt": "git@github.com:kego1992/inquirer-table-prompt.git",
|
|
43
44
|
"lodash": "^4.17.15",
|
|
44
45
|
"open": "^8.4.2",
|
|
45
46
|
"ora": "^5.4.0",
|
|
@@ -72,4 +73,4 @@
|
|
|
72
73
|
"tslib": "^1.13.0",
|
|
73
74
|
"typescript": "^4.9.3"
|
|
74
75
|
}
|
|
75
|
-
}
|
|
76
|
+
}
|
package/types/auth-handler.d.ts
CHANGED
|
@@ -3,43 +3,42 @@
|
|
|
3
3
|
* Auth handler
|
|
4
4
|
*/
|
|
5
5
|
declare class AuthHandler {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
isAuthorisationTypeOAuth(): Promise<boolean>;
|
|
6
|
+
private _host;
|
|
7
|
+
private codeVerifier;
|
|
8
|
+
private OAuthBaseURL;
|
|
9
|
+
private OAuthAppId;
|
|
10
|
+
private OAuthClientId;
|
|
11
|
+
private OAuthRedirectURL;
|
|
12
|
+
private OAuthScope;
|
|
13
|
+
private OAuthResponseType;
|
|
14
|
+
private authTokenKeyName;
|
|
15
|
+
private authEmailKeyName;
|
|
16
|
+
private oauthAccessTokenKeyName;
|
|
17
|
+
private oauthDateTimeKeyName;
|
|
18
|
+
private oauthUserUidKeyName;
|
|
19
|
+
private oauthOrgUidKeyName;
|
|
20
|
+
private oauthRefreshTokenKeyName;
|
|
21
|
+
private authorisationTypeKeyName;
|
|
22
|
+
private authorisationTypeOAUTHValue;
|
|
23
|
+
private authorisationTypeAUTHValue;
|
|
24
|
+
private allAuthConfigItems;
|
|
25
|
+
set host(contentStackHost: any);
|
|
26
|
+
constructor();
|
|
27
|
+
setOAuthBaseURL(): Promise<void>;
|
|
28
|
+
oauth(): Promise<object>;
|
|
29
|
+
createHTTPServer(): Promise<object>;
|
|
30
|
+
openOAuthURL(): Promise<object>;
|
|
31
|
+
getAccessToken(code: string): Promise<object>;
|
|
32
|
+
setConfigData(type: string, userData?: any): Promise<object>;
|
|
33
|
+
unsetConfigData(type?: string): Promise<void>;
|
|
34
|
+
refreshToken(): Promise<object>;
|
|
35
|
+
getUserDetails(data: any): Promise<object>;
|
|
36
|
+
isAuthenticated(): boolean;
|
|
37
|
+
getAuthorisationType(): Promise<any>;
|
|
38
|
+
isAuthorisationTypeBasic(): Promise<boolean>;
|
|
39
|
+
isAuthorisationTypeOAuth(): Promise<boolean>;
|
|
40
|
+
checkExpiryAndRefresh: (force?: boolean) => Promise<void | object>;
|
|
41
|
+
compareOAuthExpiry(force?: boolean): Promise<void | object>;
|
|
43
42
|
}
|
|
44
43
|
declare const _default: AuthHandler;
|
|
45
44
|
export default _default;
|
package/types/cli-ux.d.ts
CHANGED
|
@@ -1,24 +1,30 @@
|
|
|
1
1
|
import { Table } from '@oclif/core/lib/cli-ux';
|
|
2
2
|
import { Args, Flags, Command } from '@oclif/core';
|
|
3
|
+
import { Ora } from 'ora';
|
|
3
4
|
import { PrintOptions, InquirePayload, CliUXPromptOptions } from './interfaces';
|
|
4
5
|
/**
|
|
5
6
|
* CLI Interface
|
|
6
7
|
*/
|
|
7
8
|
declare class CLIInterface {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
9
|
+
private loading;
|
|
10
|
+
constructor();
|
|
11
|
+
get uxTable(): typeof Table.table;
|
|
12
|
+
init(context: any): void;
|
|
13
|
+
registerSearchPlugin(): void;
|
|
14
|
+
print(message: string, opts?: PrintOptions): void;
|
|
15
|
+
success(message: string): void;
|
|
16
|
+
error(message: string, ...params: any): void;
|
|
17
|
+
loader(message?: string): void;
|
|
18
|
+
table(
|
|
19
|
+
data: Record<string, unknown>[],
|
|
20
|
+
columns: Table.table.Columns<Record<string, unknown>>,
|
|
21
|
+
options?: Table.table.Options,
|
|
22
|
+
): void;
|
|
23
|
+
inquire<T>(inquirePayload: InquirePayload | Array<InquirePayload>): Promise<T>;
|
|
24
|
+
prompt(name: string, options?: CliUXPromptOptions): Promise<any>;
|
|
25
|
+
confirm(message?: string): Promise<boolean>;
|
|
26
|
+
progress(options?: any): any;
|
|
27
|
+
loaderV2(message?: string, spinner?: any): Ora | void;
|
|
22
28
|
}
|
|
23
29
|
declare const _default: CLIInterface;
|
|
24
30
|
export default _default;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { ContentstackClient, ContentstackConfig } from '@contentstack/management';
|
|
2
2
|
declare class ManagementSDKInitiator {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
private analyticsInfo;
|
|
4
|
+
constructor();
|
|
5
|
+
init(context: any): void;
|
|
6
|
+
createAPIClient(config: any): Promise<ContentstackClient>;
|
|
7
7
|
}
|
|
8
|
-
declare const _default: (config: any) => Promise<ContentstackClient>;
|
|
9
8
|
export declare const managementSDKInitiator: ManagementSDKInitiator;
|
|
9
|
+
declare const _default: any;
|
|
10
10
|
export default _default;
|
|
11
11
|
export { ContentstackConfig, ContentstackClient };
|
package/types/helpers.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare
|
|
1
|
+
export declare const isAuthenticated: () => boolean;
|
|
@@ -225,6 +225,9 @@ export declare class HttpClient implements IHttpClient {
|
|
|
225
225
|
* Returns the request payload depending on the selected request payload format.
|
|
226
226
|
*/
|
|
227
227
|
prepareRequestPayload(): any;
|
|
228
|
+
refreshToken(): Promise<{
|
|
229
|
+
authorization: string;
|
|
230
|
+
}>;
|
|
228
231
|
}
|
|
229
232
|
export interface HttpRequestConfig extends AxiosRequestConfig {
|
|
230
233
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -4,74 +4,11 @@ export { default as CLIError } from './cli-error';
|
|
|
4
4
|
export { default as messageHandler } from './message-handler';
|
|
5
5
|
export { default as authHandler } from './auth-handler';
|
|
6
6
|
export { default as configHandler } from './config-handler';
|
|
7
|
-
export {
|
|
8
|
-
default as managementSDKClient,
|
|
9
|
-
managementSDKInitiator,
|
|
10
|
-
ContentstackClient,
|
|
11
|
-
ContentstackConfig,
|
|
12
|
-
} from './contentstack-management-sdk';
|
|
7
|
+
export { default as managementSDKClient, managementSDKInitiator, ContentstackClient, ContentstackConfig, } from './contentstack-management-sdk';
|
|
13
8
|
export { default as printFlagDeprecation } from './flag-deprecation-check';
|
|
14
9
|
export * from './http-client';
|
|
15
10
|
export { default as NodeCrypto } from './encrypter';
|
|
16
11
|
export { Args as args, Flags as flags, Command } from './cli-ux';
|
|
17
|
-
export {
|
|
18
|
-
Args,
|
|
19
|
-
CommandHelp,
|
|
20
|
-
Config,
|
|
21
|
-
Errors,
|
|
22
|
-
Flags,
|
|
23
|
-
loadHelpClass,
|
|
24
|
-
Help,
|
|
25
|
-
HelpBase,
|
|
26
|
-
HelpSection,
|
|
27
|
-
HelpSectionRenderer,
|
|
28
|
-
HelpSectionKeyValueTable,
|
|
29
|
-
Hook,
|
|
30
|
-
Interfaces,
|
|
31
|
-
Parser,
|
|
32
|
-
Plugin,
|
|
33
|
-
run,
|
|
34
|
-
toCached,
|
|
35
|
-
tsPath,
|
|
36
|
-
toStandardizedId,
|
|
37
|
-
toConfiguredId,
|
|
38
|
-
settings,
|
|
39
|
-
Settings,
|
|
40
|
-
flush,
|
|
41
|
-
ux,
|
|
42
|
-
execute,
|
|
43
|
-
stderr,
|
|
44
|
-
stdout,
|
|
45
|
-
} from '@oclif/core';
|
|
46
|
-
export { FlagInput } from '@oclif/core/lib/interfaces/parser';
|
|
47
12
|
export * from './helpers';
|
|
48
|
-
export {
|
|
49
|
-
Args,
|
|
50
|
-
CommandHelp,
|
|
51
|
-
Config,
|
|
52
|
-
Errors,
|
|
53
|
-
Flags,
|
|
54
|
-
loadHelpClass,
|
|
55
|
-
Help,
|
|
56
|
-
HelpBase,
|
|
57
|
-
HelpSection,
|
|
58
|
-
HelpSectionRenderer,
|
|
59
|
-
HelpSectionKeyValueTable,
|
|
60
|
-
Hook,
|
|
61
|
-
Interfaces,
|
|
62
|
-
Parser,
|
|
63
|
-
Plugin,
|
|
64
|
-
run,
|
|
65
|
-
toCached,
|
|
66
|
-
tsPath,
|
|
67
|
-
toStandardizedId,
|
|
68
|
-
toConfiguredId,
|
|
69
|
-
settings,
|
|
70
|
-
Settings,
|
|
71
|
-
flush,
|
|
72
|
-
ux,
|
|
73
|
-
execute,
|
|
74
|
-
stderr,
|
|
75
|
-
stdout,
|
|
76
|
-
} from '@oclif/core';
|
|
13
|
+
export { Args, CommandHelp, Config, Errors, Flags, loadHelpClass, Help, HelpBase, HelpSection, HelpSectionRenderer, HelpSectionKeyValueTable, Hook, Interfaces, Parser, Plugin, run, toCached, tsPath, toStandardizedId, toConfiguredId, settings, Settings, flush, ux, execute, stderr, stdout, } from '@oclif/core';
|
|
77
14
|
export { FlagInput } from '@oclif/core/lib/interfaces/parser';
|
|
@@ -1,53 +1,56 @@
|
|
|
1
|
-
import { IPromptOptions } from
|
|
1
|
+
import { IPromptOptions } from '@oclif/core/lib/cli-ux';
|
|
2
2
|
export interface PrintOptions {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
bold?: boolean;
|
|
4
|
+
color?: string;
|
|
5
5
|
}
|
|
6
6
|
export interface InquirePayload {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
type: string;
|
|
8
|
+
name: string;
|
|
9
|
+
default?: any;
|
|
10
|
+
message: string;
|
|
11
|
+
choices?: Array<any>;
|
|
12
|
+
transformer?: Function;
|
|
13
|
+
validate?(input: any, answers?: any): boolean | string | Promise<boolean | string>;
|
|
14
|
+
columns?: Array<any>;
|
|
15
|
+
rows?: Array<any>;
|
|
16
|
+
selectAll?: boolean;
|
|
17
|
+
pageSize?: number;
|
|
14
18
|
}
|
|
15
19
|
export interface Region {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
20
|
+
name: string;
|
|
21
|
+
cma: string;
|
|
22
|
+
cda: string;
|
|
19
23
|
}
|
|
20
24
|
export interface Token {
|
|
21
|
-
|
|
22
|
-
|
|
25
|
+
token: string;
|
|
26
|
+
apiKey: string;
|
|
23
27
|
}
|
|
24
28
|
export interface Organization {
|
|
25
|
-
|
|
26
|
-
|
|
29
|
+
uid: string;
|
|
30
|
+
name: string;
|
|
27
31
|
}
|
|
28
32
|
export interface selectedOrganization {
|
|
29
|
-
|
|
30
|
-
|
|
33
|
+
orgUid: string;
|
|
34
|
+
orgName: string;
|
|
31
35
|
}
|
|
32
36
|
export interface Stack {
|
|
33
|
-
|
|
34
|
-
|
|
37
|
+
name: string;
|
|
38
|
+
api_key: string;
|
|
35
39
|
}
|
|
36
40
|
export interface ContentType {
|
|
37
|
-
|
|
38
|
-
|
|
41
|
+
uid: string;
|
|
42
|
+
title: string;
|
|
39
43
|
}
|
|
40
44
|
export interface Environment {
|
|
41
|
-
|
|
42
|
-
|
|
45
|
+
name: string;
|
|
46
|
+
uid: string;
|
|
43
47
|
}
|
|
44
48
|
export interface Entry {
|
|
45
|
-
|
|
46
|
-
|
|
49
|
+
uid: string;
|
|
50
|
+
title: string;
|
|
47
51
|
}
|
|
48
52
|
export interface Locale {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
export interface CliUXPromptOptions extends IPromptOptions {
|
|
53
|
+
name: string;
|
|
54
|
+
code: string;
|
|
53
55
|
}
|
|
56
|
+
export interface CliUXPromptOptions extends IPromptOptions {}
|