Better README! (#114)

Improve README
Implement "npm start"
This commit is contained in:
TheBrokenRail 2016-08-31 16:31:01 -04:00 committed by Chris Willis-Ford
parent 29a595345a
commit 220d614a9d
3 changed files with 34 additions and 18 deletions

View file

@ -6,6 +6,8 @@
[![devDependency Status](https://david-dm.org/LLK/scratch-vm/dev-status.svg)](https://david-dm.org/LLK/scratch-vm#info=devDependencies)
## Installation
This requires you to have Git and Node.js installed.
In your own node environment/application:
```bash
npm install https://github.com/LLK/scratch-vm.git
@ -17,27 +19,23 @@ cd scratch-vm
npm install
```
## Setup
For an extended setup example, check out the /playground directory, which includes a fully running VM instance.
```js
var VirtualMachine = require('scratch-vm');
var vm = new VirtualMachine();
## Development Server
This requires Node.js to be installed.
// Block events
workspace.addChangeListener(vm.blockListener);
var flyoutWorkspace = workspace.toolbox_.flyout_.workspace_;
flyoutWorkspace.addChangeListener(vm.flyoutBlockListener);
// Run threads
vm.runtime.start();
```
## Development Server and Playground
For convenience, we've included a development server with the VM. This is useful because the VM can take advantage of executing in a WebWorker, which is not permitted in a local file. To start the server, run:
For convenience, we've included a development server with the VM. This is useful because the VM can take advantage of executing in a WebWorker, which is not permitted in a local file.
## Running the Development Server
Open a Command Prompt or Terminal in the repository and run:
```bash
make serve
npm start
```
and go to [http://localhost:8080/](http://localhost:8080/) - you will be redirected to the playground, which demonstrates various tools and internal state.
Or on Windows:
```bash
StartServerWindows.bat
```
## Playground
To run the Playground, make sure the dev server's running and go to [http://localhost:8080/](http://localhost:8080/) - you will be redirected to the playground, which demonstrates various tools and internal state.
![VM Playground Screenshot](https://i.imgur.com/nOCNqEc.gif)
@ -55,6 +53,21 @@ make build
</script>
```
## How to include in a Node.js App
For an extended setup example, check out the /playground directory, which includes a fully running VM instance.
```js
var VirtualMachine = require('scratch-vm');
var vm = new VirtualMachine();
// Block events
workspace.addChangeListener(vm.blockListener);
var flyoutWorkspace = workspace.toolbox_.flyout_.workspace_;
flyoutWorkspace.addChangeListener(vm.flyoutBlockListener);
// Run threads
vm.runtime.start();
```
## Abstract Syntax Tree
#### Overview

2
StartServerWindows.bat Normal file
View file

@ -0,0 +1,2 @@
@echo off
node_modules\.bin\webpack-dev-server --host 0.0.0.0 --port 80 --content-base .\

View file

@ -11,7 +11,8 @@
},
"main": "./src/index.js",
"scripts": {
"test": "make test"
"test": "make test",
"start": "webpack-dev-server --host 0.0.0.0 --content-base ."
},
"dependencies": {
"htmlparser2": "3.9.0",