@contentstack/cli-cm-branches 1.0.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/LICENSE +21 -0
- package/README.md +226 -0
- package/lib/branch/diff-handler.js +115 -0
- package/lib/branch/index.js +13 -0
- package/lib/branch/merge-handler.js +227 -0
- package/lib/commands/cm/branches/create.js +44 -0
- package/lib/commands/cm/branches/delete.js +47 -0
- package/lib/commands/cm/branches/diff.js +65 -0
- package/lib/commands/cm/branches/index.js +81 -0
- package/lib/commands/cm/branches/merge.js +94 -0
- package/lib/config/index.js +7 -0
- package/lib/interfaces/index.js +2 -0
- package/lib/utils/branch-diff-utility.js +503 -0
- package/lib/utils/create-branch.js +37 -0
- package/lib/utils/create-merge-scripts.js +67 -0
- package/lib/utils/delete-branch.js +35 -0
- package/lib/utils/entry-create-script.js +73 -0
- package/lib/utils/entry-update-script.js +126 -0
- package/lib/utils/index.js +98 -0
- package/lib/utils/interactive.js +244 -0
- package/lib/utils/merge-helper.js +138 -0
- package/messages/index.json +12 -0
- package/oclif.manifest.json +289 -0
- package/package.json +92 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"CLI_BRANCH_API_FAILED": "Something went wrong. Unable to fetch the details.",
|
|
3
|
+
"CLI_BRANCH_BASE_BRANCH": "Enter base branch name:",
|
|
4
|
+
"CLI_BRANCH_COMPARE_BRANCH": "Enter compare branch name:",
|
|
5
|
+
"CLI_BRANCH_STACK_API_KEY": "Enter Stack API key:",
|
|
6
|
+
"CLI_BRANCH_MODULE": "Choose a module:",
|
|
7
|
+
"CLI_BRANCH_REQUIRED_FIELD": "This field can't be empty.",
|
|
8
|
+
"CLI_BRANCH_CONFIG_ERROR": "Please set the config using 'cm:config:set:branch' command",
|
|
9
|
+
"CLI_BRANCH_BRANCH_UID": "Enter branch UID:",
|
|
10
|
+
"CLI_BRANCH_SOURCE_BRANCH": "Enter source branch:",
|
|
11
|
+
"CLI_BRANCH_NAME_CONFIRMATION": "To delete the branch, type the branch name to confirm:"
|
|
12
|
+
}
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "1.0.0",
|
|
3
|
+
"commands": {
|
|
4
|
+
"cm:branches:create": {
|
|
5
|
+
"id": "cm:branches:create",
|
|
6
|
+
"description": "Create a new branch",
|
|
7
|
+
"strict": true,
|
|
8
|
+
"usage": [
|
|
9
|
+
"cm:branches:create",
|
|
10
|
+
"cm:branches:create [--source <value>] [--uid <value>] [-k <value>]",
|
|
11
|
+
"cm:branches:create [--source <value>] [--uid <value>] [--stack-api-key <value>]"
|
|
12
|
+
],
|
|
13
|
+
"pluginName": "@contentstack/cli-cm-branches",
|
|
14
|
+
"pluginAlias": "@contentstack/cli-cm-branches",
|
|
15
|
+
"pluginType": "core",
|
|
16
|
+
"aliases": [],
|
|
17
|
+
"examples": [
|
|
18
|
+
"csdx cm:branches:create",
|
|
19
|
+
"csdx cm:branches:create --source main -uid new_branch -k bltxxxxxxxx",
|
|
20
|
+
"csdx cm:branches:create --source main --uid new_branch --stack-api-key bltxxxxxxxx"
|
|
21
|
+
],
|
|
22
|
+
"flags": {
|
|
23
|
+
"uid": {
|
|
24
|
+
"name": "uid",
|
|
25
|
+
"type": "option",
|
|
26
|
+
"description": "Branch UID to be created",
|
|
27
|
+
"multiple": false
|
|
28
|
+
},
|
|
29
|
+
"source": {
|
|
30
|
+
"name": "source",
|
|
31
|
+
"type": "option",
|
|
32
|
+
"description": "Source branch from which new branch to be created",
|
|
33
|
+
"multiple": false
|
|
34
|
+
},
|
|
35
|
+
"stack-api-key": {
|
|
36
|
+
"name": "stack-api-key",
|
|
37
|
+
"type": "option",
|
|
38
|
+
"char": "k",
|
|
39
|
+
"description": "Stack API key",
|
|
40
|
+
"multiple": false
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"args": {}
|
|
44
|
+
},
|
|
45
|
+
"cm:branches:delete": {
|
|
46
|
+
"id": "cm:branches:delete",
|
|
47
|
+
"description": "Delete a branch",
|
|
48
|
+
"strict": true,
|
|
49
|
+
"usage": [
|
|
50
|
+
"cm:branches:delete [-uid <value>] [-k <value>]",
|
|
51
|
+
"cm:branches:delete [--uid <value>] [--stack-api-key <value>]"
|
|
52
|
+
],
|
|
53
|
+
"pluginName": "@contentstack/cli-cm-branches",
|
|
54
|
+
"pluginAlias": "@contentstack/cli-cm-branches",
|
|
55
|
+
"pluginType": "core",
|
|
56
|
+
"aliases": [],
|
|
57
|
+
"examples": [
|
|
58
|
+
"csdx cm:branches:delete",
|
|
59
|
+
"csdx cm:branches:delete --uid main -k bltxxxxxxxx",
|
|
60
|
+
"csdx cm:branches:delete --uid main --stack-api-key bltxxxxxxxx",
|
|
61
|
+
"csdx cm:branches:delete --uid main --stack-api-key bltxxxxxxxx --yes"
|
|
62
|
+
],
|
|
63
|
+
"flags": {
|
|
64
|
+
"uid": {
|
|
65
|
+
"name": "uid",
|
|
66
|
+
"type": "option",
|
|
67
|
+
"description": "Branch UID to be deleted",
|
|
68
|
+
"multiple": false
|
|
69
|
+
},
|
|
70
|
+
"stack-api-key": {
|
|
71
|
+
"name": "stack-api-key",
|
|
72
|
+
"type": "option",
|
|
73
|
+
"char": "k",
|
|
74
|
+
"description": "Stack API key",
|
|
75
|
+
"multiple": false
|
|
76
|
+
},
|
|
77
|
+
"yes": {
|
|
78
|
+
"name": "yes",
|
|
79
|
+
"type": "boolean",
|
|
80
|
+
"char": "y",
|
|
81
|
+
"description": "Force the deletion of the branch by skipping the confirmation",
|
|
82
|
+
"allowNo": false
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
"args": {}
|
|
86
|
+
},
|
|
87
|
+
"cm:branches:diff": {
|
|
88
|
+
"id": "cm:branches:diff",
|
|
89
|
+
"description": "Differences between two branches",
|
|
90
|
+
"strict": true,
|
|
91
|
+
"usage": "cm:branches:diff [--base-branch <value>] [--compare-branch <value>] [-k <value>][--module <value>]",
|
|
92
|
+
"pluginName": "@contentstack/cli-cm-branches",
|
|
93
|
+
"pluginAlias": "@contentstack/cli-cm-branches",
|
|
94
|
+
"pluginType": "core",
|
|
95
|
+
"aliases": [],
|
|
96
|
+
"examples": [
|
|
97
|
+
"csdx cm:branches:diff",
|
|
98
|
+
"csdx cm:branches:diff --stack-api-key \"bltxxxxxxxx\"",
|
|
99
|
+
"csdx cm:branches:diff --compare-branch \"develop\"",
|
|
100
|
+
"csdx cm:branches:diff --compare-branch \"develop\" --stack-api-key \"bltxxxxxxxx\"",
|
|
101
|
+
"csdx cm:branches:diff --compare-branch \"develop\" --module \"content-types\"",
|
|
102
|
+
"csdx cm:branches:diff --module \"content-types\" --format \"detailed-text\"",
|
|
103
|
+
"csdx cm:branches:diff --compare-branch \"develop\" --format \"detailed-text\"",
|
|
104
|
+
"csdx cm:branches:diff --stack-api-key \"bltxxxxxxxx\" --base-branch \"main\"",
|
|
105
|
+
"csdx cm:branches:diff --stack-api-key \"bltxxxxxxxx\" --base-branch \"main\" --compare-branch \"develop\"",
|
|
106
|
+
"csdx cm:branches:diff --stack-api-key \"bltxxxxxxxx\" --base-branch \"main\" --module \"content-types\"",
|
|
107
|
+
"csdx cm:branches:diff --stack-api-key \"bltxxxxxxxx\" --base-branch \"main\" --compare-branch \"develop\" --module \"content-types\"",
|
|
108
|
+
"csdx cm:branches:diff --stack-api-key \"bltxxxxxxxx\" --base-branch \"main\" --compare-branch \"develop\" --module \"content-types\" --format \"detailed-text\""
|
|
109
|
+
],
|
|
110
|
+
"flags": {
|
|
111
|
+
"base-branch": {
|
|
112
|
+
"name": "base-branch",
|
|
113
|
+
"type": "option",
|
|
114
|
+
"description": "Base branch",
|
|
115
|
+
"multiple": false
|
|
116
|
+
},
|
|
117
|
+
"compare-branch": {
|
|
118
|
+
"name": "compare-branch",
|
|
119
|
+
"type": "option",
|
|
120
|
+
"description": "Compare branch",
|
|
121
|
+
"multiple": false
|
|
122
|
+
},
|
|
123
|
+
"module": {
|
|
124
|
+
"name": "module",
|
|
125
|
+
"type": "option",
|
|
126
|
+
"description": "Module",
|
|
127
|
+
"multiple": false,
|
|
128
|
+
"options": [
|
|
129
|
+
"content-types",
|
|
130
|
+
"global-fields",
|
|
131
|
+
"all"
|
|
132
|
+
]
|
|
133
|
+
},
|
|
134
|
+
"stack-api-key": {
|
|
135
|
+
"name": "stack-api-key",
|
|
136
|
+
"type": "option",
|
|
137
|
+
"char": "k",
|
|
138
|
+
"description": "Provide Stack API key to show difference between branches",
|
|
139
|
+
"multiple": false
|
|
140
|
+
},
|
|
141
|
+
"format": {
|
|
142
|
+
"name": "format",
|
|
143
|
+
"type": "option",
|
|
144
|
+
"description": "[Optional] Type of flags to show branches differences",
|
|
145
|
+
"multiple": false,
|
|
146
|
+
"options": [
|
|
147
|
+
"compact-text",
|
|
148
|
+
"detailed-text"
|
|
149
|
+
],
|
|
150
|
+
"default": "compact-text"
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
"args": {}
|
|
154
|
+
},
|
|
155
|
+
"cm:branches": {
|
|
156
|
+
"id": "cm:branches",
|
|
157
|
+
"description": "List the branches",
|
|
158
|
+
"strict": true,
|
|
159
|
+
"usage": "cm:branches",
|
|
160
|
+
"pluginName": "@contentstack/cli-cm-branches",
|
|
161
|
+
"pluginAlias": "@contentstack/cli-cm-branches",
|
|
162
|
+
"pluginType": "core",
|
|
163
|
+
"aliases": [],
|
|
164
|
+
"examples": [
|
|
165
|
+
"csdx cm:branches",
|
|
166
|
+
"csdx cm:branches --verbose",
|
|
167
|
+
"csdx cm:branches -k <stack api key>"
|
|
168
|
+
],
|
|
169
|
+
"flags": {
|
|
170
|
+
"stack-api-key": {
|
|
171
|
+
"name": "stack-api-key",
|
|
172
|
+
"type": "option",
|
|
173
|
+
"char": "k",
|
|
174
|
+
"description": "Stack API Key",
|
|
175
|
+
"multiple": false
|
|
176
|
+
},
|
|
177
|
+
"verbose": {
|
|
178
|
+
"name": "verbose",
|
|
179
|
+
"type": "boolean",
|
|
180
|
+
"description": "Verbose",
|
|
181
|
+
"allowNo": false
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
"args": {}
|
|
185
|
+
},
|
|
186
|
+
"cm:branches:merge": {
|
|
187
|
+
"id": "cm:branches:merge",
|
|
188
|
+
"description": "Merge changes from a branch",
|
|
189
|
+
"strict": true,
|
|
190
|
+
"usage": "cm:branches:merge [-k <value>][--compare-branch <value>] [--no-revert] [--export-summary-path <value>] [--use-merge-summary <value>] [--comment <value>] [--base-branch <value>]",
|
|
191
|
+
"pluginName": "@contentstack/cli-cm-branches",
|
|
192
|
+
"pluginAlias": "@contentstack/cli-cm-branches",
|
|
193
|
+
"pluginType": "core",
|
|
194
|
+
"aliases": [],
|
|
195
|
+
"examples": [
|
|
196
|
+
"csdx cm:branches:merge --stack-api-key bltxxxxxxxx --compare-branch feature-branch",
|
|
197
|
+
"csdx cm:branches:merge --stack-api-key bltxxxxxxxx --comment \"merge comment\"",
|
|
198
|
+
"csdx cm:branches:merge -k bltxxxxxxxx --base-branch base-branch",
|
|
199
|
+
"csdx cm:branches:merge --export-summary-path file/path",
|
|
200
|
+
"csdx cm:branches:merge --use-merge-summary file-path",
|
|
201
|
+
"csdx cm:branches:merge -k bltxxxxxxxx --no-revert",
|
|
202
|
+
"csdx cm:branches:merge -k bltxxxxxxxx --compare-branch feature-branch --no-revert"
|
|
203
|
+
],
|
|
204
|
+
"flags": {
|
|
205
|
+
"compare-branch": {
|
|
206
|
+
"name": "compare-branch",
|
|
207
|
+
"type": "option",
|
|
208
|
+
"description": "Compare branch name",
|
|
209
|
+
"multiple": false
|
|
210
|
+
},
|
|
211
|
+
"base-branch": {
|
|
212
|
+
"name": "base-branch",
|
|
213
|
+
"type": "option",
|
|
214
|
+
"description": "Base branch",
|
|
215
|
+
"multiple": false
|
|
216
|
+
},
|
|
217
|
+
"comment": {
|
|
218
|
+
"name": "comment",
|
|
219
|
+
"type": "option",
|
|
220
|
+
"description": "Merge comment",
|
|
221
|
+
"multiple": false
|
|
222
|
+
},
|
|
223
|
+
"stack-api-key": {
|
|
224
|
+
"name": "stack-api-key",
|
|
225
|
+
"type": "option",
|
|
226
|
+
"char": "k",
|
|
227
|
+
"description": "Provide Stack API key to show difference between branches",
|
|
228
|
+
"multiple": false
|
|
229
|
+
},
|
|
230
|
+
"export-summary-path": {
|
|
231
|
+
"name": "export-summary-path",
|
|
232
|
+
"type": "option",
|
|
233
|
+
"description": "Export summary file path",
|
|
234
|
+
"multiple": false
|
|
235
|
+
},
|
|
236
|
+
"use-merge-summary": {
|
|
237
|
+
"name": "use-merge-summary",
|
|
238
|
+
"type": "option",
|
|
239
|
+
"description": "Path of merge summary file",
|
|
240
|
+
"multiple": false
|
|
241
|
+
},
|
|
242
|
+
"no-revert": {
|
|
243
|
+
"name": "no-revert",
|
|
244
|
+
"type": "boolean",
|
|
245
|
+
"description": "If passed, will not create the new revert branch",
|
|
246
|
+
"allowNo": false
|
|
247
|
+
},
|
|
248
|
+
"strategy": {
|
|
249
|
+
"name": "strategy",
|
|
250
|
+
"type": "option",
|
|
251
|
+
"description": "Merge strategy",
|
|
252
|
+
"hidden": true,
|
|
253
|
+
"multiple": false,
|
|
254
|
+
"options": [
|
|
255
|
+
"merge_prefer_base",
|
|
256
|
+
"merge_prefer_compare",
|
|
257
|
+
"overwrite_with_compare",
|
|
258
|
+
"custom_preferences"
|
|
259
|
+
]
|
|
260
|
+
},
|
|
261
|
+
"strategy-sub-options": {
|
|
262
|
+
"name": "strategy-sub-options",
|
|
263
|
+
"type": "option",
|
|
264
|
+
"description": "Merge strategy sub options",
|
|
265
|
+
"hidden": true,
|
|
266
|
+
"multiple": false,
|
|
267
|
+
"options": [
|
|
268
|
+
"new",
|
|
269
|
+
"modified",
|
|
270
|
+
"both"
|
|
271
|
+
]
|
|
272
|
+
},
|
|
273
|
+
"merge-action": {
|
|
274
|
+
"name": "merge-action",
|
|
275
|
+
"type": "option",
|
|
276
|
+
"description": "Merge strategy",
|
|
277
|
+
"hidden": true,
|
|
278
|
+
"multiple": false,
|
|
279
|
+
"options": [
|
|
280
|
+
"export",
|
|
281
|
+
"execute",
|
|
282
|
+
"both"
|
|
283
|
+
]
|
|
284
|
+
}
|
|
285
|
+
},
|
|
286
|
+
"args": {}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@contentstack/cli-cm-branches",
|
|
3
|
+
"description": "Contentstack CLI plugin to do branches operations",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"author": "Contentstack",
|
|
6
|
+
"bugs": "https://github.com/contentstack/cli/issues",
|
|
7
|
+
"dependencies": {
|
|
8
|
+
"@contentstack/cli-command": "^1.2.3",
|
|
9
|
+
"@contentstack/cli-utilities": "^1.4.0",
|
|
10
|
+
"@oclif/command": "^1.8.16",
|
|
11
|
+
"@oclif/config": "^1.18.3",
|
|
12
|
+
"@oclif/core": "^2.3.0",
|
|
13
|
+
"async": "^3.2.4",
|
|
14
|
+
"big-json": "^3.2.0",
|
|
15
|
+
"bluebird": "^3.7.2",
|
|
16
|
+
"chalk": "^4.1.2",
|
|
17
|
+
"is-valid-path": "^0.1.1",
|
|
18
|
+
"just-diff": "^6.0.2",
|
|
19
|
+
"lodash": "^4.17.20",
|
|
20
|
+
"merge": "^2.1.1",
|
|
21
|
+
"mkdirp": "^1.0.4",
|
|
22
|
+
"path": "^0.12.7",
|
|
23
|
+
"progress-stream": "^2.0.0",
|
|
24
|
+
"promise-limit": "^2.7.0",
|
|
25
|
+
"proxyquire": "^2.1.3",
|
|
26
|
+
"tslib": "^2.4.1",
|
|
27
|
+
"winston": "^3.7.2"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@contentstack/cli-auth": "^1.2.0",
|
|
31
|
+
"@contentstack/cli-config": "^1.2.0",
|
|
32
|
+
"@contentstack/cli-dev-dependencies": "^1.2.0",
|
|
33
|
+
"@oclif/plugin-help": "^5.1.19",
|
|
34
|
+
"@oclif/test": "^1.2.6",
|
|
35
|
+
"@types/flat": "^5.0.2",
|
|
36
|
+
"assert": "^2.0.0",
|
|
37
|
+
"chai": "^4.2.0",
|
|
38
|
+
"dotenv": "^16.0.1",
|
|
39
|
+
"dotenv-expand": "^9.0.0",
|
|
40
|
+
"eslint": "^8.18.0",
|
|
41
|
+
"eslint-config-oclif": "^4.0.0",
|
|
42
|
+
"globby": "^10.0.2",
|
|
43
|
+
"mocha": "10.1.0",
|
|
44
|
+
"nyc": "^15.1.0",
|
|
45
|
+
"oclif": "^3.1.2",
|
|
46
|
+
"sinon": "^15.0.1",
|
|
47
|
+
"ts-node": "^10.9.1",
|
|
48
|
+
"typescript": "^4.9.3"
|
|
49
|
+
},
|
|
50
|
+
"scripts": {
|
|
51
|
+
"build": "npm run clean && npm run compile",
|
|
52
|
+
"clean": "rm -rf ./lib ./node_modules tsconfig.build.tsbuildinfo",
|
|
53
|
+
"compile": "tsc -b tsconfig.json",
|
|
54
|
+
"postpack": "rm -f oclif.manifest.json",
|
|
55
|
+
"prepack": "pnpm compile && oclif manifest && oclif readme",
|
|
56
|
+
"version": "oclif readme && git add README.md",
|
|
57
|
+
"test:report": "tsc -p test && nyc --reporter=lcov --extension .ts mocha --forbid-only \"test/**/*.test.ts\"",
|
|
58
|
+
"pretest": "tsc -p test",
|
|
59
|
+
"test": "nyc --extension .ts mocha --forbid-only \"test/**/*.test.ts\"",
|
|
60
|
+
"posttest": "npm run lint",
|
|
61
|
+
"lint": "eslint src/**/*.ts",
|
|
62
|
+
"format": "eslint src/**/*.ts --fix",
|
|
63
|
+
"test:integration": "mocha --forbid-only \"test/integration/*.test.ts\"",
|
|
64
|
+
"test:unit": "mocha --forbid-only \"test/unit/**/*.test.ts\"",
|
|
65
|
+
"test:unit:report": "nyc --extension .ts mocha --forbid-only \"test/unit/**/*.test.ts\""
|
|
66
|
+
},
|
|
67
|
+
"engines": {
|
|
68
|
+
"node": ">=14.0.0"
|
|
69
|
+
},
|
|
70
|
+
"files": [
|
|
71
|
+
"/lib",
|
|
72
|
+
"/messages",
|
|
73
|
+
"/npm-shrinkwrap.json",
|
|
74
|
+
"/oclif.manifest.json"
|
|
75
|
+
],
|
|
76
|
+
"homepage": "https://github.com/contentstack/cli",
|
|
77
|
+
"keywords": [
|
|
78
|
+
"contentstack",
|
|
79
|
+
"cli",
|
|
80
|
+
"plugin"
|
|
81
|
+
],
|
|
82
|
+
"license": "MIT",
|
|
83
|
+
"main": "./lib/commands/cm/stacks/export.js",
|
|
84
|
+
"types": "./types/index.d.ts",
|
|
85
|
+
"oclif": {
|
|
86
|
+
"commands": "./lib/commands",
|
|
87
|
+
"bin": "csdx",
|
|
88
|
+
"repositoryPrefix": "<%- repo %>/blob/main/packages/contentstack-export/<%- commandPath %>"
|
|
89
|
+
},
|
|
90
|
+
"csdxConfig": {},
|
|
91
|
+
"repository": "https://github.com/contentstack/cli"
|
|
92
|
+
}
|