Coder Social home page Coder Social logo

korefile's Introduction

korefile Actions Status: test

korefile: コレ・ファイル

File System API for Local/GitHub.

Features

  • Write/Read/Delete API for Local/GitHub
  • Pluggable adaptor

Install

Install with npm:

npm install korefile

Usage

Korefile apply KoreFileAdaptor implementation.

FsAdaptor

Read/Write/Delete for local file system. It wraps fs module.

import {createKoreFile, createFsAdaptor} from "korefile";
const koreFile = createKoreFile({ 
    adaptor: createFsAdaptor()
});
(async () => { 
    // write
    await koreFile.writeFile("/path/to/file", "content");
    // read
    const content = await koreFile.readFile("/path/to/file");
    // delete
    await koreFile.deleteFile("/path/to/file");
})()

GitHubAdaptor

Read/Write/Delete for GitHub repository. It wrap octokit/rest.js.

Require GitHub Auth Token.

import {createKoreFile, createGitHubAdaptor} from "korefile";
const koreFile = createKoreFile({
    adaptor: createGitHubAdaptor({
        owner: "azu",
        repo: "korefile",
        ref: "heads/test",
        token: process.env.GH_TOKEN
    })
});
(async () => { 
    // file path should be relative
    const testFilePath = "file.test";
    // write
    await koreFile.writeFile(testFilePath, input);
    // read
    const content = await koreFile.readFile(testFilePath);
    // delete
    await koreFile.deleteFile(testFilePath);
})();

UseCase

Changelog

See Releases page.

Running tests

Install devDependencies and Run npm test:

npm test

Contributing

Pull requests and stars are always welcome.

For bugs and feature requests, please create an issue.

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

Author

License

MIT © azu

korefile's People

Contributors

azu avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

korefile's Issues

Support running in the browser (without NodeJS api)

Hi! Thanks for your library!

I use it in my small project and it works very well. However I had to adjust it for my use case. Here it is.

My application is an Angular app and it runs entirely in the browser. I was unable to use KoreFile initially as it makes use of some NodeJS API such as process and Buffer. It does not seem like a strict requirement though. I forked the lib and removed/replaced those apis.

It would be quite nice if you can support it on the library level via the public API, or maybe consider doing a platform-independent version that would work well both in NodeJS app and a browser (webpack bundle).

Thanks for your time.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.