@contentstack/cli-command 1.0.4 → 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/lib/index.js CHANGED
@@ -1,27 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.flags = exports.Command = void 0;
4
- const command_1 = require("@oclif/command");
5
- Object.defineProperty(exports, "flags", { enumerable: true, get: function () { return command_1.flags; } });
6
- const ContentstackManagementSDK = require("@contentstack/management");
3
+ exports.Command = void 0;
7
4
  const ContentstackDeliverySDK = require("contentstack");
8
5
  const url = require("url");
9
6
  const cli_utilities_1 = require("@contentstack/cli-utilities");
10
7
  const defaultRateLimit = 5;
11
- class ContentstackCommand extends command_1.Command {
8
+ class ContentstackCommand extends cli_utilities_1.Command {
12
9
  get context() {
13
10
  // @ts-ignore
14
11
  return this.config.context;
15
12
  }
16
- get managementAPIClient() {
17
- if (this._managementAPIClient)
18
- return this._managementAPIClient;
19
- this._managementAPIClient = ContentstackManagementSDK.client({ host: this.cmaHost });
20
- return this._managementAPIClient;
21
- }
22
- set managementAPIClient(params) {
23
- this._managementAPIClient = ContentstackManagementSDK.client(params);
24
- }
25
13
  get email() {
26
14
  if (this._email)
27
15
  return this._email;
@@ -81,7 +69,6 @@ class ContentstackCommand extends command_1.Command {
81
69
  this._authToken = cli_utilities_1.configHandler.get('authtoken');
82
70
  if (this._authToken)
83
71
  return this._authToken;
84
- // throw new CLIError('You are not logged in. Please login with command $ csdx auth:login');
85
72
  }
86
73
  getToken(alias) {
87
74
  if (alias) {
@@ -91,9 +78,17 @@ class ContentstackCommand extends command_1.Command {
91
78
  }
92
79
  throw new cli_utilities_1.CLIError('No token found');
93
80
  }
81
+ isAuthenticated() {
82
+ const authtoken = cli_utilities_1.configHandler.get('authtoken');
83
+ if (authtoken) {
84
+ return true;
85
+ }
86
+ else {
87
+ return false;
88
+ }
89
+ }
94
90
  }
95
91
  exports.Command = ContentstackCommand;
96
92
  module.exports = {
97
93
  Command: ContentstackCommand,
98
- flags: command_1.flags,
99
94
  };
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@contentstack/cli-command",
3
3
  "description": "Contentstack CLI plugin for configuration",
4
- "version": "1.0.4",
4
+ "version": "1.2.0",
5
5
  "author": "Contentstack",
6
6
  "main": "lib/index.js",
7
7
  "types": "./types/index.d.ts",
8
8
  "scripts": {
9
- "prepack": "npm run clean && npm run compile",
10
- "clean": "rm -rf ./lib && rm -rf tsconfig.build.tsbuildinfo",
9
+ "prepack": "pnpm compile",
10
+ "clean": "rm -rf ./lib ./node_modules tsconfig.build.tsbuildinfo",
11
11
  "compile": "tsc -b tsconfig.json",
12
12
  "test:report": "tsc -p test && nyc --reporter=lcov --extension .ts mocha --forbid-only \"test/**/*.test.ts\"",
13
13
  "pretest": "tsc -p test",
@@ -17,32 +17,30 @@
17
17
  "format": "eslint src/**/*.ts --fix"
18
18
  },
19
19
  "dependencies": {
20
- "@contentstack/cli-utilities": "^1.0.5",
21
- "@contentstack/management": "^1.6.0",
22
- "@oclif/command": "^1.8.16",
20
+ "@contentstack/cli-utilities": "^1.2.0",
21
+ "@contentstack/management": "^1.6.1",
23
22
  "contentstack": "^3.10.1"
24
23
  },
25
24
  "devDependencies": {
26
- "@oclif/test": "^1.2.8",
25
+ "@oclif/test": "^2.2.10",
27
26
  "@types/chai": "^4.2.18",
28
27
  "@types/mkdirp": "^1.0.1",
29
28
  "@types/mocha": "^8.2.2",
30
29
  "@types/node": "^14.14.32",
31
30
  "@types/sinon": "^10.0.2",
32
- "@types/tar": "^4.0.3",
33
31
  "chai": "^4.3.4",
34
32
  "eslint": "^8.18.0",
35
- "eslint-config-oclif": "^3.1.0",
33
+ "eslint-config-oclif": "^4.0.0",
36
34
  "eslint-config-oclif-typescript": "^0.1.0",
37
35
  "mocha": "10.1.0",
38
36
  "nyc": "^15.1.0",
39
37
  "rimraf": "^2.7.1",
40
- "sinon": "^11.1.1",
38
+ "sinon": "^15.0.1",
41
39
  "ts-node": "^8.10.2",
42
40
  "typescript": "^4.9.3"
43
41
  },
44
42
  "engines": {
45
- "node": ">=8.0.0"
43
+ "node": ">=14.0.0"
46
44
  },
47
45
  "files": [
48
46
  "/types",
package/types/index.d.ts CHANGED
@@ -1,24 +1,22 @@
1
- import { Command, flags } from '@oclif/command';
1
+ import { Command } from '@contentstack/cli-utilities';
2
2
  import { Region } from './interfaces';
3
3
  declare abstract class ContentstackCommand extends Command {
4
- private _managementAPIClient;
5
- private _email;
6
- private _region;
7
- private _rateLimit;
8
- private _authToken;
9
- private _deliveryAPIClient;
10
- get context(): any;
11
- get managementAPIClient(): object;
12
- set managementAPIClient(params: object);
13
- get email(): string;
14
- get deliveryAPIClient(): any;
15
- get region(): Region;
16
- get rateLimit(): string | 5;
17
- get cmaHost(): string;
18
- get cdaHost(): string;
19
- get cdaAPIUrl(): string;
20
- get cmaAPIUrl(): string;
21
- get authToken(): string;
22
- getToken(alias: any): any;
4
+ private _email;
5
+ private _region;
6
+ private _rateLimit;
7
+ private _authToken;
8
+ private _deliveryAPIClient;
9
+ get context(): any;
10
+ get email(): string;
11
+ get deliveryAPIClient(): any;
12
+ get region(): Region;
13
+ get rateLimit(): string | 5;
14
+ get cmaHost(): string;
15
+ get cdaHost(): string;
16
+ get cdaAPIUrl(): string;
17
+ get cmaAPIUrl(): string;
18
+ get authToken(): string;
19
+ getToken(alias: any): any;
20
+ isAuthenticated(): any;
23
21
  }
24
- export { ContentstackCommand as Command, flags };
22
+ export { ContentstackCommand as Command };