Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
1 line
3.4 KiB
Plaintext
1 line
3.4 KiB
Plaintext
{"version":3,"sources":["../../../../src/bin/generateImportMap/utilities/resolveImportMapFilePath.ts"],"sourcesContent":["import fs from 'fs/promises'\nimport path from 'path'\n\nasync function pathOrFileExists(path: string): Promise<boolean> {\n try {\n await fs.access(path)\n return true\n } catch {\n return false\n }\n}\n\n/**\n * Returns the path to the import map file. If the import map file is not found, it throws an error.\n */\nexport async function resolveImportMapFilePath({\n adminRoute = '/admin',\n importMapFile,\n rootDir,\n}: {\n adminRoute?: string\n importMapFile?: string\n rootDir: string\n}): Promise<Error | string> {\n let importMapFilePath: string | undefined = undefined\n\n if (importMapFile?.length) {\n if (!(await pathOrFileExists(importMapFile))) {\n try {\n await fs.writeFile(importMapFile, '', { flag: 'wx' })\n } catch (err) {\n return new Error(\n `Could not find the import map file at ${importMapFile}${err instanceof Error && err?.message ? `: ${err.message}` : ''}`,\n )\n }\n }\n importMapFilePath = importMapFile\n } else {\n const appLocation = path.resolve(rootDir, `app/(payload)${adminRoute}/`)\n const srcAppLocation = path.resolve(rootDir, `src/app/(payload)${adminRoute}/`)\n\n if (appLocation && (await pathOrFileExists(appLocation))) {\n importMapFilePath = path.resolve(appLocation, 'importMap.js')\n if (!(await pathOrFileExists(importMapFilePath))) {\n await fs.writeFile(importMapFilePath, '', { flag: 'wx' })\n }\n } else if (srcAppLocation && (await pathOrFileExists(srcAppLocation))) {\n importMapFilePath = path.resolve(srcAppLocation, 'importMap.js')\n if (!(await pathOrFileExists(importMapFilePath))) {\n await fs.writeFile(importMapFilePath, '', { flag: 'wx' })\n }\n } else {\n return new Error(\n `Could not find Payload import map folder. Looked in ${appLocation} and ${srcAppLocation}`,\n )\n }\n }\n return importMapFilePath\n}\n"],"names":["fs","path","pathOrFileExists","access","resolveImportMapFilePath","adminRoute","importMapFile","rootDir","importMapFilePath","undefined","length","writeFile","flag","err","Error","message","appLocation","resolve","srcAppLocation"],"mappings":"AAAA,OAAOA,QAAQ,cAAa;AAC5B,OAAOC,UAAU,OAAM;AAEvB,eAAeC,iBAAiBD,IAAY;IAC1C,IAAI;QACF,MAAMD,GAAGG,MAAM,CAACF;QAChB,OAAO;IACT,EAAE,OAAM;QACN,OAAO;IACT;AACF;AAEA;;CAEC,GACD,OAAO,eAAeG,yBAAyB,EAC7CC,aAAa,QAAQ,EACrBC,aAAa,EACbC,OAAO,EAKR;IACC,IAAIC,oBAAwCC;IAE5C,IAAIH,eAAeI,QAAQ;QACzB,IAAI,CAAE,MAAMR,iBAAiBI,gBAAiB;YAC5C,IAAI;gBACF,MAAMN,GAAGW,SAAS,CAACL,eAAe,IAAI;oBAAEM,MAAM;gBAAK;YACrD,EAAE,OAAOC,KAAK;gBACZ,OAAO,IAAIC,MACT,CAAC,sCAAsC,EAAER,gBAAgBO,eAAeC,SAASD,KAAKE,UAAU,CAAC,EAAE,EAAEF,IAAIE,OAAO,EAAE,GAAG,IAAI;YAE7H;QACF;QACAP,oBAAoBF;IACtB,OAAO;QACL,MAAMU,cAAcf,KAAKgB,OAAO,CAACV,SAAS,CAAC,aAAa,EAAEF,WAAW,CAAC,CAAC;QACvE,MAAMa,iBAAiBjB,KAAKgB,OAAO,CAACV,SAAS,CAAC,iBAAiB,EAAEF,WAAW,CAAC,CAAC;QAE9E,IAAIW,eAAgB,MAAMd,iBAAiBc,cAAe;YACxDR,oBAAoBP,KAAKgB,OAAO,CAACD,aAAa;YAC9C,IAAI,CAAE,MAAMd,iBAAiBM,oBAAqB;gBAChD,MAAMR,GAAGW,SAAS,CAACH,mBAAmB,IAAI;oBAAEI,MAAM;gBAAK;YACzD;QAC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