Skip to content

Commit

Permalink
Release v0.6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Hernán Morales Durand committed Jun 13, 2022
1 parent 74a271f commit 4045ad9
Show file tree
Hide file tree
Showing 14 changed files with 134 additions and 78 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.6.1](https://github.com/hernanmd/pi/compare/0.6.0...0.6.1)

#### [0.6.0](https://github.com/hernanmd/pi/compare/0.5.9...0.6.0)

> 23 May 2022
- Release v0.6.0 [`74a271f`](https://github.com/hernanmd/pi/commit/74a271f0dbf7cbdf985a540641ba13ff1605fe03)

#### [0.5.9](https://github.com/hernanmd/pi/compare/0.5.8...0.5.9)

> 6 May 2022
Expand Down
2 changes: 1 addition & 1 deletion DATE
Original file line number Diff line number Diff line change
@@ -1 +1 @@
06-05-2022
14-06-2022
10 changes: 8 additions & 2 deletions EXAMPLES
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@ List Pharo packages found in GitHub:
pi list

Search Pharo GitHub packages:
pi search pillar
pi search microdown

Download latest stable Pharo image and VM:
pi image

Install multiple packages:
pi install Diacriticals ISO3166 StringExtensions
pi install Diacriticals ISO3166 StringExtensions

Run the image in the current directory
pi run

Update the repository cache
pi update
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2018-2021 Hernán Morales Durand
Copyright (c) 2018-2022 Hernán Morales Durand

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
53 changes: 43 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
# Table of Contents

- [Description](#description)
- [Requirements](#requirements)
- [Installation](#installation)
- [Bash users](#bash-users)
- [Zsh users](#zsh-users)
- [Features](#features)
- [Usage](#usage)
- [Notes](#notes)
- [Examples](#examples)
- [Troubleshooting](#troubleshooting)
- [Contribute](#contribute)
Expand All @@ -20,18 +22,24 @@

Pharo Install - A command-line tool for installing [Pharo Smalltalk](https://www.pharo.org) packages.

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 is a MIT-pip-like application installer for Pharo Smalltalk. Copy & pasting Pharo 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 Configurations) install scripts into shell one-liners which works on Unix/Linux, MacOS and Windows (MinGW64/MSYS).
PI turns copy & paste [Metacello](https://github.com/Metacello/metacello) 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.
PI automatically retrieves and parses 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 (a command line JSON processor)
- gsed
- Install for MSYS users: `pacman -Suy jq`
- Install for Linux users: `apt install jq` or `yum install jq` or `dnf install jq` etc.
- Install for macOS users: `brew install jq`
- gsed
- Install for MSYS users: `ln /usr/bin/sed.exe /usr/local/bin/gsed`
- Install for Linux users: `ln /usr/bin/sed /usr/local/bin/gsed`
- Install for macOS users: `brew install gsed`

# Installation

Expand Down Expand Up @@ -63,12 +71,12 @@ and you're done.

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

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

Expand Down Expand Up @@ -101,7 +109,13 @@ in the same tab or open a new tab.

# Usage

GitHub repositories must contain a README.md file and have "pharo" specified as topic. Pi parses the README.md file and stops on the first smalltalk expression enclosed with backticks. This expression must contain an installation script in a Pharo image, i.e. that starts with Metacello. If the current directory already contains a Pharo image, PI will use that image.
Installable packages must contain:

- A Github README.md file
- "pharo" specified as topic.
- A Metacello installation script ending with a dot ".".

If the current directory already contains a Pharo image, PI will use that image, otherwise it will download a new stable image.

## Examples

Expand Down Expand Up @@ -129,7 +143,25 @@ pi list
Search in GitHub repositories:

```bash
pi search pillar
pi search microdown
```

Output may contain multiple repositories

```bash
pi search magritte
GitHub: peteruhnak/xml-magritte-generator
GitHub: philippeback/Magritte3Doc
GitHub: grype/Magritte-Swift
GitHub: hernanmd/Seaside-Magritte-Voyage
GitHub: hernanmd/Seaside-Bootstrap-Magritte-Voyage
GitHub: udoschneider/BootstrapMagritte
```

in that case, disambiguate specifying <owner>/<repository_name>, ex:

```bash
pi install <grype/Magritte-Swift>
```

# Troubleshooting
Expand Down Expand Up @@ -176,4 +208,5 @@ If you'd like to make some changes yourself, see the following:
- Install [release-it](https://www.npmjs.com/package/release-it)
- Copy or setup a [GitHub token](https://github.com/settings/tokens)
- Evaluate `export GITHUB_TOKEN=...` with the coped token as value. Alternatively, log-in to your GitHub account with your web browser and release-it will authenticate.

- Ensure NVM is installed and accessible running: `source ~/.nvm/nvm.sh`
- To interactively deploy run `./deploy.sh`
9 changes: 8 additions & 1 deletion deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,16 @@

set -eo pipefail


main () {
local version

if [ -f .nvmrc ]; then
source ~/.nvm/nvm.sh
nvm use
else
printf "Couldn't find .nvmrc file"
fi
echo $(date "+%d-%m-%Y") > DATE
[[ -f DATE ]] || { printf "Couldn't write DATE file for release\n"; exit 1; }

Expand All @@ -20,4 +27,4 @@ main () {
fi
}

main $*
main $*
6 changes: 3 additions & 3 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@
if ! check_install; then
cat <<-EOF
${YELLOW}
In order to make Pharo Install (pi) work, if you are using bash, you need to execute the following to add pi to your .bash_profile/.profile file:
If you are using bash, you need to execute the following to add pi to your PATH:
echo "export PATH=\$HOME/.pi/pi/bin:\$PATH" >> \$HOME/.profile
echo "export PATH=\$HOME/.pi/pi/bin:\$PATH" >> \$HOME/.bash_profile
If you are using zsh, execute the following to add pi to your path:
If you are using zsh, execute the following to add pi to your PATH:
path+=\$HOME/.pi/pi/bin
${NORMAL}"
Expand Down
20 changes: 10 additions & 10 deletions libexec/piGitHub.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ init_db () {
fetch_github_pkg_names
parse_github_pkg_count ${cacheDir}/"1.js"
BLA::stop_loading_animation 2> /dev/null
printf "Detected Pharo packages in GitHub: %s\n" "$ghPkgCount"
pi_log "Detected Pharo packages in GitHub: %s\n" "$ghPkgCount"
}

# Parse and store package names from GitHub API
Expand Down Expand Up @@ -81,7 +81,7 @@ count_github_packages () {
local perPage=1
download_github_pkg_names "$pageIndex" "$perPage"
parse_github_pkg_count ${cacheDir}/"$pageIndex.js"
printf "Detected Pharo packages in GitHub: %s\n" "$ghPkgCount"
pi_log "Detected Pharo packages in GitHub: %s\n" "$ghPkgCount"
}

# Install from GitHub
Expand All @@ -105,35 +105,35 @@ install_pkg_from_github () {
pkgCount=${#matchingPackages[@]}

if [ "$pkgCount" -gt 1 ]; then
printf "Found %s repositories with the package name \"%s\"\n" "$pkgCount" "$pkgNameToInstall"
printf "Listing follows...\n"
pi_log "Found %s repositories with the package name \"%s\"\n" "$pkgCount" "$pkgNameToInstall"
pi_log "Listing follows...\n"
cat -n <<< "${matchingPackages[@]}"
printf "Please provide the full name for the package you want to install <repository>/<package name>\n"
printf "%s\n" "${matchingPackages[@]}"
pi_log "Please provide the full name for the package you want to install <repository>/<package name>\n"
pi_log "%s\n" "${matchingPackages[@]}"
return 1
else
fullPackageName=${matchingPackages[0]}
printf "Selected package: %s\n" "$fullPackageName"
pi_log "Selected package: %s\n" "$fullPackageName"
# Parse GitHub repository name with package name
IFS=/ read user p <<< "$fullPackageName"

# Download README.md file
$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; }
[ -f "README.md" ] || { pi_err "Could not find any README.md in the repository\n"; exit 1; }
# Extract installation expression from tag
# 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
err "PI-compatible Smalltalk install expression not found\n"
pi_err "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
install_pharo
printf "Install command: ./pharo --headless %s eval \"%s\"" "$imageName" "$fullInstallExpr"
pi_log "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"
Expand Down
28 changes: 13 additions & 15 deletions libexec/piHelp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,11 @@ print_version () {
printf "pi - Pharo Install [version %s - %s]\n" "$piVersion" "$piDate"
}

printBasicHelp () {
print_basic_help () {
program_name=$(basename "$0")
printf "Usage: %s {list | count | init | clean | help | image | run | examples | install <pkgname>}\n" "$program_name"
printf "Usage: %s {count | image | install <pkgname>} | list | run | search <pkgname> | update\n" "$program_name"
}

# Future version
# --dev Set Configuration/Baseline to install development versions.
# --bleedingEdge Set Configuration/Baseline to install bleedingEdge version.
print_help () {
print_version
cat << EOF
Expand All @@ -27,21 +24,22 @@ PI is a tool for installing Pharo Smalltalk packages (http://www.pharo.org)
EOF

printBasicHelp
print_basic_help

cat << EOF
The options include:
clean Clean cache package directory
count Report how many packages were found in GitHub
examples Show usage examples
image Fetch the latest stable Pharo (VM + Image)
run Run a Pharo Image
clean Clean cache package directory.
count Report how many packages were found in GitHub.
examples Show usage examples.
image Fetch the latest stable Pharo (VM + Image).
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 GitHub
version Show program version
install <pkgname> Install pkgname to the Image found in the current directory.\n\t\tDownload image if not found.
list List Pharo packages found in GitHub.
run Run a Pharo Image.
search <pkgname> Search for pkgname in GitHub.
update Update package directory.
version Show program version.
Pharo Install project home page: https://github.com/hernanmd/pi
To report bugs or get some help check: https://github.com/hernanmd/pi/issues
Expand Down
32 changes: 16 additions & 16 deletions libexec/piParseCmdOptions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,39 +11,39 @@ source "${BASH_SOURCE%/*}"/piPharo.sh

parse_cmd_line () {
case "$1" in
list )
list_github_packages
;;
init )
init_db
;;
clean )
remove_cache_directory
;;
count )
count_github_packages
;;
install | INSTALL )
install_packages "${@:2}"
examples | EXAMPLES )
examples && exit 0
;;
image | IMAGE )
install_pharo
;;
init | INIT)
init_db
;;
install | INSTALL )
install_packages "${@:2}"
;;
list )
list_github_packages
;;
run | RUN )
run_pharo
;;
search )
search_packages "${@:2}"
;;
clean )
remove_cache_directory
;;
help | h )
print_help
update )
update_packages
;;
version )
print_version
;;
examples | EXAMPLES )
examples && exit 0
;;
* )
print_help
exit 1
Expand Down
Loading

0 comments on commit 4045ad9

Please sign in to comment.