Giter Club home page Giter Club logo

fishy's Introduction

fishy

Create, manage and deploy p2panda schemas


Command-line-tool to easily create update and share your p2panda schemas.

fishy parses your current version of your schemas and matches it with previous ones to calculate the difference and apply changes automatically.

Your schema changes are committed to a schema.lock file which you can share with other developers. With fishy they will be able to deploy the same schema on their nodes.

Usage

Create, manage and deploy p2panda schemas

Usage: fishy <COMMAND>

Commands:
  init    Initialises all files for a new fishy project in a given folder
  build   Automatically creates and signs p2panda data from a key pair and the defined schemas
  deploy  Deploy created schemas on a node
  help    Print this message or the help of the given subcommand(s)

Options:
  -h, --help     Print help
  -V, --version  Print version

Examples

# Initialise a new schema, this creates a `schema.toml` file you can edit
fishy init

# Same as above, but in a different folder and with the name already defined
fishy init -n icecream ~/dev/schemas

# Commit any changes to the schema, this updates your `schema.lock` file
fishy build

# Only inspect the current status of your schemas, do not commit anything
fishy build --inspect

# Deploy commits to external node
fishy deploy --endpoint http://localhost:2020/graphql

Install

Pre-compiled binaries

Check out our Releases section.

Compile it yourself

For the following steps you need a Rust development environment on your machine.

# Download source code
git clone https://github.com/p2panda/fishy.git
cd fishy

# Compile binary
cargo build --release

# Copy binary into your path (for example)
cp ./target/release/fishy ~/.local/bin

Tutorial

  1. Initialise a new schema by running fishy init. A dialogue will ask you for the name of your first schema. Enter a name, for example cafe and press enter. You will now find a schema.toml and secret.txt file in your folder.
  2. Edit schema.toml with any text editor. Follow the format to specify multiple schemas, their fields, types and relations to each other. For example:
    [cafe]
    description = "A list of cafes"
    
    [cafe.fields]
    name = { type = "str" }
    address = { type = "str" }
    opening_year = { type = "int" }
    
    [icecream]
    description = "Icecream sorts you can get in cafes"
    
    [icecream.fields]
    name = { type = "str" }
    sweetness = { type = "str" }
    cafes = { type = "relation_list", schema = { name = "cafe" } }
  3. You can commit these changes now to schema.lock by running fishy build. The tool will automatically show you the changes which will be committed and ask for your confirmation. Hit y to confirm. This step will generate, encode and sign the commits with your private key stored in secret.txt.
  4. This version of the schema lives now in schema.lock. You can go back to the schema.toml file and do any changes to the schema, run fishy build again to apply them. The tool will again only show you exactly what you've changed and generate the commits for only exactly these changes. Try it out!
  5. Finally deploy the schema on one or many nodes by running fishy deploy. Make sure you have a node running somewhere.
  6. Share the schema.lock file with others, with it they will be able to deploy the schemas on their nodes!

License

GNU Affero General Public License v3.0 AGPL-3.0-or-later

Supported by



This project has received funding from the European Union’s Horizon 2020 research and innovation programme within the framework of the NGI-POINTER Project funded under grant agreement No 871528

fishy's People

Contributors

adzialocha avatar sandreae avatar

Stargazers

Stanislav Tkach avatar  avatar peg avatar glyph avatar  avatar Andrew Chou avatar  avatar

Watchers

Vincent Ahrend avatar  avatar

Forkers

jmanm

fishy's Issues

Fishy doesnt deploy generated schema

Can't publish freshly generated schema.lock using last version of fishy. Got this error:

Error: Could not publish schemas to node

Caused by:
    GraphQL request to node failed: 
    GQLClient Error: Look at json field for more details
    Message: data did not match any variant of untagged enum PlainValue

rollback to tag=v0.1.0 fixed the problem. Maybe some breaking changes happened and there is inconsistency with aquadogo 0.5.0?

Use fishy as a crate to read `schema.lock` and deploy / migrate it automatically

Hello!

I am trying to write a decentralized book library app to get familiar with p2panda. Thanks for this great protocol, I think you do amazing job.

It would be nice to have something like fishy as a create to be able to read schemas from lock file and to deploy them to node by GraphQL client or just endpoint.

For example, it would be convenient to provide predefined schema.lock within application bundle, to initialize local offline app's node with these schemas.

Something like:

use fishy;

fn initializeApplicationNode {
    // create and start node...
    // prepare GraphQL client if needed...
   
    // Create LockFile
    // from path
    let path = Path::from("schema.lock");
    let lock_file = LockFile::from(path).unwrap();
    // from String
    let file_content = String::from("...readed content...");
    let lock_file = LockFile::from(file_content).unwrap();

    // import schema
    let schema: Vec<Schema> = lock_file.to_schema().ok();

    // Deploy
    fishy::deploy_lock_file(lock_file, client).ok();
    fishy::deploy_schema(schema, client).ok();
}

or may be something different but doing same job.

Deploy "seed" data

Similar to other database tools it would be nice to not only automatically migrate to the latest database schema but also deploy "seed" data (populate database with initial documents).

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.