@contentstack/cli-auth 1.1.0 → 1.2.0

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2022 Contentstack
3
+ Copyright (c) 2023 Contentstack
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
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/1.1.0 linux-x64 node-v16.19.0
21
+ @contentstack/cli-auth/1.2.0 linux-x64 node-v16.19.1
22
22
  $ csdx --help [COMMAND]
23
23
  USAGE
24
24
  $ csdx COMMAND
@@ -5,8 +5,9 @@ const cli_utilities_1 = require("@contentstack/cli-utilities");
5
5
  const utils_1 = require("../../utils");
6
6
  class LoginCommand extends cli_command_1.Command {
7
7
  async run() {
8
+ const managementAPIClient = await (0, cli_utilities_1.managementSDKClient)({ host: this.cmaHost });
8
9
  const { flags: loginFlags } = await this.parse(LoginCommand);
9
- utils_1.authHandler.client = this.managementAPIClient;
10
+ utils_1.authHandler.client = managementAPIClient;
10
11
  try {
11
12
  const username = (loginFlags === null || loginFlags === void 0 ? void 0 : loginFlags.username) || (await utils_1.interactive.askUsername());
12
13
  const password = (loginFlags === null || loginFlags === void 0 ? void 0 : loginFlags.password) || (await utils_1.interactive.askPassword());
@@ -40,13 +41,13 @@ LoginCommand.examples = [
40
41
  '$ csdx auth:login --username <username> --password <password>',
41
42
  ];
42
43
  LoginCommand.flags = {
43
- username: cli_command_1.flags.string({
44
+ username: cli_utilities_1.flags.string({
44
45
  char: 'u',
45
46
  description: 'User name',
46
47
  multiple: false,
47
48
  required: false,
48
49
  }),
49
- password: cli_command_1.flags.string({
50
+ password: cli_utilities_1.flags.string({
50
51
  char: 'p',
51
52
  description: 'Password',
52
53
  multiple: false,
@@ -6,7 +6,8 @@ const utils_1 = require("../../utils");
6
6
  class LogoutCommand extends cli_command_1.Command {
7
7
  async run() {
8
8
  const { flags: logoutFlags } = await this.parse(LogoutCommand);
9
- utils_1.authHandler.client = this.managementAPIClient;
9
+ const managementAPIClient = await (0, cli_utilities_1.managementSDKClient)({ host: this.cmaHost });
10
+ utils_1.authHandler.client = managementAPIClient;
10
11
  let confirm = logoutFlags.force === true || logoutFlags.yes === true;
11
12
  if (!confirm) {
12
13
  confirm = await cli_utilities_1.cliux.inquire({
@@ -44,13 +45,13 @@ exports.default = LogoutCommand;
44
45
  LogoutCommand.description = 'User session logout';
45
46
  LogoutCommand.examples = ['$ csdx auth:logout', '$ csdx auth:logout -y', '$ csdx auth:logout --yes'];
46
47
  LogoutCommand.flags = {
47
- yes: cli_command_1.flags.boolean({
48
+ yes: cli_utilities_1.flags.boolean({
48
49
  char: 'y',
49
50
  description: 'Force log out by skipping the confirmation',
50
51
  required: false,
51
52
  default: false,
52
53
  }),
53
- force: cli_command_1.flags.boolean({
54
+ force: cli_utilities_1.flags.boolean({
54
55
  char: 'f',
55
56
  description: 'Force log out by skipping the confirmation',
56
57
  required: false,
@@ -59,8 +59,8 @@ class TokensAddCommand extends cli_command_1.Command {
59
59
  tokenValidationResult = await utils_1.tokenValidation.validateDeliveryToken(this.deliveryAPIClient, apiKey, token, environment, this.region.name, this.cdaHost);
60
60
  }
61
61
  else if (type === 'management') {
62
- this.managementAPIClient = { host: this.cmaHost, authorization: token, api_key: apiKey };
63
- tokenValidationResult = await utils_1.tokenValidation.validateManagementToken(this.managementAPIClient, apiKey, token);
62
+ const managementAPIClient = await (0, cli_utilities_1.managementSDKClient)({ host: this.cmaHost });
63
+ tokenValidationResult = await utils_1.tokenValidation.validateManagementToken(managementAPIClient, apiKey, token);
64
64
  }
65
65
  if (!tokenValidationResult.valid) {
66
66
  throw new cli_utilities_1.CLIError(tokenValidationResult.message);
@@ -101,39 +101,39 @@ TokensAddCommand.examples = [
101
101
  '$ csdx auth:tokens:add --alias <alias> --stack-api-key <stack api key> --delivery -e <environment> --token <delivery token>',
102
102
  ];
103
103
  TokensAddCommand.flags = {
104
- alias: cli_command_1.flags.string({ char: 'a', description: 'Name of the token alias' }),
105
- delivery: cli_command_1.flags.boolean({
104
+ alias: cli_utilities_1.flags.string({ char: 'a', description: 'Name of the token alias' }),
105
+ delivery: cli_utilities_1.flags.boolean({
106
106
  char: 'd',
107
107
  description: 'Set this flag to save delivery token',
108
108
  exclusive: ['management'],
109
109
  parse: (0, cli_utilities_1.printFlagDeprecation)(['-d'], ['--delivery']),
110
110
  }),
111
- management: cli_command_1.flags.boolean({
111
+ management: cli_utilities_1.flags.boolean({
112
112
  char: 'm',
113
113
  description: 'Set this flag to save management token',
114
114
  exclusive: ['delivery', 'environment'],
115
115
  parse: (0, cli_utilities_1.printFlagDeprecation)(['-m'], ['--management']),
116
116
  }),
117
- environment: cli_command_1.flags.string({
117
+ environment: cli_utilities_1.flags.string({
118
118
  char: 'e',
119
119
  description: 'Environment name for delivery token',
120
120
  exclusive: ['management'],
121
121
  }),
122
- 'stack-api-key': cli_command_1.flags.string({ char: 'k', description: 'Stack API Key' }),
123
- yes: cli_command_1.flags.boolean({ char: 'y', description: 'Use this flag to skip confirmation' }),
124
- token: cli_command_1.flags.string({
122
+ 'stack-api-key': cli_utilities_1.flags.string({ char: 'k', description: 'Stack API Key' }),
123
+ yes: cli_utilities_1.flags.boolean({ char: 'y', description: 'Use this flag to skip confirmation' }),
124
+ token: cli_utilities_1.flags.string({
125
125
  char: 't',
126
126
  description: 'Add the token name',
127
127
  env: 'TOKEN',
128
128
  parse: (0, cli_utilities_1.printFlagDeprecation)(['-t'], ['--token']),
129
129
  }),
130
130
  //To be deprecated
131
- 'api-key': cli_command_1.flags.string({
131
+ 'api-key': cli_utilities_1.flags.string({
132
132
  description: 'API Key',
133
133
  hidden: true,
134
134
  parse: (0, cli_utilities_1.printFlagDeprecation)(['api-key'], ['-k', 'stack-api-key']),
135
135
  }),
136
- force: cli_command_1.flags.boolean({
136
+ force: cli_utilities_1.flags.boolean({
137
137
  char: 'f',
138
138
  hidden: true,
139
139
  description: 'Force adding',
@@ -50,6 +50,6 @@ exports.default = TokensRemoveCommand;
50
50
  TokensRemoveCommand.description = 'Removes selected tokens';
51
51
  TokensRemoveCommand.examples = ['$ csdx auth:tokens:remove', '$ csdx auth:tokens:remove -a <alias>'];
52
52
  TokensRemoveCommand.flags = {
53
- alias: cli_command_1.flags.string({ char: 'a', description: 'Token alias' }),
54
- ignore: cli_command_1.flags.boolean({ char: 'i', description: 'Ignore' }),
53
+ alias: cli_utilities_1.flags.string({ char: 'a', description: 'Token alias' }),
54
+ ignore: cli_utilities_1.flags.boolean({ char: 'i', description: 'Ignore' }),
55
55
  };
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.1.0",
2
+ "version": "1.2.0",
3
3
  "commands": {
4
4
  "auth:login": {
5
5
  "id": "auth:login",
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@contentstack/cli-auth",
3
3
  "description": "Contentstack CLI plugin for authentication activities",
4
- "version": "1.1.0",
4
+ "version": "1.2.0",
5
5
  "author": "Contentstack",
6
6
  "bugs": "https://github.com/contentstack/cli/issues",
7
7
  "scripts": {
8
8
  "build": "npm run clean && npm run compile",
9
- "clean": "rm -rf ./lib && rm -rf tsconfig.build.tsbuildinfo",
9
+ "clean": "rm -rf ./lib ./node_modules tsconfig.build.tsbuildinfo",
10
10
  "compile": "tsc -b tsconfig.json",
11
11
  "postpack": "rm -f oclif.manifest.json",
12
- "prepack": "npm run build && oclif manifest && oclif readme",
12
+ "prepack": "pnpm compile && oclif manifest && oclif readme",
13
13
  "version": "oclif readme && git add README.md",
14
14
  "test:report": "tsc -p test && nyc --reporter=lcov --extension .ts mocha --forbid-only \"test/**/*.test.ts\"",
15
15
  "pretest": "tsc -p test",
@@ -21,17 +21,15 @@
21
21
  "test:unit": "mocha --forbid-only \"test/unit/*.test.ts\""
22
22
  },
23
23
  "dependencies": {
24
- "@contentstack/cli-command": "^1.1.0",
25
- "@contentstack/cli-utilities": "^1.1.0",
24
+ "@contentstack/cli-command": "^1.2.0",
25
+ "@contentstack/cli-utilities": "^1.2.0",
26
26
  "chalk": "^4.0.0",
27
27
  "debug": "^4.1.1",
28
28
  "inquirer": "8.2.4",
29
29
  "winston": "^3.7.2"
30
30
  },
31
31
  "devDependencies": {
32
- "oclif": "^3.1.2",
33
32
  "@fancy-test/nock": "^0.1.1",
34
- "@oclif/dev-cli": "^1.26.10",
35
33
  "@oclif/plugin-help": "^5.1.19",
36
34
  "@oclif/test": "^2.2.10",
37
35
  "@types/chai": "^4.2.18",
@@ -40,15 +38,15 @@
40
38
  "@types/mocha": "^8.2.2",
41
39
  "@types/node": "^14.14.32",
42
40
  "@types/sinon": "^10.0.2",
43
- "@types/tar": "^4.0.3",
44
41
  "chai": "^4.3.4",
45
- "dotenv": "^16.0.1",
42
+ "dotenv": "^16.0.3",
46
43
  "eslint": "^8.18.0",
47
- "eslint-config-oclif": "^3.1.0",
44
+ "eslint-config-oclif": "^4.0.0",
48
45
  "eslint-config-oclif-typescript": "^0.1.0",
49
46
  "globby": "^10.0.2",
50
47
  "mocha": "10.1.0",
51
48
  "nyc": "^15.1.0",
49
+ "oclif": "^3.1.2",
52
50
  "rimraf": "^2.7.1",
53
51
  "sinon": "^15.0.1",
54
52
  "tmp": "^0.2.1",
@@ -56,7 +54,7 @@
56
54
  "typescript": "^4.9.3"
57
55
  },
58
56
  "engines": {
59
- "node": ">=8.0.0"
57
+ "node": ">=14.0.0"
60
58
  },
61
59
  "files": [
62
60
  "/lib",