Skip to content

Commit f71cd9b

Browse files
committed
Merge branch 'develop'
2 parents c154557 + 9e179b2 commit f71cd9b

18 files changed

+783
-533
lines changed

.github/workflows/npm-publish.yml

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

CHANGELOG.md

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# 2.0.0
2+
3+
⚠️ BREAKING CHANGE
4+
5+
[@adonisjs/drive](https://docs.adonisjs.com/guides/digging-deeper/drive) is required
6+
7+
***Config basePath is deleted, replace by location option of fs service***
8+
9+
***Refacto getUrl() view helper, [add await](https://github.com/batosai/adonis-attachment?tab=readme-ov-file#urls)***
10+
11+
***Access [serialize](https://github.com/batosai/adonis-attachment?tab=readme-ov-file#by-serialize) is update***
12+
13+
* support @adonisjs/drive
14+
* dependencies update
15+
16+
# 1.1.0
17+
18+
* variantes videos thumbnail
19+
20+
21+
# 1.0.1
22+
23+
* support AdonisJS 6
24+
* attachment file by file system
25+
* save meta data
26+
* variantes images
27+
* serialize

README.md

+31-11
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@ Project sample : [adonis-starter-kit](https://github.com/batosai/adonis-starter-
1515
- [ ] documents thumbnail
1616
- [x] videos thumbnail
1717
- [ ] command regenerate
18-
- [ ] adonis-drive/flydrive
18+
- [x] adonis-drive/flydrive
1919
- [ ] jobs queue
2020
- [ ] edge component
2121
- [x] serialize
2222

23+
⚠️ Breaking change [2.0.0 version](https://github.com/batosai/adonis-attachment/blob/main/CHANGELOG.md), include [@adonisjs/drive](https://docs.adonisjs.com/guides/digging-deeper/drive)
24+
2325
### File sytem
2426

2527
Upload file in public folder.
@@ -42,9 +44,9 @@ Configure differents images sizes and formats
4244

4345
Regenerate variantes files
4446

45-
### Drive (coming soon)
47+
### Drive
4648

47-
Use drive for private file and cloud services
49+
Use [@adonisjs/drive](https://docs.adonisjs.com/guides/digging-deeper/drive) for private file and cloud services
4850

4951
### Jobs queue (coming soon)
5052

@@ -55,13 +57,13 @@ Couple with a job queue (recommended, optional)
5557
Install and configure the package:
5658

5759
```sh
58-
node ace add @jrmc/adonis-attachment
60+
node ace add @jrmc/adonis-attachment@beta
5961
```
6062

6163
Or:
6264

6365
```sh
64-
npm i @jrmc/adonis-attachment
66+
npm i @jrmc/adonis-attachment@beta
6567
node ace configure @jrmc/adonis-attachment
6668
```
6769

@@ -163,23 +165,41 @@ class User extends BaseModel {
163165
## URLs
164166

165167
```ts
166-
user.avatar.getUrl()
167-
user.avatar.getUrl('thumbnail')
168+
await user.avatar.getUrl()
169+
await user.avatar.getUrl('thumbnail')
168170
// or await user.avatar.getVariant('thumbnail').getUrl()
171+
172+
await user.avatar.getSignedUrl()
173+
await user.avatar.getSignedUrl('thumbnail')
174+
// or await user.avatar.getVariant('thumbnail').getSignedUrl()
169175
```
170176

171177
```edge
172-
<img src="{{ user.avatar.getUrl('thumbnail') }}" loading="lazy" alt="" />
178+
<img src="{{ await user.avatar.getUrl('thumbnail') }}" loading="lazy" alt="" />
179+
180+
<img src="{{ await user.avatar.getSignedUrl() }}" loading="lazy" alt="" />
181+
<img src="{{ await user.avatar.getSignedUrl({
182+
expiresIn: '30 mins',
183+
}) }}" loading="lazy" alt="" />
184+
185+
<img src="{{ await user.avatar.getSignedUrl('thumbnail') }}" loading="lazy" alt="" />
186+
<img src="{{ await user.avatar.getSignedUrl('thumbnail', {
187+
expiresIn: '30 mins',
188+
}) }}" loading="lazy" alt="" />
173189
```
174190

191+
getSignedUrl options params accepts `expiresIn`, `contentType` et `contentDisposition`. [More informations](https://flydrive.dev/docs/disk_api#getsignedurl)
192+
193+
175194
### by serialize
176195

177196
```ts
178-
user.avatar.toJSON()
197+
await user.avatar.toJSON()
179198
```
180199

181200
```html
182-
<img :src="user.avatar.thumbnail" loading="lazy" alt="" />
201+
<img :src="user.avatar.thumbnail.url" loading="lazy" alt="" />
202+
<img :src="user.avatar.thumbnail.signedUrl" loading="lazy" alt="" />
183203
```
184204

185205
## Configuration
@@ -192,7 +212,6 @@ import app from '@adonisjs/core/services/app'
192212
import sharp from 'sharp'
193213

194214
export default defineConfig({
195-
basePath: app.publicPath(),
196215
converters: [
197216
{
198217
key: 'thumbnail',
@@ -252,6 +271,7 @@ npm install sharp
252271
```
253272

254273
Variants thumbnail videos are generate by [fluent-ffmpeg](https://www.npmjs.com/package/fluent-ffmpeg)
274+
255275
By default, image format is PNG and size is video size. `options` attribute use image_converter (and sharp)
256276

257277
```sh

0 commit comments

Comments
 (0)