Skip to content

Commit ff1ee32

Browse files
committed
Merge branch 'develop'
2 parents 860a7c8 + da6323a commit ff1ee32

29 files changed

+498
-181
lines changed

.prettierignore

+8
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

README.md

+11-11
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ Project sample : [adonis-starter-kit](https://github.com/batosai/adonis-starter-
88

99
[View documentation](https://adonis-attachment.jrmc.dev/)
1010

11-
[Discord](https://discord.gg/89eMn2vB)
12-
1311
[ChangeLog](https://adonis-attachment.jrmc.dev/changelog.html)
1412

13+
[Discord](https://discord.gg/89eMn2vB)
14+
1515
⚠️ [Breaking change](https://adonis-attachment.jrmc.dev/changelog.html) version 2, include [@adonisjs/drive](https://docs.adonisjs.com/guides/digging-deeper/drive)
1616

1717
## Roadmap
@@ -23,9 +23,9 @@ Project sample : [adonis-starter-kit](https://github.com/batosai/adonis-starter-
2323
- [x] documents thumbnail
2424
- [x] videos thumbnail
2525
- [ ] command regenerate
26-
- [ ] command make:convert
26+
- [x] command make:convert
2727
- [x] adonis-drive/flydrive
28-
- [ ] jobs queue
28+
- [x] jobs queue
2929
- [x] serialize
3030

3131

@@ -46,26 +46,26 @@ Simple upload file
4646
import { BaseModel } from '@adonisjs/lucid/orm'
4747
import { compose } from '@adonisjs/core/helpers'
4848
import { attachment, Attachmentable } from '@jrmc/adonis-attachment'
49-
import type { Attachment } from '@jrmc/adonis-attachment/types/attachment' // [!code highlight]
49+
import type { Attachment } from '@jrmc/adonis-attachment/types/attachment'
5050

51-
class User extends compose(BaseModel, Attachmentable) { // [!code highlight]
52-
@attachment() // [!code highlight]
53-
declare avatar: Attachment // [!code highlight]
51+
class User extends compose(BaseModel, Attachmentable) {
52+
@attachment()
53+
declare avatar: Attachment
5454
}
5555
```
5656

5757
---
5858

5959
```ts
6060
// app/controllers/users_controller.ts
61-
import { attachmentManager } from '@jrmc/adonis-attachment' // [!code focus]
61+
import { attachmentManager } from '@jrmc/adonis-attachment'
6262

6363
class UsersController {
6464
public store({ request }: HttpContext) {
65-
const avatar = request.file('avatar')! // [!code focus]
65+
const avatar = request.file('avatar')!
6666
const user = new User()
6767

68-
user.avatar = await attachmentManager.createFromFile(avatar) // [!code focus]
68+
user.avatar = await attachmentManager.createFromFile(avatar)
6969
await user.save()
7070
}
7171
}

commands/make/converter.ts

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/**
2+
* @jrmc/adonis-attachment
3+
*
4+
* @license MIT
5+
* @copyright Jeremy Chaufourier <[email protected]>
6+
*/
7+
8+
import { stubsRoot } from '../../stubs/main.js'
9+
import { args, BaseCommand } from '@adonisjs/core/ace'
10+
11+
/**
12+
* The make controller command to create an HTTP controller
13+
*/
14+
export default class MakeConverter extends BaseCommand {
15+
static commandName = 'make:converter'
16+
static description = 'Create a new media converter class'
17+
18+
@args.string({ description: 'The name of the converter' })
19+
declare name: string
20+
21+
protected stubPath: string = 'make/converter/main.stub'
22+
23+
async run() {
24+
const codemods = await this.createCodemods()
25+
await codemods.makeUsingStub(stubsRoot, this.stubPath, {
26+
name: this.name,
27+
})
28+
}
29+
}

configure.ts

+1
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,6 @@ export async function configure(command: Configure) {
2121
*/
2222
await codemods.updateRcFile((rcFile) => {
2323
rcFile.addProvider('@jrmc/adonis-attachment/attachment_provider')
24+
rcFile.addCommand('@jrmc/adonis-attachment/commands')
2425
})
2526
}

docs/.vitepress/config.ts

+45-36
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,17 @@ import { defineConfig } from 'vitepress'
22

33
// https://vitepress.dev/reference/site-config
44
export default defineConfig({
5-
title: "Adonis Attachment",
6-
description: "Transform any field in your Lucid model into an attachment data type, automatically generating various sizes and formats.",
5+
title: 'Adonis Attachment',
6+
description:
7+
'Transform any field in your Lucid model into an attachment data type, automatically generating various sizes and formats.',
78
head: [
89
[
910
'script',
10-
{ defer: '', src: 'https://umami.jrmc.dev/script.js', 'data-website-id':'bcdd9b7d-2429-4f68-96de-8250404e0f56' }
11+
{
12+
'defer': '',
13+
'src': 'https://umami.jrmc.dev/script.js',
14+
'data-website-id': 'bcdd9b7d-2429-4f68-96de-8250404e0f56',
15+
},
1116
],
1217
],
1318
themeConfig: {
@@ -23,8 +28,8 @@ export default defineConfig({
2328
{ text: 'Flydrive', link: 'https://flydrive.dev' },
2429
{ text: 'Sharp', link: 'https://sharp.pixelplumbing.com' },
2530
{ text: 'Fluent ffmpeg', link: 'https://www.npmjs.com/package/fluent-ffmpeg' },
26-
]
27-
}
31+
],
32+
},
2833
],
2934

3035
sidebar: [
@@ -33,103 +38,107 @@ export default defineConfig({
3338
items: [
3439
{
3540
text: 'Start here',
36-
link: '/guide/start-here'
41+
link: '/guide/start-here',
3742
},
3843
{
3944
text: 'Essentials',
4045
items: [
4146
{
4247
text: 'Introduction',
43-
link: '/guide/essentials/introduction'
48+
link: '/guide/essentials/introduction',
4449
},
4550
{
4651
text: 'Installation',
47-
link: '/guide/essentials/installation'
52+
link: '/guide/essentials/installation',
4853
},
4954
{
5055
text: 'Configuration',
51-
link: '/guide/essentials/configuration'
52-
}
53-
]
56+
link: '/guide/essentials/configuration',
57+
},
58+
],
5459
},
5560
{
5661
text: 'Basic Usage',
5762
items: [
5863
{
5964
text: 'Migration Setup',
60-
link: '/guide/basic_usage/migration-setup'
65+
link: '/guide/basic_usage/migration-setup',
6166
},
6267
{
6368
text: 'Model Setup',
64-
link: '/guide/basic_usage/model-setup'
69+
link: '/guide/basic_usage/model-setup',
6570
},
6671
{
6772
text: 'Controller Setup',
68-
link: '/guide/basic_usage/controller-setup'
73+
link: '/guide/basic_usage/controller-setup',
6974
},
7075
{
7176
text: 'View Setup',
72-
link: '/guide/basic_usage/view-setup'
73-
}
74-
]
77+
link: '/guide/basic_usage/view-setup',
78+
},
79+
],
7580
},
7681
{
7782
text: 'Converter',
7883
items: [
7984
{
8085
text: 'Image',
81-
link: '/guide/converters/image'
86+
link: '/guide/converters/image',
8287
},
8388
{
8489
text: 'PDF thumbnail',
85-
link: '/guide/converters/pdf-thumbnail'
90+
link: '/guide/converters/pdf-thumbnail',
8691
},
8792
{
8893
text: 'Document thumbnail',
89-
link: '/guide/converters/document-thumbnail'
94+
link: '/guide/converters/document-thumbnail',
9095
},
9196
{
9297
text: 'Video thumbnail',
93-
link: '/guide/converters/video-thumbnail'
98+
link: '/guide/converters/video-thumbnail',
9499
},
95-
]
100+
],
96101
},
97102
{
98103
text: 'Advanced Usage',
99104
items: [
100105
{
101106
text: 'Exceptions',
102-
link: '/guide/advanced_usage/exceptions'
107+
link: '/guide/advanced_usage/exceptions',
103108
},
104109
{
105110
text: 'PrecompileUrl',
106-
link: '/guide/advanced_usage/pre-compile-on-demand'
111+
link: '/guide/advanced_usage/pre-compile-on-demand',
107112
},
108113
{
109114
text: 'Custom converter',
110-
link: '/guide/advanced_usage/custom-converter'
115+
link: '/guide/advanced_usage/custom-converter',
111116
},
112-
]
117+
{
118+
text: 'Queue',
119+
link: '/guide/advanced_usage/queue',
120+
},
121+
],
113122
},
114123
{
115124
text: 'Use cases',
116125
items: [
117126
{
118127
text: 'Picture',
119-
link: '/guide/use-cases/picture'
128+
link: '/guide/use-cases/picture',
120129
},
121-
]
122-
}
123-
]
130+
],
131+
},
132+
],
124133
},
125134
{
126135
text: 'Structure data JSON',
127-
link: '/structure-data-json'
136+
link: '/structure-data-json',
128137
},
129138
{
130139
text: 'ChangeLog',
131-
link: '/changelog'
132-
}
140+
link: '/changelog',
141+
},
133142
],
134143

135144
socialLinks: [
@@ -139,7 +148,7 @@ export default defineConfig({
139148
],
140149

141150
search: {
142-
provider: 'local'
143-
}
144-
}
151+
provider: 'local',
152+
},
153+
},
145154
})

docs/changelog.md

+14-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
# Changelog
22

3-
## 2.3.2
3+
## 2.4.0
44

5-
* fix: remove file after set attributes Attachment at null
5+
* feat: use queue by Model attributes Attachment
6+
* feat: ace command for generate converter
7+
8+
```sh
9+
node ace configure @jrmc/adonis-attachment
10+
```
11+
12+
or add `() => import('@jrmc/adonis-attachment/commands')` in array commands on `adonisrc.ts`
13+
14+
* doc: add [custom converter](/guide/advanced_usage/custom-converter)
615

716
## 2.3.1
817

@@ -18,14 +27,14 @@
1827

1928
## 2.2.0
2029

21-
* add config preComputeUrl
30+
* add config [preComputeUrl](/guide/basic_usage/model-setup.html#specifying-precomputeurl)
2231
* fix data serialize
2332

2433
## 2.1.0
2534

2635
* you may set the ffmpeg and ffprobe binary paths manually
27-
* add config to disable meta
28-
* add config to disable rename
36+
* add config to disable [meta](/guide/basic_usage/model-setup.html#specifying-meta)
37+
* add config to disable [rename](/guide/basic_usage/model-setup.html#specifying-rename)
2938

3039
## 2.0.2
3140

0 commit comments

Comments
 (0)