Coder Social home page Coder Social logo

dfinity / motoko-dev-server Goto Github PK

View Code? Open in Web Editor NEW
20.0 6.0 1.0 2.13 MB

A live reload development server for Motoko smart contracts.

License: Apache License 2.0

Shell 0.10% JavaScript 0.31% TypeScript 88.99% Rust 9.60% Motoko 0.78% Modelica 0.22%
create-react-app hot-module-reloading internet-computer live-reload motoko nextjs productivity smart-contract tools vite

motoko-dev-server's Introduction

mo-dev  npm version GitHub license PRs Welcome

A live reload development server for Motoko smart contracts.


mo-dev is a flexible command-line tool for speeding up your Motoko development workflow.

Try Online

Get started with a full-stack Vite + React + Motoko project directly in your browser:

Open in Gitpod

Quick Start

Run the following command (requires Node.js ≥ 16):

npm i -g mo-dev

Note: standalone mo-dev binaries are also available as GitHub releases.

Once installed, view the available command-line options by passing the --help flag:

mo-dev --help

Check out the Vite + React + Motoko starter project for an example of how to integrate mo-dev into a modern full-stack webapp.

Basic Features

Regenerate type declarations on Motoko file change (--generate or -g):

mo-dev --generate

Deploy canisters on Motoko file change (--deploy or -d):

mo-dev --deploy

Automatically respond "yes" to reinstall prompts (--yes or -y; may clear canister state):

mo-dev --deploy -y

Run unit tests (*.test.mo) on Motoko file change (--test or -t):

mo-dev --test

Run an arbitrary command on Motoko file change (--exec or -x):

mo-dev --exec 'npm run my-reload-script'

Specify the working directory (--cwd or -C; should contain a dfx.json file):

mo-dev --cwd path/to/dfx_project

Only run the dev server for specific canisters (--canister or -c):

mo-dev --canister foo --canister bar --deploy

Pass an installation argument to dfx deploy (--argument or -a):

mo-dev --deploy --argument '()'

Advanced Features

Show additional debug output in the console (--verbose or -v):

mo-dev -v # more verbose
mo-dev -vv # extra verbose

Programmatically start mo-dev using JavaScript:

import devServer from 'mo-dev';

// Default settings
devServer();

// Custom settings
devServer({
    directory: '.',
    port: 7700,
    verbosity: 0,
    // ...
});

mo-test

The mo-dev npm package includes a mo-test command which can be used to run unit tests in CI workflows.

View all available options:

mo-test --help

Run all Motoko unit tests (*.test.mo):

mo-test

Run all Motoko unit tests using a WASI runtime by default (faster but requires installing Wasmtime on your system):

mo-test --testmode wasi

Configure the runtime of an individual unit test by including the following comment in a *.test.mo file:

// @testmode wasi

Run specific unit tests by passing a file name prefix (-f or --testfile):

mo-test -f Foo -f Bar # (only run tests for files starting with `Foo` or `Bar`)

These options may also be passed directly into the mo-dev command (e.g. mo-dev --testmode wasi -f SomeTest).


mo-dev is early in development. Please feel free to report a bug, ask a question, or request a feature on the project's GitHub issues page.

Contributions are welcome! Please check out the contributor guidelines for more information.

motoko-dev-server's People

Contributors

dependabot[bot] avatar rvanasa avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

motoko-dev-server's Issues

Possible to specify which canisters to run a given command?

Hello, thanks for the very useful project.

Is it possible to pass commands to mo-dev so that only specific canisters are included?

For instance, mo-dev generate will also generate the declarations for the internet_identity canister that's declared in the dfx.json but whose declarations are not needed (similarly they will be generated for a frontend canister).

port 4943 HARDCODED?!?!

how to make it work with a port other than 4943 specified in ~/.config/dfx/networks.json?

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.