@contentstack/cli-cm-bulk-publish 0.1.1-beta.5 → 1.0.1
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/LICENSE +21 -0
- package/README.md +522 -318
- package/oclif.manifest.json +1 -1
- package/package.json +26 -11
- package/src/commands/cm/assets/publish.js +243 -0
- package/src/commands/cm/assets/unpublish.js +179 -0
- package/src/commands/cm/bulk-publish/cross-publish.js +181 -67
- package/src/commands/cm/bulk-publish/index.js +5 -6
- package/src/commands/cm/entries/publish-modified.js +197 -0
- package/src/commands/cm/entries/publish-non-localized-fields.js +208 -0
- package/src/commands/cm/entries/publish-only-unpublished.js +109 -0
- package/src/commands/cm/entries/publish.js +254 -0
- package/src/commands/cm/entries/unpublish.js +184 -0
- package/src/commands/cm/entries/update-and-publish.js +191 -0
- package/src/commands/cm/stacks/publish-clear-logs.js +82 -0
- package/src/commands/cm/stacks/publish-configure.js +46 -0
- package/src/commands/cm/stacks/publish-revert.js +102 -0
- package/src/commands/cm/stacks/publish.js +110 -0
- package/src/commands/cm/stacks/unpublish.js +282 -0
- package/src/config/index.js +18 -57
- package/src/consumer/publish.js +589 -362
- package/src/producer/add-fields.js +204 -179
- package/src/producer/cross-publish.js +177 -99
- package/src/producer/nonlocalized-field-changes.js +225 -194
- package/src/producer/publish-assets.js +97 -83
- package/src/producer/publish-edits.js +113 -88
- package/src/producer/publish-entries.js +121 -90
- package/src/producer/publish-unpublished-env.js +114 -90
- package/src/producer/revert.js +261 -230
- package/src/producer/unpublish.js +154 -97
- package/src/services/publish-only-unpublished.js +130 -0
- package/src/util/client.js +14 -15
- package/src/util/command-helper.js +25 -0
- package/src/util/fs.js +10 -11
- package/src/util/index.js +38 -36
- package/src/util/logger.js +21 -25
- package/src/util/queue.js +13 -13
- package/src/util/retryfailed.js +8 -4
- package/src/util/store.js +43 -47
- package/src/commands/cm/bulk-publish/add-fields.js +0 -122
- package/src/commands/cm/bulk-publish/assets.js +0 -122
- package/src/commands/cm/bulk-publish/clear.js +0 -65
- package/src/commands/cm/bulk-publish/configure.js +0 -44
- package/src/commands/cm/bulk-publish/entries.js +0 -131
- package/src/commands/cm/bulk-publish/entry-edits.js +0 -129
- package/src/commands/cm/bulk-publish/nonlocalized-field-changes.js +0 -121
- package/src/commands/cm/bulk-publish/revert.js +0 -81
- package/src/commands/cm/bulk-publish/unpublish.js +0 -169
- package/src/commands/cm/bulk-publish/unpublished-entries.js +0 -127
- package/src/util/request.js +0 -59
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
const fs = require('fs')
|
|
2
|
-
const {cli} = require('cli-ux')
|
|
3
|
-
const {Command, flags} = require('@oclif/command')
|
|
4
|
-
const {getLogsDirPath} = require('../../../util/logger.js')
|
|
5
|
-
|
|
6
|
-
class ClearCommand extends Command {
|
|
7
|
-
async run() {
|
|
8
|
-
const clearFlags = this.parse(ClearCommand).flags
|
|
9
|
-
let dirPath = getLogsDirPath()
|
|
10
|
-
if (clearFlags.list) {
|
|
11
|
-
this.listFiles(dirPath)
|
|
12
|
-
} else if (clearFlags.yes) {
|
|
13
|
-
this.rmDir(dirPath, false)
|
|
14
|
-
} else {
|
|
15
|
-
const confirmation = await cli.prompt('Proceed to delete all log files (y/n)?')
|
|
16
|
-
if (confirmation) {
|
|
17
|
-
this.rmDir(dirPath, false)
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
rmDir(dirPath, removeSelf) {
|
|
23
|
-
if (fs.existsSync(dirPath)) {
|
|
24
|
-
if (removeSelf === undefined) {
|
|
25
|
-
removeSelf = true;
|
|
26
|
-
}
|
|
27
|
-
try { var files = fs.readdirSync(dirPath); }
|
|
28
|
-
catch(e) { return; }
|
|
29
|
-
if (files.length > 0)
|
|
30
|
-
for (var i = 0; i < files.length; i++) {
|
|
31
|
-
var filePath = dirPath + '/' + files[i];
|
|
32
|
-
if (fs.statSync(filePath).isFile())
|
|
33
|
-
fs.unlinkSync(filePath);
|
|
34
|
-
else
|
|
35
|
-
rmDir(filePath);
|
|
36
|
-
}
|
|
37
|
-
if (removeSelf) {
|
|
38
|
-
fs.rmdirSync(dirPath);
|
|
39
|
-
}
|
|
40
|
-
this.log('Log files have been cleared')
|
|
41
|
-
} else {
|
|
42
|
-
this.error(`The log directory doesn't exist.`)
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
listFiles(dirPath) {
|
|
47
|
-
if (fs.existsSync(dirPath)) {
|
|
48
|
-
fs.readdir(dirPath, (err, files) => {
|
|
49
|
-
this.log(files.length)
|
|
50
|
-
})
|
|
51
|
-
} else {
|
|
52
|
-
this.error(`The log directory doesn't exist.`)
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
ClearCommand.description = `Clear the log folder
|
|
58
|
-
`
|
|
59
|
-
|
|
60
|
-
ClearCommand.flags = {
|
|
61
|
-
list: flags.boolean({char: 'l', description: 'List number of log files'}),
|
|
62
|
-
yes: flags.boolean({char: 'y', description: 'Delete all files without asking for confirmation'})
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
module.exports = ClearCommand
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
const {Command, flags} = require('@oclif/command')
|
|
2
|
-
const {cli} = require('cli-ux')
|
|
3
|
-
const fs = require('fs')
|
|
4
|
-
const path = require('path')
|
|
5
|
-
let config = require('../../../config/index.js')
|
|
6
|
-
|
|
7
|
-
class ConfigureCommand extends Command {
|
|
8
|
-
|
|
9
|
-
async run() {
|
|
10
|
-
const configureFlags = this.parse(ConfigureCommand).flags
|
|
11
|
-
|
|
12
|
-
if (!configureFlags.alias) {
|
|
13
|
-
configureFlags.alias = await cli.prompt('Please enter the management token alias to be used')
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
await this.config.runHook('validateManagementTokenAlias', {alias: configureFlags.alias})
|
|
17
|
-
this.setConfig(configureFlags)
|
|
18
|
-
this.log('The configuration has been saved successfully.')
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
setConfig({apikey, alias}) {
|
|
22
|
-
if (alias)
|
|
23
|
-
config.alias = alias
|
|
24
|
-
fs.writeFileSync(path.join(process.cwd(), 'config.js'), `module.exports = ${JSON.stringify(config, null, 2)}`)
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
ConfigureCommand.description = `Generate configuration template
|
|
29
|
-
The configure command is used for generating a configuration file for bulk-publish script.
|
|
30
|
-
|
|
31
|
-
Here is a detailed description for all the available flags
|
|
32
|
-
|
|
33
|
-
-----------------------------------------------------------------------------------------------------------
|
|
34
|
-
--alias or -a : Management token Alias for the stack in use.
|
|
35
|
-
|
|
36
|
-
EXAMPLE : cm:bulk-publish:configure --alias [MANAGEMENT TOKEN Alias]
|
|
37
|
-
EXAMPLE : cm:bulk-publish:configure -a [MANAGEMENT TOKEN Alias]
|
|
38
|
-
`
|
|
39
|
-
|
|
40
|
-
ConfigureCommand.flags = {
|
|
41
|
-
alias: flags.string({char: 'a', description: 'Management token alias for the stack'}),
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
module.exports = ConfigureCommand
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-console */
|
|
2
|
-
/* eslint-disable node/no-extraneous-require */
|
|
3
|
-
const {Command, flags} = require('@oclif/command')
|
|
4
|
-
const {start} = require('../../../producer/publish-entries')
|
|
5
|
-
const store = require('../../../util/store.js')
|
|
6
|
-
const {cli} = require('cli-ux')
|
|
7
|
-
const configKey = 'publish_entries'
|
|
8
|
-
const {prettyPrint, formatError} = require('../../../util')
|
|
9
|
-
const {getStack} = require('../../../util/client.js')
|
|
10
|
-
let config
|
|
11
|
-
|
|
12
|
-
class EntriesCommand extends Command {
|
|
13
|
-
async run() {
|
|
14
|
-
const entriesFlags = this.parse(EntriesCommand).flags
|
|
15
|
-
let updatedFlags
|
|
16
|
-
try {
|
|
17
|
-
updatedFlags = (entriesFlags.config) ? store.updateMissing(configKey, entriesFlags) : entriesFlags
|
|
18
|
-
} catch (error) {
|
|
19
|
-
this.error(error.message, {exit: 2})
|
|
20
|
-
}
|
|
21
|
-
if (this.validate(updatedFlags)) {
|
|
22
|
-
let stack
|
|
23
|
-
if (!updatedFlags.retryFailed) {
|
|
24
|
-
if (!updatedFlags.alias) {
|
|
25
|
-
updatedFlags.alias = await cli.prompt('Provide the alias of the management token to use')
|
|
26
|
-
}
|
|
27
|
-
updatedFlags.bulkPublish = updatedFlags.bulkPublish !== 'false'
|
|
28
|
-
await this.config.runHook('validateManagementTokenAlias', {alias: updatedFlags.alias})
|
|
29
|
-
config = {
|
|
30
|
-
alias: updatedFlags.alias,
|
|
31
|
-
host: this.config.userConfig.getRegion().cma,
|
|
32
|
-
branch: entriesFlags.branch,
|
|
33
|
-
}
|
|
34
|
-
stack = getStack(config)
|
|
35
|
-
}
|
|
36
|
-
if (await this.confirmFlags(updatedFlags)) {
|
|
37
|
-
try {
|
|
38
|
-
// eslint-disable-next-line no-negated-condition
|
|
39
|
-
if (!updatedFlags.retryFailed) {
|
|
40
|
-
await start(updatedFlags, stack, config)
|
|
41
|
-
} else {
|
|
42
|
-
await start(updatedFlags)
|
|
43
|
-
}
|
|
44
|
-
} catch (error) {
|
|
45
|
-
let message = formatError(error)
|
|
46
|
-
this.error(message, {exit: 2})
|
|
47
|
-
}
|
|
48
|
-
} else {
|
|
49
|
-
this.exit(0)
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
validate({contentTypes, locales, environments, retryFailed, publishAllContentTypes}) {
|
|
55
|
-
let missing = []
|
|
56
|
-
if (retryFailed) {
|
|
57
|
-
return true
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if (publishAllContentTypes && contentTypes && contentTypes.length > 0) {
|
|
61
|
-
this.error('Do not specify contentTypes when publishAllContentTypes flag is set. Please check --help for more details', {exit: 2})
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
if ((!contentTypes || contentTypes.length === 0) && !publishAllContentTypes) {
|
|
65
|
-
missing.push('Content Types')
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if (!locales || locales.length === 0) {
|
|
69
|
-
missing.push('Locales')
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
if (!environments || environments.length === 0) {
|
|
73
|
-
missing.push('Environments')
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if (missing.length > 0) {
|
|
77
|
-
this.error(`${missing.join(', ')} are required for processing this command. Please check --help for more details`, {exit: 2})
|
|
78
|
-
} else {
|
|
79
|
-
return true
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
async confirmFlags(data) {
|
|
84
|
-
prettyPrint(data)
|
|
85
|
-
if (data.yes) {
|
|
86
|
-
return true
|
|
87
|
-
}
|
|
88
|
-
const confirmation = await cli.confirm('Do you want to continue with this configuration ? [yes or no]')
|
|
89
|
-
return confirmation
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
EntriesCommand.description = `Publish entries from multiple content-types to multiple environments and locales
|
|
94
|
-
The entries command is used for publishing entries from the specified content types, to the
|
|
95
|
-
specified environments and locales
|
|
96
|
-
|
|
97
|
-
Content Types, Environments and Locales are required for executing the command successfully
|
|
98
|
-
But, if retryFailed flag is set, then only a logfile is required
|
|
99
|
-
`
|
|
100
|
-
|
|
101
|
-
EntriesCommand.flags = {
|
|
102
|
-
alias: flags.string({char: 'a', description: 'Alias for the management token to be used'}),
|
|
103
|
-
retryFailed: flags.string({char: 'r', description: 'Retry failed entries from the logfile (optional, overrides all other flags) This flag is used to retry publishing entries that failed to publish in a previous attempt. A log file for the previous session will be required for processing the failed entries'}),
|
|
104
|
-
bulkPublish: flags.string({char: 'b', description: 'This flag is set to true by default. It indicates that contentstack\'s bulkpublish API will be used for publishing the entries', default: 'true'}),
|
|
105
|
-
publishAllContentTypes: flags.boolean({char: 'o', description: 'Publish all content-types (optional, cannot be set when contentTypes flag is set)'}),
|
|
106
|
-
contentTypes: flags.string({char: 't', description: 'The Content-types from which entries need to be published', multiple: true}),
|
|
107
|
-
locales: flags.string({char: 'l', description: 'Locales to which entries need to be published', multiple: true}),
|
|
108
|
-
environments: flags.string({char: 'e', description: 'Environments to which entries need to be published', multiple: true}),
|
|
109
|
-
config: flags.string({char: 'c', description: 'Path for the external config file to be used (A new config file can be generated at the current working directory using `csdx cm:bulk-publish:configure -a [ALIAS]`)'}),
|
|
110
|
-
yes: flags.boolean({char: 'y', description: 'Agree to process the command with the current configuration'}),
|
|
111
|
-
branch: flags.string({char: 'B', default: 'main', description: 'Specify the branch to fetch the content from (default is main branch)'}),
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
EntriesCommand.examples = [
|
|
115
|
-
'General Usage',
|
|
116
|
-
'csdx cm:bulk-publish:entries -t [CONTENT TYPE 1] [CONTENT TYPE 2] -e [ENVIRONMENT 1] [ENVIRONMENT 2] -l [LOCALE 1] [LOCALE 2] -a [MANAGEMENT TOKEN ALIAS]',
|
|
117
|
-
'',
|
|
118
|
-
'Using --config or -c flag',
|
|
119
|
-
'Generate a config file at the current working directory using `csdx cm:bulk-publish:configure -a [ALIAS]`',
|
|
120
|
-
'csdx cm:bulk-publish:entries --config [PATH TO CONFIG FILE]',
|
|
121
|
-
'csdx cm:bulk-publish:entries -c [PATH TO CONFIG FILE]',
|
|
122
|
-
'',
|
|
123
|
-
'Using --retryFailed or -r flag',
|
|
124
|
-
'csdx cm:bulk-publish:entries --retryFailed [LOG FILE NAME]',
|
|
125
|
-
'csdx cm:bulk-publish:entries -r [LOG FILE NAME]',
|
|
126
|
-
'',
|
|
127
|
-
'Using --branch or -B flag',
|
|
128
|
-
'csdx cm:bulk-publish:entries -t [CONTENT TYPE 1] [CONTENT TYPE 2] -e [ENVIRONMENT 1] [ENVIRONMENT 2] -l [LOCALE 1] [LOCALE 2] -a [MANAGEMENT TOKEN ALIAS] -B [BRANCH NAME]',
|
|
129
|
-
]
|
|
130
|
-
|
|
131
|
-
module.exports = EntriesCommand
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
const {Command, flags} = require('@oclif/command')
|
|
2
|
-
const {start} = require('../../../producer/publish-edits')
|
|
3
|
-
const store = require('../../../util/store.js')
|
|
4
|
-
// eslint-disable-next-line node/no-extraneous-require
|
|
5
|
-
const {cli} = require('cli-ux')
|
|
6
|
-
const configKey = 'publish_edits_on_env'
|
|
7
|
-
const {prettyPrint, formatError} = require('../../../util')
|
|
8
|
-
const {getStack} = require('../../../util/client.js')
|
|
9
|
-
let config
|
|
10
|
-
|
|
11
|
-
class EntryEditsCommand extends Command {
|
|
12
|
-
async run() {
|
|
13
|
-
const entryEditsFlags = this.parse(EntryEditsCommand).flags
|
|
14
|
-
let updatedFlags
|
|
15
|
-
try {
|
|
16
|
-
updatedFlags = (entryEditsFlags.config) ? store.updateMissing(configKey, entryEditsFlags) : entryEditsFlags
|
|
17
|
-
} catch (error) {
|
|
18
|
-
this.error(error.message, {exit: 2})
|
|
19
|
-
}
|
|
20
|
-
if (this.validate(updatedFlags)) {
|
|
21
|
-
let stack
|
|
22
|
-
if (!updatedFlags.retryFailed) {
|
|
23
|
-
if (!updatedFlags.alias) {
|
|
24
|
-
updatedFlags.alias = await cli.prompt('Please enter the management token alias to be used')
|
|
25
|
-
}
|
|
26
|
-
updatedFlags.bulkPublish = updatedFlags.bulkPublish !== 'false'
|
|
27
|
-
await this.config.runHook('validateManagementTokenAlias', {alias: updatedFlags.alias})
|
|
28
|
-
config = {
|
|
29
|
-
alias: updatedFlags.alias,
|
|
30
|
-
host: this.config.userConfig.getRegion().cma,
|
|
31
|
-
branch: entryEditsFlags.branch,
|
|
32
|
-
}
|
|
33
|
-
stack = getStack(config)
|
|
34
|
-
}
|
|
35
|
-
if (await this.confirmFlags(updatedFlags)) {
|
|
36
|
-
try {
|
|
37
|
-
if (!updatedFlags.retryFailed) {
|
|
38
|
-
await start(updatedFlags, stack, config)
|
|
39
|
-
} else {
|
|
40
|
-
await start(updatedFlags)
|
|
41
|
-
}
|
|
42
|
-
} catch (error) {
|
|
43
|
-
let message = formatError(error)
|
|
44
|
-
this.error(message, {exit: 2})
|
|
45
|
-
}
|
|
46
|
-
} else {
|
|
47
|
-
this.exit(0)
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
validate({contentTypes, environments, sourceEnv, locales, retryFailed}) {
|
|
53
|
-
let missing = []
|
|
54
|
-
if (retryFailed) {
|
|
55
|
-
return true
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (!contentTypes || contentTypes.length === 0) {
|
|
59
|
-
missing.push('Content Types')
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
if (!sourceEnv || sourceEnv.length === 0) {
|
|
63
|
-
missing.push('SourceEnv')
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (!environments || environments.length === 0) {
|
|
67
|
-
missing.push('Environments')
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
if (!locales || locales.length === 0) {
|
|
71
|
-
missing.push('Locales')
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if (missing.length > 0) {
|
|
75
|
-
this.error(`${missing.join(', ')} are required for processing this command. Please check --help for more details`, {exit: 2})
|
|
76
|
-
} else {
|
|
77
|
-
return true
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
async confirmFlags(data) {
|
|
82
|
-
prettyPrint(data)
|
|
83
|
-
if (data.yes) {
|
|
84
|
-
return true
|
|
85
|
-
}
|
|
86
|
-
const confirmation = await cli.confirm('Do you want to continue with this configuration ? [yes or no]')
|
|
87
|
-
return confirmation
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
EntryEditsCommand.description = `Publish edited entries from a specified Content Type to given locales and environments
|
|
92
|
-
The entry-edits command is used for publishing entries from the specified content types, to the
|
|
93
|
-
specified environments and locales
|
|
94
|
-
|
|
95
|
-
Content Type(s), Source Environment, Destination Environment(s) and Locale(s) are required for executing the command successfully
|
|
96
|
-
But, if retryFailed flag is set, then only a logfile is required
|
|
97
|
-
`
|
|
98
|
-
|
|
99
|
-
EntryEditsCommand.flags = {
|
|
100
|
-
alias: flags.string({char: 'a', description: 'Alias for the management token to be used'}),
|
|
101
|
-
retryFailed: flags.string({char: 'r', description: 'Retry publishing failed entries from the logfile (optional, overrides all other flags)'}),
|
|
102
|
-
bulkPublish: flags.string({char: 'b', description: 'This flag is set to true by default. It indicates that contentstack\'s bulkpublish API will be used for publishing the entries', default: 'true'}),
|
|
103
|
-
sourceEnv: flags.string({char: 's', description: 'Environment from which edited entries will be published'}),
|
|
104
|
-
contentTypes: flags.string({char: 't', description: 'The Content-Types which will be checked for edited entries', multiple: true}),
|
|
105
|
-
locales: flags.string({char: 'l', description: 'Locales to which edited entries need to be published', multiple: true}),
|
|
106
|
-
environments: flags.string({char: 'e', description: 'Destination environments', multiple: true}),
|
|
107
|
-
config: flags.string({char: 'c', description: 'Path to config file to be used'}),
|
|
108
|
-
yes: flags.boolean({char: 'y', description: 'Agree to process the command with the current configuration'}),
|
|
109
|
-
branch: flags.string({char: 'B', default: 'main', description: 'Specify the branch to fetch the content from (default is main branch)'}),
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
EntryEditsCommand.examples = [
|
|
113
|
-
'General Usage',
|
|
114
|
-
'csdx cm:bulk-publish:entry-edits -t [CONTENT TYPE 1] [CONTENT TYPE 2] -s [SOURCE_ENV] -e [ENVIRONMENT 1] [ENVIRONMENT 2] -l [LOCALE 1] [LOCALE 2] -a [MANAGEMENT TOKEN ALIAS]',
|
|
115
|
-
'',
|
|
116
|
-
'Using --config or -c flag',
|
|
117
|
-
'Generate a config file at the current working directory using `csdx cm:bulk-publish:configure -a [ALIAS]`',
|
|
118
|
-
'csdx cm:bulk-publish:entry-edits --config [PATH TO CONFIG FILE]',
|
|
119
|
-
'csdx cm:bulk-publish:entry-edits -c [PATH TO CONFIG FILE]',
|
|
120
|
-
'',
|
|
121
|
-
'Using --retryFailed or -r flag',
|
|
122
|
-
'csdx cm:bulk-publish:entry-edits --retryFailed [LOG FILE NAME]',
|
|
123
|
-
'csdx cm:bulk-publish:entry-edits -r [LOG FILE NAME]',
|
|
124
|
-
'',
|
|
125
|
-
'Using --branch or -B flag',
|
|
126
|
-
'csdx cm:bulk-publish:entry-edits -t [CONTENT TYPE 1] [CONTENT TYPE 2] -s [SOURCE_ENV] -e [ENVIRONMENT 1] [ENVIRONMENT 2] -l [LOCALE 1] [LOCALE 2] -a [MANAGEMENT TOKEN ALIAS] -B [BRANCH NAME]',
|
|
127
|
-
]
|
|
128
|
-
|
|
129
|
-
module.exports = EntryEditsCommand
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
const {Command, flags} = require('@oclif/command')
|
|
2
|
-
const {start} = require('../../../producer/nonlocalized-field-changes')
|
|
3
|
-
const store = require('../../../util/store.js')
|
|
4
|
-
const {cli} = require('cli-ux')
|
|
5
|
-
const configKey = 'nonlocalized_field_changes'
|
|
6
|
-
const { prettyPrint, formatError } = require('../../../util')
|
|
7
|
-
const { getStack } = require('../../../util/client.js')
|
|
8
|
-
let config
|
|
9
|
-
|
|
10
|
-
class NonlocalizedFieldChangesCommand extends Command {
|
|
11
|
-
async run() {
|
|
12
|
-
const nonlocalizedFieldChangesFlags = this.parse(NonlocalizedFieldChangesCommand).flags
|
|
13
|
-
let updatedFlags
|
|
14
|
-
try {
|
|
15
|
-
updatedFlags = (nonlocalizedFieldChangesFlags.config) ? store.updateMissing(configKey, nonlocalizedFieldChangesFlags) : nonlocalizedFieldChangesFlags
|
|
16
|
-
} catch(error) {
|
|
17
|
-
this.error(error.message, {exit: 2})
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
if (this.validate(updatedFlags)) {
|
|
21
|
-
let stack
|
|
22
|
-
if (!updatedFlags.retryFailed) {
|
|
23
|
-
updatedFlags.bulkPublish = (updatedFlags.bulkPublish === 'false') ? false : true
|
|
24
|
-
await this.config.runHook('validateManagementTokenAlias', {alias: updatedFlags.alias})
|
|
25
|
-
config = {
|
|
26
|
-
alias: updatedFlags.alias,
|
|
27
|
-
host: this.config.userConfig.getRegion().cma,
|
|
28
|
-
branch: nonlocalizedFieldChangesFlags.branch,
|
|
29
|
-
}
|
|
30
|
-
stack = getStack(config)
|
|
31
|
-
}
|
|
32
|
-
if (await this.confirmFlags(updatedFlags)) {
|
|
33
|
-
try {
|
|
34
|
-
if (!updatedFlags.retryFailed) {
|
|
35
|
-
await start(updatedFlags, stack, config)
|
|
36
|
-
} else {
|
|
37
|
-
await start(updatedFlags)
|
|
38
|
-
}
|
|
39
|
-
} catch(error) {
|
|
40
|
-
let message = formatError(error)
|
|
41
|
-
this.error(message, {exit: 2})
|
|
42
|
-
}
|
|
43
|
-
} else {
|
|
44
|
-
this.exit(0)
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
validate({contentTypes, environments, sourceEnv, retryFailed}) {
|
|
50
|
-
let missing = []
|
|
51
|
-
if (retryFailed) {
|
|
52
|
-
return true
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (!contentTypes || contentTypes.length === 0) {
|
|
56
|
-
missing.push('Content Types')
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if (!sourceEnv) {
|
|
60
|
-
missing.push('SourceEnv')
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
if (!environments || environments.length === 0) {
|
|
64
|
-
missing.push('Environments')
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (missing.length > 0) {
|
|
68
|
-
this.error(`${missing.join(', ')} are required for processing this command. Please check --help for more details`, {exit: 2})
|
|
69
|
-
} else {
|
|
70
|
-
return true
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
async confirmFlags(data) {
|
|
75
|
-
prettyPrint(data)
|
|
76
|
-
if(data.yes) {
|
|
77
|
-
return true
|
|
78
|
-
}
|
|
79
|
-
const confirmation = await cli.confirm('Do you want to continue with this configuration ? [yes or no]')
|
|
80
|
-
return confirmation
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
NonlocalizedFieldChangesCommand.description = `Publish non-localized-fields for given Content Types, from a particular source environment to specified environments
|
|
85
|
-
The nonlocalized-field-changes command is used for publishing nonlocalized field changes from the given Content Types to
|
|
86
|
-
the specified Environments
|
|
87
|
-
|
|
88
|
-
Content Types, Environments and Source Environment are required for executing this command successfully.
|
|
89
|
-
But, if retryFailed flag is set, then only a logfile is required
|
|
90
|
-
`
|
|
91
|
-
|
|
92
|
-
NonlocalizedFieldChangesCommand.flags = {
|
|
93
|
-
alias: flags.string({char: 'a', description: 'Alias for the management token to be used'}),
|
|
94
|
-
retryFailed: flags.string({char: 'r', description: 'Retry publishing failed entries from the logfile'}),
|
|
95
|
-
bulkPublish: flags.string({char: 'b', description: 'This flag is set to true by default. It indicates that contentstack\'s bulkpublish API will be used for publishing the entries', default: 'true'}),
|
|
96
|
-
sourceEnv: flags.string({char: 's', description: 'Source Environment'}),
|
|
97
|
-
contentTypes: flags.string({char: 't', description: 'The Content-Types from which entries need to be published', multiple: true}),
|
|
98
|
-
environments: flags.string({char: 'e', description: 'Destination environments', multiple: true}),
|
|
99
|
-
config: flags.string({char: 'c', description: 'Path to config file to be used'}),
|
|
100
|
-
yes: flags.boolean({char: 'y', description: 'Agree to process the command with the current configuration'}),
|
|
101
|
-
branch: flags.string({char: 'B', default: 'main', description: 'Specify the branch to fetch the content from (default is main branch)'}),
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
NonlocalizedFieldChangesCommand.examples = [
|
|
105
|
-
'General Usage',
|
|
106
|
-
'csdx cm:bulk-publish:nonlocalized-field-changes -t [CONTENT TYPE 1] [CONTENT TYPE 2] -e [ENVIRONMENT 1] [ENVIRONMENT 2] -l [LOCALE 1] [LOCALE 2] -a [MANAGEMENT TOKEN ALIAS] -s [SOURCE ENV]',
|
|
107
|
-
'',
|
|
108
|
-
'Using --config or -c flag',
|
|
109
|
-
'Generate a config file at the current working directory using `csdx cm:bulk-publish:configure -a [ALIAS]`',
|
|
110
|
-
'csdx cm:bulk-publish:nonlocalized-field-changes --config [PATH TO CONFIG FILE]',
|
|
111
|
-
'csdx cm:bulk-publish:nonlocalized-field-changes -c [PATH TO CONFIG FILE]',
|
|
112
|
-
'',
|
|
113
|
-
'Using --retryFailed or -r flag',
|
|
114
|
-
'csdx cm:bulk-publish:nonlocalized-field-changes --retryFailed [LOG FILE NAME]',
|
|
115
|
-
'csdx cm:bulk-publish:nonlocalized-field-changes -r [LOG FILE NAME]',
|
|
116
|
-
'',
|
|
117
|
-
'Using --branch or -B flag',
|
|
118
|
-
'csdx cm:bulk-publish:nonlocalized-field-changes -t [CONTENT TYPE 1] [CONTENT TYPE 2] -e [ENVIRONMENT 1] [ENVIRONMENT 2] -l [LOCALE 1] [LOCALE 2] -a [MANAGEMENT TOKEN ALIAS] -B [BRANCH NAME] -s [SOURCE ENV]',
|
|
119
|
-
]
|
|
120
|
-
|
|
121
|
-
module.exports = NonlocalizedFieldChangesCommand
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
const {Command, flags} = require('@oclif/command')
|
|
2
|
-
const {start} = require('../../../producer/revert')
|
|
3
|
-
const store = require('../../../util/store.js')
|
|
4
|
-
const configKey = 'revert'
|
|
5
|
-
const { prettyPrint, formatError } = require('../../../util')
|
|
6
|
-
const { getStack } = require('../../../util/client.js')
|
|
7
|
-
const {cli} = require('cli-ux')
|
|
8
|
-
|
|
9
|
-
let config
|
|
10
|
-
|
|
11
|
-
class RevertCommand extends Command {
|
|
12
|
-
async run() {
|
|
13
|
-
const revertFlags = this.parse(RevertCommand).flags
|
|
14
|
-
let updatedFlags
|
|
15
|
-
try {
|
|
16
|
-
updatedFlags = (revertFlags.config) ? store.updateMissing(configKey, revertFlags) : revertFlags
|
|
17
|
-
} catch(error) {
|
|
18
|
-
this.error(error.message, {exit: 2})
|
|
19
|
-
}
|
|
20
|
-
if (this.validate(updatedFlags)) {
|
|
21
|
-
if(await this.confirmFlags(updatedFlags)) {
|
|
22
|
-
try {
|
|
23
|
-
await start(updatedFlags, config)
|
|
24
|
-
} catch(error) {
|
|
25
|
-
let message = formatError(error)
|
|
26
|
-
this.error(message, {exit: 2})
|
|
27
|
-
}
|
|
28
|
-
} else {
|
|
29
|
-
this.exit(0)
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
validate({retryFailed, logFile}) {
|
|
35
|
-
let missing = []
|
|
36
|
-
if (retryFailed) {
|
|
37
|
-
return true
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (!logFile) {
|
|
41
|
-
missing.push('Logfile')
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if (missing.length > 0) {
|
|
45
|
-
this.error(`${missing.join(', ')} is required for processing this command. Please check --help for more details`, {exit: 2})
|
|
46
|
-
} else {
|
|
47
|
-
return true
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
async confirmFlags(data) {
|
|
52
|
-
prettyPrint(data)
|
|
53
|
-
if(data.yes) {
|
|
54
|
-
return true
|
|
55
|
-
}
|
|
56
|
-
const confirmation = await cli.confirm('Do you want to continue with this configuration ? [yes or no]')
|
|
57
|
-
return confirmation
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
RevertCommand.description = `Revert publish operations by using a log file
|
|
62
|
-
The revert command is used for reverting all publish operations performed using bulk-publish script.
|
|
63
|
-
A log file name is required to execute revert command
|
|
64
|
-
`
|
|
65
|
-
|
|
66
|
-
RevertCommand.flags = {
|
|
67
|
-
retryFailed: flags.string({char: 'r', description: 'retry publishing failed entries from the logfile'}),
|
|
68
|
-
logFile: flags.string({char: 'l', description: 'logfile to be used to revert'}),
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
RevertCommand.examples = [
|
|
72
|
-
'Using --logFile',
|
|
73
|
-
'cm:bulk-publish:revert --logFile [LOG FILE NAME]',
|
|
74
|
-
'cm:bulk-publish:revert -l [LOG FILE NAME]',
|
|
75
|
-
'',
|
|
76
|
-
'Using --retryFailed',
|
|
77
|
-
'cm:bulk-publish:revert --retryFailed [LOG FILE NAME]',
|
|
78
|
-
'cm:bulk-publish:revert -r [LOG FILE NAME]',
|
|
79
|
-
]
|
|
80
|
-
|
|
81
|
-
module.exports = RevertCommand
|