diff --git a/.babelrc b/.babelrc new file mode 100644 index 00000000..c13c5f62 --- /dev/null +++ b/.babelrc @@ -0,0 +1,3 @@ +{ + "presets": ["es2015"] +} diff --git a/.gitignore b/.gitignore index 695253f6..17067cdf 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,6 @@ logs **/node_modules releases dists/ipfs-app/build +www +**/gopath +**/tmp-build diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..ddd4195b --- /dev/null +++ b/.travis.yml @@ -0,0 +1,8 @@ +language: node_js +node_js: + - '4' + - '5' + - stable + +script: + - npm run lint \ No newline at end of file diff --git a/Makefile b/Makefile index 37b8d562..840c3cfe 100644 --- a/Makefile +++ b/Makefile @@ -1,19 +1,17 @@ -all: all_dists index +all: all_dists site -all_dists: go-ipfs +all_dists: go-ipfs ipfs-update fs-repo-migrations -ipfs-app: - echo "** making $@ **" +%: + echo "** $@ **" cd dists/$@ && make -go-ipfs: - echo "** making $@ **" - cd dists/$@ && make - -index: - echo "** making index.html **" - node gen-index.js >releases/index.html - cp -r static releases/. +site: + echo "** Building site **" + npm run build -publish: all_dists index +publish: all_dists site ipfs add -s rabin -q -r releases | tail -n1 >>versions + +clean: + rm -rf releases diff --git a/README.md b/README.md index 37e47979..844b7539 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,10 @@ # IPFS distributions +[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://ipn.io) [![](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io/) [![](https://img.shields.io/badge/freejs-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) +[![Dependency Status](https://david-dm.org/ipfs/distributions.svg?style=flat-square)](https://david-dm.org/ipfs/distributions) +[![Travis CI](https://travis-ci.org/ipfs/distributions.svg?branch=master)](https://travis-ci.org/ipfs/distributions) +[![Circle CI](https://circleci.com/gh/ipfs/distributions.svg?style=svg)](https://circleci.com/gh/ipfs/distributions) + > Source for building https://dist.ipfs.io ## How this repo works diff --git a/build-go.sh b/build-go.sh new file mode 100755 index 00000000..d3606fe5 --- /dev/null +++ b/build-go.sh @@ -0,0 +1,206 @@ +#!/bin/bash + +# globals +releases=../../releases + +# init colors +txtnon='\e[0m' # color reset +txtred='\e[0;31m' # Red +txtgrn='\e[0;32m' # Green +txtylw='\e[0;33m' # Yellow + +function fail() { + printf $txtred%s$txtnon\\n "$@" + exit 1 +} + +function warn() { + printf $txtylw%s$txtnon\\n "$@" +} + +function notice() { + printf $txtgrn%s$txtnon\\n "$@" +} + +# dep checks +reqbins="jq zip go" +for b in $reqbins +do + if ! type $b > /dev/null; then + fail "must have '$b' installed" + fi +done + +function printDistInfo() { + # print json output + jq -e ".platforms[\"$goos\"]" dist.json > /dev/null + if [ ! $? -eq 0 ]; then + cp dist.json dist.json.temp + jq ".platforms[\"$goos\"] = {\"name\":\"$goos Binary\",\"archs\":{}}" dist.json.temp > dist.json + fi + + local binname="$1" + cp dist.json dist.json.temp + jq ".platforms[\"$goos\"].archs[\"$goarch\"] = {\"link\":\"$goos-$goarch/$binname.zip\"}" dist.json.temp > dist.json + rm dist.json.temp +} + +function doBuild() { + local goos=$1 + local goarch=$2 + local target=$3 + local output=$4 + + echo "==> building for $goos $goarch" + + dir=$output/$1-$2 + if [ -e $dir ]; then + echo " $dir exists, skipping build" + return + fi + echo " output to $dir" + + mkdir -p tmp-build + + (cd tmp-build && GOOS=$goos GOARCH=$goarch go build $target 2> build-log) + if [ $? -ne 0 ]; then + warn " failed." + return 1 + fi + + notice " build succeeded!" + + # copy dist assets if they exist + if [ -e $GOPATH/src/$target/dist ]; then + cp -r $GOPATH/src/$target/dist/* tmp-build/ + fi + + # now zip it all up + local binname=$(basename $target) + mkdir -p $dir + if zip -r $dir/$binname.zip tmp-build/* > /dev/null; then + printDistInfo $binname + rm -rf tmp-build + else + warn " failed to zip up output" + success=1 + fi + + + # output results to results table + echo $target, $goos, $goarch, $success >> $output/results +} + +function printInitialDistfile() { + local distname=$1 + local version=$2 + test -e description || fail "no description file found" + + printf "{\"id\":\"$distname\",\"version\":\"$version\",\"releaseLink\":\"/$distname/$version\"}" | + jq ".name = \"$disname\"" | + jq ".platforms = {}" | + jq ".description = \"`cat description`\"" +} + +function printBuildInfo() { + # print out build information + local commit=$1 + go version + echo "git sha of code: $commit" + uname -a + echo built on `date` +} + +function buildWithMatrix() { + local matfile=$1 + local gobin=$2 + local output=$3 + local commit=$4 + + test -n "$output" || fail "error: output dir not specified" + test -e "$matfile" || fail "build matrix $matfile does not exist" + + mkdir -p "$output" + + local distname=$(basename `pwd`) + + printInitialDistfile $distname $version > dist.json + printBuildInfo $commit > $output/build-info + + # build each os/arch combo + while read line + do + doBuild $line $gobin $output + done < $matfile + + mv dist.json $output/dist.json +} + +function cleanRepo() { + local repopath=$1 + + reporoot=$(cd "$repopath" && git rev-parse --show-toplevel) + (cd "$reporoot" && git clean -df) + (cd "$reporoot" && git reset --hard) +} + +function checkoutVersion() { + local repopath=$1 + local ref=$2 + + test -n "$repopath" || fail "checkoutVersion: no repo to check out specified" + + echo "==> checking out version $ref in $repopath" + cleanRepo "$repopath" + (cd "$repopath" && git checkout $ref > /dev/null) + + test $? -eq 0 || fail "failed to check out $ref in $reporoot" +} + +function currentSha() { + (cd $1 && git show --pretty="%H") +} + +function printVersions() { + versarr=$(tr \n ' ' < versions) + echo "building versions: $versarr" +} + +function startGoBuilds() { + distname=$1 + gpath=$2 + + outputDir="$releases/$distname" + + # if the output directory already exists, warn user + if [ -e $outputDir ]; then + warn "dirty output directory" + warn "will skip building already existing binaries" + fi + + export GOPATH=$(pwd)/gopath + if [ ! -e $GOPATH/src/$gpath ]; then + echo "fetching $distname code..." + go get $gpath 2> /dev/null + fi + + repopath="$GOPATH/src/$gpath" + + (cd "$repopath" && git reset --hard && git clean -df) + + printVersions + + echo "" + while read version + do + notice "Building version $version binaries" + checkoutVersion $repopath $version + + buildWithMatrix matrices/$version $gpath $outputDir/$version $(currentSha $repopath) + echo "" + done < versions + + notice "build complete!" +} + +startGoBuilds $1 $2 diff --git a/circle.yml b/circle.yml new file mode 100644 index 00000000..95d89b18 --- /dev/null +++ b/circle.yml @@ -0,0 +1,7 @@ +machine: + node: + version: stable + +test: + override: + - npm run lint \ No newline at end of file diff --git a/dists/fs-repo-migrations/Makefile b/dists/fs-repo-migrations/Makefile new file mode 100644 index 00000000..4c3a845d --- /dev/null +++ b/dists/fs-repo-migrations/Makefile @@ -0,0 +1,22 @@ +repo=http://github.com/ipfs/fs-repo-migrations +releases=../../releases/fs-repo-migrations + +all: dist + +dist: versions + mkdir -p $(releases) + cp versions $(releases)/versions + ../../build-go.sh fs-repo-migrations github.com/ipfs/fs-repo-migrations + +versions: filtered_versions + git ls-remote -t $(repo) | egrep -o "refs/tags/v(.*)" | sed 's/refs\/tags\///' | sort > tag_versions + comm -23 -- tag_versions filtered_versions > versions + +filtered_versions: + touch filtered_versions + +clean: + rm -rf ./gopath + rm -rf $(releases) + rm versions tag_versions + diff --git a/dists/fs-repo-migrations/current b/dists/fs-repo-migrations/current new file mode 100644 index 00000000..0ec25f75 --- /dev/null +++ b/dists/fs-repo-migrations/current @@ -0,0 +1 @@ +v1.0.0 diff --git a/dists/fs-repo-migrations/description b/dists/fs-repo-migrations/description new file mode 100644 index 00000000..503dd7b0 --- /dev/null +++ b/dists/fs-repo-migrations/description @@ -0,0 +1 @@ +fs-repo-migrations is a tool to help migration ipfs storage repos to newer versions diff --git a/dists/fs-repo-migrations/matrices/v1.0.0 b/dists/fs-repo-migrations/matrices/v1.0.0 new file mode 100644 index 00000000..2c416b0d --- /dev/null +++ b/dists/fs-repo-migrations/matrices/v1.0.0 @@ -0,0 +1,10 @@ +darwin 386 +darwin amd64 +freebsd 386 +freebsd amd64 +freebsd arm +linux 386 +linux amd64 +linux arm +windows 386 +windows amd64 diff --git a/dists/fs-repo-migrations/versions b/dists/fs-repo-migrations/versions new file mode 100644 index 00000000..0ec25f75 --- /dev/null +++ b/dists/fs-repo-migrations/versions @@ -0,0 +1 @@ +v1.0.0 diff --git a/dists/go-ipfs/.gitignore b/dists/go-ipfs/.gitignore new file mode 100644 index 00000000..9dcf6e6f --- /dev/null +++ b/dists/go-ipfs/.gitignore @@ -0,0 +1 @@ +gopath/* diff --git a/dists/go-ipfs/Makefile b/dists/go-ipfs/Makefile index 1681b0fb..f893a7c7 100644 --- a/dists/go-ipfs/Makefile +++ b/dists/go-ipfs/Makefile @@ -1,32 +1,16 @@ repo = http://github.com/ipfs/go-ipfs -gpath = github.com/ipfs/go-ipfs/cmd/ipfs releases = ../../releases/go-ipfs -gbcli = $(shell which gobuilder-cli) all: dist -dist: versions deps +dist: versions mkdir -p $(releases) cp versions $(releases)/versions - ./go-ipfs-dist all + ../../build-go.sh go-ipfs github.com/ipfs/go-ipfs/cmd/ipfs versions: filtered_versions - git ls-remote -t $(repo) | egrep -o "refs/tags/v(.*)" | sed 's/refs\/tags\///' > tag_versions - cat tag_versions | grep -f filtered_versions -vE > versions + git ls-remote -t $(repo) | egrep -o "refs/tags/v(.*)" | sed 's/refs\/tags\///' | sort > tag_versions + comm -23 -- tag_versions filtered_versions > versions -deps: bin bin/gobuilder-cli go-ipfs-dist-x - -bin: - @mkdir -p bin - -go-ipfs-dist-x: - chmod +x go-ipfs-dist - -bin/gobuilder-cli: bin - #TODO: make this not require a go compiler... - go get github.com/Luzifer/gobuilder/cmd/gobuilder-cli - cp $(gbcli) bin/gobuilder-cli - -# bin/go-env: -# ipfs get -o bin/go-env QmfS4PZj7G7KgAztPN3JxXyY6KHJDZ77EaxzocWqsa3XhQ/go-env -# chmox +x bin/go-env +clean: + rm -rf $(releases) diff --git a/dists/go-ipfs/current b/dists/go-ipfs/current new file mode 100644 index 00000000..bf15550d --- /dev/null +++ b/dists/go-ipfs/current @@ -0,0 +1 @@ +v0.3.11 diff --git a/dists/go-ipfs/description b/dists/go-ipfs/description new file mode 100644 index 00000000..6452bb88 --- /dev/null +++ b/dists/go-ipfs/description @@ -0,0 +1 @@ +go-ipfs is the main implementation of IPFS. It is the base distribution, and includes:\n- an IPFS core implementation\n- an IPFS daemon server\n- extensive command line tooling\n- an HTTP API for controlling the node\n- an HTTP Gateway for serving content to HTTP browsers\n diff --git a/dists/go-ipfs/dist.json b/dists/go-ipfs/dist.json deleted file mode 100644 index 091f4994..00000000 --- a/dists/go-ipfs/dist.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "id": "go-ipfs", - "name": "go-ipfs", - "tagline": "IPFS implementation and toolchain in Go", - "description": "go-ipfs is the main implementation of IPFS. It is the base distribution, and includes:\n- an IPFS core implementation\n- an IPFS daemon server\n- extensive command line tooling\n- an HTTP API for controlling the node\n- an HTTP Gateway for serving content to HTTP browsers\n" -} \ No newline at end of file diff --git a/dists/go-ipfs/go-ipfs-dist b/dists/go-ipfs/go-ipfs-dist deleted file mode 100755 index 505aad46..00000000 --- a/dists/go-ipfs/go-ipfs-dist +++ /dev/null @@ -1,94 +0,0 @@ -#!/bin/bash - -# constants -repo="github.com/ipfs/go-ipfs" -gpath="github.com/ipfs/go-ipfs/cmd/ipfs" -releases="../../releases/go-ipfs" - -if [ "$#" -eq 0 ]; then - echo "usage: $0 " - echo "construct the go-ipfs dist directory for given version" - echo "" - exit 1 -fi - -die() { - echo >&2 "error: $@" - exit 1 -} - -assert() { - eval $1 >/dev/null 2>&1 || die $2 -} - -# check we have things installed -assert "bin/gobuilder-cli -h" "please run: make deps" -assert "ipfs -h" "please install ipfs" -assert "stat versions" "please run: make versions" - -# check the ipfs daemon is running -ipfs swarm peers >/dev/null || die "please run: ipfs daemon" - - -dist_version() { - # get version from input - cwd=`pwd` - version=$1 - dest_path="$releases/$version" - dest_path_src="$dest_path/go-ipfs_${version}_src.zip" - - # check version is ok - cat versions | grep "$version" >/dev/null || die "versions not in listing" - - stat "$releases/$version/dist.json" >/dev/null 2>&1 - if [ "$?" -eq 0 ]; then - echo "--> have $version in $dest_path" - return - fi - - echo "--> making $version" - - # get archives from gobuilder - echo "---> preparing $dest_path" - mkdir -p "$dest_path" - - echo "---> getting archives from gobuilder..." - bin/gobuilder-cli get-all "$gpath" "$dest_path" "$version" - if [ "$?" -ne 0 ]; then - echo "---> failed." - return -1 - fi - - # move gobuilder archives; they start with "ipfs_", not "go-ipfs_" - cd "$dest_path" - for f in ipfs_*.zip ; do mv "$f" "go-$f"; done - echo "mmv ipfs_*.zip go-ipfs_*.zip" - cd "$cwd" - - # get OSX installer (TODO) - # echo "---> building OSX installer..." - - echo "---> getting source tarball" - wget -q -O "$dest_path_src" "https://$repo/zipball/$version.zip" - echo "wrote $dest_path_src" - - # generate hashes file - echo "---> generating hashes" - cd "$dest_path" - ipfs add -s rabin --only-hash * >hashes - cd "$cwd" - - # generate dist.json file - echo "---> generating dist.json" - ./mkdist.js "$version" -} - -if [ "$1" = "all" ]; then - - for version in $(cat versions); do - dist_version $version || die "failed to make $version" - done - -else - dist_version $1 || die "failed to make $version" -fi diff --git a/dists/go-ipfs/matrices/v0.3.10 b/dists/go-ipfs/matrices/v0.3.10 new file mode 100644 index 00000000..2c416b0d --- /dev/null +++ b/dists/go-ipfs/matrices/v0.3.10 @@ -0,0 +1,10 @@ +darwin 386 +darwin amd64 +freebsd 386 +freebsd amd64 +freebsd arm +linux 386 +linux amd64 +linux arm +windows 386 +windows amd64 diff --git a/dists/go-ipfs/matrices/v0.3.2 b/dists/go-ipfs/matrices/v0.3.2 new file mode 100644 index 00000000..2c416b0d --- /dev/null +++ b/dists/go-ipfs/matrices/v0.3.2 @@ -0,0 +1,10 @@ +darwin 386 +darwin amd64 +freebsd 386 +freebsd amd64 +freebsd arm +linux 386 +linux amd64 +linux arm +windows 386 +windows amd64 diff --git a/dists/go-ipfs/matrices/v0.3.3 b/dists/go-ipfs/matrices/v0.3.3 new file mode 100644 index 00000000..2c416b0d --- /dev/null +++ b/dists/go-ipfs/matrices/v0.3.3 @@ -0,0 +1,10 @@ +darwin 386 +darwin amd64 +freebsd 386 +freebsd amd64 +freebsd arm +linux 386 +linux amd64 +linux arm +windows 386 +windows amd64 diff --git a/dists/go-ipfs/matrices/v0.3.4 b/dists/go-ipfs/matrices/v0.3.4 new file mode 100644 index 00000000..2c416b0d --- /dev/null +++ b/dists/go-ipfs/matrices/v0.3.4 @@ -0,0 +1,10 @@ +darwin 386 +darwin amd64 +freebsd 386 +freebsd amd64 +freebsd arm +linux 386 +linux amd64 +linux arm +windows 386 +windows amd64 diff --git a/dists/go-ipfs/matrices/v0.3.5 b/dists/go-ipfs/matrices/v0.3.5 new file mode 100644 index 00000000..2c416b0d --- /dev/null +++ b/dists/go-ipfs/matrices/v0.3.5 @@ -0,0 +1,10 @@ +darwin 386 +darwin amd64 +freebsd 386 +freebsd amd64 +freebsd arm +linux 386 +linux amd64 +linux arm +windows 386 +windows amd64 diff --git a/dists/go-ipfs/matrices/v0.3.6 b/dists/go-ipfs/matrices/v0.3.6 new file mode 100644 index 00000000..2c416b0d --- /dev/null +++ b/dists/go-ipfs/matrices/v0.3.6 @@ -0,0 +1,10 @@ +darwin 386 +darwin amd64 +freebsd 386 +freebsd amd64 +freebsd arm +linux 386 +linux amd64 +linux arm +windows 386 +windows amd64 diff --git a/dists/go-ipfs/matrices/v0.3.7 b/dists/go-ipfs/matrices/v0.3.7 new file mode 100644 index 00000000..2c416b0d --- /dev/null +++ b/dists/go-ipfs/matrices/v0.3.7 @@ -0,0 +1,10 @@ +darwin 386 +darwin amd64 +freebsd 386 +freebsd amd64 +freebsd arm +linux 386 +linux amd64 +linux arm +windows 386 +windows amd64 diff --git a/dists/go-ipfs/matrices/v0.3.8 b/dists/go-ipfs/matrices/v0.3.8 new file mode 100644 index 00000000..2c416b0d --- /dev/null +++ b/dists/go-ipfs/matrices/v0.3.8 @@ -0,0 +1,10 @@ +darwin 386 +darwin amd64 +freebsd 386 +freebsd amd64 +freebsd arm +linux 386 +linux amd64 +linux arm +windows 386 +windows amd64 diff --git a/dists/go-ipfs/matrices/v0.3.9 b/dists/go-ipfs/matrices/v0.3.9 new file mode 100644 index 00000000..2c416b0d --- /dev/null +++ b/dists/go-ipfs/matrices/v0.3.9 @@ -0,0 +1,10 @@ +darwin 386 +darwin amd64 +freebsd 386 +freebsd amd64 +freebsd arm +linux 386 +linux amd64 +linux arm +windows 386 +windows amd64 diff --git a/dists/go-ipfs/matrices/v0.4.0-dev b/dists/go-ipfs/matrices/v0.4.0-dev new file mode 100644 index 00000000..2c416b0d --- /dev/null +++ b/dists/go-ipfs/matrices/v0.4.0-dev @@ -0,0 +1,10 @@ +darwin 386 +darwin amd64 +freebsd 386 +freebsd amd64 +freebsd arm +linux 386 +linux amd64 +linux arm +windows 386 +windows amd64 diff --git a/dists/go-ipfs/mkdist.js b/dists/go-ipfs/mkdist.js old mode 100755 new mode 100644 index 2468894c..abb69999 --- a/dists/go-ipfs/mkdist.js +++ b/dists/go-ipfs/mkdist.js @@ -1,9 +1,7 @@ -#!/usr/bin/env node - -var mkdist = require('../../mkdist') +var mkdist = require('../../scripts/mkdist') if (process.argv.length != 3) { - console.log("usage: mkdist.js ") + console.log('usage: mkdist.js ') process.exit(1) } @@ -12,19 +10,19 @@ dist.version = process.argv[2] mkdist({ dist: dist, - path: "../..", + path: '../..', platforms: { oses: [ - {id: 'darwin', name: "Mac OSX App", browser:'OS X', icon: 'apple'}, - {id: 'linux', name: "Linux App", browser:'Linux', icon: 'linux'}, - {id: 'openbsd', name: "OpenBSD App", browser:'OpenBSD', icon: 'circle-o'}, - {id: 'freebsd', name: "FreeBSD App", browser:'FreeBSD', icon: 'circle-o'}, - {id: 'windows', name: "Windows App", browser:'Windows', icon: 'windows'}, + {id: 'darwin', name: 'Mac OSX Binary (.zip)', browser: 'OS X'}, + {id: 'linux', name: 'Linux Binary (.zip)', browser: 'Linux'}, + {id: 'openbsd', name: 'OpenBSD Binary (.zip)', browser: 'OpenBSD'}, + {id: 'freebsd', name: 'FreeBSD Binary (.zip)', browser: 'FreeBSD'}, + {id: 'windows', name: 'Windows Binary (.zip)', browser: 'Windows'} ], archs: [ {id: '386', name: '32 bit', browser: '32'}, {id: 'amd64', name: '64 bit', browser: '64'}, - {id: 'arm', name: 'ARM', browser: 'ARM'}, + {id: 'arm', name: 'ARM', browser: 'ARM'} ] } }) diff --git a/dists/go-ipfs/versions b/dists/go-ipfs/versions index bb48fbaf..211ba11f 100644 --- a/dists/go-ipfs/versions +++ b/dists/go-ipfs/versions @@ -4,3 +4,6 @@ v0.3.5 v0.3.6 v0.3.7 v0.3.8 +v0.3.9 +v0.3.10 +v0.4.0-dev diff --git a/dists/ipfs-update/Makefile b/dists/ipfs-update/Makefile new file mode 100644 index 00000000..4a2c2177 --- /dev/null +++ b/dists/ipfs-update/Makefile @@ -0,0 +1,22 @@ +repo=http://github.com/ipfs/ipfs-update +releases=../../releases/ipfs-update + +all: dist + +dist: versions + mkdir -p $(releases) + cp versions $(releases)/versions + ../../build-go.sh ipfs-update github.com/ipfs/ipfs-update + +versions: filtered_versions + git ls-remote -t $(repo) | egrep -o "refs/tags/v(.*)" | sed 's/refs\/tags\///' | sort > tag_versions + comm -23 -- tag_versions filtered_versions > versions + +filtered_versions: + touch filtered_versions + +clean: + rm -rf ./gopath + rm -rf $(releases) + rm versions tag_versions + diff --git a/dists/ipfs-update/current b/dists/ipfs-update/current new file mode 100644 index 00000000..0ec25f75 --- /dev/null +++ b/dists/ipfs-update/current @@ -0,0 +1 @@ +v1.0.0 diff --git a/dists/ipfs-update/description b/dists/ipfs-update/description new file mode 100644 index 00000000..96beced9 --- /dev/null +++ b/dists/ipfs-update/description @@ -0,0 +1 @@ +ipfs-update is a cli tool to help update and install ipfs easily diff --git a/dists/ipfs-update/matrices/v1.0.0 b/dists/ipfs-update/matrices/v1.0.0 new file mode 100644 index 00000000..2c416b0d --- /dev/null +++ b/dists/ipfs-update/matrices/v1.0.0 @@ -0,0 +1,10 @@ +darwin 386 +darwin amd64 +freebsd 386 +freebsd amd64 +freebsd arm +linux 386 +linux amd64 +linux arm +windows 386 +windows amd64 diff --git a/dists/ipfs-update/versions b/dists/ipfs-update/versions new file mode 100644 index 00000000..0ec25f75 --- /dev/null +++ b/dists/ipfs-update/versions @@ -0,0 +1 @@ +v1.0.0 diff --git a/package.json b/package.json index 02d68ed1..4349d105 100644 --- a/package.json +++ b/package.json @@ -5,15 +5,18 @@ "main": "gulpfile.babel.js", "dependencies": {}, "devDependencies": { + "Bootstrap-Offcanvas": "github:iamphill/Bootstrap-Offcanvas", + "async": "^1.5.0", "babel-core": "^6.1.2", - "babel-eslint": "^4.1.3", - "babel-jscs": "^2.0.0", + "babel-eslint": "^5.0.0-beta6", + "babel-jscs": "^3.0.0-beta1", "babel-loader": "^6.0.0", "babel-plugin-transform-remove-console": "^6.0.14", "babel-polyfill": "^6.0.14", - "babel-preset-es2015": "^6.0.15", + "babel-preset-es2015": "^6.3.13", "bootstrap": "^4.0.0-alpha.2", "browser-sync": "^2.10.0", + "del": "^2.2.0", "eslint": "^1.8.0", "eslint-config-standard": "^4.4.0", "eslint-plugin-standard": "^1.3.1", @@ -21,17 +24,23 @@ "gulp-batch": "^1.0.5", "gulp-eslint": "^1.1.1", "gulp-load-plugins": "^1.1.0", + "gulp-util": "^3.0.7", "gulp-watch": "^4.3.5", "harp": "^0.20.0", "jquery": "^2.1.4", + "lodash": "^3.10.1", + "mkdirp": "^0.5.1", "pre-commit": "^1.1.2", "require-dir": "^0.3.0", + "run-sequence": "^1.1.5", + "stickyfill": "^1.1.1", "tether": "^1.1.1", "webpack": "^1.12.2", - "webpack-stream": "^2.3.0" + "webpack-stream": "^3.1.0" }, "scripts": { - "lint": "gulp lint" + "lint": "gulp lint", + "build": "gulp build" }, "repository": { "type": "git", @@ -48,5 +57,8 @@ "homepage": "https://github.com/ipfs/distributions#readme", "pre-commit": [ "lint" - ] + ], + "engines": { + "node": "^4.0.0" + } } diff --git a/scripts/gen-index.js b/scripts/gen-index.js deleted file mode 100755 index ee4894fa..00000000 --- a/scripts/gen-index.js +++ /dev/null @@ -1,20 +0,0 @@ -var marked = require('marked') -var nunjucks = require('nunjucks') -var njmd = require('nunjucks-markdown') - -var njx = nunjucks.configure('.') -njmd.register(njx, marked) - -var spec = { - template: 'tmpl/index.html', - data: { dists: {} } -} - -var goipfsPath = './releases/go-ipfs/v0.3.7/dist.json' -spec.data.dists['go-ipfs'] = require(goipfsPath) - -njx.render(spec.template, spec.data, function (err, res) { - if (err) throw err - process.stdout.write(res) - process.exit(0) -}) diff --git a/site/README.md b/site/README.md index ab4db4fc..7161d9bd 100644 --- a/site/README.md +++ b/site/README.md @@ -1,7 +1,6 @@ -# IPFS Distributions +# Site - -## Development +> Distributions page written with [harpjs](http://harpjs.com). Harpjs setup with @@ -10,9 +9,17 @@ Harpjs setup with * bundeling using webpack * transpiling using babel * Linting using eslint +* Templates in jade +## Development ```bash $ gulp $ open localhost:3000 ``` + +## Build + +```bash +$ gulp build +``` diff --git a/site/public/_footer.jade b/site/public/_footer.jade new file mode 100644 index 00000000..45c1eb90 --- /dev/null +++ b/site/public/_footer.jade @@ -0,0 +1,10 @@ +footer.d-footer + .container + .row + | © Interplanetary Networks, Inc. | + | Except as + a(href='http://ipn.io/legal/policies') noted + | , content licensed + a(href='https://creativecommons.org/licenses/by/3.0/') CC-BY 3.0 + | | Source on + a(href='https://github.com/ipfs/distributions') Github diff --git a/site/public/_harp.json b/site/public/_harp.json new file mode 100644 index 00000000..dd5c8f53 --- /dev/null +++ b/site/public/_harp.json @@ -0,0 +1,6 @@ +{ + "globals": { + "title": "IPFS Distributions", + "desc": "Easily download everything needed for your IPFS needs" + } +} diff --git a/site/public/_header.jade b/site/public/_header.jade new file mode 100644 index 00000000..b68c2c99 --- /dev/null +++ b/site/public/_header.jade @@ -0,0 +1,13 @@ +nav.d-header.navbar.navbar-fixed-top.navbar-dark.bg-inverse + .container + .row + a.navbar-brand + | IPFS + span.d-header-light distributions + + button#d-toggle.navbar-toggler.offcanvas-toggle.hidden-sm-up.pull-right( + type='button' + data-toggle='offcanvas' + data-target='#d-navbar-offcanvas' + ) + | ☰ diff --git a/site/public/_js/script.js b/site/public/_js/script.js index 77df8f9c..a4ed2bc6 100644 --- a/site/public/_js/script.js +++ b/site/public/_js/script.js @@ -1,10 +1,7 @@ const $ = window.jQuery = require('jquery') window.Tether = require('tether') +const Stickyfill = require('stickyfill')() require('bootstrap') +require('bootstrap-offcanvas/dist/js/bootstrap.offcanvas.js') -const init = () => { - // LETS DO THIS! - console.log('hello world') -} - -$(init) +Stickyfill.add($('.sticky')[0]) diff --git a/site/public/_layout.jade b/site/public/_layout.jade index f5450b79..03fabf3a 100644 --- a/site/public/_layout.jade +++ b/site/public/_layout.jade @@ -12,6 +12,6 @@ html(lang='en') rel='stylesheet' type='text/css' ) - body + body(data-spy='scroll' data-target='#d-navbar') != yield script(src='build/script.js') \ No newline at end of file diff --git a/site/public/css/base.less b/site/public/css/_base.less similarity index 84% rename from site/public/css/base.less rename to site/public/css/_base.less index ff05e869..4bf2963c 100644 --- a/site/public/css/base.less +++ b/site/public/css/_base.less @@ -1,10 +1,7 @@ body { font-family: 'Fira Sans', sans-serif; line-height: @baseLineHeight; -} - -.container { - margin-top: 88px; + position: relative; } .bg-inverse { @@ -20,4 +17,8 @@ a { text-decoration: none; cursor: pointer; } +} + +.pull-right { + float: right; } \ No newline at end of file diff --git a/site/public/css/component.less b/site/public/css/_component.less similarity index 69% rename from site/public/css/component.less rename to site/public/css/_component.less index cd32d190..31d386f4 100644 --- a/site/public/css/component.less +++ b/site/public/css/_component.less @@ -1,14 +1,20 @@ .d-component { + padding-top: 4 * @baseLineHeight; + padding-bottom: 3 * @baseLineHeight; + border-bottom: 1px solid @borderGray; + &:first-child { + padding-top: 0; + } } .d-component-desc-title { - font-size: 18px; + font-size: 22px; font-weight: 500; } .d-component-desc-sub-title { - font-size: 16px; + font-size: 18px; font-weight: 300; } @@ -47,6 +53,7 @@ .d-download-table { font-size: 14px; line-height: 36px; + margin-top: 2 * @baseLineHeight; th { font-weight: 400; @@ -63,13 +70,18 @@ border-bottom: 1px solid @borderGray; border-top: none; - transition: all 0.3s linear; + transition: background 0.3s linear; - &:hover { + &:hover{ background-color: @baseBlue; color: @white; cursor: pointer; } + &:hover a, + a:hover { + color: @white; + cursor: pointer; + } } tr:last-child { @@ -78,4 +90,14 @@ border-bottom: none; } } -} \ No newline at end of file +} + +@media (min-width: 768px) { + .d-component:first-child { + padding-top: 5 * @baseLineHeight; + } + + .d-download-table { + margin-top: 0; + } +} diff --git a/site/public/css/_footer.less b/site/public/css/_footer.less new file mode 100644 index 00000000..b5d2762d --- /dev/null +++ b/site/public/css/_footer.less @@ -0,0 +1,16 @@ +.d-footer { + text-align: center; + color: @lightGray; + font-size: 14px; + font-weight: 300; + margin-top: 2 * @baseLineHeight; + padding: @baseLineHeight; + min-height: 100px; +} + +@media (min-width: 768px) { + .d-footer { + margin-top: 5 * @baseLineHeight; + min-height: 0; + } +} \ No newline at end of file diff --git a/site/public/css/_header.less b/site/public/css/_header.less new file mode 100644 index 00000000..89e9a563 --- /dev/null +++ b/site/public/css/_header.less @@ -0,0 +1,8 @@ +.d-header-light { + font-weight: 300; +} + +#d-toggle { + background: transparent; + padding: 0; +} \ No newline at end of file diff --git a/site/public/css/sidebar.less b/site/public/css/_sidebar.less similarity index 50% rename from site/public/css/sidebar.less rename to site/public/css/_sidebar.less index 6ef868ba..f8aefa06 100644 --- a/site/public/css/sidebar.less +++ b/site/public/css/_sidebar.less @@ -1,14 +1,13 @@ @leftBorderWidth: 2px; +.d-sidebar-wrapper { + top: 2 * @baseLineHeight; + background: #FFFFFF; + padding-top: @baseLineHeight; +} + .d-sidebar-item { line-height: 27px; - - &.active { - .d-sidebar-link { - border-left: @leftBorderWidth solid @baseBlue; - color: @baseBlue; - } - } } .d-sidebar-link { @@ -21,8 +20,22 @@ transition: color 0.4s linear; + &.active { + border-left: @leftBorderWidth solid @baseBlue; + color: @baseBlue; + } + &:hover { color: @baseBlue; cursor: pointer; } -} \ No newline at end of file +} + +@media (min-width: 768px) { + .d-sidebar-wrapper { + top: 4.8 * @baseLineHeight; + position: sticky; + background: #FFFFFF; + padding-top: 0; + } +} diff --git a/site/public/css/colors.less b/site/public/css/_variables.less similarity index 87% rename from site/public/css/colors.less rename to site/public/css/_variables.less index 86788c88..9db5ced4 100644 --- a/site/public/css/colors.less +++ b/site/public/css/_variables.less @@ -9,5 +9,5 @@ @white: #FFFFFF; @baseBlue: #6282d7; @linkBlue: #076fad; -@lightGray: #777777; +@lightGray: #6b6b6b; @borderGray: #ebebeb; \ No newline at end of file diff --git a/site/public/css/style.less b/site/public/css/style.less index 98b25713..093a8901 100644 --- a/site/public/css/style.less +++ b/site/public/css/style.less @@ -1,7 +1,10 @@ @import (inline) '../../../node_modules/bootstrap/dist/css/bootstrap.css'; +@import (inline) '../../../node_modules/bootstrap-offcanvas/dist/css/bootstrap.offcanvas.css'; -@import './colors'; -@import './base'; +@import './_variables'; +@import './_base'; -@import './sidebar'; -@import './component'; +@import './_header'; +@import './_footer'; +@import './_sidebar'; +@import './_component'; diff --git a/site/public/index.jade b/site/public/index.jade index bca2b4cc..caa85e8f 100644 --- a/site/public/index.jade +++ b/site/public/index.jade @@ -1,70 +1,52 @@ -nav.navbar.navbar-fixed-top.navbar-dark.bg-inverse - a.navbar-brand IPFS distributions +include ./_header.jade + +- targetMap = {'386': '32-bit', 'amd64': '64-bit', 'arm': 'ARM'} +- architectureMap = {'darwin Binary': 'Mac OS X Binary', 'freebsd Binary': 'FreeBSD Binary', 'linux Binary': 'Linux Binary', 'windows Binary': 'Windows Binary'} .container .row - .col-md-2 + .d-sidebar-wrapper.col-md-2.sticky.navbar-offcanvas#d-navbar-offcanvas .d-sidebar - ul.nav#d-navbar - li.d-sidebar-item.nav-item.active - a.d-sidebar-link.nav-link go-ipfs - li.d-sidebar-item.nav-item - a.d-sidebar-link.nav-link Station + ul.nav#d-navbar: each value, key in public.releases li.d-sidebar-item.nav-item - a.d-sidebar-link.nav-link ipfs-update - .col-md-10 - .d-component + a.d-sidebar-link.nav-link(href='##{key}')= key + .col-md-10: each value, key in public.releases + .d-component(id='#{key}') + - data = value._data .d-component-desc.row .col-md-8 h1.d-component-desc-title - | go-ipfs + = key h2.d-component-desc-sub-title - | IPFS reference implementation and toolchain in Go + = data.tagline .d-component-desc-body - | go-ipfs is the main implementation of IPFS. It is the base - | distribution, and includes: - ul - li an IPFS core implementation - li an IPFS daemon server - li extensive command line tooling - li an HTTP API for controlling the node - li an HTTP Gateway for serving content to HTTP browsers - .d-component-asset.col-md-4 - a(href='https://asciinema.org/a/23012' target='_blank') - img(src='https://asciinema.org/a/23012.png' width='260') + != partial('releases/' + key + '/index') + if data.ascii + .d-component-asset.col-md-4 + a(href="https://asciinema.org/a/#{data.ascii}" target='_blank') + img(src="https://asciinema.org/a/#{data.ascii}.png" width='260') .d-component-release.row .col-md-4 - h3.d-component-version 0.4.0 + h3.d-component-version= data.version h4.d-component-release-date January 1, 2016 .d-component-actions - a.d-component-actions-docs Docs - a.d-component-actions-changelog Changelog - a.d-component-actions-versions All Versions + a.d-component-actions-docs(href="https://github.com/ipfs/#{data.id}/tree/#{data.version}/README.md" target='_blank') + | Docs + a.d-component-actions-changelog(href="https://github.com/ipfs/#{data.id}/tree/#{data.version}/CHANGELOG.md" target='_blank') + | Changelog + a.d-component-actions-versions(href="#{data.id}") + | All Versions .col-md-8 table.table.d-download-table tbody - tr - th Windows Binary (.zip) - td(colspan='3') 32bit - td(colspan='3') 64bit - tr - th Mac OS X Binary (.zip) - td(colspan='3') 32bit - td(colspan='3') 64bit - tr - th Linux Binary (.tar.gz) - td(colspan='3') 32bit - td(colspan='3') 64bit - tr - th ARM Binary (.tar.gz) - td(colspan='2') ARM v6 - td(colspan='2') ARM v7 - td(colspan='2') ARM v8 - tr - th Free BSD Binary (.tar.gz) - td(colspan='3') 32bit - td(colspan='3') 64bit - tr - th Source Code (.tar.gz) - td(colspan='6') Download + for p in data.platforms + - colspan = 6 / Object.keys(p.archs).length + tr + th= architectureMap[p.name] + for arch, target in p.archs + td(colspan="#{colspan}") + - link = data.releaseLink.replace(/^\//, '') + '/' + arch.link + a(href="#{link}")= targetMap[target] + +include ./_footer.jade \ No newline at end of file diff --git a/tasks/build.js b/tasks/build.js index 7a044ab7..3ec25ced 100644 --- a/tasks/build.js +++ b/tasks/build.js @@ -1 +1,37 @@ -// TODO: Build harp + webpack +const gulp = require('gulp') +const runSequence = require('run-sequence') +const harp = require('harp') +const webpackStream = require('webpack-stream') +const del = require('del') + +const config = require('./config') + +gulp.task('clean', () => { + return del(['./www']) +}) + +gulp.task('webpack:prod', () => { + return gulp.src('./site/public/_js/script.js') + .pipe(webpackStream(config.webpack.prod)) + .pipe(gulp.dest('site/')) +}) + +gulp.task('harp:compile', done => { + harp.compile('./site', '../www', done) +}) + +gulp.task('copy:site', done => { + return gulp.src(['./www/**/*']) + .pipe(gulp.dest('./releases')) +}) + +gulp.task('build', done => { + runSequence( + ['clean', 'dist'], + 'webpack:prod', + 'harp:compile', + 'copy:site', + 'clean', + done + ) +}) diff --git a/tasks/config.js b/tasks/config.js new file mode 100644 index 00000000..9a3f1d6e --- /dev/null +++ b/tasks/config.js @@ -0,0 +1,48 @@ +const webpack = require('webpack') + +const base = { + entry: [ + 'babel-polyfill', + './site/public/_js/script.js' + ], + output: { + path: __dirname, + filename: './public/build/script.js' + }, + module: { + loaders: [{ + test: /\.js$/, + exclude: /node_modules/, + loader: 'babel', + query: { + cacheDirectory: true, + presets: ['es2015'] + } + }] + }, + plugins: [ + new webpack.NoErrorsPlugin() + ], + stats: { + colors: true + } +} + +module.exports = { + webpack: { + dev: Object.assign({}, base, { + watch: true, + devtool: 'source-map' + }), + prod: Object.assign({}, base, { + plugins: [ + new webpack.optimize.UglifyJsPlugin({ + compressor: { + warnings: false + } + }), + new webpack.NoErrorsPlugin() + ] + }) + } +} diff --git a/tasks/dist.js b/tasks/dist.js new file mode 100644 index 00000000..ca6831f0 --- /dev/null +++ b/tasks/dist.js @@ -0,0 +1,54 @@ +const gulp = require('gulp') +const $ = require('gulp-load-plugins')() +const fs = require('fs') +const {join} = require('path') +const _ = require('lodash') +const mkdirp = require('mkdirp') +const async = require('async') + +const log = $.util.log + +function fail (msg) { + log($.util.colors.red(msg)) + process.exit(1) +} + +const RELEASE_PATH = join(__dirname, '..', 'releases') +const SITE_PATH = join(__dirname, '..', 'site', 'public', 'releases') + +function getVersion (type, done) { + const p = join(RELEASE_PATH, type, 'versions') + + fs.readFile(p, (err, versions) => { + if (err) return done(err) + done(null, _(versions.toString().split('\n')).compact().last()) + }) +} + +function writeData (type, version, done) { + const dataPath = join(RELEASE_PATH, type, version, 'dist.json') + const data = JSON.parse(fs.readFileSync(dataPath).toString()) + + const dataTargetPath = join(SITE_PATH, type) + async.series([ + mkdirp.bind(mkdirp, dataTargetPath), + fs.writeFile.bind(fs, join(dataTargetPath, '_data.json'), JSON.stringify(data, null, 2)), + fs.writeFile.bind(fs, join(dataTargetPath, 'index.md'), data.description) + ], done) +} + +function writeSiteFiles (type, done) { + getVersion(type, (err, version) => { + if (err) return done(err) + + writeData(type, version, done) + }) +} + +gulp.task('dist', done => { + fs.readdir(RELEASE_PATH, (err, types) => { + if (err) return fail(err.msg) + + async.each(types, writeSiteFiles, done) + }) +}) diff --git a/tasks/serve.js b/tasks/serve.js index 55f12ed6..04a166a1 100644 --- a/tasks/serve.js +++ b/tasks/serve.js @@ -2,11 +2,12 @@ const gulp = require('gulp') const browserSync = require('browser-sync') const reload = browserSync.reload const harp = require('harp') -const webpack = require('webpack') const webpackStream = require('webpack-stream') const $ = require('gulp-load-plugins')() const _ = require('lodash') +const config = require('./config') + const tmpFiles = p => { const file = _.last(p.split('/')) const emacsTmp = !!file.match(/^\.#/) @@ -65,36 +66,8 @@ gulp.task('harp', () => { gulp.task('webpack', () => { gulp.src('./site/public/_js/script.js') - .pipe(webpackStream({ - watch: true, - entry: [ - 'babel-polyfill', - './site/public/_js/script.js' - ], - output: { - path: __dirname, - filename: './public/build/script.js' - }, - module: { - loaders: [{ - test: /\.js$/, - exclude: /node_modules/, - loader: 'babel', - query: { - cacheDirectory: true, - presets: ['es2015'] - } - }] - }, - plugins: [ - new webpack.NoErrorsPlugin() - ], - stats: { - colors: true - }, - devtool: 'source-map' - })) + .pipe(webpackStream(config.webpack.dev)) .pipe(gulp.dest('site/')) }) -gulp.task('serve', ['harp', 'webpack']) +gulp.task('serve', ['dist', 'harp', 'webpack'])