artifact-app 0.8.2

Artifact is a design doc tool made for developers. It allows anyone to easily write and link their design docs both to each other and to source code, making it easy to track how complete their project is. Documents are revision controllable, can be rendered as a static web page and have a full suite of command line tools for searching, formatting and displaying them.
Documentation
# This is for creating a local developer environment to run non-rust commands.
# 
# # Prerequisites
# This assumes you have the following installed:
# - python2.7
# - virtuanenv (with any python version) 
#
# Python recommended command: `sudo pip install virtualenv`
#
# # Usage
# To use simply execute the following. All your paths will be setup for you:
# ```
# source env
# ```
export RUSTFMT_VERSION="0.1.3"
export RUSTCLIPPY_VERSION="0.0.140"
if [ -z $RUST_VERSION ]; then
    export RUST_VERSION="nightly-2017-06-17"
fi

export NPM_PACKAGES="\
elm@0.18.0 \
webpack@2.6.1 \
elm-format@0.6.1-alpha \
phantomjs@2.1.7 \
"

export PYTHON_CHECK="\
web-ui/sel_tests \
web-ui/py_helpers \
scripts/interact.py \
"

export NODE_VERSION="v8.1.2"

if [ -z $TRAVIS_BUILD_DIR ]; then
    # if non-travis, create in target directory and override PATH
    export ENV_DIR=$PWD/target/env
    export PATH="/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/sbin"
else
    # if on travis, create in ~/build_environment and leave PATH alone
    export ENV_DIR=$HOME/build_environment
fi

if [[ `uname` == "Darwin" ]]; then
    NODE_URL="https://nodejs.org/dist/${NODE_VERSION}/node-${NODE_VERSION}-darwin-x64.tar.gz"
else
    NODE_URL="https://nodejs.org/dist/${NODE_VERSION}/node-${NODE_VERSION}-linux-x64.tar.xz"
fi

errcho() {
  >&2 echo "\e[1m\e[32m${1}\e[0m"
}

if [ ! -d ".git" ] || [ ! -d "web-ui" ]; then
    errcho "Must be run in repository root."
    exit 1
fi

pathinsert() {
    export PATH="$1:$PATH"
}

mkdir -p $ENV_DIR

################################################################################
# setup rust
errcho "-- setting up rust --"
RUST_DIR=$ENV_DIR/rust
export CARGO_HOME=$RUST_DIR/cargo
export RUSTUP_HOME=$RUST_DIR/multirust
export RUST_BIN=$CARGO_HOME/bin
mkdir -p $CARGO_HOME

if [ ! -d $RUSTUP_HOME ]; then
    errcho "- installing rustup"
    curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain $RUST_VERSION || return $?
fi
pathinsert $RUST_BIN

# always make sure the default is up-to-date
rustup default $RUST_VERSION || return $?
export CARGO_INCREMENTAL=1

################################################################################
# setup python virtualenv and packages
errcho "-- setting up python --"
PY_DIR=$ENV_DIR/art
PY_ACTIVATE=$PY_DIR/bin/activate
export PYTHONPATH="web-ui"
if [ ! -d $PY_DIR ]; then
    virtualenv $PY_DIR -p python2.7 || return $?
    source $PY_ACTIVATE || return $?
else
    source $PY_ACTIVATE || return $?
fi


################################################################################
# set up node path and packages
errcho "-- setting up node.js and elm --"

export NODE_DIR=$ENV_DIR/node
NODE_BIN=$NODE_DIR/bin

if [ -x $NODE_BIN/node ]; then
    current_node_version=$($NODE_BIN/node --version) || return $?
fi
if [ ! -x $NODE_BIN/node ] || [ "$current_node_version" != "$NODE_VERSION" ]; then
    errcho "- installing node.js + npm"
    rm -rf $NODE_DIR && mkdir $NODE_DIR || return $?
    curl -LSfs $NODE_URL | \
        tar xJ --directory $NODE_DIR --strip-components=1 --
fi
pathinsert $NODE_DIR/node_modules/.bin
pathinsert $NODE_BIN

################################################################################
# Do final updates
errcho "-- do final update of dependencies --"
if [ ! -e $RUST_BIN/just ]; then
    errcho "- installing build tools"
    # install required packages. They can be updated with `just update`
    cargo install cargo-update || return $?
    cargo install just || return $?
    just update || return $?
fi

pathinsert $NODE_DIR/node_modules/.bin

if [ ! -e $RUST_BIN/art ]; then
    errcho "- building release+debug artifact as art+artd"
    # build artifact in release mode and debug mode and link both
    cargo build --release --features server || return $?
    cargo build --features server || return $?
    ln -s $PWD/target/release/art $RUST_BIN/art || return $?
    ln -s $PWD/target/debug/art $RUST_BIN/artd || return $?
fi
errcho "-- artifact environment has been set up successfully --"