Skip to content

Commit 0da2e80

Browse files
committed
feat: first version !
1 parent f6c257a commit 0da2e80

File tree

19 files changed

+3538
-2
lines changed

19 files changed

+3538
-2
lines changed

.github/workflows/build.yaml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: build
2+
3+
on:
4+
push:
5+
branches:
6+
- '*'
7+
pull_request:
8+
branches:
9+
- 'master'
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
node: ['14', '16', '18']
17+
name: Test Node v${{ matrix.node }} version
18+
steps:
19+
- uses: actions/checkout@v3
20+
21+
- name: Setup node
22+
uses: actions/setup-node@v3
23+
with:
24+
node-version: ${{ matrix.node }}
25+
26+
- name: Cache pnpm modules
27+
uses: actions/cache@v3
28+
with:
29+
path: ~/.pnpm-store
30+
key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}
31+
restore-keys: |
32+
${{ runner.os }}-
33+
34+
- name: Install pnpm
35+
uses: pnpm/action-setup@v2.2.1
36+
with:
37+
version: 7
38+
39+
- name: Install packages
40+
run: pnpm install --frozen-lockfile --ignore-script
41+
42+
- name: Lint the sources
43+
run: pnpm format
44+
45+
- name: Lint the sources
46+
run: pnpm lint

.github/workflows/publish.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: release
2+
3+
on:
4+
release:
5+
types: [created]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v3
12+
13+
- name: Setup node
14+
uses: actions/setup-node@v3
15+
with:
16+
node-version: '16.x'
17+
registry-url: 'https://registry.npmjs.org'
18+
scope: '@vafanassieff'
19+
20+
- name: Cache pnpm modules
21+
uses: actions/cache@v3
22+
with:
23+
path: ~/.pnpm-store
24+
key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}
25+
restore-keys: |
26+
${{ runner.os }}-
27+
28+
- name: Install pnpm
29+
uses: pnpm/action-setup@v2.2.1
30+
with:
31+
version: 7
32+
33+
- name: Install packages
34+
run: pnpm install --frozen-lockfile --ignore-script
35+
36+
- name: Lint the sources
37+
run: pnpm format
38+
39+
- name: Lint the sources
40+
run: pnpm lint
41+
42+
- run: pnpm publish --no-git-checks
43+
env:
44+
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

.husky/commit-msg

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
#!/usr/bin/env bash
3+
4+
. "$(dirname "$0")/_/husky.sh"
5+
6+
pnpm commitlint --edit "$1"

.husky/pre-commit

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bash
2+
3+
. "$(dirname "$0")/_/husky.sh"
4+
5+
pnpm lint-staged

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
# alias-ovh
2-
Create an ovh email alias easy
1+
# mail-alias
2+
3+
Create a mail alias easly from CLI !
4+

bin/index.js

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/usr/bin/env node
2+
3+
import 'zx/globals'
4+
import console from 'node:console'
5+
import process from 'node:process'
6+
7+
import { Command } from 'commander'
8+
9+
import add from '#src/base/add.js'
10+
import list from '#src/base/list.js'
11+
import remove from '#src/base/remove.js'
12+
import configure from '#src/provider/configure.js'
13+
import set from '#src/provider/set.js'
14+
15+
const program = new Command()
16+
17+
const provider = new Command('provider')
18+
19+
$.verbose = false
20+
21+
provider
22+
.command('configure')
23+
.description('Configure a provider')
24+
.argument('<provider>', 'Provider to configure')
25+
.action(configure)
26+
27+
provider
28+
.command('set')
29+
.description('Set the used provider')
30+
.argument('<provider>', 'Provider to use')
31+
.action(set)
32+
33+
program.name('mail-alias').description('Manage email aliass').version('0.1.0')
34+
35+
program.command('list').description('List current aliass').action(list)
36+
37+
program
38+
.command('add')
39+
.description('Add a new alias')
40+
.requiredOption('--from <string>', 'alias email')
41+
.requiredOption('--to <string>', 'Destination email')
42+
.action(add)
43+
44+
program
45+
.command('remove')
46+
.description('Add a new alias')
47+
.argument('<alias>', 'alias to remove')
48+
.action(remove)
49+
50+
program.addCommand(provider)
51+
52+
program.exitOverride()
53+
54+
try {
55+
await program.parseAsync(process.argv)
56+
} catch (error) {
57+
console.error(error.message)
58+
process.exit(-1)
59+
}

docs/ovh.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# OVH
2+
3+
To add OVH keys use `email-alias provider configure ovh` and `email-alias provider set ovh`
4+
5+
You need to create an API key [https://www.ovh.com/auth/api/createToken](here)
6+
7+
The key need to have this permissions :
8+
9+
The **{domain}** is the domain on ovh (i.e `example.com`)
10+
11+
- `GET: /email/domain/{domain}/redirection/*`
12+
- `PUT: /email/domain/{domain}/redirection/*`
13+
- `POST: /email/domain/{domain}/redirection/*`
14+
- `DELETE: /email/domain/{domain}/redirection/*`

jsconfig.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"compilerOptions": {
3+
"module": "CommonJS",
4+
"target": "ES2021",
5+
"baseUrl": ".",
6+
"paths": {
7+
"#src/*": [
8+
"src/*"
9+
],
10+
}
11+
},
12+
"include": [
13+
"**/*.js",
14+
]
15+
}

package.json

Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
{
2+
"name": "@vafanassieff/mail-alias",
3+
"version": "0.1.0",
4+
"description": "Create an email alias !",
5+
"main": "src/index.js",
6+
"repository": {
7+
"type": "git",
8+
"url": "git@github.com:vafanassieff/mail-alias.git"
9+
},
10+
"author": "Victor Afanassieff <victor@afanassieff.com>",
11+
"publishConfig": {
12+
"access": "public"
13+
},
14+
"bugs": {
15+
"url": "https://github.com/vafanassieff/mail-alias/issues"
16+
},
17+
"homepage": "https://github.com/vafanassieff/mail-alias#readme",
18+
"keywords": [
19+
"email",
20+
"alias",
21+
"ovh",
22+
"cli",
23+
"tool",
24+
"redirection",
25+
"privacy"
26+
],
27+
"license": "MIT",
28+
"engines": {
29+
"node": ">=14",
30+
"pnpm": ">=7"
31+
},
32+
"type": "module",
33+
"files": [
34+
"bin/**/*.js",
35+
"src/**/*.js"
36+
],
37+
"imports": {
38+
"#src/*": "./src/*"
39+
},
40+
"bin": {
41+
"email-alias": "./bin/index.js"
42+
},
43+
"scripts": {
44+
"test": "exit 0",
45+
"prepare": "husky install",
46+
"eslint": "eslint --fix",
47+
"prettier": "prettier --write",
48+
"lint": "eslint '**/*.js'",
49+
"format": "prettier '**/*.js' --check"
50+
},
51+
"dependencies": {
52+
"commander": "9.2.0",
53+
"zx": "6.1.0"
54+
},
55+
"devDependencies": {
56+
"@commitlint/cli": "^17.0.1",
57+
"@commitlint/config-conventional": "^17.0.0",
58+
"eslint": "^8.16.0",
59+
"eslint-config-prettier": "^8.5.0",
60+
"eslint-import-resolver-alias": "^1.1.2",
61+
"eslint-import-resolver-custom-alias": "^1.3.0",
62+
"eslint-plugin-import": "^2.26.0",
63+
"eslint-plugin-jsdoc": "^39.3.2",
64+
"eslint-plugin-prettier": "^4.0.0",
65+
"eslint-plugin-unicorn": "^42.0.0",
66+
"husky": "^8.0.1",
67+
"lint-staged": "^12.4.2",
68+
"prettier": "^2.6.2"
69+
},
70+
"prettier": {
71+
"printWidth": 80,
72+
"tabWidth": 2,
73+
"semi": false,
74+
"singleQuote": true,
75+
"trailingComma": "es5",
76+
"arrowParens": "always"
77+
},
78+
"commitlint": {
79+
"extends": [
80+
"@commitlint/config-conventional"
81+
]
82+
},
83+
"lint-staged": {
84+
"**/*.js": [
85+
"prettier",
86+
"eslint"
87+
]
88+
},
89+
"eslintConfig": {
90+
"root": true,
91+
"extends": [
92+
"eslint:recommended",
93+
"plugin:unicorn/recommended",
94+
"plugin:prettier/recommended",
95+
"plugin:import/recommended",
96+
"plugin:jsdoc/recommended"
97+
],
98+
"parserOptions": {
99+
"ecmaVersion": "latest",
100+
"sourceType": "module"
101+
},
102+
"ignorePatterns": [
103+
"node_modules/**"
104+
],
105+
"globals": {
106+
"question": true,
107+
"$": true,
108+
"fetch": true
109+
},
110+
"rules": {
111+
"jsdoc/require-jsdoc": [
112+
1,
113+
{
114+
"require": {
115+
"ArrowFunctionExpression": true,
116+
"ClassDeclaration": true,
117+
"ClassExpression": true,
118+
"FunctionDeclaration": true,
119+
"FunctionExpression": true,
120+
"MethodDefinition": true
121+
},
122+
"publicOnly": true,
123+
"enableFixer": false
124+
}
125+
],
126+
"import/order": [
127+
"error",
128+
{
129+
"groups": [
130+
"builtin",
131+
"external",
132+
"internal",
133+
"parent",
134+
"sibling",
135+
"index"
136+
],
137+
"alphabetize": {
138+
"order": "asc",
139+
"caseInsensitive": true
140+
},
141+
"newlines-between": "always",
142+
"pathGroups": [
143+
{
144+
"pattern": "#src/**",
145+
"group": "internal"
146+
}
147+
]
148+
}
149+
]
150+
},
151+
"settings": {
152+
"import/core-modules": [
153+
"node:process",
154+
"node:console",
155+
"node:os",
156+
"node:net",
157+
"node:crypto",
158+
"node:buffer",
159+
"node:timers",
160+
"node:querystring",
161+
"node:url",
162+
"node:path",
163+
"node:fs",
164+
"node:fs/promises",
165+
"node:timers/promises",
166+
"zx/globals",
167+
"node:stream/promises"
168+
],
169+
"import/resolver": {
170+
"alias": {
171+
"map": [
172+
[
173+
"#src",
174+
"./src"
175+
]
176+
],
177+
"extensions": [
178+
".js",
179+
".json"
180+
]
181+
}
182+
}
183+
}
184+
}
185+
}

0 commit comments

Comments
 (0)