@travetto/email-compiler 5.0.0-rc.1 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/email-compiler",
3
- "version": "5.0.0-rc.1",
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/base": "^5.0.0-rc.1",
30
- "@travetto/config": "^5.0.0-rc.1",
31
- "@travetto/di": "^5.0.0-rc.0",
32
- "@travetto/email": "^5.0.0-rc.1",
33
- "@travetto/image": "^5.0.0-rc.1",
34
- "@travetto/worker": "^5.0.0-rc.0",
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.1"
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/base';
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 entry = RuntimeIndex.getEntry(file);
20
- const mod = entry ? RuntimeIndex.getModule(entry.module) : undefined;
21
- if (!entry || !mod) {
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)]);
@@ -1,6 +1,6 @@
1
1
  import fs from 'node:fs/promises';
2
2
 
3
- import { Util, RuntimeContext } from '@travetto/base';
3
+ import { Util, Runtime } from '@travetto/runtime';
4
4
  import { parse, stringify } from 'yaml';
5
5
 
6
6
  import { EditorConfigType } from './types';
@@ -35,13 +35,12 @@ export class EditorConfig {
35
35
  static async get(): Promise<EditorConfigType>;
36
36
  static async get<K extends keyof EditorConfigType>(key?: K): Promise<EditorConfigType | EditorConfigType[K]> {
37
37
  try {
38
- const resolved = RuntimeContext.workspaceRelative(CONFIG_FILE);
38
+ const resolved = Runtime.workspaceRelative(CONFIG_FILE);
39
39
  const content = await fs.readFile(resolved, 'utf8');
40
40
  const data: EditorConfigType = parse(content) ?? {};
41
41
  return key ? data[key] : data;
42
42
  } catch {
43
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
44
- return {} as EditorConfigType;
43
+ return { to: undefined!, from: undefined! };
45
44
  }
46
45
  }
47
46
 
@@ -50,7 +49,7 @@ export class EditorConfig {
50
49
  }
51
50
 
52
51
  static async ensureConfig(): Promise<string> {
53
- const resolved = RuntimeContext.workspaceRelative(CONFIG_FILE);
52
+ const resolved = Runtime.workspaceRelative(CONFIG_FILE);
54
53
  if (!(await fs.stat(resolved).catch(() => { }))) {
55
54
  await Util.bufferedFileWrite(resolved, this.getDefaultConfig());
56
55
  }
@@ -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/base';
3
+ import { AppError, TypedObject } from '@travetto/runtime';
4
4
 
5
5
  import { EditorSendService } from './send';
6
6
  import { EditorConfig } from './config';
@@ -1,4 +1,4 @@
1
- import { MailService, EmailOptions, SentEmail } from '@travetto/email';
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 (err) {
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
- const info = await svc.send<{ host?: string } & SentEmail>(message);
49
- console.log('Sent email', { to });
50
-
51
- return this.ethereal ? {
52
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions, @typescript-eslint/no-explicit-any
53
- url: (await import('nodemailer')).getTestMessageUrl(info as any)
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,6 +1,6 @@
1
1
  import { RootRegistry } from '@travetto/registry';
2
2
  import { CliCommandShape, CliCommand, cliTpl } from '@travetto/cli';
3
- import { Env, RuntimeContext } from '@travetto/base';
3
+ import { Env, Runtime } from '@travetto/runtime';
4
4
 
5
5
  import { EmailCompiler } from '../src/compiler';
6
6
 
@@ -26,7 +26,7 @@ export class EmailCompileCommand implements CliCommandShape {
26
26
  const all = await EmailCompiler.compileAll();
27
27
  console!.log(cliTpl`Successfully compiled ${{ param: `${all.length}` }} templates`);
28
28
  for (const el of all) {
29
- console!.log(cliTpl` * ${{ param: RuntimeContext.stripWorkspacePath(el) }}`);
29
+ console!.log(cliTpl` * ${{ param: Runtime.stripWorkspacePath(el) }}`);
30
30
  }
31
31
 
32
32
  if (this.watch) {
@@ -1,4 +1,4 @@
1
- import { Env } from '@travetto/base';
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({ addEnv: true })
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/base';
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({ addEnv: true })
13
+ @CliCommand({ with: { env: true } })
14
14
  export class EmailTestCommand implements CliCommandShape {
15
15
 
16
16
  preMain(): void {