@contentstack/cli-cm-clone 1.3.0 → 1.4.1
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
|
@@ -15,7 +15,7 @@ $ npm install -g @contentstack/cli-cm-clone
|
|
|
15
15
|
$ csdx COMMAND
|
|
16
16
|
running command...
|
|
17
17
|
$ csdx (--version)
|
|
18
|
-
@contentstack/cli-cm-clone/1.
|
|
18
|
+
@contentstack/cli-cm-clone/1.4.1 linux-x64 node-v16.20.0
|
|
19
19
|
$ csdx --help [COMMAND]
|
|
20
20
|
USAGE
|
|
21
21
|
$ csdx COMMAND
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentstack/cli-cm-clone",
|
|
3
3
|
"description": "Contentstack stack clone plugin",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.4.1",
|
|
5
5
|
"author": "Contentstack",
|
|
6
6
|
"bugs": "https://github.com/rohitmishra209/cli-cm-clone/issues",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@contentstack/cli-cm-export": "^1.
|
|
9
|
-
"@contentstack/cli-cm-import": "^1.
|
|
10
|
-
"@contentstack/cli-command": "^1.2.
|
|
11
|
-
"@contentstack/cli-utilities": "^1.
|
|
8
|
+
"@contentstack/cli-cm-export": "^1.5.1",
|
|
9
|
+
"@contentstack/cli-cm-import": "^1.5.1",
|
|
10
|
+
"@contentstack/cli-command": "^1.2.2",
|
|
11
|
+
"@contentstack/cli-utilities": "^1.3.1",
|
|
12
12
|
"@contentstack/management": "^1.6.1",
|
|
13
13
|
"async": "^3.2.4",
|
|
14
14
|
"chalk": "^4.1.0",
|
|
@@ -63,6 +63,10 @@
|
|
|
63
63
|
"csdxConfig": {
|
|
64
64
|
"expiredCommands": {
|
|
65
65
|
"cm:stack-clone": "csdx cm:stacks:clone"
|
|
66
|
+
},
|
|
67
|
+
"shortCommandName": {
|
|
68
|
+
"cm:stacks:clone": "CLN",
|
|
69
|
+
"cm:stack-clone": "O-CLN"
|
|
66
70
|
}
|
|
67
71
|
}
|
|
68
72
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const { Command } = require('@contentstack/cli-command');
|
|
2
|
-
const { configHandler, flags } = require('@contentstack/cli-utilities');
|
|
2
|
+
const { configHandler, flags, isAuthenticated, managementSDKClient } = require('@contentstack/cli-utilities');
|
|
3
3
|
const { CloneHandler } = require('../../../lib/util/clone-handler');
|
|
4
4
|
let config = require('../../../lib/util/dummyConfig.json');
|
|
5
5
|
const path = require('path');
|
|
@@ -11,7 +11,6 @@ class StackCloneCommand extends Command {
|
|
|
11
11
|
async run() {
|
|
12
12
|
try {
|
|
13
13
|
let self = this;
|
|
14
|
-
let _authToken = configHandler.get('authtoken');
|
|
15
14
|
const { flags: cloneCommandFlags } = await self.parse(StackCloneCommand);
|
|
16
15
|
const {
|
|
17
16
|
yes,
|
|
@@ -70,17 +69,19 @@ class StackCloneCommand extends Command {
|
|
|
70
69
|
await this.removeContentDirIfNotEmptyBeforeClone(pathdir); // NOTE remove if folder not empty before clone
|
|
71
70
|
this.registerCleanupOnInterrupt(pathdir);
|
|
72
71
|
|
|
73
|
-
config.auth_token =
|
|
72
|
+
config.auth_token = configHandler.get('authtoken');
|
|
74
73
|
config.host = this.cmaHost;
|
|
75
74
|
config.cdn = this.cdaHost;
|
|
76
75
|
config.pathDir = pathdir;
|
|
77
76
|
const cloneHandler = new CloneHandler(config);
|
|
77
|
+
const managementAPIClient = await managementSDKClient(config);
|
|
78
|
+
cloneHandler.setClient(managementAPIClient);
|
|
78
79
|
cloneHandler.execute().catch();
|
|
79
80
|
};
|
|
80
81
|
|
|
81
82
|
if (sourceManagementTokenAlias && destinationManagementTokenAlias) {
|
|
82
83
|
if (sourceStackBranch || targetStackBranch) {
|
|
83
|
-
if (
|
|
84
|
+
if (isAuthenticated()) {
|
|
84
85
|
handleClone();
|
|
85
86
|
} else {
|
|
86
87
|
console.log('Please login to execute this command, csdx auth:login');
|
|
@@ -89,7 +90,7 @@ class StackCloneCommand extends Command {
|
|
|
89
90
|
} else {
|
|
90
91
|
handleClone();
|
|
91
92
|
}
|
|
92
|
-
} else if (
|
|
93
|
+
} else if (isAuthenticated()) {
|
|
93
94
|
handleClone();
|
|
94
95
|
} else {
|
|
95
96
|
console.log('Please login to execute this command, csdx auth:login');
|
|
@@ -6,7 +6,6 @@ const chalk = require('chalk');
|
|
|
6
6
|
|
|
7
7
|
let exportCmd = require('@contentstack/cli-cm-export');
|
|
8
8
|
let importCmd = require('@contentstack/cli-cm-import');
|
|
9
|
-
let sdkInstance = require('../../lib/util/contentstack-management-sdk');
|
|
10
9
|
const { CustomAbortController } = require('./abort-controller');
|
|
11
10
|
|
|
12
11
|
const {
|
|
@@ -61,11 +60,13 @@ let master_locale;
|
|
|
61
60
|
class CloneHandler {
|
|
62
61
|
constructor(opt) {
|
|
63
62
|
config = opt;
|
|
64
|
-
client = sdkInstance.Client(config);
|
|
65
63
|
cloneCommand = new Clone();
|
|
66
64
|
this.pathDir = opt.pathDir;
|
|
67
65
|
process.stdin.setMaxListeners(50);
|
|
68
66
|
}
|
|
67
|
+
setClient(managementSDKClient) {
|
|
68
|
+
client = managementSDKClient;
|
|
69
|
+
}
|
|
69
70
|
|
|
70
71
|
handleOrgSelection(options = {}) {
|
|
71
72
|
return new Promise(async (resolve, reject) => {
|
|
@@ -498,6 +499,11 @@ class CloneHandler {
|
|
|
498
499
|
async cmdExport() {
|
|
499
500
|
return new Promise((resolve, reject) => {
|
|
500
501
|
const cmd = ['-k', config.source_stack, '-d', __dirname.split('src')[0] + 'contents'];
|
|
502
|
+
if (config.cloneType === 'a') {
|
|
503
|
+
config.filteredModules = ['stack'].concat(structureList);
|
|
504
|
+
cmd.push('-c');
|
|
505
|
+
cmd.push(path.join(__dirname, 'dummyConfig.json'));
|
|
506
|
+
}
|
|
501
507
|
|
|
502
508
|
if (config.source_alias) {
|
|
503
509
|
cmd.push('-a', config.source_alias);
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
const contentstacksdk = require('@contentstack/management');
|
|
2
|
-
|
|
3
|
-
exports.Client = function (config) {
|
|
4
|
-
const option = {
|
|
5
|
-
host: config.host,
|
|
6
|
-
authtoken: config.auth_token,
|
|
7
|
-
maxContentLength: 100000000,
|
|
8
|
-
maxBodyLength: 1000000000,
|
|
9
|
-
logHandler: (_level, _data) => {
|
|
10
|
-
// empty log handler
|
|
11
|
-
},
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
if (config.target_stack) {
|
|
15
|
-
option.api_key = config.target_stack;
|
|
16
|
-
}
|
|
17
|
-
if (config.source_stack) {
|
|
18
|
-
option.api_key = config.source_stack;
|
|
19
|
-
}
|
|
20
|
-
return contentstacksdk.client(option);
|
|
21
|
-
};
|