diff --git a/.golangci.yaml b/.golangci.yaml index 805bfc3..9413538 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -1,3 +1,5 @@ +run: + timeout: 3m linters: enable-all: true disable: diff --git a/.goreleaser.yaml b/.goreleaser.yaml index e46d313..e585705 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -9,6 +9,8 @@ builds: - amd64 - arm64 binary: tigris + flags: + - -tags=release,tigris_grpc,tigris_http ldflags: - -w -extldflags '-static' - -X 'github.com/tigrisdata/tigris-cli/util.Version={{.Version}}' diff --git a/Makefile b/Makefile index afe59d7..e31a148 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ ${BIN}: ${GO_SRC} go.sum CGO_ENABLED=0 go build ${BUILD_PARAM} . lint: - golangci-lint run --timeout=3m --fix + golangci-lint run --fix shellcheck tests/*.sh cd pkg/npm && TIGRIS_SKIP_VERIFY=1 npm i; npx eslint install.js git checkout pkg/npm/bin/tigris # lints above overwrites placeholder with real binary diff --git a/README.md b/README.md index 89cf859..12e05e5 100644 --- a/README.md +++ b/README.md @@ -2,13 +2,16 @@ [![Build Status](https://github.com/tigrisdata/tigrisdb/workflows/go-lint/badge.svg)]() [![Build Status](https://github.com/tigrisdata/tigrisdb/workflows/go-test/badge.svg)]() +[![Go Report Card](https://goreportcard.com/badge/github.com/tigrisdata/tigris-cli)](https://goreportcard.com/report/github.com/tigrisdata/tigris-cli) + +[![NPM](https://img.shields.io/npm/v/@tigrisdata/tigris-cli)](https://www.npmjs.com/package/@tigrisdata/tigris-cli) +[![tigris](https://snapcraft.io/tigris/badge.svg)](https://snapcraft.io/tigris) Create databases and collections, read and write data, perform transactions, stream events and setup Tigris locally, all from the command line. # Documentation -- [Quickstart](https://docs.tigrisdata.com/quickstart/with-cli) - [Working Locally](https://docs.tigrisdata.com/cli/working-locally) - [Command Reference](https://docs.tigrisdata.com/cli) @@ -72,6 +75,7 @@ Available Commands: help Help about any command import Import documents into collection insert Inserts document(s) + invitation Invitation management commands list Lists projects, collections or namespaces login Authenticate on the Tigris instance logout Logout from Tigris instance diff --git a/cmd/collection.go b/cmd/collection.go index 955e3d8..0abe835 100644 --- a/cmd/collection.go +++ b/cmd/collection.go @@ -111,7 +111,7 @@ var createCollectionCmd = &cobra.Command{ Long: "Creates collections with provided schema.", Example: fmt.Sprintf(` # Pass the schema as a string - %[1]s create collection --project=testdb '{ + %[1]s create collection --project=myproj '{ "title": "users", "description": "Collection of documents with details of users", "properties": { @@ -150,11 +150,11 @@ var createCollectionCmd = &cobra.Command{ # "id" # ] # } - %[1]s create collection --project=testdb { const hash = crypto.createHash('sha256').setEncoding('hex'); res.body.pipe(hash).on('end', () => { hash.end(); }); - res.body - .pipe( - tar.x( - { - C: opts.binPath, - }, - ['tigris'], - ), - ) - .on('end', () => { - verifyAndPlaceBinary( - opts.binName, - opts.binPath, - hash.read(), - opts.checksums, - callback, - ); - }); + + const handleExtractComplete = () => { + verifyAndPlaceBinary( + opts.binName, + opts.binPath, + hash.read(), + opts.checksums, + callback, + ); + }; + + if (IS_WINDOWS) { + // Numerous unzip Node stream supporting solutions were tried. + // However, none seem to unzip the .exe in a usable format. + // Therefore, saving to disk and then using a trusted unzipper + // that doesn't support streams to extract. + const tmpZip = path.join(opts.binPath, 'tigris-tmp.zip'); + res.body + .pipe(fs.createWriteStream(tmpZip)) + .on('finish', () => { + const zip = new AdmZip(tmpZip); + zip.extractAllTo(opts.binPath, true); + fs.unlinkSync(tmpZip); + + handleExtractComplete(); + }); + } else { + res.body.pipe(tar.x( + { + C: opts.binPath, + }, + ['tigris'], + )).on('end', handleExtractComplete); + } }); return null; diff --git a/pkg/npm/package.json b/pkg/npm/package.json index 396b07d..3cde6cf 100644 --- a/pkg/npm/package.json +++ b/pkg/npm/package.json @@ -35,6 +35,7 @@ ], "homepage": "https://www.tigrisdata.com", "dependencies": { + "adm-zip": "^0.5.10", "mkdirp": "^1.0.4", "node-fetch": "^2.6.7", "tar": "^6.1.12" diff --git a/pkg/snap/snapcraft.yaml b/pkg/snap/snapcraft.yaml index 820d3aa..7cd67eb 100644 --- a/pkg/snap/snapcraft.yaml +++ b/pkg/snap/snapcraft.yaml @@ -14,7 +14,7 @@ name: tigris base: core20 -version: '1.0.0-beta' +version: '1.0.0' summary: "Tigris command line tool" description: Tigris is a modern, scalable backend for building real-time websites and apps. @@ -33,7 +33,7 @@ apps: parts: tigris-cli: source: https://github.com/tigrisdata/tigris-cli.git - source-branch: beta + source-branch: release plugin: make build-snaps: - go diff --git a/tests/main.sh b/tests/main.sh index 4144d99..a9b4f50 100644 --- a/tests/main.sh +++ b/tests/main.sh @@ -64,10 +64,6 @@ export TIGRIS_URL="localhost:$TIGRIS_TEST_PORT" $cli server info $cli server version -if [ "$OS" == 'Darwin' ]; then - export TIGRIS_TIMEOUT=35s -fi - test_config() { export TIGRIS_CLIENT_ID=test_id_1 export TIGRIS_CLIENT_SECRET=test_secret_1 @@ -432,6 +428,10 @@ source "$BASEDIR/search/import.sh" main() { test_config + if [ "$OS" == 'Darwin' ]; then + export TIGRIS_TIMEOUT=35s + fi + # Exercise tests via HTTP unset TIGRIS_PROTOCOL export TIGRIS_URL="localhost:$TIGRIS_TEST_PORT"