Compare commits
5 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a090186c54 | ||
|
|
9c948f1f3e | ||
|
|
ee0c106a2c | ||
|
|
2f095b79c5 | ||
|
|
52f9438f6c |
|
|
@ -42,3 +42,8 @@ deno install \
|
|||
# OR
|
||||
./cohamail <subcommand> -h
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
You can override default config and templates with your own in
|
||||
`/etc/cohabit/mailer/(config|templates)/`.
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import { exists } from '@std/fs/exists'
|
||||
import type { JSX } from 'preact'
|
||||
import { EnumType } from '@cliffy/command'
|
||||
import type { Template } from '../types.ts'
|
||||
|
|
@ -18,18 +19,20 @@ for (const template of Object.values(defaultTemplates)) {
|
|||
}
|
||||
|
||||
//Load local templates
|
||||
const basePath = '/etc/cohabit/mailer'
|
||||
const basePath = '/etc/cohabit/mailer/templates'
|
||||
|
||||
for await (
|
||||
const template of Deno.readDir(basePath)
|
||||
) {
|
||||
if (await exists(basePath)) {
|
||||
for await (const template of Deno.readDir(basePath)) {
|
||||
if (!template.isFile) continue
|
||||
if (!template.name.endsWith('.tsx')) 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)
|
||||
}
|
||||
}
|
||||
|
||||
function checkFsErrors(error: Error) {
|
||||
if (error instanceof Deno.errors.PermissionDenied) {
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ async function readJsonFile<
|
|||
return { ...defaultValue, ...json }
|
||||
}
|
||||
|
||||
const basePath = '/ect/cohabit/mailer'
|
||||
const basePath = '/ect/cohabit/mailer/config'
|
||||
|
||||
export const accounts = await readJsonFile<AccountRecord>(
|
||||
`${basePath}/account.json`,
|
||||
|
|
|
|||
10
deno.json
10
deno.json
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@cohabit/mailer",
|
||||
"version": "0.3.3",
|
||||
"version": "0.5.2",
|
||||
"exports": {
|
||||
".": "./mod.ts",
|
||||
"./cli": "./cli.ts",
|
||||
|
|
@ -8,8 +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/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"
|
||||
"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,jsr.io --allow-sys=osRelease,networkInterfaces --allow-run=/usr/sbin/sendmail,whoami ./cli.ts"
|
||||
},
|
||||
"fmt": {
|
||||
"singleQuote": true,
|
||||
|
|
@ -19,6 +19,7 @@
|
|||
"imports": {
|
||||
"@cliffy/command": "jsr:@cliffy/command@^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",
|
||||
"@types/nodemailer": "npm:@types/nodemailer@^6.4.15",
|
||||
"jsx-email": "npm:jsx-email@^1.10.12",
|
||||
|
|
@ -30,5 +31,6 @@
|
|||
"compilerOptions": {
|
||||
"jsx": "react-jsx",
|
||||
"jsxImportSource": "preact"
|
||||
}
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
||||
|
|
|
|||
14
deno.lock
14
deno.lock
|
|
@ -12,9 +12,11 @@
|
|||
"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/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/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.8": "1.0.8",
|
||||
"jsr:@std/streams@^1.0.7": "1.0.9",
|
||||
"jsr:@std/text@1.0.0-rc.1": "1.0.0-rc.1",
|
||||
"npm:@types/node@*": "18.16.19",
|
||||
|
|
@ -66,7 +68,7 @@
|
|||
"jsr:@std/assert",
|
||||
"jsr:@std/fmt",
|
||||
"jsr:@std/io",
|
||||
"jsr:@std/path",
|
||||
"jsr:@std/path@1.0.0-rc.2",
|
||||
"jsr:@std/text"
|
||||
]
|
||||
},
|
||||
|
|
@ -89,6 +91,12 @@
|
|||
"@std/fmt@0.225.6": {
|
||||
"integrity": "aba6aea27f66813cecfd9484e074a9e9845782ab0685c030e453a8a70b37afc8"
|
||||
},
|
||||
"@std/fs@1.0.13": {
|
||||
"integrity": "756d3ff0ade91c9e72b228e8012b6ff00c3d4a4ac9c642c4dac083536bf6c605",
|
||||
"dependencies": [
|
||||
"jsr:@std/path@^1.0.8"
|
||||
]
|
||||
},
|
||||
"@std/io@0.224.3": {
|
||||
"integrity": "b402edeb99c6b3778d9ae3e9927bc9085b170b41e5a09bbb7064ab2ee394ae2f"
|
||||
},
|
||||
|
|
@ -101,6 +109,9 @@
|
|||
"@std/path@1.0.0-rc.2": {
|
||||
"integrity": "39f20d37a44d1867abac8d91c169359ea6e942237a45a99ee1e091b32b921c7d"
|
||||
},
|
||||
"@std/path@1.0.8": {
|
||||
"integrity": "548fa456bb6a04d3c1a1e7477986b6cffbce95102d0bb447c67c4ee70e0364be"
|
||||
},
|
||||
"@std/streams@1.0.9": {
|
||||
"integrity": "a9d26b1988cdd7aa7b1f4b51e1c36c1557f3f252880fa6cc5b9f37078b1a5035"
|
||||
},
|
||||
|
|
@ -3814,6 +3825,7 @@
|
|||
"dependencies": [
|
||||
"jsr:@cliffy/command@^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",
|
||||
"npm:@types/nodemailer@^6.4.15",
|
||||
"npm:jsx-email@^1.10.12",
|
||||
|
|
|
|||
Loading…
Reference in a new issue