@contentstack/cli-cm-import 1.5.9 → 1.5.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 +1 -1
- package/oclif.manifest.json +1 -1
- package/package.json +2 -2
- package/src/app.js +19 -8
- package/src/lib/util/removeReferenceFields.js +2 -2
package/README.md
CHANGED
|
@@ -47,7 +47,7 @@ $ npm install -g @contentstack/cli-cm-import
|
|
|
47
47
|
$ csdx COMMAND
|
|
48
48
|
running command...
|
|
49
49
|
$ csdx (--version)
|
|
50
|
-
@contentstack/cli-cm-import/1.5.
|
|
50
|
+
@contentstack/cli-cm-import/1.5.10 linux-x64 node-v16.20.1
|
|
51
51
|
$ csdx --help [COMMAND]
|
|
52
52
|
USAGE
|
|
53
53
|
$ csdx COMMAND
|
package/oclif.manifest.json
CHANGED
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": "1.5.
|
|
4
|
+
"version": "1.5.10",
|
|
5
5
|
"author": "Contentstack",
|
|
6
6
|
"bugs": "https://github.com/contentstack/cli/issues",
|
|
7
7
|
"dependencies": {
|
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
"bluebird": "^3.7.2",
|
|
13
13
|
"chalk": "^4.1.2",
|
|
14
14
|
"debug": "^4.1.0",
|
|
15
|
+
"fs-extra": "^11.1.1",
|
|
15
16
|
"lodash": "^4.17.20",
|
|
16
17
|
"marked": "^4.0.17",
|
|
17
18
|
"mkdirp": "^1.0.4",
|
|
18
|
-
"ncp": "^2.0.0",
|
|
19
19
|
"promise-limit": "^2.7.0",
|
|
20
20
|
"winston": "^3.7.2"
|
|
21
21
|
},
|
package/src/app.js
CHANGED
|
@@ -5,13 +5,15 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
const fs = require('fs');
|
|
8
|
-
const
|
|
8
|
+
const os = require('os');
|
|
9
9
|
const path = require('path');
|
|
10
10
|
const chalk = require('chalk');
|
|
11
|
+
const { copy, copySync, removeSync } = require('fs-extra');
|
|
11
12
|
const util = require('./lib/util/index');
|
|
12
13
|
const login = require('./lib/util/login');
|
|
13
14
|
const { addlogs } = require('./lib/util/log');
|
|
14
15
|
const { managementSDKClient, isAuthenticated } = require('@contentstack/cli-utilities');
|
|
16
|
+
const { camelCase } = require('lodash')
|
|
15
17
|
|
|
16
18
|
exports.initial = (configData) => {
|
|
17
19
|
return new Promise(async (resolve, reject) => {
|
|
@@ -161,21 +163,30 @@ const createBackup = (backupDirPath, config) => {
|
|
|
161
163
|
if (config.hasOwnProperty('useBackedupDir') && fs.existsSync(config.useBackedupDir)) {
|
|
162
164
|
return resolve(config.useBackedupDir);
|
|
163
165
|
}
|
|
164
|
-
|
|
166
|
+
|
|
165
167
|
if (path.isAbsolute(config.data)) {
|
|
166
|
-
|
|
168
|
+
copy(config.data, backupDirPath, (error) => {
|
|
167
169
|
if (error) {
|
|
168
170
|
return reject(error);
|
|
169
171
|
}
|
|
170
172
|
return resolve(backupDirPath);
|
|
171
173
|
});
|
|
172
174
|
} else {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
175
|
+
//handle mac error :- Cannot copy to a subdirectory of itself
|
|
176
|
+
if (config.data === "." || config.data === "./") {
|
|
177
|
+
const tempDestination = `${os.platform() === 'darwin' ? '/private/tmp' : '/tmp'}/${camelCase(backupDirPath)}`;
|
|
178
|
+
copySync(config.data, tempDestination);
|
|
179
|
+
copySync(tempDestination, backupDirPath);
|
|
180
|
+
removeSync(tempDestination);
|
|
177
181
|
return resolve(backupDirPath);
|
|
178
|
-
}
|
|
182
|
+
} else {
|
|
183
|
+
copy(config.data, backupDirPath,(error) => {
|
|
184
|
+
if (error) {
|
|
185
|
+
return reject(error);
|
|
186
|
+
}
|
|
187
|
+
return resolve(backupDirPath);
|
|
188
|
+
});
|
|
189
|
+
}
|
|
179
190
|
}
|
|
180
191
|
});
|
|
181
192
|
};
|
|
@@ -4,12 +4,12 @@ const _ = require('lodash');
|
|
|
4
4
|
const removeReferenceFields = (module.exports = async function (schema, flag, stackAPIClient) {
|
|
5
5
|
for (let i = 0; i < schema.length; i++) {
|
|
6
6
|
if (schema[i].data_type === 'group') {
|
|
7
|
-
|
|
7
|
+
removeReferenceFields(schema[i].schema, flag);
|
|
8
8
|
} else if (schema[i].data_type === 'blocks') {
|
|
9
9
|
for (var block in schema[i].blocks) {
|
|
10
10
|
removeReferenceFields(schema[i].blocks[block].schema, flag);
|
|
11
11
|
}
|
|
12
|
-
} else if (schema[i].data_type === 'reference') {
|
|
12
|
+
} else if (schema[i].data_type === 'reference' || schema[i].reference_to ) {
|
|
13
13
|
flag.supressed = true;
|
|
14
14
|
// Check if content-type exists
|
|
15
15
|
// If exists, then no change should be required.
|