contensis-cli 1.0.0-beta.5 → 1.0.0-beta.50
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 +669 -74
- package/dist/commands/connect.js +3 -3
- package/dist/commands/connect.js.map +2 -2
- package/dist/commands/create.js +30 -10
- package/dist/commands/create.js.map +2 -2
- package/dist/commands/diff.js +57 -0
- package/dist/commands/diff.js.map +7 -0
- package/dist/commands/get.js +61 -12
- package/dist/commands/get.js.map +2 -2
- package/dist/commands/globalOptions.js +22 -17
- package/dist/commands/globalOptions.js.map +2 -2
- package/dist/commands/import.js +36 -10
- package/dist/commands/import.js.map +2 -2
- package/dist/commands/index.js +9 -1
- package/dist/commands/index.js.map +2 -2
- package/dist/commands/list.js +19 -8
- package/dist/commands/list.js.map +2 -2
- package/dist/commands/login.js +3 -3
- package/dist/commands/login.js.map +2 -2
- package/dist/commands/push.js +8 -4
- package/dist/commands/push.js.map +2 -2
- package/dist/commands/release.js +47 -0
- package/dist/commands/release.js.map +7 -0
- package/dist/commands/remove.js +10 -8
- package/dist/commands/remove.js.map +2 -2
- package/dist/commands/set.js +53 -12
- package/dist/commands/set.js.map +2 -2
- package/dist/localisation/en-GB.js +97 -47
- package/dist/localisation/en-GB.js.map +2 -2
- package/dist/providers/CredentialProvider.js +36 -7
- package/dist/providers/CredentialProvider.js.map +3 -3
- package/dist/providers/SessionCacheProvider.js +21 -1
- package/dist/providers/SessionCacheProvider.js.map +2 -2
- package/dist/providers/file-provider.js +8 -4
- package/dist/providers/file-provider.js.map +3 -3
- package/dist/services/ContensisCliService.js +600 -336
- package/dist/services/ContensisCliService.js.map +3 -3
- package/dist/shell.js +27 -10
- package/dist/shell.js.map +3 -3
- package/dist/util/console.printer.js +170 -47
- package/dist/util/console.printer.js.map +2 -2
- package/dist/util/index.js +5 -2
- package/dist/util/index.js.map +3 -3
- package/dist/util/logger.js +45 -13
- package/dist/util/logger.js.map +2 -2
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +2 -2
- package/src/commands/connect.ts +3 -2
- package/src/commands/create.ts +37 -8
- package/src/commands/diff.ts +41 -0
- package/src/commands/get.ts +80 -5
- package/src/commands/globalOptions.ts +18 -17
- package/src/commands/import.ts +43 -4
- package/src/commands/index.ts +9 -1
- package/src/commands/list.ts +35 -9
- package/src/commands/login.ts +3 -2
- package/src/commands/push.ts +9 -2
- package/src/commands/release.ts +32 -0
- package/src/commands/remove.ts +12 -4
- package/src/commands/set.ts +65 -9
- package/src/localisation/en-GB.ts +142 -64
- package/src/providers/CredentialProvider.ts +39 -6
- package/src/providers/SessionCacheProvider.ts +29 -2
- package/src/providers/file-provider.ts +8 -4
- package/src/services/ContensisCliService.ts +741 -387
- package/src/shell.ts +31 -11
- package/src/util/console.printer.ts +234 -66
- package/src/util/index.ts +12 -6
- package/src/util/logger.ts +84 -15
- package/src/version.ts +1 -1
|
@@ -33,6 +33,7 @@ var import_path = __toESM(require("path"));
|
|
|
33
33
|
var import_node_fetch = __toESM(require("node-fetch"));
|
|
34
34
|
var import_inquirer = __toESM(require("inquirer"));
|
|
35
35
|
var import_await_to_js = __toESM(require("await-to-js"));
|
|
36
|
+
var import_chalk = __toESM(require("chalk"));
|
|
36
37
|
var import_util = require("../util");
|
|
37
38
|
var import_SessionCacheProvider = __toESM(require("../providers/SessionCacheProvider"));
|
|
38
39
|
var import_ContensisAuthService = __toESM(require("./ContensisAuthService"));
|
|
@@ -45,35 +46,65 @@ var import_xml = require("../util/xml.formatter");
|
|
|
45
46
|
var import_json = require("../util/json.formatter");
|
|
46
47
|
var import_console = require("../util/console.printer");
|
|
47
48
|
var import_file_provider = require("../providers/file-provider");
|
|
49
|
+
let insecurePasswordWarningShown = false;
|
|
48
50
|
class ContensisCli {
|
|
49
51
|
static quit = (error) => {
|
|
50
52
|
process.removeAllListeners("exit");
|
|
51
53
|
const exitCode = error ? 1 : 0;
|
|
52
|
-
console.info(`
|
|
53
|
-
Exiting contensis-cli with exit code: ${exitCode}
|
|
54
|
-
`);
|
|
55
54
|
process.exit(exitCode);
|
|
56
55
|
};
|
|
57
|
-
|
|
56
|
+
command;
|
|
57
|
+
format;
|
|
58
|
+
output;
|
|
59
|
+
session;
|
|
58
60
|
contensis;
|
|
59
61
|
contensisOpts;
|
|
60
|
-
contentTypes;
|
|
61
|
-
components;
|
|
62
|
-
currentEnv;
|
|
63
62
|
currentProject;
|
|
64
|
-
|
|
65
|
-
sourceEnv;
|
|
63
|
+
sourceAlias;
|
|
66
64
|
targetEnv;
|
|
67
65
|
urls;
|
|
68
|
-
command;
|
|
69
|
-
format;
|
|
70
|
-
output;
|
|
71
66
|
log = import_logger.Logger;
|
|
72
67
|
messages = import_en_GB.LogMessages;
|
|
73
|
-
session;
|
|
74
68
|
verb;
|
|
75
69
|
noun;
|
|
76
70
|
thirdArg;
|
|
71
|
+
get cache() {
|
|
72
|
+
return this.session.Get();
|
|
73
|
+
}
|
|
74
|
+
get currentEnv() {
|
|
75
|
+
return this.cache.currentEnvironment || "";
|
|
76
|
+
}
|
|
77
|
+
set currentEnv(currentEnvironment) {
|
|
78
|
+
this.session.Update({ currentEnvironment });
|
|
79
|
+
}
|
|
80
|
+
get env() {
|
|
81
|
+
const currentEnvironment = this.currentEnv;
|
|
82
|
+
const environments = this.cache.environments || {};
|
|
83
|
+
if (!currentEnvironment)
|
|
84
|
+
return {};
|
|
85
|
+
else if (!!environments[currentEnvironment])
|
|
86
|
+
return environments[currentEnvironment];
|
|
87
|
+
else {
|
|
88
|
+
return {
|
|
89
|
+
history: [],
|
|
90
|
+
lastUserId: "",
|
|
91
|
+
projects: [],
|
|
92
|
+
versionStatus: "latest"
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
get contentTypes() {
|
|
97
|
+
var _a;
|
|
98
|
+
return (_a = this.contensis) == null ? void 0 : _a.models.contentTypes();
|
|
99
|
+
}
|
|
100
|
+
get components() {
|
|
101
|
+
var _a;
|
|
102
|
+
return (_a = this.contensis) == null ? void 0 : _a.models.components();
|
|
103
|
+
}
|
|
104
|
+
get models() {
|
|
105
|
+
var _a;
|
|
106
|
+
return (_a = this.contensis) == null ? void 0 : _a.models.contentModels();
|
|
107
|
+
}
|
|
77
108
|
constructor(args, outputOpts, contensisOpts = {}) {
|
|
78
109
|
const [exe, script, verb = "", noun = "", ...restArgs] = args;
|
|
79
110
|
this.verb = verb == null ? void 0 : verb.toLowerCase();
|
|
@@ -81,24 +112,12 @@ Exiting contensis-cli with exit code: ${exitCode}
|
|
|
81
112
|
this.thirdArg = restArgs == null ? void 0 : restArgs[0];
|
|
82
113
|
const commandText = `${this.verb} ${this.noun} ${restArgs ? restArgs.join(" ") : ""}`.trim();
|
|
83
114
|
this.session = new import_SessionCacheProvider.default();
|
|
84
|
-
this.cache = this.session.Get();
|
|
85
115
|
this.contensisOpts = contensisOpts;
|
|
86
116
|
this.format = outputOpts == null ? void 0 : outputOpts.format;
|
|
87
117
|
this.output = (outputOpts == null ? void 0 : outputOpts.output) && import_path.default.join(process.cwd(), outputOpts.output);
|
|
88
|
-
const currentEnvironment = (outputOpts == null ? void 0 : outputOpts.alias) || this.
|
|
118
|
+
const currentEnvironment = (outputOpts == null ? void 0 : outputOpts.alias) || this.currentEnv;
|
|
89
119
|
const environments = this.cache.environments || {};
|
|
90
|
-
|
|
91
|
-
this.env = {};
|
|
92
|
-
else if (!!environments[currentEnvironment])
|
|
93
|
-
this.env = environments[currentEnvironment];
|
|
94
|
-
else {
|
|
95
|
-
this.env = {
|
|
96
|
-
history: [],
|
|
97
|
-
lastUserId: "",
|
|
98
|
-
projects: [],
|
|
99
|
-
versionStatus: "latest"
|
|
100
|
-
};
|
|
101
|
-
}
|
|
120
|
+
this.currentEnv = currentEnvironment;
|
|
102
121
|
const env = this.env;
|
|
103
122
|
if (outputOpts == null ? void 0 : outputOpts.projectId)
|
|
104
123
|
env.currentProject = outputOpts.projectId;
|
|
@@ -110,9 +129,8 @@ Exiting contensis-cli with exit code: ${exitCode}
|
|
|
110
129
|
env.lastUserId = outputOpts.clientId;
|
|
111
130
|
if (outputOpts == null ? void 0 : outputOpts.sharedSecret)
|
|
112
131
|
env.passwordFallback = outputOpts.sharedSecret;
|
|
113
|
-
this.currentEnv = currentEnvironment;
|
|
114
132
|
this.currentProject = (env == null ? void 0 : env.currentProject) || "null";
|
|
115
|
-
this.
|
|
133
|
+
this.sourceAlias = (outputOpts == null ? void 0 : outputOpts.sourceAlias) || currentEnvironment;
|
|
116
134
|
if (currentEnvironment) {
|
|
117
135
|
this.urls = (0, import_util.url)(currentEnvironment, (env == null ? void 0 : env.currentProject) || "website");
|
|
118
136
|
}
|
|
@@ -124,7 +142,7 @@ Exiting contensis-cli with exit code: ${exitCode}
|
|
|
124
142
|
if (currentEnvironment) {
|
|
125
143
|
env.history = [this.command];
|
|
126
144
|
if (commandText) {
|
|
127
|
-
environments[currentEnvironment] =
|
|
145
|
+
environments[currentEnvironment] = env;
|
|
128
146
|
this.session.Update({
|
|
129
147
|
currentEnvironment,
|
|
130
148
|
environments,
|
|
@@ -149,34 +167,20 @@ Exiting contensis-cli with exit code: ${exitCode}
|
|
|
149
167
|
};
|
|
150
168
|
Connect = async (environment) => {
|
|
151
169
|
var _a;
|
|
152
|
-
const {
|
|
170
|
+
const { log, messages, session } = this;
|
|
153
171
|
if (environment) {
|
|
154
|
-
const envCache = cache.environments[environment];
|
|
155
|
-
if (!envCache)
|
|
156
|
-
cache.environments[environment] = {
|
|
157
|
-
versionStatus: "published",
|
|
158
|
-
history: [],
|
|
159
|
-
lastUserId: "",
|
|
160
|
-
projects: [],
|
|
161
|
-
...!this.currentEnv ? this.env : {}
|
|
162
|
-
};
|
|
163
|
-
this.env = cache.environments[environment];
|
|
164
172
|
this.currentEnv = environment;
|
|
165
173
|
this.urls = (0, import_util.url)(environment, "website");
|
|
166
174
|
const [fetchErr, response] = await (0, import_await_to_js.default)((0, import_node_fetch.default)(this.urls.cms));
|
|
167
175
|
if (response && (response == null ? void 0 : response.status) < 400) {
|
|
168
176
|
log.success(messages.connect.connected(environment));
|
|
177
|
+
session.UpdateEnv(this.env, environment);
|
|
169
178
|
if ((_a = this.env) == null ? void 0 : _a.lastUserId) {
|
|
170
|
-
await this.ConnectContensis();
|
|
171
179
|
await this.PrintProjects();
|
|
172
180
|
} else {
|
|
173
181
|
log.warning(messages.projects.noList());
|
|
174
182
|
log.help(messages.connect.tip());
|
|
175
183
|
}
|
|
176
|
-
session.Update({
|
|
177
|
-
currentEnvironment: environment,
|
|
178
|
-
environments: cache.environments
|
|
179
|
-
});
|
|
180
184
|
} else {
|
|
181
185
|
log.error(
|
|
182
186
|
messages.connect.unreachable(this.urls.cms, (response == null ? void 0 : response.status) || 0)
|
|
@@ -188,93 +192,80 @@ Exiting contensis-cli with exit code: ${exitCode}
|
|
|
188
192
|
};
|
|
189
193
|
ConnectContensis = async ({ commit = false } = {}) => {
|
|
190
194
|
var _a, _b, _c;
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
195
|
+
if (!this.contensis) {
|
|
196
|
+
const { contensisOpts, currentEnv, env, log, messages } = this;
|
|
197
|
+
const userId = env == null ? void 0 : env.lastUserId;
|
|
198
|
+
const isGuidId = userId && (0, import_util.isUuid)(userId);
|
|
199
|
+
if (currentEnv && userId) {
|
|
200
|
+
const credentials = await this.GetCredentials(
|
|
197
201
|
userId,
|
|
198
|
-
|
|
199
|
-
},
|
|
200
|
-
env.passwordFallback
|
|
201
|
-
).Init();
|
|
202
|
-
if (credentialError && !credentials.current) {
|
|
203
|
-
log.error(credentialError);
|
|
204
|
-
return;
|
|
205
|
-
}
|
|
206
|
-
const cachedPassword = (_a = credentials == null ? void 0 : credentials.current) == null ? void 0 : _a.password;
|
|
207
|
-
if (cachedPassword) {
|
|
208
|
-
this.contensis = new import_migratortron.ContensisMigrationService(
|
|
209
|
-
{
|
|
210
|
-
...contensisOpts,
|
|
211
|
-
source: {
|
|
212
|
-
url: ((_b = this.urls) == null ? void 0 : _b.cms) || "",
|
|
213
|
-
username: !isGuidId ? userId : void 0,
|
|
214
|
-
password: !isGuidId ? cachedPassword : void 0,
|
|
215
|
-
clientId: isGuidId ? userId : void 0,
|
|
216
|
-
sharedSecret: isGuidId ? cachedPassword : void 0,
|
|
217
|
-
project: (env == null ? void 0 : env.currentProject) || "",
|
|
218
|
-
assetHostname: (_c = this.urls) == null ? void 0 : _c.previewWeb
|
|
219
|
-
},
|
|
220
|
-
concurrency: typeof contensisOpts.concurrency !== "undefined" ? contensisOpts.concurrency : 3,
|
|
221
|
-
outputProgress: true
|
|
222
|
-
},
|
|
223
|
-
!commit
|
|
202
|
+
env.passwordFallback
|
|
224
203
|
);
|
|
204
|
+
const cachedPassword = (_a = credentials == null ? void 0 : credentials.current) == null ? void 0 : _a.password;
|
|
205
|
+
if (cachedPassword) {
|
|
206
|
+
this.contensis = new import_migratortron.ContensisMigrationService(
|
|
207
|
+
{
|
|
208
|
+
...contensisOpts,
|
|
209
|
+
source: {
|
|
210
|
+
url: ((_b = this.urls) == null ? void 0 : _b.cms) || "",
|
|
211
|
+
username: !isGuidId ? userId : void 0,
|
|
212
|
+
password: !isGuidId ? cachedPassword : void 0,
|
|
213
|
+
clientId: isGuidId ? userId : void 0,
|
|
214
|
+
sharedSecret: isGuidId ? cachedPassword : void 0,
|
|
215
|
+
project: (env == null ? void 0 : env.currentProject) || "",
|
|
216
|
+
assetHostname: (_c = this.urls) == null ? void 0 : _c.previewWeb
|
|
217
|
+
},
|
|
218
|
+
concurrency: typeof contensisOpts.concurrency !== "undefined" ? contensisOpts.concurrency : 3,
|
|
219
|
+
outputProgress: true
|
|
220
|
+
},
|
|
221
|
+
!commit
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
} else {
|
|
225
|
+
if (!currentEnv)
|
|
226
|
+
log.help(messages.connect.help());
|
|
227
|
+
if (!userId)
|
|
228
|
+
log.help(messages.connect.tip());
|
|
225
229
|
}
|
|
226
|
-
} else {
|
|
227
|
-
if (!currentEnv)
|
|
228
|
-
log.help(messages.connect.help());
|
|
229
|
-
if (!userId)
|
|
230
|
-
log.help(messages.connect.tip());
|
|
231
230
|
}
|
|
231
|
+
return this.contensis;
|
|
232
232
|
};
|
|
233
233
|
ConnectContensisImport = async ({
|
|
234
|
-
commit,
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
fileDataType
|
|
234
|
+
commit = false,
|
|
235
|
+
fromFile,
|
|
236
|
+
importDataType
|
|
238
237
|
}) => {
|
|
239
238
|
var _a, _b, _c, _d, _e, _f;
|
|
240
|
-
const
|
|
239
|
+
const source = fromFile ? "file" : "contensis";
|
|
240
|
+
const fileData = fromFile ? (0, import_file_provider.readJsonFile)(fromFile) || [] : [];
|
|
241
|
+
if (typeof fileData === "string")
|
|
242
|
+
throw new Error(`Import file format must be of type JSON`);
|
|
243
|
+
const { contensisOpts, currentEnv, env, log, messages, sourceAlias } = this;
|
|
241
244
|
const environments = this.cache.environments || {};
|
|
242
|
-
const sourceEnvironment = environments[
|
|
245
|
+
const sourceEnvironment = environments[sourceAlias || ""] || {};
|
|
243
246
|
const sourceCms = "source" in contensisOpts && contensisOpts.source || {};
|
|
244
247
|
const sourceUserId = sourceCms.clientId || sourceCms.username || sourceEnvironment.lastUserId;
|
|
245
248
|
const sourceProjectId = sourceCms.project || sourceEnvironment.currentProject || "website";
|
|
246
249
|
const isSourceGuidId = sourceUserId && (0, import_util.isUuid)(sourceUserId);
|
|
247
|
-
const sourceUrls = (0, import_util.url)(
|
|
250
|
+
const sourceUrls = (0, import_util.url)(sourceAlias || "", sourceProjectId);
|
|
248
251
|
const sourcePassword = sourceCms.sharedSecret || sourceCms.password || sourceEnvironment.passwordFallback;
|
|
249
252
|
const targetUserId = env == null ? void 0 : env.lastUserId;
|
|
250
253
|
const isTargetGuidId = targetUserId && (0, import_util.isUuid)(targetUserId);
|
|
251
254
|
if (sourceUserId && currentEnv && targetUserId) {
|
|
252
|
-
const
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
).Init();
|
|
259
|
-
if (sourceCredentialError && !sourceCredentials.current) {
|
|
260
|
-
(0, import_logger.logError)(sourceCredentialError);
|
|
261
|
-
return;
|
|
262
|
-
}
|
|
255
|
+
const sourceCredentials = await this.GetCredentials(
|
|
256
|
+
sourceUserId,
|
|
257
|
+
sourcePassword,
|
|
258
|
+
sourceAlias,
|
|
259
|
+
false
|
|
260
|
+
);
|
|
263
261
|
const cachedSourcePassword = (_a = sourceCredentials == null ? void 0 : sourceCredentials.current) == null ? void 0 : _a.password;
|
|
264
|
-
const
|
|
265
|
-
|
|
266
|
-
userId: targetUserId,
|
|
267
|
-
alias: currentEnv
|
|
268
|
-
},
|
|
262
|
+
const targetCredentials = await this.GetCredentials(
|
|
263
|
+
targetUserId,
|
|
269
264
|
env.passwordFallback
|
|
270
|
-
)
|
|
271
|
-
if (targetCredentialError && !targetCredentials.current) {
|
|
272
|
-
log.error(targetCredentialError);
|
|
273
|
-
return;
|
|
274
|
-
}
|
|
265
|
+
);
|
|
275
266
|
const cachedTargetPassword = (_b = targetCredentials == null ? void 0 : targetCredentials.current) == null ? void 0 : _b.password;
|
|
276
267
|
if (cachedSourcePassword && cachedTargetPassword) {
|
|
277
|
-
if (source === "file" ||
|
|
268
|
+
if (source === "file" || importDataType === "user-input") {
|
|
278
269
|
this.contensis = new import_migratortron.ContensisMigrationService(
|
|
279
270
|
{
|
|
280
271
|
concurrency: 3,
|
|
@@ -289,12 +280,11 @@ Exiting contensis-cli with exit code: ${exitCode}
|
|
|
289
280
|
targetProjects: [env.currentProject || ""],
|
|
290
281
|
assetHostname: (_d = this.urls) == null ? void 0 : _d.previewWeb
|
|
291
282
|
},
|
|
292
|
-
...
|
|
283
|
+
...importDataType ? { [importDataType]: fileData } : {}
|
|
293
284
|
},
|
|
294
285
|
!commit
|
|
295
286
|
);
|
|
296
|
-
}
|
|
297
|
-
if (source === "contensis") {
|
|
287
|
+
} else if (source === "contensis") {
|
|
298
288
|
this.contensis = new import_migratortron.ContensisMigrationService(
|
|
299
289
|
{
|
|
300
290
|
concurrency: 3,
|
|
@@ -329,82 +319,104 @@ Exiting contensis-cli with exit code: ${exitCode}
|
|
|
329
319
|
if (!targetUserId)
|
|
330
320
|
log.help(messages.connect.tip());
|
|
331
321
|
}
|
|
322
|
+
return this.contensis;
|
|
323
|
+
};
|
|
324
|
+
GetCredentials = async (userId, password, currentEnv = this.currentEnv, saveCurrentEnv = true) => {
|
|
325
|
+
const { log, messages } = this;
|
|
326
|
+
if (userId) {
|
|
327
|
+
const [credentialError, credentials] = await new import_CredentialProvider.default(
|
|
328
|
+
{ userId, alias: currentEnv },
|
|
329
|
+
password
|
|
330
|
+
).Init();
|
|
331
|
+
if (credentialError && !credentials.current) {
|
|
332
|
+
log.error(credentialError);
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
if (credentials.remarks.secure !== true) {
|
|
336
|
+
if (!insecurePasswordWarningShown) {
|
|
337
|
+
log.warning(messages.login.insecurePassword());
|
|
338
|
+
insecurePasswordWarningShown = true;
|
|
339
|
+
}
|
|
340
|
+
} else {
|
|
341
|
+
const env = this.cache.environments[currentEnv];
|
|
342
|
+
env.passwordFallback = void 0;
|
|
343
|
+
this.session.UpdateEnv(env, currentEnv, saveCurrentEnv);
|
|
344
|
+
}
|
|
345
|
+
return credentials;
|
|
346
|
+
}
|
|
332
347
|
};
|
|
333
348
|
Login = async (userId, {
|
|
334
349
|
password = (0, import_util.isPassword)(this.env.passwordFallback),
|
|
335
350
|
promptPassword = true,
|
|
336
351
|
sharedSecret = (0, import_util.isSharedSecret)(this.env.passwordFallback),
|
|
337
|
-
silent = false
|
|
338
|
-
|
|
352
|
+
silent = false,
|
|
353
|
+
attempt = 1
|
|
354
|
+
} = {}) => {
|
|
339
355
|
var _a, _b, _c, _d;
|
|
340
|
-
let inputPassword = password;
|
|
356
|
+
let inputPassword = password || sharedSecret;
|
|
341
357
|
const { log, messages } = this;
|
|
342
358
|
if (userId) {
|
|
343
|
-
const {
|
|
359
|
+
const { currentEnv, env } = this;
|
|
344
360
|
if (currentEnv) {
|
|
345
|
-
const
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
return await this.Login(userId, { password, sharedSecret });
|
|
398
|
-
} else {
|
|
399
|
-
throw new Error(messages.login.failed(currentEnv, userId));
|
|
361
|
+
const credentials = await this.GetCredentials(userId, inputPassword);
|
|
362
|
+
if (credentials) {
|
|
363
|
+
const cachedPassword = (0, import_util.isPassword)((_a = credentials.current) == null ? void 0 : _a.password);
|
|
364
|
+
const cachedSecret = (0, import_util.isSharedSecret)((_b = credentials.current) == null ? void 0 : _b.password);
|
|
365
|
+
if (!cachedPassword && !cachedSecret && promptPassword) {
|
|
366
|
+
({ inputPassword } = await import_inquirer.default.prompt([
|
|
367
|
+
{
|
|
368
|
+
type: "password",
|
|
369
|
+
message: messages.login.passwordPrompt(currentEnv, userId),
|
|
370
|
+
name: "inputPassword",
|
|
371
|
+
mask: "*",
|
|
372
|
+
prefix: void 0
|
|
373
|
+
}
|
|
374
|
+
]));
|
|
375
|
+
}
|
|
376
|
+
if (inputPassword || cachedPassword || cachedSecret) {
|
|
377
|
+
const authService = new import_ContensisAuthService.default({
|
|
378
|
+
username: userId,
|
|
379
|
+
password: inputPassword || cachedPassword,
|
|
380
|
+
projectId: (env == null ? void 0 : env.currentProject) || "website",
|
|
381
|
+
rootUrl: ((_c = this.urls) == null ? void 0 : _c.cms) || "",
|
|
382
|
+
clientId: userId,
|
|
383
|
+
clientSecret: sharedSecret || cachedSecret
|
|
384
|
+
});
|
|
385
|
+
const [authError, bearerToken] = await (0, import_await_to_js.default)(
|
|
386
|
+
authService.BearerToken()
|
|
387
|
+
);
|
|
388
|
+
if (bearerToken) {
|
|
389
|
+
env.authToken = bearerToken;
|
|
390
|
+
env.lastUserId = userId;
|
|
391
|
+
env.passwordFallback = credentials.remarks.secure !== true ? (_d = credentials.current) == null ? void 0 : _d.password : void 0;
|
|
392
|
+
this.session.UpdateEnv(env);
|
|
393
|
+
if (!silent) {
|
|
394
|
+
import_logger.Logger.success(messages.login.success(currentEnv, userId));
|
|
395
|
+
await this.PrintProjects();
|
|
396
|
+
}
|
|
397
|
+
if (inputPassword)
|
|
398
|
+
await credentials.Save(inputPassword);
|
|
399
|
+
if (sharedSecret)
|
|
400
|
+
await credentials.Save(sharedSecret);
|
|
401
|
+
} else if (authError) {
|
|
402
|
+
import_logger.Logger.error(authError.toString());
|
|
403
|
+
env.authToken = "";
|
|
404
|
+
env.lastUserId = "";
|
|
405
|
+
env.passwordFallback = void 0;
|
|
406
|
+
this.session.UpdateEnv(env);
|
|
407
|
+
if ((cachedPassword || cachedSecret) && credentials.remarks.secure) {
|
|
408
|
+
await credentials.Delete();
|
|
409
|
+
return await this.Login(userId, { password, sharedSecret });
|
|
410
|
+
} else {
|
|
411
|
+
throw new Error(messages.login.failed(currentEnv, userId));
|
|
412
|
+
}
|
|
400
413
|
}
|
|
414
|
+
return env.authToken;
|
|
415
|
+
} else {
|
|
416
|
+
import_logger.Logger.error(messages.login.passwordPrompt());
|
|
417
|
+
if (attempt < 2)
|
|
418
|
+
return await this.Login(userId, { attempt: attempt + 1 });
|
|
401
419
|
}
|
|
402
|
-
this.session.Update({
|
|
403
|
-
environments: cache.environments
|
|
404
|
-
});
|
|
405
|
-
return env.authToken;
|
|
406
|
-
} else {
|
|
407
|
-
import_logger.Logger.error(messages.login.passwordPrompt(currentEnv, userId));
|
|
408
420
|
}
|
|
409
421
|
} else {
|
|
410
422
|
import_logger.Logger.error(messages.login.noEnv());
|
|
@@ -413,37 +425,61 @@ Exiting contensis-cli with exit code: ${exitCode}
|
|
|
413
425
|
import_logger.Logger.error(messages.login.noUserId());
|
|
414
426
|
}
|
|
415
427
|
};
|
|
428
|
+
PrintContensisVersion = async () => {
|
|
429
|
+
const { log, messages } = this;
|
|
430
|
+
const contensis = await this.ConnectContensis();
|
|
431
|
+
if (contensis) {
|
|
432
|
+
const [projectsErr, projects] = await (0, import_await_to_js.default)(
|
|
433
|
+
contensis.projects.GetSourceProjects()
|
|
434
|
+
);
|
|
435
|
+
if (Array.isArray(projects)) {
|
|
436
|
+
this.HandleFormattingAndOutput(
|
|
437
|
+
contensis.contensisVersion,
|
|
438
|
+
() => log.raw(log.highlightText(contensis.contensisVersion))
|
|
439
|
+
);
|
|
440
|
+
}
|
|
441
|
+
if (projectsErr) {
|
|
442
|
+
log.error(messages.projects.noList());
|
|
443
|
+
log.error(projectsErr.message);
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
};
|
|
416
447
|
PrintProjects = async () => {
|
|
417
|
-
const {
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
if (this.contensis) {
|
|
448
|
+
const { currentProject, log, messages, session } = this;
|
|
449
|
+
const contensis = await this.ConnectContensis();
|
|
450
|
+
if (contensis) {
|
|
421
451
|
const [projectsErr, projects] = await (0, import_await_to_js.default)(
|
|
422
|
-
|
|
452
|
+
contensis.projects.GetSourceProjects()
|
|
423
453
|
);
|
|
424
454
|
if (Array.isArray(projects)) {
|
|
425
|
-
const currentVals = cache.environments[currentEnv] || {};
|
|
426
455
|
const nextCurrentProject = currentProject && currentProject !== "null" ? currentProject : projects.some((p) => p.id === "website") ? "website" : void 0;
|
|
427
|
-
|
|
428
|
-
...currentVals,
|
|
456
|
+
session.UpdateEnv({
|
|
429
457
|
projects: projects.map((p) => p.id),
|
|
430
458
|
currentProject: nextCurrentProject
|
|
431
|
-
};
|
|
459
|
+
});
|
|
432
460
|
log.success(messages.projects.list());
|
|
461
|
+
log.raw("");
|
|
433
462
|
this.HandleFormattingAndOutput(projects, () => {
|
|
434
|
-
for (const project of projects
|
|
463
|
+
for (const project of projects.sort(
|
|
464
|
+
(a, b) => a.id.localeCompare(b.id)
|
|
465
|
+
)) {
|
|
466
|
+
let color;
|
|
467
|
+
try {
|
|
468
|
+
color = import_chalk.default.keyword(project.color);
|
|
469
|
+
} catch (ex) {
|
|
470
|
+
color = import_chalk.default.white;
|
|
471
|
+
}
|
|
435
472
|
console.log(
|
|
436
|
-
|
|
473
|
+
`${nextCurrentProject === project.id ? `>> ${log.boldText(color(project.id))}` : ` ${color(project.id)}`} ${log.infoText(
|
|
474
|
+
`[${project.supportedLanguages.map(
|
|
475
|
+
(l) => l === project.primaryLanguage ? `*${log.boldText(l)}` : l
|
|
476
|
+
).join(" ")}]`
|
|
477
|
+
)}`
|
|
437
478
|
);
|
|
438
479
|
}
|
|
439
480
|
});
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
});
|
|
443
|
-
if (nextCurrentProject) {
|
|
444
|
-
this.env = cache.environments[currentEnv];
|
|
445
|
-
this.SetProject(nextCurrentProject);
|
|
446
|
-
}
|
|
481
|
+
if (!this.SetProject(nextCurrentProject))
|
|
482
|
+
log.warning(messages.projects.tip());
|
|
447
483
|
}
|
|
448
484
|
if (projectsErr) {
|
|
449
485
|
log.error(messages.projects.noList());
|
|
@@ -451,8 +487,28 @@ Exiting contensis-cli with exit code: ${exitCode}
|
|
|
451
487
|
}
|
|
452
488
|
}
|
|
453
489
|
};
|
|
454
|
-
|
|
455
|
-
const {
|
|
490
|
+
PrintProject = async (projectId = this.currentProject) => {
|
|
491
|
+
const { log, messages, session } = this;
|
|
492
|
+
const contensis = await this.ConnectContensis();
|
|
493
|
+
if (contensis) {
|
|
494
|
+
const [projectsErr, projects] = await (0, import_await_to_js.default)(
|
|
495
|
+
contensis.projects.GetSourceProjects()
|
|
496
|
+
);
|
|
497
|
+
const foundProject = projects == null ? void 0 : projects.find(
|
|
498
|
+
(p) => p.id.toLowerCase() === projectId.toLowerCase()
|
|
499
|
+
);
|
|
500
|
+
if (foundProject) {
|
|
501
|
+
log.raw("");
|
|
502
|
+
this.HandleFormattingAndOutput(foundProject, log.object);
|
|
503
|
+
}
|
|
504
|
+
if (projectsErr) {
|
|
505
|
+
log.error(messages.projects.noList());
|
|
506
|
+
log.error(projectsErr.message);
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
};
|
|
510
|
+
SetProject = (projectId = "website") => {
|
|
511
|
+
const { env, log, messages, session } = this;
|
|
456
512
|
let nextProjectId;
|
|
457
513
|
if ((env == null ? void 0 : env.projects.length) > 0 && (env == null ? void 0 : env.lastUserId)) {
|
|
458
514
|
nextProjectId = env.projects.find(
|
|
@@ -460,10 +516,9 @@ Exiting contensis-cli with exit code: ${exitCode}
|
|
|
460
516
|
);
|
|
461
517
|
if (nextProjectId) {
|
|
462
518
|
env.currentProject = nextProjectId;
|
|
463
|
-
session.
|
|
464
|
-
environments: cache.environments
|
|
465
|
-
});
|
|
519
|
+
session.UpdateEnv(env);
|
|
466
520
|
log.success(messages.projects.set(projectId));
|
|
521
|
+
log.raw("");
|
|
467
522
|
} else {
|
|
468
523
|
log.error(messages.projects.failedSet(projectId));
|
|
469
524
|
}
|
|
@@ -473,8 +528,8 @@ Exiting contensis-cli with exit code: ${exitCode}
|
|
|
473
528
|
}
|
|
474
529
|
return nextProjectId;
|
|
475
530
|
};
|
|
476
|
-
SetVersion =
|
|
477
|
-
const {
|
|
531
|
+
SetVersion = (versionStatus) => {
|
|
532
|
+
const { env, log, messages, session } = this;
|
|
478
533
|
if (!["latest", "published"].includes(versionStatus)) {
|
|
479
534
|
log.error(messages.version.invalid(versionStatus));
|
|
480
535
|
return false;
|
|
@@ -484,10 +539,7 @@ Exiting contensis-cli with exit code: ${exitCode}
|
|
|
484
539
|
return false;
|
|
485
540
|
}
|
|
486
541
|
if ((env == null ? void 0 : env.projects.length) > 0 && (env == null ? void 0 : env.lastUserId)) {
|
|
487
|
-
|
|
488
|
-
session.Update({
|
|
489
|
-
environments: cache.environments
|
|
490
|
-
});
|
|
542
|
+
session.UpdateEnv({ versionStatus });
|
|
491
543
|
log.success(messages.version.set(this.currentEnv, versionStatus));
|
|
492
544
|
return true;
|
|
493
545
|
} else {
|
|
@@ -498,11 +550,10 @@ Exiting contensis-cli with exit code: ${exitCode}
|
|
|
498
550
|
};
|
|
499
551
|
HydrateContensis = async () => {
|
|
500
552
|
const { log } = this;
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
if (this.contensis) {
|
|
553
|
+
const contensis = await this.ConnectContensis();
|
|
554
|
+
if (contensis) {
|
|
504
555
|
const [contensisErr, models] = await (0, import_await_to_js.default)(
|
|
505
|
-
|
|
556
|
+
contensis.models.HydrateContensisRepositories()
|
|
506
557
|
);
|
|
507
558
|
if (contensisErr) {
|
|
508
559
|
log.error(contensisErr.message);
|
|
@@ -512,10 +563,9 @@ Exiting contensis-cli with exit code: ${exitCode}
|
|
|
512
563
|
};
|
|
513
564
|
PrintApiKeys = async () => {
|
|
514
565
|
const { currentEnv, log, messages } = this;
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
const [keysErr, apiKeys] = await this.contensis.apiKeys.GetKeys();
|
|
566
|
+
const contensis = await this.ConnectContensis();
|
|
567
|
+
if (contensis) {
|
|
568
|
+
const [keysErr, apiKeys] = await contensis.apiKeys.GetKeys();
|
|
519
569
|
if (Array.isArray(apiKeys)) {
|
|
520
570
|
log.success(messages.keys.list(currentEnv));
|
|
521
571
|
this.HandleFormattingAndOutput(apiKeys, () => {
|
|
@@ -543,13 +593,9 @@ Exiting contensis-cli with exit code: ${exitCode}
|
|
|
543
593
|
};
|
|
544
594
|
CreateApiKey = async (name, description) => {
|
|
545
595
|
const { currentEnv, log, messages } = this;
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
const [err, key] = await this.contensis.apiKeys.CreateKey(
|
|
550
|
-
name,
|
|
551
|
-
description
|
|
552
|
-
);
|
|
596
|
+
const contensis = await this.ConnectContensis();
|
|
597
|
+
if (contensis) {
|
|
598
|
+
const [err, key] = await contensis.apiKeys.CreateKey(name, description);
|
|
553
599
|
if (key) {
|
|
554
600
|
log.success(messages.keys.created(currentEnv, name));
|
|
555
601
|
console.log(
|
|
@@ -566,10 +612,9 @@ Exiting contensis-cli with exit code: ${exitCode}
|
|
|
566
612
|
};
|
|
567
613
|
RemoveApiKey = async (id) => {
|
|
568
614
|
const { currentEnv, log, messages } = this;
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
const [err, key] = await this.contensis.apiKeys.RemoveKey(id);
|
|
615
|
+
const contensis = await this.ConnectContensis({ commit: true });
|
|
616
|
+
if (contensis) {
|
|
617
|
+
const [err, key] = await contensis.apiKeys.RemoveKey(id);
|
|
573
618
|
if (!err) {
|
|
574
619
|
log.success(messages.keys.removed(currentEnv, id));
|
|
575
620
|
console.log("");
|
|
@@ -578,18 +623,179 @@ Exiting contensis-cli with exit code: ${exitCode}
|
|
|
578
623
|
}
|
|
579
624
|
}
|
|
580
625
|
};
|
|
626
|
+
CreateProject = async (project) => {
|
|
627
|
+
const { currentEnv, log, messages } = this;
|
|
628
|
+
const contensis = await this.ConnectContensis();
|
|
629
|
+
if (contensis) {
|
|
630
|
+
const [err, created] = await contensis.projects.CreateProject(project);
|
|
631
|
+
if (created) {
|
|
632
|
+
log.success(messages.projects.created(currentEnv, project.id));
|
|
633
|
+
this.HandleFormattingAndOutput(created, () => {
|
|
634
|
+
this.SetProject(project.id);
|
|
635
|
+
this.PrintProjects();
|
|
636
|
+
});
|
|
637
|
+
return project.id;
|
|
638
|
+
}
|
|
639
|
+
if (err) {
|
|
640
|
+
log.error(messages.projects.failedCreate(currentEnv, project.id), err);
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
};
|
|
644
|
+
UpdateProject = async (project) => {
|
|
645
|
+
const { currentEnv, currentProject, log, messages } = this;
|
|
646
|
+
const contensis = await this.ConnectContensis();
|
|
647
|
+
if (contensis) {
|
|
648
|
+
const [err, updated] = await contensis.projects.UpdateProject({
|
|
649
|
+
id: currentProject,
|
|
650
|
+
...project
|
|
651
|
+
});
|
|
652
|
+
if (updated) {
|
|
653
|
+
log.success(messages.projects.updated(currentEnv, currentProject));
|
|
654
|
+
this.HandleFormattingAndOutput(updated, log.object);
|
|
655
|
+
return updated.id;
|
|
656
|
+
}
|
|
657
|
+
if (err) {
|
|
658
|
+
log.error(
|
|
659
|
+
messages.projects.failedUpdate(currentEnv, currentProject),
|
|
660
|
+
err
|
|
661
|
+
);
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
};
|
|
581
665
|
GetContentTypes = async () => {
|
|
582
666
|
const { currentProject, log, messages } = this;
|
|
583
667
|
let err;
|
|
584
668
|
if (!this.contensis)
|
|
585
669
|
err = await this.HydrateContensis();
|
|
586
670
|
if (err)
|
|
587
|
-
log.error(messages.
|
|
588
|
-
if (this.contensis)
|
|
589
|
-
|
|
590
|
-
|
|
671
|
+
log.error(messages.models.noList(currentProject));
|
|
672
|
+
if (!this.contensis)
|
|
673
|
+
log.warning(messages.models.noList(currentProject));
|
|
674
|
+
return this.contensis;
|
|
675
|
+
};
|
|
676
|
+
PrintContentModels = async (modelIds = []) => {
|
|
677
|
+
const { currentProject, log, messages } = this;
|
|
678
|
+
const contensis = await this.GetContentTypes();
|
|
679
|
+
if (contensis) {
|
|
680
|
+
const { models, contentTypes = [], components = [] } = this;
|
|
681
|
+
const returnModels = (modelIds == null ? void 0 : modelIds.length) ? models == null ? void 0 : models.filter(
|
|
682
|
+
(m) => modelIds.some((id) => id.toLowerCase() === m.id.toLowerCase())
|
|
683
|
+
) : void 0;
|
|
684
|
+
const contentTypeIds = Array.from(
|
|
685
|
+
/* @__PURE__ */ new Set([
|
|
686
|
+
...(returnModels || models || []).map((m) => m.id),
|
|
687
|
+
...(returnModels || models || []).map((m) => {
|
|
688
|
+
var _a, _b;
|
|
689
|
+
return ((_b = (_a = m.dependencies) == null ? void 0 : _a.contentTypes) == null ? void 0 : _b.map((c) => c[0])) || [];
|
|
690
|
+
}).flat()
|
|
691
|
+
])
|
|
692
|
+
);
|
|
693
|
+
const componentIds = Array.from(
|
|
694
|
+
new Set(
|
|
695
|
+
(returnModels || models || []).map((m) => {
|
|
696
|
+
var _a, _b;
|
|
697
|
+
return ((_b = (_a = m.dependencies) == null ? void 0 : _a.components) == null ? void 0 : _b.map((c) => c[0])) || [];
|
|
698
|
+
}).flat()
|
|
699
|
+
)
|
|
700
|
+
);
|
|
701
|
+
const contentModelBackup = [
|
|
702
|
+
...contentTypes.filter((c) => contentTypeIds.includes(c.id)),
|
|
703
|
+
...components.filter((c) => componentIds.includes(c.id))
|
|
704
|
+
];
|
|
705
|
+
if (Array.isArray(returnModels)) {
|
|
706
|
+
log.success(messages.models.list(currentProject));
|
|
707
|
+
this.HandleFormattingAndOutput(contentModelBackup, () => {
|
|
708
|
+
for (const model of returnModels) {
|
|
709
|
+
log.raw("");
|
|
710
|
+
log.object(model);
|
|
711
|
+
}
|
|
712
|
+
log.raw("");
|
|
713
|
+
});
|
|
714
|
+
} else {
|
|
715
|
+
log.success(
|
|
716
|
+
messages.models.get(currentProject, (models == null ? void 0 : models.length.toString()) || "0")
|
|
717
|
+
);
|
|
718
|
+
log.raw("");
|
|
719
|
+
if (models == null ? void 0 : models.length) {
|
|
720
|
+
this.HandleFormattingAndOutput(contentModelBackup, () => {
|
|
721
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
722
|
+
for (const model of models) {
|
|
723
|
+
const components2 = ((_a = model.components) == null ? void 0 : _a.length) || 0;
|
|
724
|
+
const contentTypes2 = ((_b = model.contentTypes) == null ? void 0 : _b.length) || 0;
|
|
725
|
+
const dependencies = (((_d = (_c = model.dependencies) == null ? void 0 : _c.components) == null ? void 0 : _d.length) || 0) + (((_f = (_e = model.dependencies) == null ? void 0 : _e.contentTypes) == null ? void 0 : _f.length) || 0);
|
|
726
|
+
const dependencyOf = (((_h = (_g = model.dependencyOf) == null ? void 0 : _g.components) == null ? void 0 : _h.length) || 0) + (((_j = (_i = model.dependencyOf) == null ? void 0 : _i.contentTypes) == null ? void 0 : _j.length) || 0);
|
|
727
|
+
const hasAny = components2 + contentTypes2 + dependencies + dependencyOf;
|
|
728
|
+
log.raw(
|
|
729
|
+
` - ${log.highlightText(log.boldText(model.id))} ${hasAny ? log.infoText(
|
|
730
|
+
`{ ${components2 ? `components: ${components2}, ` : ""}${contentTypes2 ? `contentTypes: ${contentTypes2}, ` : ""}${dependencies ? `references: ${dependencies}, ` : ""}${dependencyOf ? `required by: ${dependencyOf}` : ""} }`
|
|
731
|
+
) : ""}`
|
|
732
|
+
);
|
|
733
|
+
}
|
|
734
|
+
log.raw("");
|
|
735
|
+
});
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
};
|
|
740
|
+
ImportContentModels = async ({
|
|
741
|
+
commit,
|
|
742
|
+
fromFile
|
|
743
|
+
}) => {
|
|
744
|
+
const { currentProject, log, messages } = this;
|
|
745
|
+
const fileData = fromFile ? (0, import_file_provider.readJsonFile)(fromFile) || [] : [];
|
|
746
|
+
if (typeof fileData === "string")
|
|
747
|
+
throw new Error(`Import file format must be of type JSON`);
|
|
748
|
+
const contensis = await this.ConnectContensisImport({
|
|
749
|
+
commit,
|
|
750
|
+
fromFile,
|
|
751
|
+
importDataType: "models"
|
|
752
|
+
});
|
|
753
|
+
if (contensis) {
|
|
754
|
+
log.line();
|
|
755
|
+
if (contensis.isPreview) {
|
|
756
|
+
console.log(log.successText(` -- IMPORT PREVIEW -- `));
|
|
757
|
+
} else {
|
|
758
|
+
console.log(log.warningText(` *** COMMITTING IMPORT *** `));
|
|
759
|
+
}
|
|
760
|
+
const [migrateErr, result] = await contensis.MigrateContentModels();
|
|
761
|
+
if (migrateErr)
|
|
762
|
+
(0, import_logger.logError)(migrateErr);
|
|
763
|
+
else
|
|
764
|
+
this.HandleFormattingAndOutput(result, () => {
|
|
765
|
+
if (!commit) {
|
|
766
|
+
log.raw(log.boldText(`
|
|
767
|
+
Content types:`));
|
|
768
|
+
if (!result.contentTypes)
|
|
769
|
+
log.info(`- None returned
|
|
770
|
+
`);
|
|
771
|
+
else
|
|
772
|
+
(0, import_console.printModelMigrationAnalysis)(this, result.contentTypes);
|
|
773
|
+
log.raw(log.boldText(`
|
|
774
|
+
Components:`));
|
|
775
|
+
if (!result.components)
|
|
776
|
+
log.info(`- None returned
|
|
777
|
+
`);
|
|
778
|
+
else
|
|
779
|
+
(0, import_console.printModelMigrationAnalysis)(this, result.components);
|
|
780
|
+
} else {
|
|
781
|
+
const migrateResult = result;
|
|
782
|
+
log.raw(log.boldText(`
|
|
783
|
+
Content types:`));
|
|
784
|
+
(0, import_console.printModelMigrationResult)(
|
|
785
|
+
this,
|
|
786
|
+
migrateResult[currentProject].contentTypes
|
|
787
|
+
);
|
|
788
|
+
log.raw(log.boldText(`
|
|
789
|
+
Components:`));
|
|
790
|
+
(0, import_console.printModelMigrationResult)(
|
|
791
|
+
this,
|
|
792
|
+
migrateResult[currentProject].components
|
|
793
|
+
);
|
|
794
|
+
}
|
|
795
|
+
});
|
|
591
796
|
} else {
|
|
592
|
-
log.warning(messages.
|
|
797
|
+
log.warning(messages.models.noList(currentProject));
|
|
798
|
+
log.help(messages.connect.tip());
|
|
593
799
|
}
|
|
594
800
|
};
|
|
595
801
|
PrintContentTypes = async () => {
|
|
@@ -635,15 +841,12 @@ Exiting contensis-cli with exit code: ${exitCode}
|
|
|
635
841
|
};
|
|
636
842
|
RemoveContentTypes = async (contentTypeIds, commit = false) => {
|
|
637
843
|
const { currentProject, log, messages } = this;
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
const [err, result] = await this.contensis.DeleteContentTypes(
|
|
645
|
-
contentTypeIds
|
|
646
|
-
);
|
|
844
|
+
const contensis = await this.ConnectContensisImport({
|
|
845
|
+
commit,
|
|
846
|
+
importDataType: "user-input"
|
|
847
|
+
});
|
|
848
|
+
if (contensis) {
|
|
849
|
+
const [err, result] = await contensis.DeleteContentTypes(contentTypeIds);
|
|
647
850
|
if (err) {
|
|
648
851
|
log.error(
|
|
649
852
|
messages.contenttypes.failedRemove(
|
|
@@ -657,7 +860,7 @@ Exiting contensis-cli with exit code: ${exitCode}
|
|
|
657
860
|
messages.contenttypes.removed(
|
|
658
861
|
currentProject,
|
|
659
862
|
contentTypeIds.join('", "'),
|
|
660
|
-
!
|
|
863
|
+
!contensis.isPreview
|
|
661
864
|
)
|
|
662
865
|
);
|
|
663
866
|
this.HandleFormattingAndOutput(
|
|
@@ -677,15 +880,15 @@ Exiting contensis-cli with exit code: ${exitCode}
|
|
|
677
880
|
throw new Error(`Import file format must be of type JSON`);
|
|
678
881
|
if (!Array.isArray(fileData))
|
|
679
882
|
fileData = [fileData];
|
|
680
|
-
await this.ConnectContensisImport({
|
|
883
|
+
const contensis = await this.ConnectContensisImport({
|
|
681
884
|
commit,
|
|
682
|
-
|
|
885
|
+
importDataType: fromFile ? "user-input" : void 0
|
|
683
886
|
});
|
|
684
|
-
if (
|
|
887
|
+
if (contensis) {
|
|
685
888
|
for (const contentType of fileData) {
|
|
686
889
|
contentType.projectId = currentProject;
|
|
687
890
|
delete contentType.uuid;
|
|
688
|
-
const [err, created, createStatus] = await
|
|
891
|
+
const [err, created, createStatus] = await contensis.models.targetRepos[currentProject].repo.UpsertContentType(false, contentType);
|
|
689
892
|
if (err)
|
|
690
893
|
log.error(err.message, err);
|
|
691
894
|
if (createStatus) {
|
|
@@ -702,6 +905,49 @@ Exiting contensis-cli with exit code: ${exitCode}
|
|
|
702
905
|
}
|
|
703
906
|
}
|
|
704
907
|
};
|
|
908
|
+
DiffModels = async ({
|
|
909
|
+
fromFile
|
|
910
|
+
}, modelIds = []) => {
|
|
911
|
+
const { log } = this;
|
|
912
|
+
let fileData = fromFile ? (0, import_file_provider.readJsonFile)(fromFile) || [] : [];
|
|
913
|
+
if (typeof fileData === "string")
|
|
914
|
+
throw new Error(`Import file format must be of type JSON`);
|
|
915
|
+
if (!Array.isArray(fileData))
|
|
916
|
+
fileData = [fileData];
|
|
917
|
+
const contensis = await this.ConnectContensisImport({
|
|
918
|
+
fromFile,
|
|
919
|
+
importDataType: "models"
|
|
920
|
+
});
|
|
921
|
+
if (contensis) {
|
|
922
|
+
const [err, result] = await (0, import_await_to_js.default)(
|
|
923
|
+
contensis.models.Diff(fileData.length ? fileData : modelIds)
|
|
924
|
+
);
|
|
925
|
+
if (err)
|
|
926
|
+
log.error(err.message, err);
|
|
927
|
+
if (result)
|
|
928
|
+
this.HandleFormattingAndOutput(result, () => {
|
|
929
|
+
var _a;
|
|
930
|
+
log.success(
|
|
931
|
+
`Queried models ${log.infoText(
|
|
932
|
+
`"${(_a = result.query.modelIds) == null ? void 0 : _a.join(", ")}"`
|
|
933
|
+
)}
|
|
934
|
+
`
|
|
935
|
+
);
|
|
936
|
+
log.raw(log.boldText(`Content types:`));
|
|
937
|
+
if (!result.contentTypes)
|
|
938
|
+
log.info(`- None returned
|
|
939
|
+
`);
|
|
940
|
+
else
|
|
941
|
+
(0, import_console.printModelMigrationAnalysis)(this, result.contentTypes);
|
|
942
|
+
log.raw(log.boldText(`Components:`));
|
|
943
|
+
if (!result.components)
|
|
944
|
+
log.info(`- None returned
|
|
945
|
+
`);
|
|
946
|
+
else
|
|
947
|
+
(0, import_console.printModelMigrationAnalysis)(this, result.components);
|
|
948
|
+
});
|
|
949
|
+
}
|
|
950
|
+
};
|
|
705
951
|
PrintComponents = async () => {
|
|
706
952
|
const { currentProject, log, messages } = this;
|
|
707
953
|
await this.GetContentTypes();
|
|
@@ -741,13 +987,12 @@ Exiting contensis-cli with exit code: ${exitCode}
|
|
|
741
987
|
};
|
|
742
988
|
RemoveComponents = async (componentIds, commit = false) => {
|
|
743
989
|
const { currentProject, log, messages } = this;
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
const [err, result] = await this.contensis.DeleteContentTypes(
|
|
990
|
+
const contensis = await this.ConnectContensisImport({
|
|
991
|
+
commit,
|
|
992
|
+
importDataType: "user-input"
|
|
993
|
+
});
|
|
994
|
+
if (contensis) {
|
|
995
|
+
const [err, result] = await contensis.DeleteContentTypes(
|
|
751
996
|
void 0,
|
|
752
997
|
componentIds
|
|
753
998
|
);
|
|
@@ -764,7 +1009,7 @@ Exiting contensis-cli with exit code: ${exitCode}
|
|
|
764
1009
|
messages.components.removed(
|
|
765
1010
|
currentProject,
|
|
766
1011
|
componentIds.join('", "'),
|
|
767
|
-
!
|
|
1012
|
+
!contensis.isPreview
|
|
768
1013
|
)
|
|
769
1014
|
);
|
|
770
1015
|
this.HandleFormattingAndOutput(
|
|
@@ -784,15 +1029,15 @@ Exiting contensis-cli with exit code: ${exitCode}
|
|
|
784
1029
|
throw new Error(`Import file format must be of type JSON`);
|
|
785
1030
|
if (!Array.isArray(fileData))
|
|
786
1031
|
fileData = [fileData];
|
|
787
|
-
await this.ConnectContensisImport({
|
|
1032
|
+
const contensis = await this.ConnectContensisImport({
|
|
788
1033
|
commit,
|
|
789
|
-
|
|
1034
|
+
importDataType: fromFile ? "user-input" : void 0
|
|
790
1035
|
});
|
|
791
|
-
if (
|
|
1036
|
+
if (contensis) {
|
|
792
1037
|
for (const component of fileData) {
|
|
793
1038
|
component.projectId = currentProject;
|
|
794
1039
|
delete component.uuid;
|
|
795
|
-
const [err, created, createStatus] = await
|
|
1040
|
+
const [err, created, createStatus] = await contensis.models.targetRepos[currentProject].repo.UpsertComponent(false, component);
|
|
796
1041
|
if (err)
|
|
797
1042
|
log.error(err.message, err);
|
|
798
1043
|
if (createStatus) {
|
|
@@ -809,33 +1054,32 @@ Exiting contensis-cli with exit code: ${exitCode}
|
|
|
809
1054
|
}
|
|
810
1055
|
}
|
|
811
1056
|
};
|
|
812
|
-
|
|
1057
|
+
RemoveEntries = async (commit = false) => {
|
|
813
1058
|
var _a, _b, _c;
|
|
814
1059
|
const { currentEnv, log, messages } = this;
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
if (this.contensis.isPreview) {
|
|
1060
|
+
const contensis = await this.ConnectContensisImport({
|
|
1061
|
+
commit,
|
|
1062
|
+
importDataType: "user-input"
|
|
1063
|
+
});
|
|
1064
|
+
if (contensis) {
|
|
1065
|
+
if (contensis.isPreview) {
|
|
822
1066
|
console.log(log.successText(` -- PREVIEW -- `));
|
|
823
1067
|
} else {
|
|
824
1068
|
console.log(log.warningText(` *** COMMITTING DELETE *** `));
|
|
825
1069
|
}
|
|
826
|
-
const [err, result] = await
|
|
1070
|
+
const [err, result] = await contensis.DeleteEntries();
|
|
827
1071
|
if (result)
|
|
828
1072
|
this.HandleFormattingAndOutput(result, () => {
|
|
829
1073
|
(0, import_console.printMigrateResult)(this, result, { action: "delete" });
|
|
830
1074
|
});
|
|
831
1075
|
if (!err && (!commit && ((_a = Object.values(result.entriesToMigrate)) == null ? void 0 : _a[0].totalCount) > 0 || commit && ((_b = result.migrateResult) == null ? void 0 : _b.deleted))) {
|
|
832
|
-
log.success(messages.entries.removed(currentEnv,
|
|
1076
|
+
log.success(messages.entries.removed(currentEnv, commit));
|
|
833
1077
|
if (!commit)
|
|
834
1078
|
log.help(messages.entries.commitTip());
|
|
835
1079
|
} else {
|
|
836
|
-
log.error(messages.entries.failedRemove(currentEnv
|
|
1080
|
+
log.error(messages.entries.failedRemove(currentEnv), err);
|
|
837
1081
|
if (!((_c = Object.values(result.entriesToMigrate)) == null ? void 0 : _c[0].totalCount))
|
|
838
|
-
log.help(messages.entries.notFound(
|
|
1082
|
+
log.help(messages.entries.notFound(currentEnv));
|
|
839
1083
|
}
|
|
840
1084
|
}
|
|
841
1085
|
};
|
|
@@ -843,23 +1087,23 @@ Exiting contensis-cli with exit code: ${exitCode}
|
|
|
843
1087
|
withDependents = false
|
|
844
1088
|
}) => {
|
|
845
1089
|
const { currentProject, log, messages } = this;
|
|
846
|
-
await this.ConnectContensis();
|
|
847
|
-
if (
|
|
1090
|
+
const contensis = await this.ConnectContensis();
|
|
1091
|
+
if (contensis) {
|
|
848
1092
|
log.line();
|
|
849
|
-
const entries = await
|
|
1093
|
+
const entries = await contensis.GetEntries({ withDependents });
|
|
850
1094
|
this.HandleFormattingAndOutput(
|
|
851
1095
|
entries,
|
|
852
1096
|
() => {
|
|
853
|
-
var _a
|
|
1097
|
+
var _a;
|
|
854
1098
|
return (0, import_migratortron.logEntriesTable)(
|
|
855
1099
|
entries,
|
|
856
1100
|
currentProject,
|
|
857
|
-
(
|
|
1101
|
+
(_a = contensis.payload.query) == null ? void 0 : _a.fields
|
|
858
1102
|
);
|
|
859
1103
|
}
|
|
860
1104
|
);
|
|
861
1105
|
} else {
|
|
862
|
-
log.warning(messages.
|
|
1106
|
+
log.warning(messages.models.noList(currentProject));
|
|
863
1107
|
log.help(messages.connect.tip());
|
|
864
1108
|
}
|
|
865
1109
|
};
|
|
@@ -868,23 +1112,19 @@ Exiting contensis-cli with exit code: ${exitCode}
|
|
|
868
1112
|
fromFile
|
|
869
1113
|
}) => {
|
|
870
1114
|
const { currentProject, log, messages } = this;
|
|
871
|
-
const
|
|
872
|
-
if (typeof fileData === "string")
|
|
873
|
-
throw new Error(`Import file format must be of type JSON`);
|
|
874
|
-
await this.ConnectContensisImport({
|
|
1115
|
+
const contensis = await this.ConnectContensisImport({
|
|
875
1116
|
commit,
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
fileDataType: "entries"
|
|
1117
|
+
fromFile,
|
|
1118
|
+
importDataType: "entries"
|
|
879
1119
|
});
|
|
880
|
-
if (
|
|
1120
|
+
if (contensis) {
|
|
881
1121
|
log.line();
|
|
882
|
-
if (
|
|
1122
|
+
if (contensis.isPreview) {
|
|
883
1123
|
console.log(log.successText(` -- IMPORT PREVIEW -- `));
|
|
884
1124
|
} else {
|
|
885
1125
|
console.log(log.warningText(` *** COMMITTING IMPORT *** `));
|
|
886
1126
|
}
|
|
887
|
-
const [migrateErr, migrateResult] = await
|
|
1127
|
+
const [migrateErr, migrateResult] = await contensis.MigrateEntries();
|
|
888
1128
|
if (migrateErr)
|
|
889
1129
|
(0, import_logger.logError)(migrateErr);
|
|
890
1130
|
else
|
|
@@ -892,22 +1132,21 @@ Exiting contensis-cli with exit code: ${exitCode}
|
|
|
892
1132
|
(0, import_console.printMigrateResult)(this, migrateResult);
|
|
893
1133
|
});
|
|
894
1134
|
} else {
|
|
895
|
-
log.warning(messages.
|
|
1135
|
+
log.warning(messages.models.noList(currentProject));
|
|
896
1136
|
log.help(messages.connect.tip());
|
|
897
1137
|
}
|
|
898
1138
|
};
|
|
899
1139
|
PrintWebhookSubscriptions = async (subscriptionIds, name) => {
|
|
900
1140
|
const { currentEnv, log, messages } = this;
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
const
|
|
905
|
-
const filteredResults = typeof name === "string" ? webhooks.filter(
|
|
1141
|
+
const contensis = await this.ConnectContensis();
|
|
1142
|
+
if (contensis) {
|
|
1143
|
+
const [webhooksErr, webhooks] = await contensis.subscriptions.webhooks.GetSubscriptions();
|
|
1144
|
+
const filteredResults = typeof name === "string" ? webhooks == null ? void 0 : webhooks.filter(
|
|
906
1145
|
(w) => {
|
|
907
1146
|
var _a;
|
|
908
1147
|
return (_a = w.name) == null ? void 0 : _a.toLowerCase().includes(name.toLowerCase());
|
|
909
1148
|
}
|
|
910
|
-
) : Array.isArray(subscriptionIds) ? webhooks.filter((w) => subscriptionIds == null ? void 0 : subscriptionIds.some((id) => id === w.id)) : webhooks;
|
|
1149
|
+
) : Array.isArray(subscriptionIds) ? webhooks == null ? void 0 : webhooks.filter((w) => subscriptionIds == null ? void 0 : subscriptionIds.some((id) => id === w.id)) : webhooks;
|
|
911
1150
|
if (Array.isArray(filteredResults)) {
|
|
912
1151
|
this.HandleFormattingAndOutput(filteredResults, () => {
|
|
913
1152
|
log.success(messages.webhooks.list(currentEnv));
|
|
@@ -935,14 +1174,13 @@ Exiting contensis-cli with exit code: ${exitCode}
|
|
|
935
1174
|
}
|
|
936
1175
|
};
|
|
937
1176
|
PrintBlocks = async () => {
|
|
938
|
-
const { currentEnv, log, messages } = this;
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
const [err, blocks] = await this.contensis.blocks.GetBlocks();
|
|
1177
|
+
const { currentEnv, env, log, messages } = this;
|
|
1178
|
+
const contensis = await this.ConnectContensis();
|
|
1179
|
+
if (contensis) {
|
|
1180
|
+
const [err, blocks] = await contensis.blocks.GetBlocks();
|
|
943
1181
|
if (Array.isArray(blocks)) {
|
|
944
1182
|
this.HandleFormattingAndOutput(blocks, () => {
|
|
945
|
-
log.success(messages.blocks.list(currentEnv));
|
|
1183
|
+
log.success(messages.blocks.list(currentEnv, env.currentProject));
|
|
946
1184
|
for (const {
|
|
947
1185
|
id,
|
|
948
1186
|
description,
|
|
@@ -969,10 +1207,9 @@ Exiting contensis-cli with exit code: ${exitCode}
|
|
|
969
1207
|
};
|
|
970
1208
|
PrintBlockVersions = async (blockId, branch, version) => {
|
|
971
1209
|
const { currentEnv, env, log, messages } = this;
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
const [err, blocks] = await this.contensis.blocks.GetBlockVersions(
|
|
1210
|
+
const contensis = await this.ConnectContensis();
|
|
1211
|
+
if (contensis) {
|
|
1212
|
+
const [err, blocks] = await contensis.blocks.GetBlockVersions(
|
|
976
1213
|
blockId,
|
|
977
1214
|
branch,
|
|
978
1215
|
version
|
|
@@ -980,7 +1217,7 @@ Exiting contensis-cli with exit code: ${exitCode}
|
|
|
980
1217
|
if (blocks) {
|
|
981
1218
|
this.HandleFormattingAndOutput(blocks, () => {
|
|
982
1219
|
log.success(
|
|
983
|
-
messages.blocks.get(
|
|
1220
|
+
messages.blocks.get(blockId, currentEnv, env.currentProject)
|
|
984
1221
|
);
|
|
985
1222
|
for (const block of blocks)
|
|
986
1223
|
(0, import_console.printBlockVersion)(
|
|
@@ -1003,17 +1240,18 @@ Exiting contensis-cli with exit code: ${exitCode}
|
|
|
1003
1240
|
};
|
|
1004
1241
|
PushBlock = async (block) => {
|
|
1005
1242
|
const { currentEnv, env, log, messages } = this;
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1243
|
+
log.info(
|
|
1244
|
+
messages.blocks.tryPush(
|
|
1245
|
+
block.id,
|
|
1246
|
+
block.source.branch,
|
|
1247
|
+
currentEnv,
|
|
1248
|
+
env.currentProject
|
|
1249
|
+
)
|
|
1011
1250
|
);
|
|
1012
1251
|
console.log((0, import_json.jsonFormatter)(block));
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
const [err, blockVersion] = await this.contensis.blocks.PushBlockVersion(
|
|
1252
|
+
const contensis = await this.ConnectContensis();
|
|
1253
|
+
if (contensis) {
|
|
1254
|
+
const [err, blockVersion] = await contensis.blocks.PushBlockVersion(
|
|
1017
1255
|
block
|
|
1018
1256
|
);
|
|
1019
1257
|
if (!err) {
|
|
@@ -1025,7 +1263,6 @@ Exiting contensis-cli with exit code: ${exitCode}
|
|
|
1025
1263
|
env.currentProject
|
|
1026
1264
|
)
|
|
1027
1265
|
);
|
|
1028
|
-
console.log((0, import_json.jsonFormatter)(blockVersion));
|
|
1029
1266
|
}
|
|
1030
1267
|
if (blockVersion) {
|
|
1031
1268
|
this.HandleFormattingAndOutput(blockVersion, () => {
|
|
@@ -1038,12 +1275,39 @@ Exiting contensis-cli with exit code: ${exitCode}
|
|
|
1038
1275
|
);
|
|
1039
1276
|
}
|
|
1040
1277
|
};
|
|
1278
|
+
ReleaseBlock = async (blockId, version) => {
|
|
1279
|
+
const { currentEnv, env, log, messages } = this;
|
|
1280
|
+
const contensis = await this.ConnectContensis();
|
|
1281
|
+
if (contensis) {
|
|
1282
|
+
const [err, blockVersion] = await contensis.blocks.BlockAction(
|
|
1283
|
+
blockId,
|
|
1284
|
+
"release",
|
|
1285
|
+
version
|
|
1286
|
+
);
|
|
1287
|
+
if (blockVersion) {
|
|
1288
|
+
this.HandleFormattingAndOutput(blockVersion, () => {
|
|
1289
|
+
log.success(
|
|
1290
|
+
messages.blocks.released(blockId, currentEnv, env.currentProject)
|
|
1291
|
+
);
|
|
1292
|
+
(0, import_console.printBlockVersion)(this, blockVersion);
|
|
1293
|
+
});
|
|
1294
|
+
}
|
|
1295
|
+
if (err) {
|
|
1296
|
+
log.error(
|
|
1297
|
+
messages.blocks.failedRelease(blockId, currentEnv, env.currentProject)
|
|
1298
|
+
);
|
|
1299
|
+
log.error((0, import_json.jsonFormatter)(err));
|
|
1300
|
+
}
|
|
1301
|
+
}
|
|
1302
|
+
};
|
|
1041
1303
|
PrintBlockLogs = async (blockId, branch, version, dataCenter) => {
|
|
1042
|
-
const { currentEnv, log, messages } = this;
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1304
|
+
const { currentEnv, env, log, messages } = this;
|
|
1305
|
+
const contensis = await this.ConnectContensis();
|
|
1306
|
+
if (contensis) {
|
|
1307
|
+
log.success(
|
|
1308
|
+
messages.blocks.getLogs(blockId, branch, currentEnv, env.currentProject)
|
|
1309
|
+
);
|
|
1310
|
+
const [err, blockLogs] = await contensis.blocks.GetBlockLogs({
|
|
1047
1311
|
blockId,
|
|
1048
1312
|
branchId: branch,
|
|
1049
1313
|
version,
|
|
@@ -1051,7 +1315,6 @@ Exiting contensis-cli with exit code: ${exitCode}
|
|
|
1051
1315
|
});
|
|
1052
1316
|
if (blockLogs) {
|
|
1053
1317
|
this.HandleFormattingAndOutput(blockLogs, () => {
|
|
1054
|
-
log.success(messages.blocks.list(currentEnv));
|
|
1055
1318
|
console.log(
|
|
1056
1319
|
` - ${blockId} ${branch} ${Number(version) ? `v${version}` : version} [${dataCenter}]`
|
|
1057
1320
|
);
|
|
@@ -1061,13 +1324,28 @@ Exiting contensis-cli with exit code: ${exitCode}
|
|
|
1061
1324
|
});
|
|
1062
1325
|
}
|
|
1063
1326
|
if (err) {
|
|
1064
|
-
log.error(
|
|
1327
|
+
log.error(
|
|
1328
|
+
messages.blocks.failedGetLogs(blockId, currentEnv, env.currentProject)
|
|
1329
|
+
);
|
|
1065
1330
|
log.error((0, import_json.jsonFormatter)(err));
|
|
1066
1331
|
}
|
|
1067
1332
|
}
|
|
1068
1333
|
};
|
|
1069
1334
|
HandleFormattingAndOutput = (obj, logFn) => {
|
|
1070
1335
|
const { format, log, messages, output } = this;
|
|
1336
|
+
if (!format) {
|
|
1337
|
+
logFn(obj);
|
|
1338
|
+
} else if (format === "csv") {
|
|
1339
|
+
log.raw("");
|
|
1340
|
+
log.raw(log.infoText((0, import_csv.csvFormatter)(obj)));
|
|
1341
|
+
} else if (format === "xml") {
|
|
1342
|
+
log.raw("");
|
|
1343
|
+
log.raw(log.infoText((0, import_xml.xmlFormatter)(obj)));
|
|
1344
|
+
} else if (format === "json") {
|
|
1345
|
+
log.raw("");
|
|
1346
|
+
log.raw(log.infoText((0, import_json.jsonFormatter)(obj)));
|
|
1347
|
+
}
|
|
1348
|
+
log.raw("");
|
|
1071
1349
|
if (output) {
|
|
1072
1350
|
let writeString = "";
|
|
1073
1351
|
if (format === "csv") {
|
|
@@ -1082,20 +1360,6 @@ Exiting contensis-cli with exit code: ${exitCode}
|
|
|
1082
1360
|
} else {
|
|
1083
1361
|
log.info(messages.app.noFileOutput());
|
|
1084
1362
|
}
|
|
1085
|
-
} else {
|
|
1086
|
-
if (!format) {
|
|
1087
|
-
logFn(obj);
|
|
1088
|
-
} else if (format === "csv") {
|
|
1089
|
-
log.raw("");
|
|
1090
|
-
log.raw(log.infoText((0, import_csv.csvFormatter)(obj)));
|
|
1091
|
-
} else if (format === "xml") {
|
|
1092
|
-
log.raw("");
|
|
1093
|
-
log.raw(log.infoText((0, import_xml.xmlFormatter)(obj)));
|
|
1094
|
-
} else if (format === "json") {
|
|
1095
|
-
log.raw("");
|
|
1096
|
-
log.raw(log.infoText((0, import_json.jsonFormatter)(obj)));
|
|
1097
|
-
}
|
|
1098
|
-
log.raw("");
|
|
1099
1363
|
}
|
|
1100
1364
|
};
|
|
1101
1365
|
}
|