Files
cinny-mobile/scripts/restore-cinny.mjs
Max Litruv Boonzaayer 2e4a39b27e
Some checks failed
Build / increment-version (push) Successful in 6s
Build / build-linux (push) Failing after 30s
Build / build-android (push) Failing after 3m1s
Build / build-windows (push) Has been cancelled
Build / create-release (push) Has been cancelled
feat: build Android APK on Linux CI (symlink, gradlew, setup-android action)
2026-04-07 15:40:07 +10:00

60 lines
2.0 KiB
JavaScript

/**
* Restores the cinny submodule to its pre-build state after an Android build.
*
* This script:
* 1. Reverts all tracked file changes made by apply-overlay (git checkout)
* 2. Removes untracked overlay files (capacitor.config.json)
* 3. Removes the cinny/android junction
* 4. Pops the pre-overlay git stash if apply-overlay saved one
*/
import { existsSync, unlinkSync } from 'fs';
import { join, dirname } from 'path';
import { fileURLToPath } from 'url';
import { execSync } from 'child_process';
const __dirname = dirname(fileURLToPath(import.meta.url));
const ROOT = join(__dirname, '..');
const CINNY = join(ROOT, 'cinny');
const STASH_FLAG = join(ROOT, '.cinny-stash-pending');
// 1. Revert all tracked overlay modifications
console.log('[restore-cinny] Reverting tracked changes...');
execSync('git checkout -- .', { cwd: CINNY, stdio: 'inherit' });
// 2. Remove untracked capacitor.config.json written by the overlay
const capConfig = join(CINNY, 'capacitor.config.json');
if (existsSync(capConfig)) {
unlinkSync(capConfig);
console.log('[restore-cinny] Removed cinny/capacitor.config.json');
}
// 3. Remove the android link (junction on Windows, symlink on Linux)
const androidJunction = join(CINNY, 'android');
if (existsSync(androidJunction)) {
try {
if (process.platform === 'win32') {
execSync(`cmd /c rmdir "${androidJunction}"`, { stdio: 'pipe' });
} else {
unlinkSync(androidJunction);
}
console.log('[restore-cinny] Removed cinny/android link');
} catch (err) {
console.warn('[restore-cinny] Could not remove android link:', err.message);
}
}
// 4. Pop stash if apply-overlay saved one
if (existsSync(STASH_FLAG)) {
console.log('[restore-cinny] Popping pre-overlay stash...');
try {
execSync('git stash pop', { cwd: CINNY, stdio: 'inherit' });
console.log('[restore-cinny] Stash restored.');
} catch (err) {
console.warn('[restore-cinny] Stash pop failed (may have conflicts):', err.message);
}
unlinkSync(STASH_FLAG);
}
console.log('[restore-cinny] Done. cinny submodule is clean.');