├── .all-contributorsrc ├── .circleci └── config.yml ├── .drone.yml ├── .github ├── .markdownlint.yml ├── .yamllint └── workflows │ └── lint.yml ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── cmd ├── install │ └── main.go ├── purge │ └── main.go ├── root.go ├── search │ └── main.go ├── uninstall │ └── main.go └── update │ └── main.go ├── config.toml ├── go.mod ├── go.sum ├── lint-local.sh ├── main.go ├── revive.sh └── runner ├── console.go ├── exec.go ├── runner.go └── runner_test.go /.all-contributorsrc: -------------------------------------------------------------------------------- 1 | { 2 | "files": [ 3 | "README.md" 4 | ], 5 | "imageSize": 100, 6 | "commit": false, 7 | "contributors": [ 8 | { 9 | "login": "BaseMax", 10 | "name": "Max Base", 11 | "avatar_url": "https://avatars.githubusercontent.com/u/2658040?v=4", 12 | "profile": "https://maxbase.org/", 13 | "contributions": [ 14 | "code" 15 | ] 16 | }, 17 | { 18 | "login": "jbampton", 19 | "name": "John Bampton", 20 | "avatar_url": "https://avatars.githubusercontent.com/u/418747?v=4", 21 | "profile": "https://github.com/jbampton", 22 | "contributions": [ 23 | "code" 24 | ] 25 | }, 26 | { 27 | "login": "1995parham", 28 | "name": "Parham Alvani", 29 | "avatar_url": "https://avatars.githubusercontent.com/u/8181240?v=4", 30 | "profile": "https://1995parham.me", 31 | "contributions": [ 32 | "code" 33 | ] 34 | }, 35 | { 36 | "login": "esmaeelE", 37 | "name": "EEC", 38 | "avatar_url": "https://avatars.githubusercontent.com/u/22000310?v=4", 39 | "profile": "https://github.com/esmaeelE", 40 | "contributions": [ 41 | "doc" 42 | ] 43 | }, 44 | { 45 | "login": "amir-shiati", 46 | "name": "Amir", 47 | "avatar_url": "https://avatars.githubusercontent.com/u/47950086?v=4", 48 | "profile": "http://amir-shiati.github.io/", 49 | "contributions": [ 50 | "code" 51 | ] 52 | }, 53 | { 54 | "login": "all-contributors", 55 | "name": "All Contributors", 56 | "avatar_url": "https://avatars.githubusercontent.com/u/46410174?v=4", 57 | "profile": "https://allcontributors.org", 58 | "contributions": [ 59 | "doc" 60 | ] 61 | } 62 | ], 63 | "contributorsPerLine": 7, 64 | "projectName": "PackageManager", 65 | "projectOwner": "DonyaOS", 66 | "repoType": "github", 67 | "repoHost": "https://github.com", 68 | "skipCi": true 69 | } 70 | -------------------------------------------------------------------------------- /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | jobs: 3 | go-lint: 4 | docker: # run the steps with Docker 5 | # CircleCI Go images available at: https://hub.docker.com/r/circleci/golang/ 6 | - image: circleci/golang:1.14 7 | # directory where steps are run. Path must conform to the Go Workspace requirements 8 | working_directory: /go/src/github.com/DonyaOS/PackageManager 9 | steps: 10 | - checkout 11 | - restore_cache: # restores saved cache if no changes are detected since last run 12 | # Read about caching dependencies: https://circleci.com/docs/2.0/caching/ 13 | keys: 14 | - v1-pkg-cache 15 | - run: go get -u github.com/mgechev/revive 16 | - run: 17 | name: 🧹 Run Golang revive lint 18 | command: | 19 | sh ./revive.sh || exit 1 20 | - save_cache: # Store cache in the /go/pkg directory 21 | key: v1-pkg-cache 22 | paths: 23 | - "/go/pkg" 24 | -------------------------------------------------------------------------------- /.drone.yml: -------------------------------------------------------------------------------- 1 | --- 2 | kind: pipeline 3 | name: default 4 | type: docker 5 | 6 | steps: 7 | - name: lint 8 | image: golangci/golangci-lint 9 | commands: 10 | - golangci-lint run --enable-all 11 | - name: test 12 | image: golang 13 | commands: 14 | - go test -v ./... -covermode=atomic -coverprofile=coverage.out 15 | - name: coverage 16 | image: plugins/codecov 17 | settings: 18 | token: 19 | from_secret: codecov_token 20 | files: 21 | - coverage.out 22 | -------------------------------------------------------------------------------- /.github/.markdownlint.yml: -------------------------------------------------------------------------------- 1 | # MD001/heading-increment/header-increment 2 | MD001: false 3 | 4 | # MD013/line-length 5 | MD013: false 6 | 7 | # MD014/commands-show-output 8 | MD014: false 9 | 10 | # MD040/fenced-code-language 11 | MD040: false 12 | -------------------------------------------------------------------------------- /.github/.yamllint: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | extends: default 4 | 5 | rules: 6 | document-start: disable 7 | line-length: 8 | max: 95 9 | truthy: disable 10 | -------------------------------------------------------------------------------- /.github/workflows/lint.yml: -------------------------------------------------------------------------------- 1 | name: Lint 2 | 3 | on: [push, pull_request] 4 | 5 | permissions: # added using https://github.com/step-security/secure-workflows 6 | contents: read 7 | 8 | jobs: 9 | markdownlint: 10 | name: 🧹 Markdown Lint 11 | runs-on: ubuntu-18.04 12 | steps: 13 | - uses: actions/checkout@v2 14 | - name: Use Node.js 15 | uses: actions/setup-node@v1 16 | with: 17 | node-version: '12.x' 18 | - run: npm install -g markdownlint-cli@0.23.2 19 | - run: markdownlint '**/*.md' --ignore node_modules --config .github/.markdownlint.yml 20 | shellcheck: 21 | name: 🧹 Shellcheck 22 | runs-on: ubuntu-latest 23 | steps: 24 | - uses: actions/checkout@v2 25 | - name: Run ShellCheck 26 | uses: ludeeus/action-shellcheck@master 27 | yamllint: 28 | name: 🧹 YAML Lint 29 | runs-on: ubuntu-latest 30 | steps: 31 | - uses: actions/checkout@v1 32 | - name: yaml-lint 33 | uses: ibiqlik/action-yamllint@v1 34 | with: 35 | config_file: .github/.yamllint 36 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, sex characteristics, gender identity and expression, 9 | level of experience, education, socio-economic status, nationality, personal 10 | appearance, race, religion, or sexual identity and orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team at maxbasecode@gmail.com. All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 71 | available at 72 | 73 | [homepage]: https://www.contributor-covenant.org 74 | 75 | For answers to common questions about this code of conduct, see 76 | 77 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | To print your Go environment variables run: 4 | 5 | ``` 6 | go env 7 | ``` 8 | 9 | From the root of this project install the Golang libraries with: 10 | 11 | ``` 12 | go get -u ./... 13 | ``` 14 | 15 | Example run: 16 | 17 | ``` 18 | go run donya.go 19 | ``` 20 | 21 | To build the Go file into an executable for Linux run: 22 | 23 | ``` 24 | go build donya.go 25 | ``` 26 | 27 | And generally for Windows: 28 | 29 | ``` 30 | env GOOS=windows GOARCH=amd64 go build donya.go 31 | ``` 32 | 33 | To see all the platforms run: 34 | 35 | ``` 36 | go tool dist list -json 37 | ``` 38 | 39 | You can install `revive` with: 40 | 41 | ``` 42 | go get -u github.com/mgechev/revive 43 | ``` 44 | 45 | To clean up the `go.sum` file run: 46 | 47 | ``` 48 | go mod tidy 49 | ``` 50 | 51 | - [Go](https://golang.org/) - Go is an open source programming language that makes it easy to build simple, reliable, and efficient software. 52 | - [revive](https://github.com/mgechev/revive) - 🔥 ~6x faster, stricter, configurable, extensible, and beautiful drop-in replacement for golint. 53 | - [Cobra](https://github.com/spf13/cobra) - A Commander for modern Go CLI interactions 54 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Donya Operating system 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Donya Package Manager 2 | 3 | [![All Contributors](https://img.shields.io/badge/all_contributors-6-orange.svg?style=flat-square)](#contributors-) 4 | 5 | 6 | [![MIT License](https://img.shields.io/github/license/DonyaOS/PackageManager?color=brightgreen&style=flat-square)](LICENSE) 7 | [![GitHub Linter Workflow Status](https://img.shields.io/github/workflow/status/DonyaOS/PackageManager/Lint?label=Linter&logo=github&style=flat-square)](#donya-package-manager) 8 | [![IRC chat on freenode](https://img.shields.io/badge/IRC%20chat%20on%20freenode-%23DonyaOS-brightgreen?style=flat-square)](#donya-package-manager) 9 | [![Drone (cloud) with branch](https://img.shields.io/drone/build/DonyaOS/PackageManager/master?logo=drone&style=flat-square)](https://cloud.drone.io/DonyaOS/PackageManager) 10 | 11 | - [Donya or d](#donya-or-d) 12 | - [Donya Package Manager Commands](#donya-package-manager-commands) 13 | - [install or `i`](#install-or-i) 14 | - [search or `s`](#search-or-s) 15 | - [remove or `r`](#remove-or-r) 16 | - [list or `l`](#list-or-l) 17 | - [Contribution to Donya Package Manager](#contribution-to-donya-package-manager) 18 | - [License](#license) 19 | 20 | Donya Package System 21 | 22 | ![Donya Package System](https://user-images.githubusercontent.com/2658040/91432025-65355380-e876-11ea-8b4c-400b0aa77a4d.jpg) 23 | 24 | ## Donya or d 25 | 26 | We will set `d` as an alias of `donya` later. 27 | 28 | ``` 29 | ./donya install php ; install php version 7.1 30 | ./donya i php ; install php version 7.1 31 | 32 | ./donya i php7.4 ; install php version 7.4 33 | ./donya i gcc ; install gcc 34 | 35 | ./donya s php ; search all package with php prefix 36 | ./donya search php ; search all package with php prefix 37 | 38 | ./donya r php ; remove php package 39 | ./donya remove php ; remove php package 40 | 41 | ./donya r php* ; remove all php prefix package 42 | 43 | ./donya i php* ; install all php prefix package 44 | ``` 45 | 46 | ## Compiling Donya Package Manager 47 | 48 | ``` 49 | $ go get github.com/DonyaOS/PackageManager 50 | $ cd $(go env GOPATH)/src/github.com/DonyaOS/PackageManager 51 | $ go build 52 | $ ./PackageManager 53 | ``` 54 | 55 | ## Donya Package Manager Commands 56 | 57 | #### install or `i` 58 | 59 | #### search or `s` 60 | 61 | #### remove or `r` 62 | 63 | #### list or `l` 64 | 65 | `./donya list` : List of all installed packages 66 | 67 | `./donya list all` : List of all packages available in the repository 68 | 69 | ----------- 70 | 71 | ## Contribution to Donya Package Manager 72 | 73 | Please make sure to read the [Contributing Guide](CONTRIBUTING.md) before making a pull request. If you have a Donya-related project/feature/tool, add it with a pull request to this curated list! 74 | 75 | Thank you to all the people who already contributed to DonyaOS! 76 | 77 | ## License 78 | 79 | [MIT License](LICENSE) 80 | 81 | ## Install on debian chroot environment 82 | 83 | 1. Create a simple chroot in Debian based distro 84 | [Create Debian chroot](https://gist.github.com/esmaeelE/ab35177313793d342174c28ff4bcbc07) 85 | 86 | 2. Activate chroot environment 87 | 88 | 3. Download and install Go inside chroot env 89 | 90 | [Official download link](https://golang.org/dl/) 91 | 92 | extract downloaded package and place under `/usr/local` 93 | 94 | `tar -C /usr/local -xzvf go1.13.linux-amd64.tar.gz` 95 | 96 | Change name of package `go1.13.linux-amd64.tar.gz` as it changes version. 97 | 98 | Once the file is extracted, edit the `$PATH` environment variable so that the system knows where the Go executable binaries are located. You can do this either by appending the following line to the /etc/profile file (for a system-wide installation) or to the `$HOME/.profile` file (for a current user installation):`~/.profile` 99 | 100 | `export PATH=$PATH:/usr/local/go/bin` 101 | 102 | Save the file, and apply the new PATH environment variable to the current shell session by typing: 103 | 104 | `source ~/.profile` 105 | 106 | To verify that Go has been successfully installed run the following command which will print the Go version: 107 | 108 | `go version` 109 | 110 | [Original Resource](https://linuxize.com/post/how-to-install-go-on-debian-10/) 111 | 112 | ## Contributors ✨ 113 | 114 | Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)): 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 |

Max Base

💻

John Bampton

💻

Parham Alvani

💻

EEC

📖

Amir

💻

All Contributors

📖
129 | 130 | 131 | 132 | 133 | 134 | 135 | This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome! 136 | -------------------------------------------------------------------------------- /cmd/install/main.go: -------------------------------------------------------------------------------- 1 | package install 2 | 3 | import ( 4 | "fmt" 5 | "strconv" 6 | "strings" 7 | 8 | "github.com/spf13/cobra" 9 | ) 10 | 11 | // Register registers install command. 12 | func Register(root *cobra.Command) { 13 | cmd := &cobra.Command{ 14 | Use: "install [name of packages]", 15 | Aliases: []string{"i"}, 16 | Short: "installs a package", 17 | Long: "Installing package(s) in DonyaOS", 18 | Args: cobra.MinimumNArgs(1), 19 | Run: func(cmd *cobra.Command, args []string) { 20 | leng := strconv.Itoa(len(args)) 21 | fmt.Println("Installing " + leng + " package(s): " + strings.Join(args, " ")) 22 | }, 23 | } 24 | 25 | root.AddCommand(cmd) 26 | } 27 | -------------------------------------------------------------------------------- /cmd/purge/main.go: -------------------------------------------------------------------------------- 1 | package purge 2 | 3 | import ( 4 | "fmt" 5 | "strconv" 6 | "strings" 7 | 8 | "github.com/spf13/cobra" 9 | ) 10 | 11 | // Register registers purge command. 12 | func Register(root *cobra.Command) { 13 | cmd := &cobra.Command{ 14 | Use: "purge [name of packages]", 15 | Aliases: []string{"p"}, 16 | Short: "removes all orphaned packages", 17 | Long: "Removing all orphaned package(s) in DonyaOS", 18 | Args: cobra.MinimumNArgs(1), 19 | Run: func(cmd *cobra.Command, args []string) { 20 | leng := strconv.Itoa(len(args)) 21 | fmt.Println("Purging " + leng + " package(s): " + strings.Join(args, " ")) 22 | }, 23 | } 24 | 25 | root.AddCommand(cmd) 26 | } 27 | -------------------------------------------------------------------------------- /cmd/root.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/DonyaOS/PackageManager/cmd/install" 8 | "github.com/DonyaOS/PackageManager/cmd/purge" 9 | "github.com/DonyaOS/PackageManager/cmd/search" 10 | "github.com/spf13/cobra" 11 | ) 12 | 13 | // ExitFailure status code. 14 | const ExitFailure = 1 15 | 16 | // Execute adds all child commands to the root command and sets flags appropriately. 17 | // This is called by main.main(). It only needs to happen once to the rootCmd. 18 | func Execute() { 19 | root := &cobra.Command{ 20 | Use: "donya", 21 | Short: "Donya Package Manager/System", 22 | } 23 | 24 | install.Register(root) 25 | purge.Register(root) 26 | search.Register(root) 27 | 28 | if err := root.Execute(); err != nil { 29 | fmt.Printf("error: %s\n", err.Error()) 30 | os.Exit(ExitFailure) 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /cmd/search/main.go: -------------------------------------------------------------------------------- 1 | package search 2 | 3 | import ( 4 | "fmt" 5 | "strconv" 6 | "strings" 7 | 8 | "github.com/spf13/cobra" 9 | ) 10 | 11 | // Register registers search command. 12 | func Register(root *cobra.Command) { 13 | cmd := &cobra.Command{ 14 | Use: "search [name of packages]", 15 | Aliases: []string{"s"}, 16 | Short: "searches for a package", 17 | Long: "Searching for a package(s) in DonyaOS", 18 | Args: cobra.MinimumNArgs(1), 19 | Run: func(cmd *cobra.Command, args []string) { 20 | leng := strconv.Itoa(len(args)) 21 | fmt.Println("Searching for " + leng + " package(s): " + strings.Join(args, " ")) 22 | }, 23 | } 24 | 25 | root.AddCommand(cmd) 26 | } 27 | -------------------------------------------------------------------------------- /cmd/uninstall/main.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "fmt" 5 | "strconv" 6 | "strings" 7 | 8 | "github.com/spf13/cobra" 9 | ) 10 | 11 | // Register registers uninstall command. 12 | func Register(root *cobra.Command) { 13 | cmd := &cobra.Command{ 14 | Use: "uninstall [name of packages]", 15 | Aliases: []string{"r", "remove"}, 16 | Short: "removes a package", 17 | Long: "Removing package(s) in DonyaOS", 18 | Args: cobra.MinimumNArgs(1), 19 | Run: func(cmd *cobra.Command, args []string) { 20 | leng := strconv.Itoa(len(args)) 21 | fmt.Println("Uninstalling " + leng + " package(s): " + strings.Join(args, " ")) 22 | }, 23 | } 24 | 25 | root.AddCommand(cmd) 26 | } 27 | -------------------------------------------------------------------------------- /cmd/update/main.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "fmt" 5 | "strconv" 6 | "strings" 7 | 8 | "github.com/spf13/cobra" 9 | ) 10 | 11 | // Register registers update command. 12 | func Register(root *cobra.Command) { 13 | cmd := &cobra.Command{ 14 | Use: "update [name of packages]", 15 | Aliases: []string{"u"}, 16 | Short: "updates the list of packages", 17 | Long: "Updating the list of packages in DonyaOS", 18 | Args: cobra.MinimumNArgs(1), 19 | Run: func(cmd *cobra.Command, args []string) { 20 | leng := strconv.Itoa(len(args)) 21 | fmt.Println("Updating " + leng + " package(s): " + strings.Join(args, " ")) 22 | }, 23 | } 24 | 25 | root.AddCommand(cmd) 26 | } 27 | -------------------------------------------------------------------------------- /config.toml: -------------------------------------------------------------------------------- 1 | ignoreGeneratedHeader = false 2 | severity = "warning" 3 | confidence = 0.8 4 | errorCode = 0 5 | warningCode = 0 6 | 7 | [rule.blank-imports] 8 | [rule.context-as-argument] 9 | [rule.context-keys-type] 10 | [rule.dot-imports] 11 | [rule.error-return] 12 | [rule.error-strings] 13 | [rule.error-naming] 14 | [rule.exported] 15 | [rule.if-return] 16 | [rule.increment-decrement] 17 | [rule.var-naming] 18 | [rule.var-declaration] 19 | [rule.package-comments] 20 | [rule.range] 21 | [rule.receiver-naming] 22 | [rule.time-naming] 23 | [rule.unexported-return] 24 | [rule.indent-error-flow] 25 | [rule.errorf] 26 | [rule.empty-block] 27 | [rule.superfluous-else] 28 | [rule.unused-parameter] 29 | [rule.unreachable-code] 30 | [rule.redefines-builtin-id] 31 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/DonyaOS/PackageManager 2 | 3 | go 1.15 4 | 5 | require ( 6 | github.com/dlclark/regexp2 v1.2.1 // indirect 7 | github.com/dop251/goja v0.0.0-20200912112403-81ddb8a7cc41 8 | github.com/go-resty/resty/v2 v2.3.0 9 | github.com/go-sourcemap/sourcemap v2.1.3+incompatible // indirect 10 | github.com/sirupsen/logrus v1.2.0 11 | github.com/spf13/cobra v1.0.0 12 | github.com/spf13/pflag v1.0.5 // indirect 13 | github.com/stretchr/testify v1.2.2 14 | ) 15 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= 2 | github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= 3 | github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= 4 | github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= 5 | github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= 6 | github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= 7 | github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= 8 | github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= 9 | github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= 10 | github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= 11 | github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= 12 | github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= 13 | github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= 14 | github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= 15 | github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= 16 | github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= 17 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= 18 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 19 | github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= 20 | github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= 21 | github.com/dlclark/regexp2 v1.2.1 h1:Ff/S0snjr1oZHUNOkvA/gP6KUaMg5vDDl3Qnhjnwgm8= 22 | github.com/dlclark/regexp2 v1.2.1/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= 23 | github.com/dop251/goja v0.0.0-20200912112403-81ddb8a7cc41 h1:2P55x6IerzvQIv7bdKEQQWl93uIEQgh6417+uwHGtKQ= 24 | github.com/dop251/goja v0.0.0-20200912112403-81ddb8a7cc41/go.mod h1:Mw6PkjjMXWbTj+nnj4s3QPXq1jaT0s5pC0iFD4+BOAA= 25 | github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= 26 | github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= 27 | github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= 28 | github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= 29 | github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= 30 | github.com/go-resty/resty v1.12.0 h1:L1P5qymrXL5H/doXe2pKUr1wxovAI5ilm2LdVLbwThc= 31 | github.com/go-resty/resty/v2 v2.3.0 h1:JOOeAvjSlapTT92p8xiS19Zxev1neGikoHsXJeOq8So= 32 | github.com/go-resty/resty/v2 v2.3.0/go.mod h1:UpN9CgLZNsv4e9XG50UU8xdI0F43UQ4HmxLBDwaroHU= 33 | github.com/go-sourcemap/sourcemap v1.0.5 h1:oaGf6nqLxwhWPrW5jjNWUYM1SWqHIsJSFcPZojn23Mc= 34 | github.com/go-sourcemap/sourcemap v2.1.3+incompatible h1:W1iEw64niKVGogNgBN3ePyLFfuisuzeidWPMPWmECqU= 35 | github.com/go-sourcemap/sourcemap v2.1.3+incompatible/go.mod h1:F8jJfvm2KbVjc5NqelyYJmf/v5J0dwNLS2mL4sNA1Jg= 36 | github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= 37 | github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= 38 | github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= 39 | github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= 40 | github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= 41 | github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= 42 | github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 43 | github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 44 | github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= 45 | github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= 46 | github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= 47 | github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= 48 | github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= 49 | github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= 50 | github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= 51 | github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= 52 | github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= 53 | github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= 54 | github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= 55 | github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= 56 | github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= 57 | github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= 58 | github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= 59 | github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= 60 | github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= 61 | github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= 62 | github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= 63 | github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= 64 | github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= 65 | github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= 66 | github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= 67 | github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= 68 | github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= 69 | github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 70 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 71 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 72 | github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= 73 | github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= 74 | github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= 75 | github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= 76 | github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= 77 | github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= 78 | github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= 79 | github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= 80 | github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= 81 | github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= 82 | github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= 83 | github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= 84 | github.com/sirupsen/logrus v1.2.0 h1:juTguoYk5qI21pwyTXY3B3Y5cOTH3ZUyZCg1v/mihuo= 85 | github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= 86 | github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= 87 | github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= 88 | github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= 89 | github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= 90 | github.com/spf13/cobra v1.0.0 h1:6m/oheQuQ13N9ks4hubMG6BnvwOeaJrqSPLahSnczz8= 91 | github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE= 92 | github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= 93 | github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg= 94 | github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= 95 | github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= 96 | github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= 97 | github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= 98 | github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 99 | github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= 100 | github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= 101 | github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= 102 | github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= 103 | github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= 104 | github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= 105 | go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= 106 | go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= 107 | go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= 108 | go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= 109 | golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= 110 | golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M= 111 | golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= 112 | golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= 113 | golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= 114 | golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 115 | golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 116 | golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 117 | golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 118 | golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= 119 | golang.org/x/net v0.0.0-20200513185701-a91f0712d120 h1:EZ3cVSzKOlJxAd8e8YAJ7no8nNypTxexh/YE/xW3ZEY= 120 | golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= 121 | golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= 122 | golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 123 | golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 124 | golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 125 | golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 126 | golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 127 | golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 128 | golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 129 | golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU= 130 | golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 131 | golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd h1:xhmwyvizuTgC2qz7ZlMluP20uW+C3Rm0FD/WLDX8884= 132 | golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 133 | golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= 134 | golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 135 | golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= 136 | golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 137 | golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 138 | golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= 139 | google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= 140 | google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= 141 | google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= 142 | google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= 143 | gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= 144 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 145 | gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 146 | gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= 147 | gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= 148 | gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 149 | gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= 150 | gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 151 | honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= 152 | -------------------------------------------------------------------------------- /lint-local.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Use this file for linting on your local machine 4 | # markdownlint is an npm package 5 | # yamllint is a Python package 6 | markdownlint '**/*.md' --ignore node_modules --fix --config .github/.markdownlint.yml 7 | yamllint -c .github/.yamllint . 8 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/DonyaOS/PackageManager/cmd" 7 | ) 8 | 9 | // nolint: gocheckglobals 10 | var ( 11 | version = "dev" 12 | commit = "none" 13 | date = "unknown" 14 | ) 15 | 16 | func main() { 17 | fmt.Printf("gosimac %s, commit %s, built at %s\n", version, commit, date) 18 | 19 | cmd.Execute() 20 | } 21 | -------------------------------------------------------------------------------- /revive.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # print first 4 | revive -config config.toml . 5 | 6 | var=$(revive -config config.toml .) 7 | # then exit with fail if found 8 | if test -z "$var"; then 9 | exit 0 10 | else 11 | exit 1 12 | fi 13 | -------------------------------------------------------------------------------- /runner/console.go: -------------------------------------------------------------------------------- 1 | package runner 2 | 3 | import ( 4 | "github.com/dop251/goja" 5 | "github.com/sirupsen/logrus" 6 | ) 7 | 8 | type Console struct{} 9 | 10 | func (c Console) Log(msg goja.Value) { 11 | logrus.Info(msg) 12 | } 13 | 14 | func (c Console) ToJS(rt *goja.Runtime) goja.Value { 15 | obj := rt.NewObject() 16 | 17 | if err := obj.Set("log", c.Log); err != nil { 18 | panic(err) 19 | } 20 | 21 | return obj 22 | } 23 | -------------------------------------------------------------------------------- /runner/exec.go: -------------------------------------------------------------------------------- 1 | package runner 2 | 3 | import ( 4 | "io" 5 | "os" 6 | "os/exec" 7 | 8 | "github.com/dop251/goja" 9 | "github.com/sirupsen/logrus" 10 | ) 11 | 12 | type Exec struct{} 13 | 14 | func (e Exec) Run(rt *goja.Runtime) func(goja.Value) { 15 | return func(cmd goja.Value) { 16 | var args []string 17 | 18 | logger := logrus.New() 19 | logger.SetLevel(logrus.InfoLevel) 20 | logger.SetOutput(os.Stdout) 21 | 22 | if err := rt.ExportTo(cmd, &args); err != nil { 23 | logrus.Error(err) 24 | 25 | return 26 | } 27 | 28 | //nolint:gosec 29 | command := exec.Command(args[0], args[1:]...) 30 | 31 | pipe, err := command.StdoutPipe() 32 | if err != nil { 33 | return 34 | } 35 | 36 | if err := command.Start(); err != nil { 37 | logrus.Error(err) 38 | } 39 | 40 | w := logger.WithField("command", args[0]).Writer() 41 | if _, err := io.Copy(w, pipe); err != nil { 42 | logrus.Error(err) 43 | } 44 | 45 | if err := w.Close(); err != nil { 46 | logrus.Error(err) 47 | } 48 | 49 | if err := command.Wait(); err != nil { 50 | logrus.Error(err) 51 | } 52 | } 53 | } 54 | 55 | func (e Exec) ToJS(rt *goja.Runtime) goja.Value { 56 | obj := rt.NewObject() 57 | 58 | if err := obj.Set("run", e.Run(rt)); err != nil { 59 | panic(err) 60 | } 61 | 62 | return obj 63 | } 64 | -------------------------------------------------------------------------------- /runner/runner.go: -------------------------------------------------------------------------------- 1 | package runner 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | "io/ioutil" 7 | "os" 8 | "runtime" 9 | 10 | "github.com/dop251/goja" 11 | "github.com/go-resty/resty/v2" 12 | "github.com/sirupsen/logrus" 13 | ) 14 | 15 | type Runner struct { 16 | runtime *goja.Runtime 17 | this *goja.Object 18 | client *resty.Client 19 | } 20 | 21 | var ErrNoInstall = errors.New("there must be an install function") 22 | 23 | func New() *Runner { 24 | rt := goja.New() 25 | 26 | rt.Set("console", Console{}.ToJS(rt)) 27 | rt.Set("exec", Exec{}.ToJS(rt)) 28 | 29 | this := rt.NewObject() 30 | if err := this.DefineDataProperty( 31 | "go", 32 | rt.ToValue(runtime.Version()), 33 | goja.FLAG_FALSE, goja.FLAG_FALSE, goja.FLAG_FALSE, 34 | ); err != nil { 35 | panic(err) 36 | } 37 | 38 | return &Runner{ 39 | runtime: rt, 40 | this: this, 41 | client: resty.New().SetHeader("User-Agent", "donya-pkg"), 42 | } 43 | } 44 | 45 | // nolint: funlen 46 | func (r *Runner) Run(str string) error { 47 | _, err := r.runtime.RunString(str) 48 | if err != nil { 49 | return err 50 | } 51 | 52 | arch := r.runtime.Get("arch").String() 53 | if arch != runtime.GOARCH { 54 | logrus.Warnf("installation script has arch = %s but your current arch is %s", arch, runtime.GOARCH) 55 | } 56 | 57 | version := r.runtime.Get("version").String() 58 | if err := r.this.DefineDataProperty( 59 | "version", 60 | r.runtime.ToValue(version), 61 | goja.FLAG_FALSE, goja.FLAG_FALSE, goja.FLAG_FALSE, 62 | ); err != nil { 63 | panic(err) 64 | } 65 | 66 | var sources []string 67 | if err := r.runtime.ExportTo(r.runtime.Get("sources"), &sources); err != nil { 68 | logrus.Errorf("sources: %s", err.Error()) 69 | } 70 | 71 | files := make([]string, len(sources)) 72 | 73 | for i, source := range sources { 74 | logrus.Info(source) 75 | 76 | resp, err := r.client.R().Get(source) 77 | if err != nil { 78 | logrus.Error(err) 79 | } 80 | 81 | content := resp.Body() 82 | 83 | tmpfile, err := ioutil.TempFile("", fmt.Sprintf("s_%d_*", i)) 84 | if err != nil { 85 | logrus.Error(err) 86 | 87 | continue 88 | } 89 | 90 | if _, err := tmpfile.Write(content); err != nil { 91 | logrus.Error(err) 92 | } 93 | 94 | if err := tmpfile.Close(); err != nil { 95 | logrus.Error(err) 96 | } 97 | 98 | files[i] = tmpfile.Name() 99 | } 100 | 101 | if err := r.this.DefineDataProperty( 102 | "files", 103 | r.runtime.ToValue(files), 104 | goja.FLAG_FALSE, goja.FLAG_FALSE, goja.FLAG_FALSE, 105 | ); err != nil { 106 | panic(err) 107 | } 108 | 109 | f, ok := goja.AssertFunction(r.runtime.Get("install")) 110 | if !ok { 111 | return ErrNoInstall 112 | } 113 | 114 | if _, err := f(r.this); err != nil { 115 | return err 116 | } 117 | 118 | for _, file := range files { 119 | if err := os.Remove(file); err != nil { 120 | logrus.Error(err) 121 | } 122 | } 123 | 124 | return nil 125 | } 126 | -------------------------------------------------------------------------------- /runner/runner_test.go: -------------------------------------------------------------------------------- 1 | package runner_test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/DonyaOS/PackageManager/runner" 7 | "github.com/stretchr/testify/assert" 8 | ) 9 | 10 | func TestRunner(t *testing.T) { 11 | r := runner.New() 12 | 13 | script := ` 14 | version = "13" 15 | arch = "amd64" 16 | 17 | sources = [ 18 | "https://httpbin.org/bytes/" + version, 19 | ] 20 | 21 | function install() { 22 | console.log(this.go) 23 | console.log(this.version) 24 | console.log('Hello World') 25 | 26 | console.log(this.files[0]) 27 | exec.run(['cat', this.files[0]]) 28 | } 29 | ` 30 | 31 | assert.NoError(t, r.Run(script)) 32 | } 33 | --------------------------------------------------------------------------------