mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix(android-build): keep tar@7 and patch Capacitor CLI extractor compatibility
This commit is contained in:
@@ -49,6 +49,7 @@
|
||||
"scripts": {
|
||||
"generate:assets": "node scripts/generate-asset-manifest.js",
|
||||
"sync:directories": "node scripts/sync-directories.js",
|
||||
"postinstall": "node scripts/patch-capacitor-cli-tar.cjs",
|
||||
"prebuild": "yarn sync:directories && yarn generate:assets",
|
||||
"prestart": "yarn sync:directories && yarn generate:assets",
|
||||
"start": "vite",
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const templatePath = path.join(__dirname, '..', 'node_modules', '@capacitor', 'cli', 'dist', 'util', 'template.js');
|
||||
|
||||
if (!fs.existsSync(templatePath)) {
|
||||
console.log('[patch-capacitor-cli-tar] Skip: @capacitor/cli template.js not found.');
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
const source = fs.readFileSync(templatePath, 'utf8');
|
||||
|
||||
if (source.includes('Patched for tar v7 compatibility')) {
|
||||
console.log('[patch-capacitor-cli-tar] Already patched.');
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
const target = ' await tar_1.default.extract({ file: src, cwd: dir });';
|
||||
if (!source.includes(target)) {
|
||||
console.warn('[patch-capacitor-cli-tar] Target snippet not found; leaving file unchanged.');
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
const replacement = [
|
||||
' // Patched for tar v7 compatibility.',
|
||||
' const tarCompat = tar_1.default ?? tar_1;',
|
||||
' const extract = tarCompat.extract ?? tarCompat.default?.extract;',
|
||||
' if (typeof extract !== "function") {',
|
||||
' throw new TypeError("Capacitor CLI template extractor unavailable");',
|
||||
' }',
|
||||
' await extract({ file: src, cwd: dir });',
|
||||
].join('\n');
|
||||
|
||||
const updated = source.replace(target, replacement);
|
||||
fs.writeFileSync(templatePath, updated, 'utf8');
|
||||
console.log('[patch-capacitor-cli-tar] Applied patch to @capacitor/cli template extractor.');
|
||||
Reference in New Issue
Block a user