├── .circleci ├── config.yml └── script │ ├── deploy │ ├── docker │ ├── install-clojure │ ├── install-leiningen │ ├── lein │ ├── performance │ ├── release │ └── tools.deps ├── .gitignore ├── LICENSE ├── README.md ├── appveyor.yml ├── deps.edn ├── resources └── PUGET_CLI_VERSION ├── script ├── compile ├── compile.bat └── test └── src └── puget_cli └── main.clj /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | # Clojure CircleCI 2.0 configuration file 2 | # 3 | # Check https://circleci.com/docs/2.0/language-clojure/ for more details 4 | # 5 | version: 2.1 6 | jobs: 7 | jvm: 8 | docker: 9 | # specify the version you desire here 10 | - image: circleci/clojure:lein-2.8.1 11 | working_directory: ~/repo 12 | environment: 13 | LEIN_ROOT: "true" 14 | steps: 15 | - checkout 16 | - restore_cache: 17 | keys: 18 | - v1-dependencies-{{ checksum "deps.edn" }} 19 | # fallback to using the latest cache if no exact match is found 20 | - v1-dependencies- 21 | - run: 22 | name: Install Clojure 23 | command: | 24 | wget -nc https://download.clojure.org/install/linux-install-1.10.1.447.sh 25 | chmod +x linux-install-1.10.1.447.sh 26 | sudo ./linux-install-1.10.1.447.sh 27 | - run: 28 | name: Run JVM tests 29 | command: | 30 | script/test 31 | - save_cache: 32 | paths: 33 | - ~/.m2 34 | key: v1-dependencies-{{ checksum "deps.edn" }} 35 | linux: 36 | docker: 37 | - image: circleci/clojure:lein-2.8.1 38 | working_directory: ~/repo 39 | environment: 40 | LEIN_ROOT: "true" 41 | GRAALVM_HOME: /home/circleci/graalvm-ce-java11-20.2.0 42 | PUGET_PLATFORM: linux # used in release script 43 | PUGET_TEST_ENV: native 44 | steps: 45 | - checkout 46 | - restore_cache: 47 | keys: 48 | - linux-{{ checksum "deps.edn" }}-{{ checksum ".circleci/config.yml" }} 49 | - run: 50 | name: Install Clojure 51 | command: | 52 | wget https://download.clojure.org/install/linux-install-1.10.1.447.sh 53 | chmod +x linux-install-1.10.1.447.sh 54 | sudo ./linux-install-1.10.1.447.sh 55 | - run: 56 | name: Install native dev tools 57 | command: | 58 | sudo apt-get update 59 | sudo apt-get -y install gcc zlib1g-dev 60 | - run: 61 | name: Download GraalVM 62 | command: | 63 | cd ~ 64 | if ! [ -d graalvm-ce-java11-20.2.0 ]; then 65 | curl -O -sL https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-20.2.0/graalvm-ce-java11-linux-amd64-20.2.0.tar.gz 66 | tar xzf graalvm-ce-java11-linux-amd64-20.2.0.tar.gz 67 | fi 68 | - run: 69 | name: Build binary 70 | command: | 71 | script/compile 72 | no_output_timeout: 30m 73 | - run: 74 | name: Run tests 75 | command: | 76 | script/test 77 | # - run: 78 | # name: Performance report 79 | # command: | 80 | # .circleci/script/performance 81 | - run: 82 | name: Release 83 | command: | 84 | .circleci/script/release 85 | - save_cache: 86 | paths: 87 | - ~/.m2 88 | - ~/graalvm-ce-java11-20.2.0 89 | key: linux-{{ checksum "deps.edn" }}-{{ checksum ".circleci/config.yml" }} 90 | - store_artifacts: 91 | path: /tmp/release 92 | destination: release 93 | mac: 94 | macos: 95 | xcode: "12.0.0" 96 | environment: 97 | GRAALVM_HOME: /Users/distiller/graalvm-ce-java11-20.2.0/Contents/Home 98 | PUGET_PLATFORM: macos # used in release script 99 | PUGET_TEST_ENV: native 100 | steps: 101 | - checkout 102 | - restore_cache: 103 | keys: 104 | - mac-{{ checksum "deps.edn" }}-{{ checksum ".circleci/config.yml" }} 105 | - run: 106 | name: Install Clojure 107 | command: | 108 | .circleci/script/install-clojure /usr/local 109 | - run: 110 | name: Install Leiningen 111 | command: | 112 | .circleci/script/install-leiningen 113 | 114 | - run: 115 | name: Download GraalVM 116 | command: | 117 | cd ~ 118 | ls -la 119 | if ! [ -d graalvm-ce-java11-20.2.0 ]; then 120 | curl -O -sL https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-20.2.0/graalvm-ce-java11-darwin-amd64-20.2.0.tar.gz 121 | tar xzf graalvm-ce-java11-darwin-amd64-20.2.0.tar.gz 122 | fi 123 | - run: 124 | name: Build binary 125 | command: | 126 | script/compile 127 | no_output_timeout: 30m 128 | - run: 129 | name: Run tests 130 | command: | 131 | script/test 132 | # - run: 133 | # name: Performance report 134 | # command: | 135 | # .circleci/script/performance 136 | - run: 137 | name: Release 138 | command: | 139 | .circleci/script/release 140 | - save_cache: 141 | paths: 142 | - ~/.m2 143 | - ~/graalvm-ce-java11-20.2.0 144 | key: mac-{{ checksum "deps.edn" }}-{{ checksum ".circleci/config.yml" }} 145 | - store_artifacts: 146 | path: /tmp/release 147 | destination: release 148 | deploy: 149 | docker: 150 | - image: circleci/clojure:lein-2.8.1 151 | working_directory: ~/repo 152 | environment: 153 | LEIN_ROOT: "true" 154 | steps: 155 | - checkout 156 | - restore_cache: 157 | keys: 158 | - v1-dependencies-{{ checksum "deps.edn" }} 159 | # fallback to using the latest cache if no exact match is found 160 | - v1-dependencies- 161 | - run: .circleci/script/deploy 162 | - save_cache: 163 | paths: 164 | - ~/.m2 165 | key: v1-dependencies-{{ checksum "deps.edn" }} 166 | # docker: 167 | # docker: 168 | # - image: circleci/buildpack-deps:stretch 169 | # steps: 170 | # - checkout 171 | # - setup_remote_docker: 172 | # docker_layer_caching: true 173 | # - run: 174 | # name: Build Docker image 175 | # command: .circleci/script/docker 176 | 177 | workflows: 178 | version: 2 179 | ci: 180 | jobs: 181 | - jvm 182 | - linux 183 | - mac 184 | - deploy: 185 | filters: 186 | branches: 187 | only: master 188 | requires: 189 | - jvm 190 | - linux 191 | - mac 192 | # - docker: 193 | # filters: 194 | # branches: 195 | # only: master 196 | # requires: 197 | # - jvm 198 | # - linux 199 | # - mac 200 | -------------------------------------------------------------------------------- /.circleci/script/deploy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | if [ -z "$CIRCLE_PULL_REQUEST" ] && [ "$CIRCLE_BRANCH" = "master" ] 4 | then 5 | lein deploy clojars 6 | fi 7 | 8 | exit 0; 9 | -------------------------------------------------------------------------------- /.circleci/script/docker: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | image_name="borkdude/clj-kondo" 4 | image_tag=$(cat resources/CLJ_KONDO_VERSION) 5 | latest_tag="latest" 6 | 7 | if [[ $image_tag =~ SNAPSHOT$ ]]; then 8 | echo "This is a snapshot version" 9 | snapshot="true" 10 | else 11 | echo "This is a non-snapshot version" 12 | snapshot="false" 13 | fi 14 | 15 | if [ -z "$CIRCLE_PULL_REQUEST" ] && [ "$CIRCLE_BRANCH" = "master" ]; then 16 | echo "Building Docker image $image_name:$image_tag" 17 | echo "$DOCKERHUB_PASS" | docker login -u "$DOCKERHUB_USER" --password-stdin 18 | docker build -t "$image_name" . 19 | docker tag "$image_name:$latest_tag" "$image_name:$image_tag" 20 | # we only update latest when it's not a SNAPSHOT version 21 | if [ "false" = "$snapshot" ]; then 22 | echo "Pushing image $image_name:$latest_tag" 23 | docker push "$image_name:$latest_tag" 24 | fi 25 | # we update the version tag, even if it's a SNAPSHOT version 26 | echo "Pushing image $image_name:$image_tag" 27 | docker push "$image_name:$image_tag" 28 | else 29 | echo "Not publishing Docker image" 30 | fi 31 | 32 | exit 0; 33 | -------------------------------------------------------------------------------- /.circleci/script/install-clojure: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | install_dir=${1:-/tmp/clojure} 4 | mkdir -p "$install_dir" 5 | cd /tmp 6 | curl -O -sL https://download.clojure.org/install/clojure-tools-1.10.1.447.tar.gz 7 | tar xzf clojure-tools-1.10.1.447.tar.gz 8 | cd clojure-tools 9 | clojure_lib_dir="$install_dir/lib/clojure" 10 | mkdir -p "$clojure_lib_dir/libexec" 11 | cp ./*.jar "$clojure_lib_dir/libexec" 12 | cp deps.edn "$clojure_lib_dir" 13 | cp example-deps.edn "$clojure_lib_dir" 14 | 15 | sed -i -e 's@PREFIX@'"$clojure_lib_dir"'@g' clojure 16 | mkdir -p "$install_dir/bin" 17 | cp clojure "$install_dir/bin" 18 | cp clj "$install_dir/bin" 19 | 20 | cd /tmp 21 | rm -rf clojure-tools-1.10.1.447.tar.gz 22 | rm -rf clojure-tools 23 | echo "Installed clojure to $install_dir/bin" 24 | -------------------------------------------------------------------------------- /.circleci/script/install-leiningen: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | curl https://raw.githubusercontent.com/technomancy/leiningen/2.9.1/bin/lein > lein 4 | sudo mkdir -p /usr/local/bin/ 5 | sudo mv lein /usr/local/bin/lein 6 | sudo chmod a+x /usr/local/bin/lein 7 | -------------------------------------------------------------------------------- /.circleci/script/lein: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | echo '{:a 1}' | lein jet --from edn --to json 4 | -------------------------------------------------------------------------------- /.circleci/script/performance: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | err=0 4 | function _trap_error() { 5 | local exit_code="$1" 6 | if [ "$exit_code" -ne 2 ] && [ "$exit_code" -ne 3 ]; then 7 | echo "EXIT CODE :( $exit_code" 8 | (( err |= "$exit_code" )) 9 | fi 10 | } 11 | 12 | trap '_trap_error $?' ERR 13 | trap 'exit $err' SIGINT SIGTERM 14 | 15 | 16 | rm -rf performance.txt 17 | echo -e "==== Build initial cache" | tee -a performance.txt 18 | cp="$(clojure -R:cljs -Spath)" 19 | read -r -d '' config <<'EOF' || true 20 | {:linters 21 | {:not-a-function 22 | {:skip-args [clojure.pprint/defdirectives 23 | cljs.pprint/defdirectives 24 | clojure.data.json/codepoint-case]}}} 25 | EOF 26 | 27 | (time ./clj-kondo --lint "$cp" --cache --config "$config") 2>&1 | tee -a performance.txt 28 | 29 | echo -e "\n==== Lint a single file (emulate in-editor usage)" | tee -a performance.txt 30 | (time ./clj-kondo --lint src/clj_kondo/impl/core.clj --cache) 2>&1 | tee -a performance.txt 31 | 32 | count=$(find . -name "*.clj*" -type f | wc -l | tr -d ' ') 33 | echo -e "\n==== Launch clj-kondo for each file in project ($count)" | tee -a performance.txt 34 | (time find src -name "*.clj*" -type f -exec ./clj-kondo --lint {} --cache \; ) 2>&1 | tee -a performance.txt 35 | 36 | exit "$err" 37 | -------------------------------------------------------------------------------- /.circleci/script/release: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | rm -rf /tmp/release 4 | mkdir -p /tmp/release 5 | cp puget /tmp/release 6 | VERSION=$(cat resources/PUGET_CLI_VERSION) 7 | 8 | cd /tmp/release 9 | 10 | ## release binary as zip archive 11 | 12 | zip "puget-cli-$VERSION-$PUGET_PLATFORM-amd64.zip" puget 13 | 14 | ## cleanup 15 | 16 | rm puget 17 | -------------------------------------------------------------------------------- /.circleci/script/tools.deps: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | err=0 4 | function _trap_error() { 5 | local exit_code="$1" 6 | if [ "$exit_code" -ne 2 ] && [ "$exit_code" -ne 3 ]; then 7 | (( err |= "$exit_code" )) 8 | fi 9 | } 10 | 11 | trap '_trap_error $?' ERR 12 | trap 'exit $err' SIGINT SIGTERM 13 | 14 | 15 | # Run as local root dependency 16 | rm -rf /tmp/proj 17 | mkdir -p /tmp/proj 18 | cd /tmp/proj 19 | clojure -Sdeps '{:deps {clj-kondo {:local/root "/home/circleci/repo"}}}' \ 20 | -m clj-kondo.main --lint /home/circleci/repo/src /home/circleci/repo/test 21 | 22 | # Run as git dependency 23 | rm -rf /tmp/proj 24 | mkdir -p /tmp/proj 25 | cd /tmp/proj 26 | 27 | github_user=${CIRCLE_PR_USERNAME:-borkdude} 28 | clojure -Sdeps "{:deps {clj-kondo {:git/url \"https://github.com/$github_user/clj-kondo\" :sha \"$CIRCLE_SHA1\"}}}" \ 29 | -m clj-kondo.main --lint /home/circleci/repo/src /home/circleci/repo/test 30 | 31 | exit "$err" 32 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .cpcache 2 | target 3 | pom.xml 4 | .lein-failures 5 | puget 6 | classes 7 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Eclipse Public License - v 1.0 2 | 3 | THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC 4 | LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM 5 | CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. 6 | 7 | 1. DEFINITIONS 8 | 9 | "Contribution" means: 10 | 11 | a) in the case of the initial Contributor, the initial code and documentation 12 | distributed under this Agreement, and 13 | b) in the case of each subsequent Contributor: 14 | i) changes to the Program, and 15 | ii) additions to the Program; 16 | 17 | where such changes and/or additions to the Program originate from and are 18 | distributed by that particular Contributor. A Contribution 'originates' from 19 | a Contributor if it was added to the Program by such Contributor itself or 20 | anyone acting on such Contributor's behalf. Contributions do not include 21 | additions to the Program which: (i) are separate modules of software 22 | distributed in conjunction with the Program under their own license 23 | agreement, and (ii) are not derivative works of the Program. 24 | 25 | "Contributor" means any person or entity that distributes the Program. 26 | 27 | "Licensed Patents" mean patent claims licensable by a Contributor which are 28 | necessarily infringed by the use or sale of its Contribution alone or when 29 | combined with the Program. 30 | 31 | "Program" means the Contributions distributed in accordance with this Agreement. 32 | 33 | "Recipient" means anyone who receives the Program under this Agreement, 34 | including all Contributors. 35 | 36 | 2. GRANT OF RIGHTS 37 | a) Subject to the terms of this Agreement, each Contributor hereby grants 38 | Recipient a non-exclusive, worldwide, royalty-free copyright license to 39 | reproduce, prepare derivative works of, publicly display, publicly perform, 40 | distribute and sublicense the Contribution of such Contributor, if any, and 41 | such derivative works, in source code and object code form. 42 | b) Subject to the terms of this Agreement, each Contributor hereby grants 43 | Recipient a non-exclusive, worldwide, royalty-free patent license under 44 | Licensed Patents to make, use, sell, offer to sell, import and otherwise 45 | transfer the Contribution of such Contributor, if any, in source code and 46 | object code form. This patent license shall apply to the combination of the 47 | Contribution and the Program if, at the time the Contribution is added by 48 | the Contributor, such addition of the Contribution causes such combination 49 | to be covered by the Licensed Patents. The patent license shall not apply 50 | to any other combinations which include the Contribution. No hardware per 51 | se is licensed hereunder. 52 | c) Recipient understands that although each Contributor grants the licenses to 53 | its Contributions set forth herein, no assurances are provided by any 54 | Contributor that the Program does not infringe the patent or other 55 | intellectual property rights of any other entity. Each Contributor 56 | disclaims any liability to Recipient for claims brought by any other entity 57 | based on infringement of intellectual property rights or otherwise. As a 58 | condition to exercising the rights and licenses granted hereunder, each 59 | Recipient hereby assumes sole responsibility to secure any other 60 | intellectual property rights needed, if any. For example, if a third party 61 | patent license is required to allow Recipient to distribute the Program, it 62 | is Recipient's responsibility to acquire that license before distributing 63 | the Program. 64 | d) Each Contributor represents that to its knowledge it has sufficient 65 | copyright rights in its Contribution, if any, to grant the copyright 66 | license set forth in this Agreement. 67 | 68 | 3. REQUIREMENTS 69 | 70 | A Contributor may choose to distribute the Program in object code form under its 71 | own license agreement, provided that: 72 | 73 | a) it complies with the terms and conditions of this Agreement; and 74 | b) its license agreement: 75 | i) effectively disclaims on behalf of all Contributors all warranties and 76 | conditions, express and implied, including warranties or conditions of 77 | title and non-infringement, and implied warranties or conditions of 78 | merchantability and fitness for a particular purpose; 79 | ii) effectively excludes on behalf of all Contributors all liability for 80 | damages, including direct, indirect, special, incidental and 81 | consequential damages, such as lost profits; 82 | iii) states that any provisions which differ from this Agreement are offered 83 | by that Contributor alone and not by any other party; and 84 | iv) states that source code for the Program is available from such 85 | Contributor, and informs licensees how to obtain it in a reasonable 86 | manner on or through a medium customarily used for software exchange. 87 | 88 | When the Program is made available in source code form: 89 | 90 | a) it must be made available under this Agreement; and 91 | b) a copy of this Agreement must be included with each copy of the Program. 92 | Contributors may not remove or alter any copyright notices contained within 93 | the Program. 94 | 95 | Each Contributor must identify itself as the originator of its Contribution, if 96 | any, in a manner that reasonably allows subsequent Recipients to identify the 97 | originator of the Contribution. 98 | 99 | 4. COMMERCIAL DISTRIBUTION 100 | 101 | Commercial distributors of software may accept certain responsibilities with 102 | respect to end users, business partners and the like. While this license is 103 | intended to facilitate the commercial use of the Program, the Contributor who 104 | includes the Program in a commercial product offering should do so in a manner 105 | which does not create potential liability for other Contributors. Therefore, if 106 | a Contributor includes the Program in a commercial product offering, such 107 | Contributor ("Commercial Contributor") hereby agrees to defend and indemnify 108 | every other Contributor ("Indemnified Contributor") against any losses, damages 109 | and costs (collectively "Losses") arising from claims, lawsuits and other legal 110 | actions brought by a third party against the Indemnified Contributor to the 111 | extent caused by the acts or omissions of such Commercial Contributor in 112 | connection with its distribution of the Program in a commercial product 113 | offering. The obligations in this section do not apply to any claims or Losses 114 | relating to any actual or alleged intellectual property infringement. In order 115 | to qualify, an Indemnified Contributor must: a) promptly notify the Commercial 116 | Contributor in writing of such claim, and b) allow the Commercial Contributor to 117 | control, and cooperate with the Commercial Contributor in, the defense and any 118 | related settlement negotiations. The Indemnified Contributor may participate in 119 | any such claim at its own expense. 120 | 121 | For example, a Contributor might include the Program in a commercial product 122 | offering, Product X. That Contributor is then a Commercial Contributor. If that 123 | Commercial Contributor then makes performance claims, or offers warranties 124 | related to Product X, those performance claims and warranties are such 125 | Commercial Contributor's responsibility alone. Under this section, the 126 | Commercial Contributor would have to defend claims against the other 127 | Contributors related to those performance claims and warranties, and if a court 128 | requires any other Contributor to pay any damages as a result, the Commercial 129 | Contributor must pay those damages. 130 | 131 | 5. NO WARRANTY 132 | 133 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN 134 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR 135 | IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, 136 | NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each 137 | Recipient is solely responsible for determining the appropriateness of using and 138 | distributing the Program and assumes all risks associated with its exercise of 139 | rights under this Agreement , including but not limited to the risks and costs 140 | of program errors, compliance with applicable laws, damage to or loss of data, 141 | programs or equipment, and unavailability or interruption of operations. 142 | 143 | 6. DISCLAIMER OF LIABILITY 144 | 145 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY 146 | CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, 147 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST 148 | PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 149 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 150 | OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS 151 | GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 152 | 153 | 7. GENERAL 154 | 155 | If any provision of this Agreement is invalid or unenforceable under applicable 156 | law, it shall not affect the validity or enforceability of the remainder of the 157 | terms of this Agreement, and without further action by the parties hereto, such 158 | provision shall be reformed to the minimum extent necessary to make such 159 | provision valid and enforceable. 160 | 161 | If Recipient institutes patent litigation against any entity (including a 162 | cross-claim or counterclaim in a lawsuit) alleging that the Program itself 163 | (excluding combinations of the Program with other software or hardware) 164 | infringes such Recipient's patent(s), then such Recipient's rights granted under 165 | Section 2(b) shall terminate as of the date such litigation is filed. 166 | 167 | All Recipient's rights under this Agreement shall terminate if it fails to 168 | comply with any of the material terms or conditions of this Agreement and does 169 | not cure such failure in a reasonable period of time after becoming aware of 170 | such noncompliance. If all Recipient's rights under this Agreement terminate, 171 | Recipient agrees to cease use and distribution of the Program as soon as 172 | reasonably practicable. However, Recipient's obligations under this Agreement 173 | and any licenses granted by Recipient relating to the Program shall continue and 174 | survive. 175 | 176 | Everyone is permitted to copy and distribute copies of this Agreement, but in 177 | order to avoid inconsistency the Agreement is copyrighted and may only be 178 | modified in the following manner. The Agreement Steward reserves the right to 179 | publish new versions (including revisions) of this Agreement from time to time. 180 | No one other than the Agreement Steward has the right to modify this Agreement. 181 | The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation 182 | may assign the responsibility to serve as the Agreement Steward to a suitable 183 | separate entity. Each new version of the Agreement will be given a 184 | distinguishing version number. The Program (including Contributions) may always 185 | be distributed subject to the version of the Agreement under which it was 186 | received. In addition, after a new version of the Agreement is published, 187 | Contributor may elect to distribute the Program (including its Contributions) 188 | under the new version. Except as expressly stated in Sections 2(a) and 2(b) 189 | above, Recipient receives no rights or licenses to the intellectual property of 190 | any Contributor under this Agreement, whether expressly, by implication, 191 | estoppel or otherwise. All rights in the Program not expressly granted under 192 | this Agreement are reserved. 193 | 194 | This Agreement is governed by the laws of the State of New York and the 195 | intellectual property laws of the United States of America. No party to this 196 | Agreement will bring a legal action under this Agreement more than one year 197 | after the cause of action arose. Each party waives its rights to a jury trial in 198 | any resulting litigation. 199 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Puget CLI 2 | 3 | The `puget` CLI can be used to pprint EDN values with colors. It is based on the 4 | [puget](https://github.com/greglook/puget) library. 5 | 6 | ## Installation 7 | 8 | ### Brew (linux and macOS) 9 | 10 | brew install borkdude/brew/puget 11 | 12 | ### Scoop (Windows) 13 | 14 | See [scoop-clojure](https://github.com/littleli/scoop-clojure). 15 | 16 | ### Manual 17 | 18 | Grab the binary for your OS at [Github releases](https://github.com/borkdude/puget-cli/releases). 19 | 20 | ## Usage 21 | 22 | Pipe EDN to stdin. Provide options to `puget.printer/pprint` using `--opts`. 23 | 24 | E.g.: 25 | 26 | ``` shell 27 | $ echo '[1 2 3]' | puget 28 | ``` 29 | 30 | This will invoke `puget.printer/pprint`. By default it uses colorized output which you can disable with: 31 | 32 | 33 | ``` shell 34 | $ echo '[1 2 3]' | puget --opts '{:print-color false}' 35 | ``` 36 | 37 | ## License 38 | 39 | Copyright © 2020 Michiel Borkent 40 | 41 | Distributed under the EPL License, same as Clojure. See LICENSE. 42 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | version: "v-{build}" 4 | 5 | image: Visual Studio 2017 6 | 7 | clone_folder: C:\projects\babashka 8 | 9 | environment: 10 | GRAALVM_HOME: C:\projects\babashka\graalvm\graalvm-ce-java11-20.2.0 11 | BABASHKA_XMX: "-J-Xmx5g" 12 | 13 | cache: 14 | - C:\ProgramData\chocolatey\lib -> project.clj, appveyor.yml 15 | - '%USERPROFILE%\.m2 -> project.clj' 16 | - 'graalvm -> appveyor.yml' 17 | 18 | clone_script: 19 | - ps: >- 20 | if(-not $env:APPVEYOR_PULL_REQUEST_NUMBER) { 21 | git clone -q --branch=$env:APPVEYOR_REPO_BRANCH https://github.com/$env:APPVEYOR_REPO_NAME.git $env:APPVEYOR_BUILD_FOLDER 22 | cd $env:APPVEYOR_BUILD_FOLDER 23 | git checkout -qf $env:APPVEYOR_REPO_COMMIT 24 | } else { 25 | git clone -q https://github.com/$env:APPVEYOR_REPO_NAME.git $env:APPVEYOR_BUILD_FOLDER 26 | cd $env:APPVEYOR_BUILD_FOLDER 27 | git fetch -q origin +refs/pull/$env:APPVEYOR_PULL_REQUEST_NUMBER/merge: 28 | git checkout -qf FETCH_HEAD 29 | } 30 | - cmd: git submodule update --init --recursive 31 | 32 | build_script: 33 | - cmd: >- 34 | 35 | # set CLJ_KONDO_TEST_ENV=jvm 36 | 37 | # call script/test.bat 38 | 39 | # see https://github.com/quarkusio/quarkus/pull/7663 40 | 41 | - cmd: >- 42 | call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat" 43 | 44 | powershell -Command "if (Test-Path('graalvm')) { return } else { (New-Object Net.WebClient).DownloadFile('https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-20.2.0/graalvm-ce-java11-windows-amd64-20.2.0.zip', 'graalvm.zip') }" 45 | 46 | powershell -Command "if (Test-Path('graalvm')) { return } else { Expand-Archive graalvm.zip graalvm }" 47 | 48 | powershell -Command "iwr -useb https://raw.githubusercontent.com/borkdude/deps.clj/master/install.ps1 | iex" 49 | 50 | - cmd: >- 51 | call script/compile.bat 52 | 53 | artifacts: 54 | - path: puget-cli-*-windows-amd64.zip 55 | name: puget 56 | -------------------------------------------------------------------------------- /deps.edn: -------------------------------------------------------------------------------- 1 | {:deps {org.clojure/clojure {:mvn/version "1.10.2-alpha2"} 2 | mvxcvi/puget {:mvn/version "1.3.1"}}} 3 | -------------------------------------------------------------------------------- /resources/PUGET_CLI_VERSION: -------------------------------------------------------------------------------- 1 | 0.0.3 2 | -------------------------------------------------------------------------------- /script/compile: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -eo pipefail 4 | 5 | if [ -z "$GRAALVM_HOME" ]; then 6 | echo "Please set $GRAALVM_HOME" 7 | exit 1 8 | fi 9 | 10 | mkdir -p classes 11 | clojure -J-Dclojure.compiler.direct-linking=true -e "(compile 'puget-cli.main)" 12 | 13 | "$GRAALVM_HOME/bin/gu" install native-image 14 | 15 | "$GRAALVM_HOME/bin/native-image" \ 16 | -cp "$(clojure -Spath):classes" \ 17 | -H:Name=puget \ 18 | -H:+ReportExceptionStackTraces \ 19 | --initialize-at-build-time \ 20 | "-J-Dclojure.spec.skip-macros=true" \ 21 | "-J-Dclojure.compiler.direct-linking=true" \ 22 | --report-unsupported-elements-at-runtime \ 23 | --verbose \ 24 | --no-fallback \ 25 | --no-server \ 26 | "-J-Xmx3g" \ 27 | puget_cli.main 28 | -------------------------------------------------------------------------------- /script/compile.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | Rem set GRAALVM_HOME=C:\Users\IEUser\Downloads\graalvm-ce-java8-19.3.1 4 | Rem set PATH=%PATH%;C:\Users\IEUser\bin 5 | 6 | if "%GRAALVM_HOME%"=="" ( 7 | echo Please set GRAALVM_HOME 8 | exit /b 9 | ) 10 | 11 | set JAVA_HOME=%GRAALVM_HOME% 12 | set PATH=%GRAALVM_HOME%\bin;%PATH% 13 | 14 | set /P PUGET_CLI_VERSION=< resources\PUGET_CLI_VERSION 15 | echo Building puget-cli %PUGET_CLI_VERSION% 16 | 17 | if "%GRAALVM_HOME%"=="" ( 18 | echo Please set GRAALVM_HOME 19 | exit /b 20 | ) 21 | 22 | set PATH=%USERPROFILE%\deps.clj;%PATH% 23 | 24 | if not exist "classes" mkdir classes 25 | call deps -J-Dclojure.compiler.direct-linking=true -e "(compile 'puget-cli.main)" 26 | deps -Spath > .classpath 27 | set /P PUGET_CLASSPATH=<.classpath 28 | 29 | call %GRAALVM_HOME%\bin\gu.cmd install native-image 30 | 31 | call %GRAALVM_HOME%\bin\native-image.cmd ^ 32 | "-cp" "%PUGET_CLASSPATH%;classes" ^ 33 | "-H:Name=puget" ^ 34 | "-H:+ReportExceptionStackTraces" ^ 35 | "--initialize-at-build-time" ^ 36 | "-J-Dclojure.spec.skip-macros=true" ^ 37 | "-J-Dclojure.compiler.direct-linking=true" ^ 38 | "--report-unsupported-elements-at-runtime" ^ 39 | "--verbose" ^ 40 | "--no-fallback" ^ 41 | "--no-server" ^ 42 | "-J-Xmx3g" ^ 43 | "puget_cli.main" 44 | 45 | del .classpath 46 | 47 | if %errorlevel% neq 0 exit /b %errorlevel% 48 | 49 | echo Creating zip archive 50 | jar -cMf puget-cli-%PUGET_CLI_VERSION%-windows-amd64.zip puget.exe 51 | -------------------------------------------------------------------------------- /script/test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | -------------------------------------------------------------------------------- /src/puget_cli/main.clj: -------------------------------------------------------------------------------- 1 | (ns puget-cli.main 2 | (:gen-class) 3 | (:require [clojure.edn :as edn] 4 | [clojure.string :as str] 5 | [puget.printer :as puget]) 6 | (:import [java.io PushbackReader])) 7 | 8 | (def default-opts 9 | {:print-color true}) 10 | 11 | (defn parse-args [options] 12 | (let [opts (loop [options options 13 | opts-map {} 14 | current-opt nil] 15 | (if-let [opt (first options)] 16 | (if (str/starts-with? opt "--") 17 | (recur (rest options) 18 | (assoc opts-map opt nil) 19 | opt) 20 | (recur (rest options) 21 | (update opts-map current-opt (fnil conj []) opt) 22 | current-opt)) 23 | opts-map))] 24 | {:opts (some-> (get opts "--opts") 25 | first 26 | edn/read-string)})) 27 | 28 | (defn read-and-print 29 | [reader opts] 30 | (with-open [r (PushbackReader. reader)] 31 | (->> (repeatedly #(edn/read {:eof ::eof 32 | :default tagged-literal} r)) 33 | (take-while #(not= % ::eof)) 34 | (run! #(puget/pprint % opts))))) 35 | 36 | (defn -main [& args] 37 | (let [arg-opts (parse-args args) 38 | opts (:opts arg-opts) 39 | opts (merge default-opts opts)] 40 | (read-and-print *in* opts))) 41 | --------------------------------------------------------------------------------