@contentstack/cli-command 1.1.0 → 1.2.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/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,26 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.flags = exports.Command = void 0;
4
- const core_1 = require("@oclif/core");
5
- Object.defineProperty(exports, "flags", { enumerable: true, get: function () { return core_1.Flags; } });
6
- const ContentstackManagementSDK = require("@contentstack/management");
3
+ exports.Command = void 0;
7
4
  const ContentstackDeliverySDK = require("contentstack");
8
- const url = require("url");
5
+ const url_1 = require("url");
9
6
  const cli_utilities_1 = require("@contentstack/cli-utilities");
10
7
  const defaultRateLimit = 5;
11
- class ContentstackCommand extends core_1.Command {
8
+ class ContentstackCommand extends cli_utilities_1.Command {
12
9
  get context() {
13
10
  // @ts-ignore
14
- return this.config.context;
15
- }
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);
11
+ return this.config.context || {};
24
12
  }
25
13
  get email() {
26
14
  if (this._email)
@@ -52,7 +40,7 @@ class ContentstackCommand extends core_1.Command {
52
40
  get cmaHost() {
53
41
  let cma = this.region.cma;
54
42
  if (cma.startsWith('http')) {
55
- const u = url.parse(cma);
43
+ const u = new url_1.URL(cma);
56
44
  if (u.host)
57
45
  return u.host;
58
46
  }
@@ -61,7 +49,7 @@ class ContentstackCommand extends core_1.Command {
61
49
  get cdaHost() {
62
50
  let cda = this.region.cda;
63
51
  if (cda.startsWith('http')) {
64
- const u = url.parse(cda);
52
+ const u = new url_1.URL(cda);
65
53
  if (u.host)
66
54
  return u.host;
67
55
  }
@@ -90,18 +78,8 @@ class ContentstackCommand extends core_1.Command {
90
78
  }
91
79
  throw new cli_utilities_1.CLIError('No token found');
92
80
  }
93
- isAuthenticated() {
94
- const authtoken = cli_utilities_1.configHandler.get('authtoken');
95
- if (authtoken) {
96
- return true;
97
- }
98
- else {
99
- return false;
100
- }
101
- }
102
81
  }
103
82
  exports.Command = ContentstackCommand;
104
83
  module.exports = {
105
84
  Command: ContentstackCommand,
106
- flags: core_1.Flags,
107
85
  };
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.1.0",
4
+ "version": "1.2.1",
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,8 +17,7 @@
17
17
  "format": "eslint src/**/*.ts --fix"
18
18
  },
19
19
  "dependencies": {
20
- "@oclif/core": "^1.21.0",
21
- "@contentstack/cli-utilities": "^1.1.0",
20
+ "@contentstack/cli-utilities": "^1.2.1",
22
21
  "@contentstack/management": "^1.6.1",
23
22
  "contentstack": "^3.10.1"
24
23
  },
@@ -29,10 +28,9 @@
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",
@@ -42,7 +40,7 @@
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,15 +1,12 @@
1
- import { Command, Flags } from '@oclif/core';
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
4
  private _email;
6
5
  private _region;
7
6
  private _rateLimit;
8
7
  private _authToken;
9
8
  private _deliveryAPIClient;
10
9
  get context(): any;
11
- get managementAPIClient(): object;
12
- set managementAPIClient(params: object);
13
10
  get email(): string;
14
11
  get deliveryAPIClient(): any;
15
12
  get region(): Region;
@@ -20,6 +17,5 @@ declare abstract class ContentstackCommand extends Command {
20
17
  get cmaAPIUrl(): string;
21
18
  get authToken(): string;
22
19
  getToken(alias: any): any;
23
- isAuthenticated(): any;
24
20
  }
25
- export { ContentstackCommand as Command, Flags as flags };
21
+ export { ContentstackCommand as Command };