( fileUpdates: FsUpdates, opts: UpdateAppOptions, srcDir: string, destDir: string, alwaysInRoot?: string[] )
| 5 | import { getPackageManager } from '../utils/utils'; |
| 6 | |
| 7 | export async function mergeIntegrationDir( |
| 8 | fileUpdates: FsUpdates, |
| 9 | opts: UpdateAppOptions, |
| 10 | srcDir: string, |
| 11 | destDir: string, |
| 12 | alwaysInRoot?: string[] |
| 13 | ) { |
| 14 | const items = await fs.promises.readdir(srcDir); |
| 15 | await Promise.all( |
| 16 | items.map(async (itemName) => { |
| 17 | const destName = itemName === 'gitignore' ? '.gitignore' : itemName; |
| 18 | const ext = extname(destName); |
| 19 | const srcChildPath = join(srcDir, itemName); |
| 20 | |
| 21 | const destRootPath = join(destDir, destName); |
| 22 | |
| 23 | const s = await fs.promises.stat(srcChildPath); |
| 24 | |
| 25 | if (s.isDirectory()) { |
| 26 | await mergeIntegrationDir(fileUpdates, opts, srcChildPath, destRootPath, alwaysInRoot); |
| 27 | } else if (s.isFile()) { |
| 28 | const finalDestPath = getFinalDestPath(opts, destRootPath, destDir, destName, alwaysInRoot); |
| 29 | |
| 30 | if (destName === 'package.json') { |
| 31 | await mergePackageJsons(fileUpdates, srcChildPath, destRootPath); |
| 32 | } else if (destDir.endsWith('.vscode') && destName === 'settings.json') { |
| 33 | await mergeVSCodeSettings(fileUpdates, srcChildPath, finalDestPath); |
| 34 | } else if (destName === 'README.md') { |
| 35 | await mergeReadmes(fileUpdates, srcChildPath, finalDestPath); |
| 36 | } else if ( |
| 37 | destName === '.gitignore' || |
| 38 | destName === '.prettierignore' || |
| 39 | destName === '.eslintignore' |
| 40 | ) { |
| 41 | await mergeIgnoresFile(fileUpdates, srcChildPath, destRootPath); |
| 42 | } else if (ext === '.css') { |
| 43 | await mergeCss(fileUpdates, srcChildPath, finalDestPath, opts); |
| 44 | } else if (fs.existsSync(finalDestPath)) { |
| 45 | fileUpdates.files.push({ |
| 46 | path: finalDestPath, |
| 47 | content: await fs.promises.readFile(srcChildPath), |
| 48 | type: 'overwrite', |
| 49 | }); |
| 50 | } else { |
| 51 | fileUpdates.files.push({ |
| 52 | path: finalDestPath, |
| 53 | content: await fs.promises.readFile(srcChildPath), |
| 54 | type: 'create', |
| 55 | }); |
| 56 | } |
| 57 | } |
| 58 | }) |
| 59 | ); |
| 60 | } |
| 61 | |
| 62 | function getFinalDestPath( |
| 63 | opts: UpdateAppOptions, |
no test coverage detected
searching dependent graphs…