Browse Source

remove java version

migrate-to-golang
Dennis Jekubczyk 3 years ago
parent
commit
0111003c96
4 changed files with 4 additions and 455 deletions
  1. +4
    -2
      build/Dockerfile.dockerignore
  2. +0
    -324
      package-lock.json
  3. +0
    -25
      package.json
  4. +0
    -104
      src/index.js

+ 4
- 2
build/Dockerfile.dockerignore

@ -1,6 +1,8 @@
.idea/
.git/ .git/
node_modules/
.github/
.idea/
third_party/
.secrets.rc .secrets.rc
.gitignore .gitignore

+ 0
- 324
package-lock.json

@ -1,324 +0,0 @@
{
"name": "mirror-to-gitea",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"@octokit/auth-token": {
"version": "2.4.4",
"resolved": "https://globaldevtools.bbva.com:443/artifactory/api/npm/npm-repo/@octokit/auth-token/-/auth-token-2.4.4.tgz",
"integrity": "sha1-7jHGmwHQN4wS/T/+QGAw89lNO1Y=",
"requires": {
"@octokit/types": "^6.0.0"
}
},
"@octokit/core": {
"version": "3.2.4",
"resolved": "https://globaldevtools.bbva.com:443/artifactory/api/npm/npm-repo/@octokit/core/-/core-3.2.4.tgz",
"integrity": "sha1-V5ElYFepYuypcuMYGPAkVIl/0QY=",
"requires": {
"@octokit/auth-token": "^2.4.4",
"@octokit/graphql": "^4.5.8",
"@octokit/request": "^5.4.12",
"@octokit/types": "^6.0.3",
"before-after-hook": "^2.1.0",
"universal-user-agent": "^6.0.0"
}
},
"@octokit/endpoint": {
"version": "6.0.10",
"resolved": "https://globaldevtools.bbva.com:443/artifactory/api/npm/npm-repo/@octokit/endpoint/-/endpoint-6.0.10.tgz",
"integrity": "sha1-dBzh+i9Pt3zo6+DG6vXOY/Vl+Og=",
"requires": {
"@octokit/types": "^6.0.0",
"is-plain-object": "^5.0.0",
"universal-user-agent": "^6.0.0"
}
},
"@octokit/graphql": {
"version": "4.5.8",
"resolved": "https://globaldevtools.bbva.com:443/artifactory/api/npm/npm-repo/@octokit/graphql/-/graphql-4.5.8.tgz",
"integrity": "sha1-1CNzYzwwFdDq/OZKjOGWvhZ/3Zs=",
"requires": {
"@octokit/request": "^5.3.0",
"@octokit/types": "^6.0.0",
"universal-user-agent": "^6.0.0"
}
},
"@octokit/openapi-types": {
"version": "2.2.0",
"resolved": "https://globaldevtools.bbva.com:443/artifactory/api/npm/npm-repo/@octokit/openapi-types/-/openapi-types-2.2.0.tgz",
"integrity": "sha1-Ej4EOKC8cYzNrDtaLmmz3QDaqFs="
},
"@octokit/plugin-paginate-rest": {
"version": "2.7.0",
"resolved": "https://globaldevtools.bbva.com:443/artifactory/api/npm/npm-repo/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-2.7.0.tgz",
"integrity": "sha1-a7ewQ8JG4GVBGabsTnKhcsnix/M=",
"requires": {
"@octokit/types": "^6.0.1"
}
},
"@octokit/plugin-request-log": {
"version": "1.0.2",
"resolved": "https://globaldevtools.bbva.com:443/artifactory/api/npm/npm-repo/@octokit/plugin-request-log/-/plugin-request-log-1.0.2.tgz",
"integrity": "sha1-OU1Z7HNM0vEiQx+68FCZhh7OPEQ="
},
"@octokit/plugin-rest-endpoint-methods": {
"version": "4.4.1",
"resolved": "https://globaldevtools.bbva.com:443/artifactory/api/npm/npm-repo/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-4.4.1.tgz",
"integrity": "sha1-EFz5MlVDIVXeB4ye/DO9ThTRzWM=",
"requires": {
"@octokit/types": "^6.1.0",
"deprecation": "^2.3.1"
}
},
"@octokit/request": {
"version": "5.4.12",
"resolved": "https://globaldevtools.bbva.com:443/artifactory/api/npm/npm-repo/@octokit/request/-/request-5.4.12.tgz",
"integrity": "sha1-sEgm+pNGcMVrE1qBRHviwXI6L/w=",
"requires": {
"@octokit/endpoint": "^6.0.1",
"@octokit/request-error": "^2.0.0",
"@octokit/types": "^6.0.3",
"deprecation": "^2.0.0",
"is-plain-object": "^5.0.0",
"node-fetch": "^2.6.1",
"once": "^1.4.0",
"universal-user-agent": "^6.0.0"
}
},
"@octokit/request-error": {
"version": "2.0.4",
"resolved": "https://globaldevtools.bbva.com:443/artifactory/api/npm/npm-repo/@octokit/request-error/-/request-error-2.0.4.tgz",
"integrity": "sha1-B91cBSHS7pdSASdMRyoSeRd0EmI=",
"requires": {
"@octokit/types": "^6.0.0",
"deprecation": "^2.0.0",
"once": "^1.4.0"
}
},
"@octokit/rest": {
"version": "18.0.12",
"resolved": "https://globaldevtools.bbva.com:443/artifactory/api/npm/npm-repo/@octokit/rest/-/rest-18.0.12.tgz",
"integrity": "sha1-J4vUE1jFbYfCAeeH6K3AysEyUDo=",
"requires": {
"@octokit/core": "^3.2.3",
"@octokit/plugin-paginate-rest": "^2.6.2",
"@octokit/plugin-request-log": "^1.0.2",
"@octokit/plugin-rest-endpoint-methods": "4.4.1"
}
},
"@octokit/types": {
"version": "6.2.1",
"resolved": "https://globaldevtools.bbva.com:443/artifactory/api/npm/npm-repo/@octokit/types/-/types-6.2.1.tgz",
"integrity": "sha1-f4gf5ER1qxgld2pKWcoa4ILtEEM=",
"requires": {
"@octokit/openapi-types": "^2.2.0",
"@types/node": ">= 8"
}
},
"@types/node": {
"version": "14.14.20",
"resolved": "https://globaldevtools.bbva.com:443/artifactory/api/npm/npm-repo/@types/node/-/node-14.14.20.tgz",
"integrity": "sha1-95dIY+3SHR+KSUpz6OKzZYYVw0A="
},
"asynckit": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
"integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k="
},
"before-after-hook": {
"version": "2.1.0",
"resolved": "https://globaldevtools.bbva.com:443/artifactory/api/npm/npm-repo/before-after-hook/-/before-after-hook-2.1.0.tgz",
"integrity": "sha1-tsA0h/ROJCAN0wyl5qGXnF0vtjU="
},
"combined-stream": {
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.7.tgz",
"integrity": "sha512-brWl9y6vOB1xYPZcpZde3N9zDByXTosAeMDo4p1wzo6UMOX4vumB+TP1RZ76sfE6Md68Q0NJSrE/gbezd4Ul+w==",
"requires": {
"delayed-stream": "~1.0.0"
}
},
"component-emitter": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.1.tgz",
"integrity": "sha1-E3kY1teCg/ffemt8WmPhQOaUJeY="
},
"cookiejar": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/cookiejar/-/cookiejar-2.1.2.tgz",
"integrity": "sha512-Mw+adcfzPxcPeI+0WlvRrr/3lGVO0bD75SxX6811cxSh1Wbxx7xZBGK1eVtDf6si8rg2lhnUjsVLMFMfbRIuwA=="
},
"debug": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz",
"integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==",
"requires": {
"ms": "^2.1.1"
}
},
"delayed-stream": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
"integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk="
},
"deprecation": {
"version": "2.3.1",
"resolved": "https://globaldevtools.bbva.com:443/artifactory/api/npm/npm-repo/deprecation/-/deprecation-2.3.1.tgz",
"integrity": "sha1-Y2jL20Cr8zc7UlrIfkomDDpwCRk="
},
"eventemitter3": {
"version": "4.0.7",
"resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.7.tgz",
"integrity": "sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw=="
},
"form-data": {
"version": "2.3.3",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz",
"integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==",
"requires": {
"asynckit": "^0.4.0",
"combined-stream": "^1.0.6",
"mime-types": "^2.1.12"
}
},
"formidable": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/formidable/-/formidable-1.2.1.tgz",
"integrity": "sha512-Fs9VRguL0gqGHkXS5GQiMCr1VhZBxz0JnJs4JmMp/2jL18Fmbzvv7vOFRU+U8TBkHEE/CX1qDXzJplVULgsLeg=="
},
"inherits": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
"integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4="
},
"is-plain-object": {
"version": "5.0.0",
"resolved": "https://globaldevtools.bbva.com:443/artifactory/api/npm/npm-repo/is-plain-object/-/is-plain-object-5.0.0.tgz",
"integrity": "sha1-RCf1CrNCnpAl6n1S6QQ6nvQVk0Q="
},
"methods": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz",
"integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4="
},
"mime": {
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/mime/-/mime-2.4.0.tgz",
"integrity": "sha512-ikBcWwyqXQSHKtciCcctu9YfPbFYZ4+gbHEmE0Q8jzcTYQg5dHCr3g2wwAZjPoJfQVXZq6KXAjpXOTf5/cjT7w=="
},
"mime-db": {
"version": "1.38.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.38.0.tgz",
"integrity": "sha512-bqVioMFFzc2awcdJZIzR3HjZFX20QhilVS7hytkKrv7xFAn8bM1gzc/FOX2awLISvWe0PV8ptFKcon+wZ5qYkg=="
},
"mime-types": {
"version": "2.1.22",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.22.tgz",
"integrity": "sha512-aGl6TZGnhm/li6F7yx82bJiBZwgiEa4Hf6CNr8YO+r5UHr53tSTYZb102zyU50DOWWKeOv0uQLRL0/9EiKWCog==",
"requires": {
"mime-db": "~1.38.0"
}
},
"ms": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz",
"integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg=="
},
"node-fetch": {
"version": "2.6.1",
"resolved": "https://globaldevtools.bbva.com:443/artifactory/api/npm/npm-repo/node-fetch/-/node-fetch-2.6.1.tgz",
"integrity": "sha1-BFvTI2Mfdu0uK1VXM5RBa2OaAFI="
},
"once": {
"version": "1.4.0",
"resolved": "https://globaldevtools.bbva.com:443/artifactory/api/npm/npm-repo/once/-/once-1.4.0.tgz",
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
"requires": {
"wrappy": "1"
}
},
"p-finally": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz",
"integrity": "sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4="
},
"p-queue": {
"version": "6.6.2",
"resolved": "https://registry.npmjs.org/p-queue/-/p-queue-6.6.2.tgz",
"integrity": "sha512-RwFpb72c/BhQLEXIZ5K2e+AhgNVmIejGlTgiB9MzZ0e93GRvqZ7uSi0dvRF7/XIXDeNkra2fNHBxTyPDGySpjQ==",
"requires": {
"eventemitter3": "^4.0.4",
"p-timeout": "^3.2.0"
}
},
"p-timeout": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/p-timeout/-/p-timeout-3.2.0.tgz",
"integrity": "sha512-rhIwUycgwwKcP9yTOOFK/AKsAopjjCakVqLHePO3CC6Mir1Z99xT+R63jZxAT5lFZLa2inS5h+ZS2GvR99/FBg==",
"requires": {
"p-finally": "^1.0.0"
}
},
"qs": {
"version": "6.6.0",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.6.0.tgz",
"integrity": "sha512-KIJqT9jQJDQx5h5uAVPimw6yVg2SekOKu959OCtktD3FjzbpvaPr8i4zzg07DOMz+igA4W/aNM7OV8H37pFYfA=="
},
"readable-stream": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.2.0.tgz",
"integrity": "sha512-RV20kLjdmpZuTF1INEb9IA3L68Nmi+Ri7ppZqo78wj//Pn62fCoJyV9zalccNzDD/OuJpMG4f+pfMl8+L6QdGw==",
"requires": {
"inherits": "^2.0.3",
"string_decoder": "^1.1.1",
"util-deprecate": "^1.0.1"
}
},
"safe-buffer": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
},
"string_decoder": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.2.0.tgz",
"integrity": "sha512-6YqyX6ZWEYguAxgZzHGL7SsCeGx3V2TtOTqZz1xSTSWnqsbWwbptafNyvf/ACquZUXV3DANr5BDIwNYe1mN42w==",
"requires": {
"safe-buffer": "~5.1.0"
}
},
"superagent": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/superagent/-/superagent-4.1.0.tgz",
"integrity": "sha512-FT3QLMasz0YyCd4uIi5HNe+3t/onxMyEho7C3PSqmti3Twgy2rXT4fmkTz6wRL6bTF4uzPcfkUCa8u4JWHw8Ag==",
"requires": {
"component-emitter": "^1.2.0",
"cookiejar": "^2.1.2",
"debug": "^4.1.0",
"form-data": "^2.3.3",
"formidable": "^1.2.0",
"methods": "^1.1.1",
"mime": "^2.4.0",
"qs": "^6.6.0",
"readable-stream": "^3.0.6"
}
},
"universal-user-agent": {
"version": "6.0.0",
"resolved": "https://globaldevtools.bbva.com:443/artifactory/api/npm/npm-repo/universal-user-agent/-/universal-user-agent-6.0.0.tgz",
"integrity": "sha1-M4H4UDslHA2c0hvB3pOeyd9UgO4="
},
"util-deprecate": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
"integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
},
"wrappy": {
"version": "1.0.2",
"resolved": "https://globaldevtools.bbva.com:443/artifactory/api/npm/npm-repo/wrappy/-/wrappy-1.0.2.tgz",
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8="
}
}
}

+ 0
- 25
package.json

@ -1,25 +0,0 @@
{
"name": "mirror-to-gitea",
"version": "1.0.0",
"description": "mirror all your public github repositories to your gitea server",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/jaedle/mirror-to-gitea.git"
},
"keywords": [],
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/jaedle/mirror-to-gitea/issues"
},
"homepage": "https://github.com/jaedle/mirror-to-gitea#readme",
"dependencies": {
"@octokit/rest": "^18.0.12",
"p-queue": "^6.6.2",
"superagent": "^4.0.0"
}
}

+ 0
- 104
src/index.js

@ -1,104 +0,0 @@
const {Octokit} = require('@octokit/rest');
const request = require('superagent');
const {default: PQueue} = require('p-queue');
async function getGithubRepositories(username, token) {
const octokit = new Octokit({
auth: token || null,
});
return octokit.paginate('GET /users/:username/repos', { username: username })
.then(repositories => toRepositoryList(repositories));
}
function toRepositoryList(repositories) {
return repositories.map(repository => {
return { name: repository.name, url: repository.clone_url }
});
}
async function getGiteaUser(gitea) {
return request.get(gitea.url
+ '/api/v1/user')
.query(`access_token=${gitea.token}`)
.then(response => {
return { id: response.body.id, name: response.body.username }
});
}
function isAlreadyMirroredOnGitea(repository, gitea, giteaUser) {
const requestUrl = `${gitea.url}/api/v1/repos/${giteaUser.name}/${repository}`;
return request.get(
requestUrl)
.query(`access_token=${gitea.token}`)
.then(() => true)
.catch(() => false);
}
function mirrorOnGitea(repository, gitea, giteaUser) {
request.post(`${gitea.url}/api/v1/repos/migrate`)
.query(`access_token=${gitea.token}`)
.send({
clone_addr: repository.url,
mirror: true,
repo_name: repository.name,
uid: giteaUser.id,
})
.then(() => {
console.log('Did it!');
})
.catch(err => {
console.log('Failed', err);
});
}
async function mirror(repository, gitea, giteaUser) {
if (await isAlreadyMirroredOnGitea(repository.name,
gitea,
giteaUser)) {
console.log('Repository is already mirrored; doing nothing: ', repository.name);
return;
}
console.log('Mirroring repository to gitea: ', repository.name);
await mirrorOnGitea(repository, gitea, giteaUser);
}
async function main() {
const githubUsername = process.env.GITHUB_USERNAME;
if (!githubUsername) {
console.error('No GITHUB_USERNAME specified, please specify! Exiting..');
return;
}
const githubToken = process.env.GITHUB_TOKEN;
const giteaUrl = process.env.GITEA_URL;
if (!giteaUrl) {
console.error('No GITEA_URL specified, please specify! Exiting..');
return;
}
const giteaToken = process.env.GITEA_TOKEN;
if (!giteaToken) {
console.error('No GITEA_TOKEN specified, please specify! Exiting..');
return;
}
const githubRepositories = await getGithubRepositories(githubUsername, githubToken);
console.log(`Found ${githubRepositories.length} repositories on github`);
const gitea = {
url: giteaUrl,
token: giteaToken,
};
const giteaUser = await getGiteaUser(gitea);
const queue = new PQueue({ concurrency: 4 });
await queue.addAll(githubRepositories.map(repository => {
return async () => {
await mirror(repository, gitea, giteaUser);
};
}));
}
main();

Loading…
Cancel
Save