Compare commits
4 commits
dc000ac4de
...
a88178c2ce
Author | SHA1 | Date | |
---|---|---|---|
Julien Oculi | a88178c2ce | ||
Julien Oculi | 09f84fc493 | ||
Julien Oculi | 27519378e5 | ||
Julien Oculi | 2b29a4c9e8 |
2
cli.ts
2
cli.ts
|
@ -1,5 +1,5 @@
|
|||
import config from './deno.json' with { type: 'json' }
|
||||
import { Command } from '@cliffy/command/command.ts'
|
||||
import { Command } from '@cliffy/command'
|
||||
import { cmd as send } from './cli/send.ts'
|
||||
import { cmd as preview } from './cli/preview.ts'
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Input } from '@cliffy/prompt/input.ts'
|
||||
import { Input } from '@cliffy/prompt'
|
||||
import type { Template } from '../types.ts'
|
||||
import type { JSX } from 'preact'
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { fromFileUrl } from '@std/path'
|
||||
import type { JSX } from 'preact'
|
||||
import { EnumType } from '@cliffy/command/mod.ts'
|
||||
import { EnumType } from '@cliffy/command'
|
||||
import type { Template } from '../types.ts'
|
||||
|
||||
export const templates: Map<
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Command } from '@cliffy/command/mod.ts'
|
||||
import { Command } from '@cliffy/command'
|
||||
import { renderTemplate } from '../src/template.tsx'
|
||||
import { templates, templateType } from './_templates_loader.ts'
|
||||
import { promptProps } from './_prompt_template.ts'
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Command } from '@cliffy/command/mod.ts'
|
||||
import { Command } from '@cliffy/command'
|
||||
import { Contact } from '../src/contact.ts'
|
||||
import { send } from '../src/send.ts'
|
||||
import type { Mail } from '../types.ts'
|
||||
|
|
10
deno.json
10
deno.json
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"name": "@cohabit/cohamail",
|
||||
"name": "@cohabit/mailer",
|
||||
"version": "0.2.1",
|
||||
"exports": {
|
||||
".": "./mod.ts",
|
||||
|
@ -8,9 +8,8 @@
|
|||
"./templates": "./templates/mod.ts"
|
||||
},
|
||||
"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/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",
|
||||
"utils:scp": "scp -O -P 55555 -i C:/Users/Julien/.ssh/id_ed25519_cohabit -r $(pwd) julien@cohabit.fr:/home/julien/cohabit_mail"
|
||||
"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",
|
||||
"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"
|
||||
},
|
||||
"fmt": {
|
||||
"singleQuote": true,
|
||||
|
@ -18,7 +17,8 @@
|
|||
"useTabs": true
|
||||
},
|
||||
"imports": {
|
||||
"@cliffy/": "https://deno.land/x/cliffy@v1.0.0-rc.3/",
|
||||
"@cliffy/command": "jsr:@cliffy/command@^1.0.0-rc.5",
|
||||
"@cliffy/prompt": "jsr:@cliffy/prompt@^1.0.0-rc.5",
|
||||
"@std/path": "jsr:@std/path@^0.221.0",
|
||||
"jsx-email": "npm:jsx-email@^1.10.12",
|
||||
"nodemailer": "npm:nodemailer@^6.9.13",
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import custom from '../config/account.json' with { type: 'json' }
|
||||
import accounts from '../config/account.json' with { type: 'json' }
|
||||
import dkim from '../config/dkim.json' with { type: 'json' }
|
||||
|
||||
export class Contact {
|
||||
#name: string
|
||||
|
@ -15,11 +16,11 @@ export class Contact {
|
|||
}
|
||||
|
||||
static expand(shortName: string): Contact {
|
||||
if (!(shortName in custom)) {
|
||||
if (!(shortName in accounts)) {
|
||||
throw new Error('unknown short name contact')
|
||||
}
|
||||
|
||||
const { name, address } = custom[shortName as keyof typeof custom]
|
||||
const { name, address } = accounts[shortName as keyof typeof accounts]
|
||||
|
||||
if (typeof name !== 'string') {
|
||||
throw new SyntaxError(
|
||||
|
@ -31,7 +32,9 @@ export class Contact {
|
|||
`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(
|
||||
`invalid "address" in contact short name config for "${shortName}"`,
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue