mirror of
https://github.com/AikidoSec/safe-chain.git
synced 2026-05-26 12:10:49 +00:00
Update startup scripts to use safe-chain instead of aikido-*
This commit is contained in:
parent
f1ee6567df
commit
a3bff105cc
3 changed files with 28 additions and 31 deletions
|
|
@ -45,7 +45,6 @@ const pkgManagerCommands = [
|
||||||
];
|
];
|
||||||
|
|
||||||
if (pkgManagerCommands.includes(command)) {
|
if (pkgManagerCommands.includes(command)) {
|
||||||
ui.writeInformation(process.argv.join(", "));
|
|
||||||
setEcoSystem(ECOSYSTEM_JS);
|
setEcoSystem(ECOSYSTEM_JS);
|
||||||
initializePackageManager(command);
|
initializePackageManager(command);
|
||||||
(async () => {
|
(async () => {
|
||||||
|
|
|
||||||
|
|
@ -39,12 +39,11 @@ function Invoke-RealCommand {
|
||||||
function Invoke-WrappedCommand {
|
function Invoke-WrappedCommand {
|
||||||
param(
|
param(
|
||||||
[string]$OriginalCmd,
|
[string]$OriginalCmd,
|
||||||
[string]$AikidoCmd,
|
|
||||||
[string[]]$Arguments
|
[string[]]$Arguments
|
||||||
)
|
)
|
||||||
|
|
||||||
if (Test-CommandAvailable $AikidoCmd) {
|
if (Test-CommandAvailable "safe-chain") {
|
||||||
& $AikidoCmd @Arguments
|
& safe-chain $OriginalCmd @Arguments
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Write-SafeChainWarning $OriginalCmd
|
Write-SafeChainWarning $OriginalCmd
|
||||||
|
|
@ -53,27 +52,27 @@ function Invoke-WrappedCommand {
|
||||||
}
|
}
|
||||||
|
|
||||||
function npx {
|
function npx {
|
||||||
Invoke-WrappedCommand "npx" "aikido-npx" $args
|
Invoke-WrappedCommand "npx" $args
|
||||||
}
|
}
|
||||||
|
|
||||||
function yarn {
|
function yarn {
|
||||||
Invoke-WrappedCommand "yarn" "aikido-yarn" $args
|
Invoke-WrappedCommand "yarn" $args
|
||||||
}
|
}
|
||||||
|
|
||||||
function pnpm {
|
function pnpm {
|
||||||
Invoke-WrappedCommand "pnpm" "aikido-pnpm" $args
|
Invoke-WrappedCommand "pnpm" $args
|
||||||
}
|
}
|
||||||
|
|
||||||
function pnpx {
|
function pnpx {
|
||||||
Invoke-WrappedCommand "pnpx" "aikido-pnpx" $args
|
Invoke-WrappedCommand "pnpx" $args
|
||||||
}
|
}
|
||||||
|
|
||||||
function bun {
|
function bun {
|
||||||
Invoke-WrappedCommand "bun" "aikido-bun" $args
|
Invoke-WrappedCommand "bun" $args
|
||||||
}
|
}
|
||||||
|
|
||||||
function bunx {
|
function bunx {
|
||||||
Invoke-WrappedCommand "bunx" "aikido-bunx" $args
|
Invoke-WrappedCommand "bunx" $args
|
||||||
}
|
}
|
||||||
|
|
||||||
function npm {
|
function npm {
|
||||||
|
|
@ -84,28 +83,28 @@ function npm {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
Invoke-WrappedCommand "npm" "aikido-npm" $args
|
Invoke-WrappedCommand "npm" $args
|
||||||
}
|
}
|
||||||
|
|
||||||
function pip {
|
function pip {
|
||||||
Invoke-WrappedCommand "pip" "aikido-pip" $args
|
Invoke-WrappedCommand "pip" $args
|
||||||
}
|
}
|
||||||
|
|
||||||
function pip3 {
|
function pip3 {
|
||||||
Invoke-WrappedCommand "pip3" "aikido-pip3" $args
|
Invoke-WrappedCommand "pip3" $args
|
||||||
}
|
}
|
||||||
|
|
||||||
function uv {
|
function uv {
|
||||||
Invoke-WrappedCommand "uv" "aikido-uv" $args
|
Invoke-WrappedCommand "uv" $args
|
||||||
}
|
}
|
||||||
|
|
||||||
# `python -m pip`, `python -m pip3`.
|
# `python -m pip`, `python -m pip3`.
|
||||||
function python {
|
function python {
|
||||||
Invoke-WrappedCommand 'python' 'aikido-python' $args
|
Invoke-WrappedCommand 'python' $args
|
||||||
}
|
}
|
||||||
|
|
||||||
# `python3 -m pip`, `python3 -m pip3'.
|
# `python3 -m pip`, `python3 -m pip3'.
|
||||||
function python3 {
|
function python3 {
|
||||||
Invoke-WrappedCommand 'python3' 'aikido-python3' $args
|
Invoke-WrappedCommand 'python3' $args
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,41 +17,40 @@ end
|
||||||
|
|
||||||
function wrapSafeChainCommand
|
function wrapSafeChainCommand
|
||||||
set original_cmd $argv[1]
|
set original_cmd $argv[1]
|
||||||
set aikido_cmd $argv[2]
|
set cmd_args $argv[2..-1]
|
||||||
set cmd_args $argv[3..-1]
|
|
||||||
|
|
||||||
if type -q $aikido_cmd
|
if type -q safe-chain
|
||||||
# If the aikido command is available, just run it with the provided arguments
|
# If the safe-chain command is available, just run it with the provided arguments
|
||||||
$aikido_cmd $cmd_args
|
safe-chain $original_cmd $cmd_args
|
||||||
else
|
else
|
||||||
# If the aikido command is not available, print a warning and run the original command
|
# If the safe-chain command is not available, print a warning and run the original command
|
||||||
printSafeChainWarning $original_cmd
|
printSafeChainWarning $original_cmd
|
||||||
command $original_cmd $cmd_args
|
command $original_cmd $cmd_args
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function npx
|
function npx
|
||||||
wrapSafeChainCommand "npx" "aikido-npx" $argv
|
wrapSafeChainCommand "npx" $argv
|
||||||
end
|
end
|
||||||
|
|
||||||
function yarn
|
function yarn
|
||||||
wrapSafeChainCommand "yarn" "aikido-yarn" $argv
|
wrapSafeChainCommand "yarn" $argv
|
||||||
end
|
end
|
||||||
|
|
||||||
function pnpm
|
function pnpm
|
||||||
wrapSafeChainCommand "pnpm" "aikido-pnpm" $argv
|
wrapSafeChainCommand "pnpm" $argv
|
||||||
end
|
end
|
||||||
|
|
||||||
function pnpx
|
function pnpx
|
||||||
wrapSafeChainCommand "pnpx" "aikido-pnpx" $argv
|
wrapSafeChainCommand "pnpx" $argv
|
||||||
end
|
end
|
||||||
|
|
||||||
function bun
|
function bun
|
||||||
wrapSafeChainCommand "bun" "aikido-bun" $argv
|
wrapSafeChainCommand "bun" $argv
|
||||||
end
|
end
|
||||||
|
|
||||||
function bunx
|
function bunx
|
||||||
wrapSafeChainCommand "bunx" "aikido-bunx" $argv
|
wrapSafeChainCommand "bunx" $argv
|
||||||
end
|
end
|
||||||
|
|
||||||
function npm
|
function npm
|
||||||
|
|
@ -66,5 +65,5 @@ function npm
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
wrapSafeChainCommand "npm" "aikido-npm" $argv
|
wrapSafeChainCommand "npm" $argv
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue