(config: Config)
| 22 | } |
| 23 | |
| 24 | export async function checkWebDir(config: Config): Promise<string | null> { |
| 25 | // We can skip checking the web dir if a server URL is set. |
| 26 | if (config.app.extConfig.server?.url) { |
| 27 | return null; |
| 28 | } |
| 29 | |
| 30 | const invalidFolders = ['', '.', '..', '../', './']; |
| 31 | if (invalidFolders.includes(config.app.webDir)) { |
| 32 | return `"${config.app.webDir}" is not a valid value for webDir`; |
| 33 | } |
| 34 | if (!(await pathExists(config.app.webDirAbs))) { |
| 35 | return ( |
| 36 | `Could not find the web assets directory: ${c.strong(prettyPath(config.app.webDirAbs))}.\n` + |
| 37 | `Please create it and make sure it has an ${c.strong( |
| 38 | 'index.html', |
| 39 | )} file. You can change the path of this directory in ${c.strong(config.app.extConfigName)} (${c.input( |
| 40 | 'webDir', |
| 41 | )} option). You may need to compile the web assets for your app (typically ${c.input( |
| 42 | 'npm run build', |
| 43 | )}). More info: ${c.strong('https://capacitorjs.com/docs/basics/workflow#sync-your-project')}` |
| 44 | ); |
| 45 | } |
| 46 | |
| 47 | if (!(await pathExists(join(config.app.webDirAbs, 'index.html')))) { |
| 48 | return ( |
| 49 | `The web assets directory (${c.strong( |
| 50 | prettyPath(config.app.webDirAbs), |
| 51 | )}) must contain an ${c.strong('index.html')} file.\n` + |
| 52 | `It will be the entry point for the web portion of the Capacitor app.` |
| 53 | ); |
| 54 | } |
| 55 | return null; |
| 56 | } |
| 57 | |
| 58 | export async function checkPackage(): Promise<string | null> { |
| 59 | if (!(await pathExists('package.json'))) { |
no outgoing calls
no test coverage detected