Update main.yml

This commit is contained in:
Savsis 2026-05-08 03:09:00 +05:00 • committed by GitHub
parent e7e4877a48
commit e0f6e63167

View file

@ -27,29 +27,56 @@ jobs:
- name: Patch react-native-track-player - name: Patch react-native-track-player
run: | run: |
TP="node_modules/react-native-track-player" node -e "
SRC="$TP/lib/src" const fs = require('fs');
CJS="$TP/lib/commonjs" const path = require('path');
echo "=== Listing package structure ===" const pkg = 'node_modules/react-native-track-player';
ls "$TP/lib/" 2>/dev/null || echo "No lib dir" const srcDir = path.join(pkg, 'lib', 'src');
ls "$CJS/" 2>/dev/null | head -20 || echo "No commonjs dir" const target = path.join(srcDir, 'trackPlayer.js');
mkdir -p "$SRC"
# Copy real compiled files from commonjs → src // List lib/src contents
if [ -d "$CJS" ]; then console.log('lib/src/ files:');
cp -r "$CJS/." "$SRC/" if (fs.existsSync(srcDir)) {
echo "=== Copied commonjs → lib/src ===" fs.readdirSync(srcDir).forEach(f => console.log(' ', f));
ls "$SRC/" }
else
echo "ERROR: lib/commonjs not found — cannot patch" if (fs.existsSync(target)) { console.log('Already exists'); process.exit(0); }
exit 1
fi // Try web version
# Verify the critical file exists const webVer = path.join(pkg, 'lib', 'web', 'trackPlayer.js');
if [ ! -f "$SRC/trackPlayer.js" ]; then if (fs.existsSync(webVer)) {
echo "ERROR: trackPlayer.js still missing after patch" fs.copyFileSync(webVer, target);
ls "$SRC/" console.log('Copied from lib/web/trackPlayer.js');
exit 1 process.exit(0);
fi }
echo "PATCH OK: trackPlayer.js exists"
// Create re-export shim — forwards to NativeModules
const shim = [
'\"use strict\";',
'Object.defineProperty(exports, \"__esModule\", { value: true });',
'const react_native_1 = require(\"react-native\");',
'const NTP = react_native_1.NativeModules.TrackPlayer || {};',
'const TrackPlayer = {',
' setupPlayer: (o) => NTP.setupPlayer(o),',
' add: (t, b) => NTP.add(t, b),',
' play: () => NTP.play(),',
' pause: () => NTP.pause(),',
' stop: () => NTP.stop(),',
' reset: () => NTP.reset(),',
' seekTo: (s) => NTP.seekTo(s),',
' skipToNext: () => NTP.skipToNext(),',
' skipToPrevious: () => NTP.skipToPrevious(),',
' getPlaybackState: () => NTP.getState ? NTP.getState() : Promise.resolve({ state: 0 }),',
' updateOptions: (o) => NTP.updateOptions ? NTP.updateOptions(o) : Promise.resolve(),',
' updateNowPlayingMetadata: (m) => NTP.updateNowPlayingMetadata ? NTP.updateNowPlayingMetadata(m) : Promise.resolve(),',
'};',
'exports.default = TrackPlayer;',
'Object.assign(exports, TrackPlayer);',
].join('\n');
fs.mkdirSync(srcDir, { recursive: true });
fs.writeFileSync(target, shim);
console.log('Created NativeModules shim trackPlayer.js');
"
- name: Install CocoaPods - name: Install CocoaPods
run: sudo gem install cocoapods --no-document run: sudo gem install cocoapods --no-document