mirror of
https://github.com/neosubhamoy/neodlp.git
synced 2025-12-19 02:42:58 +05:30
ci: organized build scripts
This commit is contained in:
51
scripts/chmod.js
Normal file
51
scripts/chmod.js
Normal file
@@ -0,0 +1,51 @@
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
import { execSync } from 'child_process';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
const projectRoot = path.resolve(__dirname, '..');
|
||||
|
||||
// Define array of binary source directories
|
||||
const binSrcDirs = [
|
||||
path.join(projectRoot, 'src-tauri', 'binaries'),
|
||||
];
|
||||
|
||||
function makeFilesExecutable() {
|
||||
let totalCount = 0;
|
||||
let successDirs = 0;
|
||||
|
||||
for (const binSrc of binSrcDirs) {
|
||||
try {
|
||||
if (!fs.existsSync(binSrc)) {
|
||||
console.error(`Binaries directory does not exist: ${binSrc}`);
|
||||
continue;
|
||||
}
|
||||
|
||||
const files = fs.readdirSync(binSrc);
|
||||
const nonExeFiles = files.filter(file => !file.endsWith('.exe'));
|
||||
let count = 0;
|
||||
|
||||
for (const file of nonExeFiles) {
|
||||
const filePath = path.join(binSrc, file);
|
||||
if (fs.statSync(filePath).isFile()) {
|
||||
execSync(`chmod +x "${filePath}"`);
|
||||
console.log(`Made executable: ${path.relative(__dirname, filePath)}`);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
console.log(`Successfully made ${count} files executable in ${binSrc}`);
|
||||
totalCount += count;
|
||||
successDirs++;
|
||||
} catch (error) {
|
||||
console.error(`Error processing directory ${binSrc}: ${error.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
console.log(`\nSummary: Made ${totalCount} files executable across ${successDirs} directories`);
|
||||
}
|
||||
|
||||
console.log(`RUNNING: 🛠️ Build Script --> chmod.js`);
|
||||
makeFilesExecutable();
|
||||
57
scripts/update-yt-dlp.js
Normal file
57
scripts/update-yt-dlp.js
Normal file
@@ -0,0 +1,57 @@
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { execFile } from 'child_process';
|
||||
import { fileURLToPath } from 'url';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
const projectRoot = path.resolve(__dirname, '..');
|
||||
|
||||
console.log(`RUNNING: 🛠️ Build Script --> update-yt-dlp.js`);
|
||||
|
||||
// Get the platform triple from command line arguments
|
||||
const platformTriple = process.argv[2];
|
||||
|
||||
if (!platformTriple) {
|
||||
console.error('Error: Please provide a platform triple');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// Define the binaries directory
|
||||
const binariesDir = path.join(projectRoot, 'src-tauri', 'binaries');
|
||||
|
||||
// Construct the binary filename based on platform triple
|
||||
let binaryName = `yt-dlp-${platformTriple}`;
|
||||
if (platformTriple === 'x86_64-pc-windows-msvc') {
|
||||
binaryName += '.exe';
|
||||
}
|
||||
|
||||
// Full path to the binary
|
||||
const binaryPath = path.join(binariesDir, binaryName);
|
||||
|
||||
// Check if binary exists
|
||||
if (!fs.existsSync(binaryPath)) {
|
||||
console.error(`Error: Binary not found at: ${binaryPath}`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
console.log(`Found binary at: ${binaryPath}`);
|
||||
|
||||
// Make binary executable if not on Windows
|
||||
if (platformTriple !== 'x86_64-pc-windows-msvc') {
|
||||
console.log('Making binary executable...');
|
||||
fs.chmodSync(binaryPath, 0o755);
|
||||
}
|
||||
|
||||
// Execute the update command
|
||||
console.log(`Updating ${platformTriple} binary to latest nightly version...`);
|
||||
execFile(binaryPath, ['--update-to', 'nightly'], (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
console.error(`Error updating binary: ${error.message}`);
|
||||
if (stderr) console.error(stderr);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
console.log(`Update successful for ${platformTriple}:`);
|
||||
console.log(stdout);
|
||||
});
|
||||
Reference in New Issue
Block a user