(monoRepoLike = false)
| 70 | } |
| 71 | |
| 72 | export async function makeAppDir(monoRepoLike = false): Promise<void> { |
| 73 | const appDirObj: any = await mktmp(); |
| 74 | const tmpDir = appDirObj.path; |
| 75 | const rootDir = monoRepoLike ? join(tmpDir, 'test-root') : join(tmpDir, 'test-app'); |
| 76 | if (monoRepoLike) { |
| 77 | await mkdir(rootDir); |
| 78 | } |
| 79 | const cordovaPluginPath = join(tmpDir, CORDOVA_PLUGIN_ID); |
| 80 | const APP_PACKAGE_JSON = ` |
| 81 | { |
| 82 | "name": "test-app", |
| 83 | "dependencies": { |
| 84 | "${CORDOVA_PLUGIN_ID}": "file:${cordovaPluginPath}" |
| 85 | } |
| 86 | } |
| 87 | `; |
| 88 | const appDir = monoRepoLike ? join(rootDir, 'test-app') : rootDir; |
| 89 | await mkdir(appDir); |
| 90 | // Make the web dir |
| 91 | await mkdir(join(appDir, 'www')); |
| 92 | // Make a fake index.html |
| 93 | await writeFile(join(appDir, 'www', 'index.html'), APP_INDEX); |
| 94 | // Make a fake package.json |
| 95 | await writeFile(join(appDir, 'package.json'), APP_PACKAGE_JSON); |
| 96 | |
| 97 | // We use 'npm install' to install @capacitor/core and @capacitor/cli |
| 98 | // Otherwise later use of 'npm install --save @capacitor/android|ios' will wipe 'node_modules/@capacitor/' |
| 99 | const corePath = resolve(cwd, '../core'); |
| 100 | const cliPath = resolve(cwd, '../cli'); |
| 101 | await runCommand('npm', ['install', '--save', corePath, cliPath], { |
| 102 | cwd: rootDir, |
| 103 | }); |
| 104 | |
| 105 | // Make a fake cordova plugin |
| 106 | await makeCordovaPlugin(cordovaPluginPath); |
| 107 | |
| 108 | await runCommand('npm', ['install', '--save', cordovaPluginPath], { |
| 109 | cwd: rootDir, |
| 110 | }); |
| 111 | |
| 112 | return { |
| 113 | ...appDirObj, |
| 114 | appDir, |
| 115 | }; |
| 116 | } |
| 117 | |
| 118 | const CODOVA_PLUGIN_JS = ` |
| 119 | var exec = require('cordova/exec'); |
no test coverage detected