From 220d614a9d6dfce72efc788ab548be59f58c009d Mon Sep 17 00:00:00 2001 From: TheBrokenRail Date: Wed, 31 Aug 2016 16:31:01 -0400 Subject: [PATCH] Better README! (#114) Improve README Implement "npm start" --- README.md | 47 +++++++++++++++++++++++++++--------------- StartServerWindows.bat | 2 ++ package.json | 3 ++- 3 files changed, 34 insertions(+), 18 deletions(-) create mode 100644 StartServerWindows.bat diff --git a/README.md b/README.md index 1709bf467..1c9afbb93 100644 --- a/README.md +++ b/README.md @@ -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 ``` +## 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 diff --git a/StartServerWindows.bat b/StartServerWindows.bat new file mode 100644 index 000000000..2ea1bccdb --- /dev/null +++ b/StartServerWindows.bat @@ -0,0 +1,2 @@ +@echo off +node_modules\.bin\webpack-dev-server --host 0.0.0.0 --port 80 --content-base .\ diff --git a/package.json b/package.json index 095dc2a9b..f6e1ba3d8 100644 --- a/package.json +++ b/package.json @@ -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",