@contentstack/cli-cm-export 1.24.2 → 1.25.0
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/lib/config/index.js +6 -0
- package/lib/export/modules/publishing-rules.d.ts +11 -0
- package/lib/export/modules/publishing-rules.js +64 -0
- package/lib/types/default-config.d.ts +7 -0
- package/lib/types/index.d.ts +8 -1
- package/oclif.manifest.json +1 -1
- package/package.json +5 -6
package/README.md
CHANGED
|
@@ -48,7 +48,7 @@ $ npm install -g @contentstack/cli-cm-export
|
|
|
48
48
|
$ csdx COMMAND
|
|
49
49
|
running command...
|
|
50
50
|
$ csdx (--version)
|
|
51
|
-
@contentstack/cli-cm-export/1.
|
|
51
|
+
@contentstack/cli-cm-export/1.25.0 linux-x64 node-v22.22.2
|
|
52
52
|
$ csdx --help [COMMAND]
|
|
53
53
|
USAGE
|
|
54
54
|
$ csdx COMMAND
|
package/lib/config/index.js
CHANGED
|
@@ -36,6 +36,7 @@ const config = {
|
|
|
36
36
|
'content-types',
|
|
37
37
|
'custom-roles',
|
|
38
38
|
'workflows',
|
|
39
|
+
'publishing-rules',
|
|
39
40
|
'personalize',
|
|
40
41
|
'entries',
|
|
41
42
|
'labels',
|
|
@@ -86,6 +87,11 @@ const config = {
|
|
|
86
87
|
fileName: 'workflows.json',
|
|
87
88
|
invalidKeys: ['stackHeaders', 'urlPath', 'created_at', 'updated_at', 'created_by', 'updated_by'],
|
|
88
89
|
},
|
|
90
|
+
'publishing-rules': {
|
|
91
|
+
dirName: 'workflows',
|
|
92
|
+
fileName: 'publishing-rules.json',
|
|
93
|
+
invalidKeys: ['stackHeaders', 'urlPath', 'created_at', 'updated_at', 'created_by', 'updated_by'],
|
|
94
|
+
},
|
|
89
95
|
globalfields: {
|
|
90
96
|
dirName: 'global_fields',
|
|
91
97
|
fileName: 'globalfields.json',
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import BaseClass from './base-class';
|
|
2
|
+
import { ModuleClassParams } from '../../types';
|
|
3
|
+
export default class ExportPublishingRules extends BaseClass {
|
|
4
|
+
private readonly publishingRules;
|
|
5
|
+
private readonly publishingRulesConfig;
|
|
6
|
+
private publishingRulesFolderPath;
|
|
7
|
+
private readonly qs;
|
|
8
|
+
constructor({ exportConfig, stackAPIClient }: ModuleClassParams);
|
|
9
|
+
start(): Promise<void>;
|
|
10
|
+
private fetchAllPublishingRules;
|
|
11
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const omit_1 = tslib_1.__importDefault(require("lodash/omit"));
|
|
5
|
+
const isEmpty_1 = tslib_1.__importDefault(require("lodash/isEmpty"));
|
|
6
|
+
const node_path_1 = require("node:path");
|
|
7
|
+
const cli_utilities_1 = require("@contentstack/cli-utilities");
|
|
8
|
+
const base_class_1 = tslib_1.__importDefault(require("./base-class"));
|
|
9
|
+
const utils_1 = require("../../utils");
|
|
10
|
+
class ExportPublishingRules extends base_class_1.default {
|
|
11
|
+
constructor({ exportConfig, stackAPIClient }) {
|
|
12
|
+
super({ exportConfig, stackAPIClient });
|
|
13
|
+
this.publishingRules = {};
|
|
14
|
+
this.publishingRulesConfig = exportConfig.modules['publishing-rules'];
|
|
15
|
+
this.qs = { include_count: true };
|
|
16
|
+
this.exportConfig.context.module = 'publishing-rules';
|
|
17
|
+
}
|
|
18
|
+
async start() {
|
|
19
|
+
this.publishingRulesFolderPath = (0, node_path_1.resolve)(this.exportConfig.data, this.exportConfig.branchName || '', this.publishingRulesConfig.dirName);
|
|
20
|
+
cli_utilities_1.log.debug(`Publishing rules folder path: ${this.publishingRulesFolderPath}`, this.exportConfig.context);
|
|
21
|
+
await utils_1.fsUtil.makeDirectory(this.publishingRulesFolderPath);
|
|
22
|
+
cli_utilities_1.log.debug('Created publishing rules directory', this.exportConfig.context);
|
|
23
|
+
await this.fetchAllPublishingRules();
|
|
24
|
+
if ((0, isEmpty_1.default)(this.publishingRules)) {
|
|
25
|
+
cli_utilities_1.log.info('No Publishing Rules found', this.exportConfig.context);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const outPath = (0, node_path_1.resolve)(this.publishingRulesFolderPath, this.publishingRulesConfig.fileName);
|
|
29
|
+
utils_1.fsUtil.writeFile(outPath, this.publishingRules);
|
|
30
|
+
cli_utilities_1.log.success(`Publishing rules exported successfully! Total count: ${Object.keys(this.publishingRules).length}`, this.exportConfig.context);
|
|
31
|
+
}
|
|
32
|
+
async fetchAllPublishingRules(skip = 0) {
|
|
33
|
+
var _a, _b;
|
|
34
|
+
try {
|
|
35
|
+
if (skip > 0) {
|
|
36
|
+
this.qs.skip = skip;
|
|
37
|
+
}
|
|
38
|
+
const data = await this.stack
|
|
39
|
+
.workflow()
|
|
40
|
+
.publishRule()
|
|
41
|
+
.fetchAll(this.qs);
|
|
42
|
+
const items = (_a = data.items) !== null && _a !== void 0 ? _a : [];
|
|
43
|
+
const total = (_b = data.count) !== null && _b !== void 0 ? _b : items.length;
|
|
44
|
+
if (!items.length) {
|
|
45
|
+
cli_utilities_1.log.debug('No publishing rules returned for this page', this.exportConfig.context);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
for (const rule of items) {
|
|
49
|
+
const uid = rule.uid;
|
|
50
|
+
if (uid) {
|
|
51
|
+
this.publishingRules[uid] = (0, omit_1.default)(rule, this.publishingRulesConfig.invalidKeys);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
const nextSkip = skip + items.length;
|
|
55
|
+
if (nextSkip < total) {
|
|
56
|
+
await this.fetchAllPublishingRules(nextSkip);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
(0, cli_utilities_1.handleAndLogError)(error, Object.assign({}, this.exportConfig.context));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.default = ExportPublishingRules;
|
|
@@ -57,6 +57,13 @@ export default interface DefaultConfig {
|
|
|
57
57
|
invalidKeys: string[];
|
|
58
58
|
dependencies?: Modules[];
|
|
59
59
|
};
|
|
60
|
+
'publishing-rules': {
|
|
61
|
+
dirName: string;
|
|
62
|
+
fileName: string;
|
|
63
|
+
invalidKeys: string[];
|
|
64
|
+
dependencies?: Modules[];
|
|
65
|
+
limit?: number;
|
|
66
|
+
};
|
|
60
67
|
globalfields: {
|
|
61
68
|
dirName: string;
|
|
62
69
|
fileName: string;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ export interface Region {
|
|
|
26
26
|
cda: string;
|
|
27
27
|
uiHost: string;
|
|
28
28
|
}
|
|
29
|
-
export type Modules = 'stack' | 'assets' | 'locales' | 'environments' | 'extensions' | 'webhooks' | 'global-fields' | 'entries' | 'content-types' | 'custom-roles' | 'workflows' | 'labels' | 'marketplace-apps' | 'taxonomies' | 'personalize' | 'composable-studio';
|
|
29
|
+
export type Modules = 'stack' | 'assets' | 'locales' | 'environments' | 'extensions' | 'webhooks' | 'global-fields' | 'entries' | 'content-types' | 'custom-roles' | 'workflows' | 'publishing-rules' | 'labels' | 'marketplace-apps' | 'taxonomies' | 'personalize' | 'composable-studio';
|
|
30
30
|
export type ModuleClassParams = {
|
|
31
31
|
stackAPIClient: ReturnType<ContentstackClient['stack']>;
|
|
32
32
|
exportConfig: ExportConfig;
|
|
@@ -84,6 +84,13 @@ export interface WorkflowConfig {
|
|
|
84
84
|
dependencies?: Modules[];
|
|
85
85
|
limit?: number;
|
|
86
86
|
}
|
|
87
|
+
export interface PublishingRulesConfig {
|
|
88
|
+
dirName: string;
|
|
89
|
+
fileName: string;
|
|
90
|
+
invalidKeys: string[];
|
|
91
|
+
dependencies?: Modules[];
|
|
92
|
+
limit?: number;
|
|
93
|
+
}
|
|
87
94
|
export interface CustomRoleConfig {
|
|
88
95
|
dirName: string;
|
|
89
96
|
fileName: string;
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentstack/cli-cm-export",
|
|
3
3
|
"description": "Contentstack CLI plugin to export content from stack",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.25.0",
|
|
5
5
|
"author": "Contentstack",
|
|
6
6
|
"bugs": "https://github.com/contentstack/cli/issues",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@contentstack/cli-command": "~1.8.
|
|
8
|
+
"@contentstack/cli-command": "~1.8.2",
|
|
9
9
|
"@oclif/core": "^4.10.5",
|
|
10
|
-
"@contentstack/cli-variants": "~1.
|
|
11
|
-
"@contentstack/cli-utilities": "~1.18.
|
|
10
|
+
"@contentstack/cli-variants": "~1.5.0",
|
|
11
|
+
"@contentstack/cli-utilities": "~1.18.3",
|
|
12
12
|
"async": "^3.2.6",
|
|
13
13
|
"big-json": "^3.2.0",
|
|
14
14
|
"bluebird": "^3.7.2",
|
|
@@ -35,8 +35,7 @@
|
|
|
35
35
|
"chai": "^4.4.1",
|
|
36
36
|
"dotenv": "^16.5.0",
|
|
37
37
|
"dotenv-expand": "^9.0.0",
|
|
38
|
-
"eslint": "^
|
|
39
|
-
"eslint-config-oclif": "^6.0.68",
|
|
38
|
+
"eslint": "^9.26.0",
|
|
40
39
|
"mocha": "10.8.2",
|
|
41
40
|
"nyc": "^15.1.0",
|
|
42
41
|
"oclif": "^4.17.46",
|