├── .gitignore ├── Examples └── Cundlefile ├── README.md └── cundle.sh /.gitignore: -------------------------------------------------------------------------------- 1 | SharedLib 2 | -------------------------------------------------------------------------------- /Examples/Cundlefile: -------------------------------------------------------------------------------- 1 | cundle "https://github.com/pokeb/asi-http-request" 2 | cundle "enormego/EGOImageLoading" 3 | cundle "https://bitbucket.org/jaredhobbs/pysiri.git" 4 | cundle "git@github.com:ashchan/macruby-keychain-wrapper.git" 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Cundle 2 | 3 | As iOS/Mac has more and more great libraries like ASIHTTPRequest, RestKit and etc. There's no good package management tool for it. Cundle is inspired by the simple but useful vim bundler `vundle` and aims to provide a tool with minimized functions to manage these packages. 4 | 5 | The command line is written in bash. No need for compile. 6 | 7 | ## Usage 8 | 9 | $ cundle 10 | 11 | Cundle - the Obj-C Library Manager 12 | 13 | Usage: 14 | cundle help Show this message 15 | cundle install Download and install all libs defined in ./Cundlefile 16 | cundle install Download and install a 17 | cundle update Use the latest code for libs defined in ./Cundlefile 18 | cundle update Use the latest code for from git 19 | cundle ls List installed libs 20 | cundle remove Remove a 21 | 22 | Example: 23 | cundle install RestKit/RestKit Install latest version of RestKit 24 | cundle remove RestKit/RestKit Remove RestKit under SharedLib 25 | 26 | Run the following command under your project root. This will add ASIHttpRequest to SharedLib/asi-http-request. And by default, this command will also fetch all submodules or cundles defined inside the cundle. 27 | 28 | $ cundle install pokeb/asi-http-request 29 | 30 | Full git url can also be used. 31 | 32 | $ cundle install git@github.com:ashchan/macruby-keychain-wrapper.git 33 | 34 | To list all installed cundles 35 | 36 | $ cundle ls 37 | Installed libs under /Users/jyo/Examples/SharedLib: 38 | ✓ enormego/EGOImageLoading 39 | ✓ pokeb/asi-http-request 40 | 41 | To remove an installed bundle. And you need to remove that dependency from you Xcode project manually. 42 | 43 | $ cundle remove RestKit/RestKit 44 | 45 | If you have a `Cundlefile` at the project root, use `cundle` to install all cundles defined in the `Cundlefile`. 46 | 47 | $ cat Cundlefile 48 | cundle "pokeb/asi-http-request" 49 | cundle "RestKit/RestKit" 50 | cundle "enormego/EGOImageLoading" 51 | cundle "https://bitbucket.org/jaredhobbs/pysiri.git" 52 | 53 | $ cundle install 54 | Cloning into '/Users/jyo/Examples/SharedLib/asi-http-request'... 55 | Cloning into '/Users/jyo/Examples/SharedLib/EGOImageLoading'... 56 | Submodule 'EGOCache' (git://github.com/enormego/EGOCache.git) registered for path 'EGOCache' 57 | Cloning into 'EGOCache'... 58 | Submodule path 'EGOCache': checked out '8b7c7ecfc8fad396b6547ad3fef085713644f794' 59 | 60 | Use `cundle update` to update your all your cundles or `cundle update RestKit/RestKit` for just RestKit. 61 | 62 | ## Install 63 | 64 | Download and install cundle 65 | 66 | $ git clone git://github.com/rjyo/cundle.git ~/.cundle 67 | 68 | To activate cundle, you need to source it from your bash shell 69 | 70 | $ . ~/.cundle/cundle.sh 71 | 72 | Add this line to ~/.bashrc or ~/.zshrc (if you use oh-my-zsh like me) file to have it automatically source upon login. 73 | 74 | ## Limitations & Future plan 75 | 76 | * Not able to use a certain commit, tag or branch. It just pulls the latest source. 77 | * `cundle` is still at its alpha stage, but I'll make it better as I can. [Shoot me an email](mailto:jyo.rakuraku@gmail.com) if you have any question. 78 | 79 | ## License 80 | 81 | (The MIT License) 82 | 83 | Copyright (c) 2011 Rakuraku Jyo 84 | 85 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 86 | 87 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 88 | 89 | THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 90 | -------------------------------------------------------------------------------- /cundle.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Cundle - Obj-C Libary Manager 4 | # Implemented as a bash function 5 | # To use source this file from your bash profile 6 | # 7 | 8 | # Auto detect the CUNDLE_DIR 9 | # if [ ! -d "$CUNDLE_DIR" ]; then 10 | # export CUNDLE_DIR=$(cd "$(dirname ${BASH_SOURCE[0]:-$0})"; pwd) 11 | # fi 12 | 13 | # Check url 14 | if [ ! `which curl` ]; then 15 | NOCURL='nocurl' 16 | curl() { echo 'Need curl to proceed.' >&2; } 17 | fi 18 | 19 | # Check git 20 | if [ ! `which git` ]; then 21 | NOGIT='nogit' 22 | git() { echo 'Need git to proceed.' >&2; } 23 | fi 24 | 25 | LIB_DIR_NAME='SharedLib' 26 | 27 | # Install a lib at current path 28 | install() { 29 | if [ $# -ne 1 ]; then 30 | cundle help 31 | return 32 | fi 33 | 34 | [ "$NOCURL" ] && curl && return 35 | [ "$NOGIT" ] && git && return 36 | 37 | local old_path=`pwd` 38 | local lib_name=${1//.git/} 39 | local lib_path="$PWD/$LIB_DIR_NAME/`echo ${lib_name##*/}`" 40 | 41 | [ -d "$lib_path" ] && echo "$lib_path is already installed." && return 42 | 43 | if [[ $lib_name == http:* || $lib_name == https:* || $lib_name == git@* ]]; then 44 | local git_url=$lib_name 45 | else 46 | local git_url="https://github.com/$lib_name" 47 | fi 48 | 49 | git clone $git_url $lib_path 2>/dev/null 50 | 51 | if [ -d "$lib_path" ]; then 52 | if [ -f "$lib_path/.gitmodules" ]; then 53 | cd "$lib_path" 54 | git submodule update --init 2>/dev/null 55 | cd "$old_path" 56 | fi 57 | 58 | if [ -f "$lib_path/Cundlefile" ]; then 59 | install_path $lib_path 60 | fi 61 | fi 62 | } 63 | 64 | # Install libs at a given path, there must be a Cundle file at that path 65 | install_path() { 66 | local cundlefile="$1/Cundlefile" 67 | 68 | if [ ! -f $cundlefile ]; then 69 | cundle help 70 | return 71 | fi 72 | 73 | local old_path=`pwd` 74 | cd "$1" 75 | 76 | while read line 77 | do 78 | lib=`echo $line | awk '{print $2}' | tr -d "\""` 79 | install $lib 80 | done < $cundlefile 81 | 82 | cd "$old_path" 83 | } 84 | 85 | # Update an install cundle 86 | update() { 87 | local old_path=`pwd` 88 | 89 | if [ -d "$old_path/$LIB_DIR_NAME/$1/.git" ]; then 90 | cd "$old_path/$LIB_DIR_NAME/$1" 91 | 92 | # Get the lib name 93 | local repo=`git config -l | grep origin.url | grep -o "[^/]*$"` 94 | 95 | if [[ $repo =~ $1 ]]; then 96 | echo "Updating $1 ..." 97 | git reset --hard HEAD 2> /dev/null 98 | git clean -fd 2> /dev/null 99 | git pull 2> /dev/null 100 | fi 101 | 102 | cd "$old_path" 103 | fi 104 | # done 105 | } 106 | 107 | update_path() { 108 | local cundlefile="$1/Cundlefile" 109 | 110 | if [ ! -f $cundlefile ]; then 111 | cundle help 112 | return 113 | fi 114 | 115 | local old_path=`pwd` 116 | cd "$1" 117 | 118 | while read line 119 | do 120 | local lib=`echo $line | awk -F "/" '{ split($NF, name, "."); print name[1] }' | tr -d "\""` 121 | update $lib 122 | done < $cundlefile 123 | 124 | cd "$old_path" 125 | } 126 | 127 | cundle() 128 | { 129 | if [ $# -lt 1 ]; then 130 | cundle help 131 | return 132 | fi 133 | 134 | case $1 in 135 | "help" ) 136 | echo 137 | echo "Cundle - Obj-C Libary Manager" 138 | echo 139 | echo "Usage:" 140 | echo " cundle help Show this message" 141 | echo " cundle install Download and install all libs defined in ./Cundlefile" 142 | echo " cundle install Download and install a " 143 | echo " cundle update Use the latest code for libs defined in ./Cundlefile" 144 | echo " cundle update Use the latest code for from git" 145 | echo " cundle ls List installed libs" 146 | echo " cundle remove Remove a " 147 | echo 148 | echo "Example:" 149 | echo " cundle install enormego/EGOCache" 150 | echo 151 | ;; 152 | "install" ) 153 | if [ $# -eq 1 ]; then 154 | install_path `pwd` 155 | elif [ $# -eq 2 ]; then 156 | install $2 157 | else 158 | cundle help && return 159 | fi 160 | ;; 161 | "update" ) 162 | if [ $# -eq 1 ]; then 163 | update_path `pwd` 164 | elif [ $# -eq 2 ]; then 165 | update $2 166 | else 167 | cundle help && return 168 | fi 169 | ;; 170 | "remove" ) 171 | [ $# -ne 2 ] && cundle help && return 172 | 173 | local old_path=`pwd` 174 | for lib in `ls $LIB_DIR_NAME` 175 | do 176 | if [ -d "$old_path/$LIB_DIR_NAME/$lib/.git" ]; then 177 | cd "$old_path/$LIB_DIR_NAME/$lib" 178 | 179 | # Get the lib name 180 | liburl=`git config -l | grep origin.url` 181 | if [[ $liburl =~ $2 ]]; then 182 | rm -rf "$old_path/$LIB_DIR_NAME/$lib" 183 | echo "Removed $2" 184 | fi 185 | 186 | cd "$old_path" 187 | fi 188 | done 189 | ;; 190 | "ls" | "list" ) 191 | [ $# -ne 1 ] && cundle help && return 192 | 193 | local old_path=`pwd` 194 | 195 | [ ! -d "$old_path/$LIB_DIR_NAME" ] && echo "No libs installed" && return 196 | 197 | echo "Installed libs under $old_path/$LIB_DIR_NAME:" 198 | for lib in `ls $LIB_DIR_NAME` 199 | do 200 | if [ -d "$old_path/$LIB_DIR_NAME/$lib/.git" ]; then 201 | cd "$old_path/$LIB_DIR_NAME/$lib" 202 | # Get the lib name 203 | repo=`git config -l | grep origin.url | grep -o "[^/]*$"` 204 | if [ $repo ]; then echo "✓ $lib"; fi 205 | cd "$old_path" 206 | fi 207 | done 208 | ;; 209 | * ) 210 | cundle help 211 | ;; 212 | esac 213 | } 214 | --------------------------------------------------------------------------------