27 changed files with 271 additions and 109 deletions
+1 -1
View File
@@ -26,7 +26,7 @@ jobs:
fetch-depth: 0
- name: Authenticate as @ohmyzsh
id: generate-token
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0
with:
client-id: ${{ secrets.OHMYZSH_CLIENT_ID }}
private-key: ${{ secrets.OHMYZSH_APP_PRIVATE_KEY }}
+1 -1
View File
@@ -22,7 +22,7 @@ jobs:
egress-policy: audit
- name: Authenticate as @ohmyzsh
id: generate-token
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0
with:
client-id: ${{ secrets.OHMYZSH_CLIENT_ID }}
private-key: ${{ secrets.OHMYZSH_APP_PRIVATE_KEY }}
+2 -2
View File
@@ -46,7 +46,7 @@ jobs:
persist-credentials: false
- name: "Run analysis"
uses: ossf/scorecard-action@2d1146689b8cda280b9bc96326124645441f03bc # v2.4.4
uses: ossf/scorecard-action@fa7117db83c52d787ae5a89f350999701505d78e # v2.5.0
with:
results_file: results.sarif
results_format: sarif
@@ -60,6 +60,6 @@ jobs:
retention-days: 5
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@24c54180a607b1449ed407dd24f251e4e9147c8d # v4.38.3
uses: github/codeql-action/upload-sarif@6f2ac81f5cd81fe351a197ba0b00d91d03cd2aee # v4.39.0
with:
sarif_file: results.sarif
+15 -25
View File
@@ -1,6 +1,6 @@
# Bridgetown plugin
This plugin adds aliases for common [Bridgetown](https://www.bridgetownrb.com/) commands.
This plugin adds some aliases and autocompletion for common [Bridgetown](https://bridgetownrb.com/) commands.
To use it, add `bridgetown` to the plugins array in your zshrc file:
@@ -10,27 +10,17 @@ plugins=(... bridgetown)
## Aliases
Most aliases use the project's `bin/bridgetown` executable so the command runs with the Bridgetown version
locked in its `Gemfile`. The `br` and `brn` aliases use the globally installed executable and can be run
outside a Bridgetown project.
| Alias | Command | Description |
| --------- | ---------------------------- | ---------------------------------------- |
| `br` | `bridgetown` | Run the globally installed CLI |
| `bra` | `bin/bridgetown apply` | Apply an automation |
| `brb` | `bin/bridgetown build` | Build the site |
| `brc` | `bin/bridgetown console` | Open the Bridgetown console |
| `brclean` | `bin/bridgetown clean` | Remove generated files and caches |
| `brco` | `bin/bridgetown configure` | Apply a bundled configuration |
| `brd` | `bin/bridgetown deploy` | Run the project's deployment task |
| `brdev` | `bin/bridgetown dev` | Start the development server |
| `bre` | `bin/bridgetown esbuild` | Manage the esbuild configuration |
| `brh` | `bin/bridgetown help` | Show command help |
| `brn` | `bridgetown new` | Create a new Bridgetown site |
| `brp` | `bin/bridgetown plugins` | Access plugin commands |
| `brpl` | `bin/bridgetown plugins list` | List installed plugins |
| `brs` | `bin/bridgetown start` | Start the development server |
| `brt` | `bin/bridgetown test` | Run the project's test build task |
`deploy` and `test` are standard tasks from the `Rakefile` generated for a new Bridgetown site. If the project
customizes or removes those tasks, the corresponding aliases follow that project behavior.
| Alias | Command |
|-------|----------------------------|
| br | `bridgetown` |
| bra | `bin/bridgetown apply` |
| brb | `bin/bridgetown build` |
| brc | `bin/bridgetown console` |
| brclean | `bin/bridgetown clean` |
| brd | `bin/bridgetown deploy` |
| brdoc | `bin/bridgetown doctor` |
| brh | `bin/bridgetown help` |
| brn | `bridgetown new` |
| brp | `bridgetown plugins` |
| brpl | `bridgetown plugins list` |
| brs | `bin/bridgetown start` |
+3 -6
View File
@@ -3,13 +3,10 @@ alias bra='bin/bridgetown apply'
alias brb='bin/bridgetown build'
alias brc='bin/bridgetown console'
alias brclean='bin/bridgetown clean'
alias brco='bin/bridgetown configure'
alias brd='bin/bridgetown deploy'
alias brdev='bin/bridgetown dev'
alias bre='bin/bridgetown esbuild'
alias brdoc='bin/bridgetown doctor'
alias brh='bin/bridgetown help'
alias brn='bridgetown new'
alias brp='bin/bridgetown plugins'
alias brpl='bin/bridgetown plugins list'
alias brp='bridgetown plugins'
alias brpl='bridgetown plugins list'
alias brs='bin/bridgetown start'
alias brt='bin/bridgetown test'
+5
View File
@@ -48,6 +48,11 @@ fi
0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
0="${${(M)0:#/*}:-$PWD/$0}"
# Make sure the cache directory exists; when the plugin is loaded by a
# standalone plugin manager (e.g. antigen) the core is not sourced, so
# $ZSH_CACHE_DIR/completions may not have been created yet (#13679).
[[ -d "$ZSH_CACHE_DIR/completions" ]] || mkdir -p "$ZSH_CACHE_DIR/completions"
# If the completion file doesn't exist yet, we need to autoload it and
# bind it to `docker`. Otherwise, compinit will have already done that.
if [[ ! -f "$ZSH_CACHE_DIR/completions/_docker" ]]; then
+2 -2
View File
@@ -107,8 +107,8 @@ EOF
(*.xz) xzcat "$full_path" > "${file:t:r}" ;;
(*.lrz) (( $+commands[lrunzip] )) && lrunzip "$full_path" ;;
(*.lz4) lz4 -d "$full_path" ;;
(*.lzma) unlzma "$full_path" ;;
(*.z) uncompress "$full_path" ;;
(*.lzma) unlzma -c "$full_path" > "${file:t:r}" ;;
(*.z) uncompress -c "$full_path" > "${file:t:r}" ;;
(*.zip|*.war|*.jar|*.ear|*.sublime-package|*.ipa|*.ipsw|*.xpi|*.apk|*.aar|*.whl|*.vsix|*.crx|*.pk3|*.pk4) unzip "$full_path" ;;
(*.rar)
if (( $+commands[unrar] )); then
+65
View File
@@ -0,0 +1,65 @@
#!/usr/bin/env zsh
# Run with: zsh -df plugins/extract/tests/extract.test.zsh
emulate -L zsh
setopt err_return
for tool in lzma unlzma uncompress; do
(( $+commands[$tool] )) || {
print -u2 -r -- "These tests require $tool."
exit 1
}
done
source "${0:A:h:h}/extract.plugin.zsh"
local test_dir=$(mktemp -d) original_dir=$PWD
check_extract() {
local extension=$1 mode=$2
local case_dir="$test_dir/$extension-$mode"
mkdir -p "$case_dir/source files" "$case_dir/work/target dir"
local archive="$case_dir/source files/sample.txt.$extension"
cp "$test_dir/fixture.$extension" "$archive"
builtin cd "$case_dir/work"
local output="$PWD/sample.txt"
local -a args
case "$mode" in
target)
args=(-t 'target dir')
output="$PWD/target dir/sample.txt"
;;
remove) args=(-r) ;;
esac
# Run the plugin without the test's ERR_RETURN option.
() {
emulate -L zsh
extract "${args[@]}" "$archive"
} || return 1
cmp "$test_dir/plain" "$output"
if [[ $mode == remove ]]; then
[[ ! -e $archive ]]
else
[[ -f $archive ]]
fi
print -r -- "PASS: $extension ($mode)"
}
{
print -r -- hello > "$test_dir/plain"
lzma -c "$test_dir/plain" > "$test_dir/fixture.lzma"
# "hello\n" as a .Z stream, since many systems only ship uncompress.
printf '\037\235\220\150\312\260\141\363\106\001' \
> "$test_dir/fixture.Z"
for extension in lzma Z; do
for mode in default target remove; do
check_extract "$extension" "$mode"
done
done
print 'All extract compressed-file tests passed.'
} always {
builtin cd "$original_dir"
rm -rf -- "$test_dir"
}
+5 -8
View File
@@ -1,7 +1,6 @@
# git-commit plugin
The git-commit plugin adds several
[git aliases](https://www.git-scm.com/docs/git-config#Documentation/git-config.txt-alias) for
The git-commit plugin adds several git subcommands for
[conventional commit](https://www.conventionalcommits.org/en/v1.0.0/#summary) messages.
To use it, add `git-commit` to the plugins array in your zshrc file:
@@ -31,15 +30,13 @@ Where `type` is one of the following:
- `test`
- `wip`
> NOTE: the alias for `revert` type is `rev`, as otherwise it conflicts with the git command of the same name.
> It will still generate a commit message in the format `revert: <message>`
> ⚠️ Enabling this plugin will (potentially) overwrite all `alias.<type>` that you manually set. Use with
> care!
> NOTE: the subcommand for `revert` type is `rev`, as otherwise it conflicts with the
> git command of the same name. It will still generate a commit message in the format
> `revert: <message>`
## Examples
| Git alias | Command |
| Git subcommand | Command |
| --------------------------------------------- | ---------------------------------------------------- |
| `git style "remove trailing whitespace"` | `git commit -m "style: remove trailing whitespace"` |
| `git wip "work in progress"` | `git commit -m "work in progress"` |
+1
View File
@@ -0,0 +1 @@
./omz_git_commit
+1
View File
@@ -0,0 +1 @@
./omz_git_commit
+1
View File
@@ -0,0 +1 @@
./omz_git_commit
+1
View File
@@ -0,0 +1 @@
./omz_git_commit
+1
View File
@@ -0,0 +1 @@
./omz_git_commit
+1
View File
@@ -0,0 +1 @@
./omz_git_commit
+1
View File
@@ -0,0 +1 @@
./omz_git_commit
+1
View File
@@ -0,0 +1 @@
./omz_git_commit
+1
View File
@@ -0,0 +1 @@
./omz_git_commit
+1
View File
@@ -0,0 +1 @@
./omz_git_commit
+1
View File
@@ -0,0 +1 @@
./omz_git_commit
+1
View File
@@ -0,0 +1 @@
./omz_git_commit
+38
View File
@@ -0,0 +1,38 @@
#!/usr/bin/env zsh
_omz_git_commit() {
0=${(%):-%x}
if [[ "$0" != */git-* ]]; then
echo >&2 "Expecting command named git-foo. Got '$0'."
return 1
fi
local _type="${0##*/git-}"
# The subcommand is shortened to avoid Git's built-in revert command.
if [[ "$_type" == rev ]]; then
_type=revert
fi
local _scope _attention _message
while [ $# -ne 0 ]; do
case $1 in
-s | --scope )
if [ -z $2 ]; then
echo >&2 "Missing scope!"
return 1
fi
_scope="$2"
shift 2
;;
-a | --attention )
_attention="!"
shift 1
;;
* )
_message="${_message} $1"
shift 1
;;
esac
done
git commit -m "${_type}${_scope:+(${_scope})}${_attention}:${_message}"
}
_omz_git_commit "$@"
+42 -55
View File
@@ -1,58 +1,45 @@
local _rev="$(git -C $ZSH rev-parse HEAD 2> /dev/null)"
if [[ $_rev == $(git config --global --get oh-my-zsh.git-commit-alias 2> /dev/null) ]]; then
return
fi
git config --global oh-my-zsh.git-commit-alias "$_rev"
# Add git-commit commands directory to path
0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
0="${${(M)0:#/*}:-$PWD/$0}"
path=("${0:a:h}/git-commands" $path)
local -a _git_commit_aliases
_git_commit_aliases=(
'build'
'chore'
'ci'
'docs'
'feat'
'fix'
'perf'
'refactor'
'revert'
'style'
'test'
'wip'
)
# Append completions for custom git commands
() {
local -a git_user_commands
zstyle -a ':completion:*:*:git:*' user-commands 'git_user_commands' \
|| git_user_commands=()
git_user_commands+=(
build:'Commit with a message indicating a build' \
chore:'Commit with a message indicating a chore' \
ci:'Commit with a message indicating a CI change' \
docs:'Commit with a message indicating an update to the documentation' \
feat:'Commit with a message indicating a feature' \
fix:'Commit with a message indicating a fix' \
perf:'Commit with a message indicating a performance enhancement' \
refactor:'Commit with a message indicating a refactor' \
rev:'Commit with a message indicating a revert' \
style:'Commit with a message indicating a style change' \
test:'Commit with a message indicating updates to tests' \
wip:'Commit with a message indicating a work in progress'
)
zstyle ':completion:*:*:git:*' user-commands "${git_user_commands[@]}"
}
local _alias _type
for _type in "${_git_commit_aliases[@]}"; do
# an alias can't be named "revert" because the git command takes precedence
# https://stackoverflow.com/a/3538791
case "$_type" in
revert) _alias=rev ;;
*) _alias=$_type ;;
esac
local _func='!a() {
local _scope _attention _message
while [ $# -ne 0 ]; do
case $1 in
-s | --scope )
if [ -z $2 ]; then
echo "Missing scope!"
return 1
# Clean up aliases from the prior implementation of git-commit. Keep this migration
# for users upgrading from versions that still wrote aliases to .gitconfig.
() {
git config --global --get oh-my-zsh.git-commit-alias &> /dev/null || return 0
local -a old_git_aliases=(
'build' 'chore' 'ci'
'docs' 'feat' 'fix'
'perf' 'refactor' 'rev'
'style' 'test' 'wip'
)
local git_alias
for git_alias in $old_git_aliases; do
if [[ "$(git config --global --get alias.$git_alias | tr '\n' ' ')" == "!a() { local _scope _attention _message"* ]]; then
git config --global --unset alias.$git_alias
fi
_scope="$2"
shift 2
;;
-a | --attention )
_attention="!"
shift 1
;;
* )
_message="${_message} $1"
shift 1
;;
esac
done
git commit -m "'$_type'${_scope:+(${_scope})}${_attention}:${_message}"
}; a'
git config --global alias.$_alias "$_func"
done
done
git config --global --unset oh-my-zsh.git-commit-alias
}
+13 -6
View File
@@ -22,14 +22,17 @@ fi
# Define json tools for each method
case "$JSONTOOLS_METHOD" in
node)
# node doesn't make it easy to deal with stdin, so we pass it as an argument with xargs -0
# Read stdin directly so input is not limited by command-line argument size.
function pp_json() {
xargs -0 node -e 'console.log(JSON.stringify(JSON.parse(process.argv[1]), null, 4));'
node -e '
const input = require("fs").readFileSync(0, "utf8");
console.log(JSON.stringify(JSON.parse(input), null, 4));
'
}
function is_json() {
xargs -0 node -e '
node -e '
try {
json = JSON.parse(process.argv[1]);
JSON.parse(require("fs").readFileSync(0, "utf8"));
console.log("true");
process.exit(0);
} catch (e) {
@@ -39,10 +42,14 @@ case "$JSONTOOLS_METHOD" in
'
}
function urlencode_json() {
xargs -0 node -e "console.log(encodeURIComponent(process.argv[1]))"
node -e '
console.log(encodeURIComponent(require("fs").readFileSync(0, "utf8")));
'
}
function urldecode_json() {
xargs -0 node -e "console.log(decodeURIComponent(process.argv[1]))"
node -e '
console.log(decodeURIComponent(require("fs").readFileSync(0, "utf8")));
'
}
;;
python3)
@@ -0,0 +1,64 @@
#!/usr/bin/env zsh
# Run with: zsh -df plugins/jsontools/tests/jsontools.test.zsh
emulate -L zsh
setopt err_return
(( $+commands[node] )) || {
print -u2 'These tests require Node.js.'
exit 1
}
JSONTOOLS_METHOD=node
source "${0:A:h:h}/jsontools.plugin.zsh"
local test_dir=$(mktemp -d)
check_output() {
local tool=$1 description=$2 expected_status=${3:-0}
local -i result=0
$tool < "$test_dir/input" > "$test_dir/actual" || result=$?
if (( result != expected_status )) \
|| ! cmp -s "$test_dir/expected" "$test_dir/actual"; then
print -u2 -r -- "FAIL: $description ($tool exited $result)"
return 1
fi
print -r -- "PASS: $description"
}
{
print -rn -- '{"value":42}' > "$test_dir/input"
printf '{\n "value": 42\n}\n' > "$test_dir/expected"
check_output pp_json 'pretty-print a small document'
# Larger than the 128 KiB limit for a single command-line argument.
local large_value=${(l:262144::x:):-}
print -rn -- '{"value":"'"$large_value"'"}' > "$test_dir/input"
printf '{\n "value": "%s"\n}\n' "$large_value" > "$test_dir/expected"
check_output pp_json 'pretty-print a large document'
print -r -- true > "$test_dir/expected"
check_output is_json 'validate a large document'
print -r -- '%7B%22value%22%3A%22'"$large_value"'%22%7D' \
> "$test_dir/expected"
check_output urlencode_json 'encode a large document'
local encoded=$(< "$test_dir/expected")
print -rn -- "$encoded" > "$test_dir/input"
print -r -- '{"value":"'"$large_value"'"}' > "$test_dir/expected"
check_output urldecode_json 'decode a large document'
# Passed as an argument, node used to parse this as its own option.
print -rn -- '--version' > "$test_dir/input"
print -r -- '--version' > "$test_dir/expected"
check_output urlencode_json 'encode input that starts with --'
print -rn -- '{invalid}' > "$test_dir/input"
print -r -- false > "$test_dir/expected"
check_output is_json 'reject invalid JSON' 1
printf '1\0002' > "$test_dir/input"
check_output is_json 'reject input with NUL bytes' 1
print 'All jsontools Node.js tests passed.'
} always {
rm -rf -- "$test_dir"
}
+1 -1
View File
@@ -237,7 +237,7 @@ case "$words[1]" in
'(-c|--noancestors)'{-c,--noancestors}'[do not include second-generation package ancestors in the scratch org]' \
'(-i|--clientid)'{-i,--clientid}'[connected app consumer key]' \
'(-s|--setdefaultusername)'{-s,--setdefaultusername}'[set the created org as the default username]' \
'(-a|--setalias)'{-a,--setalias}'[set an alias for for the created scratch org]' \
'(-a|--setalias)'{-a,--setalias}'[set an alias for the created scratch org]' \
'(-e|--env)'{-e,--env}'[environment where the scratch org is created: \[sandbox*,virtual,prototype\] (sandbox*,virtual,prototype)]' \
'(-w|--wait)'{-w,--wait}'[the streaming client socket timeout (in minutes) (default:6, min:2)]' \
'(-d|--durationdays)'{-d,--durationdays}'[duration of the scratch org (in days) (default:7, min:1, max:30)]' \
+2 -2
View File
@@ -15,8 +15,8 @@ plugins=(... uv)
| :---- | ---------------------------------------------------------------------------------------- | :-------------------------------------------------------------------- |
| uva | `uv add` | Add packages to the project |
| uvexp | `uv export --format requirements-txt --no-hashes --output-file requirements.txt --quiet` | Export the lock file to `requirements.txt` |
| uvi | `uv init` | Initialize a new project in current workspace and environment. |
| uvinw | `uv init --no-workspace` | Initialize a new project in a new workspace and environment |
| uvi | `uv init` | Initialize a new project |
| uvinw | `uv init --no-workspace` | Initialize a standalone project without joining a parent workspace |
| uvl | `uv lock` | Lock the dependencies |
| uvlr | `uv lock --refresh` | Rebuild the lock file without upgrading dependencies |
| uvlu | `uv lock --upgrade` | Lock the dependencies to the newest compatible versions |