mirror of
https://git.undefined-dev.fr/Blendman974/faceclaw.git
synced 2026-11-19 21:03:09 +00:00
Refactor Kotlin for iOS commonality
This commit is contained in:
1 parent
587364e5e6
commit
c3a0ba9f56
31 files changed
+2780
-964
No files matched your search
@@ -5,3 +5,5 @@ else
|
||||
cp build_paths.sh.template build_paths.sh
|
||||
fi
|
||||
|
||||
# Restore the Kotlin prepare hook if a package install removed it.
|
||||
node "$(dirname "${BASH_SOURCE[0]}")/install-hooks.cjs"
|
||||
@@ -0,0 +1,8 @@
|
||||
const { buildKotlin, checkAndroidRuntime } = require('../../scripts/kotlin-build.cjs');
|
||||
|
||||
module.exports = function (hookArgs) {
|
||||
// NativeScript parses hooks with an older JavaScript parser; avoid optional chaining.
|
||||
const { platform, release } = hookArgs.prepareData;
|
||||
if (platform === 'android') checkAndroidRuntime();
|
||||
return buildKotlin(platform, release ? 'release' : 'debug');
|
||||
};
|
||||
@@ -0,0 +1,31 @@
|
||||
// NativeScript runs hooks/<event>/*.js, but that directory is also managed by
|
||||
// @nativescript/hook on package (re)installs and has been observed to lose our
|
||||
// custom hook. The tracked copy under scripts/hooks/ is the source of truth;
|
||||
// this restores it on `npm install` and before every build.
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
|
||||
const root = path.resolve(__dirname, '..');
|
||||
const hooks = [
|
||||
{ source: 'scripts/hooks/faceclaw-kotlin.before-prepare.js', target: 'hooks/before-prepare/faceclaw-kotlin.js' },
|
||||
];
|
||||
|
||||
function installHooks() {
|
||||
const restored = [];
|
||||
for (const { source, target } of hooks) {
|
||||
const from = path.join(root, source);
|
||||
const to = path.join(root, target);
|
||||
const content = fs.readFileSync(from);
|
||||
if (fs.existsSync(to) && fs.readFileSync(to).equals(content)) continue;
|
||||
fs.mkdirSync(path.dirname(to), { recursive: true });
|
||||
fs.writeFileSync(to, content);
|
||||
restored.push(target);
|
||||
}
|
||||
return restored;
|
||||
}
|
||||
|
||||
module.exports = { installHooks };
|
||||
if (require.main === module) {
|
||||
const restored = installHooks();
|
||||
if (restored.length) console.log(`[hooks] restored ${restored.join(', ')}`);
|
||||
}
|
||||
@@ -19,4 +19,5 @@ if command -v ruby >/dev/null 2>&1; then
|
||||
export PATH="$gem_bin:$PATH"
|
||||
fi
|
||||
|
||||
node scripts/install-hooks.cjs
|
||||
exec ns "$@"
|
||||
Reference in new issue
Block a user