-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
51 changed files
with
9,321 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"extends": [ | ||
"oclif", | ||
"oclif-typescript" | ||
], | ||
"rules": { | ||
"unicorn/no-abusive-eslint-disable": "off", | ||
"@typescript-eslint/no-use-before-define": "off" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,3 +102,5 @@ dist | |
|
||
# TernJS port file | ||
.tern-port | ||
|
||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,139 @@ | ||
# contentstack-cli-content-type | ||
contentstack-cli-content-type | ||
=== | ||
|
||
Retrieve information about Content Types in a Stack. | ||
|
||
[![oclif](https://img.shields.io/badge/cli-oclif-brightgreen.svg)](https://oclif.io) | ||
[![Version](https://img.shields.io/npm/v/evo.svg)](https://npmjs.org/package/evo) | ||
[![Downloads/week](https://img.shields.io/npm/dw/evo.svg)](https://npmjs.org/package/evo) | ||
[![License](https://img.shields.io/npm/l/evo.svg)](https://github.com/Garbage/evo/blob/master/package.json) | ||
|
||
<!-- toc --> | ||
* [Usage](#usage) | ||
* [Commands](#commands) | ||
<!-- tocstop --> | ||
# Usage | ||
<!-- usage --> | ||
```sh-session | ||
$ npm install -g contentstack-cli-content-type | ||
$ csdx COMMAND | ||
running command... | ||
$ csdx (-v|--version|version) | ||
contentstack-cli-content-type/1.0.0 darwin-x64 node-v12.16.1 | ||
$ csdx --help [COMMAND] | ||
USAGE | ||
$ csdx COMMAND | ||
... | ||
``` | ||
<!-- usagestop --> | ||
# Commands | ||
<!-- commands --> | ||
* [`csdx `](#csdx-) | ||
* [`csdx command`](#csdx-command) | ||
* [`csdx content-type:audit`](#csdx-content-typeaudit) | ||
* [`csdx content-type:compare`](#csdx-content-typecompare) | ||
* [`csdx content-type:details`](#csdx-content-typedetails) | ||
* [`csdx content-type:list`](#csdx-content-typelist) | ||
|
||
## `csdx ` | ||
|
||
``` | ||
USAGE | ||
$ csdx | ||
``` | ||
|
||
_See code: [src/commands/index.ts](https://github.com/Contentstack-Solutions/contentstack-cli-content-type/blob/v1.0.0/src/commands/index.ts)_ | ||
|
||
## `csdx command` | ||
|
||
``` | ||
USAGE | ||
$ csdx command | ||
``` | ||
|
||
_See code: [src/commands/command.ts](https://github.com/Contentstack-Solutions/contentstack-cli-content-type/blob/v1.0.0/src/commands/command.ts)_ | ||
|
||
## `csdx content-type:audit` | ||
|
||
display audit logs for recent changes to a Content Type | ||
|
||
``` | ||
USAGE | ||
$ csdx content-type:audit | ||
OPTIONS | ||
-a, --token-alias=token-alias management token alias | ||
-c, --content-type=content-type (required) Content Type UID | ||
-s, --stack=stack stack uid | ||
EXAMPLES | ||
$ csdx content-type:audit -s "xxxxxxxxxxxxxxxxxxx" -c "home_page" | ||
$ csdx content-type:audit -a "management token" -c "home_page" | ||
``` | ||
|
||
_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)_ | ||
|
||
## `csdx content-type:compare` | ||
|
||
compare two Content Type versions | ||
|
||
``` | ||
USAGE | ||
$ csdx content-type:compare | ||
OPTIONS | ||
-a, --token-alias=token-alias management token alias | ||
-c, --content-type=content-type (required) Content Type UID | ||
-l, --left=left (required) previous Content Type version | ||
-r, --right=right (required) current Content Type version | ||
-s, --stack=stack stack uid | ||
EXAMPLES | ||
$ csdx content-type:compare -s "xxxxxxxxxxxxxxxxxxx" -c "home_page" | ||
$ csdx content-type:compare -s "xxxxxxxxxxxxxxxxxxx" -c "home_page" -left # -right # | ||
$ csdx content-type:compare -a "management token" -c "home_page" -left # -right # | ||
``` | ||
|
||
_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)_ | ||
|
||
## `csdx content-type:details` | ||
|
||
display Content Type details | ||
|
||
``` | ||
USAGE | ||
$ csdx content-type:details | ||
OPTIONS | ||
-a, --token-alias=token-alias management token alias | ||
-c, --content-type=content-type (required) Content Type UID | ||
-s, --stack=stack stack uid | ||
EXAMPLES | ||
$ csdx content-type:details -s "xxxxxxxxxxxxxxxxxxx" -c "home_page" | ||
$ csdx content-type:details -a "management token" -c "home_page" | ||
``` | ||
|
||
_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)_ | ||
|
||
## `csdx content-type:list` | ||
|
||
list all Content Types in a Stack | ||
|
||
``` | ||
USAGE | ||
$ csdx content-type:list | ||
OPTIONS | ||
-a, --token-alias=token-alias management token alias | ||
-o, --order=title|modified [default: title] order by column | ||
-s, --stack=stack stack uid | ||
EXAMPLES | ||
$ csdx content-type:list -s "xxxxxxxxxxxxxxxxxxx" | ||
$ csdx content-type:list -a "management token" | ||
$ csdx content-type:list -a "management token" -o modified | ||
``` | ||
|
||
_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)_ | ||
<!-- commandsstop --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env node | ||
|
||
require('@oclif/command').run() | ||
.catch(require('@oclif/errors/handle')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
@echo off | ||
|
||
node "%~dp0\run" %* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module.exports = { | ||
"roots": [ | ||
"<rootDir>" | ||
], | ||
"testMatch": [ | ||
"**/tests/**/*.+(ts|tsx)", | ||
"**/?(*.)+(spec|test).+(ts|tsx)" | ||
], | ||
"transform": { | ||
"^.+\\.(ts|tsx)$": "ts-jest" | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { Command } from '@contentstack/cli-command'; | ||
import ContentstackClient from '../core/contentstack/client'; | ||
export default class ContentTypeCommand extends Command { | ||
protected apiKey: string; | ||
protected client: ContentstackClient; | ||
setup(flags: any): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const tslib_1 = require("tslib"); | ||
const cli_command_1 = require("@contentstack/cli-command"); | ||
const client_1 = tslib_1.__importDefault(require("../core/contentstack/client")); | ||
class ContentTypeCommand extends cli_command_1.Command { | ||
setup(flags) { | ||
if (!this.authToken) { | ||
this.error('You need to login, first. See: auth:login --help', { exit: 2, suggestions: ['https://www.contentstack.com/docs/developers/cli/authentication/'] }); | ||
} | ||
if (!flags['token-alias'] && !flags.stack) { | ||
this.error('You must provide either a token alias or a Stack UID.', { exit: 2 }); | ||
} | ||
if (flags['token-alias']) { | ||
const token = this.getToken(flags['token-alias']); | ||
if (token.type !== 'management') { | ||
this.warn('Possibly using a delivery token. You may not be able to connect to your Stack. Please use a management token.'); | ||
} | ||
this.apiKey = token.apiKey; | ||
} | ||
else { | ||
this.apiKey = flags.stack; | ||
} | ||
this.client = new client_1.default(this.cmaHost, this.authToken); | ||
} | ||
} | ||
exports.default = ContentTypeCommand; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import Command from '../command'; | ||
import { flags } from '@contentstack/cli-command'; | ||
export default class AuditCommand extends Command { | ||
static description: string; | ||
static examples: string[]; | ||
static flags: { | ||
stack: flags.IOptionFlag<string | undefined>; | ||
'token-alias': flags.IOptionFlag<string | undefined>; | ||
'content-type': flags.IOptionFlag<string>; | ||
}; | ||
run(): Promise<void>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const tslib_1 = require("tslib"); | ||
const command_1 = tslib_1.__importDefault(require("../command")); | ||
const cli_command_1 = require("@contentstack/cli-command"); | ||
const audit_1 = tslib_1.__importDefault(require("../../core/content-type/audit")); | ||
class AuditCommand extends command_1.default { | ||
async run() { | ||
try { | ||
const { flags } = this.parse(AuditCommand); | ||
this.setup(flags); | ||
const [stack, audit, users] = await Promise.all([ | ||
this.client.getStack(this.apiKey), | ||
this.client.getContentTypeAuditLogs(this.apiKey, flags['content-type']), | ||
this.client.getUsers(this.apiKey), | ||
]); | ||
this.log(`Displaying audit logs for '${flags['content-type']}' on '${stack.name}.'\n`); | ||
const output = audit_1.default(audit.logs, users); | ||
if (output.hasRows) { | ||
this.log(output.body); | ||
} | ||
else { | ||
this.log('No audit logs found.'); | ||
} | ||
} | ||
catch (error) { | ||
this.error(error, { exit: 1, suggestions: error.suggestions }); | ||
} | ||
} | ||
} | ||
exports.default = AuditCommand; | ||
AuditCommand.description = 'display audit logs for recent changes to a Content Type'; | ||
AuditCommand.examples = [ | ||
'$ csdx content-type:audit -s "xxxxxxxxxxxxxxxxxxx" -c "home_page"', | ||
'$ csdx content-type:audit -a "management token" -c "home_page"', | ||
]; | ||
AuditCommand.flags = { | ||
stack: cli_command_1.flags.string({ | ||
char: 's', | ||
description: 'stack uid', | ||
required: false, | ||
exclusive: ['token-alias'], | ||
}), | ||
'token-alias': cli_command_1.flags.string({ | ||
char: 'a', | ||
description: 'management token alias', | ||
required: false, | ||
multiple: false, | ||
}), | ||
'content-type': cli_command_1.flags.string({ | ||
char: 'c', | ||
description: 'Content Type UID', | ||
required: true, | ||
}), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import Command from '../command'; | ||
import { flags } from '@contentstack/cli-command'; | ||
export default class CompareCommand extends Command { | ||
static description: string; | ||
static examples: string[]; | ||
static flags: { | ||
stack: flags.IOptionFlag<string | undefined>; | ||
'token-alias': flags.IOptionFlag<string | undefined>; | ||
'content-type': flags.IOptionFlag<string>; | ||
left: import("@oclif/parser/lib/flags").IOptionFlag<number>; | ||
right: import("@oclif/parser/lib/flags").IOptionFlag<number>; | ||
}; | ||
run(): Promise<void>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const tslib_1 = require("tslib"); | ||
const command_1 = tslib_1.__importDefault(require("../command")); | ||
const cli_command_1 = require("@contentstack/cli-command"); | ||
const compare_1 = tslib_1.__importDefault(require("../../core/content-type/compare")); | ||
class CompareCommand extends command_1.default { | ||
async run() { | ||
try { | ||
const { flags } = this.parse(CompareCommand); | ||
this.setup(flags); | ||
const [stack, previous, current] = await Promise.all([ | ||
this.client.getStack(this.apiKey), | ||
this.client.getContentType(this.apiKey, flags['content-type'], true, flags.left), | ||
this.client.getContentType(this.apiKey, flags['content-type'], true, flags.right), | ||
]); | ||
this.log(`Displaying details for '${flags['content-type']}' on '${stack.name}.'`); | ||
await compare_1.default(flags['content-type'], previous, current); | ||
} | ||
catch (error) { | ||
this.error(error, { exit: 1, suggestions: error.suggestions }); | ||
} | ||
} | ||
} | ||
exports.default = CompareCommand; | ||
CompareCommand.description = 'compare two Content Type versions'; | ||
CompareCommand.examples = [ | ||
'$ csdx content-type:compare -s "xxxxxxxxxxxxxxxxxxx" -c "home_page"', | ||
'$ csdx content-type:compare -s "xxxxxxxxxxxxxxxxxxx" -c "home_page" -left # -right #', | ||
'$ csdx content-type:compare -a "management token" -c "home_page" -left # -right #', | ||
]; | ||
CompareCommand.flags = { | ||
stack: cli_command_1.flags.string({ | ||
char: 's', | ||
description: 'stack uid', | ||
required: false, | ||
exclusive: ['token-alias'], | ||
}), | ||
'token-alias': cli_command_1.flags.string({ | ||
char: 'a', | ||
description: 'management token alias', | ||
hidden: false, | ||
multiple: false, | ||
required: false, | ||
}), | ||
'content-type': cli_command_1.flags.string({ | ||
char: 'c', | ||
description: 'Content Type UID', | ||
required: true, | ||
}), | ||
left: cli_command_1.flags.integer({ | ||
char: 'l', | ||
description: 'previous Content Type version', | ||
required: true, | ||
}), | ||
right: cli_command_1.flags.integer({ | ||
char: 'r', | ||
description: 'current Content Type version', | ||
required: true, | ||
}), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import Command from '../command'; | ||
import { flags } from '@contentstack/cli-command'; | ||
export default class DetailsCommand extends Command { | ||
static description: string; | ||
static examples: string[]; | ||
static flags: { | ||
stack: flags.IOptionFlag<string | undefined>; | ||
'token-alias': flags.IOptionFlag<string | undefined>; | ||
'content-type': flags.IOptionFlag<string>; | ||
}; | ||
run(): Promise<void>; | ||
} |
Oops, something went wrong.