Comparing version 1.6.3 to 1.6.4
@@ -16,3 +16,3 @@ const axios = require('axios') | ||
async function inviteCollaboratorsToRepos(org, repos, collaborators, token) { | ||
async function inviteCollaboratorsToRepos(org, repos, arrays, token) { | ||
// Get org repo url | ||
@@ -23,9 +23,8 @@ const filePath = path.join(__dirname, '..', 'properties', 'api.properties'); | ||
try { | ||
// Invite collaborators for each repository | ||
await Promise.all(repos.map(async repo => { | ||
await Promise.all(collaborators.map(async collaborator => { | ||
await Promise.all(repos.map(async (repo, i) => { | ||
for (let j = 0; j < arrays[i].length; j++) { | ||
const replacements = { | ||
organization: org, | ||
repository: repo, | ||
collaborator: collaborator | ||
collaborator: arrays[i][j] | ||
}; | ||
@@ -40,10 +39,8 @@ | ||
}); | ||
console.log(`Invitation sent to ${collaborator} for ${repo}`); | ||
console.log(`Invitation sent to ${arrays[i][j]} for ${repo}`); | ||
} catch (error) { | ||
console.error(`Error inviting ${collaborator} for ${repo}:`, error.response ? error.response.data : error.message); | ||
console.error(`Error inviting ${arrays[i][j]} for ${repo}:`, error.response ? error.response.data : error.message); | ||
} | ||
})); | ||
} | ||
})); | ||
console.log('Collaborators invited successfully.'); | ||
} catch (error) { | ||
@@ -50,0 +47,0 @@ console.error('Error inviting collaborators:', error.response ? error.response.data : error.message); |
@@ -16,4 +16,4 @@ const axios = require('axios') | ||
async function removeReposCollaborators(org, repos, collaborators, token) { | ||
// Get org repo url | ||
async function removeCollaboratorsFromRepos(org, repos, arrays, token) { | ||
// Get org repo URL | ||
const filePath = path.join(__dirname, '..', 'properties', 'api.properties'); | ||
@@ -23,9 +23,8 @@ const config = readPropertiesFile(filePath); | ||
try { | ||
// Remove collaborators for each repository | ||
await Promise.all(repos.map(async repo => { | ||
await Promise.all(collaborators.map(async collaborator => { | ||
await Promise.all(repos.map(async (repo, i) => { | ||
for (let j = 0; j < arrays[i].length; j++) { | ||
const replacements = { | ||
organization: org, | ||
repository: repo, | ||
collaborator: collaborator | ||
collaborator: arrays[i][j] | ||
}; | ||
@@ -40,10 +39,8 @@ | ||
}); | ||
console.log(`Collaborator ${collaborator} removed from ${repo}`); | ||
console.log(`Collaborator ${arrays[i][j]} removed from ${repo}`); | ||
} catch (error) { | ||
console.error(`Error removing ${collaborator} from ${repo}:`, error.response ? error.response.data : error.message); | ||
console.error(`Error removing ${arrays[i][j]} from ${repo}:`, error.response ? error.response.data : error.message); | ||
} | ||
})); | ||
} | ||
})); | ||
console.log('Collaborators removed successfully.'); | ||
} catch (error) { | ||
@@ -50,0 +47,0 @@ console.error('Error removing collaborators:', error.response ? error.response.data : error.message); |
{ | ||
"name": "jwz", | ||
"version": "1.6.3", | ||
"version": "1.6.4", | ||
"description": "Utils", | ||
@@ -5,0 +5,0 @@ "repository": { |
147
README.md
@@ -0,1 +1,8 @@ | ||
  | ||
<div align="center"> | ||
<a href="https://opencollective.com/jetsadawijit" target="_blank" rel="noopener noreferrer"> | ||
<img width="300" src="https://opencollective.com/public/images/opencollectivelogo.svg" alt="Open Collective"> | ||
</a> | ||
</div> | ||
# `Function` | ||
@@ -10,54 +17,54 @@ ## `GitHub` | ||
- `usage` | ||
``` | ||
/* | ||
@param org = String | ||
@param repo = String | ||
@param vis = String | ||
@param token = String | ||
*/ | ||
const buildGitHubRepos = require('jwz'); | ||
``` | ||
/* | ||
@param org = String | ||
@param repo = String | ||
@param vis = String | ||
@param token = String | ||
*/ | ||
const buildGitHubRepos = require('jwz'); | ||
const org = 'your-org-name'; | ||
var repos = ['your-repoA', 'your-repoB']; | ||
var vis = 'public'; | ||
const token = 'your-token'; | ||
const org = 'your-org-name'; | ||
var repos = ['your-repoA', 'your-repoB']; | ||
var vis = 'public'; | ||
const token = 'your-token'; | ||
const res = await buildGitHubRepos(org, repos, vis, token); | ||
const res = await buildGitHubRepos(org, repos, vis, token); | ||
console.log(res); | ||
``` | ||
console.log(res); | ||
``` | ||
### `deleteGitHubRepos` | ||
- `usage` | ||
``` | ||
/* | ||
@param org = String | ||
@param repos = Array | ||
@param token = String | ||
*/ | ||
const deleteGitHubRepos = require('jwz'); | ||
``` | ||
/* | ||
@param org = String | ||
@param repos = Array | ||
@param token = String | ||
*/ | ||
const deleteGitHubRepos = require('jwz'); | ||
const org = 'your-org-name'; | ||
var repos = ['your-repoA', 'your-repoB']; | ||
const token = 'your-token'; | ||
const org = 'your-org-name'; | ||
var repos = ['your-repoA', 'your-repoB']; | ||
const token = 'your-token'; | ||
deleteGitHubRepos(org, repos, token) | ||
``` | ||
deleteGitHubRepos(org, repos, token) | ||
``` | ||
### `inviteGitHubReposCollaborators` | ||
- `usage` | ||
``` | ||
/* | ||
@param org = String | ||
@param repos = Array | ||
@param collaborators = Array | ||
@param token = String | ||
*/ | ||
const inviteGitHubReposCollaborators = require('jwz'); | ||
``` | ||
/* | ||
@param org = String | ||
@param repos = Array | ||
@param arrays = Array of Array | ||
@param token = String | ||
*/ | ||
const inviteGitHubReposCollaborators = require('jwz'); | ||
const org = 'your-org-name'; | ||
var repo = ['your-repoA', 'your-repoB']; | ||
var collaborators = ['collaboratorA', 'collaboratorB'] | ||
const token = 'your-token'; | ||
const org = 'your-org-name'; | ||
var repo = ['your-repoA', 'your-repoB']; | ||
var arrays = [['collaboratorA', 'collaboratorB'], ['collaboratorC', 'collaboratorD']] | ||
const token = 'your-token'; | ||
inviteGitHubReposCollaborators(org, repos, collaborators, token); | ||
``` | ||
inviteGitHubReposCollaborators(org, repos, arrays, token); | ||
``` | ||
- `note` | ||
@@ -67,40 +74,40 @@ - when code is running it will have output of result | ||
- `usage` | ||
``` | ||
/* | ||
@param org = String | ||
@param repos = Array | ||
@param collaborators = Array | ||
@param token = String | ||
*/ | ||
const removeGitHubReposCollaborators = require('jwz'); | ||
``` | ||
/* | ||
@param org = String | ||
@param repos = Array | ||
@param arrays = Array of Array | ||
@param token = String | ||
*/ | ||
const removeGitHubReposCollaborators = require('jwz'); | ||
const org = 'your-org-name'; | ||
var repo = ['your-repoA', 'your-repoB']; | ||
var collaborators = ['collaboratorA', 'collaboratorB'] | ||
const token = 'your-token'; | ||
const org = 'your-org-name'; | ||
var repo = ['your-repoA', 'your-repoB']; | ||
var arrays = [['collaboratorA', 'collaboratorB'], ['collaboratorC', 'collaboratorD']] | ||
const token = 'your-token'; | ||
removeGitHubReposCollaborators(org, repos, collaborators, token); | ||
``` | ||
removeGitHubReposCollaborators(org, repos, arrays, token); | ||
``` | ||
### `getGitHubReleaseVersion` | ||
- `usage` | ||
``` | ||
/* | ||
@param org = String | ||
@param repo = String | ||
@param version = String | ||
*/ | ||
const getGitHubReleaseVersion = require('jwz'); | ||
``` | ||
/* | ||
@param org = String | ||
@param repo = String | ||
@param version = String | ||
*/ | ||
const getGitHubReleaseVersion = require('jwz'); | ||
const org = 'org-name'; | ||
const repo = 'repo-name'; | ||
const version = 'version' | ||
const org = 'org-name'; | ||
const repo = 'repo-name'; | ||
const version = 'version' | ||
const release = await getGitHubReleaseVersion(org, repo, version); | ||
const release = await getGitHubReleaseVersion(org, repo, version); | ||
console.log(`Release Name: ${release.releaseName}`); | ||
console.log(`Release Tag: ${release.releaseTag}`); | ||
console.log(`Release URL: ${release.releaseURL}`); | ||
``` | ||
console.log(`Release Name: ${release.releaseName}`); | ||
console.log(`Release Tag: ${release.releaseTag}`); | ||
console.log(`Release URL: ${release.releaseURL}`); | ||
``` | ||
- `note` | ||
- return `releaseName` `releaseTag` `releaseURL` | ||
- This is for public organization repository |
111
14679
256