Skip to content

Commit 1f3e446

Browse files
committed
adding remote option
1 parent 6290ad1 commit 1f3e446

File tree

4 files changed

+83
-3
lines changed

4 files changed

+83
-3
lines changed

README.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,13 @@ $ csdx plugins:install contentstack-cli-content-type
2222
<!-- commands -->
2323
* [`csdx content-type:audit`](#csdx-content-typeaudit)
2424
* [`csdx content-type:compare`](#csdx-content-typecompare)
25+
* [`csdx content-type:compare-remote`](#csdx-content-typecompare-remote)
2526
* [`csdx content-type:details`](#csdx-content-typedetails)
2627
* [`csdx content-type:list`](#csdx-content-typelist)
2728

2829
## `csdx content-type:audit`
2930

30-
display Audit Logs for recent changes to a Content Type
31+
display recent changes to a Content Type
3132

3233
```
3334
USAGE
@@ -68,6 +69,25 @@ EXAMPLES
6869

6970
_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)_
7071

72+
## `csdx content-type:compare-remote`
73+
74+
compare two Content Types on different stacks
75+
76+
```
77+
USAGE
78+
$ csdx content-type:compare-remote
79+
80+
OPTIONS
81+
-c, --content-type=content-type (required) Content Type UID
82+
-o, --origin-stack=origin-stack origin stack uid
83+
-r, --remote-stack=remote-stack remote stack uid
84+
85+
EXAMPLE
86+
$ csdx content-type:compare-remote -o "xxxxxxxxxxxxxxxxxxx" -r "xxxxxxxxxxxxxxxxxxx" -c "home_page"
87+
```
88+
89+
_See code: [src/commands/content-type/compare-remote.ts](https://github.com/Contentstack-Solutions/contentstack-cli-content-type/blob/v1.0.0/src/commands/content-type/compare-remote.ts)_
90+
7191
## `csdx content-type:details`
7292

7393
display Content Type details

oclif.manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"version":"1.0.0","commands":{"content-type:audit":{"id":"content-type:audit","description":"display Audit Logs for recent changes to a Content Type","pluginName":"contentstack-cli-content-type","pluginType":"core","aliases":[],"examples":["$ csdx content-type:audit -s \"xxxxxxxxxxxxxxxxxxx\" -c \"home_page\"","$ csdx content-type:audit -a \"management token\" -c \"home_page\""],"flags":{"stack":{"name":"stack","type":"option","char":"s","description":"stack uid","required":false},"token-alias":{"name":"token-alias","type":"option","char":"a","description":"management token alias","required":false},"content-type":{"name":"content-type","type":"option","char":"c","description":"Content Type UID","required":true}},"args":[]},"content-type:compare":{"id":"content-type:compare","description":"compare two Content Type versions","pluginName":"contentstack-cli-content-type","pluginType":"core","aliases":[],"examples":["$ csdx content-type:compare -s \"xxxxxxxxxxxxxxxxxxx\" -c \"home_page\"","$ csdx content-type:compare -s \"xxxxxxxxxxxxxxxxxxx\" -c \"home_page\" -l # -r #","$ csdx content-type:compare -a \"management token\" -c \"home_page\" -l # -r #"],"flags":{"stack":{"name":"stack","type":"option","char":"s","description":"stack uid","required":false},"token-alias":{"name":"token-alias","type":"option","char":"a","description":"management token alias","hidden":false,"required":false},"content-type":{"name":"content-type","type":"option","char":"c","description":"Content Type UID","required":true},"left":{"name":"left","type":"option","char":"l","description":"Content Type version, i.e. prev version","required":false},"right":{"name":"right","type":"option","char":"r","description":"Content Type version, i.e. later version","required":false}},"args":[]},"content-type:details":{"id":"content-type:details","description":"display Content Type details","pluginName":"contentstack-cli-content-type","pluginType":"core","aliases":[],"examples":["$ csdx content-type:details -s \"xxxxxxxxxxxxxxxxxxx\" -c \"home_page\"","$ csdx content-type:details -a \"management token\" -c \"home_page\"","$ csdx content-type:details -a \"management token\" -c \"home_page\" --no-path"],"flags":{"stack":{"name":"stack","type":"option","char":"s","description":"stack uid","required":false},"token-alias":{"name":"token-alias","type":"option","char":"a","description":"management token alias","required":false},"content-type":{"name":"content-type","type":"option","char":"c","description":"Content Type UID","required":true},"path":{"name":"path","type":"boolean","char":"p","description":"show path column","allowNo":true}},"args":[]},"content-type:list":{"id":"content-type:list","description":"list all Content Types in a Stack","pluginName":"contentstack-cli-content-type","pluginType":"core","aliases":[],"examples":["$ csdx content-type:list -s \"xxxxxxxxxxxxxxxxxxx\"","$ csdx content-type:list -a \"management token\"","$ csdx content-type:list -a \"management token\" -o modified"],"flags":{"stack":{"name":"stack","type":"option","char":"s","description":"stack uid","required":false},"token-alias":{"name":"token-alias","type":"option","char":"a","description":"management token alias","required":false},"order":{"name":"order","type":"option","char":"o","description":"order by column","required":false,"options":["title","modified"],"default":"title"}},"args":[]}}}
1+
{"version":"1.0.0","commands":{"content-type:audit":{"id":"content-type:audit","description":"display recent changes to a Content Type","pluginName":"contentstack-cli-content-type","pluginType":"core","aliases":[],"examples":["$ csdx content-type:audit -s \"xxxxxxxxxxxxxxxxxxx\" -c \"home_page\"","$ csdx content-type:audit -a \"management token\" -c \"home_page\""],"flags":{"stack":{"name":"stack","type":"option","char":"s","description":"stack uid","required":false},"token-alias":{"name":"token-alias","type":"option","char":"a","description":"management token alias","required":false},"content-type":{"name":"content-type","type":"option","char":"c","description":"Content Type UID","required":true}},"args":[]},"content-type:compare-remote":{"id":"content-type:compare-remote","description":"compare two Content Types on different stacks","pluginName":"contentstack-cli-content-type","pluginType":"core","aliases":[],"examples":["$ csdx content-type:compare-remote -o \"xxxxxxxxxxxxxxxxxxx\" -r \"xxxxxxxxxxxxxxxxxxx\" -c \"home_page\""],"flags":{"origin-stack":{"name":"origin-stack","type":"option","char":"o","description":"origin stack uid","required":false},"remote-stack":{"name":"remote-stack","type":"option","char":"r","description":"remote stack uid","required":false},"content-type":{"name":"content-type","type":"option","char":"c","description":"Content Type UID","required":true}},"args":[]},"content-type:compare":{"id":"content-type:compare","description":"compare two Content Type versions","pluginName":"contentstack-cli-content-type","pluginType":"core","aliases":[],"examples":["$ csdx content-type:compare -s \"xxxxxxxxxxxxxxxxxxx\" -c \"home_page\"","$ csdx content-type:compare -s \"xxxxxxxxxxxxxxxxxxx\" -c \"home_page\" -l # -r #","$ csdx content-type:compare -a \"management token\" -c \"home_page\" -l # -r #"],"flags":{"stack":{"name":"stack","type":"option","char":"s","description":"stack uid","required":false},"token-alias":{"name":"token-alias","type":"option","char":"a","description":"management token alias","hidden":false,"required":false},"content-type":{"name":"content-type","type":"option","char":"c","description":"Content Type UID","required":true},"left":{"name":"left","type":"option","char":"l","description":"Content Type version, i.e. prev version","required":false},"right":{"name":"right","type":"option","char":"r","description":"Content Type version, i.e. later version","required":false}},"args":[]},"content-type:details":{"id":"content-type:details","description":"display Content Type details","pluginName":"contentstack-cli-content-type","pluginType":"core","aliases":[],"examples":["$ csdx content-type:details -s \"xxxxxxxxxxxxxxxxxxx\" -c \"home_page\"","$ csdx content-type:details -a \"management token\" -c \"home_page\"","$ csdx content-type:details -a \"management token\" -c \"home_page\" --no-path"],"flags":{"stack":{"name":"stack","type":"option","char":"s","description":"stack uid","required":false},"token-alias":{"name":"token-alias","type":"option","char":"a","description":"management token alias","required":false},"content-type":{"name":"content-type","type":"option","char":"c","description":"Content Type UID","required":true},"path":{"name":"path","type":"boolean","char":"p","description":"show path column","allowNo":true}},"args":[]},"content-type:list":{"id":"content-type:list","description":"list all Content Types in a Stack","pluginName":"contentstack-cli-content-type","pluginType":"core","aliases":[],"examples":["$ csdx content-type:list -s \"xxxxxxxxxxxxxxxxxxx\"","$ csdx content-type:list -a \"management token\"","$ csdx content-type:list -a \"management token\" -o modified"],"flags":{"stack":{"name":"stack","type":"option","char":"s","description":"stack uid","required":false},"token-alias":{"name":"token-alias","type":"option","char":"a","description":"management token alias","required":false},"order":{"name":"order","type":"option","char":"o","description":"order by column","required":false,"options":["title","modified"],"default":"title"}},"args":[]}}}

src/commands/content-type/audit.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import cli from 'cli-ux'
44
import buildOutput from '../../core/content-type/audit'
55

66
export default class AuditCommand extends Command {
7-
static description = 'display Audit Logs for recent changes to a Content Type';
7+
static description = 'display recent changes to a Content Type';
88

99
static examples = [
1010
'$ csdx content-type:audit -s "xxxxxxxxxxxxxxxxxxx" -c "home_page"',
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import Command from '../../core/command'
2+
import {flags} from '@contentstack/cli-command'
3+
import cli from 'cli-ux'
4+
import buildOutput from '../../core/content-type/compare'
5+
6+
export default class CompareRemoteCommand extends Command {
7+
static description = 'compare two Content Types on different stacks';
8+
9+
static examples = [
10+
'$ csdx content-type:compare-remote -o "xxxxxxxxxxxxxxxxxxx" -r "xxxxxxxxxxxxxxxxxxx" -c "home_page"',
11+
];
12+
13+
static flags = {
14+
'origin-stack': flags.string({
15+
char: 'o',
16+
description: 'origin stack uid',
17+
required: false,
18+
dependsOn: ['remote-stack'],
19+
}),
20+
21+
'remote-stack': flags.string({
22+
char: 'r',
23+
description: 'remote stack uid',
24+
required: false,
25+
dependsOn: ['origin-stack'],
26+
}),
27+
28+
'content-type': flags.string({
29+
char: 'c',
30+
description: 'Content Type UID',
31+
required: true,
32+
})
33+
}
34+
35+
async run() {
36+
try {
37+
const {flags} = this.parse(CompareRemoteCommand)
38+
this.setup({ 'token-alias': undefined, 'stack': flags['origin-stack'] })
39+
40+
cli.action.start(Command.RequestDataMessage)
41+
42+
const originStackApi = flags['origin-stack'] as string
43+
const remoteStackApi = flags['remote-stack'] as string
44+
45+
const [originStackResp, remoteStackResp, originContentTypeResp, remoteContentTypeResp] = await Promise.all([
46+
this.client.getStack(originStackApi),
47+
this.client.getStack(remoteStackApi),
48+
this.client.getContentType(originStackApi, flags['content-type'], true),
49+
this.client.getContentType(remoteStackApi, flags['content-type'], true),
50+
])
51+
52+
cli.action.stop()
53+
54+
const output = await buildOutput(flags['content-type'], originContentTypeResp, remoteContentTypeResp)
55+
this.printOutput(output, 'changes', flags['content-type'], `${originStackResp.name} <-> ${remoteStackResp.name}`)
56+
} catch (error) {
57+
this.error(error, {exit: 1, suggestions: error.suggestions})
58+
}
59+
}
60+
}

0 commit comments

Comments
 (0)