@contentstack/cli-cm-import 0.1.1-beta.1 → 0.1.1-beta.12
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 +13 -9
- package/oclif.manifest.json +1 -1
- package/package.json +13 -10
- package/src/app.js +106 -76
- package/src/commands/cm/import.js +106 -49
- package/src/config/default.js +238 -211
- package/src/lib/import/assets.js +44 -40
- package/src/lib/import/content-types.js +90 -97
- package/src/lib/import/entries.js +423 -406
- package/src/lib/import/environments.js +1 -1
- package/src/lib/import/global-fields.js +4 -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 +22 -5
- package/src/lib/util/extensionsUidReplace.js +27 -29
- package/src/lib/util/import-flags.js +135 -75
- package/src/lib/util/index.js +100 -28
- package/src/lib/util/log.js +4 -2
- package/src/lib/util/login.js +4 -4
- package/src/lib/util/lookupReplaceEntries.js +92 -94
- package/src/lib/util/removeReferenceFields.js +3 -5
- 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.12 linux-x64 node-v12.18.4
|
|
20
20
|
$ csdx --help [COMMAND]
|
|
21
21
|
USAGE
|
|
22
22
|
$ csdx COMMAND
|
|
@@ -37,10 +37,11 @@ USAGE
|
|
|
37
37
|
|
|
38
38
|
OPTIONS
|
|
39
39
|
-A, --auth-token to use auth token
|
|
40
|
+
-B, --branch=branch [optional] branch name
|
|
40
41
|
-a, --management-token-alias=management-token-alias alias of the management token
|
|
42
|
+
-b, --backup-dir=backup-dir [optional] backup directory name when using specific module
|
|
41
43
|
-c, --config=config [optional] path of config file
|
|
42
44
|
-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
45
|
-m, --module=module [optional] specific module name
|
|
45
46
|
-s, --stack-uid=stack-uid API key of the target stack
|
|
46
47
|
|
|
@@ -50,13 +51,16 @@ DESCRIPTION
|
|
|
50
51
|
|
|
51
52
|
EXAMPLES
|
|
52
53
|
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 -
|
|
54
|
+
csdx cm:import -A -s <stack_ApiKey> -d <path/of/export/destination/dir>
|
|
55
|
+
csdx cm:import -A -c <path/of/config/dir>
|
|
56
|
+
csdx cm:import -A -m <single module name>
|
|
57
|
+
csdx cm:import -A -m <single module name> -b <backup dir>
|
|
58
|
+
csdx cm:import -a <management_token_alias>
|
|
59
|
+
csdx cm:import -a <management_token_alias> -d <path/of/export/destination/dir>
|
|
60
|
+
csdx cm:import -a <management_token_alias> -c <path/of/config/file>
|
|
61
|
+
csdx cm:import -A -m <single module name>
|
|
62
|
+
csdx cm:import -A -B <branch name>
|
|
59
63
|
```
|
|
60
64
|
|
|
61
|
-
_See code: [src/commands/cm/import.js](https://github.com/contentstack/cli/blob/v0.1.1-beta.
|
|
65
|
+
_See code: [src/commands/cm/import.js](https://github.com/contentstack/cli/blob/v0.1.1-beta.12/packages/contentstack-import/src/commands/cm/import.js)_
|
|
62
66
|
<!-- commandsstop -->
|
package/oclif.manifest.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"0.1.1-beta.
|
|
1
|
+
{"version":"0.1.1-beta.12","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>","csdx cm:import -A -m <single module name>","csdx cm:import -A -B <branch name>"],"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"},"branch":{"name":"branch","type":"option","char":"B","description":"[optional] branch name"}},"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.12",
|
|
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": "github:contentstack/contentstack-management-javascript#65e8588",
|
|
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
|
-
"debug": "4.1.0",
|
|
16
|
-
"lodash": "4.17.
|
|
15
|
+
"debug": "^4.1.0",
|
|
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,125 @@ let Bluebird = require('bluebird')
|
|
|
9
9
|
let fs = require('fs')
|
|
10
10
|
let path = require('path')
|
|
11
11
|
const chalk = require('chalk')
|
|
12
|
-
|
|
12
|
+
const helper = require('./lib/util/fs')
|
|
13
|
+
let _ = require('lodash')
|
|
13
14
|
let login = require('./lib/util/login')
|
|
14
15
|
let util = require('./lib/util/index')
|
|
15
|
-
let {addlogs} = require('./lib/util/log')
|
|
16
|
+
let { addlogs } = require('./lib/util/log')
|
|
16
17
|
|
|
17
|
-
exports.initial = function (configData) {
|
|
18
|
+
exports.initial = function (configData) {
|
|
19
|
+
return new Promise(function (resolve, reject) {
|
|
20
|
+
let config = util.initialization(configData)
|
|
21
|
+
config.oldPath = config.data
|
|
22
|
+
if (config) {
|
|
23
|
+
login(config)
|
|
24
|
+
.then(function () {
|
|
25
|
+
if (fs.existsSync(config.data)) {
|
|
26
|
+
let migrationBackupDirPath = path.join(process.cwd(), '_backup_' + Math.floor((Math.random() * 1000)))
|
|
27
|
+
return createBackup(migrationBackupDirPath, config).then((basePath) => {
|
|
28
|
+
config.data = basePath
|
|
29
|
+
return util.sanitizeStack(config)
|
|
30
|
+
}).catch(e => {
|
|
31
|
+
console.error(e)
|
|
32
|
+
process.exit(1)
|
|
33
|
+
})
|
|
34
|
+
.then(() => {
|
|
35
|
+
let types = config.modules.types
|
|
36
|
+
if (config.moduleName) {
|
|
37
|
+
singleImport(config.moduleName, types, config).then(() => {
|
|
38
|
+
return resolve()
|
|
39
|
+
})
|
|
40
|
+
} else {
|
|
41
|
+
allImport(config, types).then(() => {
|
|
42
|
+
return resolve()
|
|
43
|
+
})
|
|
44
|
+
}
|
|
45
|
+
}).catch(e => {
|
|
46
|
+
console.error(e)
|
|
47
|
+
return reject(e)
|
|
48
|
+
})
|
|
49
|
+
} else {
|
|
50
|
+
let filename = path.basename(config.data)
|
|
51
|
+
addlogs(config, chalk.red(filename + " Folder does not Exist"), 'error')
|
|
52
|
+
return
|
|
53
|
+
}
|
|
54
|
+
}).catch(error => {
|
|
55
|
+
return
|
|
56
|
+
})
|
|
57
|
+
}
|
|
58
|
+
})
|
|
59
|
+
}
|
|
18
60
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
61
|
+
let singleImport = async (moduleName, types, config) => {
|
|
62
|
+
return new Promise(async (resolve, reject) => {
|
|
63
|
+
if (types.indexOf(moduleName) > -1) {
|
|
64
|
+
if (!config.master_locale) {
|
|
65
|
+
try {
|
|
66
|
+
var masterLocalResponse = await util.masterLocalDetails(config)
|
|
67
|
+
let master_locale = { code: masterLocalResponse.code }
|
|
68
|
+
config['master_locale'] = master_locale
|
|
69
|
+
} catch (error) {
|
|
70
|
+
console.log("Error to fetch the stack details" + error);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
let exportedModule = require('./lib/import/' + moduleName)
|
|
74
|
+
exportedModule.start(config).then(async function () {
|
|
75
|
+
if (moduleName === 'content-types') {
|
|
76
|
+
let ctPath = path.resolve(config.data, config.modules.content_types.dirName)
|
|
77
|
+
let fieldPath = path.join(ctPath + '/field_rules_uid.json')
|
|
78
|
+
if (fieldPath && fieldPath !== undefined) {
|
|
79
|
+
await util.field_rules_update(config, ctPath)
|
|
80
|
+
}
|
|
39
81
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
82
|
+
addlogs(config, moduleName + ' imported successfully!', 'success')
|
|
83
|
+
addlogs(config, 'The log for this is stored at ' + path.join(config.oldPath, 'logs', 'import'), 'success')
|
|
84
|
+
return resolve()
|
|
85
|
+
}).catch(function (error) {
|
|
86
|
+
addlogs(config, 'Failed to migrate ' + moduleName, 'error')
|
|
87
|
+
addlogs(config, error, 'error')
|
|
88
|
+
addlogs(config, 'The log for this is stored at ' + path.join(config.oldPath, 'logs', 'import'), 'error')
|
|
89
|
+
return reject(error)
|
|
43
90
|
})
|
|
44
|
-
} else {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
return
|
|
91
|
+
} else {
|
|
92
|
+
addlogs(config, 'Please provide valid module name.', 'error')
|
|
93
|
+
return reject()
|
|
48
94
|
}
|
|
49
|
-
|
|
50
|
-
return
|
|
51
|
-
})
|
|
52
|
-
}
|
|
95
|
+
})
|
|
53
96
|
}
|
|
54
97
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
98
|
+
let allImport = async (config, types) => {
|
|
99
|
+
return new Promise(async (resolve, reject) => {
|
|
100
|
+
try {
|
|
101
|
+
for (let i = 0; i < types.length; i++) {
|
|
102
|
+
let type = types[i]
|
|
103
|
+
var exportedModule = require('./lib/import/' + type)
|
|
104
|
+
if (i === 0 && !config.master_locale) {
|
|
105
|
+
var masterLocalResponse = await util.masterLocalDetails(config)
|
|
106
|
+
let master_locale = { code: masterLocalResponse.code }
|
|
107
|
+
config['master_locale'] = master_locale
|
|
108
|
+
}
|
|
109
|
+
await exportedModule.start(config).then(result => {
|
|
110
|
+
return
|
|
111
|
+
})
|
|
112
|
+
}
|
|
113
|
+
if (config.target_stack && config.source_stack) {
|
|
114
|
+
addlogs(config, chalk.green('The data of the ' + config.sourceStackName + ' stack has been imported into ' + config.destinationStackName + ' stack successfully!'), 'success')
|
|
115
|
+
addlogs(config, 'The log for this is stored at ' + path.join(config.data, 'logs', 'import'), 'success')
|
|
116
|
+
} else {
|
|
117
|
+
addlogs(config, chalk.green('Stack: ' + config.target_stack + ' has been imported succesfully!'), 'success')
|
|
118
|
+
addlogs(config, 'The log for this is stored at ' + path.join(config.oldPath, 'logs', 'import'), 'success')
|
|
119
|
+
}
|
|
120
|
+
return resolve()
|
|
121
|
+
} catch (error) {
|
|
122
|
+
addlogs(config, chalk.red('Failed to migrate stack: ' + config.target_stack + '. Please check error logs for more info'), 'error')
|
|
64
123
|
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++
|
|
124
|
+
addlogs(config, 'The log for this is stored at ' + path.join(config.oldPath, 'logs', 'import'), 'error')
|
|
125
|
+
return reject(error)
|
|
85
126
|
}
|
|
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
127
|
})
|
|
97
128
|
}
|
|
98
129
|
|
|
99
|
-
|
|
100
|
-
function createBackup (backupDirPath, config) {
|
|
130
|
+
function createBackup(backupDirPath, config) {
|
|
101
131
|
return new Promise((resolve, reject) => {
|
|
102
132
|
if (config.hasOwnProperty('useBackedupDir') && fs.existsSync(config.useBackedupDir)) {
|
|
103
133
|
return resolve(config.useBackedupDir)
|
|
@@ -119,4 +149,4 @@ function createBackup (backupDirPath, config) {
|
|
|
119
149
|
})
|
|
120
150
|
}
|
|
121
151
|
})
|
|
122
|
-
}
|
|
152
|
+
}
|
|
@@ -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,79 +13,109 @@ const {configWithMToken,
|
|
|
14
13
|
|
|
15
14
|
class ImportCommand extends Command {
|
|
16
15
|
async run() {
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
let targetStack =
|
|
21
|
-
const data =
|
|
22
|
-
const moduleName =
|
|
23
|
-
const
|
|
24
|
-
const
|
|
16
|
+
let self = this
|
|
17
|
+
const importCommandFlags = self.parse(ImportCommand).flags
|
|
18
|
+
const extConfig = importCommandFlags.config
|
|
19
|
+
let targetStack = importCommandFlags['stack-uid']
|
|
20
|
+
const data = importCommandFlags.data
|
|
21
|
+
const moduleName = importCommandFlags.module
|
|
22
|
+
const backupdir = importCommandFlags["backup-dir"]
|
|
23
|
+
const alias = importCommandFlags['management-token-alias']
|
|
24
|
+
const authToken = importCommandFlags['auth-token']
|
|
25
25
|
let _authToken = credStore.get('authtoken')
|
|
26
|
-
let
|
|
26
|
+
let branchName = importCommandFlags.branch
|
|
27
|
+
let host = self.cmaHost
|
|
28
|
+
|
|
29
|
+
return new Promise(function (resolve, reject) {
|
|
30
|
+
if (alias) {
|
|
31
|
+
let managementTokens = self.getToken(alias)
|
|
27
32
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
host.cma = cmaMainURL[1]
|
|
31
|
-
host.cda = cdaMainURL[1]
|
|
32
|
-
|
|
33
|
-
if (alias && alias !== undefined) {
|
|
34
|
-
let managementTokens = this.getToken(alias)
|
|
35
|
-
|
|
36
|
-
if (managementTokens && managementTokens !== undefined) {
|
|
37
|
-
if (extConfig && extConfig !== undefined) {
|
|
33
|
+
if (managementTokens) {
|
|
34
|
+
if (extConfig && _authToken) {
|
|
38
35
|
configWithMToken(
|
|
39
36
|
extConfig,
|
|
40
37
|
managementTokens,
|
|
41
38
|
moduleName,
|
|
42
|
-
host
|
|
39
|
+
host,
|
|
40
|
+
_authToken,
|
|
41
|
+
branchName,
|
|
42
|
+
backupdir
|
|
43
43
|
)
|
|
44
|
-
|
|
44
|
+
.then(() => {
|
|
45
|
+
return resolve()
|
|
46
|
+
})
|
|
47
|
+
} else if (data) {
|
|
45
48
|
parameterWithMToken(
|
|
46
|
-
masterLang,
|
|
47
49
|
managementTokens,
|
|
48
50
|
data,
|
|
49
51
|
moduleName,
|
|
50
|
-
host
|
|
52
|
+
host,
|
|
53
|
+
_authToken,
|
|
54
|
+
branchName,
|
|
55
|
+
backupdir
|
|
51
56
|
)
|
|
57
|
+
.then(() => {
|
|
58
|
+
return resolve()
|
|
59
|
+
})
|
|
52
60
|
} else {
|
|
53
61
|
withoutParameterMToken(
|
|
54
62
|
managementTokens,
|
|
55
63
|
moduleName,
|
|
56
|
-
host
|
|
64
|
+
host,
|
|
65
|
+
_authToken,
|
|
66
|
+
branchName,
|
|
67
|
+
backupdir
|
|
57
68
|
)
|
|
69
|
+
.then(() => {
|
|
70
|
+
return resolve()
|
|
71
|
+
})
|
|
58
72
|
}
|
|
59
73
|
} else {
|
|
60
|
-
|
|
74
|
+
console.log('management Token is not present please add managment token first')
|
|
61
75
|
}
|
|
62
|
-
} else if (authToken &&
|
|
63
|
-
if (extConfig
|
|
76
|
+
} else if (authToken && _authToken) {
|
|
77
|
+
if (extConfig) {
|
|
64
78
|
configWithAuthToken(
|
|
65
79
|
extConfig,
|
|
66
80
|
_authToken,
|
|
67
81
|
moduleName,
|
|
68
|
-
host
|
|
82
|
+
host,
|
|
83
|
+
branchName,
|
|
84
|
+
backupdir
|
|
69
85
|
)
|
|
70
|
-
|
|
86
|
+
.then(() => {
|
|
87
|
+
return resolve()
|
|
88
|
+
})
|
|
89
|
+
} else if (targetStack && data) {
|
|
71
90
|
parametersWithAuthToken(
|
|
72
|
-
masterLang,
|
|
73
91
|
_authToken,
|
|
74
92
|
targetStack,
|
|
75
93
|
data,
|
|
76
94
|
moduleName,
|
|
77
|
-
host
|
|
95
|
+
host,
|
|
96
|
+
backupdir,
|
|
97
|
+
branchName
|
|
78
98
|
)
|
|
99
|
+
.then(() => {
|
|
100
|
+
return resolve()
|
|
101
|
+
})
|
|
79
102
|
} else {
|
|
80
103
|
withoutParametersWithAuthToken(
|
|
81
104
|
_authToken,
|
|
82
105
|
moduleName,
|
|
83
|
-
host
|
|
106
|
+
host,
|
|
107
|
+
backupdir,
|
|
108
|
+
branchName
|
|
84
109
|
)
|
|
110
|
+
.then(() => {
|
|
111
|
+
return resolve()
|
|
112
|
+
})
|
|
85
113
|
}
|
|
86
114
|
} else {
|
|
87
|
-
|
|
115
|
+
console.log('Provide alias for managementToken or authtoken')
|
|
88
116
|
}
|
|
89
|
-
}
|
|
117
|
+
})
|
|
118
|
+
}
|
|
90
119
|
}
|
|
91
120
|
|
|
92
121
|
ImportCommand.description = `Import script for importing the content into new stack
|
|
@@ -95,21 +124,49 @@ Once you export content from the source stack, import it to your destination sta
|
|
|
95
124
|
`
|
|
96
125
|
ImportCommand.examples = [
|
|
97
126
|
`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 -
|
|
127
|
+
`csdx cm:import -A -s <stack_ApiKey> -d <path/of/export/destination/dir>`,
|
|
128
|
+
`csdx cm:import -A -c <path/of/config/dir>`,
|
|
129
|
+
`csdx cm:import -A -m <single module name>`,
|
|
130
|
+
`csdx cm:import -A -m <single module name> -b <backup dir>`,
|
|
131
|
+
`csdx cm:import -a <management_token_alias>`,
|
|
132
|
+
`csdx cm:import -a <management_token_alias> -d <path/of/export/destination/dir>`,
|
|
133
|
+
`csdx cm:import -a <management_token_alias> -c <path/of/config/file>`,
|
|
134
|
+
`csdx cm:import -A -m <single module name>`,
|
|
135
|
+
`csdx cm:import -A -B <branch name>`,
|
|
104
136
|
]
|
|
105
137
|
ImportCommand.flags = {
|
|
106
|
-
config: flags.string({
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
'
|
|
111
|
-
|
|
112
|
-
|
|
138
|
+
config: flags.string({
|
|
139
|
+
char: 'c',
|
|
140
|
+
description: '[optional] path of config file'
|
|
141
|
+
}),
|
|
142
|
+
'stack-uid': flags.string({
|
|
143
|
+
char: 's',
|
|
144
|
+
description: 'API key of the target stack'
|
|
145
|
+
}),
|
|
146
|
+
data: flags.string({
|
|
147
|
+
char: 'd',
|
|
148
|
+
description: 'path and location where data is stored'
|
|
149
|
+
}),
|
|
150
|
+
'management-token-alias': flags.string({
|
|
151
|
+
char: 'a',
|
|
152
|
+
description: 'alias of the management token'
|
|
153
|
+
}),
|
|
154
|
+
'auth-token': flags.boolean({
|
|
155
|
+
char: 'A',
|
|
156
|
+
description: 'to use auth token'
|
|
157
|
+
}),
|
|
158
|
+
module: flags.string({
|
|
159
|
+
char: 'm',
|
|
160
|
+
description: '[optional] specific module name'
|
|
161
|
+
}),
|
|
162
|
+
"backup-dir": flags.string({
|
|
163
|
+
char: 'b',
|
|
164
|
+
description: '[optional] backup directory name when using specific module'
|
|
165
|
+
}),
|
|
166
|
+
'branch': flags.string({
|
|
167
|
+
char: 'B',
|
|
168
|
+
description: '[optional] branch name'
|
|
169
|
+
})
|
|
113
170
|
}
|
|
114
171
|
|
|
115
|
-
module.exports = ImportCommand
|
|
172
|
+
module.exports = ImportCommand
|