@contentstack/cli-cm-import 0.1.1-beta.1 → 0.1.1-beta.10
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/README.md +10 -11
- package/oclif.manifest.json +1 -1
- package/package.json +12 -9
- package/src/app.js +108 -75
- package/src/commands/cm/import.js +82 -38
- package/src/config/default.js +238 -211
- package/src/lib/import/assets.js +42 -38
- package/src/lib/import/content-types.js +90 -95
- package/src/lib/import/entries.js +426 -399
- package/src/lib/import/environments.js +1 -1
- package/src/lib/import/global-fields.js +3 -0
- package/src/lib/import/labels.js +43 -37
- package/src/lib/import/locales.js +32 -21
- package/src/lib/import/workflows.js +118 -0
- package/src/lib/util/contentstack-management-sdk.js +21 -9
- package/src/lib/util/extensionsUidReplace.js +27 -29
- package/src/lib/util/import-flags.js +129 -75
- package/src/lib/util/index.js +77 -5
- package/src/lib/util/log.js +4 -2
- package/src/lib/util/login.js +2 -2
- package/src/lib/util/lookupReplaceEntries.js +92 -94
- package/src/lib/util/supress-mandatory-fields.js +1 -1
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ $ npm install -g @contentstack/cli-cm-import
|
|
|
16
16
|
$ csdx COMMAND
|
|
17
17
|
running command...
|
|
18
18
|
$ csdx (-v|--version|version)
|
|
19
|
-
@contentstack/cli-cm-import/0.1.1-beta.
|
|
19
|
+
@contentstack/cli-cm-import/0.1.1-beta.10 linux-x64 node-v12.22.7
|
|
20
20
|
$ csdx --help [COMMAND]
|
|
21
21
|
USAGE
|
|
22
22
|
$ csdx COMMAND
|
|
@@ -29,8 +29,6 @@ USAGE
|
|
|
29
29
|
|
|
30
30
|
## `csdx cm:import`
|
|
31
31
|
|
|
32
|
-
Import script for importing the content into new stack
|
|
33
|
-
|
|
34
32
|
```
|
|
35
33
|
USAGE
|
|
36
34
|
$ csdx cm:import
|
|
@@ -38,9 +36,9 @@ USAGE
|
|
|
38
36
|
OPTIONS
|
|
39
37
|
-A, --auth-token to use auth token
|
|
40
38
|
-a, --management-token-alias=management-token-alias alias of the management token
|
|
39
|
+
-b, --backup-dir=backup-dir [optional] backup directory name when using specific module
|
|
41
40
|
-c, --config=config [optional] path of config file
|
|
42
41
|
-d, --data=data path and location where data is stored
|
|
43
|
-
-l, --master-lang=master-lang code of the target stack's master language
|
|
44
42
|
-m, --module=module [optional] specific module name
|
|
45
43
|
-s, --stack-uid=stack-uid API key of the target stack
|
|
46
44
|
|
|
@@ -50,13 +48,14 @@ DESCRIPTION
|
|
|
50
48
|
|
|
51
49
|
EXAMPLES
|
|
52
50
|
csdx cm:import -A
|
|
53
|
-
csdx cm:import -A -
|
|
54
|
-
csdx cm:import -A -c
|
|
55
|
-
csdx cm:import -
|
|
56
|
-
csdx cm:import -
|
|
57
|
-
csdx cm:import -a
|
|
58
|
-
csdx cm:import -
|
|
51
|
+
csdx cm:import -A -s <stack_ApiKey> -d <path/of/export/destination/dir>
|
|
52
|
+
csdx cm:import -A -c <path/of/config/dir>
|
|
53
|
+
csdx cm:import -A -m <single module name>
|
|
54
|
+
csdx cm:import -A -m <single module name> -b <backup dir>
|
|
55
|
+
csdx cm:import -a <management_token_alias>
|
|
56
|
+
csdx cm:import -a <management_token_alias> -d <path/of/export/destination/dir>
|
|
57
|
+
csdx cm:import -a <management_token_alias> -c <path/of/config/file>
|
|
59
58
|
```
|
|
60
59
|
|
|
61
|
-
_See code: [src/commands/cm/import.js](https://github.com/contentstack/cli/blob/v0.1.1-beta.
|
|
60
|
+
_See code: [src/commands/cm/import.js](https://github.com/contentstack/cli/blob/v0.1.1-beta.10/packages/contentstack-import/src/commands/cm/import.js)_
|
|
62
61
|
<!-- commandsstop -->
|
package/oclif.manifest.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"0.1.1-beta.
|
|
1
|
+
{"version":"0.1.1-beta.10","commands":{"cm:import":{"id":"cm:import","description":"Import script for importing the content into new stack\n...\nOnce you export content from the source stack, import it to your destination stack by using the cm:import command.\n","pluginName":"@contentstack/cli-cm-import","pluginType":"core","aliases":[],"examples":["csdx cm:import -A","csdx cm:import -A -s <stack_ApiKey> -d <path/of/export/destination/dir>","csdx cm:import -A -c <path/of/config/dir>","csdx cm:import -A -m <single module name>","csdx cm:import -A -m <single module name> -b <backup dir>","csdx cm:import -a <management_token_alias>","csdx cm:import -a <management_token_alias> -d <path/of/export/destination/dir>","csdx cm:import -a <management_token_alias> -c <path/of/config/file>"],"flags":{"config":{"name":"config","type":"option","char":"c","description":"[optional] path of config file"},"stack-uid":{"name":"stack-uid","type":"option","char":"s","description":"API key of the target stack"},"data":{"name":"data","type":"option","char":"d","description":"path and location where data is stored"},"management-token-alias":{"name":"management-token-alias","type":"option","char":"a","description":"alias of the management token"},"auth-token":{"name":"auth-token","type":"boolean","char":"A","description":"to use auth token","allowNo":false},"module":{"name":"module","type":"option","char":"m","description":"[optional] specific module name"},"backup-dir":{"name":"backup-dir","type":"option","char":"b","description":"[optional] backup directory name when using specific module"}},"args":[]}}}
|
package/package.json
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentstack/cli-cm-import",
|
|
3
3
|
"description": "Contentstack CLI plugin to import content into stack",
|
|
4
|
-
"version": "0.1.1-beta.
|
|
4
|
+
"version": "0.1.1-beta.10",
|
|
5
5
|
"author": "Contentstack",
|
|
6
6
|
"bugs": "https://github.com/contentstack/cli/issues",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@contentstack/
|
|
8
|
+
"@contentstack/cli-command": "0.1.0-beta",
|
|
9
|
+
"@contentstack/management": "^1.2.1",
|
|
9
10
|
"@oclif/command": "^1.6.1",
|
|
10
|
-
"@contentstack/cli-command": "0.1.1-beta.1",
|
|
11
11
|
"@oclif/config": "^1.15.1",
|
|
12
|
-
"axios": "^0.
|
|
12
|
+
"axios": "^0.21.1",
|
|
13
13
|
"bluebird": "3.5.1",
|
|
14
14
|
"configstore": "^5.0.1",
|
|
15
15
|
"debug": "4.1.0",
|
|
16
|
-
"lodash": "4.17.
|
|
16
|
+
"lodash": "^4.17.20",
|
|
17
17
|
"marked": "0.7.0",
|
|
18
|
-
"mkdirp": "0.
|
|
18
|
+
"mkdirp": "^1.0.4",
|
|
19
19
|
"ncp": "2.0.0",
|
|
20
20
|
"request": "2.88.0",
|
|
21
|
-
"winston": "2.
|
|
21
|
+
"winston": "2.4.5"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@oclif/dev-cli": "^1.22.2",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"eslint": "^5.16.0",
|
|
29
29
|
"eslint-config-oclif": "^3.1.0",
|
|
30
30
|
"globby": "^10.0.2",
|
|
31
|
-
"mocha": "^
|
|
31
|
+
"mocha": "^8.2.1",
|
|
32
32
|
"nyc": "^14.1.1"
|
|
33
33
|
},
|
|
34
34
|
"engines": {
|
|
@@ -42,7 +42,9 @@
|
|
|
42
42
|
],
|
|
43
43
|
"homepage": "https://github.com/contentstack/cli",
|
|
44
44
|
"keywords": [
|
|
45
|
-
"contentstack",
|
|
45
|
+
"contentstack",
|
|
46
|
+
"cli",
|
|
47
|
+
"plugin"
|
|
46
48
|
],
|
|
47
49
|
"scripts": {
|
|
48
50
|
"pack": "npm pack && mv *.tgz ../../build",
|
|
@@ -51,6 +53,7 @@
|
|
|
51
53
|
"test": "nyc mocha --forbid-only \"test/**/*.test.js\"",
|
|
52
54
|
"version": "oclif-dev readme && git add README.md"
|
|
53
55
|
},
|
|
56
|
+
"main": "./src/commands/cm/import.js",
|
|
54
57
|
"license": "MIT",
|
|
55
58
|
"oclif": {
|
|
56
59
|
"commands": "./src/commands",
|
package/src/app.js
CHANGED
|
@@ -9,95 +9,128 @@ let Bluebird = require('bluebird')
|
|
|
9
9
|
let fs = require('fs')
|
|
10
10
|
let path = require('path')
|
|
11
11
|
const chalk = require('chalk')
|
|
12
|
+
const helper = require('./lib/util/fs')
|
|
13
|
+
let _ = require('lodash')
|
|
12
14
|
|
|
13
15
|
let login = require('./lib/util/login')
|
|
14
16
|
let util = require('./lib/util/index')
|
|
15
|
-
let {addlogs} = require('./lib/util/log')
|
|
16
17
|
|
|
17
|
-
exports.initial = function (configData) {
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
19
|
+
let { addlogs } = require('./lib/util/log')
|
|
20
|
+
|
|
21
|
+
exports.initial = function (configData) {
|
|
22
|
+
return new Promise(function (resolve, reject) {
|
|
23
|
+
let config = util.initialization(configData)
|
|
24
|
+
config.oldPath = config.data
|
|
25
|
+
if (config && config !== undefined) {
|
|
26
|
+
login(config)
|
|
27
|
+
.then(function () {
|
|
28
|
+
if (fs.existsSync(config.data)) {
|
|
29
|
+
let migrationBackupDirPath = path.join(process.cwd(), '_backup_' + Math.floor((Math.random() * 1000)))
|
|
30
|
+
return createBackup(migrationBackupDirPath, config).then((basePath) => {
|
|
31
|
+
config.data = basePath
|
|
32
|
+
return util.sanitizeStack(config)
|
|
33
|
+
}).catch(e => {
|
|
34
|
+
console.error(e)
|
|
35
|
+
process.exit(1)
|
|
36
|
+
})
|
|
37
|
+
.then(() => {
|
|
38
|
+
let types = config.modules.types
|
|
39
|
+
if (config.moduleName && config.moduleName !== undefined) {
|
|
40
|
+
singleImport(config.moduleName, types, config).then(() => {
|
|
41
|
+
return resolve()
|
|
42
|
+
})
|
|
43
|
+
} else {
|
|
44
|
+
allImport(config, types).then(() => {
|
|
45
|
+
return resolve()
|
|
46
|
+
})
|
|
47
|
+
}
|
|
48
|
+
}).catch(e => {
|
|
49
|
+
console.error(e)
|
|
50
|
+
return reject(e)
|
|
51
|
+
})
|
|
52
|
+
} else {
|
|
53
|
+
let filename = path.basename(config.data)
|
|
54
|
+
addlogs(config, chalk.red(filename + " Folder does not Exist"), 'error')
|
|
55
|
+
return
|
|
56
|
+
}
|
|
57
|
+
}).catch(error => {
|
|
58
|
+
return
|
|
59
|
+
})
|
|
60
|
+
}
|
|
61
|
+
})
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
let singleImport = async (moduleName, types, config) => {
|
|
65
|
+
return new Promise(async (resolve, reject) => {
|
|
66
|
+
if (types.indexOf(moduleName) > -1) {
|
|
67
|
+
if (!config.master_locale) {
|
|
68
|
+
try {
|
|
69
|
+
var masterLocalResponse = await util.masterLocalDetails(config)
|
|
70
|
+
let master_locale = { code: masterLocalResponse.code }
|
|
71
|
+
config['master_locale'] = master_locale
|
|
72
|
+
} catch (error) {
|
|
73
|
+
console.log("Error to fetch the stack details" + error);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
let exportedModule = require('./lib/import/' + moduleName)
|
|
77
|
+
exportedModule.start(config).then(async function () {
|
|
78
|
+
if (moduleName === 'content-types') {
|
|
79
|
+
let ctPath = path.resolve(config.data, config.modules.content_types.dirName)
|
|
80
|
+
let fieldPath = path.join(ctPath + '/field_rules_uid.json')
|
|
81
|
+
if (fieldPath && fieldPath !== undefined) {
|
|
82
|
+
await util.field_rules_update(config, ctPath)
|
|
83
|
+
}
|
|
39
84
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
85
|
+
addlogs(config, moduleName + ' imported successfully!', 'success')
|
|
86
|
+
addlogs(config, 'The log for this is stored at ' + path.join(config.oldPath, 'logs', 'import'), 'success')
|
|
87
|
+
return resolve()
|
|
88
|
+
}).catch(function (error) {
|
|
89
|
+
addlogs(config, 'Failed to migrate ' + moduleName, 'error')
|
|
90
|
+
addlogs(config, error, 'error')
|
|
91
|
+
addlogs(config, 'The log for this is stored at ' + path.join(config.oldPath, 'logs', 'import'), 'error')
|
|
92
|
+
return reject()
|
|
43
93
|
})
|
|
44
|
-
} else {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
return
|
|
94
|
+
} else {
|
|
95
|
+
addlogs(config, 'Please provide valid module name.', 'error')
|
|
96
|
+
return reject()
|
|
48
97
|
}
|
|
49
|
-
|
|
50
|
-
return
|
|
51
|
-
})
|
|
52
|
-
}
|
|
98
|
+
})
|
|
53
99
|
}
|
|
54
100
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
101
|
+
let allImport = async (config, types) => {
|
|
102
|
+
return new Promise(async (resolve, reject) => {
|
|
103
|
+
try {
|
|
104
|
+
for (let i = 0; i < types.length; i++) {
|
|
105
|
+
let type = types[i]
|
|
106
|
+
var exportedModule = require('./lib/import/' + type)
|
|
107
|
+
if (i === 0 && !config.master_locale) {
|
|
108
|
+
var masterLocalResponse = await util.masterLocalDetails(config)
|
|
109
|
+
let master_locale = { code: masterLocalResponse.code }
|
|
110
|
+
config['master_locale'] = master_locale
|
|
111
|
+
}
|
|
112
|
+
await exportedModule.start(config).then(result => {
|
|
113
|
+
return
|
|
114
|
+
})
|
|
115
|
+
}
|
|
116
|
+
if (config.target_stack && config.source_stack) {
|
|
117
|
+
addlogs(config, chalk.green('The data of the ' + config.sourceStackName + ' stack has been imported into ' + config.destinationStackName + ' stack successfully!'), 'success')
|
|
118
|
+
addlogs(config, 'The log for this is stored at ' + path.join(config.data, 'logs', 'import'), 'success')
|
|
119
|
+
} else {
|
|
120
|
+
addlogs(config, chalk.green('Stack: ' + config.target_stack + ' has been imported succesfully!'), 'success')
|
|
121
|
+
addlogs(config, 'The log for this is stored at ' + path.join(config.oldPath, 'logs', 'import'), 'success')
|
|
122
|
+
}
|
|
123
|
+
return resolve()
|
|
124
|
+
} catch (error) {
|
|
125
|
+
addlogs(config, chalk.red('Failed to migrate stack: ' + config.target_stack + '. Please check error logs for more info'), 'error')
|
|
64
126
|
addlogs(config, error, 'error')
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
} else {
|
|
68
|
-
addlogs(config, 'Please provide valid module name.', 'error')
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
let allExport = async (config, types) => {
|
|
73
|
-
let counter = 0
|
|
74
|
-
Bluebird.map(types, function (type) {
|
|
75
|
-
if (config.preserveStackVersion) {
|
|
76
|
-
let exportedModule = require('./lib/import/' + types[counter])
|
|
77
|
-
counter++
|
|
78
|
-
return exportedModule.start(config)
|
|
79
|
-
} else if(!config.preserveStackVersion && type !== 'stack') {
|
|
80
|
-
let exportedModule = require('./lib/import/' + types[counter])
|
|
81
|
-
counter++
|
|
82
|
-
return exportedModule.start(config)
|
|
83
|
-
} else {
|
|
84
|
-
counter++
|
|
127
|
+
addlogs(config, 'The log for this is stored at ' + path.join(config.oldPath, 'logs', 'import'), 'error')
|
|
128
|
+
return reject()
|
|
85
129
|
}
|
|
86
|
-
}, {
|
|
87
|
-
concurrency: 1
|
|
88
|
-
}).then(function () {
|
|
89
|
-
addlogs(config, chalk.green('Stack: ' + config.target_stack + ' has been imported succesfully!'), 'success')
|
|
90
|
-
addlogs(config, 'The log for this is stored at' + path.join(config.oldPath, 'logs', 'import'), 'success')
|
|
91
|
-
}).catch(function (error) {
|
|
92
|
-
addlogs(config, chalk.red('Failed to migrate stack: ' + config.target_stack + '. Please check error logs for more info'), 'error')
|
|
93
|
-
addlogs(config, error, 'error')
|
|
94
|
-
addlogs(config, 'The log for this is stored at' + path.join(config.oldPath, 'logs', 'import'), 'error')
|
|
95
|
-
|
|
96
130
|
})
|
|
97
131
|
}
|
|
98
132
|
|
|
99
|
-
|
|
100
|
-
function createBackup (backupDirPath, config) {
|
|
133
|
+
function createBackup(backupDirPath, config) {
|
|
101
134
|
return new Promise((resolve, reject) => {
|
|
102
135
|
if (config.hasOwnProperty('useBackedupDir') && fs.existsSync(config.useBackedupDir)) {
|
|
103
136
|
return resolve(config.useBackedupDir)
|
|
@@ -119,4 +152,4 @@ function createBackup (backupDirPath, config) {
|
|
|
119
152
|
})
|
|
120
153
|
}
|
|
121
154
|
})
|
|
122
|
-
}
|
|
155
|
+
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// const {Command, flags} = require('@oclif/command')
|
|
2
1
|
const {Command, flags} = require('@contentstack/cli-command')
|
|
3
2
|
const {cli} = require('cli-ux')
|
|
4
3
|
let _ = require('lodash')
|
|
@@ -14,50 +13,61 @@ const {configWithMToken,
|
|
|
14
13
|
|
|
15
14
|
class ImportCommand extends Command {
|
|
16
15
|
async run() {
|
|
17
|
-
|
|
16
|
+
let self = this
|
|
17
|
+
const {flags} = self.parse(ImportCommand)
|
|
18
18
|
const extConfig = flags.config
|
|
19
|
-
const masterLang = flags['master-lang']
|
|
20
19
|
let targetStack = flags['stack-uid']
|
|
21
20
|
const data = flags.data
|
|
22
21
|
const moduleName = flags.module
|
|
22
|
+
const backupdir = flags["backup-dir"]
|
|
23
23
|
const alias = flags['management-token-alias']
|
|
24
24
|
const authToken = flags['auth-token']
|
|
25
25
|
let _authToken = credStore.get('authtoken')
|
|
26
|
-
let host =
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
let cdaMainURL = host.cda.split('//')
|
|
30
|
-
host.cma = cmaMainURL[1]
|
|
31
|
-
host.cda = cdaMainURL[1]
|
|
32
|
-
|
|
26
|
+
let host = self.cmaHost
|
|
27
|
+
|
|
28
|
+
return new Promise(function (resolve, reject) {
|
|
33
29
|
if (alias && alias !== undefined) {
|
|
34
|
-
let managementTokens =
|
|
30
|
+
let managementTokens = self.getToken(alias)
|
|
35
31
|
|
|
36
32
|
if (managementTokens && managementTokens !== undefined) {
|
|
37
|
-
if (extConfig && extConfig !== undefined) {
|
|
33
|
+
if (extConfig && extConfig !== undefined && _authToken) {
|
|
38
34
|
configWithMToken(
|
|
39
35
|
extConfig,
|
|
40
36
|
managementTokens,
|
|
41
37
|
moduleName,
|
|
42
|
-
host
|
|
38
|
+
host,
|
|
39
|
+
_authToken,
|
|
40
|
+
backupdir
|
|
43
41
|
)
|
|
44
|
-
|
|
42
|
+
.then(() => {
|
|
43
|
+
return resolve()
|
|
44
|
+
})
|
|
45
|
+
} else if (data) {
|
|
45
46
|
parameterWithMToken(
|
|
46
|
-
masterLang,
|
|
47
47
|
managementTokens,
|
|
48
48
|
data,
|
|
49
49
|
moduleName,
|
|
50
|
-
host
|
|
50
|
+
host,
|
|
51
|
+
_authToken,
|
|
52
|
+
backupdir
|
|
51
53
|
)
|
|
54
|
+
.then(() => {
|
|
55
|
+
return resolve()
|
|
56
|
+
})
|
|
52
57
|
} else {
|
|
53
58
|
withoutParameterMToken(
|
|
54
59
|
managementTokens,
|
|
55
60
|
moduleName,
|
|
56
|
-
host
|
|
61
|
+
host,
|
|
62
|
+
_authToken,
|
|
63
|
+
backupdir
|
|
57
64
|
)
|
|
65
|
+
.then(() => {
|
|
66
|
+
return resolve()
|
|
67
|
+
})
|
|
58
68
|
}
|
|
59
69
|
} else {
|
|
60
|
-
|
|
70
|
+
console.log('management Token is not present please add managment token first')
|
|
61
71
|
}
|
|
62
72
|
} else if (authToken && authToken !== undefined && _authToken && _authToken !== undefined) {
|
|
63
73
|
if (extConfig && extConfig !== undefined) {
|
|
@@ -65,28 +75,40 @@ class ImportCommand extends Command {
|
|
|
65
75
|
extConfig,
|
|
66
76
|
_authToken,
|
|
67
77
|
moduleName,
|
|
68
|
-
host
|
|
78
|
+
host,
|
|
79
|
+
backupdir
|
|
69
80
|
)
|
|
70
|
-
|
|
81
|
+
.then(() => {
|
|
82
|
+
return resolve()
|
|
83
|
+
})
|
|
84
|
+
} else if (targetStack && data) {
|
|
71
85
|
parametersWithAuthToken(
|
|
72
|
-
masterLang,
|
|
73
86
|
_authToken,
|
|
74
87
|
targetStack,
|
|
75
88
|
data,
|
|
76
89
|
moduleName,
|
|
77
|
-
host
|
|
90
|
+
host,
|
|
91
|
+
backupdir
|
|
78
92
|
)
|
|
93
|
+
.then(() => {
|
|
94
|
+
return resolve()
|
|
95
|
+
})
|
|
79
96
|
} else {
|
|
80
97
|
withoutParametersWithAuthToken(
|
|
81
98
|
_authToken,
|
|
82
99
|
moduleName,
|
|
83
|
-
host
|
|
100
|
+
host,
|
|
101
|
+
backupdir
|
|
84
102
|
)
|
|
103
|
+
.then(() => {
|
|
104
|
+
return resolve()
|
|
105
|
+
})
|
|
85
106
|
}
|
|
86
107
|
} else {
|
|
87
|
-
|
|
108
|
+
console.log('Provide alias for managementToken or authtoken')
|
|
88
109
|
}
|
|
89
|
-
}
|
|
110
|
+
})
|
|
111
|
+
}
|
|
90
112
|
}
|
|
91
113
|
|
|
92
114
|
ImportCommand.description = `Import script for importing the content into new stack
|
|
@@ -95,21 +117,43 @@ Once you export content from the source stack, import it to your destination sta
|
|
|
95
117
|
`
|
|
96
118
|
ImportCommand.examples = [
|
|
97
119
|
`csdx cm:import -A`,
|
|
98
|
-
`csdx cm:import -A -
|
|
99
|
-
`csdx cm:import -A -c
|
|
100
|
-
`csdx cm:import -
|
|
101
|
-
`csdx cm:import -
|
|
102
|
-
`csdx cm:import -a
|
|
103
|
-
`csdx cm:import -
|
|
120
|
+
`csdx cm:import -A -s <stack_ApiKey> -d <path/of/export/destination/dir>`,
|
|
121
|
+
`csdx cm:import -A -c <path/of/config/dir>`,
|
|
122
|
+
`csdx cm:import -A -m <single module name>`,
|
|
123
|
+
`csdx cm:import -A -m <single module name> -b <backup dir>`,
|
|
124
|
+
`csdx cm:import -a <management_token_alias>`,
|
|
125
|
+
`csdx cm:import -a <management_token_alias> -d <path/of/export/destination/dir>`,
|
|
126
|
+
`csdx cm:import -a <management_token_alias> -c <path/of/config/file>`,
|
|
104
127
|
]
|
|
105
128
|
ImportCommand.flags = {
|
|
106
|
-
config: flags.string({
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
'
|
|
111
|
-
|
|
112
|
-
|
|
129
|
+
config: flags.string({
|
|
130
|
+
char: 'c',
|
|
131
|
+
description: '[optional] path of config file'
|
|
132
|
+
}),
|
|
133
|
+
'stack-uid': flags.string({
|
|
134
|
+
char: 's',
|
|
135
|
+
description: 'API key of the target stack'
|
|
136
|
+
}),
|
|
137
|
+
data: flags.string({
|
|
138
|
+
char: 'd',
|
|
139
|
+
description: 'path and location where data is stored'
|
|
140
|
+
}),
|
|
141
|
+
'management-token-alias': flags.string({
|
|
142
|
+
char: 'a',
|
|
143
|
+
description: 'alias of the management token'
|
|
144
|
+
}),
|
|
145
|
+
'auth-token': flags.boolean({
|
|
146
|
+
char: 'A',
|
|
147
|
+
description: 'to use auth token'
|
|
148
|
+
}),
|
|
149
|
+
module: flags.string({
|
|
150
|
+
char: 'm',
|
|
151
|
+
description: '[optional] specific module name'
|
|
152
|
+
}),
|
|
153
|
+
"backup-dir": flags.string({
|
|
154
|
+
char: 'b',
|
|
155
|
+
description: '[optional] backup directory name when using specific module'
|
|
156
|
+
})
|
|
113
157
|
}
|
|
114
158
|
|
|
115
159
|
module.exports = ImportCommand
|