@contentstack/cli-cm-seed 1.4.11 → 1.4.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.
|
@@ -31,6 +31,11 @@ class SeedCommand extends cli_command_1.Command {
|
|
|
31
31
|
}
|
|
32
32
|
catch (error) {
|
|
33
33
|
let errorObj = error;
|
|
34
|
+
if (errorObj.message !== undefined) {
|
|
35
|
+
cli_utilities_1.cliux.loader();
|
|
36
|
+
cli_utilities_1.cliux.print(`Error: ${errorObj.message}`, { color: 'red' });
|
|
37
|
+
this.exit(1);
|
|
38
|
+
}
|
|
34
39
|
this.error(errorObj, { exit: 1, suggestions: errorObj.suggestions });
|
|
35
40
|
}
|
|
36
41
|
}
|
|
@@ -23,6 +23,7 @@ export default class ContentstackClient {
|
|
|
23
23
|
constructor(cmaHost: string, limit: number);
|
|
24
24
|
getOrganization(org_uid: string): Promise<Organization>;
|
|
25
25
|
getOrganizations(skip?: number, organizations?: Organization[]): Promise<Organization[]>;
|
|
26
|
+
private mapOrganization;
|
|
26
27
|
getStack(stackUID: string): Promise<Stack>;
|
|
27
28
|
getStacks(org_uid: string, skip?: number, stacks?: Stack[]): Promise<Stack[]>;
|
|
28
29
|
getContentTypeCount(api_key: string): Promise<number>;
|
|
@@ -24,16 +24,20 @@ class ContentstackClient {
|
|
|
24
24
|
async getOrganizations(skip = 0, organizations = []) {
|
|
25
25
|
try {
|
|
26
26
|
const client = await this.instance;
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
27
|
+
const configOrgUid = cli_utilities_1.configHandler.get('oauthOrgUid');
|
|
28
|
+
if (configOrgUid) {
|
|
29
|
+
const response = await client.organization(configOrgUid).fetch();
|
|
30
|
+
const mappedOrganization = this.mapOrganization(response);
|
|
31
|
+
organizations.push(mappedOrganization);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
const response = await client
|
|
35
|
+
.organization()
|
|
36
|
+
.fetchAll({ limit: this.limit, asc: 'name', include_count: true, skip });
|
|
37
|
+
organizations.push(...response.items.map(this.mapOrganization));
|
|
38
|
+
if (organizations.length < response.count) {
|
|
39
|
+
organizations = await this.getOrganizations(skip + this.limit, organizations);
|
|
40
|
+
}
|
|
37
41
|
}
|
|
38
42
|
return organizations;
|
|
39
43
|
}
|
|
@@ -41,6 +45,13 @@ class ContentstackClient {
|
|
|
41
45
|
throw this.buildError(error);
|
|
42
46
|
}
|
|
43
47
|
}
|
|
48
|
+
mapOrganization(o) {
|
|
49
|
+
return {
|
|
50
|
+
uid: o.uid,
|
|
51
|
+
name: o.name,
|
|
52
|
+
enabled: o.enabled,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
44
55
|
async getStack(stackUID) {
|
|
45
56
|
try {
|
|
46
57
|
const client = await this.instance;
|
|
@@ -66,7 +77,7 @@ class ContentstackClient {
|
|
|
66
77
|
limit: this.limit,
|
|
67
78
|
include_count: true,
|
|
68
79
|
skip: skip,
|
|
69
|
-
query: {}
|
|
80
|
+
query: {},
|
|
70
81
|
})
|
|
71
82
|
.find();
|
|
72
83
|
stacks = stacks.concat(response.items.map((s) => {
|
|
@@ -122,8 +133,8 @@ class ContentstackClient {
|
|
|
122
133
|
}
|
|
123
134
|
buildError(error) {
|
|
124
135
|
var _a;
|
|
125
|
-
const message = ((_a = error.response.data) === null || _a === void 0 ? void 0 : _a.
|
|
126
|
-
const status = error.
|
|
136
|
+
const message = error.errorMessage || ((_a = error.response.data) === null || _a === void 0 ? void 0 : _a.errorMessage) || error.response.statusText;
|
|
137
|
+
const status = error.status;
|
|
127
138
|
return new error_1.default(message, status);
|
|
128
139
|
}
|
|
129
140
|
}
|
package/lib/seed/importer.js
CHANGED
|
@@ -3,12 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.run = void 0;
|
|
4
4
|
const process = require("process");
|
|
5
5
|
const path = require("path");
|
|
6
|
+
const cli_cm_import_1 = require("@contentstack/cli-cm-import");
|
|
6
7
|
const STACK_FOLDER = 'stack';
|
|
7
8
|
async function run(options) {
|
|
8
9
|
const importPath = path.resolve(options.tmpPath, STACK_FOLDER);
|
|
9
10
|
process.chdir(options.tmpPath);
|
|
10
|
-
|
|
11
|
-
const { parametersWithAuthToken } = require('@contentstack/cli-cm-import/src/lib/util/import-flags');
|
|
12
|
-
await parametersWithAuthToken(options.api_key, importPath, '', options.cmaHost, '', {});
|
|
11
|
+
await cli_cm_import_1.default.run(['-k', options.api_key, '-d', importPath]);
|
|
13
12
|
}
|
|
14
13
|
exports.run = run;
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentstack/cli-cm-seed",
|
|
3
3
|
"description": "create a Stack from existing content types, entries, assets, etc.",
|
|
4
|
-
"version": "1.4.
|
|
4
|
+
"version": "1.4.12",
|
|
5
5
|
"author": "Contentstack",
|
|
6
6
|
"bugs": "https://github.com/contentstack/cli/issues",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@contentstack/cli-cm-import": "^1.
|
|
9
|
-
"@contentstack/cli-command": "^1.2.
|
|
10
|
-
"@contentstack/cli-utilities": "^1.
|
|
8
|
+
"@contentstack/cli-cm-import": "^1.6.0",
|
|
9
|
+
"@contentstack/cli-command": "^1.2.10",
|
|
10
|
+
"@contentstack/cli-utilities": "^1.5.0",
|
|
11
11
|
"axios": "1.3.4",
|
|
12
12
|
"inquirer": "8.2.4",
|
|
13
13
|
"mkdirp": "^1.0.4",
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
"/npm-shrinkwrap.json",
|
|
42
42
|
"/oclif.manifest.json"
|
|
43
43
|
],
|
|
44
|
+
"types": "./types/index.d.ts",
|
|
44
45
|
"homepage": "https://github.com/contentstack/cli",
|
|
45
46
|
"keywords": [
|
|
46
47
|
"contentstack",
|
|
@@ -72,4 +73,4 @@
|
|
|
72
73
|
"version": "oclif readme && git add README.md",
|
|
73
74
|
"clean": "rm -rf ./node_modules tsconfig.build.tsbuildinfo"
|
|
74
75
|
}
|
|
75
|
-
}
|
|
76
|
+
}
|