@contentstack/cli-auth 2.0.0-beta.12 → 2.0.0-beta.14

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 CHANGED
@@ -18,7 +18,7 @@ $ npm install -g @contentstack/cli-auth
18
18
  $ csdx COMMAND
19
19
  running command...
20
20
  $ csdx (--version)
21
- @contentstack/cli-auth/2.0.0-beta.12 linux-x64 node-v22.22.2
21
+ @contentstack/cli-auth/2.0.0-beta.14 linux-x64 node-v22.23.0
22
22
  $ csdx --help [COMMAND]
23
23
  USAGE
24
24
  $ csdx COMMAND
@@ -33,11 +33,11 @@ USAGE
33
33
  * [`csdx auth:logout`](#csdx-authlogout)
34
34
  * [`csdx auth:tokens`](#csdx-authtokens)
35
35
  * [`csdx auth:tokens:add [-a <value>] [--delivery] [--management] [-e <value>] [-k <value>] [-y] [--token <value>]`](#csdx-authtokensadd--a-value---delivery---management--e-value--k-value--y---token-value)
36
+ * [`csdx auth:tokens:list`](#csdx-authtokenslist)
36
37
  * [`csdx auth:tokens:remove`](#csdx-authtokensremove)
37
38
  * [`csdx auth:whoami`](#csdx-authwhoami)
38
39
  * [`csdx login`](#csdx-login)
39
40
  * [`csdx logout`](#csdx-logout)
40
- * [`csdx tokens`](#csdx-tokens)
41
41
  * [`csdx whoami`](#csdx-whoami)
42
42
 
43
43
  ## `csdx auth:login`
@@ -102,7 +102,7 @@ _See code: [src/commands/auth/logout.ts](https://github.com/contentstack/cli/blo
102
102
 
103
103
  ## `csdx auth:tokens`
104
104
 
105
- Lists all existing tokens added to the session
105
+ Manage authentication tokens for API access
106
106
 
107
107
  ```
108
108
  USAGE
@@ -120,13 +120,14 @@ TABLE FLAGS
120
120
  --sort=<value> Sort the table by a column. Use "-" for descending.
121
121
 
122
122
  DESCRIPTION
123
- Lists all existing tokens added to the session
124
-
125
- ALIASES
126
- $ csdx tokens
123
+ Manage authentication tokens for API access
127
124
 
128
125
  EXAMPLES
129
- $ csdx auth:tokens
126
+ $ csdx auth:tokens:list
127
+
128
+ $ csdx auth:tokens:add --alias mytoken
129
+
130
+ $ csdx auth:tokens:remove --alias mytoken
130
131
  ```
131
132
 
132
133
  _See code: [src/commands/auth/tokens/index.ts](https://github.com/contentstack/cli/blob/main/packages/contentstack-auth/src/commands/auth/tokens/index.ts)_
@@ -177,6 +178,34 @@ EXAMPLES
177
178
 
178
179
  _See code: [src/commands/auth/tokens/add.ts](https://github.com/contentstack/cli/blob/main/packages/contentstack-auth/src/commands/auth/tokens/add.ts)_
179
180
 
181
+ ## `csdx auth:tokens:list`
182
+
183
+ Lists all existing tokens added to the session
184
+
185
+ ```
186
+ USAGE
187
+ $ csdx auth:tokens:list [--columns <value>] [--sort <value>] [--filter <value>] [--csv] [--no-truncate]
188
+ [--no-header] [--output csv|json|yaml]
189
+
190
+ TABLE FLAGS
191
+ --columns=<value> Specify columns to display, comma-separated.
192
+ --csv Output results in CSV format.
193
+ --filter=<value> Filter rows by a column value (e.g., name=foo).
194
+ --no-header Hide table headers in output.
195
+ --no-truncate Prevent truncation of long text in columns.
196
+ --output=<option> Specify output format: csv, json, or yaml.
197
+ <options: csv|json|yaml>
198
+ --sort=<value> Sort the table by a column. Use "-" for descending.
199
+
200
+ DESCRIPTION
201
+ Lists all existing tokens added to the session
202
+
203
+ EXAMPLES
204
+ $ csdx auth:tokens:list
205
+ ```
206
+
207
+ _See code: [src/commands/auth/tokens/list.ts](https://github.com/contentstack/cli/blob/main/packages/contentstack-auth/src/commands/auth/tokens/list.ts)_
208
+
180
209
  ## `csdx auth:tokens:remove`
181
210
 
182
211
  Removes selected tokens
@@ -276,35 +305,6 @@ EXAMPLES
276
305
  $ csdx auth:logout --yes
277
306
  ```
278
307
 
279
- ## `csdx tokens`
280
-
281
- Lists all existing tokens added to the session
282
-
283
- ```
284
- USAGE
285
- $ csdx tokens [--columns <value>] [--sort <value>] [--filter <value>] [--csv] [--no-truncate]
286
- [--no-header] [--output csv|json|yaml]
287
-
288
- TABLE FLAGS
289
- --columns=<value> Specify columns to display, comma-separated.
290
- --csv Output results in CSV format.
291
- --filter=<value> Filter rows by a column value (e.g., name=foo).
292
- --no-header Hide table headers in output.
293
- --no-truncate Prevent truncation of long text in columns.
294
- --output=<option> Specify output format: csv, json, or yaml.
295
- <options: csv|json|yaml>
296
- --sort=<value> Sort the table by a column. Use "-" for descending.
297
-
298
- DESCRIPTION
299
- Lists all existing tokens added to the session
300
-
301
- ALIASES
302
- $ csdx tokens
303
-
304
- EXAMPLES
305
- $ csdx auth:tokens
306
- ```
307
-
308
308
  ## `csdx whoami`
309
309
 
310
310
  Display current users email address
@@ -1,9 +1,9 @@
1
- import { FlagInput } from '@contentstack/cli-utilities';
2
1
  import { BaseCommand } from '../../../base-command';
3
- export default class TokensListCommand extends BaseCommand<typeof TokensListCommand> {
4
- static aliases: string[];
5
- static examples: string[];
2
+ import { FlagInput } from '@contentstack/cli-utilities';
3
+ export default class AuthTokensCommand extends BaseCommand<typeof AuthTokensCommand> {
6
4
  static description: string;
5
+ static strict: boolean;
6
+ static examples: string[];
7
7
  static flags: FlagInput;
8
8
  run(): Promise<any>;
9
9
  }
@@ -1,69 +1,25 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const cli_utilities_1 = require("@contentstack/cli-utilities");
3
+ const core_1 = require("@oclif/core");
4
4
  const base_command_1 = require("../../../base-command");
5
- class TokensListCommand extends base_command_1.BaseCommand {
5
+ const cli_utilities_1 = require("@contentstack/cli-utilities");
6
+ class AuthTokensCommand extends base_command_1.BaseCommand {
6
7
  async run() {
7
- cli_utilities_1.log.debug('TokensListCommand run method started.', this.contextDetails);
8
- this.contextDetails.module = 'tokens-list';
9
- try {
10
- cli_utilities_1.log.debug('Retrieving tokens from configuration.', this.contextDetails);
11
- const managementTokens = cli_utilities_1.configHandler.get('tokens');
12
- cli_utilities_1.log.debug('Tokens retrieved from configuration.', Object.assign(Object.assign({}, this.contextDetails), { tokenCount: managementTokens ? Object.keys(managementTokens).length : 0 }));
13
- const tokens = [];
14
- if (managementTokens && Object.keys(managementTokens).length > 0) {
15
- cli_utilities_1.log.debug('Processing tokens for display.', this.contextDetails);
16
- Object.keys(managementTokens).forEach(function (item) {
17
- tokens.push({
18
- alias: item,
19
- token: managementTokens[item].token,
20
- apiKey: managementTokens[item].apiKey,
21
- environment: managementTokens[item].environment ? managementTokens[item].environment : '-',
22
- type: managementTokens[item].type,
23
- });
24
- cli_utilities_1.log.debug(`Token processed: ${item}`, { tokenType: managementTokens[item].type });
25
- });
26
- const { flags } = await this.parse(TokensListCommand);
27
- cli_utilities_1.log.debug('Token list flags parsed.', Object.assign(Object.assign({}, this.contextDetails), { flags }));
28
- const headers = [
29
- {
30
- value: 'alias',
31
- },
32
- {
33
- value: 'token',
34
- },
35
- {
36
- value: 'apiKey',
37
- },
38
- {
39
- value: 'environment',
40
- },
41
- {
42
- value: 'type',
43
- },
44
- ];
45
- cli_utilities_1.log.debug('Displaying token table.', Object.assign(Object.assign({}, this.contextDetails), { tokenCount: tokens.length }));
46
- cli_utilities_1.cliux.table(headers, tokens, flags);
47
- cli_utilities_1.log.debug('Token table displayed successfully.', this.contextDetails);
48
- }
49
- else {
50
- cli_utilities_1.log.debug('No tokens found in configuration.', this.contextDetails);
51
- cli_utilities_1.cliux.print('CLI_AUTH_TOKENS_LIST_NO_TOKENS');
52
- }
53
- cli_utilities_1.log.debug('Token list command completed successfully.', this.contextDetails);
54
- }
55
- catch (error) {
56
- cli_utilities_1.log.debug('Token list command failed.', Object.assign(Object.assign({}, this.contextDetails), { error }));
57
- cli_utilities_1.cliux.print('CLI_AUTH_TOKENS_LIST_FAILED', { color: 'yellow' });
58
- (0, cli_utilities_1.handleAndLogError)(error, Object.assign({}, this.contextDetails));
59
- }
8
+ await this.parse(AuthTokensCommand, this.argv.filter((a) => a !== '-help' && a !== '-h'));
9
+ const cmd = this.config.findCommand('auth:tokens');
10
+ if (cmd)
11
+ await new core_1.Help(this.config).showCommandHelp(cmd);
60
12
  }
61
13
  }
62
- exports.default = TokensListCommand;
63
- TokensListCommand.aliases = ['tokens'];
64
- TokensListCommand.examples = ['$ csdx auth:tokens'];
65
- TokensListCommand.description = 'Lists all existing tokens added to the session';
66
- TokensListCommand.flags = cli_utilities_1.CLITable.getTableFlags([
14
+ exports.default = AuthTokensCommand;
15
+ AuthTokensCommand.description = 'Manage authentication tokens for API access';
16
+ AuthTokensCommand.strict = false;
17
+ AuthTokensCommand.examples = [
18
+ '$ csdx auth:tokens:list',
19
+ '$ csdx auth:tokens:add --alias mytoken',
20
+ '$ csdx auth:tokens:remove --alias mytoken',
21
+ ];
22
+ AuthTokensCommand.flags = cli_utilities_1.CLITable.getTableFlags([
67
23
  'columns',
68
24
  'sort',
69
25
  'filter',
@@ -71,4 +27,4 @@ TokensListCommand.flags = cli_utilities_1.CLITable.getTableFlags([
71
27
  'no-truncate',
72
28
  'no-header',
73
29
  'output',
74
- ]); // use the cli table flags as it displays tokens in table
30
+ ]);
@@ -0,0 +1,8 @@
1
+ import { FlagInput } from '@contentstack/cli-utilities';
2
+ import { BaseCommand } from '../../../base-command';
3
+ export default class AuthTokensListCommand extends BaseCommand<typeof AuthTokensListCommand> {
4
+ static description: string;
5
+ static examples: string[];
6
+ static flags: FlagInput;
7
+ run(): Promise<any>;
8
+ }
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const cli_utilities_1 = require("@contentstack/cli-utilities");
4
+ const base_command_1 = require("../../../base-command");
5
+ class AuthTokensListCommand extends base_command_1.BaseCommand {
6
+ async run() {
7
+ cli_utilities_1.log.debug('AuthTokensListCommand run method started.', this.contextDetails);
8
+ this.contextDetails.module = 'auth-tokens-list';
9
+ try {
10
+ cli_utilities_1.log.debug('Retrieving tokens from configuration.', this.contextDetails);
11
+ const managementTokens = cli_utilities_1.configHandler.get('tokens');
12
+ cli_utilities_1.log.debug('Tokens retrieved from configuration.', Object.assign(Object.assign({}, this.contextDetails), { tokenCount: managementTokens ? Object.keys(managementTokens).length : 0 }));
13
+ const tokens = [];
14
+ if (managementTokens && Object.keys(managementTokens).length > 0) {
15
+ cli_utilities_1.log.debug('Processing tokens for display.', this.contextDetails);
16
+ Object.keys(managementTokens).forEach(function (item) {
17
+ tokens.push({
18
+ alias: item,
19
+ token: managementTokens[item].token,
20
+ apiKey: managementTokens[item].apiKey,
21
+ environment: managementTokens[item].environment ? managementTokens[item].environment : '-',
22
+ type: managementTokens[item].type,
23
+ });
24
+ cli_utilities_1.log.debug(`Token processed: ${item}`, { tokenType: managementTokens[item].type });
25
+ });
26
+ const { flags } = await this.parse(AuthTokensListCommand);
27
+ cli_utilities_1.log.debug('Token list flags parsed.', Object.assign(Object.assign({}, this.contextDetails), { flags }));
28
+ const headers = [
29
+ { value: 'alias' },
30
+ { value: 'token' },
31
+ { value: 'apiKey' },
32
+ { value: 'environment' },
33
+ { value: 'type' },
34
+ ];
35
+ cli_utilities_1.log.debug('Displaying token table.', Object.assign(Object.assign({}, this.contextDetails), { tokenCount: tokens.length }));
36
+ cli_utilities_1.cliux.table(headers, tokens, flags);
37
+ cli_utilities_1.log.debug('Token table displayed successfully.', this.contextDetails);
38
+ }
39
+ else {
40
+ cli_utilities_1.log.debug('No tokens found in configuration.', this.contextDetails);
41
+ cli_utilities_1.cliux.print('CLI_AUTH_TOKENS_LIST_NO_TOKENS');
42
+ }
43
+ cli_utilities_1.log.debug('Token list command completed successfully.', this.contextDetails);
44
+ }
45
+ catch (error) {
46
+ cli_utilities_1.log.debug('Token list command failed.', Object.assign(Object.assign({}, this.contextDetails), { error }));
47
+ cli_utilities_1.cliux.print('CLI_AUTH_TOKENS_LIST_FAILED', { color: 'yellow' });
48
+ (0, cli_utilities_1.handleAndLogError)(error, Object.assign({}, this.contextDetails));
49
+ }
50
+ }
51
+ }
52
+ exports.default = AuthTokensListCommand;
53
+ AuthTokensListCommand.description = 'Lists all existing tokens added to the session';
54
+ AuthTokensListCommand.examples = ['$ csdx auth:tokens:list'];
55
+ AuthTokensListCommand.flags = cli_utilities_1.CLITable.getTableFlags([
56
+ 'columns',
57
+ 'sort',
58
+ 'filter',
59
+ 'csv',
60
+ 'no-truncate',
61
+ 'no-header',
62
+ 'output',
63
+ ]);
@@ -233,13 +233,96 @@
233
233
  ]
234
234
  },
235
235
  "auth:tokens": {
236
- "aliases": [
237
- "tokens"
236
+ "aliases": [],
237
+ "args": {},
238
+ "description": "Manage authentication tokens for API access",
239
+ "examples": [
240
+ "$ csdx auth:tokens:list",
241
+ "$ csdx auth:tokens:add --alias mytoken",
242
+ "$ csdx auth:tokens:remove --alias mytoken"
238
243
  ],
244
+ "flags": {
245
+ "columns": {
246
+ "description": "Specify columns to display, comma-separated.",
247
+ "helpGroup": "TABLE",
248
+ "name": "columns",
249
+ "hasDynamicHelp": false,
250
+ "multiple": false,
251
+ "type": "option"
252
+ },
253
+ "sort": {
254
+ "description": "Sort the table by a column. Use \"-\" for descending.",
255
+ "helpGroup": "TABLE",
256
+ "name": "sort",
257
+ "hasDynamicHelp": false,
258
+ "multiple": false,
259
+ "type": "option"
260
+ },
261
+ "filter": {
262
+ "description": "Filter rows by a column value (e.g., name=foo).",
263
+ "helpGroup": "TABLE",
264
+ "name": "filter",
265
+ "hasDynamicHelp": false,
266
+ "multiple": false,
267
+ "type": "option"
268
+ },
269
+ "csv": {
270
+ "description": "Output results in CSV format.",
271
+ "helpGroup": "TABLE",
272
+ "name": "csv",
273
+ "allowNo": false,
274
+ "type": "boolean"
275
+ },
276
+ "no-truncate": {
277
+ "description": "Prevent truncation of long text in columns.",
278
+ "helpGroup": "TABLE",
279
+ "name": "no-truncate",
280
+ "allowNo": false,
281
+ "type": "boolean"
282
+ },
283
+ "no-header": {
284
+ "description": "Hide table headers in output.",
285
+ "helpGroup": "TABLE",
286
+ "name": "no-header",
287
+ "allowNo": false,
288
+ "type": "boolean"
289
+ },
290
+ "output": {
291
+ "description": "Specify output format: csv, json, or yaml.",
292
+ "helpGroup": "TABLE",
293
+ "name": "output",
294
+ "hasDynamicHelp": false,
295
+ "multiple": false,
296
+ "options": [
297
+ "csv",
298
+ "json",
299
+ "yaml"
300
+ ],
301
+ "type": "option"
302
+ }
303
+ },
304
+ "hasDynamicHelp": false,
305
+ "hiddenAliases": [],
306
+ "id": "auth:tokens",
307
+ "pluginAlias": "@contentstack/cli-auth",
308
+ "pluginName": "@contentstack/cli-auth",
309
+ "pluginType": "core",
310
+ "strict": false,
311
+ "isESM": false,
312
+ "relativePath": [
313
+ "lib",
314
+ "commands",
315
+ "auth",
316
+ "tokens",
317
+ "index.js"
318
+ ]
319
+ },
320
+ "auth:tokens:list": {
321
+ "aliases": [],
239
322
  "args": {},
240
323
  "description": "Lists all existing tokens added to the session",
241
324
  "examples": [
242
- "$ csdx auth:tokens"
325
+ "$ csdx auth:tokens:list"
243
326
  ],
244
327
  "flags": {
245
328
  "columns": {
@@ -303,7 +386,7 @@
303
386
  },
304
387
  "hasDynamicHelp": false,
305
388
  "hiddenAliases": [],
306
- "id": "auth:tokens",
389
+ "id": "auth:tokens:list",
307
390
  "pluginAlias": "@contentstack/cli-auth",
308
391
  "pluginName": "@contentstack/cli-auth",
309
392
  "pluginType": "core",
@@ -314,7 +397,7 @@
314
397
  "commands",
315
398
  "auth",
316
399
  "tokens",
317
- "index.js"
400
+ "list.js"
318
401
  ]
319
402
  },
320
403
  "auth:tokens:remove": {
@@ -359,5 +442,5 @@
359
442
  ]
360
443
  }
361
444
  },
362
- "version": "2.0.0-beta.12"
445
+ "version": "2.0.0-beta.14"
363
446
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@contentstack/cli-auth",
3
3
  "description": "Contentstack CLI plugin for authentication activities",
4
- "version": "2.0.0-beta.12",
4
+ "version": "2.0.0-beta.14",
5
5
  "author": "Contentstack",
6
6
  "bugs": "https://github.com/contentstack/cli/issues",
7
7
  "scripts": {
@@ -15,9 +15,9 @@
15
15
  "lint": "eslint src/**/*.ts"
16
16
  },
17
17
  "dependencies": {
18
- "@contentstack/cli-command": "~2.0.0-beta.7",
19
- "@contentstack/cli-utilities": "~2.0.0-beta.8",
20
- "@oclif/core": "^4.10.5",
18
+ "@contentstack/cli-command": "~2.0.0-beta.9",
19
+ "@contentstack/cli-utilities": "~2.0.0-beta.10",
20
+ "@oclif/core": "^4.11.4",
21
21
  "otplib": "^12.0.1"
22
22
  },
23
23
  "overrides": {
@@ -26,26 +26,26 @@
26
26
  }
27
27
  },
28
28
  "devDependencies": {
29
- "@oclif/test": "^4.1.13",
29
+ "@oclif/test": "^4.1.18",
30
30
  "@types/chai": "^4.3.20",
31
31
  "@types/mocha": "^8.2.3",
32
32
  "@types/node": "^14.18.63",
33
33
  "@types/sinon": "^21.0.1",
34
34
  "chai": "^4.5.0",
35
- "dotenv": "^16.4.7",
36
- "eslint": "^9.26.0",
35
+ "dotenv": "^16.6.1",
36
+ "eslint": "^10.5.0",
37
37
  "eslint-config-oclif": "^5.2.2",
38
38
  "eslint-config-oclif-typescript": "^3.1.14",
39
39
  "mocha": "10.8.2",
40
40
  "nock": "^13.5.6",
41
41
  "nyc": "^15.1.0",
42
- "oclif": "^4.23.0",
42
+ "oclif": "^4.23.8",
43
43
  "sinon": "^21.1.2",
44
44
  "ts-node": "^10.9.2",
45
45
  "typescript": "^4.9.5"
46
46
  },
47
47
  "engines": {
48
- "node": ">=14.0.0"
48
+ "node": ">=22.0.0"
49
49
  },
50
50
  "files": [
51
51
  "/lib",