Spaces:
Running
Running
Delete up.js
Browse files
up.js
DELETED
@@ -1,49 +0,0 @@
|
|
1 |
-
require('dotenv/config')
|
2 |
-
const fs = require("fs")
|
3 |
-
let accounts = fs.readFileSync('./account', 'utf8').split("\n")
|
4 |
-
const { exec } = require('child_process');
|
5 |
-
const key = "Abr0M3fvrtOxT09MS1ZwmUq"
|
6 |
-
|
7 |
-
const { promisify } = require('util')
|
8 |
-
|
9 |
-
const execPromise = promisify(exec);
|
10 |
-
|
11 |
-
const execute = (command) => {
|
12 |
-
return execPromise(command).then(({ stdout, stderr }) => {
|
13 |
-
if (stderr) {
|
14 |
-
console.warn(`Stderr: ${stderr}`);
|
15 |
-
}
|
16 |
-
return stdout;
|
17 |
-
}).catch((error) => {
|
18 |
-
throw new Error(`Error: ${error.message}`);
|
19 |
-
});
|
20 |
-
};
|
21 |
-
|
22 |
-
const push = async (username) => {
|
23 |
-
try {
|
24 |
-
const token = await fetch(`https://${username}-cors.hf.space/ev?key=${key}&q=process.env.TOKEN`).then(a => a.text())
|
25 |
-
const repoUrl = "huggingface.co/spaces/"+username+"/"+process.env.REPO_NAME
|
26 |
-
|
27 |
-
console.log(await execute('git add .'))
|
28 |
-
console.log(await execute('git status'));
|
29 |
-
console.log(await execute(`git commit --allow-empty -m "changed"`));
|
30 |
-
console.log(await execute('git branch -M main'));
|
31 |
-
console.log(await execute(`git push https://${username}:${token}@${repoUrl} main --force`));
|
32 |
-
console.log('Commands executed successfully');
|
33 |
-
return
|
34 |
-
} catch (error) {
|
35 |
-
console.error(`Failed to execute commands: ${error}`);
|
36 |
-
}
|
37 |
-
};
|
38 |
-
|
39 |
-
|
40 |
-
let custom = process.argv.slice(2)
|
41 |
-
let _accounts = custom?.length > 0 ? custom : accounts
|
42 |
-
console.log(_accounts);
|
43 |
-
(async()=> {
|
44 |
-
for(let account of _accounts){
|
45 |
-
await push(account)
|
46 |
-
console.log('✅success', { account })
|
47 |
-
}
|
48 |
-
setTimeout(() => process.exit(), 3000)
|
49 |
-
})()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|