-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(app): Bulletproof Cordova and Capacitor modes handling after a g…
…it clone
- Loading branch information
1 parent
eba6e05
commit bd920c2
Showing
6 changed files
with
105 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
const fs = require('fs') | ||
const fse = require('fs-extra') | ||
|
||
const nodePackager = require('../helpers/node-packager') | ||
const { spawnSync } = require('../helpers/spawn') | ||
const appPaths = require('../app-paths') | ||
|
||
const logger = require('../helpers/logger') | ||
const log = logger('app:ensure-consistency') | ||
const warn = logger('app:ensure-consistency', 'red') | ||
|
||
function ensureWWW () { | ||
const www = appPaths.resolve.capacitor('www') | ||
|
||
fse.removeSync(www) | ||
fse.copySync( | ||
appPaths.resolve.cli('templates/capacitor/www'), | ||
appPaths.resolve.capacitor('www') | ||
) | ||
} | ||
|
||
function ensureDeps () { | ||
if (fs.existsSync(appPaths.resolve.capacitor('node_modules'))) { | ||
return | ||
} | ||
|
||
const cmdParam = nodePackager === 'npm' | ||
? ['install'] | ||
: [] | ||
|
||
log(`Installing Capacitor dependencies...`) | ||
spawnSync( | ||
nodePackager, | ||
cmdParam, | ||
{ cwd: appPaths.capacitorDir }, | ||
() => warn(`⚠️ [FAIL] failed installing dependencies in /src-capacitor`) | ||
) | ||
} | ||
|
||
module.exports = function () { | ||
ensureWWW() | ||
ensureDeps() | ||
} | ||
|
||
module.exports.ensureWWW = ensureWWW | ||
module.exports.ensureDeps = ensureDeps |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
const fs = require('fs') | ||
const fse = require('fs-extra') | ||
|
||
const { spawnSync } = require('../helpers/spawn') | ||
const appPaths = require('../app-paths') | ||
|
||
const logger = require('../helpers/logger') | ||
const log = logger('app:ensure-consistency') | ||
const warn = logger('app:ensure-consistency', 'red') | ||
|
||
function ensureWWW () { | ||
const www = appPaths.resolve.cordova('www') | ||
|
||
fse.removeSync(www) | ||
fse.copySync( | ||
appPaths.resolve.cli('templates/cordova'), | ||
appPaths.cordovaDir | ||
) | ||
} | ||
|
||
function ensureDeps () { | ||
if (fs.existsSync(appPaths.resolve.cordova('node_modules'))) { | ||
return | ||
} | ||
|
||
log('Installing dependencies in /src-cordova') | ||
spawnSync( | ||
'npm', | ||
[ 'install' ], | ||
{ cwd: appPaths.cordovaDir }, | ||
() => { | ||
warn(`⚠️ [FAIL] npm failed installing dependencies in /src-cordova`) | ||
process.exit(1) | ||
} | ||
) | ||
} | ||
|
||
module.exports = function () { | ||
ensureWWW() | ||
ensureDeps() | ||
} | ||
|
||
module.exports.ensureWWW = ensureWWW | ||
module.exports.ensureDeps = ensureDeps |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters