Skip to content

Commit

Permalink
Release v0.5.7
Browse files Browse the repository at this point in the history
  • Loading branch information
Hernán Morales Durand committed Mar 31, 2022
1 parent 30a8d41 commit 2788e40
Show file tree
Hide file tree
Showing 15 changed files with 84 additions and 299 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@ All notable changes to this project will be documented in this file. Dates are d

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

#### [0.5.7](https://github.com/hernanmd/pi/compare/0.5.6...0.5.7)

#### [0.5.6](https://github.com/hernanmd/pi/compare/0.5.5...0.5.6)

> 15 March 2022
- Release v0.5.6 [`30a8d41`](https://github.com/hernanmd/pi/commit/30a8d41f1ec84e045baf79621457c09c685c04e0)

#### [0.5.5](https://github.com/hernanmd/pi/compare/0.5.4...0.5.5)

> 7 March 2022
Expand Down
2 changes: 1 addition & 1 deletion DATE
Original file line number Diff line number Diff line change
@@ -1 +1 @@
15-03-2022
31-03-2022
45 changes: 35 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ Pharo Install - A command-line tool for installing [Pharo Smalltalk](https://www

PI is a MIT-pip-like application installer for Pharo Smalltalk. Copy & pasting install scripts found in forums or the web is an easy method, but it’s also time consuming because of the manual interaction, and hard to make the process reproducible.

PI turns copy & paste Smalltalk ([Metacello](https://github.com/pharo-open-documentation/pharo-wiki/blob/master/General/Baselines.md)) install scripts into shell one-liners which works on Unix/Linux, MacOS and Windows (MinGW64/MSYS).
PI turns copy & paste Smalltalk (Metacello Configurations) install scripts into shell one-liners which works on Unix/Linux, MacOS and Windows (MinGW64/MSYS).

PI automatically retrieve and parse Pharo GitHub repository information, and also downloads the latest stable Pharo image and virtual machine if none is found in the current directory. It also supports installing multiple packages at once.

# Requirements

- bash or zsh
- curl or wget
- [jq](https://stedolan.github.io/jq/) (a command line JSON processor)
- [gsed](https://www.gnu.org/software/sed/)
- jq (a command line JSON processor)
- gsed

# Installation

Expand All @@ -54,15 +54,41 @@ env | grep -i path

## bash users

For one shell session:
```bash
echo "export PATH=$HOME/.pi/pi/bin:$PATH" >> $HOME/.profile
export PATH=$HOME/.pi/pi/bin:$PATH
```
and you're done.

To persist usage between multiple shell sessions:
```bash
echo "export PATH=$HOME/.pi/pi/bin:$PATH" >> ~/.profile
```

To see the effect, do:
```bash
source ~/.profile
```
in the same tab or open a new tab.

## zsh users

For one shell session:
```bash
path+=$HOME/.pi/pi/bin
```
and you're done.

To persist usage between multiple shell sessions:
```bash
echo -n 'export PATH=$HOME/.pi/pi/bin:$PATH' >> ~/.zshrc
```

To see the effect, do:
```bash
source ~/.zshrc
```
in the same tab or open a new tab.

# Features

Expand All @@ -81,27 +107,27 @@ GitHub repositories must contain a README.md file and have "pharo" specified as
### Installing

Installing NeoCSV package:
```smalltalk
```bash
pi install NeoCSV
```

Installing multiple packages:
```smalltalk
```bash
pi install Diacritics ISO3166 StringExtensions
```

### Listing

List packages from GitHub
```smalltalk
```bash
pi list
```

### Searching

Search in GitHub repositories:

```smalltalk
```bash
pi search pillar
```

Expand All @@ -124,7 +150,7 @@ pi version
# Contribute

**Working on your first Pull Request?** You can learn how from this *free* series [How to Contribute to an Open Source Project on
GitHub](https://app.egghead.io/playlists/how-to-contribute-to-an-open-source-project-on-github)
GitHub](https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github)

If you have discovered a bug or have a feature suggestion, feel free to create an issue on Github.

Expand All @@ -144,7 +170,6 @@ See CHANGELOG.md
# ToDo

- Add log4sh logging feature.
- Install individual packages instead of only Metacello Configurations.
- Uninstall packages(?)
- i18n

2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.5.6
0.5.7
11 changes: 0 additions & 11 deletions libexec/piCatalog.sh

This file was deleted.

8 changes: 1 addition & 7 deletions libexec/piEnvVars.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,14 @@ piDate="$(<${BASH_SOURCE%/*}/../DATE)"
piVersion="$(<${BASH_SOURCE%/*}/../VERSION)"

cacheDir=$HOME/.pi/.pi-cache
# Default image name
imageName="Pharo.image"
setZeroConfURL
# Default Configuration/Baseline version (stable, development, bleedingEdge)
pkgVersion="stable"
# Detected Operating System
os="Unknown"

#################################
## SmalltalkHub Settings
#################################

stHubUrl="http://smalltalkhub.com/"
stHubPkgIndexFile="index.html"

#################################
## GitHub Settings
#################################
Expand Down
36 changes: 22 additions & 14 deletions libexec/piGitHub.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ fetchGitHubPkgNames () {
}

# Report how many packages were found in GitHub
countgh_packages () {
countGitHubPackages () {
local pageIndex=1
local perPage=1
downloadGitHubPkgNames "$pageIndex" "$perPage"
Expand All @@ -91,7 +91,7 @@ countgh_packages () {
# Currently uses exact match for package names
pkgGHInstall () {
pkgNameToInstall="$1"
fetchGitHubPkgNames "false"
fetchGitHubPkgNames
declare -a matchingPackages
local lcPharoPkgName installExpr fullInstallExpr saveImageExp fullInstallExpr

Expand Down Expand Up @@ -124,31 +124,39 @@ pkgGHInstall () {
$dApp -O README.md "https://raw.githubusercontent.com/$user/$p/master/README.md"
[ -f "README.md" ] || { printf "Could not find any README.md in the repository\n"; exit 1; }
# Extract installation expression from tag
installExpr=$(grep "^\[//]\:\ #\ (pi)" -A 15 README.md | sed '/\#/d;/^\[\/\//d;/^[[:space:]]*$/d;/.*smalltalk/d;/```/d')
# Use gsed to overcome BSD sed ignore-case limitations
# Ignore Smalltalk expressions past the first dot
installExpr=$(gsed -n '/^```smalltalk/I,/\.$/ p; /\]\./q' < README.md | gsed '/^```/ d;/^spec/I d')
if [ -z "$installExpr" ]; then
# Use gsed to overcome BSD sed ignore-case limitations
# Ignore following Smalltalk expressions, we only match until first dot is found
installExpr=$(gsed -n '/^```smalltalk/I,/\.$/ p; /\]\./q' < README.md | gsed '/^```/ d;/^spec/I d')
if [ -z "$installExpr" ]; then
printf "PI-compatible Smalltalk install expression not found\n"
return $?
fi
printf "PI-compatible Smalltalk install expression not found\n"
return $?
fi
# Save image after each Metacello package installation
saveImageExp=".Smalltalk snapshot: true andQuit: true."
fullInstallExpr="${installExpr} ${saveImageExp}"
# Download and install Pharo image if not present
installPharo
printf "Install command: ./pharo --headless %s eval \"%s\"" "$imageName" "$fullInstallExpr"
./pharo --headless "$imageName" eval "$fullInstallExpr"
# Remove README.md file
[ ! -e "README.md" ] || rm -f "README.md"
fi
return $?
}
}

# List packages in cache
listgh_packages () {
fetchGitHubPkgNames
listGitHubPackages () {
# Check package cache directory exists
if [ -d ${cacheDir} ]; then
if [ -z "$(ls -A ${cacheDir})" ]; then
initApp
fi
else
err "Package cache is broken. Repairing.\n"
initApp
fi
# Parse JSON file
jq -jr $jqListOptions \
jq -jr ${jqListOptions} \
${cacheDir}/*.js \
| column -s'|' -t -c 500 \
| LC_ALL='C' sort -t$'\t' -i -b -k1,2 -f
Expand Down
2 changes: 1 addition & 1 deletion libexec/piHelp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ The options include:
init Initialize and fetch PI Pharo package cache
install <pkgname> Install pkgname to the Image found in the current directory. Download Image if not found.
list List Pharo packages found in GitHub
search <pgname> Search for pkgname in SmalltalkHub and GitHub repositories
search <pgname> Search for pkgname in GitHub
version Show program version
Pharo Install project home page: https://github.com/hernanmd/pi
Expand Down
48 changes: 3 additions & 45 deletions libexec/piInstallPkg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,48 +7,7 @@
## Packages Installation Functions
##################################

source "${BASH_SOURCE%/*}"/piCatalog.sh

# Detect which Configuration version to install.
# This setting is global: Applied to all Configuration names passed as parameters.
setPkgVersionSetting () {
printf "Setting package version...\n"
for param in "$@"; do
case "$param" in
"--dev")
pkgVersion="development"
;;
"--bleedingEdge")
pkgVersion="bleedingEdge"
;;
esac
done
printf "Selected package version: %s\n" "$pkgVersion"
}

install_from_catalog () {
printf "Trying to install from Pharo Catalog...\n"
if ! (pkgCatalogInstall "$1"); then
printf "not found\n"
return 1
else
printf "done\n"
return 0
fi
}

install_from_smalltalkhub () {
printf "Trying to install from SmalltalkHub...\n"
if ! (pkgSHInstall "$1"); then
printf "not found\n"
return 1
else
printf "done\n"
return 0
fi
}

install_from_github () {
installFromGitHub () {
printf "Scanning GitHub repositories...\n"
if ! (pkgGHInstall "$1"); then
printf "exit with error.\n"
Expand All @@ -60,11 +19,10 @@ install_from_github () {
}

# Read argument packages and install from their repositories
install_packages () {
installPackages () {
printf "Installing packages...\n"
until [ -z "$1" ]; do
install_from_github "$1"
# || install_from_catalog "$1"
installFromGitHub "$1"
shift
done
}
9 changes: 4 additions & 5 deletions libexec/piParseCmdOptions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#

source "${BASH_SOURCE%/*}"/piHelp.sh
source "${BASH_SOURCE%/*}"/piSmalltalkHub.sh
source "${BASH_SOURCE%/*}"/piGitHub.sh
source "${BASH_SOURCE%/*}"/piSearch.sh
source "${BASH_SOURCE%/*}"/piInstallPkg.sh
Expand All @@ -13,22 +12,22 @@ source "${BASH_SOURCE%/*}"/piPharo.sh
parseCmdLine () {
case "$1" in
list )
listgh_packages
listGitHubPackages
;;
init )
init_db
;;
count )
countgh_packages
countGitHubPackages
;;
install | INSTALL )
install_packages "${@:2}"
installPackages "${@:2}"
;;
image | IMAGE )
installPharo
;;
search )
search_packages "${@:2}"
searchPackages "${@:2}"
;;
clean )
removeCacheDir
Expand Down
13 changes: 3 additions & 10 deletions libexec/piSearch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,21 @@
#

# source piGitHub.sh
# source piSmalltalkHub.sh

###################################
## Pharo Searching Packages Section
###################################

# Search for package passed as argument in the SmalltalkHub repository
searchsh_packages () {
fetchStHubPkgNames
printf -- '%s\n' "$pkgs[@]" | grep -i "$1" | sed 's/^/SmalltalkHub\: /'
}

# Search for package passed as argument in the GitHub repository
searchgh_packages () {
searchGitHubPackages () {
fetchGitHubPkgNames
printf -- '%s\n' "${ghPkgNames[@]}" | grep -i "$1" | sed 's/^/GitHub\: /'
}

# Search for package passed as argument in all supported repositories
search_packages () {
searchPackages () {
pkg_name="$1"
[[ -n $pkg_name ]] || { printf "Missing package name. Exiting\n"; exit 1; }
# searchsh_packages $pkg_name
searchgh_packages $pkg_name
searchGitHubPackages $pkg_name
}
Loading

0 comments on commit 2788e40

Please sign in to comment.