Skip to content

Commit 2c0050c

Browse files
committed
feat: configure default disk via DRIVE_DISK env variable
1 parent eb9c5a9 commit 2c0050c

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed

configure.ts

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -131,24 +131,34 @@ export async function configure(command: ConfigureCommand) {
131131
* Define env variables for the selected services
132132
*/
133133
await codemods.defineEnvVariables(
134-
services.reduce<Record<string, string>>((result, service) => {
135-
STORAGE_SERVICES[service].env.forEach((envVariable) => {
136-
result[envVariable.name] = envVariable.value
137-
})
138-
return result
139-
}, {})
134+
services.reduce<Record<string, string>>(
135+
(result, service) => {
136+
STORAGE_SERVICES[service].env.forEach((envVariable) => {
137+
result[envVariable.name] = envVariable.value
138+
})
139+
return result
140+
},
141+
{
142+
DRIVE_DISK: services[0],
143+
}
144+
)
140145
)
141146

142147
/**
143148
* Define env variables validation for the selected services
144149
*/
145150
await codemods.defineEnvValidations({
146151
leadingComment: 'Variables for configuring the drive package',
147-
variables: services.reduce<Record<string, string>>((result, service) => {
148-
STORAGE_SERVICES[service].env.forEach((envVariable) => {
149-
result[envVariable.name] = envVariable.schema
150-
})
151-
return result
152-
}, {}),
152+
variables: services.reduce<Record<string, string>>(
153+
(result, service) => {
154+
STORAGE_SERVICES[service].env.forEach((envVariable) => {
155+
result[envVariable.name] = envVariable.schema
156+
})
157+
return result
158+
},
159+
{
160+
DRIVE_DISK: `Env.schema.enum(['${services.join("', '")}'])`,
161+
}
162+
),
153163
})
154164
}

stubs/config/drive.stub

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import app from '@adonisjs/core/services/app'{{/if}}
66
import { defineConfig, services } from '@adonisjs/drive'
77

88
const driveConfig = defineConfig({
9-
default: '{{services[0]}}',
9+
default: env.get('DRIVE_DISK'),
1010

1111
/**
1212
* The services object can be used to configure multiple file system

0 commit comments

Comments
 (0)