Skip to content

Commit 35c7bdb

Browse files
committed
initial commit
1 parent ce35dea commit 35c7bdb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+9321
-1
lines changed

.editorconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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

.eslintignore

Whitespace-only changes.

.eslintrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"extends": [
3+
"oclif",
4+
"oclif-typescript"
5+
],
6+
"rules": {
7+
"unicorn/no-abusive-eslint-disable": "off",
8+
"@typescript-eslint/no-use-before-define": "off"
9+
}
10+
}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,5 @@ dist
102102

103103
# TernJS port file
104104
.tern-port
105+
106+
.DS_Store

README.md

Lines changed: 139 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,139 @@
1-
# contentstack-cli-content-type
1+
contentstack-cli-content-type
2+
===
3+
4+
Retrieve information about Content Types in a Stack.
5+
6+
[![oclif](https://img.shields.io/badge/cli-oclif-brightgreen.svg)](https://oclif.io)
7+
[![Version](https://img.shields.io/npm/v/evo.svg)](https://npmjs.org/package/evo)
8+
[![Downloads/week](https://img.shields.io/npm/dw/evo.svg)](https://npmjs.org/package/evo)
9+
[![License](https://img.shields.io/npm/l/evo.svg)](https://github.com/Garbage/evo/blob/master/package.json)
10+
11+
<!-- toc -->
12+
* [Usage](#usage)
13+
* [Commands](#commands)
14+
<!-- tocstop -->
15+
# Usage
16+
<!-- usage -->
17+
```sh-session
18+
$ npm install -g contentstack-cli-content-type
19+
$ csdx COMMAND
20+
running command...
21+
$ csdx (-v|--version|version)
22+
contentstack-cli-content-type/1.0.0 darwin-x64 node-v12.16.1
23+
$ csdx --help [COMMAND]
24+
USAGE
25+
$ csdx COMMAND
26+
...
27+
```
28+
<!-- usagestop -->
29+
# Commands
30+
<!-- commands -->
31+
* [`csdx `](#csdx-)
32+
* [`csdx command`](#csdx-command)
33+
* [`csdx content-type:audit`](#csdx-content-typeaudit)
34+
* [`csdx content-type:compare`](#csdx-content-typecompare)
35+
* [`csdx content-type:details`](#csdx-content-typedetails)
36+
* [`csdx content-type:list`](#csdx-content-typelist)
37+
38+
## `csdx `
39+
40+
```
41+
USAGE
42+
$ csdx
43+
```
44+
45+
_See code: [src/commands/index.ts](https://github.com/Contentstack-Solutions/contentstack-cli-content-type/blob/v1.0.0/src/commands/index.ts)_
46+
47+
## `csdx command`
48+
49+
```
50+
USAGE
51+
$ csdx command
52+
```
53+
54+
_See code: [src/commands/command.ts](https://github.com/Contentstack-Solutions/contentstack-cli-content-type/blob/v1.0.0/src/commands/command.ts)_
55+
56+
## `csdx content-type:audit`
57+
58+
display audit logs for recent changes to a Content Type
59+
60+
```
61+
USAGE
62+
$ csdx content-type:audit
63+
64+
OPTIONS
65+
-a, --token-alias=token-alias management token alias
66+
-c, --content-type=content-type (required) Content Type UID
67+
-s, --stack=stack stack uid
68+
69+
EXAMPLES
70+
$ csdx content-type:audit -s "xxxxxxxxxxxxxxxxxxx" -c "home_page"
71+
$ csdx content-type:audit -a "management token" -c "home_page"
72+
```
73+
74+
_See code: [src/commands/content-type/audit.ts](https://github.com/Contentstack-Solutions/contentstack-cli-content-type/blob/v1.0.0/src/commands/content-type/audit.ts)_
75+
76+
## `csdx content-type:compare`
77+
78+
compare two Content Type versions
79+
80+
```
81+
USAGE
82+
$ csdx content-type:compare
83+
84+
OPTIONS
85+
-a, --token-alias=token-alias management token alias
86+
-c, --content-type=content-type (required) Content Type UID
87+
-l, --left=left (required) previous Content Type version
88+
-r, --right=right (required) current Content Type version
89+
-s, --stack=stack stack uid
90+
91+
EXAMPLES
92+
$ csdx content-type:compare -s "xxxxxxxxxxxxxxxxxxx" -c "home_page"
93+
$ csdx content-type:compare -s "xxxxxxxxxxxxxxxxxxx" -c "home_page" -left # -right #
94+
$ csdx content-type:compare -a "management token" -c "home_page" -left # -right #
95+
```
96+
97+
_See code: [src/commands/content-type/compare.ts](https://github.com/Contentstack-Solutions/contentstack-cli-content-type/blob/v1.0.0/src/commands/content-type/compare.ts)_
98+
99+
## `csdx content-type:details`
100+
101+
display Content Type details
102+
103+
```
104+
USAGE
105+
$ csdx content-type:details
106+
107+
OPTIONS
108+
-a, --token-alias=token-alias management token alias
109+
-c, --content-type=content-type (required) Content Type UID
110+
-s, --stack=stack stack uid
111+
112+
EXAMPLES
113+
$ csdx content-type:details -s "xxxxxxxxxxxxxxxxxxx" -c "home_page"
114+
$ csdx content-type:details -a "management token" -c "home_page"
115+
```
116+
117+
_See code: [src/commands/content-type/details.ts](https://github.com/Contentstack-Solutions/contentstack-cli-content-type/blob/v1.0.0/src/commands/content-type/details.ts)_
118+
119+
## `csdx content-type:list`
120+
121+
list all Content Types in a Stack
122+
123+
```
124+
USAGE
125+
$ csdx content-type:list
126+
127+
OPTIONS
128+
-a, --token-alias=token-alias management token alias
129+
-o, --order=title|modified [default: title] order by column
130+
-s, --stack=stack stack uid
131+
132+
EXAMPLES
133+
$ csdx content-type:list -s "xxxxxxxxxxxxxxxxxxx"
134+
$ csdx content-type:list -a "management token"
135+
$ csdx content-type:list -a "management token" -o modified
136+
```
137+
138+
_See code: [src/commands/content-type/list.ts](https://github.com/Contentstack-Solutions/contentstack-cli-content-type/blob/v1.0.0/src/commands/content-type/list.ts)_
139+
<!-- commandsstop -->

bin/run

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env node
2+
3+
require('@oclif/command').run()
4+
.catch(require('@oclif/errors/handle'))

bin/run.cmd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@echo off
2+
3+
node "%~dp0\run" %*

jest.config.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module.exports = {
2+
"roots": [
3+
"<rootDir>"
4+
],
5+
"testMatch": [
6+
"**/tests/**/*.+(ts|tsx)",
7+
"**/?(*.)+(spec|test).+(ts|tsx)"
8+
],
9+
"transform": {
10+
"^.+\\.(ts|tsx)$": "ts-jest"
11+
},
12+
}

lib/commands/command.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { Command } from '@contentstack/cli-command';
2+
import ContentstackClient from '../core/contentstack/client';
3+
export default class ContentTypeCommand extends Command {
4+
protected apiKey: string;
5+
protected client: ContentstackClient;
6+
setup(flags: any): void;
7+
}

lib/commands/command.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
3+
const tslib_1 = require("tslib");
4+
const cli_command_1 = require("@contentstack/cli-command");
5+
const client_1 = tslib_1.__importDefault(require("../core/contentstack/client"));
6+
class ContentTypeCommand extends cli_command_1.Command {
7+
setup(flags) {
8+
if (!this.authToken) {
9+
this.error('You need to login, first. See: auth:login --help', { exit: 2, suggestions: ['https://www.contentstack.com/docs/developers/cli/authentication/'] });
10+
}
11+
if (!flags['token-alias'] && !flags.stack) {
12+
this.error('You must provide either a token alias or a Stack UID.', { exit: 2 });
13+
}
14+
if (flags['token-alias']) {
15+
const token = this.getToken(flags['token-alias']);
16+
if (token.type !== 'management') {
17+
this.warn('Possibly using a delivery token. You may not be able to connect to your Stack. Please use a management token.');
18+
}
19+
this.apiKey = token.apiKey;
20+
}
21+
else {
22+
this.apiKey = flags.stack;
23+
}
24+
this.client = new client_1.default(this.cmaHost, this.authToken);
25+
}
26+
}
27+
exports.default = ContentTypeCommand;

0 commit comments

Comments
 (0)