@zerops/zcli 0.25.10 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +12 -7
- package/{tools/npm → utils}/binary.js +8 -5
- package/.github/workflows/master.yml +0 -36
- package/.github/workflows/tag.yml +0 -69
- package/.golangci.yaml +0 -58
- package/LICENSE +0 -1
- package/README.md +0 -2
- package/bin/.gitignore +0 -2
- package/tools/gomodrun.go +0 -60
- package/tools/install.sh +0 -40
- /package/{tools/npm → utils}/install.js +0 -0
- /package/{tools/npm → utils}/run.js +0 -0
- /package/{tools/npm → utils}/uninstall.js +0 -0
package/package.json
CHANGED
|
@@ -1,22 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zerops/zcli",
|
|
3
|
-
"version": "
|
|
4
|
-
"main": "./
|
|
3
|
+
"version": "v1.0.2",
|
|
4
|
+
"main": "./utils/binary.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"private": false,
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"binary-install": "
|
|
8
|
+
"@cloudflare/binary-install": "0.2.0",
|
|
9
|
+
"@octokit/core": "3.5.1",
|
|
9
10
|
"actions-toolkit": "^2.2.0",
|
|
10
11
|
"yargs": "^15.3.1"
|
|
11
12
|
},
|
|
12
13
|
"devDependencies": {
|
|
13
|
-
"standard": "^
|
|
14
|
+
"standard": "^16.0.4"
|
|
14
15
|
},
|
|
15
16
|
"bin": {
|
|
16
|
-
"zcli": "
|
|
17
|
+
"zcli": "utils/run.js"
|
|
17
18
|
},
|
|
19
|
+
"files": [
|
|
20
|
+
"/utils",
|
|
21
|
+
"package.json"
|
|
22
|
+
],
|
|
18
23
|
"scripts": {
|
|
19
|
-
"postinstall": "./
|
|
20
|
-
"preuninstall": "./
|
|
24
|
+
"postinstall": "node ./utils/install.js",
|
|
25
|
+
"preuninstall": "node ./utils/uninstall.js"
|
|
21
26
|
}
|
|
22
27
|
}
|
|
@@ -1,24 +1,27 @@
|
|
|
1
|
-
const { Binary } = require("binary-install");
|
|
1
|
+
const { Binary } = require("@cloudflare/binary-install");
|
|
2
2
|
const os = require("os");
|
|
3
3
|
|
|
4
4
|
function getPlatform() {
|
|
5
5
|
const type = os.type();
|
|
6
6
|
const arch = os.arch();
|
|
7
|
-
|
|
8
7
|
if (type === "Linux" && arch === "x64") return "linux-amd64";
|
|
9
8
|
if (type === "Linux" && arch === "x86") return "linux-i386";
|
|
10
9
|
if (type === "Darwin" && arch === "x64") return "darwin-amd64";
|
|
11
|
-
|
|
10
|
+
if (type === "Darwin" && arch === "arm64") return "darwin-arm64";
|
|
11
|
+
if (type === "Windows_NT" && arch === "x64") return "win-x64.exe";
|
|
12
12
|
throw new Error(`Unsupported platform: ${type} ${arch}`);
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
function getBinary() {
|
|
16
16
|
const platform_arch = getPlatform();
|
|
17
|
-
const version = require("
|
|
18
|
-
const
|
|
17
|
+
const version = require("../package.json").version;
|
|
18
|
+
const compatibleVersion = version.startsWith('v') ? version : `v${version}`;
|
|
19
|
+
const url = `https://github.com/zeropsio/zcli/releases/download/${compatibleVersion}/zcli-${platform_arch}-npm.tar.gz`;
|
|
19
20
|
const name = `zcli-${platform_arch}`;
|
|
21
|
+
|
|
20
22
|
return new Binary(url, { name });
|
|
21
23
|
}
|
|
24
|
+
|
|
22
25
|
const run = () => {
|
|
23
26
|
const binary = getBinary();
|
|
24
27
|
binary.run();
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
name: Master
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches: [ master ]
|
|
6
|
-
pull_request:
|
|
7
|
-
branches: [ master ]
|
|
8
|
-
|
|
9
|
-
jobs:
|
|
10
|
-
|
|
11
|
-
build:
|
|
12
|
-
name: Build
|
|
13
|
-
runs-on: ubuntu-latest
|
|
14
|
-
steps:
|
|
15
|
-
|
|
16
|
-
- name: Set up Go 1.x
|
|
17
|
-
uses: actions/setup-go@v2
|
|
18
|
-
with:
|
|
19
|
-
go-version: ^1.14
|
|
20
|
-
id: go
|
|
21
|
-
|
|
22
|
-
- name: Check out code into the Go module directory
|
|
23
|
-
uses: actions/checkout@v2
|
|
24
|
-
|
|
25
|
-
- name: Get dependencies
|
|
26
|
-
run: |
|
|
27
|
-
export GOPATH=$HOME/go
|
|
28
|
-
./tools/install.sh
|
|
29
|
-
|
|
30
|
-
- name: Build
|
|
31
|
-
run: go build -v .
|
|
32
|
-
|
|
33
|
-
- name: Test
|
|
34
|
-
run: go test -v .
|
|
35
|
-
|
|
36
|
-
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
name: Upload build asset
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
release:
|
|
5
|
-
types: [published]
|
|
6
|
-
|
|
7
|
-
jobs:
|
|
8
|
-
build:
|
|
9
|
-
name: Upload build asset for ${{ matrix.os }}
|
|
10
|
-
runs-on: ${{ matrix.os }}
|
|
11
|
-
strategy:
|
|
12
|
-
matrix:
|
|
13
|
-
include:
|
|
14
|
-
- os: ubuntu-latest
|
|
15
|
-
buildCmd: env GOOS=linux GOARCH=amd64 go build -o zcli-linux-amd64 ./main.go && tar -czvf zcli-linux-amd64.tar.gz zcli-linux-amd64
|
|
16
|
-
file: zcli-linux-amd64
|
|
17
|
-
args:
|
|
18
|
-
strip: true
|
|
19
|
-
- os: macos-latest
|
|
20
|
-
buildCmd: env GOOS=darwin GOARCH=amd64 go build -o zcli-darwin-amd64 ./main.go && tar -czvf zcli-darwin-amd64.tar.gz zcli-darwin-amd64
|
|
21
|
-
file: zcli-darwin-amd64
|
|
22
|
-
args:
|
|
23
|
-
strip: false
|
|
24
|
-
|
|
25
|
-
steps:
|
|
26
|
-
|
|
27
|
-
- name: Checkout code
|
|
28
|
-
uses: actions/checkout@v2
|
|
29
|
-
|
|
30
|
-
- name: Get dependencies
|
|
31
|
-
run: |
|
|
32
|
-
export GOPATH=$HOME/go
|
|
33
|
-
./tools/install.sh
|
|
34
|
-
|
|
35
|
-
- name: Build
|
|
36
|
-
run: ${{ matrix.buildCmd }}
|
|
37
|
-
|
|
38
|
-
- name: Compress binary
|
|
39
|
-
uses: svenstaro/upx-action@v1-release
|
|
40
|
-
with:
|
|
41
|
-
file: ./${{ matrix.file }}
|
|
42
|
-
args: ${{ matrix.args }}
|
|
43
|
-
strip: ${{ matrix.strip }}
|
|
44
|
-
|
|
45
|
-
- name: Upload asset
|
|
46
|
-
uses: actions/upload-release-asset@v1
|
|
47
|
-
env:
|
|
48
|
-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
49
|
-
with:
|
|
50
|
-
upload_url: ${{ github.event.release.upload_url }}
|
|
51
|
-
asset_path: ./${{ matrix.file }}
|
|
52
|
-
asset_name: ${{ matrix.file }}
|
|
53
|
-
asset_content_type: application/octet-stream
|
|
54
|
-
|
|
55
|
-
publish-npm:
|
|
56
|
-
needs: build
|
|
57
|
-
runs-on: ubuntu-latest
|
|
58
|
-
steps:
|
|
59
|
-
- uses: actions/checkout@v2
|
|
60
|
-
- uses: actions/setup-node@v1
|
|
61
|
-
with:
|
|
62
|
-
node-version: 12
|
|
63
|
-
registry-url: https://registry.npmjs.org/
|
|
64
|
-
- run: npm ci --ignore-scripts
|
|
65
|
-
- run: npm i -g replace-in-files-cli
|
|
66
|
-
- run: replace-in-files --string='v0.0.0-zerops' --replacement='${{ github.event.release.tag_name }}' package.json
|
|
67
|
-
- run: npm publish --access=public
|
|
68
|
-
env:
|
|
69
|
-
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
|
package/.golangci.yaml
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
concurrency: 16
|
|
2
|
-
run:
|
|
3
|
-
deadline: 10m
|
|
4
|
-
issues-exit-code: 1
|
|
5
|
-
tests: true
|
|
6
|
-
|
|
7
|
-
output:
|
|
8
|
-
format: colored-line-number
|
|
9
|
-
|
|
10
|
-
linters-settings:
|
|
11
|
-
gocritic:
|
|
12
|
-
disabled-checks:
|
|
13
|
-
- captLocal # CIDR, IpV6, ....
|
|
14
|
-
- unlambda # falsePositive for function passed to defer
|
|
15
|
-
godox:
|
|
16
|
-
keywords:
|
|
17
|
-
- FIXME
|
|
18
|
-
|
|
19
|
-
issues:
|
|
20
|
-
max-same-issues: 0
|
|
21
|
-
|
|
22
|
-
exclude-rules:
|
|
23
|
-
|
|
24
|
-
# Exclude some staticcheck messages
|
|
25
|
-
- linters:
|
|
26
|
-
- staticcheck
|
|
27
|
-
text: "SA4004:" #https://staticcheck.io/docs/checks#SA4004 The loop exits unconditionally after one iteration
|
|
28
|
-
|
|
29
|
-
linters:
|
|
30
|
-
enable:
|
|
31
|
-
- scopelint
|
|
32
|
-
- govet
|
|
33
|
-
- ineffassign
|
|
34
|
-
- varcheck
|
|
35
|
-
- unused
|
|
36
|
-
- deadcode
|
|
37
|
-
- bodyclose
|
|
38
|
-
- structcheck
|
|
39
|
-
- staticcheck
|
|
40
|
-
- godox
|
|
41
|
-
|
|
42
|
-
# high priority
|
|
43
|
-
# - rowserrcheck
|
|
44
|
-
# - errcheck
|
|
45
|
-
|
|
46
|
-
# normal priority
|
|
47
|
-
# - prealloc - jednotky
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
# low priority
|
|
51
|
-
# - gosimple
|
|
52
|
-
# - gosec
|
|
53
|
-
# - goconst
|
|
54
|
-
# - gocritic
|
|
55
|
-
# - nakedret
|
|
56
|
-
|
|
57
|
-
disable-all: true
|
|
58
|
-
fast: false
|
package/LICENSE
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
TODO
|
package/README.md
DELETED
package/bin/.gitignore
DELETED
package/tools/gomodrun.go
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
package main
|
|
2
|
-
|
|
3
|
-
import (
|
|
4
|
-
"fmt"
|
|
5
|
-
"log"
|
|
6
|
-
"os"
|
|
7
|
-
"os/exec"
|
|
8
|
-
"path"
|
|
9
|
-
)
|
|
10
|
-
|
|
11
|
-
func getMod(dir string) (string, error) {
|
|
12
|
-
if _, err := os.Stat(path.Join(dir, "go.mod")); err == nil {
|
|
13
|
-
return dir, nil
|
|
14
|
-
}
|
|
15
|
-
newDir := path.Dir(dir)
|
|
16
|
-
if newDir != "" {
|
|
17
|
-
return getMod(newDir)
|
|
18
|
-
}
|
|
19
|
-
return "", fmt.Errorf("go.mod not found")
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
func main() {
|
|
23
|
-
wd, err := os.Getwd()
|
|
24
|
-
if err != nil {
|
|
25
|
-
log.Fatal(err)
|
|
26
|
-
}
|
|
27
|
-
modDir, err := getMod(wd)
|
|
28
|
-
if err != nil {
|
|
29
|
-
log.Fatal(err)
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if len(os.Args) < 2 {
|
|
33
|
-
log.Fatal("executable not defined")
|
|
34
|
-
return
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
bin := os.Args[1]
|
|
38
|
-
if !path.IsAbs(bin) {
|
|
39
|
-
bin = path.Join(modDir, "bin", bin)
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if err := os.Setenv("PATH", path.Join(modDir, "bin")+":"+os.Getenv("PATH")); err != nil {
|
|
43
|
-
log.Fatal(err)
|
|
44
|
-
return
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
cmd := &exec.Cmd{
|
|
48
|
-
Path: bin,
|
|
49
|
-
Dir: wd,
|
|
50
|
-
Stdout: os.Stdout,
|
|
51
|
-
Stdin: os.Stdin,
|
|
52
|
-
Stderr: os.Stderr,
|
|
53
|
-
Args: os.Args[1:],
|
|
54
|
-
Env: os.Environ(),
|
|
55
|
-
}
|
|
56
|
-
if err := cmd.Run(); err != nil {
|
|
57
|
-
log.Fatal(err)
|
|
58
|
-
}
|
|
59
|
-
os.Exit(0)
|
|
60
|
-
}
|
package/tools/install.sh
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
cd `dirname $0`
|
|
4
|
-
|
|
5
|
-
set -e
|
|
6
|
-
|
|
7
|
-
cd ..
|
|
8
|
-
export GOBIN=$GOPATH/bin
|
|
9
|
-
export PATH=$GOBIN:$PATH
|
|
10
|
-
|
|
11
|
-
[[ ! -d "${GOBIN}" ]] && mkdir -p "${GOBIN}"
|
|
12
|
-
|
|
13
|
-
go install tools/gomodrun.go
|
|
14
|
-
|
|
15
|
-
export GOBIN=$PWD/bin
|
|
16
|
-
export PATH="${GOBIN}:${PATH}"
|
|
17
|
-
|
|
18
|
-
echo "GOBIN=${GOBIN}"
|
|
19
|
-
|
|
20
|
-
go install github.com/golang/protobuf/protoc-gen-go/...
|
|
21
|
-
|
|
22
|
-
[[ -f protoc.zip ]] && rm protoc.zip
|
|
23
|
-
[[ -f bin/protoc ]] && rm bin/protoc
|
|
24
|
-
[[ -d tmp ]] && rm -rf tmp
|
|
25
|
-
mkdir tmp
|
|
26
|
-
cd tmp
|
|
27
|
-
if [[ "$OSTYPE" == "darwin"* ]]; then
|
|
28
|
-
wget -O protoc.zip https://github.com/protocolbuffers/protobuf/releases/download/v3.7.1/protoc-3.7.1-osx-x86_64.zip
|
|
29
|
-
else
|
|
30
|
-
wget -O protoc.zip https://github.com/protocolbuffers/protobuf/releases/download/v3.7.1/protoc-3.7.1-linux-x86_64.zip
|
|
31
|
-
fi
|
|
32
|
-
ls -la protoc.zip
|
|
33
|
-
unzip protoc.zip
|
|
34
|
-
mv bin/protoc ../bin
|
|
35
|
-
cd ..
|
|
36
|
-
rm -rf tmp
|
|
37
|
-
chmod +x bin/protoc
|
|
38
|
-
|
|
39
|
-
# https://github.com/golangci/golangci-lint#go Please, do not install golangci-lint by go get
|
|
40
|
-
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b "$GOBIN" v1.23.8
|
|
File without changes
|
|
File without changes
|
|
File without changes
|