()
| 102 | } |
| 103 | |
| 104 | async function updateDataDb() { |
| 105 | let latestPrismaApp |
| 106 | |
| 107 | const appsWithPrisma = apps.filter(app => exists(path.join(app, 'prisma'))) |
| 108 | // copy this to all the other apps |
| 109 | for (const app of appsWithPrisma) { |
| 110 | const prismaIsUnchanged = latestPrismaApp |
| 111 | ? await dirsAreTheSame( |
| 112 | path.join(latestPrismaApp, 'prisma'), |
| 113 | path.join(app, 'prisma'), |
| 114 | [/data\.db/], |
| 115 | ) |
| 116 | : false |
| 117 | if (!prismaIsUnchanged) { |
| 118 | if (latestPrismaApp) { |
| 119 | logVerbose( |
| 120 | `The prisma folder in ${rel(app)} is different to ${rel( |
| 121 | latestPrismaApp, |
| 122 | )}. Updating the latest.`, |
| 123 | ) |
| 124 | } else { |
| 125 | logVerbose(`Setting the latest prisma app to ${rel(app)}`) |
| 126 | } |
| 127 | latestPrismaApp = app |
| 128 | await reseedIfNecessary(latestPrismaApp) |
| 129 | } |
| 130 | const pathToLatestAppDb = path.join(latestPrismaApp, 'prisma/data.db') |
| 131 | const pathToDestAppDb = path.join(app, 'prisma/data.db') |
| 132 | if (pathToLatestAppDb !== pathToDestAppDb) { |
| 133 | if (!isSameFile(pathToLatestAppDb, pathToDestAppDb)) { |
| 134 | console.log( |
| 135 | `Copying data.db from ${rel(latestPrismaApp)} to ${rel(app)}`, |
| 136 | ) |
| 137 | await fs.promises.copyFile(pathToLatestAppDb, pathToDestAppDb) |
| 138 | } else { |
| 139 | logVerbose( |
| 140 | `Skipping copying ${rel(pathToLatestAppDb)} to ${rel( |
| 141 | pathToDestAppDb, |
| 142 | )} because they are the same`, |
| 143 | ) |
| 144 | } |
| 145 | } |
| 146 | } |
| 147 | } |
| 148 | |
| 149 | function isSameFile(file1, file2) { |
| 150 | const f1IsFile = isFile(file1) |
no test coverage detected