Merge pull request from LLK/publish

Publish to NPM and Github Pages
This commit is contained in:
Ray Schamp 2016-09-27 10:28:59 -04:00 committed by GitHub
commit 46a2fe76eb
13 changed files with 150 additions and 17268 deletions

6
.gitignore vendored
View file

@ -9,3 +9,9 @@ npm-*
/.nyc_output
/coverage
/dist.js
/vm.js
/vm.min.js
/playground/media
/playground/vendor.js
/playground/vm.js
/playground/zenburn.css

2
.npmignore Normal file
View file

@ -0,0 +1,2 @@
/.nyc_output
/coverage

View file

@ -6,3 +6,27 @@ sudo: false
cache:
directories:
- node_modules
after_script:
- |
# RELEASE_BRANCHES and NPM_TOKEN defined in Travis settings panel
declare exitCode
$(npm bin)/travis-after-all
exitCode=$?
if [[
# Execute after all jobs finish successfully
$exitCode = 0 &&
# Only release on release branches
$RELEASE_BRANCHES =~ $TRAVIS_BRANCH &&
# Don't release on PR builds
$TRAVIS_PULL_REQUEST = "false"
]]; then
# Authenticate NPM
echo "//registry.npmjs.org/:_authToken=\${NPM_TOKEN}" > .npmrc
# Set version to timestamp
npm --no-git-tag-version version $($(npm bin)/json -f package.json version)-prerelease.$(date +%s)
npm publish
# Publish to gh-pages as most recent committer
git config --global user.email $(git log --pretty=format:"%ce" -n1)
git config --global user.name $(git log --pretty=format:"%cn" -n1)
./node_modules/.bin/gh-pages -x -r https://${GH_TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git -d playground -m "Build for $(git log --pretty=format:%H)"
fi

View file

@ -13,7 +13,7 @@ watch:
$(WEBPACK) --watch
serve:
$(WEBPACK_DEV_SERVER) --host 0.0.0.0 --content-base ./
$(WEBPACK_DEV_SERVER)
# ------------------------------------------------------------------------------

View file

@ -35,7 +35,7 @@ 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.
To run the Playground, make sure the dev server's running and go to [http://localhost:8080/](http://localhost:8080/) - you will be directed to the playground, which demonstrates various tools and internal state.
![VM Playground Screenshot](https://i.imgur.com/nOCNqEc.gif)

View file

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

View file

@ -1,7 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="refresh" content="0; URL='/playground'" />
<title>Redirect to playground</title>
</head>
</html>

View file

@ -11,24 +11,29 @@
},
"main": "./dist.js",
"scripts": {
"postinstall": "./node_modules/.bin/webpack",
"start": "webpack-dev-server --host 0.0.0.0 --content-base .",
"test": "make test"
},
"dependencies": {
"expose-loader": "0.7.1",
"htmlparser2": "3.9.0",
"json-loader": "0.5.4",
"promise": "7.1.1",
"webpack": "1.13.0"
"prepublish": "./node_modules/.bin/webpack --bail",
"start": "make serve",
"test": "make test",
"version": "./node_modules/.bin/json -f package.json -I -e \"this.repository.sha = '$(git log -n1 --pretty=format:%H)'\""
},
"devDependencies": {
"copy-webpack-plugin": "3.0.1",
"eslint": "2.7.0",
"expose-loader": "0.7.1",
"gh-pages": "0.11.0",
"highlightjs": "8.7.0",
"scratch-blocks": "git+https://git@github.com/LLK/scratch-blocks.git#develop",
"scratch-render": "git+https://git@github.com/LLK/scratch-render.git#develop",
"htmlparser2": "3.9.0",
"json": "9.0.4",
"json-loader": "0.5.4",
"lodash.defaultsdeep": "4.6.0",
"promise": "7.1.1",
"scratch-blocks": "^0.1.0-prepublish",
"scratch-render": "^0.1.0-prepublish",
"script-loader": "0.7.0",
"stats.js": "0.16.0",
"tap": "5.7.1",
"travis-after-all": "1.4.4",
"webpack": "1.13.0",
"webpack-dev-server": "1.14.1"
}
}

View file

@ -5,7 +5,7 @@
<meta charset="utf-8">
<title>Scratch VM Playground</title>
<link rel="stylesheet" href="playground.css">
<link rel="stylesheet" href="../node_modules/highlightjs/styles/zenburn.css">
<link rel="stylesheet" href="zenburn.css">
</head>
<body>
<div id="vm-devtools">
@ -763,20 +763,10 @@
</category>
<category name="More Blocks" colour="#FF6680" custom="PROCEDURE"></category>
</xml>
<!-- FPS counter -->
<script src="../node_modules/stats.js/build/stats.min.js"></script>
<!-- Syntax highlighter -->
<script src="../node_modules/highlightjs/highlight.pack.min.js"></script>
<!-- Scratch Blocks -->
<!-- For easier development between the two, use `npm link` -->
<script src="../node_modules/scratch-blocks/blockly_compressed_vertical.js"></script>
<script src="../node_modules/scratch-blocks/blocks_compressed.js"></script>
<script src="../node_modules/scratch-blocks/blocks_compressed_vertical.js"></script>
<script src="../node_modules/scratch-blocks/msg/messages.js"></script>
<!-- Renderer -->
<script src="../node_modules/scratch-render/render.js"></script>
<!-- FPS counter, Syntax highlighter, Blocks, Renderer -->
<script src="./vendor.js"></script>
<!-- VM Worker -->
<script src="../vm.js"></script>
<script src="./vm.js"></script>
<!-- Playground -->
<script src="./playground.js"></script>
<script>

View file

@ -47,7 +47,7 @@ window.onload = function() {
var toolbox = document.getElementById('toolbox');
var workspace = window.Blockly.inject('blocks', {
toolbox: toolbox,
media: '../node_modules/scratch-blocks/media/',
media: './media/',
zoom: {
controls: true,
wheel: true,

17196
vm.js

File diff suppressed because it is too large Load diff

11
vm.min.js vendored

File diff suppressed because one or more lines are too long

View file

@ -1,14 +1,18 @@
var CopyWebpackPlugin = require('copy-webpack-plugin');
var defaultsDeep = require('lodash.defaultsdeep');
var path = require('path');
var webpack = require('webpack');
var base = {
devServer: {
contentBase: path.resolve(__dirname, 'playground'),
host: '0.0.0.0'
},
module: {
loaders: [
{
test: /\.json$/,
loader: 'json-loader'
}, {
test: require.resolve('./src/index.js'),
loader: 'expose?VirtualMachine'
}
]
},
@ -23,23 +27,88 @@ var base = {
]
};
module.exports = [Object.assign({}, base, {
entry: {
'vm': './src/index.js',
'vm.min': './src/index.js'
},
output: {
path: __dirname,
filename: '[name].js'
}
}), Object.assign({}, base, {
entry: {
'dist': './src/index.js'
},
output: {
library: 'VirtualMachine',
libraryTarget: 'commonjs2',
path: __dirname,
filename: '[name].js'
}
})];
module.exports = [
// Web-compatible, playground
defaultsDeep({}, base, {
entry: {
'vm': './src/index.js',
'vm.min': './src/index.js'
},
output: {
path: __dirname,
filename: '[name].js'
},
module: {
loaders: base.module.loaders.concat([
{
test: require.resolve('./src/index.js'),
loader: 'expose?VirtualMachine'
}
])
}
}),
// Webpack-compatible
defaultsDeep({}, base, {
entry: {
'dist': './src/index.js'
},
output: {
library: 'VirtualMachine',
libraryTarget: 'commonjs2',
path: __dirname,
filename: '[name].js'
}
}),
// Playground
defaultsDeep({}, base, {
entry: {
'vm': './src/index.js',
'vendor': [
// FPS counter
'stats.js/build/stats.min.js',
// Syntax highlighter
'highlightjs/highlight.pack.min.js',
// Scratch Blocks
'scratch-blocks/dist/vertical.js',
// Renderer
'scratch-render'
]
},
output: {
path: path.resolve(__dirname, 'playground'),
filename: '[name].js'
},
module: {
loaders: base.module.loaders.concat([
{
test: require.resolve('./src/index.js'),
loader: 'expose?VirtualMachine'
},
{
test: require.resolve('stats.js/build/stats.min.js'),
loader: 'script'
},
{
test: require.resolve('highlightjs/highlight.pack.min.js'),
loader: 'script'
},
{
test: require.resolve('scratch-blocks/dist/vertical.js'),
loader: 'expose?Blockly'
},
{
test: require.resolve('scratch-render'),
loader: 'expose?RenderWebGL'
}
])
},
plugins: base.plugins.concat([
new CopyWebpackPlugin([{
from: 'node_modules/scratch-blocks/media',
to: 'media'
}, {
from: 'node_modules/highlightjs/styles/zenburn.css'
}])
])
})
];