Compare commits

...

3 Commits

Author SHA1 Message Date
Elliot DeNolf
ea0a99e0e4 chore: bring placeholders back to blank 2024-11-17 21:26:58 -05:00
Elliot DeNolf
abf5bb2c34 chore: gen blank template from _template 2024-11-17 17:40:08 -05:00
Elliot DeNolf
3242c679eb chore(templates): clean up storage adapter imports if not used 2024-11-17 17:32:48 -05:00
2 changed files with 21 additions and 2 deletions

View File

@@ -106,21 +106,37 @@ export async function configurePayloadConfig(args: {
})
// Storage Adapter Replacement
const STORAGE_ADAPTER_PLACEHOLDER = '// storage-adapter-placeholder'
const STORAGE_ADAPTER_IMPORT_PLACEHOLDER = '// storage-adapter-import-placeholder'
if (args.storageAdapter) {
const replacement = storageReplacements[args.storageAdapter]
configLines = replaceInConfigLines({
lines: configLines,
replacement: replacement.configReplacement,
startMatch: '// storage-adapter-placeholder',
startMatch: STORAGE_ADAPTER_PLACEHOLDER,
})
if (replacement?.importReplacement !== undefined) {
configLines = replaceInConfigLines({
lines: configLines,
replacement: [replacement.importReplacement],
startMatch: '// storage-adapter-import-placeholder',
startMatch: STORAGE_ADAPTER_IMPORT_PLACEHOLDER,
})
}
} else {
console.log('no storage adapter')
// Clean up both placeholders if no storage adapter
configLines = replaceInConfigLines({
lines: configLines,
replacement: [],
startMatch: STORAGE_ADAPTER_PLACEHOLDER,
})
configLines = replaceInConfigLines({
lines: configLines,
replacement: [],
startMatch: STORAGE_ADAPTER_IMPORT_PLACEHOLDER,
})
}
// Sharp Replacement (provided by default, only remove if explicitly set to false)

View File

@@ -125,6 +125,9 @@ describe('createProject', () => {
expect(content).not.toContain('// database-adapter-config-start')
expect(content).not.toContain('// database-adapter-config-end')
expect(content).toContain(dbReplacement.configReplacement().join('\n'))
expect(content).not.toContain('// storage-adapter-import-placeholder')
expect(content).not.toContain('// storage-adapter-placeholder')
})
})
})