contensis-cli 1.0.0-beta.53 → 1.0.0-beta.55
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/.vscode/launch.json +15 -15
- package/README.md +1226 -1226
- package/dist/commands/connect.js.map +1 -1
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/diff.js.map +1 -1
- package/dist/commands/get.js.map +1 -1
- package/dist/commands/globalOptions.js.map +1 -1
- package/dist/commands/import.js.map +1 -1
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/list.js.map +1 -1
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/push.js.map +1 -1
- package/dist/commands/release.js.map +1 -1
- package/dist/commands/remove.js.map +1 -1
- package/dist/commands/set.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/localisation/en-GB.js.map +1 -1
- package/dist/providers/CredentialProvider.js.map +1 -1
- package/dist/providers/SessionCacheProvider.js.map +1 -1
- package/dist/providers/file-provider.js.map +1 -1
- package/dist/services/ContensisAuthService.js.map +1 -1
- package/dist/services/ContensisCliService.js +4 -0
- package/dist/services/ContensisCliService.js.map +2 -2
- package/dist/shell.js.map +1 -1
- package/dist/util/console.printer.js +5 -5
- package/dist/util/console.printer.js.map +2 -2
- package/dist/util/csv.formatter.js.map +1 -1
- package/dist/util/index.js.map +1 -1
- package/dist/util/json.formatter.js.map +1 -1
- package/dist/util/logger.js.map +1 -1
- package/dist/util/xml.formatter.js.map +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/esbuild.config.js +49 -49
- package/headless-setup.sh +6 -6
- package/package.json +59 -59
- package/src/commands/connect.ts +24 -24
- package/src/commands/create.ts +70 -70
- package/src/commands/diff.ts +41 -41
- package/src/commands/get.ts +214 -214
- package/src/commands/globalOptions.ts +127 -127
- package/src/commands/import.ts +128 -128
- package/src/commands/index.ts +80 -80
- package/src/commands/list.ts +116 -116
- package/src/commands/login.ts +34 -34
- package/src/commands/push.ts +127 -127
- package/src/commands/release.ts +32 -32
- package/src/commands/remove.ts +85 -85
- package/src/commands/set.ts +96 -96
- package/src/index.ts +19 -19
- package/src/localisation/en-GB.ts +289 -289
- package/src/models/AppError.d.ts +40 -40
- package/src/models/Cache.d.ts +25 -25
- package/src/models/JsModules.d.ts +1 -1
- package/src/providers/CredentialProvider.ts +121 -121
- package/src/providers/SessionCacheProvider.ts +101 -101
- package/src/providers/file-provider.ts +76 -76
- package/src/services/ContensisAuthService.ts +70 -70
- package/src/services/ContensisCliService.ts +1749 -1745
- package/src/shell.ts +270 -270
- package/src/util/console.printer.ts +371 -371
- package/src/util/csv.formatter.ts +21 -21
- package/src/util/index.ts +73 -73
- package/src/util/json.formatter.ts +1 -1
- package/src/util/logger.ts +234 -234
- package/src/util/xml.formatter.ts +20 -20
- package/src/version.ts +1 -1
- package/tsconfig.json +22 -22
|
@@ -1,127 +1,127 @@
|
|
|
1
|
-
import { Command, Option } from 'commander';
|
|
2
|
-
import { url } from '~/util';
|
|
3
|
-
|
|
4
|
-
export const mapContensisOpts = (opts: any = {}) => ({
|
|
5
|
-
source:
|
|
6
|
-
opts.sourceAlias || opts.sourceProjectId
|
|
7
|
-
? {
|
|
8
|
-
url: opts.sourceAlias
|
|
9
|
-
? url(opts.sourceAlias, 'website').cms
|
|
10
|
-
: (undefined as any),
|
|
11
|
-
project: opts.sourceProjectId || (undefined as any),
|
|
12
|
-
}
|
|
13
|
-
: undefined,
|
|
14
|
-
models: opts.modelIds,
|
|
15
|
-
query:
|
|
16
|
-
opts.id || opts.entryIds || opts.phrase || opts.fields
|
|
17
|
-
? {
|
|
18
|
-
fields: opts.fields,
|
|
19
|
-
includeIds: opts.id || opts.entryIds,
|
|
20
|
-
searchTerm: opts.phrase,
|
|
21
|
-
}
|
|
22
|
-
: undefined,
|
|
23
|
-
zenQL: opts.zenql,
|
|
24
|
-
transformGuids: !opts.preserveGuids,
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
/* Output options */
|
|
28
|
-
const output = new Option(
|
|
29
|
-
'-o, --output <output>',
|
|
30
|
-
'save output to a file e.g. --output ./output.txt'
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
const format = new Option(
|
|
34
|
-
'-f, --format <format>',
|
|
35
|
-
'format output as csv, json, xml or table (default)'
|
|
36
|
-
).choices(['csv', 'json', 'xml', 'table']);
|
|
37
|
-
|
|
38
|
-
/* Connect options */
|
|
39
|
-
const alias = new Option(
|
|
40
|
-
'-a, --alias <alias>',
|
|
41
|
-
'the cloud CMS alias to connect your request with'
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
export const project = new Option(
|
|
45
|
-
'-p, --project-id <projectId>',
|
|
46
|
-
'the projectId to make your request with'
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
/* Authentication options */
|
|
50
|
-
const user = new Option(
|
|
51
|
-
'-u, --user <user>',
|
|
52
|
-
'the username to authenticate your request with'
|
|
53
|
-
);
|
|
54
|
-
const password = new Option(
|
|
55
|
-
'-pw, --password <password>',
|
|
56
|
-
'the password to use to login with (optional/insecure)'
|
|
57
|
-
);
|
|
58
|
-
const clientId = new Option(
|
|
59
|
-
'-id, --client-id <clientId>',
|
|
60
|
-
'the clientId to authenticate your request with'
|
|
61
|
-
);
|
|
62
|
-
const sharedSecret = new Option(
|
|
63
|
-
'-s, --shared-secret <sharedSecret>',
|
|
64
|
-
'the shared secret to use when logging in with a client id'
|
|
65
|
-
);
|
|
66
|
-
|
|
67
|
-
/* Entry get options */
|
|
68
|
-
export const zenql = new Option(
|
|
69
|
-
'-q, --zenql <zenql>',
|
|
70
|
-
'get entries with a supplied ZenQL statement'
|
|
71
|
-
);
|
|
72
|
-
|
|
73
|
-
export const entryId = new Option('-i --id <id...>', 'the entry id(s) to get');
|
|
74
|
-
|
|
75
|
-
/* Import options */
|
|
76
|
-
export const fromFile = new Option(
|
|
77
|
-
'-file, --from-file <fromFile>',
|
|
78
|
-
'file path to import asset(s) from'
|
|
79
|
-
);
|
|
80
|
-
|
|
81
|
-
export const fromCms = new Option(
|
|
82
|
-
'-source, --source-alias <fromCms>',
|
|
83
|
-
'the cloud CMS alias to import asset(s) from'
|
|
84
|
-
);
|
|
85
|
-
export const fromProject = new Option(
|
|
86
|
-
'-sp, --source-project-id <fromProject>',
|
|
87
|
-
'the id of the Contensis project to import asset(s) from (Default: [last connected project])'
|
|
88
|
-
);
|
|
89
|
-
|
|
90
|
-
export const commit = new Option(
|
|
91
|
-
'--commit',
|
|
92
|
-
'add this flag only after you have run a preview of the import and agree with the analysis'
|
|
93
|
-
).default(false);
|
|
94
|
-
|
|
95
|
-
export const addConnectOptions = (program: Command) =>
|
|
96
|
-
program.addOption(alias.hideHelp()).addOption(project.hideHelp());
|
|
97
|
-
|
|
98
|
-
export const addAuthenticationOptions = (program: Command) =>
|
|
99
|
-
program
|
|
100
|
-
.addOption(user.hideHelp())
|
|
101
|
-
.addOption(password.hideHelp())
|
|
102
|
-
.addOption(clientId.hideHelp())
|
|
103
|
-
.addOption(sharedSecret.hideHelp());
|
|
104
|
-
|
|
105
|
-
const addOutputAndFormatOptions = (program: Command) =>
|
|
106
|
-
program.addOption(output).addOption(format);
|
|
107
|
-
|
|
108
|
-
export const addImportOptions = (program: Command) => {
|
|
109
|
-
for (const command of program.commands) {
|
|
110
|
-
command.addOption(fromFile).addOption(fromCms).addOption(fromProject);
|
|
111
|
-
}
|
|
112
|
-
return program;
|
|
113
|
-
};
|
|
114
|
-
export const addGetEntryOptions = (program: Command) => {
|
|
115
|
-
for (const command of program.commands) {
|
|
116
|
-
command.addOption(entryId).addOption(zenql);
|
|
117
|
-
}
|
|
118
|
-
return program;
|
|
119
|
-
};
|
|
120
|
-
export const addGlobalOptions = (program: Command) => {
|
|
121
|
-
for (const command of program.commands) {
|
|
122
|
-
addOutputAndFormatOptions(command);
|
|
123
|
-
addConnectOptions(command);
|
|
124
|
-
addAuthenticationOptions(command);
|
|
125
|
-
}
|
|
126
|
-
return program;
|
|
127
|
-
};
|
|
1
|
+
import { Command, Option } from 'commander';
|
|
2
|
+
import { url } from '~/util';
|
|
3
|
+
|
|
4
|
+
export const mapContensisOpts = (opts: any = {}) => ({
|
|
5
|
+
source:
|
|
6
|
+
opts.sourceAlias || opts.sourceProjectId
|
|
7
|
+
? {
|
|
8
|
+
url: opts.sourceAlias
|
|
9
|
+
? url(opts.sourceAlias, 'website').cms
|
|
10
|
+
: (undefined as any),
|
|
11
|
+
project: opts.sourceProjectId || (undefined as any),
|
|
12
|
+
}
|
|
13
|
+
: undefined,
|
|
14
|
+
models: opts.modelIds,
|
|
15
|
+
query:
|
|
16
|
+
opts.id || opts.entryIds || opts.phrase || opts.fields
|
|
17
|
+
? {
|
|
18
|
+
fields: opts.fields,
|
|
19
|
+
includeIds: opts.id || opts.entryIds,
|
|
20
|
+
searchTerm: opts.phrase,
|
|
21
|
+
}
|
|
22
|
+
: undefined,
|
|
23
|
+
zenQL: opts.zenql,
|
|
24
|
+
transformGuids: !opts.preserveGuids,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
/* Output options */
|
|
28
|
+
const output = new Option(
|
|
29
|
+
'-o, --output <output>',
|
|
30
|
+
'save output to a file e.g. --output ./output.txt'
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
const format = new Option(
|
|
34
|
+
'-f, --format <format>',
|
|
35
|
+
'format output as csv, json, xml or table (default)'
|
|
36
|
+
).choices(['csv', 'json', 'xml', 'table']);
|
|
37
|
+
|
|
38
|
+
/* Connect options */
|
|
39
|
+
const alias = new Option(
|
|
40
|
+
'-a, --alias <alias>',
|
|
41
|
+
'the cloud CMS alias to connect your request with'
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
export const project = new Option(
|
|
45
|
+
'-p, --project-id <projectId>',
|
|
46
|
+
'the projectId to make your request with'
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
/* Authentication options */
|
|
50
|
+
const user = new Option(
|
|
51
|
+
'-u, --user <user>',
|
|
52
|
+
'the username to authenticate your request with'
|
|
53
|
+
);
|
|
54
|
+
const password = new Option(
|
|
55
|
+
'-pw, --password <password>',
|
|
56
|
+
'the password to use to login with (optional/insecure)'
|
|
57
|
+
);
|
|
58
|
+
const clientId = new Option(
|
|
59
|
+
'-id, --client-id <clientId>',
|
|
60
|
+
'the clientId to authenticate your request with'
|
|
61
|
+
);
|
|
62
|
+
const sharedSecret = new Option(
|
|
63
|
+
'-s, --shared-secret <sharedSecret>',
|
|
64
|
+
'the shared secret to use when logging in with a client id'
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
/* Entry get options */
|
|
68
|
+
export const zenql = new Option(
|
|
69
|
+
'-q, --zenql <zenql>',
|
|
70
|
+
'get entries with a supplied ZenQL statement'
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
export const entryId = new Option('-i --id <id...>', 'the entry id(s) to get');
|
|
74
|
+
|
|
75
|
+
/* Import options */
|
|
76
|
+
export const fromFile = new Option(
|
|
77
|
+
'-file, --from-file <fromFile>',
|
|
78
|
+
'file path to import asset(s) from'
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
export const fromCms = new Option(
|
|
82
|
+
'-source, --source-alias <fromCms>',
|
|
83
|
+
'the cloud CMS alias to import asset(s) from'
|
|
84
|
+
);
|
|
85
|
+
export const fromProject = new Option(
|
|
86
|
+
'-sp, --source-project-id <fromProject>',
|
|
87
|
+
'the id of the Contensis project to import asset(s) from (Default: [last connected project])'
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
export const commit = new Option(
|
|
91
|
+
'--commit',
|
|
92
|
+
'add this flag only after you have run a preview of the import and agree with the analysis'
|
|
93
|
+
).default(false);
|
|
94
|
+
|
|
95
|
+
export const addConnectOptions = (program: Command) =>
|
|
96
|
+
program.addOption(alias.hideHelp()).addOption(project.hideHelp());
|
|
97
|
+
|
|
98
|
+
export const addAuthenticationOptions = (program: Command) =>
|
|
99
|
+
program
|
|
100
|
+
.addOption(user.hideHelp())
|
|
101
|
+
.addOption(password.hideHelp())
|
|
102
|
+
.addOption(clientId.hideHelp())
|
|
103
|
+
.addOption(sharedSecret.hideHelp());
|
|
104
|
+
|
|
105
|
+
const addOutputAndFormatOptions = (program: Command) =>
|
|
106
|
+
program.addOption(output).addOption(format);
|
|
107
|
+
|
|
108
|
+
export const addImportOptions = (program: Command) => {
|
|
109
|
+
for (const command of program.commands) {
|
|
110
|
+
command.addOption(fromFile).addOption(fromCms).addOption(fromProject);
|
|
111
|
+
}
|
|
112
|
+
return program;
|
|
113
|
+
};
|
|
114
|
+
export const addGetEntryOptions = (program: Command) => {
|
|
115
|
+
for (const command of program.commands) {
|
|
116
|
+
command.addOption(entryId).addOption(zenql);
|
|
117
|
+
}
|
|
118
|
+
return program;
|
|
119
|
+
};
|
|
120
|
+
export const addGlobalOptions = (program: Command) => {
|
|
121
|
+
for (const command of program.commands) {
|
|
122
|
+
addOutputAndFormatOptions(command);
|
|
123
|
+
addConnectOptions(command);
|
|
124
|
+
addAuthenticationOptions(command);
|
|
125
|
+
}
|
|
126
|
+
return program;
|
|
127
|
+
};
|
package/src/commands/import.ts
CHANGED
|
@@ -1,128 +1,128 @@
|
|
|
1
|
-
import { Argument, Command } from 'commander';
|
|
2
|
-
import { cliCommand } from '~/services/ContensisCliService';
|
|
3
|
-
import { url } from '~/util';
|
|
4
|
-
import { commit, mapContensisOpts } from './globalOptions';
|
|
5
|
-
|
|
6
|
-
export const makeImportCommand = () => {
|
|
7
|
-
const program = new Command()
|
|
8
|
-
.command('import')
|
|
9
|
-
.description('import command')
|
|
10
|
-
.addHelpText('after', `\n`)
|
|
11
|
-
.showHelpAfterError(true)
|
|
12
|
-
.exitOverride();
|
|
13
|
-
|
|
14
|
-
program
|
|
15
|
-
.command('models')
|
|
16
|
-
.description('import complete content models')
|
|
17
|
-
.argument('[modelIds...]', 'ids of the content models to import (optional)')
|
|
18
|
-
.addOption(commit)
|
|
19
|
-
.addHelpText(
|
|
20
|
-
'after',
|
|
21
|
-
`
|
|
22
|
-
Example call:
|
|
23
|
-
> import models blogPost --from-file contentmodels-backup.json
|
|
24
|
-
> import models --source-alias example-dev
|
|
25
|
-
`
|
|
26
|
-
)
|
|
27
|
-
.action(async (modelIds: string[], opts) => {
|
|
28
|
-
await cliCommand(
|
|
29
|
-
['import', 'models', modelIds.join(' ')],
|
|
30
|
-
opts,
|
|
31
|
-
mapContensisOpts({ modelIds, ...opts })
|
|
32
|
-
).ImportContentModels({
|
|
33
|
-
fromFile: opts.fromFile,
|
|
34
|
-
commit: opts.commit,
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
program
|
|
39
|
-
.command('contenttypes')
|
|
40
|
-
.description('import content types')
|
|
41
|
-
.argument(
|
|
42
|
-
'[contentTypeIds...]',
|
|
43
|
-
'Optional list of API id(s) of the content type(s) to import'
|
|
44
|
-
)
|
|
45
|
-
.addOption(commit)
|
|
46
|
-
.addHelpText(
|
|
47
|
-
'after',
|
|
48
|
-
`
|
|
49
|
-
Example call:
|
|
50
|
-
> import contenttypes {contentTypeIds} --from-file contenttypes-backup.json
|
|
51
|
-
> import contenttypes {contentTypeIds} --source-alias example-dev
|
|
52
|
-
`
|
|
53
|
-
)
|
|
54
|
-
.action(async (contentTypeIds: string[], opts) => {
|
|
55
|
-
await cliCommand(
|
|
56
|
-
['import', 'contenttypes'],
|
|
57
|
-
opts,
|
|
58
|
-
mapContensisOpts({ contentTypeIds, ...opts })
|
|
59
|
-
).ImportContentTypes(
|
|
60
|
-
{
|
|
61
|
-
fromFile: opts.fromFile,
|
|
62
|
-
commit: opts.commit,
|
|
63
|
-
},
|
|
64
|
-
contentTypeIds
|
|
65
|
-
);
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
program
|
|
69
|
-
.command('components')
|
|
70
|
-
.description('import components')
|
|
71
|
-
.argument(
|
|
72
|
-
'[componentIds...]',
|
|
73
|
-
'Optional list of API id(s) of the component(s) to import'
|
|
74
|
-
)
|
|
75
|
-
.addOption(commit)
|
|
76
|
-
.addHelpText(
|
|
77
|
-
'after',
|
|
78
|
-
`
|
|
79
|
-
Example call:
|
|
80
|
-
> import components {componentIds} --from-file component-backup.json
|
|
81
|
-
> import components {componentIds} --source-alias example-dev
|
|
82
|
-
`
|
|
83
|
-
)
|
|
84
|
-
.action(async (componentIds: string[], opts) => {
|
|
85
|
-
await cliCommand(
|
|
86
|
-
['import', 'component'],
|
|
87
|
-
opts,
|
|
88
|
-
mapContensisOpts({ componentIds, ...opts })
|
|
89
|
-
).ImportComponents(
|
|
90
|
-
{
|
|
91
|
-
fromFile: opts.fromFile,
|
|
92
|
-
commit: opts.commit,
|
|
93
|
-
},
|
|
94
|
-
componentIds
|
|
95
|
-
);
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
program
|
|
99
|
-
.command('entries')
|
|
100
|
-
.description('import entries')
|
|
101
|
-
.argument(
|
|
102
|
-
'[search phrase]',
|
|
103
|
-
'get entries with the search phrase, use quotes for multiple words'
|
|
104
|
-
)
|
|
105
|
-
.addOption(commit)
|
|
106
|
-
.option(
|
|
107
|
-
'-preserve, --preserve-guids',
|
|
108
|
-
'include this flag when you are importing entries that you have previously exported and wish to update'
|
|
109
|
-
)
|
|
110
|
-
.addHelpText(
|
|
111
|
-
'after',
|
|
112
|
-
`
|
|
113
|
-
Example call:
|
|
114
|
-
> import entries --source-cms example-dev --source-project-id microsite --zenql "sys.contentTypeId = blog"
|
|
115
|
-
`
|
|
116
|
-
)
|
|
117
|
-
.action(async (phrase: string, opts, cmd) => {
|
|
118
|
-
await cliCommand(
|
|
119
|
-
['import', 'entries'],
|
|
120
|
-
opts,
|
|
121
|
-
mapContensisOpts({ phrase, ...opts })
|
|
122
|
-
).ImportEntries({ commit: opts.commit, fromFile: opts.fromFile });
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
return program;
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
export const get = makeImportCommand();
|
|
1
|
+
import { Argument, Command } from 'commander';
|
|
2
|
+
import { cliCommand } from '~/services/ContensisCliService';
|
|
3
|
+
import { url } from '~/util';
|
|
4
|
+
import { commit, mapContensisOpts } from './globalOptions';
|
|
5
|
+
|
|
6
|
+
export const makeImportCommand = () => {
|
|
7
|
+
const program = new Command()
|
|
8
|
+
.command('import')
|
|
9
|
+
.description('import command')
|
|
10
|
+
.addHelpText('after', `\n`)
|
|
11
|
+
.showHelpAfterError(true)
|
|
12
|
+
.exitOverride();
|
|
13
|
+
|
|
14
|
+
program
|
|
15
|
+
.command('models')
|
|
16
|
+
.description('import complete content models')
|
|
17
|
+
.argument('[modelIds...]', 'ids of the content models to import (optional)')
|
|
18
|
+
.addOption(commit)
|
|
19
|
+
.addHelpText(
|
|
20
|
+
'after',
|
|
21
|
+
`
|
|
22
|
+
Example call:
|
|
23
|
+
> import models blogPost --from-file contentmodels-backup.json
|
|
24
|
+
> import models --source-alias example-dev
|
|
25
|
+
`
|
|
26
|
+
)
|
|
27
|
+
.action(async (modelIds: string[], opts) => {
|
|
28
|
+
await cliCommand(
|
|
29
|
+
['import', 'models', modelIds.join(' ')],
|
|
30
|
+
opts,
|
|
31
|
+
mapContensisOpts({ modelIds, ...opts })
|
|
32
|
+
).ImportContentModels({
|
|
33
|
+
fromFile: opts.fromFile,
|
|
34
|
+
commit: opts.commit,
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
program
|
|
39
|
+
.command('contenttypes')
|
|
40
|
+
.description('import content types')
|
|
41
|
+
.argument(
|
|
42
|
+
'[contentTypeIds...]',
|
|
43
|
+
'Optional list of API id(s) of the content type(s) to import'
|
|
44
|
+
)
|
|
45
|
+
.addOption(commit)
|
|
46
|
+
.addHelpText(
|
|
47
|
+
'after',
|
|
48
|
+
`
|
|
49
|
+
Example call:
|
|
50
|
+
> import contenttypes {contentTypeIds} --from-file contenttypes-backup.json
|
|
51
|
+
> import contenttypes {contentTypeIds} --source-alias example-dev
|
|
52
|
+
`
|
|
53
|
+
)
|
|
54
|
+
.action(async (contentTypeIds: string[], opts) => {
|
|
55
|
+
await cliCommand(
|
|
56
|
+
['import', 'contenttypes'],
|
|
57
|
+
opts,
|
|
58
|
+
mapContensisOpts({ contentTypeIds, ...opts })
|
|
59
|
+
).ImportContentTypes(
|
|
60
|
+
{
|
|
61
|
+
fromFile: opts.fromFile,
|
|
62
|
+
commit: opts.commit,
|
|
63
|
+
},
|
|
64
|
+
contentTypeIds
|
|
65
|
+
);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
program
|
|
69
|
+
.command('components')
|
|
70
|
+
.description('import components')
|
|
71
|
+
.argument(
|
|
72
|
+
'[componentIds...]',
|
|
73
|
+
'Optional list of API id(s) of the component(s) to import'
|
|
74
|
+
)
|
|
75
|
+
.addOption(commit)
|
|
76
|
+
.addHelpText(
|
|
77
|
+
'after',
|
|
78
|
+
`
|
|
79
|
+
Example call:
|
|
80
|
+
> import components {componentIds} --from-file component-backup.json
|
|
81
|
+
> import components {componentIds} --source-alias example-dev
|
|
82
|
+
`
|
|
83
|
+
)
|
|
84
|
+
.action(async (componentIds: string[], opts) => {
|
|
85
|
+
await cliCommand(
|
|
86
|
+
['import', 'component'],
|
|
87
|
+
opts,
|
|
88
|
+
mapContensisOpts({ componentIds, ...opts })
|
|
89
|
+
).ImportComponents(
|
|
90
|
+
{
|
|
91
|
+
fromFile: opts.fromFile,
|
|
92
|
+
commit: opts.commit,
|
|
93
|
+
},
|
|
94
|
+
componentIds
|
|
95
|
+
);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
program
|
|
99
|
+
.command('entries')
|
|
100
|
+
.description('import entries')
|
|
101
|
+
.argument(
|
|
102
|
+
'[search phrase]',
|
|
103
|
+
'get entries with the search phrase, use quotes for multiple words'
|
|
104
|
+
)
|
|
105
|
+
.addOption(commit)
|
|
106
|
+
.option(
|
|
107
|
+
'-preserve, --preserve-guids',
|
|
108
|
+
'include this flag when you are importing entries that you have previously exported and wish to update'
|
|
109
|
+
)
|
|
110
|
+
.addHelpText(
|
|
111
|
+
'after',
|
|
112
|
+
`
|
|
113
|
+
Example call:
|
|
114
|
+
> import entries --source-cms example-dev --source-project-id microsite --zenql "sys.contentTypeId = blog"
|
|
115
|
+
`
|
|
116
|
+
)
|
|
117
|
+
.action(async (phrase: string, opts, cmd) => {
|
|
118
|
+
await cliCommand(
|
|
119
|
+
['import', 'entries'],
|
|
120
|
+
opts,
|
|
121
|
+
mapContensisOpts({ phrase, ...opts })
|
|
122
|
+
).ImportEntries({ commit: opts.commit, fromFile: opts.fromFile });
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
return program;
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
export const get = makeImportCommand();
|
package/src/commands/index.ts
CHANGED
|
@@ -1,80 +1,80 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import { Logger } from '~/util/logger';
|
|
3
|
-
import { LIB_VERSION } from '~/version';
|
|
4
|
-
import { makeConnectCommand } from './connect';
|
|
5
|
-
import { makeCreateCommand } from './create';
|
|
6
|
-
import { makeDiffCommand } from './diff';
|
|
7
|
-
import { makeGetCommand } from './get';
|
|
8
|
-
import {
|
|
9
|
-
addAuthenticationOptions,
|
|
10
|
-
addConnectOptions,
|
|
11
|
-
addGetEntryOptions,
|
|
12
|
-
addGlobalOptions,
|
|
13
|
-
addImportOptions,
|
|
14
|
-
} from './globalOptions';
|
|
15
|
-
import { makeImportCommand } from './import';
|
|
16
|
-
import { makeListCommand } from './list';
|
|
17
|
-
import { makeLoginCommand } from './login';
|
|
18
|
-
import { makePushCommand } from './push';
|
|
19
|
-
import { makeReleaseCommand } from './release';
|
|
20
|
-
import { makeRemoveCommand } from './remove';
|
|
21
|
-
import { makeSetCommand } from './set';
|
|
22
|
-
|
|
23
|
-
const commands = () => {
|
|
24
|
-
const program = new Command()
|
|
25
|
-
.name('contensis')
|
|
26
|
-
.version(LIB_VERSION)
|
|
27
|
-
.configureOutput({
|
|
28
|
-
writeErr: str => {
|
|
29
|
-
return str.toLowerCase().includes('error')
|
|
30
|
-
? Logger.error(`Command ${str}`)
|
|
31
|
-
: str.trim() && Logger.help(str);
|
|
32
|
-
},
|
|
33
|
-
})
|
|
34
|
-
.exitOverride()
|
|
35
|
-
.showHelpAfterError(true);
|
|
36
|
-
|
|
37
|
-
program.addCommand(
|
|
38
|
-
addAuthenticationOptions(makeConnectCommand()).copyInheritedSettings(
|
|
39
|
-
program
|
|
40
|
-
)
|
|
41
|
-
);
|
|
42
|
-
program.addCommand(
|
|
43
|
-
addGlobalOptions(makeCreateCommand()).copyInheritedSettings(program)
|
|
44
|
-
);
|
|
45
|
-
program.addCommand(
|
|
46
|
-
addGlobalOptions(
|
|
47
|
-
addGetEntryOptions(addImportOptions(makeDiffCommand()))
|
|
48
|
-
).copyInheritedSettings(program)
|
|
49
|
-
);
|
|
50
|
-
program.addCommand(
|
|
51
|
-
addGlobalOptions(makeGetCommand()).copyInheritedSettings(program)
|
|
52
|
-
);
|
|
53
|
-
program.addCommand(
|
|
54
|
-
addGlobalOptions(
|
|
55
|
-
addGetEntryOptions(addImportOptions(makeImportCommand()))
|
|
56
|
-
).copyInheritedSettings(program)
|
|
57
|
-
);
|
|
58
|
-
program.addCommand(
|
|
59
|
-
addGlobalOptions(makeListCommand()).copyInheritedSettings(program)
|
|
60
|
-
);
|
|
61
|
-
program.addCommand(
|
|
62
|
-
addConnectOptions(makeLoginCommand()).copyInheritedSettings(program)
|
|
63
|
-
);
|
|
64
|
-
program.addCommand(
|
|
65
|
-
addGlobalOptions(makePushCommand()).copyInheritedSettings(program)
|
|
66
|
-
);
|
|
67
|
-
program.addCommand(
|
|
68
|
-
addGlobalOptions(makeReleaseCommand()).copyInheritedSettings(program)
|
|
69
|
-
);
|
|
70
|
-
program.addCommand(
|
|
71
|
-
addGlobalOptions(makeRemoveCommand()).copyInheritedSettings(program)
|
|
72
|
-
);
|
|
73
|
-
program.addCommand(
|
|
74
|
-
addConnectOptions(makeSetCommand()).copyInheritedSettings(program)
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
return program;
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
export default commands;
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { Logger } from '~/util/logger';
|
|
3
|
+
import { LIB_VERSION } from '~/version';
|
|
4
|
+
import { makeConnectCommand } from './connect';
|
|
5
|
+
import { makeCreateCommand } from './create';
|
|
6
|
+
import { makeDiffCommand } from './diff';
|
|
7
|
+
import { makeGetCommand } from './get';
|
|
8
|
+
import {
|
|
9
|
+
addAuthenticationOptions,
|
|
10
|
+
addConnectOptions,
|
|
11
|
+
addGetEntryOptions,
|
|
12
|
+
addGlobalOptions,
|
|
13
|
+
addImportOptions,
|
|
14
|
+
} from './globalOptions';
|
|
15
|
+
import { makeImportCommand } from './import';
|
|
16
|
+
import { makeListCommand } from './list';
|
|
17
|
+
import { makeLoginCommand } from './login';
|
|
18
|
+
import { makePushCommand } from './push';
|
|
19
|
+
import { makeReleaseCommand } from './release';
|
|
20
|
+
import { makeRemoveCommand } from './remove';
|
|
21
|
+
import { makeSetCommand } from './set';
|
|
22
|
+
|
|
23
|
+
const commands = () => {
|
|
24
|
+
const program = new Command()
|
|
25
|
+
.name('contensis')
|
|
26
|
+
.version(LIB_VERSION)
|
|
27
|
+
.configureOutput({
|
|
28
|
+
writeErr: str => {
|
|
29
|
+
return str.toLowerCase().includes('error')
|
|
30
|
+
? Logger.error(`Command ${str}`)
|
|
31
|
+
: str.trim() && Logger.help(str);
|
|
32
|
+
},
|
|
33
|
+
})
|
|
34
|
+
.exitOverride()
|
|
35
|
+
.showHelpAfterError(true);
|
|
36
|
+
|
|
37
|
+
program.addCommand(
|
|
38
|
+
addAuthenticationOptions(makeConnectCommand()).copyInheritedSettings(
|
|
39
|
+
program
|
|
40
|
+
)
|
|
41
|
+
);
|
|
42
|
+
program.addCommand(
|
|
43
|
+
addGlobalOptions(makeCreateCommand()).copyInheritedSettings(program)
|
|
44
|
+
);
|
|
45
|
+
program.addCommand(
|
|
46
|
+
addGlobalOptions(
|
|
47
|
+
addGetEntryOptions(addImportOptions(makeDiffCommand()))
|
|
48
|
+
).copyInheritedSettings(program)
|
|
49
|
+
);
|
|
50
|
+
program.addCommand(
|
|
51
|
+
addGlobalOptions(makeGetCommand()).copyInheritedSettings(program)
|
|
52
|
+
);
|
|
53
|
+
program.addCommand(
|
|
54
|
+
addGlobalOptions(
|
|
55
|
+
addGetEntryOptions(addImportOptions(makeImportCommand()))
|
|
56
|
+
).copyInheritedSettings(program)
|
|
57
|
+
);
|
|
58
|
+
program.addCommand(
|
|
59
|
+
addGlobalOptions(makeListCommand()).copyInheritedSettings(program)
|
|
60
|
+
);
|
|
61
|
+
program.addCommand(
|
|
62
|
+
addConnectOptions(makeLoginCommand()).copyInheritedSettings(program)
|
|
63
|
+
);
|
|
64
|
+
program.addCommand(
|
|
65
|
+
addGlobalOptions(makePushCommand()).copyInheritedSettings(program)
|
|
66
|
+
);
|
|
67
|
+
program.addCommand(
|
|
68
|
+
addGlobalOptions(makeReleaseCommand()).copyInheritedSettings(program)
|
|
69
|
+
);
|
|
70
|
+
program.addCommand(
|
|
71
|
+
addGlobalOptions(makeRemoveCommand()).copyInheritedSettings(program)
|
|
72
|
+
);
|
|
73
|
+
program.addCommand(
|
|
74
|
+
addConnectOptions(makeSetCommand()).copyInheritedSettings(program)
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
return program;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export default commands;
|