fix(android): patch gradle for capacitor core
This commit is contained in:
@@ -9,7 +9,8 @@
|
||||
"web:sync": "node scripts/sync-web.mjs",
|
||||
"android:init": "pnpm install && pnpm exec cap init DeskClaw dev.deskclaw.app --web-dir=www --npm-client=pnpm",
|
||||
"android:add": "pnpm exec cap add android",
|
||||
"android:sync": "pnpm exec cap sync android",
|
||||
"android:patch": "node scripts/patch-android.mjs",
|
||||
"android:sync": "pnpm exec cap sync android && pnpm run android:patch",
|
||||
"android:apk:debug": "cd android && ./gradlew assembleDebug",
|
||||
"android:apk:release": "cd android && ./gradlew assembleRelease"
|
||||
},
|
||||
@@ -21,4 +22,3 @@
|
||||
"@capacitor/cli": "^7.4.3"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
25
mobile/scripts/patch-android.mjs
Normal file
25
mobile/scripts/patch-android.mjs
Normal file
@@ -0,0 +1,25 @@
|
||||
import { readFile, writeFile } from 'node:fs/promises'
|
||||
import { resolve } from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
|
||||
async function main() {
|
||||
const scriptDir = fileURLToPath(new URL('.', import.meta.url))
|
||||
const mobileRoot = resolve(scriptDir, '..')
|
||||
const appGradle = resolve(mobileRoot, 'android', 'app', 'build.gradle')
|
||||
|
||||
let text = await readFile(appGradle, 'utf8')
|
||||
const before = "implementation project(':capacitor-android')"
|
||||
const after = 'implementation "com.capacitorjs:core:7.6.2"'
|
||||
|
||||
if (text.includes(after)) return
|
||||
if (!text.includes(before)) return
|
||||
|
||||
text = text.replace(before, after)
|
||||
await writeFile(appGradle, text, 'utf8')
|
||||
}
|
||||
|
||||
main().catch((err) => {
|
||||
console.error(err)
|
||||
process.exit(1)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user