docs(install): fix typo and update indentation and whitespaces (#4941)

This commit is contained in:
Zhizhen He 2023-03-08 23:42:00 +08:00 committed by GitHub
parent 0c5b11da12
commit 000f5ed10d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 40 additions and 41 deletions

View File

@ -2,30 +2,30 @@
set -euo pipefail
# Envrionmental variables that need to be set. These are sane defaults
# Environmental variables that need to be set. These are sane defaults
# KEYCHAIN_ENTRY=AC_PASSWORD # Or whatever you picked for <AUTH_ITEM_NAME>
# RUNNER_TEMP=~/Library/Keychains/
# KEYCHAIN_FILENAME=login.keychain-db
#
# Environmental variables that can be set if needed. Else they will default to
# values selected for the CI
#
#
# The identifier for the application signing key. Can be a name or a fingerprint
# APPLICATION_KEY_IDENT=E03290CABE09E9E42341C8FC82608E91241FAD4A
# The identifier for the installer signing key. Can be a name or a fingerprint
# INSTALLATION_KEY_IDENT=E525359D0B5AE97B7B6F5BB465FEC872C117D681
usage(){
echo "Builds, signs, and notarizes starship."
echo "Read readme.md in the script directory to see the assumptions the script makes."
echo "Usage: $0 <path-to-starship-binary> <path-to-docs-directory> <arch> [pkgname]"
echo " Example: $0 target/release/starship docs/ x64"
echo " Example: $0 target/debug/starship docs/ arm64 starship-1.2.1-arm64.pkg"
echo ""
echo "If no pkgname is provided, the package will be named starship-<version>-<arch>.pkg"
usage() {
echo "Builds, signs, and notarizes starship."
echo "Read readme.md in the script directory to see the assumptions the script makes."
echo "Usage: $0 <path-to-starship-binary> <path-to-docs-directory> <arch> [pkgname]"
echo " Example: $0 target/release/starship docs/ x64"
echo " Example: $0 target/debug/starship docs/ arm64 starship-1.2.1-arm64.pkg"
echo ""
echo "If no pkgname is provided, the package will be named starship-<version>-<arch>.pkg"
}
script_dir="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
script_dir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
source "$script_dir/common.sh"
if [[ -z ${KEYCHAIN_ENTRY+x} ]]; then
@ -56,8 +56,8 @@ if [[ -z ${INSTALLATION_KEY_IDENT+x} ]]; then
fi
if [[ -z ${3+x} ]]; then
usage
exit 1
usage
exit 1
fi
starship_binary="$1"
@ -112,4 +112,4 @@ if [ "$pkgname" = "" ]; then
fi
echo ">>>> Placing final output at $pkgname"
mv starship.pkg "$pkgname"
mv starship.pkg "$pkgname"

View File

@ -8,7 +8,7 @@ set -euo pipefail
# Usage: run this script, passing $1 to the repository path. The script assumes
# it is being run from within a starship repository if $1 is not provided.
usage(){
usage() {
echo "Builds a component package for macOS."
echo "Assumes that the following items already exist:"
echo " - A starship binary which has already been notarized"
@ -17,10 +17,10 @@ usage(){
echo "Usage: $0 <path-to-starship-binary> <path-to-dist-directory>"
}
script_dir="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
script_dir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
source "$script_dir/common.sh"
cleanup_server(){
cleanup_server() {
if [[ -n "${server_pid-}" ]]; then
echo "Killing HTTP server ($server_pid) to clean up."
kill "$server_pid"
@ -77,7 +77,7 @@ sleep 3
# on MacOS by default, but lucky for us, it does exist on GHActions runners.
# Wget may return nonzero exit codes even if things were mostly fine (e.g. 404 for
# some links on translated pages) so we simply ignore if it has a failure
wget --mirror --convert-links --adjust-extension --page-requisites --no-parent 127.0.0.1:8000 &> wget.log || true
wget --mirror --convert-links --adjust-extension --page-requisites --no-parent 127.0.0.1:8000 &>wget.log || true
mkdir -p "$pkgdir/usr/local/share/doc/"
mv 127.0.0.1:8000 "$pkgdir/usr/local/share/doc/starship"
@ -87,4 +87,4 @@ trap - INT
# Build the component package
version="$(starship_version "$starship_program_file")"
pkgbuild --identifier com.starshipprompt.starship --version "$version" --root $pkgdir starship-component.pkg
pkgbuild --identifier com.starshipprompt.starship --version "$version" --root $pkgdir starship-component.pkg

View File

@ -4,25 +4,25 @@ component_package="$1"
resources="$2"
arch="$3"
usage(){
echo "Builds a distribution package for macOS."
echo "Assumes that the following items already exist:"
echo " - A starship component package"
echo " - Resources in a pkg_resources directory"
echo "Usage: $0 <path-to-component-package> <path-to-pkg-resources> <arch>"
echo " where arch is one of \"arm64\" or \"x86_64\""
usage() {
echo "Builds a distribution package for macOS."
echo "Assumes that the following items already exist:"
echo " - A starship component package"
echo " - Resources in a pkg_resources directory"
echo "Usage: $0 <path-to-component-package> <path-to-pkg-resources> <arch>"
echo " where arch is one of \"arm64\" or \"x86_64\""
}
script_dir="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
script_dir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
source "$script_dir/common.sh"
if [[ "$OSTYPE" != 'darwin'* ]]; then
error "This script only works on MacOS"
error "This script only works on MacOS"
fi
if [[ "${3-undefined}" = "undefined" ]]; then
usage
exit 1
usage
exit 1
fi
# Generate a distribution file with the appropriate architecture plists
@ -40,8 +40,7 @@ productbuild --synthesize --package starship-component.pkg --product "$archplist
# search for a line that matches our opening tag and insert our desired lines after it
# Solution taken from https://www.theunixschool.com/2012/06/insert-line-before-or-after-pattern.html
while read -r line
do
while read -r line; do
echo "$line"
if echo "$line" | grep -qF '<installer-gui-script '; then
echo '<welcome file="welcome.html" mime-type="text-html" />'
@ -49,10 +48,10 @@ do
echo '<conclusion file="conclusion.html" mime-type="text-html" />'
echo '<background file="icon.png" scaling="proportional" alignment="bottomleft"/>'
fi
done < starship_raw.dist > starship.dist
done <starship_raw.dist >starship.dist
# The above script does not correctly take care of the last line. Apply fixup.
echo '</installer-gui-script>' >> starship.dist
echo '</installer-gui-script>' >>starship.dist
echo "Creating distribution package with following distribution file:"
cat starship.dist
@ -64,4 +63,4 @@ echo "Component package is $component_package"
productbuild --distribution starship.dist --resources "$resources" --package-path "$component_package" starship-unsigned.pkg
# Clean up the distribution files
rm -- *.dist
rm -- *.dist

View File

@ -1,17 +1,17 @@
#!/bin/bash
error(){
echo "[ERROR]: $1"
exit 1
error() {
echo "[ERROR]: $1"
exit 1
}
starship_version(){
starship_version() {
starship_program_file="$1"
# Check if this is a relative path: if so, prepend './' to it
if [ "$1" = "${1#/}" ]; then
starship_program_file="./$starship_program_file"
fi
if "$starship_program_file" -V 2>&1 > /dev/null; then
if "$starship_program_file" -V 2>&1 >/dev/null; then
"$starship_program_file" -V | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+'
else
# try to get this information from Cargo.toml

View File

@ -138,7 +138,7 @@ attempts, run
xcrun notarytool history --keychain-profile "AC_PASSWORD"
```
Find the `id` of the attempt you wish to view, then run one of these commmands:
Find the `id` of the attempt you wish to view, then run one of these commands:
```
xcrun notarytool info <run-id> --keychain-profile "AC_PASSWORD"