commit
5e93c4663c
@ -0,0 +1 @@ |
||||
just some scripts i wrote don't expect much documentation |
@ -0,0 +1,59 @@ |
||||
# [scripts](https://code.juke.fr/kay/scripts) |
||||
various scripts i wrote that i felt needed to be committed for some reason |
||||
|
||||
just some scripts i wrote don't expect much documentation |
||||
|
||||
|
||||
## License |
||||
|
||||
Most all of my work is now licensed under **a modified** [CC-BY-NC-SA 4.0 AFEdit](https://code.juke.fr/kay/license/raw/branch/main/LICENSE) plus accounting for states existing in our world on top of capitalism. |
||||
|
||||
This is a weird choice for code right? |
||||
|
||||
Here are a few key reasons: |
||||
- my definition of "open" involves being able to share and modify, you are able to do such things, just not make money off of it, or oppress people |
||||
- my definition of "free" involves being able to share and modify, you are able to do such things, not just make money off of it, or oppressing people |
||||
|
||||
So no, amongst other things, this list is not exhaustive, |
||||
- you cannot have somebody work on my tool and redistribute it to your employees |
||||
- you cannot resell copies of this because in this age distribution is not done with floppy disks and the internet is a thing |
||||
- you cannot use it to generate revenue yourself |
||||
- you cannot use it to "generate value" in a capitalistic sense |
||||
- you cannot use it in any military capacity |
||||
- you cannot use it in any law enforcement capacity |
||||
- you cannot use it in any state backed capacity |
||||
- you cannot use it in any surveillance capacity |
||||
- you cannot use it if you represent the interests of a state |
||||
- you cannot use it to oppress, spy, control in any capacity |
||||
- you cannot use it to injure, harm, kill, whether physically or psychologically |
||||
|
||||
You can, however, |
||||
- change it to do whatever you please |
||||
- share it to anyone you please with attribution and under the same license |
||||
- use it as much as you please |
||||
- and probably a bunch of other cool things that are possible outside of a capitalistic, imperialistic frame of reference that permeates the tech scene |
||||
|
||||
Most of the "arguments" for how "free" and "open" source licenses are done still to this day stem from archaic concepts that might not even be relevant these days and I fail to see the issue with this license not being "interoperable" with a bunch of what I deem to be "bad" licenses, as they all allow for commercial usage. |
||||
|
||||
I also will not make any attempts to monetize these works and will at most ever offer the possibility to donate to me directly if you enjoy what I do. |
||||
|
||||
Thank you that is all. |
||||
|
||||
## Development |
||||
|
||||
To clone the repository locally: |
||||
|
||||
```bash |
||||
$ git clone https://code.juke.fr/kay/scripts.git |
||||
``` |
||||
|
||||
## Contributing |
||||
|
||||
More to come later. |
||||
|
||||
### Issues |
||||
Open new issues by mailing [eutychia.gitlab+scripts-issue@gmail.com](mailto:eutychia.gitlab+scripts-issue@gmail.com) |
||||
|
||||
--- |
||||
beep boop |
||||
|
@ -0,0 +1,129 @@ |
||||
// git is very cringe sometimes
|
||||
|
||||
import { encode, decode } from "https://deno.land/std/encoding/base64.ts"; |
||||
|
||||
let reps; |
||||
|
||||
const username = |
||||
Deno.env.get("GITEA_USERNAME") || |
||||
(() => { |
||||
throw new Error("GITEA_USERNAME required"); |
||||
})(); |
||||
const password = |
||||
Deno.env.get("GITEA_PASSWORD") || |
||||
(() => { |
||||
throw new Error("GITEA_PASSWORD required"); |
||||
})(); |
||||
const instance = |
||||
Deno.env.get("GITEA_INSTANCE") || |
||||
(() => { |
||||
throw new Error("GITEA_INSTANCE required"); |
||||
})(); |
||||
|
||||
console.log("0. Instance Healthcheck..."); |
||||
try { |
||||
await fetch(instance); |
||||
} catch (e) { |
||||
console.error(e); |
||||
throw new Error("Healthcheck failed"); |
||||
} |
||||
|
||||
console.log("1. Getting all repos..."); |
||||
try { |
||||
const repos = await ( |
||||
await fetch(`${instance}/api/v1/user/repos?limit=100`, { |
||||
method: "GET", |
||||
headers: { |
||||
Authorization: "Basic " + encode(`${username}:${password}`), |
||||
}, |
||||
}) |
||||
).json(); |
||||
reps = repos.map(({ name }) => { |
||||
console.log(`- ${username}/${name}`); |
||||
return name; |
||||
}); |
||||
console.log(`Found ${reps.length} repos.`); |
||||
} catch (e) { |
||||
console.error(e); |
||||
throw new Error("Getting repos failed"); |
||||
} |
||||
|
||||
console.log("2. Getting all repos infos..."); |
||||
try { |
||||
const tempreps = []; |
||||
for (const name of reps) { |
||||
const repo = await ( |
||||
await fetch(`${instance}/api/v1/repos/${username}/${name}`, { |
||||
method: "GET", |
||||
headers: { |
||||
Authorization: "Basic " + encode(`${username}:${password}`), |
||||
}, |
||||
}) |
||||
).json(); |
||||
const { topics } = await ( |
||||
await fetch(`${instance}/api/v1/repos/${username}/${name}/topics`, { |
||||
method: "GET", |
||||
headers: { |
||||
Authorization: "Basic " + encode(`${username}:${password}`), |
||||
}, |
||||
}) |
||||
).json(); |
||||
tempreps.push({ name, description: repo.description.trim(), topics }); |
||||
} |
||||
reps = tempreps; |
||||
console.log(reps); |
||||
await Deno.writeTextFile("./repos.json", JSON.stringify(reps, 0, 2)); |
||||
} catch (e) { |
||||
console.error(e); |
||||
throw new Error("Getting repos infos failed"); |
||||
} |
||||
|
||||
console.log("2. Deleting all repos..."); |
||||
try { |
||||
for (const rep of reps) { |
||||
await fetch(`${instance}/api/v1/repos/${username}/${rep.name}`, { |
||||
method: "DELETE", |
||||
headers: { |
||||
Authorization: "Basic " + encode(`${username}:${password}`), |
||||
}, |
||||
}); |
||||
console.log(`Deleted ${username}/${rep.name}`); |
||||
} |
||||
} catch (e) { |
||||
console.error(e); |
||||
throw new Error("Deleting repos failed"); |
||||
} |
||||
|
||||
console.log("2. Creating all repos..."); |
||||
try { |
||||
for (const rep of reps) { |
||||
await fetch(`${instance}/api/v1/user/repos`, { |
||||
method: "POST", |
||||
headers: { |
||||
Authorization: "Basic " + encode(`${username}:${password}`), |
||||
"Content-Type": "application/json", |
||||
}, |
||||
body: JSON.stringify({ |
||||
name: rep.name, |
||||
description: rep.description, |
||||
private: false, |
||||
}), |
||||
}); |
||||
console.log(`Created ${username}/${rep.name}`); |
||||
|
||||
await fetch(`${instance}/api/v1/repos/${username}/${rep.name}/topics`, { |
||||
method: "PUT", |
||||
headers: { |
||||
Authorization: "Basic " + encode(`${username}:${password}`), |
||||
"Content-Type": "application/json", |
||||
}, |
||||
body: JSON.stringify({ |
||||
topics: rep.topics, |
||||
}), |
||||
}); |
||||
console.log(`Topicced ${username}/${rep.name}`); |
||||
} |
||||
} catch (e) { |
||||
console.error(e); |
||||
throw new Error("Creating repos failed"); |
||||
} |
Loading…
Reference in new issue