contensis-cli 1.0.0-beta.8 → 1.0.0-beta.80

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.
Files changed (81) hide show
  1. package/README.md +1146 -78
  2. package/dist/commands/connect.js +3 -3
  3. package/dist/commands/connect.js.map +2 -2
  4. package/dist/commands/create.js +45 -10
  5. package/dist/commands/create.js.map +2 -2
  6. package/dist/commands/diff.js +57 -0
  7. package/dist/commands/diff.js.map +7 -0
  8. package/dist/commands/execute.js +103 -0
  9. package/dist/commands/execute.js.map +7 -0
  10. package/dist/commands/get.js +107 -18
  11. package/dist/commands/get.js.map +2 -2
  12. package/dist/commands/globalOptions.js +22 -17
  13. package/dist/commands/globalOptions.js.map +2 -2
  14. package/dist/commands/import.js +46 -11
  15. package/dist/commands/import.js.map +2 -2
  16. package/dist/commands/index.js +16 -2
  17. package/dist/commands/index.js.map +2 -2
  18. package/dist/commands/list.js +53 -10
  19. package/dist/commands/list.js.map +2 -2
  20. package/dist/commands/login.js +3 -3
  21. package/dist/commands/login.js.map +2 -2
  22. package/dist/commands/push.js +9 -5
  23. package/dist/commands/push.js.map +2 -2
  24. package/dist/commands/remove.js +51 -8
  25. package/dist/commands/remove.js.map +2 -2
  26. package/dist/commands/set.js +139 -12
  27. package/dist/commands/set.js.map +2 -2
  28. package/dist/index.js +1 -1
  29. package/dist/index.js.map +2 -2
  30. package/dist/localisation/en-GB.js +193 -49
  31. package/dist/localisation/en-GB.js.map +2 -2
  32. package/dist/providers/CredentialProvider.js +36 -7
  33. package/dist/providers/CredentialProvider.js.map +3 -3
  34. package/dist/providers/SessionCacheProvider.js +21 -1
  35. package/dist/providers/SessionCacheProvider.js.map +2 -2
  36. package/dist/providers/file-provider.js +8 -4
  37. package/dist/providers/file-provider.js.map +3 -3
  38. package/dist/services/ContensisCliService.js +1092 -410
  39. package/dist/services/ContensisCliService.js.map +3 -3
  40. package/dist/shell.js +48 -14
  41. package/dist/shell.js.map +3 -3
  42. package/dist/util/console.printer.js +171 -55
  43. package/dist/util/console.printer.js.map +2 -2
  44. package/dist/util/diff.js +39 -0
  45. package/dist/util/diff.js.map +7 -0
  46. package/dist/util/index.js +8 -2
  47. package/dist/util/index.js.map +3 -3
  48. package/dist/util/logger.js +61 -29
  49. package/dist/util/logger.js.map +3 -3
  50. package/dist/util/timers.js +49 -0
  51. package/dist/util/timers.js.map +7 -0
  52. package/dist/version.js +1 -1
  53. package/dist/version.js.map +1 -1
  54. package/esbuild.config.js +3 -1
  55. package/package.json +2 -2
  56. package/src/commands/connect.ts +3 -2
  57. package/src/commands/create.ts +61 -8
  58. package/src/commands/diff.ts +41 -0
  59. package/src/commands/execute.ts +117 -0
  60. package/src/commands/get.ts +150 -14
  61. package/src/commands/globalOptions.ts +18 -17
  62. package/src/commands/import.ts +57 -7
  63. package/src/commands/index.ts +16 -1
  64. package/src/commands/list.ts +85 -11
  65. package/src/commands/login.ts +3 -2
  66. package/src/commands/push.ts +10 -3
  67. package/src/commands/remove.ts +66 -4
  68. package/src/commands/set.ts +189 -9
  69. package/src/index.ts +1 -4
  70. package/src/localisation/en-GB.ts +269 -66
  71. package/src/providers/CredentialProvider.ts +39 -6
  72. package/src/providers/SessionCacheProvider.ts +29 -2
  73. package/src/providers/file-provider.ts +12 -4
  74. package/src/services/ContensisCliService.ts +1384 -484
  75. package/src/shell.ts +52 -15
  76. package/src/util/console.printer.ts +240 -78
  77. package/src/util/diff.ts +17 -0
  78. package/src/util/index.ts +16 -7
  79. package/src/util/logger.ts +111 -31
  80. package/src/util/timers.ts +24 -0
  81. package/src/version.ts +1 -1
package/src/shell.ts CHANGED
@@ -1,13 +1,14 @@
1
- import path from 'path';
2
1
  import figlet from 'figlet';
3
2
  import inquirer from 'inquirer';
4
3
  import inquirerPrompt from 'inquirer-command-prompt';
5
4
  import commands from './commands';
6
5
  import { LogMessages } from './localisation/en-GB';
7
- import { logError, Logger } from './util/logger';
8
6
  import CredentialProvider from './providers/CredentialProvider';
7
+ import { appRootDir } from './providers/file-provider';
9
8
  import ContensisCli, { cliCommand } from './services/ContensisCliService';
10
9
  import { Logging } from './util';
10
+ import { logError, Logger } from './util/logger';
11
+ import { LIB_VERSION } from './version';
11
12
 
12
13
  class ContensisShell {
13
14
  private currentEnvironment!: string;
@@ -39,12 +40,11 @@ class ContensisShell {
39
40
  inquirerPrompt.setConfig({
40
41
  history: {
41
42
  save: true,
42
- folder: path.join(__dirname, '../'),
43
+ folder: appRootDir,
43
44
  limit: 100,
44
45
  blacklist: ['quit'],
45
46
  },
46
47
  });
47
- // inquirer.registerPrompt('command', inquirerPrompt);
48
48
 
49
49
  const { log, messages } = this;
50
50
 
@@ -64,7 +64,7 @@ class ContensisShell {
64
64
  return;
65
65
  }
66
66
  console.log(log.successText(data));
67
- console.log(log.infoText(messages.app.startup()));
67
+ console.log(log.infoText(messages.app.startup(LIB_VERSION)));
68
68
  console.log(log.helpText(messages.app.help()));
69
69
 
70
70
  this.start().catch(ex => log.error(ex));
@@ -72,8 +72,13 @@ class ContensisShell {
72
72
  );
73
73
  }
74
74
 
75
+ restart = async () => {
76
+ this.firstStart = false;
77
+ this.log.line(); // add a line so we can see where the shell has been restarted
78
+ await this.start();
79
+ };
80
+
75
81
  start = async () => {
76
- this.log.line();
77
82
  this.refreshEnvironment();
78
83
  this.userId = '';
79
84
  const { currentEnvironment, env, log, messages } = this;
@@ -98,7 +103,10 @@ class ContensisShell {
98
103
  silent: true,
99
104
  }
100
105
  );
101
- if (token) this.userId = env.lastUserId;
106
+ if (token) {
107
+ this.userId = env.lastUserId;
108
+ if (!env.currentProject) log.warning(messages.projects.tip());
109
+ }
102
110
  this.firstStart = false;
103
111
  this.refreshEnvironment();
104
112
  } else {
@@ -127,26 +135,51 @@ class ContensisShell {
127
135
  availableCommands.push('login', 'list projects', 'set project');
128
136
  if (userId)
129
137
  availableCommands.push(
138
+ 'create key',
139
+ 'create project',
140
+ 'create role',
141
+ 'diff models',
142
+ 'execute block action release',
143
+ 'execute block action makelive',
144
+ 'execute block action rollback',
145
+ 'execute block action markasbroken',
130
146
  'get block',
131
147
  'get block logs',
132
148
  'get contenttype',
133
149
  'get component',
134
150
  'get entries',
151
+ 'get model',
152
+ 'get project',
153
+ 'get role',
154
+ 'get token',
155
+ 'get version',
156
+ 'get webhook',
135
157
  'import contenttypes',
136
158
  'import components',
137
159
  'import entries',
160
+ 'import models',
138
161
  'list blocks',
139
162
  'list contenttypes',
140
163
  'list components',
141
- 'list models',
142
164
  'list keys',
165
+ 'list models',
166
+ 'list proxies',
167
+ 'list renderers',
168
+ 'list roles',
143
169
  'list webhooks',
144
- 'create key',
145
170
  'push block',
146
- 'remove key',
147
- 'remove entry',
171
+ 'remove components',
148
172
  'remove contenttypes',
149
- 'remove components'
173
+ 'remove key',
174
+ 'remove entries',
175
+ 'remove role',
176
+ 'set project name',
177
+ 'set project description',
178
+ 'set role name',
179
+ 'set role description',
180
+ 'set role assignments',
181
+ 'set role enabled',
182
+ 'set role permissions'
150
183
  );
151
184
 
152
185
  const prompt = inquirer.createPromptModule();
@@ -155,7 +188,7 @@ class ContensisShell {
155
188
  {
156
189
  type: 'command',
157
190
  name: 'cmd',
158
- autoCompletion: availableCommands,
191
+ autoCompletion: availableCommands.sort(),
159
192
  autocompletePrompt: log.infoText(messages.app.autocomplete()),
160
193
  message: `${userId ? `${userId}@` : ''}${currentEnvironment || ''}>`,
161
194
  context: 0,
@@ -168,7 +201,7 @@ class ContensisShell {
168
201
  return true;
169
202
  }
170
203
  },
171
- prefix: `${env?.currentProject || 'contensis'}`,
204
+ prefix: `${env?.currentProject || log.infoText('contensis')}`,
172
205
  short: true,
173
206
  },
174
207
  ])
@@ -221,7 +254,11 @@ class ContensisShell {
221
254
  let globalShell: ContensisShell;
222
255
 
223
256
  export const shell = () => {
224
- if (typeof process.argv?.[2] !== 'undefined') return { start() {} } as any;
257
+ // Return a benign function for shell().restart() when used in cli context
258
+ // as some commands need to restart the shell to show an updated prompt
259
+ // after successful connect / login / set project
260
+ if (typeof process.argv?.[2] !== 'undefined')
261
+ return { quit() {}, restart() {} } as any;
225
262
  if (!globalShell) globalShell = new ContensisShell();
226
263
  return globalShell;
227
264
  };
@@ -1,6 +1,7 @@
1
1
  import dayjs from 'dayjs';
2
- import { BlockVersion, MigrateStatus } from 'migratortron';
2
+ import { BlockVersion, MigrateModelsResult, MigrateStatus } from 'migratortron';
3
3
  import ContensisCli from '~/services/ContensisCliService';
4
+ import { Logger } from './logger';
4
5
 
5
6
  const formatDate = (date: Date | string, format = 'DD/MM/YYYY HH:mm') =>
6
7
  dayjs(date).format(format);
@@ -104,57 +105,22 @@ export const printBlockVersion = (
104
105
  };
105
106
 
106
107
  export const printMigrateResult = (
107
- { log, messages, contensis, currentProject }: ContensisCli,
108
+ { log, messages, currentProject }: ContensisCli,
108
109
  migrateResult: any,
109
- { action = 'import' }: { action?: 'import' | 'delete' } = {}
110
+ {
111
+ action = 'import',
112
+ showDiff = false,
113
+ showAllEntries = false,
114
+ showChangedEntries = false,
115
+ }: {
116
+ action?: 'import' | 'delete';
117
+ showDiff?: boolean;
118
+ showAllEntries?: boolean;
119
+ showChangedEntries?: boolean;
120
+ } = {}
110
121
  ) => {
111
122
  console.log(``);
112
123
 
113
- if (action === 'import') {
114
- for (const [projectId, contentTypeCounts] of Object.entries(
115
- migrateResult.entries || {}
116
- ) as [string, any][]) {
117
- console.log(
118
- `import from project ${log.highlightText(projectId)} to ${log.boldText(
119
- log.successText(currentProject)
120
- )}`
121
- );
122
- for (const [contentTypeId, count] of Object.entries(
123
- contentTypeCounts
124
- ) as [string, number][]) {
125
- const entriesToMigrate =
126
- migrateResult.entriesToMigrate?.[projectId]?.[contentTypeId];
127
-
128
- console.log(
129
- ` - ${
130
- contentTypeId === 'totalCount'
131
- ? log.warningText(`${contentTypeId}: ${count}`)
132
- : log.helpText(`${contentTypeId}: ${count}`)
133
- } ${log.infoText`[existing: ${(
134
- ((migrateResult.existing?.[projectId]?.[contentTypeId] || 0) /
135
- count) *
136
- 100
137
- ).toFixed(0)}%]`} [${
138
- typeof entriesToMigrate !== 'number' ? `unchanged` : `to update`
139
- }: ${(
140
- ((typeof entriesToMigrate !== 'number'
141
- ? entriesToMigrate?.['no change'] || 0
142
- : entriesToMigrate) /
143
- count) *
144
- 100
145
- ).toFixed(0)}%]`
146
- );
147
- }
148
- console.log(``);
149
- }
150
- }
151
- if (
152
- contensis?.isPreview &&
153
- migrateResult.entriesToMigrate?.[currentProject]?.totalCount > 0 &&
154
- !migrateResult.errors
155
- ) {
156
- log.help(messages.entries.commitTip());
157
- }
158
124
  for (const [contentTypeId, entryRes] of Object.entries(
159
125
  migrateResult.entriesToMigrate.entryIds
160
126
  ) as [string, any]) {
@@ -162,42 +128,238 @@ export const printMigrateResult = (
162
128
  string,
163
129
  any
164
130
  ][]) {
131
+ if (
132
+ showAllEntries ||
133
+ (showChangedEntries &&
134
+ (
135
+ Object.entries(
136
+ Object.entries(entryStatus[currentProject])[0]
137
+ )[1][1] as any
138
+ ).status !== 'no change')
139
+ ) {
140
+ console.log(
141
+ log.infoText(
142
+ `${originalId} ${Object.entries(entryStatus || {})
143
+ .filter(x => x[0] !== 'entryTitle')
144
+ .map(([projectId, projectStatus]) => {
145
+ const [targetGuid, { status }] = (Object.entries(
146
+ projectStatus || {}
147
+ )?.[0] as [string, { status: MigrateStatus }]) || [
148
+ '',
149
+ { x: { status: undefined } },
150
+ ];
151
+ return `${messages.migrate.status(status)(`${status}`)}${
152
+ targetGuid !== originalId ? `-> ${targetGuid}` : ''
153
+ }`;
154
+ })}`
155
+ ) + ` ${log.helpText(contentTypeId)} ${entryStatus.entryTitle}`
156
+ );
157
+
158
+ for (const [projectId, projectStatus] of Object.entries(
159
+ entryStatus
160
+ ).filter(([key]) => key !== 'entryTitle') as [string, any][]) {
161
+ const [targetGuid, { error, diff, status }] = Object.entries(
162
+ projectStatus
163
+ )[0] as [string, any];
164
+ if (error) log.error(error);
165
+ if (diff && showDiff) {
166
+ console.log(
167
+ ` ${log.highlightText(`diff:`)} ${log.infoText(
168
+ highlightDiffText(diff)
169
+ )}\n`
170
+ );
171
+ }
172
+ }
173
+ }
174
+ }
175
+ }
176
+ if (showAllEntries || showChangedEntries) console.log(``);
177
+
178
+ for (const [projectId, contentTypeCounts] of Object.entries(
179
+ migrateResult.entries || {}
180
+ ) as [string, any][]) {
181
+ log.help(
182
+ `${action} from project ${
183
+ action === 'delete'
184
+ ? log.warningText(currentProject)
185
+ : `${log.highlightText(projectId)} to ${log.boldText(
186
+ log.warningText(currentProject)
187
+ )}`
188
+ }`
189
+ );
190
+ for (const [contentTypeId, count] of Object.entries(contentTypeCounts) as [
191
+ string,
192
+ number
193
+ ][]) {
194
+ const isTotalCountRow = contentTypeId === 'totalCount';
195
+ const migrateStatusAndCount =
196
+ migrateResult.entriesToMigrate[currentProject][contentTypeId];
197
+ const existingCount =
198
+ migrateResult.existing?.[currentProject]?.[contentTypeId] || 0;
199
+ const existingPercent = ((existingCount / count) * 100).toFixed(0);
200
+ const noChangeOrTotalEntriesCount =
201
+ typeof migrateStatusAndCount !== 'number'
202
+ ? migrateStatusAndCount?.['no change'] || 0
203
+ : migrateStatusAndCount;
204
+
205
+ const changedPercentage = (
206
+ (noChangeOrTotalEntriesCount / count) *
207
+ 100
208
+ ).toFixed(0);
209
+
210
+ const existingColor =
211
+ existingPercent === '0' || action === 'delete'
212
+ ? log.warningText
213
+ : log.infoText;
214
+
215
+ const changedColor = isTotalCountRow
216
+ ? log.helpText
217
+ : changedPercentage === '100'
218
+ ? log.successText
219
+ : log.warningText;
220
+
165
221
  console.log(
166
- log.infoText(
167
- `${originalId} [${Object.entries(entryStatus || {})
168
- .filter(x => x[0] !== 'entryTitle')
169
- .map(([projectId, projectStatus]) => {
170
- const [targetGuid, { status }] = (Object.entries(
171
- projectStatus || {}
172
- )?.[0] as [string, { status: MigrateStatus }]) || [
173
- '',
174
- { x: { status: undefined } },
175
- ];
176
- return `${messages.entries.migrateStatus(status)(
177
- `${projectId}: ${status}`
178
- )}${targetGuid !== originalId ? `-> ${targetGuid}` : ''}`;
179
- })}]`
180
- )
222
+ ` - ${
223
+ isTotalCountRow
224
+ ? log.highlightText(
225
+ `${contentTypeId}: ${noChangeOrTotalEntriesCount}`
226
+ )
227
+ : `${contentTypeId}: ${log.helpText(count)}`
228
+ }${
229
+ changedPercentage === '100' || isTotalCountRow
230
+ ? ''
231
+ : existingColor(` [existing: ${`${existingPercent}%`}]`)
232
+ }${
233
+ existingPercent === '0' || (action === 'import' && isTotalCountRow)
234
+ ? ''
235
+ : changedColor(
236
+ ` ${
237
+ isTotalCountRow
238
+ ? `[to ${action}: ${noChangeOrTotalEntriesCount}]`
239
+ : changedPercentage === '100'
240
+ ? 'up to date'
241
+ : `[needs update: ${100 - Number(changedPercentage)}%]`
242
+ }`
243
+ )
244
+ }`
245
+ );
246
+ }
247
+ }
248
+ if (migrateResult.errors?.length) {
249
+ console.log(
250
+ ` - ${log.errorText(`errors: ${migrateResult.errors.length}`)}\n`
251
+ );
252
+ for (const error of migrateResult.errors)
253
+ log.error(error.message || error, null, '');
254
+ }
255
+ };
256
+
257
+ const highlightDiffText = (str: string) => {
258
+ const addedRegex = new RegExp(/<<\+>>(.*?)<<\/\+>>/, 'g');
259
+ const removedRegex = new RegExp(/<<->>(.*?)<<\/->>/, 'g');
260
+ return str
261
+ .replace(addedRegex, match => {
262
+ return Logger.successText(
263
+ match.replace(/<<\+>>/g, '<+>').replace(/<<\/\+>>/g, '</+>')
264
+ );
265
+ })
266
+ .replace(removedRegex, match => {
267
+ return Logger.errorText(
268
+ match.replace(/<<->>/g, '<->').replace(/<<\/->>/g, '</->')
181
269
  );
182
- console.log(` ${log.helpText(contentTypeId)} ${entryStatus.entryTitle}`);
270
+ });
271
+ };
183
272
 
184
- for (const [projectId, projectStatus] of Object.entries(
185
- entryStatus
186
- ).filter(([key]) => key !== 'entryTitle') as [string, any][]) {
187
- const [targetGuid, { error, diff, status }] = Object.entries(
188
- projectStatus
189
- )[0] as [string, any];
190
- if (error) log.error(error);
191
- if (diff) {
192
- console.log(
193
- ` ${messages.entries.migrateStatus(status)(status)} ${log.infoText(
194
- targetGuid
195
- )} ${log.infoText(contentTypeId)} ${log.infoText(projectId)}`
273
+ export const printModelMigrationAnalysis = (
274
+ { log, messages }: ContensisCli,
275
+ result: any = {}
276
+ ) => {
277
+ for (const [contentTypeId, model] of Object.entries(result) as [
278
+ string,
279
+ any
280
+ ][]) {
281
+ let mainOutput = log.standardText(` - ${contentTypeId}`);
282
+ let extraOutput = '';
283
+ let errorOutput = '';
284
+ let diffOutput = '';
285
+ for (const [key, details] of Object.entries(model) as [string, any][]) {
286
+ if (key === 'dependencies') {
287
+ extraOutput += log.infoText(
288
+ ` references: [${details?.join(', ')}]\n`
289
+ );
290
+ }
291
+ if (key === 'dependencyOf') {
292
+ extraOutput += log.infoText(
293
+ ` required by: [${details?.join(', ')}]\n`
294
+ );
295
+ }
296
+ if (key === 'projects') {
297
+ for (const [projectId, projectDetails] of Object.entries(details) as [
298
+ string,
299
+ any
300
+ ][]) {
301
+ mainOutput += log.infoText(
302
+ ` [${messages.migrate.status(projectDetails.status)(
303
+ `${projectId}: ${projectDetails.status}`
304
+ )}] v${projectDetails.versionNo}`
196
305
  );
197
- console.log(``);
198
- console.log(log.highlightText(diff));
306
+ if (projectDetails.diff)
307
+ diffOutput += ` ${log.highlightText(`diff:`)} ${log.infoText(
308
+ highlightDiffText(projectDetails.diff)
309
+ )}\n`;
310
+ if (projectDetails.error)
311
+ errorOutput += ` ${log.highlightText(
312
+ `error::`
313
+ )} ${log.errorText(projectDetails.error)}`;
199
314
  }
200
315
  }
201
316
  }
317
+ console.log(mainOutput);
318
+ if (extraOutput) {
319
+ const search = '\n';
320
+ const replace = '';
321
+ console.log(
322
+ extraOutput.replace(
323
+ new RegExp(search + '([^' + search + ']*)$'),
324
+ replace + '$1'
325
+ )
326
+ );
327
+ }
328
+ if (diffOutput) console.log(diffOutput);
329
+ if (errorOutput) console.log(errorOutput);
330
+ }
331
+ };
332
+
333
+ type MigrateResultSummary = MigrateModelsResult['']['contentTypes'];
334
+ type MigrateResultStatus = keyof MigrateResultSummary;
335
+
336
+ export const printModelMigrationResult = (
337
+ { log, messages }: ContensisCli,
338
+ result: MigrateResultSummary
339
+ ) => {
340
+ for (const [status, ids] of Object.entries(result) as [
341
+ MigrateResultStatus,
342
+ string[]
343
+ ][]) {
344
+ if (ids?.length) {
345
+ if (status === 'errors') {
346
+ const errors: [string, MappedError][] = ids as any;
347
+ log.raw(
348
+ ` - ${status}: [ ${messages.migrate.models.result(status)(
349
+ ids.map(id => id[0]).join(', ')
350
+ )} ]\n`
351
+ );
352
+ for (const [contentTypeId, error] of errors)
353
+ log.error(
354
+ `${log.highlightText(contentTypeId)}: ${error.message}`,
355
+ error
356
+ );
357
+ } else
358
+ log.raw(
359
+ ` - ${status}: [ ${messages.migrate.models.result(status)(
360
+ ids.join(', ')
361
+ )} ]`
362
+ );
363
+ }
202
364
  }
203
365
  };
@@ -0,0 +1,17 @@
1
+ export const diffLogStrings = (updates: string, previous: string) => {
2
+ const lastFewLines = previous.split('\n').slice(-10);
3
+ const incomingLines = updates.split('\n');
4
+
5
+ // Find the line indices in the incoming lines
6
+ // of the last few lines previously rendered
7
+ const incomingLineIndices = [];
8
+ for (const lastRenderedLine of lastFewLines) {
9
+ if (lastRenderedLine.length > 10)
10
+ incomingLineIndices.push(incomingLines.lastIndexOf(lastRenderedLine));
11
+ }
12
+
13
+ // Get the new lines from the next position on from the last of the already shown lines
14
+ const differentFromPos = Math.max(...incomingLineIndices) + 1 || 0;
15
+ // Return just the incoming lines from the position we matched
16
+ return incomingLines.slice(differentFromPos).join('\n');
17
+ };
package/src/util/index.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import mergeWith from 'lodash/mergeWith';
2
2
  import { Logger } from './logger';
3
+ import { LogMessages as enGB } from '../localisation/en-GB.js';
3
4
 
4
5
  export const isSharedSecret = (str = '') =>
5
6
  str.length > 80 && str.split('-').length === 3 ? str : undefined;
@@ -7,7 +8,7 @@ export const isSharedSecret = (str = '') =>
7
8
  export const isPassword = (str = '') =>
8
9
  !isSharedSecret(str) ? str : undefined;
9
10
 
10
- export const tryParse = (str: string) => {
11
+ export const tryParse = (str: any) => {
11
12
  try {
12
13
  return typeof str === 'object' ? str : JSON.parse(str);
13
14
  } catch (e) {
@@ -26,6 +27,9 @@ export const tryStringify = (obj: any) => {
26
27
  }
27
28
  };
28
29
 
30
+ export const isSysError = (error: any): error is Error =>
31
+ error?.message !== undefined && error.stack;
32
+
29
33
  export const isUuid = (str: string) => {
30
34
  // Regular expression to check if string is a valid UUID
31
35
  const regexExp =
@@ -50,12 +54,17 @@ export const url = (alias: string, project: string) => {
50
54
  };
51
55
 
52
56
  export const Logging = async (language = 'en-GB') => {
53
- const { LogMessages: defaultMessages } = await import(
54
- `../localisation/en-GB.js`
55
- );
56
- const { LogMessages: localisedMessages } = await import(
57
- `../localisation/${language}.js`
58
- );
57
+ const defaultMessages = enGB;
58
+ // const { LogMessages: defaultMessages } = await import(
59
+ // `../localisation/en-GB.js`
60
+ // );
61
+ let localisedMessages = defaultMessages;
62
+
63
+ if (language === 'en-GB') {
64
+ // Using a variable import e.g. `import(`../localisation/${language}.js`);`
65
+ // does not play well with packaged executables
66
+ // So we have to hard code the import for each language individually
67
+ }
59
68
  return {
60
69
  messages: mergeWith(
61
70
  localisedMessages,