@contentstack/cli-command 0.1.0-beta → 0.1.1-beta.3

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
@@ -1,4 +1,6 @@
1
1
  @contentstack/cli-command
2
2
  ===================
3
3
 
4
- Base class for Contentstack CLI commands. Built off of [oclif](https://oclif.io).
4
+ [![License](https://img.shields.io/npm/l/@contentstack/cli)](https://github.com/contentstack/cli/blob/main/LICENSE)
5
+
6
+ Base class for Contentstack CLI commands. Built off of [oclif](https://oclif.io). To get started with Contentstack CLI, refer to the [CLI documentation](https://www.contentstack.com/docs/developers/cli/).
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@contentstack/cli-command",
3
- "version": "0.1.0-beta",
3
+ "version": "0.1.1-beta.3",
4
4
  "description": "Base class for Contentstack command",
5
- "main": "index.js",
5
+ "main": "./src/index.js",
6
6
  "author": "Contentstack",
7
7
  "scripts": {
8
8
  "test": "nyc mocha --forbid-only \\\"test/**/*.test.js\\\""
@@ -11,12 +11,16 @@
11
11
  "type": "git",
12
12
  "url": "git+https://github.com/contentstack/cli.git"
13
13
  },
14
+ "files": [
15
+ "./src"
16
+ ],
14
17
  "license": "MIT",
15
18
  "bugs": "https://github.com/contentstack/cli/issues",
16
19
  "homepage": "https://github.com/contentstack/cli#readme",
17
20
  "dependencies": {
18
- "@contentstack/management": "^1.0.0",
21
+ "@contentstack/management": "^1.3.0",
19
22
  "@oclif/command": "^1.8.0",
23
+ "@oclif/config": "^1.17.0",
20
24
  "configstore": "^5.0.1",
21
25
  "contentstack": "^3.10.1"
22
26
  },
package/.editorconfig DELETED
@@ -1,11 +0,0 @@
1
- root = true
2
-
3
- [*]
4
- indent_style = space
5
- indent_size = 2
6
- charset = utf-8
7
- trim_trailing_whitespace = true
8
- insert_final_newline = true
9
-
10
- [*.md]
11
- trim_trailing_whitespace = false
package/.eslintrc DELETED
@@ -1,3 +0,0 @@
1
- {
2
- "extends": "oclif"
3
- }
package/custom-errors.js DELETED
@@ -1,23 +0,0 @@
1
- class TokenNotFound extends Error {
2
- constructor(value) {
3
- super()
4
- this.value = value
5
- this.message = 'Token not found'
6
- this.toString = function () {
7
- return this.value + this.message
8
- }
9
- }
10
- }
11
-
12
- class NotLoggedIn extends Error {
13
- constructor() {
14
- super()
15
- this.message = 'You are not logged in. Please login with command $ csdx auth:login'
16
- this.toString = function () {
17
- return this.message
18
- }
19
- }
20
- }
21
-
22
- module.exports.TokenNotFound = TokenNotFound
23
- module.exports.NotLoggedIn = NotLoggedIn
package/index.js DELETED
@@ -1,85 +0,0 @@
1
- const {Command, flags} = require('@oclif/command')
2
- const ContentstackManagementSDK = require('@contentstack/management')
3
- const ContentstackDeliverySDK = require('contentstack')
4
- const {TokenNotFound, NotLoggedIn} = require('./custom-errors')
5
- const Configstore = require('configstore')
6
- const config = new Configstore('contentstack_cli')
7
- const url = require('url')
8
- const defaultRegion = {cma: 'https://api.contentstack.io', cda: 'https://cdn.contentstack.io', name: 'NA'}
9
-
10
- class ContentstackCommand extends Command {
11
-
12
- get managementAPIClient() {
13
- if (this._managementAPIClient) return this._managementAPIClient
14
- this._managementAPIClient = ContentstackManagementSDK.client({host:this.cmaHost})
15
- return this._managementAPIClient
16
- }
17
-
18
- get email() {
19
- if (this._email) return this._email
20
- this._email = config.get('email')
21
- if(this._email) return this._email
22
- throw new NotLoggedIn()
23
- }
24
-
25
- get deliveryAPIClient() {
26
- if (this._deliveryAPIClient) return this._deliveryAPIClient
27
- this._deliveryAPIClient = ContentstackDeliverySDK
28
- return this._deliveryAPIClient
29
- }
30
-
31
- get region() {
32
- if (this._region) return this._region
33
- this._region = config.get('region')
34
- if (this._region) return this._region
35
- return defaultRegion
36
- }
37
-
38
- get cmaHost() {
39
- let cma = this.region.cma
40
- if (cma.startsWith('http')) {
41
- const u = url.parse(cma)
42
- if (u.host) return u.host
43
- }
44
- return cma
45
- }
46
-
47
- get cdaHost() {
48
- let cda = this.region.cda
49
- if (cda.startsWith('http')) {
50
- const u = url.parse(cda)
51
- if (u.host) return u.host
52
- }
53
- return cda
54
- }
55
-
56
- get cdaAPIUrl() {
57
- let cda = this.region.cda
58
- return cda.startsWith('http') ? cda : `https://${cda}`
59
- }
60
-
61
- get cmaAPIUrl() {
62
- let cma = this.region.cma
63
- return cma.startsWith('http') ? cma : `https://${cma}`
64
- }
65
-
66
- get authToken() {
67
- if (this._authToken) return this._authToken
68
- this._authToken = config.get('authtoken')
69
- if (this._authToken) return this._authToken
70
- throw new NotLoggedIn()
71
- }
72
-
73
- getToken(alias) {
74
- if (alias) {
75
- const token = config.get(`tokens.${alias}`)
76
- if (token) return token
77
- }
78
- throw new TokenNotFound(alias)
79
- }
80
- }
81
-
82
- module.exports = {
83
- Command: ContentstackCommand,
84
- flags
85
- }