Compare commits

..

5 commits
0.4.0 ... main

5 changed files with 37 additions and 15 deletions

View file

@ -42,3 +42,8 @@ deno install \
# OR # OR
./cohamail <subcommand> -h ./cohamail <subcommand> -h
``` ```
## Configuration
You can override default config and templates with your own in
`/etc/cohabit/mailer/(config|templates)/`.

View file

@ -1,3 +1,4 @@
import { exists } from '@std/fs/exists'
import type { JSX } from 'preact' import type { JSX } from 'preact'
import { EnumType } from '@cliffy/command' import { EnumType } from '@cliffy/command'
import type { Template } from '../types.ts' import type { Template } from '../types.ts'
@ -18,17 +19,19 @@ for (const template of Object.values(defaultTemplates)) {
} }
//Load local templates //Load local templates
const basePath = '/etc/cohabit/mailer' const basePath = '/etc/cohabit/mailer/templates'
for await ( if (await exists(basePath)) {
const template of Deno.readDir(basePath) for await (const template of Deno.readDir(basePath)) {
) {
if (!template.isFile) continue if (!template.isFile) continue
if (!template.name.endsWith('.tsx')) continue if (!template.name.endsWith('.tsx')) continue
if (template.name.startsWith('_')) continue if (template.name.startsWith('_')) continue
const mod = await import(`${basePath}/${template.name}`).catch(checkFsErrors) const mod = await import(`${basePath}/${template.name}`).catch(
checkFsErrors,
)
templates.set(mod.default.name, mod.default) templates.set(mod.default.name, mod.default)
}
} }
function checkFsErrors(error: Error) { function checkFsErrors(error: Error) {

View file

@ -37,7 +37,7 @@ async function readJsonFile<
return { ...defaultValue, ...json } return { ...defaultValue, ...json }
} }
const basePath = '/ect/cohabit/mailer' const basePath = '/ect/cohabit/mailer/config'
export const accounts = await readJsonFile<AccountRecord>( export const accounts = await readJsonFile<AccountRecord>(
`${basePath}/account.json`, `${basePath}/account.json`,

View file

@ -1,6 +1,6 @@
{ {
"name": "@cohabit/mailer", "name": "@cohabit/mailer",
"version": "0.3.3", "version": "0.5.2",
"exports": { "exports": {
".": "./mod.ts", ".": "./mod.ts",
"./cli": "./cli.ts", "./cli": "./cli.ts",
@ -8,8 +8,8 @@
"./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,jsr.io --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" "cli": "deno run --allow-read --allow-env --allow-net=0.0.0.0,jsr.io --allow-sys=osRelease,networkInterfaces --allow-run=/usr/sbin/sendmail,whoami ./cli.ts"
}, },
"fmt": { "fmt": {
"singleQuote": true, "singleQuote": true,
@ -19,6 +19,7 @@
"imports": { "imports": {
"@cliffy/command": "jsr:@cliffy/command@^1.0.0-rc.5", "@cliffy/command": "jsr:@cliffy/command@^1.0.0-rc.5",
"@cliffy/prompt": "jsr:@cliffy/prompt@^1.0.0-rc.5", "@cliffy/prompt": "jsr:@cliffy/prompt@^1.0.0-rc.5",
"@std/fs": "jsr:@std/fs@^1.0.13",
"@std/json": "jsr:@std/json@^1.0.1", "@std/json": "jsr:@std/json@^1.0.1",
"@types/nodemailer": "npm:@types/nodemailer@^6.4.15", "@types/nodemailer": "npm:@types/nodemailer@^6.4.15",
"jsx-email": "npm:jsx-email@^1.10.12", "jsx-email": "npm:jsx-email@^1.10.12",
@ -30,5 +31,6 @@
"compilerOptions": { "compilerOptions": {
"jsx": "react-jsx", "jsx": "react-jsx",
"jsxImportSource": "preact" "jsxImportSource": "preact"
} },
"license": "MIT"
} }

View file

@ -12,9 +12,11 @@
"jsr:@std/cli@1.0.0-rc.2": "1.0.0-rc.2", "jsr:@std/cli@1.0.0-rc.2": "1.0.0-rc.2",
"jsr:@std/encoding@1.0.0-rc.2": "1.0.0-rc.2", "jsr:@std/encoding@1.0.0-rc.2": "1.0.0-rc.2",
"jsr:@std/fmt@~0.225.4": "0.225.6", "jsr:@std/fmt@~0.225.4": "0.225.6",
"jsr:@std/fs@^1.0.13": "1.0.13",
"jsr:@std/io@~0.224.2": "0.224.3", "jsr:@std/io@~0.224.2": "0.224.3",
"jsr:@std/json@^1.0.1": "1.0.1", "jsr:@std/json@^1.0.1": "1.0.1",
"jsr:@std/path@1.0.0-rc.2": "1.0.0-rc.2", "jsr:@std/path@1.0.0-rc.2": "1.0.0-rc.2",
"jsr:@std/path@^1.0.8": "1.0.8",
"jsr:@std/streams@^1.0.7": "1.0.9", "jsr:@std/streams@^1.0.7": "1.0.9",
"jsr:@std/text@1.0.0-rc.1": "1.0.0-rc.1", "jsr:@std/text@1.0.0-rc.1": "1.0.0-rc.1",
"npm:@types/node@*": "18.16.19", "npm:@types/node@*": "18.16.19",
@ -66,7 +68,7 @@
"jsr:@std/assert", "jsr:@std/assert",
"jsr:@std/fmt", "jsr:@std/fmt",
"jsr:@std/io", "jsr:@std/io",
"jsr:@std/path", "jsr:@std/path@1.0.0-rc.2",
"jsr:@std/text" "jsr:@std/text"
] ]
}, },
@ -89,6 +91,12 @@
"@std/fmt@0.225.6": { "@std/fmt@0.225.6": {
"integrity": "aba6aea27f66813cecfd9484e074a9e9845782ab0685c030e453a8a70b37afc8" "integrity": "aba6aea27f66813cecfd9484e074a9e9845782ab0685c030e453a8a70b37afc8"
}, },
"@std/fs@1.0.13": {
"integrity": "756d3ff0ade91c9e72b228e8012b6ff00c3d4a4ac9c642c4dac083536bf6c605",
"dependencies": [
"jsr:@std/path@^1.0.8"
]
},
"@std/io@0.224.3": { "@std/io@0.224.3": {
"integrity": "b402edeb99c6b3778d9ae3e9927bc9085b170b41e5a09bbb7064ab2ee394ae2f" "integrity": "b402edeb99c6b3778d9ae3e9927bc9085b170b41e5a09bbb7064ab2ee394ae2f"
}, },
@ -101,6 +109,9 @@
"@std/path@1.0.0-rc.2": { "@std/path@1.0.0-rc.2": {
"integrity": "39f20d37a44d1867abac8d91c169359ea6e942237a45a99ee1e091b32b921c7d" "integrity": "39f20d37a44d1867abac8d91c169359ea6e942237a45a99ee1e091b32b921c7d"
}, },
"@std/path@1.0.8": {
"integrity": "548fa456bb6a04d3c1a1e7477986b6cffbce95102d0bb447c67c4ee70e0364be"
},
"@std/streams@1.0.9": { "@std/streams@1.0.9": {
"integrity": "a9d26b1988cdd7aa7b1f4b51e1c36c1557f3f252880fa6cc5b9f37078b1a5035" "integrity": "a9d26b1988cdd7aa7b1f4b51e1c36c1557f3f252880fa6cc5b9f37078b1a5035"
}, },
@ -3814,6 +3825,7 @@
"dependencies": [ "dependencies": [
"jsr:@cliffy/command@^1.0.0-rc.5", "jsr:@cliffy/command@^1.0.0-rc.5",
"jsr:@cliffy/prompt@^1.0.0-rc.5", "jsr:@cliffy/prompt@^1.0.0-rc.5",
"jsr:@std/fs@^1.0.13",
"jsr:@std/json@^1.0.1", "jsr:@std/json@^1.0.1",
"npm:@types/nodemailer@^6.4.15", "npm:@types/nodemailer@^6.4.15",
"npm:jsx-email@^1.10.12", "npm:jsx-email@^1.10.12",