@travetto/email-compiler 5.0.0-rc.0 → 5.0.0-rc.10
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/package.json +8 -8
- package/src/compiler.ts +4 -9
- package/src/util.ts +1 -1
- package/support/bin/config.ts +4 -6
- package/support/bin/editor.ts +1 -1
- package/support/bin/send.ts +15 -9
- package/support/cli.email_compile.ts +2 -3
- package/support/cli.email_editor.ts +2 -2
- package/support/cli.email_test.ts +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/email-compiler",
|
|
3
|
-
"version": "5.0.0-rc.
|
|
3
|
+
"version": "5.0.0-rc.10",
|
|
4
4
|
"description": "Email compiling module",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"email",
|
|
@@ -26,12 +26,12 @@
|
|
|
26
26
|
"directory": "module/email-compiler"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@travetto/
|
|
30
|
-
"@travetto/config": "^5.0.0-rc.
|
|
31
|
-
"@travetto/di": "^5.0.0-rc.
|
|
32
|
-
"@travetto/email": "^5.0.0-rc.
|
|
33
|
-
"@travetto/image": "^5.0.0-rc.
|
|
34
|
-
"@travetto/worker": "^5.0.0-rc.
|
|
29
|
+
"@travetto/runtime": "^5.0.0-rc.9",
|
|
30
|
+
"@travetto/config": "^5.0.0-rc.10",
|
|
31
|
+
"@travetto/di": "^5.0.0-rc.9",
|
|
32
|
+
"@travetto/email": "^5.0.0-rc.10",
|
|
33
|
+
"@travetto/image": "^5.0.0-rc.9",
|
|
34
|
+
"@travetto/worker": "^5.0.0-rc.9",
|
|
35
35
|
"@types/inline-css": "^3.0.3",
|
|
36
36
|
"html-entities": "^2.5.2",
|
|
37
37
|
"inline-css": "^4.0.2",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"sass": "^1.77.6"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
|
-
"@travetto/cli": "^5.0.0-rc.
|
|
42
|
+
"@travetto/cli": "^5.0.0-rc.10"
|
|
43
43
|
},
|
|
44
44
|
"peerDependenciesMeta": {
|
|
45
45
|
"@travetto/cli": {
|
package/src/compiler.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import fs from 'node:fs/promises';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
|
|
4
|
-
import { TypedObject, Util, watchCompiler } from '@travetto/
|
|
4
|
+
import { TypedObject, Util, RuntimeIndex, watchCompiler, Runtime } from '@travetto/runtime';
|
|
5
5
|
import { EmailCompiled, MailUtil, EmailTemplateImport, EmailTemplateModule } from '@travetto/email';
|
|
6
|
-
import { RuntimeIndex } from '@travetto/manifest';
|
|
7
6
|
|
|
8
7
|
import { EmailCompileUtil } from './util';
|
|
9
8
|
|
|
@@ -16,13 +15,9 @@ export class EmailCompiler {
|
|
|
16
15
|
* Load Template
|
|
17
16
|
*/
|
|
18
17
|
static async loadTemplate(file: string): Promise<EmailTemplateModule> {
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
throw new Error(`Unable to find template for ${file}`);
|
|
23
|
-
}
|
|
24
|
-
const root: EmailTemplateImport = (await import(entry.outputFile)).default;
|
|
25
|
-
return await root.prepare({ file, module: mod.name });
|
|
18
|
+
const root = (await Runtime.importFrom<{ default: EmailTemplateImport }>(file)).default;
|
|
19
|
+
const entry = RuntimeIndex.getEntry(file)!;
|
|
20
|
+
return await root.prepare({ file, module: entry.module });
|
|
26
21
|
}
|
|
27
22
|
|
|
28
23
|
/**
|
package/src/util.ts
CHANGED
|
@@ -140,7 +140,7 @@ export class EmailCompileUtil {
|
|
|
140
140
|
const output = await ImageConverter.optimize(
|
|
141
141
|
ext === '.png' ? 'png' : 'jpeg', await opts.loader.readStream(src)
|
|
142
142
|
);
|
|
143
|
-
const buffer = toBuffer(output);
|
|
143
|
+
const buffer = await toBuffer(output);
|
|
144
144
|
pendingImages.push([token, ext, buffer]);
|
|
145
145
|
} else {
|
|
146
146
|
pendingImages.push([token, ext, opts.loader.read(src, true)]);
|
package/support/bin/config.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import fs from 'node:fs/promises';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { Util, Runtime } from '@travetto/runtime';
|
|
4
4
|
import { parse, stringify } from 'yaml';
|
|
5
|
-
import { Util } from '@travetto/base';
|
|
6
5
|
|
|
7
6
|
import { EditorConfigType } from './types';
|
|
8
7
|
|
|
@@ -36,13 +35,12 @@ export class EditorConfig {
|
|
|
36
35
|
static async get(): Promise<EditorConfigType>;
|
|
37
36
|
static async get<K extends keyof EditorConfigType>(key?: K): Promise<EditorConfigType | EditorConfigType[K]> {
|
|
38
37
|
try {
|
|
39
|
-
const resolved =
|
|
38
|
+
const resolved = Runtime.workspaceRelative(CONFIG_FILE);
|
|
40
39
|
const content = await fs.readFile(resolved, 'utf8');
|
|
41
40
|
const data: EditorConfigType = parse(content) ?? {};
|
|
42
41
|
return key ? data[key] : data;
|
|
43
42
|
} catch {
|
|
44
|
-
|
|
45
|
-
return {} as EditorConfigType;
|
|
43
|
+
return { to: undefined!, from: undefined! };
|
|
46
44
|
}
|
|
47
45
|
}
|
|
48
46
|
|
|
@@ -51,7 +49,7 @@ export class EditorConfig {
|
|
|
51
49
|
}
|
|
52
50
|
|
|
53
51
|
static async ensureConfig(): Promise<string> {
|
|
54
|
-
const resolved =
|
|
52
|
+
const resolved = Runtime.workspaceRelative(CONFIG_FILE);
|
|
55
53
|
if (!(await fs.stat(resolved).catch(() => { }))) {
|
|
56
54
|
await Util.bufferedFileWrite(resolved, this.getDefaultConfig());
|
|
57
55
|
}
|
package/support/bin/editor.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Inject, Injectable } from '@travetto/di';
|
|
2
2
|
import { MailUtil, EmailCompiled, MailInterpolator } from '@travetto/email';
|
|
3
|
-
import { AppError, TypedObject } from '@travetto/
|
|
3
|
+
import { AppError, TypedObject } from '@travetto/runtime';
|
|
4
4
|
|
|
5
5
|
import { EditorSendService } from './send';
|
|
6
6
|
import { EditorConfig } from './config';
|
package/support/bin/send.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MailService, EmailOptions
|
|
1
|
+
import { MailService, EmailOptions } from '@travetto/email';
|
|
2
2
|
import { MailTransportTarget } from '@travetto/email/src/internal/types';
|
|
3
3
|
import { DependencyRegistry, Injectable } from '@travetto/di';
|
|
4
4
|
|
|
@@ -29,7 +29,7 @@ export class EditorSendService {
|
|
|
29
29
|
DependencyRegistry.install(cls, { curr: cls, type: 'added' });
|
|
30
30
|
|
|
31
31
|
this.ethereal = !!senderConfig.host?.includes('ethereal.email');
|
|
32
|
-
} catch
|
|
32
|
+
} catch {
|
|
33
33
|
console.error('A mail transport is currently needed to support sending emails. Please install @travetto/email-nodemailer or any other compatible transport');
|
|
34
34
|
throw new Error('A mail transport is currently needed to support sending emails. Please install @travetto/email-nodemailer or any other compatible transport');
|
|
35
35
|
}
|
|
@@ -45,13 +45,19 @@ export class EditorSendService {
|
|
|
45
45
|
try {
|
|
46
46
|
console.log('Sending email', { to });
|
|
47
47
|
const svc = await this.service();
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
url
|
|
54
|
-
|
|
48
|
+
if (this.ethereal) {
|
|
49
|
+
const { getTestMessageUrl } = await import('nodemailer');
|
|
50
|
+
const { default: _smtp } = await import('nodemailer/lib/smtp-transport/index');
|
|
51
|
+
type SendMessage = Parameters<Parameters<(typeof _smtp)['prototype']['send']>[1]>[1];
|
|
52
|
+
const info = await svc.send<SendMessage>(message);
|
|
53
|
+
const url = getTestMessageUrl(info);
|
|
54
|
+
console.log('Sent email', { to, url });
|
|
55
|
+
return { url };
|
|
56
|
+
} else {
|
|
57
|
+
await svc.send(message);
|
|
58
|
+
console.log('Sent email', { to });
|
|
59
|
+
return {};
|
|
60
|
+
}
|
|
55
61
|
} catch (err) {
|
|
56
62
|
console.warn('Failed to send email', { to, error: err });
|
|
57
63
|
throw err;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { RootRegistry } from '@travetto/registry';
|
|
2
2
|
import { CliCommandShape, CliCommand, cliTpl } from '@travetto/cli';
|
|
3
|
-
import { Env } from '@travetto/
|
|
4
|
-
import { RuntimeContext } from '@travetto/manifest';
|
|
3
|
+
import { Env, Runtime } from '@travetto/runtime';
|
|
5
4
|
|
|
6
5
|
import { EmailCompiler } from '../src/compiler';
|
|
7
6
|
|
|
@@ -27,7 +26,7 @@ export class EmailCompileCommand implements CliCommandShape {
|
|
|
27
26
|
const all = await EmailCompiler.compileAll();
|
|
28
27
|
console!.log(cliTpl`Successfully compiled ${{ param: `${all.length}` }} templates`);
|
|
29
28
|
for (const el of all) {
|
|
30
|
-
console!.log(cliTpl` * ${{ param:
|
|
29
|
+
console!.log(cliTpl` * ${{ param: Runtime.stripWorkspacePath(el) }}`);
|
|
31
30
|
}
|
|
32
31
|
|
|
33
32
|
if (this.watch) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Env } from '@travetto/
|
|
1
|
+
import { Env } from '@travetto/runtime';
|
|
2
2
|
import { CliCommand, CliUtil } from '@travetto/cli';
|
|
3
3
|
import { RootRegistry } from '@travetto/registry';
|
|
4
4
|
import { DependencyRegistry } from '@travetto/di';
|
|
@@ -6,7 +6,7 @@ import { DependencyRegistry } from '@travetto/di';
|
|
|
6
6
|
import { EditorService } from './bin/editor';
|
|
7
7
|
|
|
8
8
|
/** The email editor compilation service and output serving */
|
|
9
|
-
@CliCommand({
|
|
9
|
+
@CliCommand({ with: { env: true } })
|
|
10
10
|
export class EmailEditorCommand {
|
|
11
11
|
|
|
12
12
|
preMain(): void {
|
|
@@ -3,14 +3,14 @@ import path from 'node:path';
|
|
|
3
3
|
import { RootRegistry } from '@travetto/registry';
|
|
4
4
|
import { CliCommandShape, CliCommand } from '@travetto/cli';
|
|
5
5
|
import { DependencyRegistry } from '@travetto/di';
|
|
6
|
-
import { Env } from '@travetto/
|
|
6
|
+
import { Env } from '@travetto/runtime';
|
|
7
7
|
|
|
8
8
|
import { EditorService } from './bin/editor';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* CLI Entry point for running the email server
|
|
12
12
|
*/
|
|
13
|
-
@CliCommand({
|
|
13
|
+
@CliCommand({ with: { env: true } })
|
|
14
14
|
export class EmailTestCommand implements CliCommandShape {
|
|
15
15
|
|
|
16
16
|
preMain(): void {
|