Skip to content

Commit

Permalink
New installer method (#955)
Browse files Browse the repository at this point in the history
* add download script

* fix tests, pin standard

* #930 replaced / with path.sep (#962)

* add latest to travis

* show messsage if invalid dir name on createDir (#889)

* show messsage if invalid dir name on createDir

* change or to and, fix tests

* Create issue_template.md (#972)

* Create issue_template.md

* Comment out security issue

* Add more comments
  • Loading branch information
=^._.^= authored and joehand committed Apr 12, 2018
1 parent 1591bec commit b227a47
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 57 deletions.
26 changes: 0 additions & 26 deletions INSTALL

This file was deleted.

64 changes: 36 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,42 @@ Have questions? Join our chat via IRC or Gitter:
- [Javascript API](#js-api)
- [For Developers](#for-developers)

## Installation

Dat can be used as a command line tool or a javascript library:

* Install the `$ dat` CLI to use in the command line.
* [require('dat')][dat-node] - dat-node, a library for downloading and sharing dat archives in javascript apps.

### Installing the `$ dat` command line tool

The recommended way to install the Dat command line tool is with `npm`:

```
npm install -g dat
```

Make sure you have `node` and `npm` installed first. If not, see the prerequisites section below. We recommend `npm` because it makes it easy to install new versions of `dat` when they get released.

Once `npm install` finishes, you should be able to run the `$ dat` command. If not, see the [installation troubleshooting](#troubleshooting) for tips.

#### Installing without npm

If you are unable to use `npm` to install dat, you can also download a single file binary distribution version of `dat` using the one line install command below. The binary includes a copy of node and dat packaged inside a single file, so you just have to download one file in order to start sharing data, with no other dependencies needed on your system:

```
wget -qO- https://raw.githubusercontent.com/datproject/dat/master/bin/download.sh | bash
```

#### NPM Prerequisites

* **Node**: You'll need to [install Node JS][install-node] before installing Dat. Dat needs `node` version 4 or above and `npm` installed. You can run `node -v` to check your version.
* **npm**: `npm` is installed with node. You can run `npm -v` to make sure it is installed.

Once you have `npm` ready, install `dat` from npm with the `--global, -g` option, `npm install -g dat`.

## Getting started

#### What is Dat?

Share, backup, and publish your filesystem. You can turn any folder on your computer into a dat. Dat scans your folder, allowing you to:
Expand Down Expand Up @@ -56,40 +92,12 @@ Mac/Linux | Windows | Version
Have questions or need some guidance?
You can [chat with us](http://chat.datproject.org) in IRC on [#dat][irc-channel] or [Gitter][gitter-chat]!

## Installation

Dat can be used as a command line tool or a javascript library:

* `npm install -g dat` - Install `dat` globally to use in the command line.
* [require('dat')][dat-node] - dat-node, a library for downloading and sharing dat archives in javascript apps.

### Installing via npm

The Dat command line tool can be installed with `npm`:

```
npm install -g dat
```

Make sure you have `node` and `npm` installed first. If not, see the prerequisites section below.

Once `npm install` finishes, you should be able to run the `dat` command. If not, see the [installation troubleshooting](#troubleshooting) for tips.

#### Prerequisites

* **Node**: You'll need to [install Node JS][install-node] before installing Dat. Dat needs `node` version 4 or above and `npm` installed. You can run `node -v` to check your version.
* **npm**: `npm` is installed with node. You can run `npm -v` to make sure it is installed.

Once you have `npm` ready, install `dat` from npm with the `--global, -g` option, `npm install -g dat`.

### JS Library

Add Dat to your `package.json`, `npm install dat --save`. Dat exports the [dat-node] API via `require('dat')`. Use it in your javascript applications! Dat Desktop and Dat command line both use dat-node to share and download dats.

Full API documentation is available in the [dat-node] repository on Github.

## Getting started

We have Dat installed, let's use it!

Dat's unique design works wherever you store your data. You can create a new dat from any folder on your computer.
Expand Down
60 changes: 60 additions & 0 deletions download.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/bin/bash

# gets latest dat release zip for platform and extracts runnable binary into ~/.dat
# usage: wget -qO- https://raw.githubusercontent.com/datproject/dat/master/bin/install.sh | bash
# based on https://github.com/jpillora/installer/blob/master/scripts/download.sh

DAT_DIR="$HOME/.dat/releases"

function cleanup {
rm -rf $DAT_DIR/tmp.zip > /dev/null
}

function fail {
cleanup
msg=$1
echo "============"
echo "Error: $msg" 1>&2
exit 1
}

function install {
# bash check
[ ! "$BASH_VERSION" ] && fail "Please use bash instead"
GET=""
if which curl > /dev/null; then
GET="curl"
GET="$GET --fail -# -L"
elif which wget > /dev/null; then
GET="wget"
GET="$GET -qO-"
else
fail "neither wget/curl are installed"
fi
case `uname -s` in
Darwin) OS="macos";;
Linux) OS="linux";;
*) fail "unsupported os: $(uname -s)";;
esac
if uname -m | grep 64 > /dev/null; then
ARCH="x64"
else
fail "only arch x64 is currently supported for single file install. please use npm instead. your arch is: $(uname -m)"
fi
echo "Fetching latest Dat release version from GitHub"
LATEST=$($GET -qs https://api.github.com/repos/datproject/dat/releases/latest | grep tag_name | head -n 1 | cut -d '"' -f 4);
mkdir -p $DAT_DIR || fail "Could not create directory $DAT_DIR, try manually downloading zip and extracting instead."
cd $DAT_DIR
RELEASE="dat-${LATEST:1}-${OS}-${ARCH}"
URL="https://github.com/datproject/dat/releases/download/${LATEST}/${RELEASE}.zip"
which unzip > /dev/null || fail "unzip is not installed"
echo "Downloading $URL"
bash -c "$GET $URL" > $DAT_DIR/tmp.zip || fail "download failed"
unzip -o -qq $DAT_DIR/tmp.zip || fail "unzip failed"
BIN="$DAT_DIR/$RELEASE/dat"
chmod +x $BIN || fail "chmod +x failed"
cleanup
printf "Dat $LATEST has been downloaded successfully. Execute it with this command:\n\n${BIN}\n\nAdd it to your PATH with this command (add this to .bash_profile/.bashrc):\n\nexport PATH=\"\$PATH:$DAT_DIR/$RELEASE\"\n"
}

install
6 changes: 3 additions & 3 deletions package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ cp LICENSE builds/dat-$VERSION-linux-x64/
cp LICENSE builds/dat-$VERSION-macos-x64/
cp LICENSE builds/dat-$VERSION-win-x64/

cp INSTALL builds/dat-$VERSION-linux-x64/README
cp INSTALL builds/dat-$VERSION-macos-x64/README
cp INSTALL builds/dat-$VERSION-win-x64/README
cp README.md builds/dat-$VERSION-linux-x64/README
cp README.md builds/dat-$VERSION-macos-x64/README
cp README.md builds/dat-$VERSION-win-x64/README

cd builds
../node_modules/.bin/cross-zip dat-$VERSION-linux-x64 ../dist/dat-$VERSION-linux-x64.zip
Expand Down

0 comments on commit b227a47

Please sign in to comment.