@contentstack/cli-cm-import 0.1.1-beta.14 → 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 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.14 linux-x64 node-v12.22.7
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.14/packages/contentstack-import/src/commands/cm/import.js)_
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 -->
@@ -1 +1 @@
1
- {"version":"0.1.1-beta.14","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":[]}}}
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,7 +1,7 @@
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.14",
4
+ "version": "0.1.1-beta.15",
5
5
  "author": "Contentstack",
6
6
  "bugs": "https://github.com/contentstack/cli/issues",
7
7
  "dependencies": {
@@ -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
- function init (_logPath, logfileName) {
41
- var logsDir = path.resolve(_logPath, 'logs', 'import')
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
- var transports = [new(winston.transports.File)({
47
- filename: logPath,
48
- maxFiles: 20,
49
- maxsize: 1000000,
50
- tailable: true,
51
- json: true
52
- })];
42
+ let successTransport
43
+ let errorTransport
53
44
 
54
- transports.push(new(winston.transports.Console)());
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
- var logger = new(winston.Logger)({
57
- transports: transports,
58
- levels: myCustomLevels.levels
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
- logger.log('error', logString);
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(configLogPath, type).log(message)
124
+ // removed type argument from init method
125
+ init(configLogPath).log(message)
98
126
  } else {
99
- init(configLogPath, type).error(message)
127
+ init(configLogPath).error(message)
100
128
  }
101
129
  }