@contentstack/cli-cm-import 0.1.1-beta.12 → 0.1.1-beta.15
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 +2 -2
- package/oclif.manifest.json +1 -1
- package/package.json +3 -3
- package/src/lib/import/workflows.js +6 -1
- package/src/lib/util/extensionsUidReplace.js +9 -0
- package/src/lib/util/log.js +49 -21
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.15 linux-x64 node-v16.14.2
|
|
20
20
|
$ csdx --help [COMMAND]
|
|
21
21
|
USAGE
|
|
22
22
|
$ csdx COMMAND
|
|
@@ -62,5 +62,5 @@ EXAMPLES
|
|
|
62
62
|
csdx cm:import -A -B <branch name>
|
|
63
63
|
```
|
|
64
64
|
|
|
65
|
-
_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.15/packages/contentstack-import/src/commands/cm/import.js)_
|
|
66
66
|
<!-- commandsstop -->
|
package/oclif.manifest.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"0.1.1-beta.
|
|
1
|
+
{"version":"0.1.1-beta.15","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,12 +1,12 @@
|
|
|
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.15",
|
|
5
5
|
"author": "Contentstack",
|
|
6
6
|
"bugs": "https://github.com/contentstack/cli/issues",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@contentstack/cli-command": "0.1.
|
|
9
|
-
"@contentstack/management": "
|
|
8
|
+
"@contentstack/cli-command": "0.1.1-beta.6",
|
|
9
|
+
"@contentstack/management": "^1.3.0",
|
|
10
10
|
"@oclif/command": "^1.6.1",
|
|
11
11
|
"@oclif/config": "^1.15.1",
|
|
12
12
|
"axios": "^0.21.1",
|
|
@@ -74,8 +74,13 @@ importWorkflows.prototype = {
|
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
+
if(workflow.admin_users !== undefined) {
|
|
78
|
+
addlogs(config, chalk.yellow('We are skipping import of `Workflow superuser(s)` from workflow'), 'info');
|
|
79
|
+
delete workflow.admin_users;
|
|
80
|
+
}
|
|
81
|
+
|
|
77
82
|
let requestOption = {
|
|
78
|
-
workflow
|
|
83
|
+
workflow
|
|
79
84
|
};
|
|
80
85
|
|
|
81
86
|
return client.stack({ api_key: config.target_stack, management_token: config.management_token }).workflow().create(requestOption)
|
|
@@ -45,6 +45,15 @@ var extension_uid_Replace = module.exports = function (schema, preserveStackVers
|
|
|
45
45
|
// eslint-disable-next-line camelcase
|
|
46
46
|
schema[i].extension_uid = data[extension_key_value]
|
|
47
47
|
}
|
|
48
|
+
} else if (schema[i].data_type === 'json' && schema[i].hasOwnProperty('plugins') && schema[i].plugins.length > 0) {
|
|
49
|
+
const newPluginUidsArray = [];
|
|
50
|
+
const data = helper.readFile(path.join(extensionPath));
|
|
51
|
+
schema[i].plugins.forEach((extension_key_value) => {
|
|
52
|
+
if (data && data.hasOwnProperty(extension_key_value)) {
|
|
53
|
+
newPluginUidsArray.push(data[extension_key_value]);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
schema[i].plugins = newPluginUidsArray;
|
|
48
57
|
}
|
|
49
58
|
}
|
|
50
59
|
}
|
package/src/lib/util/log.js
CHANGED
|
@@ -24,7 +24,6 @@ function returnString (args) {
|
|
|
24
24
|
|
|
25
25
|
var myCustomLevels = {
|
|
26
26
|
levels: {
|
|
27
|
-
error: 0,
|
|
28
27
|
warn: 1,
|
|
29
28
|
info: 2,
|
|
30
29
|
debug: 3
|
|
@@ -37,26 +36,53 @@ var myCustomLevels = {
|
|
|
37
36
|
}
|
|
38
37
|
};
|
|
39
38
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
// Create dir if doesn't already exist
|
|
43
|
-
mkdirp.sync(logsDir)
|
|
44
|
-
var logPath = path.join(logsDir, logfileName + '.log');
|
|
39
|
+
let logger
|
|
40
|
+
let errorLogger
|
|
45
41
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
maxFiles: 20,
|
|
49
|
-
maxsize: 1000000,
|
|
50
|
-
tailable: true,
|
|
51
|
-
json: true
|
|
52
|
-
})];
|
|
42
|
+
let successTransport
|
|
43
|
+
let errorTransport
|
|
53
44
|
|
|
54
|
-
|
|
45
|
+
// removed logfileName from arguments
|
|
46
|
+
function init(_logPath) {
|
|
47
|
+
if (!logger || !errorLogger) {
|
|
48
|
+
var logsDir = path.resolve(_logPath, 'logs', 'import')
|
|
49
|
+
// Create dir if doesn't already exist
|
|
50
|
+
mkdirp.sync(logsDir)
|
|
55
51
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
52
|
+
successTransport = {
|
|
53
|
+
filename: path.join(logsDir, 'success.log'),
|
|
54
|
+
maxFiles: 20,
|
|
55
|
+
maxsize: 1000000,
|
|
56
|
+
tailable: true,
|
|
57
|
+
json: true,
|
|
58
|
+
level: 'info',
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
errorTransport = {
|
|
62
|
+
filename: path.join(logsDir, 'error.log'),
|
|
63
|
+
maxFiles: 20,
|
|
64
|
+
maxsize: 1000000,
|
|
65
|
+
tailable: true,
|
|
66
|
+
json: true,
|
|
67
|
+
level: 'error',
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
logger = new (winston.Logger)({
|
|
71
|
+
transports: [
|
|
72
|
+
new (winston.transports.File)(successTransport),
|
|
73
|
+
new (winston.transports.Console)()
|
|
74
|
+
],
|
|
75
|
+
levels: myCustomLevels.levels,
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
errorLogger = new (winston.Logger)({
|
|
79
|
+
transports: [
|
|
80
|
+
new (winston.transports.File)(errorTransport),
|
|
81
|
+
new (winston.transports.Console)({level: 'error'})
|
|
82
|
+
],
|
|
83
|
+
levels: { error: 0 }
|
|
84
|
+
})
|
|
85
|
+
}
|
|
60
86
|
|
|
61
87
|
return {
|
|
62
88
|
log: function () {
|
|
@@ -77,7 +103,7 @@ function init (_logPath, logfileName) {
|
|
|
77
103
|
var args = slice.call(arguments);
|
|
78
104
|
var logString = returnString(args);
|
|
79
105
|
if (logString) {
|
|
80
|
-
|
|
106
|
+
errorLogger.log('error', logString);
|
|
81
107
|
}
|
|
82
108
|
},
|
|
83
109
|
debug: function () {
|
|
@@ -93,9 +119,11 @@ function init (_logPath, logfileName) {
|
|
|
93
119
|
exports.addlogs = async (config, message, type) => {
|
|
94
120
|
var configLogPath
|
|
95
121
|
config.source_stack && config.target_stack ? configLogPath = config.data : configLogPath = config.oldPath
|
|
122
|
+
// ignoring the type argument, as we are not using it to create a logfile anymore
|
|
96
123
|
if (type !== 'error') {
|
|
97
|
-
init
|
|
124
|
+
// removed type argument from init method
|
|
125
|
+
init(configLogPath).log(message)
|
|
98
126
|
} else {
|
|
99
|
-
init(configLogPath
|
|
127
|
+
init(configLogPath).error(message)
|
|
100
128
|
}
|
|
101
129
|
}
|