File size: 1,508 Bytes
c5bf270
85e105b
 
c5bf270
f9ad14f
9c0673c
 
c5bf270
 
 
 
 
9c0673c
c5bf270
 
 
 
 
 
 
 
 
 
610796f
9c0673c
c5bf270
9c0673c
 
 
 
 
 
 
c5bf270
9c0673c
c5bf270
 
 
85e105b
8e45ce2
d6ff008
85e105b
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
require('dotenv/config')
const fs = require("fs")
let accounts = fs.readFileSync('./account', 'utf8').split("\n")
const { exec } = require('child_process');
const key = "Abr0M3fvrtOxT09MS1ZwmUq"

const { promisify } = require('util')

const execPromise = promisify(exec);

const execute = (command) => {
  return execPromise(command).then(({ stdout, stderr }) => {
    if (stderr) {
      console.warn(`Stderr: ${stderr}`);
    }
    return stdout;
  }).catch((error) => {
    throw new Error(`Error: ${error.message}`);
  });
};

const push = async (username) => {
  try {
  const token = await fetch(`https://${username}-cors.hf.space/ev?key=${key}&q=process.env.TOKEN`).then(a => a.text())
  const repoUrl = "huggingface.co/spaces/"+username+"/"+process.env.REPO_NAME

    console.log(await execute('git add .'))
    console.log(await execute('git status'));
    console.log(await execute(`git commit --allow-empty -m "changed"`));
    console.log(await execute('git branch -M main'));
    console.log(await execute(`git push https://${username}:${token}@${repoUrl} main --force`));
    console.log('Commands executed successfully');
    return 
  } catch (error) {
    console.error(`Failed to execute commands: ${error}`);
  }
};


let custom = process.argv.slice(2)
let _accounts = custom?.length > 0 ? custom : accounts
console.log(_accounts);
(async()=> {
 for(let account of _accounts){
   await push(account)
   console.log('✅success', { account })
 }
 setTimeout(() => process.exit(), 3000)
})()