|
| 1 | +import { test } from '@japa/runner' |
| 2 | +import { fileURLToPath } from 'node:url' |
| 3 | +import { IgnitorFactory } from '@adonisjs/core/factories' |
| 4 | +import Configure from '@adonisjs/core/commands/configure' |
| 5 | + |
| 6 | +const BASE_URL = new URL('./tmp/', import.meta.url) |
| 7 | + |
| 8 | +test.group('Configure', (group) => { |
| 9 | + group.each.setup(({ context }) => { |
| 10 | + context.fs.baseUrl = BASE_URL |
| 11 | + context.fs.basePath = fileURLToPath(BASE_URL) |
| 12 | + }) |
| 13 | + |
| 14 | + test('create config file, register provider and update meta files', async ({ fs, assert }) => { |
| 15 | + const ignitor = new IgnitorFactory() |
| 16 | + .withCoreProviders() |
| 17 | + .withCoreConfig() |
| 18 | + .create(BASE_URL, { |
| 19 | + importer: (filePath) => { |
| 20 | + if (filePath.startsWith('./') || filePath.startsWith('../')) { |
| 21 | + return import(new URL(filePath, BASE_URL).href) |
| 22 | + } |
| 23 | + |
| 24 | + return import(filePath) |
| 25 | + }, |
| 26 | + }) |
| 27 | + |
| 28 | + await fs.create('.env', '') |
| 29 | + await fs.createJson('tsconfig.json', {}) |
| 30 | + await fs.create('start/kernel.ts', `router.use([])`) |
| 31 | + await fs.create('adonisrc.ts', `export default defineConfig({}) {}`) |
| 32 | + |
| 33 | + const app = ignitor.createApp('web') |
| 34 | + await app.init() |
| 35 | + await app.boot() |
| 36 | + |
| 37 | + const ace = await app.container.make('ace') |
| 38 | + const command = await ace.create(Configure, ['../../index.js']) |
| 39 | + await command.exec() |
| 40 | + |
| 41 | + await assert.fileExists('config/geolite2.ts') |
| 42 | + }).timeout(60 * 1000) |
| 43 | +}) |
0 commit comments