Skip to content

Commit

Permalink
feat: configure default disk via DRIVE_DISK env variable
Browse files Browse the repository at this point in the history
  • Loading branch information
thetutlage committed Aug 10, 2024
1 parent eb9c5a9 commit 2c0050c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
34 changes: 22 additions & 12 deletions configure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,24 +131,34 @@ export async function configure(command: ConfigureCommand) {
* Define env variables for the selected services
*/
await codemods.defineEnvVariables(
services.reduce<Record<string, string>>((result, service) => {
STORAGE_SERVICES[service].env.forEach((envVariable) => {
result[envVariable.name] = envVariable.value
})
return result
}, {})
services.reduce<Record<string, string>>(
(result, service) => {
STORAGE_SERVICES[service].env.forEach((envVariable) => {
result[envVariable.name] = envVariable.value
})
return result
},
{
DRIVE_DISK: services[0],
}
)
)

/**
* Define env variables validation for the selected services
*/
await codemods.defineEnvValidations({
leadingComment: 'Variables for configuring the drive package',
variables: services.reduce<Record<string, string>>((result, service) => {
STORAGE_SERVICES[service].env.forEach((envVariable) => {
result[envVariable.name] = envVariable.schema
})
return result
}, {}),
variables: services.reduce<Record<string, string>>(
(result, service) => {
STORAGE_SERVICES[service].env.forEach((envVariable) => {
result[envVariable.name] = envVariable.schema
})
return result
},
{
DRIVE_DISK: `Env.schema.enum(['${services.join("', '")}'])`,
}
),
})
}
2 changes: 1 addition & 1 deletion stubs/config/drive.stub
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import app from '@adonisjs/core/services/app'{{/if}}
import { defineConfig, services } from '@adonisjs/drive'

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

/**
* The services object can be used to configure multiple file system
Expand Down

0 comments on commit 2c0050c

Please sign in to comment.