@contentstack/cli-cm-export 0.1.1-beta.11 → 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 +2 -2
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
- package/src/app.js +2 -1
- package/src/lib/util/log.js +61 -22
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ $ npm install -g @contentstack/cli-cm-export
|
|
|
18
18
|
$ csdx COMMAND
|
|
19
19
|
running command...
|
|
20
20
|
$ csdx (-v|--version|version)
|
|
21
|
-
@contentstack/cli-cm-export/0.1.1-beta.
|
|
21
|
+
@contentstack/cli-cm-export/0.1.1-beta.12 linux-x64 node-v16.14.2
|
|
22
22
|
$ csdx --help [COMMAND]
|
|
23
23
|
USAGE
|
|
24
24
|
$ csdx COMMAND
|
|
@@ -68,5 +68,5 @@ EXAMPLES
|
|
|
68
68
|
csdx cm:export -A -B [optional] branch name
|
|
69
69
|
```
|
|
70
70
|
|
|
71
|
-
_See code: [src/commands/cm/export.js](https://github.com/contentstack/cli/blob/v0.1.1-beta.
|
|
71
|
+
_See code: [src/commands/cm/export.js](https://github.com/contentstack/cli/blob/v0.1.1-beta.12/packages/contentstack-export/src/commands/cm/export.js)_
|
|
72
72
|
<!-- commandsstop -->
|
package/oclif.manifest.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"0.1.1-beta.
|
|
1
|
+
{"version":"0.1.1-beta.12","commands":{"cm:export":{"id":"cm:export","description":"Export content from a stack\n...\nExport content from one stack to another\n","pluginName":"@contentstack/cli-cm-export","pluginType":"core","aliases":[],"examples":["csdx cm:export -A","csdx cm:export -A -s <stack_ApiKey> -d <path/of/export/destination/dir>","csdx cm:export -A -c <path/to/config/dir>","csdx cm:export -A -m <single module name>","csdx cm:export -A --secured-assets","csdx cm:export -a <management_token_alias>","csdx cm:export -a <management_token_alias> -d <path/to/export/destination/dir>","csdx cm:export -a <management_token_alias> -c <path/to/config/file>","csdx cm:export -A -m <single module name>","csdx cm:export -A -m <single module name> -t <content type>","csdx cm:export -A -B [optional] branch name"],"flags":{"config":{"name":"config","type":"option","char":"c","description":"[optional] path of the config"},"stack-uid":{"name":"stack-uid","type":"option","char":"s","description":"API key of the source stack"},"data":{"name":"data","type":"option","char":"d","description":"path or location to store the data"},"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"},"content-type":{"name":"content-type","type":"option","char":"t","description":"[optional] content type"},"branch":{"name":"branch","type":"option","char":"B","description":"[optional] branch name"},"secured-assets":{"name":"secured-assets","type":"boolean","description":"[optional] use when assets are secured","allowNo":false}},"args":[]}}}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentstack/cli-cm-export",
|
|
3
3
|
"description": "Contentstack CLI plugin to export content from 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": {
|
package/src/app.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable no-redeclare */
|
|
2
2
|
var util = require("./lib/util");
|
|
3
3
|
var login = require("./lib/util/login");
|
|
4
|
-
var { addlogs } = require("./lib/util/log");
|
|
4
|
+
var { addlogs, unlinkFileLogger } = require("./lib/util/log");
|
|
5
5
|
const setupBranches = require("./lib/util/setup-branches");
|
|
6
6
|
const chalk = require("chalk");
|
|
7
7
|
let path = require("path");
|
|
@@ -46,6 +46,7 @@ exports.initial = async function (config) {
|
|
|
46
46
|
console.log('failed export contents', error)
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
+
unlinkFileLogger()
|
|
49
50
|
resolve()
|
|
50
51
|
})
|
|
51
52
|
.catch((error) => {
|
package/src/lib/util/log.js
CHANGED
|
@@ -24,12 +24,11 @@ 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,
|
|
31
30
|
},
|
|
32
|
-
colors: {
|
|
31
|
+
colors: { //colors aren't being used anywhere as of now, we're using chalk to add colors while logging
|
|
33
32
|
info: 'blue',
|
|
34
33
|
debug: 'green',
|
|
35
34
|
warn: 'yellow',
|
|
@@ -37,26 +36,52 @@ 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
|
+
function init(_logPath) {
|
|
46
|
+
if (!logger || !errorLogger) {
|
|
47
|
+
var logsDir = path.resolve(_logPath, 'logs', 'export')
|
|
48
|
+
// Create dir if doesn't already exist
|
|
49
|
+
mkdirp.sync(logsDir)
|
|
55
50
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
51
|
+
successTransport = {
|
|
52
|
+
filename: path.join(logsDir, 'success.log'),
|
|
53
|
+
maxFiles: 20,
|
|
54
|
+
maxsize: 1000000,
|
|
55
|
+
tailable: true,
|
|
56
|
+
json: true,
|
|
57
|
+
level: 'info',
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
errorTransport = {
|
|
61
|
+
filename: path.join(logsDir, 'error.log'),
|
|
62
|
+
maxFiles: 20,
|
|
63
|
+
maxsize: 1000000,
|
|
64
|
+
tailable: true,
|
|
65
|
+
json: true,
|
|
66
|
+
level: 'error',
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
logger = new (winston.Logger)({
|
|
70
|
+
transports: [
|
|
71
|
+
new (winston.transports.File)(successTransport),
|
|
72
|
+
new (winston.transports.Console)()
|
|
73
|
+
],
|
|
74
|
+
levels: myCustomLevels.levels
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
errorLogger = new (winston.Logger)({
|
|
78
|
+
transports: [
|
|
79
|
+
new (winston.transports.File)(errorTransport),
|
|
80
|
+
new (winston.transports.Console)({ level: 'error' })
|
|
81
|
+
],
|
|
82
|
+
levels: { error: 0 }
|
|
83
|
+
})
|
|
84
|
+
}
|
|
60
85
|
|
|
61
86
|
return {
|
|
62
87
|
log: function () {
|
|
@@ -77,7 +102,7 @@ function init (_logPath, logfileName) {
|
|
|
77
102
|
var args = slice.call(arguments)
|
|
78
103
|
var logString = returnString(args)
|
|
79
104
|
if (logString) {
|
|
80
|
-
|
|
105
|
+
errorLogger.log('error', logString)
|
|
81
106
|
}
|
|
82
107
|
},
|
|
83
108
|
debug: function () {
|
|
@@ -91,9 +116,23 @@ function init (_logPath, logfileName) {
|
|
|
91
116
|
}
|
|
92
117
|
|
|
93
118
|
exports.addlogs = async (config, message, type) => {
|
|
119
|
+
// ignoring the type argument, as we are not using it to create a logfile anymore
|
|
94
120
|
if (type !== 'error') {
|
|
95
|
-
init
|
|
121
|
+
// removed type argument from init method
|
|
122
|
+
init(config.data).log(message)
|
|
96
123
|
} else {
|
|
97
|
-
init(config.data
|
|
124
|
+
init(config.data).error(message)
|
|
98
125
|
}
|
|
99
126
|
}
|
|
127
|
+
|
|
128
|
+
exports.unlinkFileLogger = () => {
|
|
129
|
+
if (logger) {
|
|
130
|
+
const fileLogger = logger.transports.file
|
|
131
|
+
logger.remove(fileLogger)
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (errorLogger) {
|
|
135
|
+
const fileLogger = errorLogger.transports.file
|
|
136
|
+
errorLogger.remove(fileLogger)
|
|
137
|
+
}
|
|
138
|
+
}
|