@rockcarver/frodo-cli 0.23.1-5 → 0.23.1-7
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/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.23.1-7] - 2023-05-18
|
|
11
|
+
|
|
12
|
+
## [0.23.1-6] - 2023-05-17
|
|
13
|
+
|
|
10
14
|
## [0.23.1-5] - 2023-05-17
|
|
11
15
|
|
|
12
16
|
## [0.23.1-4] - 2023-04-20
|
|
@@ -1102,7 +1106,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
1102
1106
|
- Fixed problem with adding connection profiles
|
|
1103
1107
|
- Miscellaneous bug fixes
|
|
1104
1108
|
|
|
1105
|
-
[Unreleased]: https://github.com/rockcarver/frodo-cli/compare/v0.23.1-
|
|
1109
|
+
[Unreleased]: https://github.com/rockcarver/frodo-cli/compare/v0.23.1-7...HEAD
|
|
1110
|
+
|
|
1111
|
+
[0.23.1-7]: https://github.com/rockcarver/frodo-cli/compare/v0.23.1-6...v0.23.1-7
|
|
1112
|
+
|
|
1113
|
+
[0.23.1-6]: https://github.com/rockcarver/frodo-cli/compare/v0.23.1-5...v0.23.1-6
|
|
1106
1114
|
|
|
1107
1115
|
[0.23.1-5]: https://github.com/rockcarver/frodo-cli/compare/v0.23.1-4...v0.23.1-5
|
|
1108
1116
|
|
|
@@ -7,14 +7,14 @@ const {
|
|
|
7
7
|
getTokens
|
|
8
8
|
} = Authenticate;
|
|
9
9
|
const program = new FrodoCommand('frodo email template import');
|
|
10
|
-
program.description('Import email templates.').addOption(new Option('-i, --template-id <template-id>', 'Email template id/name. If specified, -a and -A are ignored.')).addOption(new Option('-f, --file <file>', 'Name of the import file.')).addOption(new Option('-a, --all', 'Import all email templates from single file. Ignored with -i.')).addOption(new Option('-A, --all-separate', 'Import all email templates from separate files (*.template.email.json) in the current directory. Ignored with -i or -a.')).action(
|
|
10
|
+
program.description('Import email templates.').addOption(new Option('-i, --template-id <template-id>', 'Email template id/name. If specified, -a and -A are ignored.')).addOption(new Option('-f, --file <file>', 'Name of the import file.')).addOption(new Option('-a, --all', 'Import all email templates from single file. Ignored with -i.')).addOption(new Option('-A, --all-separate', 'Import all email templates from separate files (*.template.email.json) in the current directory. Ignored with -i or -a.')).addOption(new Option('--raw', "Import raw email template files. Raw templates do not contain the id/name, therefore when using -A or -f without -i, the email template id/name is parsed from the file name; Make sure your template files are named 'emailTemplate-<id/name>.json' or use -f with -i. Ignored with -a.")).action(
|
|
11
11
|
// implement program logic inside action handler
|
|
12
12
|
async (host, realm, user, password, options, command) => {
|
|
13
13
|
command.handleDefaultArgsAndOpts(host, realm, user, password, options, command);
|
|
14
14
|
// import by id
|
|
15
15
|
if (options.file && options.templateId && (await getTokens())) {
|
|
16
16
|
verboseMessage(`Importing email template "${options.templateId}"...`);
|
|
17
|
-
importEmailTemplateFromFile(options.templateId, options.file);
|
|
17
|
+
importEmailTemplateFromFile(options.templateId, options.file, options.raw);
|
|
18
18
|
}
|
|
19
19
|
// --all -a
|
|
20
20
|
else if (options.all && options.file && (await getTokens())) {
|
|
@@ -24,12 +24,12 @@ async (host, realm, user, password, options, command) => {
|
|
|
24
24
|
// --all-separate -A
|
|
25
25
|
else if (options.allSeparate && !options.file && (await getTokens())) {
|
|
26
26
|
verboseMessage('Importing all email templates from separate files (*.template.email.json) in current directory...');
|
|
27
|
-
importEmailTemplatesFromFiles();
|
|
27
|
+
importEmailTemplatesFromFiles(options.raw);
|
|
28
28
|
}
|
|
29
29
|
// import first template from file
|
|
30
30
|
else if (options.file && (await getTokens())) {
|
|
31
31
|
verboseMessage(`Importing first email template from file "${options.file}"...`);
|
|
32
|
-
importFirstEmailTemplateFromFile(options.file);
|
|
32
|
+
importFirstEmailTemplateFromFile(options.file, options.raw);
|
|
33
33
|
}
|
|
34
34
|
// unrecognized combination of options or no options
|
|
35
35
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"email-template-import.js","names":["FrodoCommand","Option","Authenticate","printMessage","verboseMessage","importEmailTemplateFromFile","importEmailTemplatesFromFile","importEmailTemplatesFromFiles","importFirstEmailTemplateFromFile","getTokens","program","description","addOption","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","file","templateId","all","allSeparate","help","process","exitCode","parse"],"sources":["cli/email/email-template-import.ts"],"sourcesContent":["import { FrodoCommand } from '../FrodoCommand';\nimport { Option } from 'commander';\nimport { Authenticate } from '@rockcarver/frodo-lib';\nimport { printMessage, verboseMessage } from '../../utils/Console.js';\nimport {\n importEmailTemplateFromFile,\n importEmailTemplatesFromFile,\n importEmailTemplatesFromFiles,\n importFirstEmailTemplateFromFile,\n} from '../../ops/EmailTemplateOps';\n\nconst { getTokens } = Authenticate;\n\nconst program = new FrodoCommand('frodo email template import');\n\nprogram\n .description('Import email templates.')\n .addOption(\n new Option(\n '-i, --template-id <template-id>',\n 'Email template id/name. If specified, -a and -A are ignored.'\n )\n )\n .addOption(new Option('-f, --file <file>', 'Name of the import file.'))\n .addOption(\n new Option(\n '-a, --all',\n 'Import all email templates from single file. Ignored with -i.'\n )\n )\n .addOption(\n new Option(\n '-A, --all-separate',\n 'Import all email templates from separate files (*.template.email.json) in the current directory. Ignored with -i or -a.'\n )\n )\n .action(\n // implement program logic inside action handler\n async (host, realm, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(\n host,\n realm,\n user,\n password,\n options,\n command\n );\n // import by id\n if (options.file && options.templateId && (await getTokens())) {\n verboseMessage(`Importing email template \"${options.templateId}\"...`);\n importEmailTemplateFromFile(options.templateId
|
|
1
|
+
{"version":3,"file":"email-template-import.js","names":["FrodoCommand","Option","Authenticate","printMessage","verboseMessage","importEmailTemplateFromFile","importEmailTemplatesFromFile","importEmailTemplatesFromFiles","importFirstEmailTemplateFromFile","getTokens","program","description","addOption","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","file","templateId","raw","all","allSeparate","help","process","exitCode","parse"],"sources":["cli/email/email-template-import.ts"],"sourcesContent":["import { FrodoCommand } from '../FrodoCommand';\nimport { Option } from 'commander';\nimport { Authenticate } from '@rockcarver/frodo-lib';\nimport { printMessage, verboseMessage } from '../../utils/Console.js';\nimport {\n importEmailTemplateFromFile,\n importEmailTemplatesFromFile,\n importEmailTemplatesFromFiles,\n importFirstEmailTemplateFromFile,\n} from '../../ops/EmailTemplateOps';\n\nconst { getTokens } = Authenticate;\n\nconst program = new FrodoCommand('frodo email template import');\n\nprogram\n .description('Import email templates.')\n .addOption(\n new Option(\n '-i, --template-id <template-id>',\n 'Email template id/name. If specified, -a and -A are ignored.'\n )\n )\n .addOption(new Option('-f, --file <file>', 'Name of the import file.'))\n .addOption(\n new Option(\n '-a, --all',\n 'Import all email templates from single file. Ignored with -i.'\n )\n )\n .addOption(\n new Option(\n '-A, --all-separate',\n 'Import all email templates from separate files (*.template.email.json) in the current directory. Ignored with -i or -a.'\n )\n )\n .addOption(\n new Option(\n '--raw',\n \"Import raw email template files. Raw templates do not contain the id/name, therefore when using -A or -f without -i, the email template id/name is parsed from the file name; Make sure your template files are named 'emailTemplate-<id/name>.json' or use -f with -i. Ignored with -a.\"\n )\n )\n .action(\n // implement program logic inside action handler\n async (host, realm, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(\n host,\n realm,\n user,\n password,\n options,\n command\n );\n // import by id\n if (options.file && options.templateId && (await getTokens())) {\n verboseMessage(`Importing email template \"${options.templateId}\"...`);\n importEmailTemplateFromFile(\n options.templateId,\n options.file,\n options.raw\n );\n }\n // --all -a\n else if (options.all && options.file && (await getTokens())) {\n verboseMessage(\n `Importing all email templates from a single file (${options.file})...`\n );\n importEmailTemplatesFromFile(options.file);\n }\n // --all-separate -A\n else if (options.allSeparate && !options.file && (await getTokens())) {\n verboseMessage(\n 'Importing all email templates from separate files (*.template.email.json) in current directory...'\n );\n importEmailTemplatesFromFiles(options.raw);\n }\n // import first template from file\n else if (options.file && (await getTokens())) {\n verboseMessage(\n `Importing first email template from file \"${options.file}\"...`\n );\n importFirstEmailTemplateFromFile(options.file, options.raw);\n }\n // unrecognized combination of options or no options\n else {\n printMessage(\n 'Unrecognized combination of options or no options...',\n 'error'\n );\n program.help();\n process.exitCode = 1;\n }\n }\n // end program logic inside action handler\n );\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,MAAM,QAAQ,WAAW;AAClC,SAASC,YAAY,QAAQ,uBAAuB;AACpD,SAASC,YAAY,EAAEC,cAAc,QAAQ,wBAAwB;AACrE,SACEC,2BAA2B,EAC3BC,4BAA4B,EAC5BC,6BAA6B,EAC7BC,gCAAgC,QAC3B,4BAA4B;AAEnC,MAAM;EAAEC;AAAU,CAAC,GAAGP,YAAY;AAElC,MAAMQ,OAAO,GAAG,IAAIV,YAAY,CAAC,6BAA6B,CAAC;AAE/DU,OAAO,CACJC,WAAW,CAAC,yBAAyB,CAAC,CACtCC,SAAS,CACR,IAAIX,MAAM,CACR,iCAAiC,EACjC,8DAA8D,CAC/D,CACF,CACAW,SAAS,CAAC,IAAIX,MAAM,CAAC,mBAAmB,EAAE,0BAA0B,CAAC,CAAC,CACtEW,SAAS,CACR,IAAIX,MAAM,CACR,WAAW,EACX,+DAA+D,CAChE,CACF,CACAW,SAAS,CACR,IAAIX,MAAM,CACR,oBAAoB,EACpB,yHAAyH,CAC1H,CACF,CACAW,SAAS,CACR,IAAIX,MAAM,CACR,OAAO,EACP,0RAA0R,CAC3R,CACF,CACAY,MAAM;AACL;AACA,OAAOC,IAAI,EAAEC,KAAK,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,OAAO,KAAK;EACvDA,OAAO,CAACC,wBAAwB,CAC9BN,IAAI,EACJC,KAAK,EACLC,IAAI,EACJC,QAAQ,EACRC,OAAO,EACPC,OAAO,CACR;EACD;EACA,IAAID,OAAO,CAACG,IAAI,IAAIH,OAAO,CAACI,UAAU,KAAK,MAAMb,SAAS,EAAE,CAAC,EAAE;IAC7DL,cAAc,CAAE,6BAA4Bc,OAAO,CAACI,UAAW,MAAK,CAAC;IACrEjB,2BAA2B,CACzBa,OAAO,CAACI,UAAU,EAClBJ,OAAO,CAACG,IAAI,EACZH,OAAO,CAACK,GAAG,CACZ;EACH;EACA;EAAA,KACK,IAAIL,OAAO,CAACM,GAAG,IAAIN,OAAO,CAACG,IAAI,KAAK,MAAMZ,SAAS,EAAE,CAAC,EAAE;IAC3DL,cAAc,CACX,qDAAoDc,OAAO,CAACG,IAAK,MAAK,CACxE;IACDf,4BAA4B,CAACY,OAAO,CAACG,IAAI,CAAC;EAC5C;EACA;EAAA,KACK,IAAIH,OAAO,CAACO,WAAW,IAAI,CAACP,OAAO,CAACG,IAAI,KAAK,MAAMZ,SAAS,EAAE,CAAC,EAAE;IACpEL,cAAc,CACZ,mGAAmG,CACpG;IACDG,6BAA6B,CAACW,OAAO,CAACK,GAAG,CAAC;EAC5C;EACA;EAAA,KACK,IAAIL,OAAO,CAACG,IAAI,KAAK,MAAMZ,SAAS,EAAE,CAAC,EAAE;IAC5CL,cAAc,CACX,6CAA4Cc,OAAO,CAACG,IAAK,MAAK,CAChE;IACDb,gCAAgC,CAACU,OAAO,CAACG,IAAI,EAAEH,OAAO,CAACK,GAAG,CAAC;EAC7D;EACA;EAAA,KACK;IACHpB,YAAY,CACV,sDAAsD,EACtD,OAAO,CACR;IACDO,OAAO,CAACgB,IAAI,EAAE;IACdC,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AAAA,CACD;;AAEHlB,OAAO,CAACmB,KAAK,EAAE"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import { EmailTemplate, ExportImportUtils } from '@rockcarver/frodo-lib';
|
|
3
3
|
import { getTypedFilename, saveJsonToFile } from '../utils/ExportImportUtils';
|
|
4
|
-
import { createProgressIndicator, updateProgressIndicator, stopProgressIndicator, printMessage, createTable } from '../utils/Console';
|
|
4
|
+
import { createProgressIndicator, updateProgressIndicator, stopProgressIndicator, printMessage, createTable, showSpinner, succeedSpinner, failSpinner, debugMessage } from '../utils/Console';
|
|
5
5
|
import wordwrap from './utils/Wordwrap';
|
|
6
|
+
import path from 'path';
|
|
7
|
+
import { cloneDeep } from './utils/OpsUtils';
|
|
6
8
|
const EMAIL_TEMPLATE_FILE_TYPE = 'template.email';
|
|
7
9
|
const {
|
|
8
10
|
EMAIL_TEMPLATE_TYPE,
|
|
@@ -171,20 +173,22 @@ export async function exportEmailTemplatesToFiles() {
|
|
|
171
173
|
|
|
172
174
|
/**
|
|
173
175
|
* Import email template by id from file
|
|
174
|
-
* @param {
|
|
175
|
-
* @param {
|
|
176
|
+
* @param {string} templateId email template id
|
|
177
|
+
* @param {string} file optional filename
|
|
178
|
+
* @param {boolean} raw import raw data file lacking frodo export envelop
|
|
176
179
|
*/
|
|
177
|
-
export async function importEmailTemplateFromFile(templateId, file) {
|
|
180
|
+
export async function importEmailTemplateFromFile(templateId, file, raw = false) {
|
|
178
181
|
// eslint-disable-next-line no-param-reassign
|
|
179
182
|
templateId = templateId.replaceAll(`${EMAIL_TEMPLATE_TYPE}/`, '');
|
|
180
183
|
fs.readFile(file, 'utf8', async (err, data) => {
|
|
181
184
|
if (err) throw err;
|
|
182
185
|
const fileData = JSON.parse(data);
|
|
183
|
-
if (validateImport(fileData.meta)) {
|
|
186
|
+
if (raw || validateImport(fileData.meta)) {
|
|
184
187
|
createProgressIndicator('determinate', 1, `Importing ${templateId}`);
|
|
185
|
-
if (fileData.emailTemplate[templateId]) {
|
|
188
|
+
if (fileData.emailTemplate[templateId] || raw && fileData._id === templateId) {
|
|
186
189
|
try {
|
|
187
|
-
|
|
190
|
+
const emailTemplateData = raw ? s2sConvert(fileData) : fileData.emailTemplate[templateId];
|
|
191
|
+
await putEmailTemplate(templateId, emailTemplateData);
|
|
188
192
|
updateProgressIndicator(`Importing ${templateId}`);
|
|
189
193
|
stopProgressIndicator(`Imported ${templateId}`);
|
|
190
194
|
} catch (putEmailTemplateError) {
|
|
@@ -192,8 +196,8 @@ export async function importEmailTemplateFromFile(templateId, file) {
|
|
|
192
196
|
printMessage(putEmailTemplateError, 'error');
|
|
193
197
|
}
|
|
194
198
|
} else {
|
|
195
|
-
stopProgressIndicator(`Email template ${templateId
|
|
196
|
-
printMessage(`Email template ${templateId
|
|
199
|
+
stopProgressIndicator(`Email template ${templateId} not found in ${file}!`);
|
|
200
|
+
printMessage(`Email template ${templateId} not found in ${file}!`, 'error');
|
|
197
201
|
}
|
|
198
202
|
} else {
|
|
199
203
|
printMessage('Import validation failed...', 'error');
|
|
@@ -203,7 +207,7 @@ export async function importEmailTemplateFromFile(templateId, file) {
|
|
|
203
207
|
|
|
204
208
|
/**
|
|
205
209
|
* Import all email templates from file
|
|
206
|
-
* @param {
|
|
210
|
+
* @param {string} file optional filename
|
|
207
211
|
*/
|
|
208
212
|
export async function importEmailTemplatesFromFile(file) {
|
|
209
213
|
fs.readFile(file, 'utf8', async (err, data) => {
|
|
@@ -231,31 +235,77 @@ export async function importEmailTemplatesFromFile(file) {
|
|
|
231
235
|
});
|
|
232
236
|
}
|
|
233
237
|
|
|
238
|
+
/**
|
|
239
|
+
* Helper function to get email template id from file name
|
|
240
|
+
* @param {string} file file name
|
|
241
|
+
* @returns {string} email template id/name
|
|
242
|
+
*/
|
|
243
|
+
function getEmailTemplateIdFromFile(file) {
|
|
244
|
+
debugMessage(`cli.EmailTemplateOps.getEmailTemplateIdFromFile: file=${file}`);
|
|
245
|
+
const fileName = path.basename(file);
|
|
246
|
+
const templateId = fileName.substring(14, fileName.indexOf('.'));
|
|
247
|
+
debugMessage(`cli.EmailTemplateOps.getEmailTemplateIdFromFile: templateId=${templateId}`);
|
|
248
|
+
return templateId;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Convert template for s2s purposes (software-to-saas migration)
|
|
253
|
+
* @param {EmailTemplateSkeleton} templateData template object
|
|
254
|
+
* @returns {EmailTemplateSkeleton} converted template object
|
|
255
|
+
*/
|
|
256
|
+
function s2sConvert(templateData) {
|
|
257
|
+
if (templateData.message && !templateData.html) {
|
|
258
|
+
const convertedData = cloneDeep(templateData);
|
|
259
|
+
convertedData.html = cloneDeep(templateData.message);
|
|
260
|
+
debugMessage(`cli.EmailTemplateOps.s2sConvert: templateData:`);
|
|
261
|
+
debugMessage(templateData);
|
|
262
|
+
debugMessage(`cli.EmailTemplateOps.s2sConvert: convertedData:`);
|
|
263
|
+
debugMessage(convertedData);
|
|
264
|
+
return convertedData;
|
|
265
|
+
}
|
|
266
|
+
return templateData;
|
|
267
|
+
}
|
|
268
|
+
|
|
234
269
|
/**
|
|
235
270
|
* Import all email templates from separate files
|
|
271
|
+
* @param {boolean} raw import raw data file lacking frodo export envelop
|
|
236
272
|
*/
|
|
237
|
-
export async function importEmailTemplatesFromFiles() {
|
|
273
|
+
export async function importEmailTemplatesFromFiles(raw = false) {
|
|
238
274
|
const names = fs.readdirSync('.');
|
|
239
|
-
const jsonFiles = names.filter(name => name.toLowerCase().endsWith(`${EMAIL_TEMPLATE_FILE_TYPE}.json`));
|
|
275
|
+
const jsonFiles = raw ? names.filter(name => name.startsWith(`${EMAIL_TEMPLATE_TYPE}-`) && name.endsWith(`.json`)) : names.filter(name => name.toLowerCase().endsWith(`${EMAIL_TEMPLATE_FILE_TYPE}.json`));
|
|
240
276
|
createProgressIndicator('determinate', jsonFiles.length, 'Importing email templates...');
|
|
241
277
|
let total = 0;
|
|
242
278
|
let totalErrors = 0;
|
|
243
279
|
for (const file of jsonFiles) {
|
|
244
280
|
const data = fs.readFileSync(file, 'utf8');
|
|
245
281
|
const fileData = JSON.parse(data);
|
|
246
|
-
if (validateImport(fileData.meta)) {
|
|
247
|
-
total += Object.keys(fileData.emailTemplate).length;
|
|
282
|
+
if (raw && file.startsWith('emailTemplate-') || validateImport(fileData.meta)) {
|
|
248
283
|
let errors = 0;
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
284
|
+
if (raw) {
|
|
285
|
+
total++;
|
|
286
|
+
const templateId = getEmailTemplateIdFromFile(file);
|
|
287
|
+
try {
|
|
288
|
+
const templateData = s2sConvert(fileData);
|
|
289
|
+
await putEmailTemplate(templateId, templateData);
|
|
290
|
+
} catch (putEmailTemplateError) {
|
|
291
|
+
var _putEmailTemplateErro;
|
|
292
|
+
errors += 1;
|
|
293
|
+
printMessage(`\nError importing ${templateId}`, 'error');
|
|
294
|
+
printMessage(putEmailTemplateError, 'error');
|
|
295
|
+
printMessage((_putEmailTemplateErro = putEmailTemplateError.response) === null || _putEmailTemplateErro === void 0 ? void 0 : _putEmailTemplateErro.data, 'error');
|
|
296
|
+
}
|
|
297
|
+
} else {
|
|
298
|
+
total += Object.keys(fileData.emailTemplate).length;
|
|
299
|
+
for (const id in fileData.emailTemplate) {
|
|
300
|
+
if ({}.hasOwnProperty.call(fileData.emailTemplate, id)) {
|
|
301
|
+
const templateId = id.replace(regexEmailTemplateType, '');
|
|
302
|
+
try {
|
|
303
|
+
await putEmailTemplate(templateId, fileData.emailTemplate[templateId]);
|
|
304
|
+
} catch (putEmailTemplateError) {
|
|
305
|
+
errors += 1;
|
|
306
|
+
printMessage(`\nError importing ${templateId}`, 'error');
|
|
307
|
+
printMessage(putEmailTemplateError.response.data, 'error');
|
|
308
|
+
}
|
|
259
309
|
}
|
|
260
310
|
}
|
|
261
311
|
}
|
|
@@ -272,24 +322,36 @@ export async function importEmailTemplatesFromFiles() {
|
|
|
272
322
|
* Import first email template from file
|
|
273
323
|
* @param {String} file optional filename
|
|
274
324
|
*/
|
|
275
|
-
export async function importFirstEmailTemplateFromFile(file) {
|
|
325
|
+
export async function importFirstEmailTemplateFromFile(file, raw = false) {
|
|
276
326
|
fs.readFile(file, 'utf8', async (err, data) => {
|
|
277
327
|
if (err) throw err;
|
|
278
328
|
const fileData = JSON.parse(data);
|
|
279
|
-
if (validateImport(fileData.meta)) {
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
329
|
+
if (raw && file.startsWith('emailTemplate-') || validateImport(fileData.meta)) {
|
|
330
|
+
showSpinner(`Importing first email template`);
|
|
331
|
+
if (raw) {
|
|
332
|
+
const templateId = getEmailTemplateIdFromFile(file);
|
|
333
|
+
try {
|
|
334
|
+
const templateData = s2sConvert(fileData);
|
|
335
|
+
await putEmailTemplate(templateId, templateData);
|
|
336
|
+
succeedSpinner(`Imported ${templateId}`);
|
|
337
|
+
} catch (putEmailTemplateError) {
|
|
338
|
+
var _putEmailTemplateErro2;
|
|
339
|
+
failSpinner(`Error importing ${templateId}`);
|
|
340
|
+
printMessage((_putEmailTemplateErro2 = putEmailTemplateError.response) === null || _putEmailTemplateErro2 === void 0 ? void 0 : _putEmailTemplateErro2.data, 'error');
|
|
341
|
+
}
|
|
342
|
+
} else {
|
|
343
|
+
for (const id in fileData.emailTemplate) {
|
|
344
|
+
if ({}.hasOwnProperty.call(fileData.emailTemplate, id)) {
|
|
345
|
+
try {
|
|
346
|
+
await putEmailTemplate(id.replace(regexEmailTemplateType, ''), fileData.emailTemplate[id]);
|
|
347
|
+
succeedSpinner(`Imported ${id}`);
|
|
348
|
+
} catch (putEmailTemplateError) {
|
|
349
|
+
var _putEmailTemplateErro3;
|
|
350
|
+
failSpinner(`Error importing ${id}`);
|
|
351
|
+
printMessage((_putEmailTemplateErro3 = putEmailTemplateError.response) === null || _putEmailTemplateErro3 === void 0 ? void 0 : _putEmailTemplateErro3.data, 'error');
|
|
352
|
+
}
|
|
353
|
+
break;
|
|
291
354
|
}
|
|
292
|
-
break;
|
|
293
355
|
}
|
|
294
356
|
}
|
|
295
357
|
} else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmailTemplateOps.js","names":["fs","EmailTemplate","ExportImportUtils","getTypedFilename","saveJsonToFile","createProgressIndicator","updateProgressIndicator","stopProgressIndicator","printMessage","createTable","wordwrap","EMAIL_TEMPLATE_FILE_TYPE","EMAIL_TEMPLATE_TYPE","getEmailTemplate","getEmailTemplates","putEmailTemplate","validateImport","regexEmailTemplateType","RegExp","getFileDataTemplate","meta","emailTemplate","getOneLineDescription","templateObj","description","_id","split","displayName","defaultLocale","subject","Object","values","getTableHeaderMd","markdown","getTableRowMd","templateId","replace","locales","keys","length","filter","locale","join","row","name","listEmailTemplates","long","emailTemplates","result","error","message","sort","a","b","localeCompare","entries","table","push","enabled","from","toString","exportEmailTemplateToFile","file","fileName","templateData","fileData","err","exportEmailTemplatesToFile","response","templates","resultCount","template","exportEmailTemplatesToFiles","importEmailTemplateFromFile","replaceAll","readFile","data","JSON","parse","putEmailTemplateError","brightCyan","importEmailTemplatesFromFile","id","hasOwnProperty","call","importEmailTemplatesFromFiles","names","readdirSync","jsonFiles","toLowerCase","endsWith","total","totalErrors","readFileSync","errors","importFirstEmailTemplateFromFile"],"sources":["ops/EmailTemplateOps.ts"],"sourcesContent":["import fs from 'fs';\nimport { EmailTemplateSkeleton } from '@rockcarver/frodo-lib/types/api/ApiTypes';\nimport { EmailTemplate, ExportImportUtils } from '@rockcarver/frodo-lib';\nimport { getTypedFilename, saveJsonToFile } from '../utils/ExportImportUtils';\nimport {\n createProgressIndicator,\n updateProgressIndicator,\n stopProgressIndicator,\n printMessage,\n createTable,\n} from '../utils/Console';\nimport wordwrap from './utils/Wordwrap';\n\nconst EMAIL_TEMPLATE_FILE_TYPE = 'template.email';\nconst {\n EMAIL_TEMPLATE_TYPE,\n getEmailTemplate,\n getEmailTemplates,\n putEmailTemplate,\n} = EmailTemplate;\nconst { validateImport } = ExportImportUtils;\n\nconst regexEmailTemplateType = new RegExp(`${EMAIL_TEMPLATE_TYPE}/`, 'g');\n\n// use a function vs a template variable to avoid problems in loops\nfunction getFileDataTemplate() {\n return {\n meta: {},\n emailTemplate: {},\n };\n}\n\n/**\n * Get a one-line description of the email template\n * @param {EmailTemplateSkeleton} templateObj email template object to describe\n * @returns {string} a one-line description\n */\nexport function getOneLineDescription(\n templateObj: EmailTemplateSkeleton\n): string {\n const description = `[${templateObj._id.split('/')[1]['brightCyan']}] ${\n templateObj.displayName ? templateObj.displayName : ''\n } - ${\n templateObj.defaultLocale\n ? templateObj.subject[templateObj.defaultLocale]\n : Object.values(templateObj.subject)[0]\n }`;\n return description;\n}\n\n/**\n * Get markdown table header\n * @returns {string} markdown table header\n */\nexport function getTableHeaderMd(): string {\n let markdown = '';\n markdown += '| Display Name | Locale(s) | Subject | Id |\\n';\n markdown += '| ------------ | --------- | ------- | ---|';\n return markdown;\n}\n\n/**\n * Get a table-row of the email template in markdown\n * @param {EmailTemplateSkeleton} templateObj email template object to describe\n * @returns {string} a table-row of the email template in markdown\n */\nexport function getTableRowMd(templateObj: EmailTemplateSkeleton): string {\n const templateId = templateObj._id.replace(`${EMAIL_TEMPLATE_TYPE}/`, '');\n const locales = `${templateObj.defaultLocale}${\n Object.keys(templateObj.subject).length > 1\n ? ` (${Object.keys(templateObj.subject)\n .filter((locale) => locale !== templateObj.defaultLocale)\n .join(',')})`\n : ''\n }`;\n const row = `| ${\n templateObj.name ? templateObj.name : templateId\n } | ${locales} | ${\n templateObj.subject[templateObj.defaultLocale]\n } | \\`${templateId}\\` |`;\n return row;\n}\n\n/**\n * List email templates\n * @param {boolean} long Long list format with details\n * @return {Promise<unknown[]>} a promise that resolves to an array of email template objects\n */\nexport async function listEmailTemplates(long = false): Promise<unknown[]> {\n let emailTemplates = [];\n try {\n emailTemplates = (await getEmailTemplates()).result;\n } catch (error) {\n printMessage(`Error retrieving email templates: ${error.message}`, 'error');\n }\n emailTemplates.sort((a, b) => a._id.localeCompare(b._id));\n if (!long) {\n for (const [, emailTemplate] of emailTemplates.entries()) {\n printMessage(\n `${emailTemplate._id.replace(`${EMAIL_TEMPLATE_TYPE}/`, '')}`,\n 'data'\n );\n }\n } else {\n const table = createTable([\n 'Id'['brightCyan'],\n 'Name'['brightCyan'],\n 'Status'['brightCyan'],\n 'Locale(s)'['brightCyan'],\n 'From'['brightCyan'],\n 'Subject'['brightCyan'],\n ]);\n for (const emailTemplate of emailTemplates) {\n table.push([\n // Id\n `${emailTemplate._id.replace(`${EMAIL_TEMPLATE_TYPE}/`, '')}`,\n // Name\n `${emailTemplate.displayName ? emailTemplate.displayName : ''}`,\n // Status\n emailTemplate.enabled === false\n ? 'disabled'['brightRed']\n : 'enabled'['brightGreen'],\n // Locale(s)\n `${emailTemplate.defaultLocale}${\n Object.keys(emailTemplate.subject).length > 1\n ? ` (${Object.keys(emailTemplate.subject)\n .filter((locale) => locale !== emailTemplate.defaultLocale)\n .join(',')})`\n : ''\n }`,\n // From\n `${emailTemplate.from ? emailTemplate.from : ''}`,\n // Subject\n wordwrap(emailTemplate.subject[emailTemplate.defaultLocale], 40),\n ]);\n }\n printMessage(table.toString(), 'data');\n }\n return emailTemplates;\n}\n\n/**\n * Export single email template to a file\n * @param {string} templateId email template id to export\n * @param {string} file filename where to export the template data\n */\nexport async function exportEmailTemplateToFile(\n templateId: string,\n file: string\n) {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(templateId, EMAIL_TEMPLATE_FILE_TYPE);\n }\n createProgressIndicator('determinate', 1, `Exporting ${templateId}`);\n try {\n const templateData = await getEmailTemplate(templateId);\n updateProgressIndicator(`Writing file ${fileName}`);\n const fileData = getFileDataTemplate();\n fileData.emailTemplate[templateId] = templateData;\n saveJsonToFile(fileData, fileName);\n stopProgressIndicator(\n `Exported ${templateId['brightCyan']} to ${fileName['brightCyan']}.`\n );\n } catch (err) {\n stopProgressIndicator(`${err}`);\n printMessage(err, 'error');\n }\n}\n\n/**\n * Export all email templates to file\n * @param {String} file optional filename\n */\nexport async function exportEmailTemplatesToFile(file) {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(`allEmailTemplates`, EMAIL_TEMPLATE_FILE_TYPE);\n }\n try {\n const fileData = getFileDataTemplate();\n const response = await getEmailTemplates();\n const templates = response.result;\n createProgressIndicator(\n 'determinate',\n response.resultCount,\n 'Exporting email templates'\n );\n for (const template of templates) {\n const templateId = template._id.replace(`${EMAIL_TEMPLATE_TYPE}/`, '');\n updateProgressIndicator(`Exporting ${templateId}`);\n fileData.emailTemplate[templateId] = template;\n }\n saveJsonToFile(fileData, fileName);\n stopProgressIndicator(\n `${response.resultCount} templates exported to ${fileName}.`\n );\n } catch (err) {\n stopProgressIndicator(`${err}`);\n printMessage(err, 'error');\n }\n}\n\n/**\n * Export all email templates to separate files\n */\nexport async function exportEmailTemplatesToFiles() {\n try {\n const response = await getEmailTemplates();\n const templates = response.result;\n createProgressIndicator(\n 'determinate',\n response.resultCount,\n 'Exporting email templates'\n );\n for (const template of templates) {\n const templateId = template._id.replace(`${EMAIL_TEMPLATE_TYPE}/`, '');\n const fileName = getTypedFilename(templateId, EMAIL_TEMPLATE_FILE_TYPE);\n const fileData = getFileDataTemplate();\n updateProgressIndicator(`Exporting ${templateId}`);\n fileData.emailTemplate[templateId] = template;\n saveJsonToFile(fileData, fileName);\n }\n stopProgressIndicator(`${response.resultCount} templates exported.`);\n } catch (err) {\n stopProgressIndicator(`${err}`);\n printMessage(err, 'error');\n }\n}\n\n/**\n * Import email template by id from file\n * @param {String} templateId email template id\n * @param {String} file optional filename\n */\nexport async function importEmailTemplateFromFile(templateId, file) {\n // eslint-disable-next-line no-param-reassign\n templateId = templateId.replaceAll(`${EMAIL_TEMPLATE_TYPE}/`, '');\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n const fileData = JSON.parse(data);\n if (validateImport(fileData.meta)) {\n createProgressIndicator('determinate', 1, `Importing ${templateId}`);\n if (fileData.emailTemplate[templateId]) {\n try {\n await putEmailTemplate(\n templateId,\n fileData.emailTemplate[templateId]\n );\n updateProgressIndicator(`Importing ${templateId}`);\n stopProgressIndicator(`Imported ${templateId}`);\n } catch (putEmailTemplateError) {\n stopProgressIndicator(`${putEmailTemplateError}`);\n printMessage(putEmailTemplateError, 'error');\n }\n } else {\n stopProgressIndicator(\n `Email template ${templateId.brightCyan} not found in ${file.brightCyan}!`\n );\n printMessage(\n `Email template ${templateId.brightCyan} not found in ${file.brightCyan}!`,\n 'error'\n );\n }\n } else {\n printMessage('Import validation failed...', 'error');\n }\n });\n}\n\n/**\n * Import all email templates from file\n * @param {String} file optional filename\n */\nexport async function importEmailTemplatesFromFile(file) {\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n const fileData = JSON.parse(data);\n if (validateImport(fileData.meta)) {\n createProgressIndicator(\n 'determinate',\n Object.keys(fileData.emailTemplate).length,\n `Importing email templates`\n );\n for (const id in fileData.emailTemplate) {\n if ({}.hasOwnProperty.call(fileData.emailTemplate, id)) {\n const templateId = id.replace(regexEmailTemplateType, '');\n try {\n // eslint-disable-next-line no-await-in-loop\n await putEmailTemplate(\n templateId,\n fileData.emailTemplate[templateId]\n );\n updateProgressIndicator(`Imported ${templateId}`);\n } catch (putEmailTemplateError) {\n printMessage(`\\nError importing ${templateId}`, 'error');\n printMessage(putEmailTemplateError.response.data, 'error');\n }\n }\n }\n stopProgressIndicator(`Done.`);\n } else {\n printMessage('Import validation failed...', 'error');\n }\n });\n}\n\n/**\n * Import all email templates from separate files\n */\nexport async function importEmailTemplatesFromFiles() {\n const names = fs.readdirSync('.');\n const jsonFiles = names.filter((name) =>\n name.toLowerCase().endsWith(`${EMAIL_TEMPLATE_FILE_TYPE}.json`)\n );\n createProgressIndicator(\n 'determinate',\n jsonFiles.length,\n 'Importing email templates...'\n );\n let total = 0;\n let totalErrors = 0;\n for (const file of jsonFiles) {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n if (validateImport(fileData.meta)) {\n total += Object.keys(fileData.emailTemplate).length;\n let errors = 0;\n for (const id in fileData.emailTemplate) {\n if ({}.hasOwnProperty.call(fileData.emailTemplate, id)) {\n const templateId = id.replace(regexEmailTemplateType, '');\n try {\n // eslint-disable-next-line no-await-in-loop\n await putEmailTemplate(\n templateId,\n fileData.emailTemplate[templateId]\n );\n } catch (putEmailTemplateError) {\n errors += 1;\n printMessage(`\\nError importing ${templateId}`, 'error');\n printMessage(putEmailTemplateError.response.data, 'error');\n }\n }\n }\n totalErrors += errors;\n updateProgressIndicator(`Imported ${file}`);\n } else {\n printMessage(`Validation of ${file} failed!`, 'error');\n }\n }\n stopProgressIndicator(\n `Imported ${total - totalErrors} of ${total} email template(s) from ${\n jsonFiles.length\n } file(s).`\n );\n}\n\n/**\n * Import first email template from file\n * @param {String} file optional filename\n */\nexport async function importFirstEmailTemplateFromFile(file) {\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n const fileData = JSON.parse(data);\n if (validateImport(fileData.meta)) {\n createProgressIndicator(\n 'determinate',\n 1,\n `Importing first email template`\n );\n for (const id in fileData.emailTemplate) {\n if ({}.hasOwnProperty.call(fileData.emailTemplate, id)) {\n try {\n await putEmailTemplate(\n id.replace(regexEmailTemplateType, ''),\n fileData.emailTemplate[id]\n );\n updateProgressIndicator(`Imported ${id}`);\n stopProgressIndicator(`Imported ${id}`);\n } catch (putEmailTemplateError) {\n stopProgressIndicator(`Error importing email template ${id}`);\n printMessage(`\\nError importing email template ${id}`, 'error');\n printMessage(putEmailTemplateError.response.data, 'error');\n }\n break;\n }\n }\n } else {\n printMessage('Import validation failed...', 'error');\n }\n });\n}\n"],"mappings":"AAAA,OAAOA,EAAE,MAAM,IAAI;AAEnB,SAASC,aAAa,EAAEC,iBAAiB,QAAQ,uBAAuB;AACxE,SAASC,gBAAgB,EAAEC,cAAc,QAAQ,4BAA4B;AAC7E,SACEC,uBAAuB,EACvBC,uBAAuB,EACvBC,qBAAqB,EACrBC,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uB,CAAE,YAAW4E,EAAG,EAAC,CAAC;YACzC3E,qBAAqB,CAAE,YAAW2E,EAAG,EAAC,CAAC;UACzC,CAAC,CAAC,OAAOH,qBAAqB,EAAE;YAC9BxE,qBAAqB,CAAE,kCAAiC2E,EAAG,EAAC,CAAC;YAC7D1E,YAAY,CAAE,oCAAmC0E,EAAG,EAAC,EAAE,OAAO,CAAC;YAC/D1E,YAAY,CAACuE,qBAAqB,CAACX,QAAQ,CAACQ,IAAI,EAAE,OAAO,CAAC;UAC5D;UACA;QACF;MACF;IACF,CAAC,MAAM;MACLpE,YAAY,CAAC,6BAA6B,EAAE,OAAO,CAAC;IACtD;EACF,CAAC,CAAC;AACJ"}
|
|
1
|
+
{"version":3,"file":"EmailTemplateOps.js","names":["fs","EmailTemplate","ExportImportUtils","getTypedFilename","saveJsonToFile","createProgressIndicator","updateProgressIndicator","stopProgressIndicator","printMessage","createTable","showSpinner","succeedSpinner","failSpinner","debugMessage","wordwrap","path","cloneDeep","EMAIL_TEMPLATE_FILE_TYPE","EMAIL_TEMPLATE_TYPE","getEmailTemplate","getEmailTemplates","putEmailTemplate","validateImport","regexEmailTemplateType","RegExp","getFileDataTemplate","meta","emailTemplate","getOneLineDescription","templateObj","description","_id","split","displayName","defaultLocale","subject","Object","values","getTableHeaderMd","markdown","getTableRowMd","templateId","replace","locales","keys","length","filter","locale","join","row","name","listEmailTemplates","long","emailTemplates","result","error","message","sort","a","b","localeCompare","entries","table","push","enabled","from","toString","exportEmailTemplateToFile","file","fileName","templateData","fileData","err","exportEmailTemplatesToFile","response","templates","resultCount","template","exportEmailTemplatesToFiles","importEmailTemplateFromFile","raw","replaceAll","readFile","data","JSON","parse","emailTemplateData","s2sConvert","putEmailTemplateError","importEmailTemplatesFromFile","id","hasOwnProperty","call","getEmailTemplateIdFromFile","basename","substring","indexOf","html","convertedData","importEmailTemplatesFromFiles","names","readdirSync","jsonFiles","startsWith","endsWith","toLowerCase","total","totalErrors","readFileSync","errors","importFirstEmailTemplateFromFile"],"sources":["ops/EmailTemplateOps.ts"],"sourcesContent":["import fs from 'fs';\nimport { EmailTemplateSkeleton } from '@rockcarver/frodo-lib/types/api/ApiTypes';\nimport { EmailTemplate, ExportImportUtils } from '@rockcarver/frodo-lib';\nimport { getTypedFilename, saveJsonToFile } from '../utils/ExportImportUtils';\nimport {\n createProgressIndicator,\n updateProgressIndicator,\n stopProgressIndicator,\n printMessage,\n createTable,\n showSpinner,\n succeedSpinner,\n failSpinner,\n debugMessage,\n} from '../utils/Console';\nimport wordwrap from './utils/Wordwrap';\nimport path from 'path';\nimport { cloneDeep } from './utils/OpsUtils';\n\nconst EMAIL_TEMPLATE_FILE_TYPE = 'template.email';\nconst {\n EMAIL_TEMPLATE_TYPE,\n getEmailTemplate,\n getEmailTemplates,\n putEmailTemplate,\n} = EmailTemplate;\nconst { validateImport } = ExportImportUtils;\n\nconst regexEmailTemplateType = new RegExp(`${EMAIL_TEMPLATE_TYPE}/`, 'g');\n\n// use a function vs a template variable to avoid problems in loops\nfunction getFileDataTemplate() {\n return {\n meta: {},\n emailTemplate: {},\n };\n}\n\n/**\n * Get a one-line description of the email template\n * @param {EmailTemplateSkeleton} templateObj email template object to describe\n * @returns {string} a one-line description\n */\nexport function getOneLineDescription(\n templateObj: EmailTemplateSkeleton\n): string {\n const description = `[${templateObj._id.split('/')[1]['brightCyan']}] ${\n templateObj.displayName ? templateObj.displayName : ''\n } - ${\n templateObj.defaultLocale\n ? templateObj.subject[templateObj.defaultLocale]\n : Object.values(templateObj.subject)[0]\n }`;\n return description;\n}\n\n/**\n * Get markdown table header\n * @returns {string} markdown table header\n */\nexport function getTableHeaderMd(): string {\n let markdown = '';\n markdown += '| Display Name | Locale(s) | Subject | Id |\\n';\n markdown += '| ------------ | --------- | ------- | ---|';\n return markdown;\n}\n\n/**\n * Get a table-row of the email template in markdown\n * @param {EmailTemplateSkeleton} templateObj email template object to describe\n * @returns {string} a table-row of the email template in markdown\n */\nexport function getTableRowMd(templateObj: EmailTemplateSkeleton): string {\n const templateId = templateObj._id.replace(`${EMAIL_TEMPLATE_TYPE}/`, '');\n const locales = `${templateObj.defaultLocale}${\n Object.keys(templateObj.subject).length > 1\n ? ` (${Object.keys(templateObj.subject)\n .filter((locale) => locale !== templateObj.defaultLocale)\n .join(',')})`\n : ''\n }`;\n const row = `| ${\n templateObj.name ? templateObj.name : templateId\n } | ${locales} | ${\n templateObj.subject[templateObj.defaultLocale]\n } | \\`${templateId}\\` |`;\n return row;\n}\n\n/**\n * List email templates\n * @param {boolean} long Long list format with details\n * @return {Promise<unknown[]>} a promise that resolves to an array of email template objects\n */\nexport async function listEmailTemplates(long = false): Promise<unknown[]> {\n let emailTemplates = [];\n try {\n emailTemplates = (await getEmailTemplates()).result;\n } catch (error) {\n printMessage(`Error retrieving email templates: ${error.message}`, 'error');\n }\n emailTemplates.sort((a, b) => a._id.localeCompare(b._id));\n if (!long) {\n for (const [, emailTemplate] of emailTemplates.entries()) {\n printMessage(\n `${emailTemplate._id.replace(`${EMAIL_TEMPLATE_TYPE}/`, '')}`,\n 'data'\n );\n }\n } else {\n const table = createTable([\n 'Id'['brightCyan'],\n 'Name'['brightCyan'],\n 'Status'['brightCyan'],\n 'Locale(s)'['brightCyan'],\n 'From'['brightCyan'],\n 'Subject'['brightCyan'],\n ]);\n for (const emailTemplate of emailTemplates) {\n table.push([\n // Id\n `${emailTemplate._id.replace(`${EMAIL_TEMPLATE_TYPE}/`, '')}`,\n // Name\n `${emailTemplate.displayName ? emailTemplate.displayName : ''}`,\n // Status\n emailTemplate.enabled === false\n ? 'disabled'['brightRed']\n : 'enabled'['brightGreen'],\n // Locale(s)\n `${emailTemplate.defaultLocale}${\n Object.keys(emailTemplate.subject).length > 1\n ? ` (${Object.keys(emailTemplate.subject)\n .filter((locale) => locale !== emailTemplate.defaultLocale)\n .join(',')})`\n : ''\n }`,\n // From\n `${emailTemplate.from ? emailTemplate.from : ''}`,\n // Subject\n wordwrap(emailTemplate.subject[emailTemplate.defaultLocale], 40),\n ]);\n }\n printMessage(table.toString(), 'data');\n }\n return emailTemplates;\n}\n\n/**\n * Export single email template to a file\n * @param {string} templateId email template id to export\n * @param {string} file filename where to export the template data\n */\nexport async function exportEmailTemplateToFile(\n templateId: string,\n file: string\n) {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(templateId, EMAIL_TEMPLATE_FILE_TYPE);\n }\n createProgressIndicator('determinate', 1, `Exporting ${templateId}`);\n try {\n const templateData = await getEmailTemplate(templateId);\n updateProgressIndicator(`Writing file ${fileName}`);\n const fileData = getFileDataTemplate();\n fileData.emailTemplate[templateId] = templateData;\n saveJsonToFile(fileData, fileName);\n stopProgressIndicator(\n `Exported ${templateId['brightCyan']} to ${fileName['brightCyan']}.`\n );\n } catch (err) {\n stopProgressIndicator(`${err}`);\n printMessage(err, 'error');\n }\n}\n\n/**\n * Export all email templates to file\n * @param {String} file optional filename\n */\nexport async function exportEmailTemplatesToFile(file) {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(`allEmailTemplates`, EMAIL_TEMPLATE_FILE_TYPE);\n }\n try {\n const fileData = getFileDataTemplate();\n const response = await getEmailTemplates();\n const templates = response.result;\n createProgressIndicator(\n 'determinate',\n response.resultCount,\n 'Exporting email templates'\n );\n for (const template of templates) {\n const templateId = template._id.replace(`${EMAIL_TEMPLATE_TYPE}/`, '');\n updateProgressIndicator(`Exporting ${templateId}`);\n fileData.emailTemplate[templateId] = template;\n }\n saveJsonToFile(fileData, fileName);\n stopProgressIndicator(\n `${response.resultCount} templates exported to ${fileName}.`\n );\n } catch (err) {\n stopProgressIndicator(`${err}`);\n printMessage(err, 'error');\n }\n}\n\n/**\n * Export all email templates to separate files\n */\nexport async function exportEmailTemplatesToFiles() {\n try {\n const response = await getEmailTemplates();\n const templates = response.result;\n createProgressIndicator(\n 'determinate',\n response.resultCount,\n 'Exporting email templates'\n );\n for (const template of templates) {\n const templateId = template._id.replace(`${EMAIL_TEMPLATE_TYPE}/`, '');\n const fileName = getTypedFilename(templateId, EMAIL_TEMPLATE_FILE_TYPE);\n const fileData = getFileDataTemplate();\n updateProgressIndicator(`Exporting ${templateId}`);\n fileData.emailTemplate[templateId] = template;\n saveJsonToFile(fileData, fileName);\n }\n stopProgressIndicator(`${response.resultCount} templates exported.`);\n } catch (err) {\n stopProgressIndicator(`${err}`);\n printMessage(err, 'error');\n }\n}\n\n/**\n * Import email template by id from file\n * @param {string} templateId email template id\n * @param {string} file optional filename\n * @param {boolean} raw import raw data file lacking frodo export envelop\n */\nexport async function importEmailTemplateFromFile(\n templateId: string,\n file: string,\n raw = false\n) {\n // eslint-disable-next-line no-param-reassign\n templateId = templateId.replaceAll(`${EMAIL_TEMPLATE_TYPE}/`, '');\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n const fileData = JSON.parse(data);\n if (raw || validateImport(fileData.meta)) {\n createProgressIndicator('determinate', 1, `Importing ${templateId}`);\n if (\n fileData.emailTemplate[templateId] ||\n (raw && fileData._id === templateId)\n ) {\n try {\n const emailTemplateData = raw\n ? s2sConvert(fileData)\n : fileData.emailTemplate[templateId];\n await putEmailTemplate(templateId, emailTemplateData);\n updateProgressIndicator(`Importing ${templateId}`);\n stopProgressIndicator(`Imported ${templateId}`);\n } catch (putEmailTemplateError) {\n stopProgressIndicator(`${putEmailTemplateError}`);\n printMessage(putEmailTemplateError, 'error');\n }\n } else {\n stopProgressIndicator(\n `Email template ${templateId} not found in ${file}!`\n );\n printMessage(\n `Email template ${templateId} not found in ${file}!`,\n 'error'\n );\n }\n } else {\n printMessage('Import validation failed...', 'error');\n }\n });\n}\n\n/**\n * Import all email templates from file\n * @param {string} file optional filename\n */\nexport async function importEmailTemplatesFromFile(file: string) {\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n const fileData = JSON.parse(data);\n if (validateImport(fileData.meta)) {\n createProgressIndicator(\n 'determinate',\n Object.keys(fileData.emailTemplate).length,\n `Importing email templates`\n );\n for (const id in fileData.emailTemplate) {\n if ({}.hasOwnProperty.call(fileData.emailTemplate, id)) {\n const templateId = id.replace(regexEmailTemplateType, '');\n try {\n // eslint-disable-next-line no-await-in-loop\n await putEmailTemplate(\n templateId,\n fileData.emailTemplate[templateId]\n );\n updateProgressIndicator(`Imported ${templateId}`);\n } catch (putEmailTemplateError) {\n printMessage(`\\nError importing ${templateId}`, 'error');\n printMessage(putEmailTemplateError.response.data, 'error');\n }\n }\n }\n stopProgressIndicator(`Done.`);\n } else {\n printMessage('Import validation failed...', 'error');\n }\n });\n}\n\n/**\n * Helper function to get email template id from file name\n * @param {string} file file name\n * @returns {string} email template id/name\n */\nfunction getEmailTemplateIdFromFile(file: string) {\n debugMessage(`cli.EmailTemplateOps.getEmailTemplateIdFromFile: file=${file}`);\n const fileName = path.basename(file);\n const templateId = fileName.substring(14, fileName.indexOf('.'));\n debugMessage(\n `cli.EmailTemplateOps.getEmailTemplateIdFromFile: templateId=${templateId}`\n );\n return templateId;\n}\n\n/**\n * Convert template for s2s purposes (software-to-saas migration)\n * @param {EmailTemplateSkeleton} templateData template object\n * @returns {EmailTemplateSkeleton} converted template object\n */\nfunction s2sConvert(\n templateData: EmailTemplateSkeleton\n): EmailTemplateSkeleton {\n if (templateData.message && !templateData.html) {\n const convertedData = cloneDeep(templateData);\n convertedData.html = cloneDeep(templateData.message);\n debugMessage(`cli.EmailTemplateOps.s2sConvert: templateData:`);\n debugMessage(templateData);\n debugMessage(`cli.EmailTemplateOps.s2sConvert: convertedData:`);\n debugMessage(convertedData);\n return convertedData;\n }\n return templateData;\n}\n\n/**\n * Import all email templates from separate files\n * @param {boolean} raw import raw data file lacking frodo export envelop\n */\nexport async function importEmailTemplatesFromFiles(raw = false) {\n const names = fs.readdirSync('.');\n const jsonFiles = raw\n ? names.filter(\n (name) =>\n name.startsWith(`${EMAIL_TEMPLATE_TYPE}-`) && name.endsWith(`.json`)\n )\n : names.filter((name) =>\n name.toLowerCase().endsWith(`${EMAIL_TEMPLATE_FILE_TYPE}.json`)\n );\n createProgressIndicator(\n 'determinate',\n jsonFiles.length,\n 'Importing email templates...'\n );\n let total = 0;\n let totalErrors = 0;\n for (const file of jsonFiles) {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n if (\n (raw && file.startsWith('emailTemplate-')) ||\n validateImport(fileData.meta)\n ) {\n let errors = 0;\n if (raw) {\n total++;\n const templateId = getEmailTemplateIdFromFile(file);\n try {\n const templateData = s2sConvert(fileData);\n await putEmailTemplate(templateId, templateData);\n } catch (putEmailTemplateError) {\n errors += 1;\n printMessage(`\\nError importing ${templateId}`, 'error');\n printMessage(putEmailTemplateError, 'error');\n printMessage(putEmailTemplateError.response?.data, 'error');\n }\n } else {\n total += Object.keys(fileData.emailTemplate).length;\n for (const id in fileData.emailTemplate) {\n if ({}.hasOwnProperty.call(fileData.emailTemplate, id)) {\n const templateId = id.replace(regexEmailTemplateType, '');\n try {\n await putEmailTemplate(\n templateId,\n fileData.emailTemplate[templateId]\n );\n } catch (putEmailTemplateError) {\n errors += 1;\n printMessage(`\\nError importing ${templateId}`, 'error');\n printMessage(putEmailTemplateError.response.data, 'error');\n }\n }\n }\n }\n totalErrors += errors;\n updateProgressIndicator(`Imported ${file}`);\n } else {\n printMessage(`Validation of ${file} failed!`, 'error');\n }\n }\n stopProgressIndicator(\n `Imported ${total - totalErrors} of ${total} email template(s) from ${\n jsonFiles.length\n } file(s).`\n );\n}\n\n/**\n * Import first email template from file\n * @param {String} file optional filename\n */\nexport async function importFirstEmailTemplateFromFile(\n file: string,\n raw = false\n) {\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n const fileData = JSON.parse(data);\n if (\n (raw && file.startsWith('emailTemplate-')) ||\n validateImport(fileData.meta)\n ) {\n showSpinner(`Importing first email template`);\n if (raw) {\n const templateId = getEmailTemplateIdFromFile(file);\n try {\n const templateData = s2sConvert(fileData);\n await putEmailTemplate(templateId, templateData);\n succeedSpinner(`Imported ${templateId}`);\n } catch (putEmailTemplateError) {\n failSpinner(`Error importing ${templateId}`);\n printMessage(putEmailTemplateError.response?.data, 'error');\n }\n } else {\n for (const id in fileData.emailTemplate) {\n if ({}.hasOwnProperty.call(fileData.emailTemplate, id)) {\n try {\n await putEmailTemplate(\n id.replace(regexEmailTemplateType, ''),\n fileData.emailTemplate[id]\n );\n succeedSpinner(`Imported ${id}`);\n } catch (putEmailTemplateError) {\n failSpinner(`Error importing ${id}`);\n printMessage(putEmailTemplateError.response?.data, 'error');\n }\n break;\n }\n }\n }\n } else {\n printMessage('Import validation failed...', 'error');\n }\n });\n}\n"],"mappings":"AAAA,OAAOA,EAAE,MAAM,IAAI;AAEnB,SAASC,aAAa,EAAEC,iBAAiB,QAAQ,uBAAuB;AACxE,SAASC,gBAAgB,EAAEC,cAAc,QAAQ,4BAA4B;AAC7E,SACEC,uBAAuB,EACvBC,uBAAuB,EACvBC,qBAAqB,EACrBC,YAAY,EACZC,WAAW,EACXC,WAAW,EACXC,cAAc,EACdC,WAAW,EACXC,YAAY,QACP,kBAAkB;AACzB,OAAOC,QAAQ,MAAM,kBAAkB;AACvC,OAAOC,IAAI,MAAM,MAAM;AACvB,SAASC,SAAS,QAAQ,kBAAkB;AAE5C,MAAMC,wBAAwB,GAAG,gBAAgB;AACjD,MAAM;EACJC,mBAAmB;EACnBC,gBAAgB;EAChBC,iBAAiB;EACjBC;AACF,CAAC,GAAGpB,aAAa;AACjB,MAAM;EAAEqB;AAAe,CAAC,GAAGpB,iBAAiB;AAE5C,MAAMqB,sBAAsB,GAAG,IAAIC,MAAM,CAAE,GAAEN,mBAAoB,GAAE,EAAE,GAAG,CAAC;;AAEzE;AACA,SAASO,mBAAmB,GAAG;EAC7B,OAAO;IACLC,IAAI,EAAE,CAAC,CAAC;IACRC,aAAa,EAAE,CAAC;EAClB,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,qBAAqB,CACnCC,WAAkC,EAC1B;EACR,MAAMC,WAAW,GAAI,IAAGD,WAAW,CA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UAC5CjC,YAAY,2BAACgF,qBAAqB,CAACd,QAAQ,2DAA9B,uBAAgCS,IAAI,EAAE,OAAO,CAAC;QAC7D;MACF,CAAC,MAAM;QACL,KAAK,MAAMO,EAAE,IAAInB,QAAQ,CAAC5C,aAAa,EAAE;UACvC,IAAI,CAAC,CAAC,CAACgE,cAAc,CAACC,IAAI,CAACrB,QAAQ,CAAC5C,aAAa,EAAE+D,EAAE,CAAC,EAAE;YACtD,IAAI;cACF,MAAMrE,gBAAgB,CACpBqE,EAAE,CAAChD,OAAO,CAACnB,sBAAsB,EAAE,EAAE,CAAC,EACtCgD,QAAQ,CAAC5C,aAAa,CAAC+D,EAAE,CAAC,CAC3B;cACD/E,cAAc,CAAE,YAAW+E,EAAG,EAAC,CAAC;YAClC,CAAC,CAAC,OAAOF,qBAAqB,EAAE;cAAA;cAC9B5E,WAAW,CAAE,mBAAkB8E,EAAG,EAAC,CAAC;cACpClF,YAAY,2BAACgF,qBAAqB,CAACd,QAAQ,2DAA9B,uBAAgCS,IAAI,EAAE,OAAO,CAAC;YAC7D;YACA;UACF;QACF;MACF;IACF,CAAC,MAAM;MACL3E,YAAY,CAAC,6BAA6B,EAAE,OAAO,CAAC;IACtD;EACF,CAAC,CAAC;AACJ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rockcarver/frodo-cli",
|
|
3
|
-
"version": "0.23.1-
|
|
3
|
+
"version": "0.23.1-7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A command line interface to manage ForgeRock Identity Cloud tenants, ForgeOps deployments, and classic deployments.",
|
|
6
6
|
"keywords": [
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
]
|
|
100
100
|
},
|
|
101
101
|
"dependencies": {
|
|
102
|
-
"@rockcarver/frodo-lib": "0.18.9-
|
|
102
|
+
"@rockcarver/frodo-lib": "0.18.9-6",
|
|
103
103
|
"chokidar": "^3.5.3",
|
|
104
104
|
"cli-progress": "^3.11.2",
|
|
105
105
|
"cli-table3": "^0.6.3",
|