( testSuiteArg: string, writeDBAdapter: string, skipGenImportMap: string, configFile?: string, )
| 14 | const runImmediately = process.argv[2] |
| 15 | |
| 16 | export async function initDevAndTest( |
| 17 | testSuiteArg: string, |
| 18 | writeDBAdapter: string, |
| 19 | skipGenImportMap: string, |
| 20 | configFile?: string, |
| 21 | ): Promise<void> { |
| 22 | const importMapPath: string = path.resolve( |
| 23 | getNextRootDir(testSuiteArg).rootDir, |
| 24 | './app/(payload)/admin/importMap.js', |
| 25 | ) |
| 26 | |
| 27 | try { |
| 28 | fs.writeFileSync(importMapPath, 'export const importMap = {}') |
| 29 | } catch (error) { |
| 30 | console.log('Error writing importMap.js', error) |
| 31 | } |
| 32 | |
| 33 | if (writeDBAdapter === 'true') { |
| 34 | const dbAdapter: keyof typeof allDatabaseAdapters = |
| 35 | (process.env.PAYLOAD_DATABASE as keyof typeof allDatabaseAdapters) || 'mongodb' |
| 36 | generateDatabaseAdapter(dbAdapter) |
| 37 | } |
| 38 | |
| 39 | if (skipGenImportMap === 'true') { |
| 40 | console.log('Done') |
| 41 | return |
| 42 | } |
| 43 | |
| 44 | // Generate importMap |
| 45 | const testDir = path.resolve(dirname, testSuiteArg) |
| 46 | console.log('Generating import map for config:', testDir) |
| 47 | |
| 48 | const configUrl = pathToFileURL(path.resolve(testDir, configFile ?? 'config.ts')).href |
| 49 | const config: SanitizedConfig = await (await import(configUrl)).default |
| 50 | |
| 51 | process.env.ROOT_DIR = getNextRootDir(testSuiteArg).rootDir |
| 52 | |
| 53 | await generateImportMap(config, { log: true, force: true }) |
| 54 | |
| 55 | console.log('Done') |
| 56 | } |
| 57 | |
| 58 | if (runImmediately === 'true') { |
| 59 | const testSuiteArg = process.argv[3] |
no test coverage detected
searching dependent graphs…