Skip to content

Commit

Permalink
fix(app-vite): build fails with latest cordova-ios #17138
Browse files Browse the repository at this point in the history
  • Loading branch information
rstoenescu committed Apr 25, 2024
1 parent c2c60a9 commit dd6e50e
Showing 1 changed file with 36 additions and 10 deletions.
46 changes: 36 additions & 10 deletions app-vite/lib/modes/cordova/cordova-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,25 @@ import { join } from 'node:path'
import { AppBuilder } from '../../app-builder.js'
import { quasarCordovaConfig } from './cordova-config.js'

import { fatal } from '../../utils/logger.js'
import { log, warn, fatal } from '../../utils/logger.js'
import { CordovaConfigFile } from './config-file.js'
import { spawn } from '../../utils/spawn.js'
import { openIDE } from '../../utils/open-ide.js'
import { onShutdown } from '../../utils/on-shutdown.js'
import { fixAndroidCleartext } from '../../utils/fix-android-cleartext.js'

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'
]
}

export class QuasarModeBuilder extends AppBuilder {
#cordovaConfigFile = new CordovaConfigFile()

Expand Down Expand Up @@ -52,14 +64,12 @@ export class QuasarModeBuilder extends AppBuilder {
fixAndroidCleartext(appPaths, 'cordova')
}

const buildPath = appPaths.resolve.cordova(
target === 'android'
? 'platforms/android/app/build/outputs'
: 'platforms/ios/build/emulator'
)

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

onShutdown(() => {
this.#cleanup()
Expand All @@ -69,7 +79,7 @@ export class QuasarModeBuilder extends AppBuilder {

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

await this.#runCordovaCommand(
args.concat(this.argv._),
Expand All @@ -87,7 +97,23 @@ export class QuasarModeBuilder extends AppBuilder {
process.exit(0)
}

fse.copySync(buildPath, join(this.quasarConf.build.distDir, this.quasarConf.ctx.targetName))
const targetFolder = join(this.quasarConf.build.distDir, this.quasarConf.ctx.targetName)

for (const folder of cordovaOutputFiles[ 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 "${ target }".`
+ ' Files have not been copied to /dist. You will need'
+ ' to manually extract the Cordova distributables.'
)
}
}

Expand Down

0 comments on commit dd6e50e

Please sign in to comment.