1.0.9 • Published 9 months ago
accessrepo v1.0.9
AccessRepo
A library made on NodeJS for read private repositorys from Github. See on npm
Name history:
- repositoryloader
- gitrepository
- @neokeee/gitrepository
- accessrepo (Actual)
Usage
The usage of the lib is very easy because i created only for read private content and more in any time that i can spend in this lib.
import { Repository, Loader } from 'accessrepo'
let GITHUB_ACCESS_TOKEN = "xxxx-xxxx-xxxx-xxxx";
let GITHUB_USERNAME = "neopkr";
let GITHUB_REPOSITORY = "AccessRepo";
const repository = new Repository(GITHUB_ACCESS_TOKEN, GITHUB_USERNAME, GITHUB_REPOSITORY);
const rl = Loader(GITHUB_ACCESS_TOKEN, GITHUB_USERNAME, GITHUB_REPOSITORY)
const myfunc = async () => {
await repository.init()
const lic = await repository.getLicense();
console.log(lic);
};
// Loader example (1)
const licenseContent = async () => {
const license = await rl.ReadFile("LICENSE")
console.log(license.content)
}
myfunc()
licenseContent()
// Loader example (2)
rl.ReadFile(/path/to/content/)
.then((content) => {
if (content === null) { return; /* Handle null... */ }
console.log(content)
/* content output:
{
"name": ...,
"path": ...,
"download_url": ...,
"html_url": ...,
"content": ...,
"links": { ... },
}
*/
})
There is not other function in the classes because i build it only for read content in private repository so probably later add more functions. See more on GitHub
Errors
- If you are getting error HTTP Status 403 check the token that are you using or check token permissions.
- If you get another errors: Create a new issue or check if exist
Versions
- 1.0.1 Unstable | Changelog
- 1.0.2 Unstable | Changelog
- 1.0.3 Stable | Changelog
- 1.0.5 Stable | Changelog
- 1.0.6 Stable | Changelog
- 1.0.7 Stable | Changelog
- 1.0.8 Stable | Changelog
- 1.0.9 Stable | Changelog
Changelog
1.0.1
First Update, added two new classes:
- Repository
- Loader Repository: has the entire repository settings and data from the users/repo Loader: Actually only have 1 function: ReadFile(/path/to/file); return the content of the file that you select, file that is on your Github no on your local xd
- See RepositoryLoader.d.ts for more info with properties
1.0.2
- Added yaml for npm publish with github, added some test.
- Change name to 'accessrepo'
- Bug:
Module 'accessrepo' not found
for typescript.
- See RepositoryLoader.d.ts for more info with properties
1.0.3
- Fixed npm-publish.yml for login with token and clear cache with --force
- Fixed bug with import in typescript
Fixed types/index.d.ts to dist/index.d.ts
- Bug:
Repository returns undefined
, change event.on to then-catch.
- See RepositoryLoader.d.ts for more info with properties
1.0.5
- Version 1.0.4 don't exist by problems with npm, check workflow action error
- Fixed some imports on javascript.
- class Repository:
RepoURL
change name to:getURL
and now returns:{ url: ... }
License
change name to:getLicense
Owner
change name to:getOwner
- Fixed:
class Repository returns undefined
should be fixed now at least inside of a async functions. _Check repository.spec.ts for more information.
- See RepositoryLoader.d.ts for more info with properties
1.0.6
- Added new functions to Repository:
getID()
- Array (should be Number)getName()
- ArraygetDescription()
- ArraygetLanguage()
- ArraygetVisibility()
- ArraygetSuscribers()
- NumbergetForks()
- NumbergetWatchers()
- NumbergetTopics()
- ArrayisPrivate()
- Boolean
- See RepositoryLoader.d.ts for more info with properties
- Fixed some functions summarys and added new ones
- For get file content use Loader.ReadFile() => Array.
1.0.7
- Added
getWorflow(workflow: string)
to Loader class. This returns the last run of the workflow action: sucess, failed, pending or not found. - Example:
const func = async () => {
const workflowStatus = await Loader.getWorkflow("npm-publish.yml")
if (workflowStatus === "not_found") {
console.log("Error: Workflow not found.");
return;
}
console.log(workflowStatus) // success, failed, pending
if (workflowStatus === "success") {
return "Build passing";
}
}
Loader.getWorkflow("npm-publish.yml").then((action) => console.log(action)) // success, failed, pending, not_found
- Rename function
ReadFile()
toreadFile()
for keep consistency. - New function on Loader class:
getLastWorkflow()
, get last workflow action used on repository.
1.0.8
- New Release, new functions.
- New functions on Repository class:
getPublishVersions(), getPreReleaseVersions(), getAllVersions()
, all returns an array with the list of public versions on github. - Maybe on next version v1.1.0 Loader class would be deleted and added all functions to Repository class.
- Error menssages translated it to english.
- If you having HTTP Status o errors see: Errors section.
- See RepositoryLoader.d.ts for more info with properties
1.0.9
- Bug fix: Build was not passing due to the
readFileFromTree()
function always returning null:- Fixed: The
const file
for the pathFile included a leading "/", resulting in a null return. Added a slice to prevent this, but it's advisable to avoid adding "/" at the beginning. - Fixed: The function couldn't read folders. This was resolved by creating a new private function to recursively read files and folders.
- If you encounter any other issues with this function, please create an issue so that we can promptly address it.
- Also, added the JSDoc
@experimental
tag.
- Fixed: The
- This update is quite lightweight, featuring a critical function in the Loader class.
- New function:
readFileFromTree(tree: string, filePath: string)
reads a file from selected tags or branches. Here's an example of its usage:
Loader.readFileFromTree("1.0.8", 'src/RepositoryLoader.ts').then((content) => {
if (content === null) { return; }
console.log(content);
/* content output:
{
"name": ...,
"path": ...,
"content": ...,
"url": ...
}
*/
})
- Changed workflow, deleted npm adduser.
- See RepositoryLoader.d.ts for more info with properties