Automate build process

master
haad 2016-09-13 18:04:28 +02:00
parent 3cab269c1a
commit 946f42014e
7 changed files with 100 additions and 14 deletions

View File

@ -73,6 +73,15 @@ module.exports = function (grunt) {
dest: moduleCacheDirectory
}
]
},
ipfsbin: {
files: [
{
expand: true,
src: './node_modules/go-ipfs-dep/go-ipfs/ipfs',
dest: path.join(moduleCacheDirectory, 'node_modules/go-ipfs-dep/go-ipfs/ipfs')
}
]
}
},
@ -106,8 +115,10 @@ module.exports = function (grunt) {
grunt.task.run('clean:bin')
grunt.task.run('copy_files')
if(!skipNpmInstall)
if(!skipNpmInstall) {
grunt.task.run('npm_install')
grunt.task.run('copy:ipfsbin')
}
grunt.task.run('chmod:bins')
grunt.task.run('electron:osxBuild')
@ -118,8 +129,10 @@ module.exports = function (grunt) {
grunt.task.run('clean:bin')
grunt.task.run('copy_files')
if(!skipNpmInstall)
if(!skipNpmInstall) {
grunt.task.run('npm_install')
grunt.task.run('copy:ipfsbin')
}
grunt.task.run('chmod:bins')
grunt.task.run('electron:linuxBuild')

View File

@ -6,6 +6,11 @@
You need to have go-ipfs binary built from the IPFS pubsub branch https://github.com/ipfs/go-ipfs/tree/feat/floodsub. You need to have the daemon running before starting Orbit (at port 5001).
You can build it manually or run the following *after* all `npm install` commands (before starting Orbit):
```
npm run build:goipfs
```
## Run
Currently only the Electron app works.
@ -47,7 +52,7 @@ npm run build
npm run electron
```
### Build
### Build a Stand-Alone App
*Run this is in project's root directory, not in `client/`.*
@ -58,6 +63,19 @@ npm run build
The application executable is in `bin/`.
### Publish
*Run this is in project's root directory, not in `client/`.*
First, clone the repo then run the following commands. This will build the project from "*scratch*" and add the build to IPFS. Note that you need to have an IPFS daemon running to be able to publish.
```sh
npm install
npm run build:goipfs
npm run build
npm run publish
```
### Development
#### Run Tests

View File

@ -58,7 +58,12 @@ module.exports = {
// new webpack.optimize.UglifyJsPlugin({
// exclude: /ipfsdist.js/
// }),
new webpack.NoErrorsPlugin()
new webpack.NoErrorsPlugin(),
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': '"production"'
}
})
],
resolveLoader: {
root: path.join(__dirname, 'node_modules')

View File

@ -84,18 +84,19 @@ app.on('ready', () => {
global.DEV = MODE === 'dev'
global.isElectron = true
// let ipfsDaemon
// ipfsd.local((err, node) => {
// if(err) reject(err)
// ipfsDaemon = node
// ipfsDaemon.startDaemon((err, ipfs) => {
global.ipfsInstance = IpfsApi()
let ipfsDaemon
ipfsd.local((err, node) => {
if(err) reject(err)
ipfsDaemon = node
ipfsDaemon.startDaemon((err, ipfs) => {
global.ipfsInstance = ipfs
// global.ipfsInstance = IpfsApi()
if(MODE === 'dev')
mainWindow.loadURL('http://localhost:8000/')
else
mainWindow.loadURL('file://' + __dirname + '/client/dist/index.html')
// })
// })
})
})
mainWindow.on('closed', () => {
mainWindow = null

View File

@ -30,12 +30,15 @@
"orbit-server": "^0.2.3"
},
"scripts": {
"postinstall": "build:goipfs && ./node_modules/.bin/grunt clean:npm",
"build:goipfs": "./scripts/build_ipfs_bin.sh",
"test": "./node_modules/.bin/mocha",
"build": "./node_modules/.bin/grunt build",
"dist": "./scripts/build_dist_package.sh",
"publish": "npm run dist && ipfs add bin/orbit-darwin-x64.tar.gz",
"dev:electron": "ENV=dev API_ORIGIN=* IPFS_EXEC=/$GOPATH/bin/ipfs ./node_modules/.bin/electron .",
"electron": "./node_modules/.bin/electron .",
"start": "cd client/dist && ../../node_modules/.bin/http-server -c-1 -p 8081 & open http://localhost:8081/index.html & wait",
"postinstall": "./node_modules/.bin/grunt clean:npm"
"start": "cd client/dist && ../../node_modules/.bin/http-server -c-1 -p 8081 & open http://localhost:8081/index.html & wait"
},
"repository": {
"type": "git",

4
scripts/build_dist_package.sh Executable file
View File

@ -0,0 +1,4 @@
#!/bin/sh
cd bin/
tar -zcvf orbit-darwin-x64.tar.gz Orbit-darwin-x64/
cd ..

42
scripts/build_ipfs_bin.sh Executable file
View File

@ -0,0 +1,42 @@
#!/bin/sh
set -e # exit on error
die() {
set +v
echo >&2 "$@"
exit 1
}
require() {
set +v
which "$1" >/dev/null || die "$1 not in \$PATH. please install $1"
set -v
}
set -v # print commands
require mv
require cd
require mkdir
require pwd
require make
require git
require go
require npm
require node
npm --version | egrep "^3." >/dev/null || die "requires npm version 3"
go version | grep "go1.7" >/dev/null || die "requires npm version 3"
# install go-ipfs pubsub branch
GOPATH="/tmp/gopath"
ORBIT_PATH=$(pwd)
rm -rf $GOPATH
mkdir -p /tmp/gopath/src/github.com/ipfs
cd /tmp/gopath/src/github.com/ipfs
git clone --branch feat/floodsub https://github.com/ipfs/go-ipfs go-ipfs || die "failed to clone go-ipfs"
cd go-ipfs
make build >/dev/null || die "failed to build go-ipfs"
# install go-ipfs into node_modules/.bin/ipfs, which should be in our path.
mv cmd/ipfs/ipfs "$ORBIT_PATH/node_modules/go-ipfs-dep/go-ipfs/ipfs"
echo 'Haz acquired go-ipfs with pubsub!'
cd "$ORBIT_PATH"