mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-10-20 12:32:10 +08:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5be5862ccf |
@@ -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 }}
|
||||
|
||||
@@ -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 }}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -48,11 +48,6 @@ 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
|
||||
|
||||
@@ -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 -c "$full_path" > "${file:t:r}" ;;
|
||||
(*.z) uncompress -c "$full_path" > "${file:t:r}" ;;
|
||||
(*.lzma) unlzma "$full_path" ;;
|
||||
(*.z) uncompress "$full_path" ;;
|
||||
(*.zip|*.war|*.jar|*.ear|*.sublime-package|*.ipa|*.ipsw|*.xpi|*.apk|*.aar|*.whl|*.vsix|*.crx|*.pk3|*.pk4) unzip "$full_path" ;;
|
||||
(*.rar)
|
||||
if (( $+commands[unrar] )); then
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
#!/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"
|
||||
}
|
||||
@@ -22,17 +22,14 @@ fi
|
||||
# Define json tools for each method
|
||||
case "$JSONTOOLS_METHOD" in
|
||||
node)
|
||||
# Read stdin directly so input is not limited by command-line argument size.
|
||||
# node doesn't make it easy to deal with stdin, so we pass it as an argument with xargs -0
|
||||
function pp_json() {
|
||||
node -e '
|
||||
const input = require("fs").readFileSync(0, "utf8");
|
||||
console.log(JSON.stringify(JSON.parse(input), null, 4));
|
||||
'
|
||||
xargs -0 node -e 'console.log(JSON.stringify(JSON.parse(process.argv[1]), null, 4));'
|
||||
}
|
||||
function is_json() {
|
||||
node -e '
|
||||
xargs -0 node -e '
|
||||
try {
|
||||
JSON.parse(require("fs").readFileSync(0, "utf8"));
|
||||
json = JSON.parse(process.argv[1]);
|
||||
console.log("true");
|
||||
process.exit(0);
|
||||
} catch (e) {
|
||||
@@ -42,14 +39,10 @@ case "$JSONTOOLS_METHOD" in
|
||||
'
|
||||
}
|
||||
function urlencode_json() {
|
||||
node -e '
|
||||
console.log(encodeURIComponent(require("fs").readFileSync(0, "utf8")));
|
||||
'
|
||||
xargs -0 node -e "console.log(encodeURIComponent(process.argv[1]))"
|
||||
}
|
||||
function urldecode_json() {
|
||||
node -e '
|
||||
console.log(decodeURIComponent(require("fs").readFileSync(0, "utf8")));
|
||||
'
|
||||
xargs -0 node -e "console.log(decodeURIComponent(process.argv[1]))"
|
||||
}
|
||||
;;
|
||||
python3)
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
#!/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
@@ -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 the created scratch org]' \
|
||||
'(-a|--setalias)'{-a,--setalias}'[set an alias for 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)]' \
|
||||
|
||||
@@ -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 |
|
||||
| uvinw | `uv init --no-workspace` | Initialize a standalone project without joining a parent workspace |
|
||||
| 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 |
|
||||
| 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 |
|
||||
|
||||
Reference in New Issue
Block a user