mirror of
https://github.com/dolthub/dolt.git
synced 2026-02-10 18:49:02 -06:00
Split clients/* into clients/go and clients/js
* clients/counter -> clients/go/counter * remove last little bit of crunchbase * clients/csv -> clients/go/csv and other cleanups * clients/flags -> clients/go/flags * clients/fs -> clients/js/fs and other cleanups * clients/json_importer -> clients/go/json-import * move clients/plotly_bar_chart -> clients/js/bar-chart * move clients/server -> clients/go/server * move clients/shove -> clients/go/shove * move clients/splore -> client/js/splore * move clients/struct-by-name -> clients/js/struct-by-name * move clients/test_util -> clients/go/test_util * move clients/url-fetch -> clients/js/url-fetch * move clients/util -> clients/go/util * move clients/xml_importer -> clients/xml
This commit is contained in:
@@ -15,7 +15,7 @@ before_script:
|
||||
- npm install
|
||||
- npm test
|
||||
- popd
|
||||
- pushd clients/splore
|
||||
- pushd clients/js/splore
|
||||
- npm prune
|
||||
- ./build.py
|
||||
- npm test
|
||||
@@ -34,7 +34,7 @@ notifications:
|
||||
cache:
|
||||
directories:
|
||||
- js/node_modules
|
||||
- clients/splore/node_modules
|
||||
- clients/js/splore/node_modules
|
||||
deploy:
|
||||
provider: script
|
||||
script: tools/publish-js-sdk.py
|
||||
|
||||
12
README.md
12
README.md
@@ -35,17 +35,17 @@ go test `go list ./... | grep -v /vendor/`
|
||||
# Run
|
||||
|
||||
```
|
||||
cd "$GOPATH/src/github.com/attic-labs/noms/clients/counter"
|
||||
cd "$GOPATH/src/github.com/attic-labs/noms/clients/go/counter"
|
||||
go build
|
||||
./counter -ldb=/tmp/foo -ds=foo
|
||||
./counter -ldb=/tmp/foo -ds=foo
|
||||
./counter -ldb=/tmp/foo -ds=foo
|
||||
./counter ldb:/tmp/foo:foo
|
||||
./counter ldb:/tmp/foo:foo
|
||||
./counter ldb:/tmp/foo:foo
|
||||
```
|
||||
|
||||
# What next?
|
||||
|
||||
* Learn the core tools: [`server`](clients/server), [`splore`](clients/splore), [`shove`](clients/shove), [`csv import/export`](clients/csv), [`json_importer`](clients/json_importer), [`xml_importer`](clients/xml_importer)
|
||||
* Run sample apps: [`sfcrime`](clients/sfcrime)
|
||||
* Learn the core tools: [`server`](clients/go/server), [`splore`](clients/js/splore), [`shove`](clients/go/shove), [`csv import/export`](clients/go/csv), [`json-import`](clients/go/json-import), [`xml_importer`](clients/go/xml_importer)
|
||||
* Run sample apps: (TODO)
|
||||
* NomDL reference (TODO)
|
||||
* Go SDK reference (TODO)
|
||||
* JavaScript SDK reference (TODO)
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
../../js/.flowconfig
|
||||
@@ -6,8 +6,8 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/attic-labs/noms/clients/flags"
|
||||
"github.com/attic-labs/noms/clients/util"
|
||||
"github.com/attic-labs/noms/clients/go/flags"
|
||||
"github.com/attic-labs/noms/clients/go/util"
|
||||
"github.com/attic-labs/noms/d"
|
||||
"github.com/attic-labs/noms/datas"
|
||||
"github.com/attic-labs/noms/types"
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/attic-labs/noms/clients/test_util"
|
||||
"github.com/attic-labs/noms/clients/go/test_util"
|
||||
"github.com/stretchr/testify/suite"
|
||||
)
|
||||
|
||||
@@ -5,9 +5,9 @@ Imports a CSV file as `List<T>` where `T` is a struct with fields corresponding
|
||||
## Usage
|
||||
|
||||
```
|
||||
$ cd importer
|
||||
$ cd csv-import
|
||||
$ go build
|
||||
$ ./importer --h=http://localhost:8000 --ds=foo <PATH>
|
||||
$ ./csv-import http://localhost:8000:foo <PATH>
|
||||
```
|
||||
|
||||
## Some places for CSV files
|
||||
@@ -22,7 +22,7 @@ Export a dataset in CSV format to stdout with column headers.
|
||||
## Usage
|
||||
|
||||
```
|
||||
$ cd exporter
|
||||
$ cd csv-export
|
||||
$ go build
|
||||
$ ./exporter --h=http://localhost:8000 --ds=foo
|
||||
$ ./csv-export http://localhost:8000:foo
|
||||
```
|
||||
@@ -7,9 +7,9 @@ import (
|
||||
"os"
|
||||
"runtime"
|
||||
|
||||
"github.com/attic-labs/noms/clients/csv"
|
||||
"github.com/attic-labs/noms/clients/flags"
|
||||
"github.com/attic-labs/noms/clients/util"
|
||||
"github.com/attic-labs/noms/clients/go/csv"
|
||||
"github.com/attic-labs/noms/clients/go/flags"
|
||||
"github.com/attic-labs/noms/clients/go/util"
|
||||
"github.com/attic-labs/noms/d"
|
||||
"github.com/attic-labs/noms/datas"
|
||||
)
|
||||
@@ -26,7 +26,7 @@ func main() {
|
||||
runtime.GOMAXPROCS(cpuCount)
|
||||
|
||||
flag.Usage = func() {
|
||||
fmt.Fprintln(os.Stderr, "Usage: csv_exporter [options] dataset > filename")
|
||||
fmt.Fprintln(os.Stderr, "Usage: csv-export [options] dataset > filename")
|
||||
flag.PrintDefaults()
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/attic-labs/noms/chunks"
|
||||
"github.com/attic-labs/noms/clients/test_util"
|
||||
"github.com/attic-labs/noms/clients/go/test_util"
|
||||
"github.com/attic-labs/noms/d"
|
||||
"github.com/attic-labs/noms/datas"
|
||||
"github.com/attic-labs/noms/dataset"
|
||||
@@ -8,9 +8,9 @@ import (
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/attic-labs/noms/clients/csv"
|
||||
"github.com/attic-labs/noms/clients/flags"
|
||||
"github.com/attic-labs/noms/clients/util"
|
||||
"github.com/attic-labs/noms/clients/go/csv"
|
||||
"github.com/attic-labs/noms/clients/go/flags"
|
||||
"github.com/attic-labs/noms/clients/go/util"
|
||||
"github.com/attic-labs/noms/d"
|
||||
"github.com/attic-labs/noms/types"
|
||||
)
|
||||
@@ -31,7 +31,7 @@ func main() {
|
||||
runtime.GOMAXPROCS(cpuCount)
|
||||
|
||||
flag.Usage = func() {
|
||||
fmt.Fprintln(os.Stderr, "Usage: csv_importer [options] <dataset> <csvfile>\n")
|
||||
fmt.Fprintln(os.Stderr, "Usage: csv-import [options] <dataset> <csvfile>\n")
|
||||
flag.PrintDefaults()
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/attic-labs/noms/chunks"
|
||||
"github.com/attic-labs/noms/clients/test_util"
|
||||
"github.com/attic-labs/noms/clients/go/test_util"
|
||||
"github.com/attic-labs/noms/d"
|
||||
"github.com/attic-labs/noms/datas"
|
||||
"github.com/attic-labs/noms/dataset"
|
||||
@@ -9,14 +9,14 @@ import (
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"github.com/attic-labs/noms/clients/flags"
|
||||
"github.com/attic-labs/noms/clients/util"
|
||||
"github.com/attic-labs/noms/clients/go/flags"
|
||||
"github.com/attic-labs/noms/clients/go/util"
|
||||
"github.com/attic-labs/noms/d"
|
||||
)
|
||||
|
||||
func main() {
|
||||
flag.Usage = func() {
|
||||
fmt.Fprintf(os.Stderr, "usage: %s <dataset> <url>\n", os.Args[0])
|
||||
fmt.Fprintf(os.Stderr, "usage: %s <url> <dataset>\n", os.Args[0])
|
||||
flag.PrintDefaults()
|
||||
}
|
||||
|
||||
@@ -24,15 +24,15 @@ func main() {
|
||||
flag.Parse()
|
||||
|
||||
if len(flag.Args()) != 2 {
|
||||
util.CheckError(errors.New("expected dataset and url flags"))
|
||||
util.CheckError(errors.New("expected url and dataset flags"))
|
||||
}
|
||||
|
||||
spec, err := flags.ParseDatasetSpec(flag.Arg(0))
|
||||
spec, err := flags.ParseDatasetSpec(flag.Arg(1))
|
||||
util.CheckError(err)
|
||||
ds, err := spec.Dataset()
|
||||
util.CheckError(err)
|
||||
|
||||
url := flag.Arg(1)
|
||||
url := flag.Arg(0)
|
||||
if url == "" {
|
||||
flag.Usage()
|
||||
}
|
||||
@@ -5,15 +5,15 @@ Server implements a noms datastore over HTTP.
|
||||
## Example
|
||||
|
||||
```
|
||||
cd $GOPATH/src/github.com/attic-labs/noms/clients/counter
|
||||
cd $GOPATH/src/github.com/attic-labs/noms/clients/go/counter
|
||||
go build
|
||||
./counter -ldb="/tmp/servertest" -ds="counter"
|
||||
./counter -ldb="/tmp/servertest" -ds="counter"
|
||||
./counter -ldb="/tmp/servertest" -ds="counter"
|
||||
./counter ldb:/tmp/servertest:counter
|
||||
./counter ldb:/tmp/servertest:counter
|
||||
./counter ldb:/tmp/servertest:counter
|
||||
|
||||
cd ../server
|
||||
go build
|
||||
./server -ldb="/tmp/servertest" &
|
||||
./server ldb:/tmp/servertest
|
||||
```
|
||||
|
||||
Then navigate a web browser to [http://localhost:8000/root](http://localhost:8000/root). You should see a string starting with `sha1-...`. This _ref_ is the unique identifier for the current state of the datastore. You can explore it further by fetching URLs like http://localhost:8000/ref/sha1-...
|
||||
@@ -23,8 +23,6 @@ Then navigate a web browser to [http://localhost:8000/root](http://localhost:800
|
||||
Server is not commonly used directly by users, but is a building block used by other tools. For example, you can connect the counter application to your running server like so:
|
||||
|
||||
```
|
||||
./counter -h="http://localhost:8000" -ds="counter"
|
||||
./counter -h="http://localhost:8000" -ds="counter"
|
||||
./counter http://localhost:8000:counter
|
||||
./counter http://localhost:8000:counter
|
||||
```
|
||||
|
||||
Most noms clients accept this `-h` flag to connect to an http datastore.
|
||||
@@ -8,8 +8,8 @@ import (
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/attic-labs/noms/clients/flags"
|
||||
"github.com/attic-labs/noms/clients/util"
|
||||
"github.com/attic-labs/noms/clients/go/flags"
|
||||
"github.com/attic-labs/noms/clients/go/util"
|
||||
"github.com/attic-labs/noms/d"
|
||||
"github.com/attic-labs/noms/datas"
|
||||
)
|
||||
26
clients/go/shove/README.md
Normal file
26
clients/go/shove/README.md
Normal file
@@ -0,0 +1,26 @@
|
||||
# Shove
|
||||
|
||||
Shove syncs between datastores and datasets. It is the noms equivalent of Git's `push` and `pull` commands.
|
||||
|
||||
## Example
|
||||
|
||||
```
|
||||
cd $GOPATH/src/github.com/attic-labs/noms/clients/go/counter
|
||||
go build
|
||||
./counter ldb:/tmp/shovetest1:counter
|
||||
./counter ldb:/tmp/shovetest1:counter
|
||||
./counter ldb:/tmp/shovetest1:counter
|
||||
|
||||
cd ../shove
|
||||
go build
|
||||
./shove ldb:/tmp/shovetest1:counter ldb:/tmp/shovetest2:counter2
|
||||
../counter/counter ldb:/tmp/shovetest2:counter2
|
||||
|
||||
# Shove can also connect to http datastores
|
||||
cd ../server
|
||||
go build
|
||||
./server ldb:/tmp/shovetest2 &
|
||||
|
||||
../shove/shove http://localhost:8000:counter2 ldb:/tmp/shovetest3:counter3
|
||||
../counter/counter ldb:/tmp/shovetest3:counter3
|
||||
```
|
||||
@@ -8,8 +8,8 @@ import (
|
||||
"os"
|
||||
"runtime"
|
||||
|
||||
"github.com/attic-labs/noms/clients/flags"
|
||||
"github.com/attic-labs/noms/clients/util"
|
||||
"github.com/attic-labs/noms/clients/go/flags"
|
||||
"github.com/attic-labs/noms/clients/go/util"
|
||||
"github.com/attic-labs/noms/d"
|
||||
"github.com/attic-labs/noms/types"
|
||||
)
|
||||
@@ -23,7 +23,7 @@ func main() {
|
||||
runtime.GOMAXPROCS(cpuCount)
|
||||
|
||||
flag.Usage = func() {
|
||||
fmt.Fprintf(os.Stderr, "%s [options] <source_objpath> <dest_dataset>\n", os.Args[0])
|
||||
fmt.Fprintf(os.Stderr, "%s [options] <source-object> <dest-dataset>\n", os.Args[0])
|
||||
flag.PrintDefaults()
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ func main() {
|
||||
flag.Parse()
|
||||
|
||||
if flag.NArg() != 2 {
|
||||
util.CheckError(errors.New("expected a sourceObject and destSpec"))
|
||||
util.CheckError(errors.New("expected a source object and destination dataset"))
|
||||
}
|
||||
|
||||
sourceSpec, err := flags.ParsePathSpec(flag.Arg(0))
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/attic-labs/noms/chunks"
|
||||
"github.com/attic-labs/noms/clients/test_util"
|
||||
"github.com/attic-labs/noms/clients/go/test_util"
|
||||
"github.com/attic-labs/noms/datas"
|
||||
"github.com/attic-labs/noms/dataset"
|
||||
"github.com/attic-labs/noms/types"
|
||||
@@ -3,7 +3,7 @@ package test_util
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/attic-labs/noms/clients/util"
|
||||
"github.com/attic-labs/noms/clients/go/util"
|
||||
"github.com/attic-labs/noms/types"
|
||||
"github.com/stretchr/testify/suite"
|
||||
)
|
||||
@@ -10,8 +10,8 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/attic-labs/noms/clients/flags"
|
||||
"github.com/attic-labs/noms/clients/util"
|
||||
"github.com/attic-labs/noms/clients/go/flags"
|
||||
"github.com/attic-labs/noms/clients/go/util"
|
||||
"github.com/attic-labs/noms/d"
|
||||
"github.com/attic-labs/noms/datas"
|
||||
"github.com/attic-labs/noms/types"
|
||||
@@ -11,8 +11,8 @@ import (
|
||||
"sort"
|
||||
"sync"
|
||||
|
||||
"github.com/attic-labs/noms/clients/flags"
|
||||
"github.com/attic-labs/noms/clients/util"
|
||||
"github.com/attic-labs/noms/clients/go/flags"
|
||||
"github.com/attic-labs/noms/clients/go/util"
|
||||
"github.com/attic-labs/noms/d"
|
||||
"github.com/attic-labs/noms/types"
|
||||
"github.com/clbanning/mxj"
|
||||
1
clients/js/bar-chart/.flowconfig
Symbolic link
1
clients/js/bar-chart/.flowconfig
Symbolic link
@@ -0,0 +1 @@
|
||||
../../../js/.flowconfig
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "noms-plotly-bar-chart",
|
||||
"name": "noms-bar-chart",
|
||||
"devDependencies": {
|
||||
"@attic/eslintrc": "^1.0.0",
|
||||
"@attic/noms": "^24.0.0",
|
||||
|
Before Width: | Height: | Size: 161 KiB After Width: | Height: | Size: 161 KiB |
1
clients/js/fs/.flowconfig
Symbolic link
1
clients/js/fs/.flowconfig
Symbolic link
@@ -0,0 +1 @@
|
||||
../../../js/.flowconfig
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"name": "directory-import",
|
||||
"name": "noms-fs",
|
||||
"main": "dist/main.js",
|
||||
"dependencies": {
|
||||
"@attic/noms": "^24.0.0",
|
||||
"babel-regenerator-runtime": "6.5.0",
|
||||
1
clients/js/fs/src/.babelrc
Symbolic link
1
clients/js/fs/src/.babelrc
Symbolic link
@@ -0,0 +1 @@
|
||||
../../../../js/.babelrc
|
||||
@@ -8,19 +8,19 @@ Splore is a general-purpose debug UI for exploring noms data.
|
||||
|
||||
```
|
||||
# Create some data
|
||||
cd "$GOPATH/src/github.com/attic-labs/noms/clients/counter"
|
||||
cd "$GOPATH/src/github.com/attic-labs/noms/clients/go/counter"
|
||||
go build
|
||||
./counter -ldb="/tmp/sploretest" -ds="counter"
|
||||
./counter -ldb="/tmp/sploretest" -ds="counter"
|
||||
./counter ldb:/tmp/sploretest:counter
|
||||
./counter ldb:/tmp/sploretest:counter
|
||||
|
||||
# Build Splore
|
||||
cd ../splore
|
||||
cd ../../js/splore
|
||||
./build.py
|
||||
|
||||
# Launch Splore with noms-view
|
||||
cd ../../cmd/noms-view
|
||||
cd ../../../cmd/noms-view
|
||||
go build
|
||||
./noms-view serve ../../clients/splore store="ldb:/tmp/sploretest" &
|
||||
./noms-view serve ../../clients/js/splore store="ldb:/tmp/sploretest"
|
||||
```
|
||||
|
||||
Then, navigate to the URL printed by noms-view, e.g. http://127.0.0.1:12345?store=xyz.
|
||||
@@ -2,13 +2,13 @@
|
||||
|
||||
import os, os.path, subprocess, sys
|
||||
|
||||
sys.path.append(os.path.abspath('../../tools'))
|
||||
sys.path.append(os.path.abspath('../../../tools'))
|
||||
|
||||
import noms.symlink as symlink
|
||||
|
||||
def main():
|
||||
symlink.Force('../../js/.babelrc', os.path.abspath('.babelrc'))
|
||||
symlink.Force('../../js/.flowconfig', os.path.abspath('.flowconfig'))
|
||||
symlink.Force('../../../js/.babelrc', os.path.abspath('.babelrc'))
|
||||
symlink.Force('../../../js/.flowconfig', os.path.abspath('.flowconfig'))
|
||||
|
||||
subprocess.check_call(['npm', 'install'], shell=False)
|
||||
subprocess.check_call(['npm', 'run', 'build'], env=os.environ, shell=False)
|
||||
|
Before Width: | Height: | Size: 43 KiB After Width: | Height: | Size: 43 KiB |
1
clients/js/struct-by-name/.flowconfig
Symbolic link
1
clients/js/struct-by-name/.flowconfig
Symbolic link
@@ -0,0 +1 @@
|
||||
../../../js/.flowconfig
|
||||
@@ -2,7 +2,7 @@
|
||||
"name": "noms-struct-by-name",
|
||||
"main": "dist/main.js",
|
||||
"dependencies": {
|
||||
"@attic/noms": "file:../../js",
|
||||
"@attic/noms": "^24.0.0",
|
||||
"babel-regenerator-runtime": "6.5.0",
|
||||
"yargs": "4.4.0"
|
||||
},
|
||||
1
clients/js/struct-by-name/src/.babelrc
Symbolic link
1
clients/js/struct-by-name/src/.babelrc
Symbolic link
@@ -0,0 +1 @@
|
||||
../../../../js/.babelrc
|
||||
@@ -1 +0,0 @@
|
||||
../../js/.babelrc
|
||||
@@ -1 +0,0 @@
|
||||
../../js/.flowconfig
|
||||
@@ -1,30 +0,0 @@
|
||||
# Shove
|
||||
|
||||
Shove syncs between datastores and datasets. It is the noms equivalent of Git's `push` and `pull` commands.
|
||||
|
||||
## Example
|
||||
|
||||
```
|
||||
cd $GOPATH/src/github.com/attic-labs/noms/clients/counter
|
||||
go build
|
||||
./counter -ldb="/tmp/shovetest1" -ds="counter"
|
||||
./counter -ldb="/tmp/shovetest1" -ds="counter"
|
||||
./counter -ldb="/tmp/shovetest1" -ds="counter"
|
||||
|
||||
cd ../shove
|
||||
go build
|
||||
./shove -source-ldb="/tmp/shovetest1" -source="counter" -sink-ldb="/tmp/shovetest2" -sink-ds="counter2"
|
||||
../counter/counter -ldb="/tmp/shovetest2" -ds="counter2"
|
||||
|
||||
# Shove can also connect to http datastores
|
||||
cd ../server
|
||||
go build
|
||||
./server -ldb="/tmp/shovetest2" &
|
||||
|
||||
../shove/shove -source-h="http://localhost:8000" -source="counter2" -sink-ldb="/tmp/shovetest3" -sink-ds="counter3"
|
||||
../counter/counter -ldb="/tmp/shovetest3" -ds="counter3"
|
||||
```
|
||||
|
||||
## Sample data
|
||||
|
||||
There are currently a small collection of datasets you can sync available at `-h="ds.noms.io"`. You can browse them at [http://splore.noms.io](http://splore.noms.io) (username: attic, password: labs).
|
||||
@@ -1 +0,0 @@
|
||||
module.exports = require('@attic/eslintrc');
|
||||
@@ -1 +0,0 @@
|
||||
../../js/.flowconfig
|
||||
@@ -1 +0,0 @@
|
||||
../../../js/.babelrc
|
||||
@@ -1 +0,0 @@
|
||||
../../js/.flowconfig
|
||||
2
clients/url_fetch/.gitignore
vendored
2
clients/url_fetch/.gitignore
vendored
@@ -1,2 +0,0 @@
|
||||
node_modules
|
||||
dist
|
||||
@@ -1,33 +0,0 @@
|
||||
{
|
||||
"name": "noms-url-fetch",
|
||||
"dependencies": {
|
||||
"@attic/noms": "^24.0.0",
|
||||
"babel-regenerator-runtime": "6.5.0",
|
||||
"humanize": "0.0.9",
|
||||
"yargs": "4.4.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@attic/eslintrc": "^1.0.0",
|
||||
"babel-cli": "6.6.5",
|
||||
"babel-core": "6.7.2",
|
||||
"babel-generator": "6.7.2",
|
||||
"babel-plugin-syntax-async-functions": "6.5.0",
|
||||
"babel-plugin-syntax-flow": "6.5.0",
|
||||
"babel-plugin-transform-async-to-generator": "6.7.0",
|
||||
"babel-plugin-transform-class-properties": "6.6.0",
|
||||
"babel-plugin-transform-es2015-destructuring": "6.6.5",
|
||||
"babel-plugin-transform-es2015-modules-commonjs": "6.7.0",
|
||||
"babel-plugin-transform-es2015-parameters": "6.7.0",
|
||||
"babel-plugin-transform-runtime": "^6.6.0",
|
||||
"babel-preset-es2015": "6.6.0",
|
||||
"babel-preset-react": "6.5.0",
|
||||
"chai": "3.5.0",
|
||||
"flow-bin": "^0.24.1",
|
||||
"mocha": "2.4.5"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "babel -d dist -w src",
|
||||
"build": "babel -d dist src",
|
||||
"test": "eslint src/ && flow src/"
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
../../../js/.babelrc
|
||||
@@ -1,3 +0,0 @@
|
||||
module.exports = require('@attic/eslintrc');
|
||||
// Allow console
|
||||
module.exports.rules['no-console'] = 0;
|
||||
@@ -1,105 +0,0 @@
|
||||
// @flow
|
||||
|
||||
import argv from 'yargs';
|
||||
import http from 'http';
|
||||
import humanize from 'humanize';
|
||||
import {
|
||||
BlobWriter,
|
||||
DatasetSpec,
|
||||
invariant,
|
||||
NomsBlob,
|
||||
} from '@attic/noms';
|
||||
|
||||
const args = argv
|
||||
.usage('Usage: $0 <url> <dataset>')
|
||||
.command('url', 'url to import')
|
||||
.command('dataset', 'dataset spec to write to')
|
||||
.demand(2)
|
||||
.argv;
|
||||
|
||||
const clearLine = '\x1b[2K\r';
|
||||
const startTime = Date.now();
|
||||
|
||||
let expectedBytes = 0;
|
||||
let expectedBytesHuman = '';
|
||||
let completedBytes = 0;
|
||||
|
||||
main().catch(ex => {
|
||||
console.error(ex.stack);
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
function main(): Promise<void> {
|
||||
const [url, datasetSpec] = parseArgs();
|
||||
if (!url) {
|
||||
process.exit(1);
|
||||
return Promise.resolve();
|
||||
}
|
||||
if (!datasetSpec) {
|
||||
process.stderr.write('invalid dataset spec');
|
||||
process.exit(1);
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
const ds = datasetSpec.set();
|
||||
|
||||
return getBlob(url)
|
||||
.then(b => ds.commit(b))
|
||||
.then(() => {
|
||||
process.stderr.write(clearLine + 'Done\n');
|
||||
});
|
||||
}
|
||||
|
||||
function getBlob(url): Promise<NomsBlob> {
|
||||
const w = new BlobWriter();
|
||||
|
||||
return new Promise(resolve => {
|
||||
http.get(url, res => {
|
||||
switch (Math.floor(res.statusCode / 100)) {
|
||||
case 4:
|
||||
case 5:
|
||||
invariant(res.statusMessage);
|
||||
process.stderr.write(`Error fetching ${url}: ${res.statusCode}: ${res.statusMessage}\n`);
|
||||
process.exit(1);
|
||||
break;
|
||||
}
|
||||
|
||||
process.stdout.write(clearLine + `got ${res.statusCode}, continuing...\n`);
|
||||
|
||||
const header = res.headers['content-length'];
|
||||
if (header) {
|
||||
expectedBytes = Number(header);
|
||||
expectedBytesHuman = humanize.filesize(expectedBytes);
|
||||
} else {
|
||||
expectedBytesHuman = '(unknown)';
|
||||
}
|
||||
|
||||
res.on('error', e => {
|
||||
process.stderr.write(`Error fetching ${url}: ${e.message}`);
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
res.on('data', chunk => {
|
||||
w.write(chunk);
|
||||
completedBytes += chunk.length;
|
||||
const elapsed = (Date.now() - startTime) / 1000;
|
||||
const rate = humanize.filesize(completedBytes / elapsed);
|
||||
process.stdout.write(clearLine + `${humanize.filesize(completedBytes)} of ` +
|
||||
`${expectedBytesHuman} written in ${elapsed}s (${rate}/s)`);
|
||||
});
|
||||
|
||||
res.on('end', () => {
|
||||
process.stdout.write(clearLine + 'Committing...');
|
||||
w.close()
|
||||
.then(() => resolve(w.blob));
|
||||
});
|
||||
|
||||
res.resume();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function parseArgs(): [string, ?DatasetSpec] {
|
||||
const [url, datasetSpec] = args._;
|
||||
return [url, DatasetSpec.parse(datasetSpec)];
|
||||
}
|
||||
@@ -7,8 +7,8 @@ import (
|
||||
"os"
|
||||
"path"
|
||||
|
||||
"github.com/attic-labs/noms/clients/flags"
|
||||
"github.com/attic-labs/noms/clients/util"
|
||||
"github.com/attic-labs/noms/clients/go/flags"
|
||||
"github.com/attic-labs/noms/clients/go/util"
|
||||
"github.com/attic-labs/noms/types"
|
||||
)
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@ import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/attic-labs/noms/clients/flags"
|
||||
"github.com/attic-labs/noms/clients/test_util"
|
||||
"github.com/attic-labs/noms/clients/go/flags"
|
||||
"github.com/attic-labs/noms/clients/go/test_util"
|
||||
"github.com/attic-labs/noms/d"
|
||||
"github.com/attic-labs/noms/dataset"
|
||||
"github.com/attic-labs/noms/types"
|
||||
|
||||
@@ -13,5 +13,5 @@ Examples:
|
||||
## serve
|
||||
|
||||
```
|
||||
./noms-view serve ../../clients/splore store=ldb:/tmp/picasa
|
||||
./noms-view serve ../../clients/js/splore store=ldb:/tmp/picasa
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user