Compare commits

..

No commits in common. "a88178c2ce4bc7031c76ccb28f6df0c74bcc5c7a" and "dc000ac4defa26b9a5021048555394c77ae7f3f4" have entirely different histories.

8 changed files with 828 additions and 909 deletions

2
cli.ts
View file

@ -1,5 +1,5 @@
import config from './deno.json' with { type: 'json' } import config from './deno.json' with { type: 'json' }
import { Command } from '@cliffy/command' import { Command } from '@cliffy/command/command.ts'
import { cmd as send } from './cli/send.ts' import { cmd as send } from './cli/send.ts'
import { cmd as preview } from './cli/preview.ts' import { cmd as preview } from './cli/preview.ts'

View file

@ -1,4 +1,4 @@
import { Input } from '@cliffy/prompt' import { Input } from '@cliffy/prompt/input.ts'
import type { Template } from '../types.ts' import type { Template } from '../types.ts'
import type { JSX } from 'preact' import type { JSX } from 'preact'

View file

@ -1,6 +1,6 @@
import { fromFileUrl } from '@std/path' import { fromFileUrl } from '@std/path'
import type { JSX } from 'preact' import type { JSX } from 'preact'
import { EnumType } from '@cliffy/command' import { EnumType } from '@cliffy/command/mod.ts'
import type { Template } from '../types.ts' import type { Template } from '../types.ts'
export const templates: Map< export const templates: Map<

View file

@ -1,4 +1,4 @@
import { Command } from '@cliffy/command' import { Command } from '@cliffy/command/mod.ts'
import { renderTemplate } from '../src/template.tsx' import { renderTemplate } from '../src/template.tsx'
import { templates, templateType } from './_templates_loader.ts' import { templates, templateType } from './_templates_loader.ts'
import { promptProps } from './_prompt_template.ts' import { promptProps } from './_prompt_template.ts'

View file

@ -1,4 +1,4 @@
import { Command } from '@cliffy/command' import { Command } from '@cliffy/command/mod.ts'
import { Contact } from '../src/contact.ts' import { Contact } from '../src/contact.ts'
import { send } from '../src/send.ts' import { send } from '../src/send.ts'
import type { Mail } from '../types.ts' import type { Mail } from '../types.ts'

View file

@ -1,5 +1,5 @@
{ {
"name": "@cohabit/mailer", "name": "@cohabit/cohamail",
"version": "0.2.1", "version": "0.2.1",
"exports": { "exports": {
".": "./mod.ts", ".": "./mod.ts",
@ -8,8 +8,9 @@
"./templates": "./templates/mod.ts" "./templates": "./templates/mod.ts"
}, },
"tasks": { "tasks": {
"compile": "deno compile --allow-read --allow-env --allow-net=0.0.0.0 --allow-sys=osRelease,networkInterfaces --allow-run=/usr/sbin/sendmail,whoami --output=bin/mailer --target=x86_64-unknown-linux-gnu ./cli.ts", "compile": "deno compile --allow-read --allow-env --allow-net=0.0.0.0 --allow-sys=osRelease,networkInterfaces --allow-run=/usr/sbin/sendmail,whoami --output=bin/cohamail --target=x86_64-unknown-linux-gnu ./cli.ts",
"cli": "deno run --allow-read --allow-env --allow-net=0.0.0.0 --allow-sys=osRelease,networkInterfaces --allow-run=/usr/sbin/sendmail,whoami ./cli.ts" "cli": "deno run --allow-read --allow-env --allow-net=0.0.0.0 --allow-sys=osRelease,networkInterfaces --allow-run=/usr/sbin/sendmail,whoami ./cli.ts",
"utils:scp": "scp -O -P 55555 -i C:/Users/Julien/.ssh/id_ed25519_cohabit -r $(pwd) julien@cohabit.fr:/home/julien/cohabit_mail"
}, },
"fmt": { "fmt": {
"singleQuote": true, "singleQuote": true,
@ -17,8 +18,7 @@
"useTabs": true "useTabs": true
}, },
"imports": { "imports": {
"@cliffy/command": "jsr:@cliffy/command@^1.0.0-rc.5", "@cliffy/": "https://deno.land/x/cliffy@v1.0.0-rc.3/",
"@cliffy/prompt": "jsr:@cliffy/prompt@^1.0.0-rc.5",
"@std/path": "jsr:@std/path@^0.221.0", "@std/path": "jsr:@std/path@^0.221.0",
"jsx-email": "npm:jsx-email@^1.10.12", "jsx-email": "npm:jsx-email@^1.10.12",
"nodemailer": "npm:nodemailer@^6.9.13", "nodemailer": "npm:nodemailer@^6.9.13",

1706
deno.lock

File diff suppressed because it is too large Load diff

View file

@ -1,5 +1,4 @@
import accounts from '../config/account.json' with { type: 'json' } import custom from '../config/account.json' with { type: 'json' }
import dkim from '../config/dkim.json' with { type: 'json' }
export class Contact { export class Contact {
#name: string #name: string
@ -16,11 +15,11 @@ export class Contact {
} }
static expand(shortName: string): Contact { static expand(shortName: string): Contact {
if (!(shortName in accounts)) { if (!(shortName in custom)) {
throw new Error('unknown short name contact') throw new Error('unknown short name contact')
} }
const { name, address } = accounts[shortName as keyof typeof accounts] const { name, address } = custom[shortName as keyof typeof custom]
if (typeof name !== 'string') { if (typeof name !== 'string') {
throw new SyntaxError( throw new SyntaxError(
@ -32,9 +31,7 @@ export class Contact {
`missing key "address" in contact short name config for "${shortName}"`, `missing key "address" in contact short name config for "${shortName}"`,
) )
} }
if (!(/\w+@(\w+\.)?cohabit\.fr/.test(address))) {
const addressRegExp = new RegExp(String.raw`\w+@(\w+\.)?${dkim.domainName}`)
if (!(addressRegExp.test(address))) {
throw new SyntaxError( throw new SyntaxError(
`invalid "address" in contact short name config for "${shortName}"`, `invalid "address" in contact short name config for "${shortName}"`,
) )