Skip to content

Commit

Permalink
feat: add assetsBundler: false through codemods
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien-R44 committed Jun 2, 2024
1 parent d347099 commit 749a040
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
21 changes: 21 additions & 0 deletions configure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,25 @@ export async function configure(command: Configure) {
} else {
await codemods.listPackagesToInstall([{ name: 'vite', isDevDependency: true }])
}

/**
* Add `assetsBundler: false` to the adonisrc file
*/
const tsMorph = await import('ts-morph')
const project = await codemods.getTsMorphProject()
const adonisRcFile = project?.getSourceFile('adonisrc.ts')
const defineConfigCall = adonisRcFile
?.getDescendantsOfKind(tsMorph.SyntaxKind.CallExpression)
.find((statement) => statement.getExpression().getText() === 'defineConfig')

const configObject = defineConfigCall!
.getArguments()[0]
.asKindOrThrow(tsMorph.SyntaxKind.ObjectLiteralExpression)

configObject.addPropertyAssignment({
name: 'assetsBundler',
initializer: 'false',
})

await adonisRcFile?.save()
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"np": "^10.0.5",
"prettier": "^3.3.0",
"supertest": "^6.3.4",
"ts-morph": "^22.0.0",
"ts-node": "^10.9.2",
"tsup": "^8.0.2",
"typescript": "~5.4.5",
Expand Down
1 change: 1 addition & 0 deletions tests/configure.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ test.group('Configure', (group) => {
await assert.fileContains('adonisrc.ts', `reloadServer: false`)
await assert.fileContains('start/kernel.ts', '@adonisjs/vite/vite_middleware')
await assert.fileContains('adonisrc.ts', `@adonisjs/vite/build_hook`)
await assert.fileContains('adonisrc.ts', `assetsBundler: false`)
})

test('install package when --install flag is used', async ({ assert, fs }) => {
Expand Down

0 comments on commit 749a040

Please sign in to comment.