Skip to content

Commit

Permalink
fix(app-webpack): (backport from q/app-webpack v4 beta) build fails w…
Browse files Browse the repository at this point in the history
…ith latest cordova-ios #17138
  • Loading branch information
rstoenescu committed Apr 25, 2024
1 parent 4dadb7a commit 0067f2e
Showing 1 changed file with 37 additions and 9 deletions.
46 changes: 37 additions & 9 deletions app-webpack/lib/cordova/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
const fse = require('fs-extra')

const { log, fatal } = require('../helpers/logger')
const { log, warn, fatal } = require('../helpers/logger')
const CordovaConfig = require('./cordova-config')
const { spawn } = require('../helpers/spawn')
const onShutdown = require('../helpers/on-shutdown')
const appPaths = require('../app-paths')
const openIde = require('../helpers/open-ide')

const cordovaOutputFiles = {
ios: [
'platforms/ios/build/Release-iphoneos', // ios-cordova 7+
'platforms/ios/build/device', // ios-cordova 6
'platforms/ios/build/emulator' // ios-cordova 6
],

android: [
'platforms/android/app/build/outputs'
]
}

class CordovaRunner {
constructor () {
this.pid = 0
Expand Down Expand Up @@ -64,18 +76,17 @@ class CordovaRunner {

async build (quasarConfFile, argv) {
const cfg = quasarConfFile.quasarConf
const buildPath = appPaths.resolve.cordova(
this.target === 'android'
? 'platforms/android/app/build/outputs'
: 'platforms/ios/build/emulator'
)

// Remove old build output
fse.removeSync(buildPath)
cordovaOutputFiles[ this.target ].forEach(outputFile => {
fse.removeSync(
appPaths.resolve.cordova(outputFile)
)
})

const args = argv[ 'skip-pkg' ] || argv.ide
? [ 'prepare', this.target ]
: [ 'build', this.ctx.debug ? '--debug' : '--release', this.target ]
: [ 'build', this.ctx.debug ? '--debug' : '--release', '--device', this.target ]

await this.__runCordovaCommand(
cfg,
Expand All @@ -91,7 +102,24 @@ class CordovaRunner {
process.exit(0)
}

fse.copySync(buildPath, cfg.build.packagedDistDir)
const targetFolder = cfg.build.packagedDistDir

for (const folder of cordovaOutputFiles[ this.target ]) {
const outputFolder = appPaths.resolve.cordova(folder)
if (fse.existsSync(outputFolder)) {
log(`Copying Cordova distributables from ${ outputFolder } to ${ targetFolder }`)
log()
fse.copySync(outputFolder, targetFolder)
return
}
}

warn(
`No output folder found for target "${ this.target }".`
+ ' Files have not been copied to /dist. You will need'
+ ' to manually extract the Cordova distributables.'
)
log()
}

stop () {
Expand Down

0 comments on commit 0067f2e

Please sign in to comment.