Skip to content

Commit ff25cd9

Browse files
committed
first version
1 parent 34c1f39 commit ff25cd9

File tree

18 files changed

+4586
-0
lines changed

18 files changed

+4586
-0
lines changed

.editorconfig

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
[*]
3+
indent_style = space
4+
indent_size = 2
5+
end_of_line = lf
6+
charset = utf-8
7+
trim_trailing_whitespace = true
8+
insert_final_newline = true
9+
10+
[*.json]
11+
insert_final_newline = ignore
12+
13+
[*.md]
14+
trim_trailing_whitespace = false

.github/workflows/issue.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Notify on Issue or Comment
2+
3+
on:
4+
issues:
5+
types: [opened, edited]
6+
issue_comment:
7+
types: [created, edited]
8+
9+
jobs:
10+
notify-discord:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Notification
15+
uses: appleboy/telegram-action@master
16+
with:
17+
token: ${{ secrets.BOT_TOKEN }}
18+
to: ${{ secrets.CHAT_ID }}
19+
message: |
20+
Repository: ${{ github.repository }}
21+
Event: ${{ github.event_name }}
22+
Action: ${{ github.event.action }}
23+
24+
Issue Title: ${{ github.event.issue.title }}
25+
Issue URL: ${{ github.event.issue.html_url }}
26+
27+
User: ${{ github.event.issue.user.login }}
28+
Comment: ${{ github.event.comment.body || 'No comment' }}

.github/workflows/npm-publish.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: NPM publish
2+
3+
on:
4+
push:
5+
branches:
6+
- 'main'
7+
8+
env:
9+
success:
10+
failure: 🔴
11+
cancelled:
12+
skipped:
13+
node_version: 22
14+
true:
15+
false: 🔴
16+
17+
jobs:
18+
release:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v3
22+
23+
- id: release
24+
uses: halvardssm/github-action-tag-release@1.0.0
25+
with:
26+
token: ${{ secrets.GITHUB_TOKEN }}
27+
path: './package.json' # optional, will use ./package.json by default
28+
29+
- run: |
30+
echo 'Release created: ${{steps.release.outputs.release_created}}' # 'true' or 'false'
31+
echo 'Release exists: ${{steps.release.outputs.release_exists}}' # 'true' or 'false'
32+
echo 'Release tag: ${{steps.release.outputs.release_tag}}' # The tag from package.json
33+
34+
- name: Notification
35+
if: ${{ always() }}
36+
uses: appleboy/telegram-action@master
37+
with:
38+
token: ${{ secrets.BOT_TOKEN }}
39+
to: ${{ secrets.CHAT_ID }}
40+
message: |
41+
Repository: ${{ github.repository }}
42+
Release : ${{ env[steps.release.outputs.release_created] }}
43+
Tag: ${{ steps.release.outputs.release_tag }}
44+
45+
publish-npm:
46+
needs: release
47+
runs-on: ubuntu-latest
48+
steps:
49+
- uses: actions/checkout@v3
50+
51+
- uses: actions/setup-node@v3
52+
with:
53+
node-version: 22
54+
registry-url: https://registry.npmjs.org/
55+
56+
- run: npm ci
57+
- run: npm publish
58+
env:
59+
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
60+
61+
- name: Notification
62+
if: ${{ always() }}
63+
uses: appleboy/telegram-action@master
64+
with:
65+
token: ${{ secrets.BOT_TOKEN }}
66+
to: ${{ secrets.CHAT_ID }}
67+
message: |
68+
Repository: ${{ github.repository }}
69+
npm publish : ${{ env[job.status] }}

.github/workflows/pull-request.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Notify on Pull Request
2+
3+
on:
4+
pull_request:
5+
types: [opened, edited, closed]
6+
7+
jobs:
8+
notify-telegram:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Send Telegram Notification
13+
uses: appleboy/telegram-action@master
14+
with:
15+
token: ${{ secrets.BOT_TOKEN }}
16+
to: ${{ secrets.CHAT_ID }}
17+
message: |
18+
Repository: ${{ github.repository }}
19+
Event Type: ${{ github.event_name }}
20+
Action: ${{ github.event.action }}
21+
User: ${{ github.event.sender.login }}
22+
23+
Pull Request Title: ${{ github.event.pull_request.title }}
24+
Pull Request URL: ${{ github.event.pull_request.html_url }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ yarn-error.log*
77
lerna-debug.log*
88
.pnpm-debug.log*
99

10+
build
11+
1012
# Diagnostic reports (https://nodejs.org/api/report.html)
1113
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
1214

.npmignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.editorconfig
2+
.github
3+
node_modules
4+
5+
tsconfig.json

.prettierignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
build
2+
docs
3+
*.md
4+
config.json
5+
.eslintrc.json
6+
package.json
7+
*.html
8+
*.txt

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Jeremy Chaufourier
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

commands/make/etl.ts

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
/**
2+
* @jrmc/adonis-etl
3+
*
4+
* @license MIT
5+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6+
*/
7+
8+
// import { stubsRoot } from '../../stubs/main.js'
9+
import { args, BaseCommand } from '@adonisjs/core/ace'
10+
import string from '@adonisjs/core/helpers/string'
11+
import { stubsRoot } from '../../stubs/main.js'
12+
13+
export default class MakeEtl extends BaseCommand {
14+
static commandName = 'make:etl'
15+
static description = 'Create a new ETL files (source, transform, destination)'
16+
17+
@args.string({ description: 'Name of the ETL process' })
18+
declare name: string
19+
20+
async run() {
21+
// Ask which ETL components to create
22+
const components = await this.prompt.multiple('Which ETL components do you want to create?', [
23+
'Source',
24+
'Transform',
25+
'Destination'
26+
], {
27+
validate: (value) => {
28+
if (!value || value.length === 0) {
29+
return 'You must select at least one component'
30+
}
31+
return true
32+
}
33+
})
34+
35+
// Ask for source details if source is selected
36+
let sourceDetails = null
37+
if (components.includes('Source') || components.includes('Transform')) {
38+
sourceDetails = await this.prompt.ask('What is the source type? (e.g., database, api, file)', {
39+
validate: (value) => {
40+
if (!value || value.trim().length === 0) {
41+
return 'Source type is required'
42+
}
43+
return true
44+
}
45+
})
46+
}
47+
48+
// Ask for destination details if destination is selected
49+
let destinationDetails = null
50+
if (components.includes('Destination') || components.includes('Transform')) {
51+
destinationDetails = await this.prompt.ask('What is the destination type? (e.g., database, api, file)', {
52+
validate: (value) => {
53+
if (!value || value.trim().length === 0) {
54+
return 'Destination type is required'
55+
}
56+
return true
57+
}
58+
})
59+
}
60+
61+
const codemods = await this.createCodemods()
62+
let className = null
63+
64+
// Create the selected components
65+
for (const component of components) {
66+
if (component === 'Source') {
67+
className = [
68+
string.snakeCase(this.name),
69+
string.snakeCase(sourceDetails!),
70+
'source',
71+
].join('_')
72+
} else if (component === 'Destination') {
73+
className = [
74+
string.snakeCase(this.name),
75+
string.snakeCase(destinationDetails!),
76+
'destination',
77+
].join('_')
78+
} else if (component === 'Transform') {
79+
className = [
80+
string.snakeCase(this.name),
81+
string.snakeCase(sourceDetails!),
82+
'to',
83+
string.snakeCase(destinationDetails!),
84+
'transform',
85+
].join('_')
86+
}
87+
88+
const stubPath = `make/etl/${component.toLowerCase()}s/main.ts.stub`
89+
90+
await codemods.makeUsingStub(stubsRoot, stubPath, {
91+
className
92+
})
93+
}
94+
95+
this.logger.success(`ETL files created successfully for: ${this.name}`)
96+
}
97+
}

configure.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import type Configure from '@adonisjs/core/commands/configure'
2+
3+
export async function configure(command: Configure) {
4+
const codemods = await command.createCodemods()
5+
6+
/**
7+
* Register provider
8+
*/
9+
await codemods.updateRcFile((rcFile) => {
10+
rcFile.addCommand('@jrmc/adonis-etl/commands')
11+
})
12+
}

0 commit comments

Comments
 (0)