Update documentation

This commit is contained in:
Reinier Criel 2025-10-23 10:23:42 -07:00
parent c85802dd2e
commit f817bf887a
8 changed files with 82 additions and 20 deletions

View file

@ -11,6 +11,7 @@ export const knownAikidoTools = [
{ tool: "pnpx", aikidoCommand: "aikido-pnpx" },
{ tool: "bun", aikidoCommand: "aikido-bun" },
{ tool: "bunx", aikidoCommand: "aikido-bunx" },
{ tool: "pip", aikidoCommand: "aikido-pip" },
// When adding a new tool here, also update the documentation for the new tool in the README.md
];

View file

@ -181,4 +181,22 @@ describe("removeLinesMatchingPatternTests", () => {
const resultLines = result.split("\n");
assert.strictEqual(resultLines.length, 5, "Should have exactly 5 lines");
});
it("should include pip in knownAikidoTools and in the package manager list", async () => {
// Import helpers after setting up the mock
const { knownAikidoTools, getPackageManagerList } = await import("./helpers.js");
// Verify pip tool
const hasPip = knownAikidoTools.some(
(t) => t.tool === "pip" && t.aikidoCommand === "aikido-pip"
);
assert.ok(hasPip, "knownAikidoTools should include pip");
// Verify pip appears in the human-readable list
const list = getPackageManagerList();
assert.ok(
/(^|[,\s])pip(,|\s| and)/.test(list) && /commands$/.test(list),
`getPackageManagerList should include 'pip' (actual: ${list})`
);
});
});

View file

@ -46,8 +46,14 @@ function createUnixShims(shimsDir) {
const template = fs.readFileSync(templatePath, "utf-8");
// Create a shim for each tool
// Create a shim for each tool except pip for now.
// TODO(pip): Enable pip and pip3 CI support
let created = 0;
for (const toolInfo of knownAikidoTools) {
if (toolInfo.tool === "pip") {
continue; // Skip pip shims in CI for now
}
const shimContent = template
.replaceAll("{{PACKAGE_MANAGER}}", toolInfo.tool)
.replaceAll("{{AIKIDO_COMMAND}}", toolInfo.aikidoCommand);
@ -57,10 +63,11 @@ function createUnixShims(shimsDir) {
// Make the shim executable on Unix systems
fs.chmodSync(shimPath, 0o755);
created++;
}
ui.writeInformation(
`Created ${knownAikidoTools.length} Unix shim(s) in ${shimsDir}`
`Created ${created} Unix shim(s) in ${shimsDir}`
);
}
@ -82,18 +89,25 @@ function createWindowsShims(shimsDir) {
const template = fs.readFileSync(templatePath, "utf-8");
// Create a shim for each tool
// Create a shim for each tool except pip for now.
// TODO(pip): Enable pip and pip3 CI support
let created = 0;
for (const toolInfo of knownAikidoTools) {
if (toolInfo.tool === "pip") {
continue; // Skip pip shims in CI for now
}
const shimContent = template
.replaceAll("{{PACKAGE_MANAGER}}", toolInfo.tool)
.replaceAll("{{AIKIDO_COMMAND}}", toolInfo.aikidoCommand);
const shimPath = path.join(shimsDir, `${toolInfo.tool}.cmd`);
fs.writeFileSync(shimPath, shimContent, "utf-8");
created++;
}
ui.writeInformation(
`Created ${knownAikidoTools.length} Windows shim(s) in ${shimsDir}`
`Created ${created} Windows shim(s) in ${shimsDir}`
);
}

View file

@ -68,3 +68,13 @@ function npm
wrapSafeChainCommand "npm" "aikido-npm" $argv
end
function pip
# Default to Python 2 major version when explicitly calling pip
wrapSafeChainCommand "pip" "aikido-pip" --target-version-major "2" $argv
end
function pip3
# Route to Python 3 when calling pip3
wrapSafeChainCommand "pip3" "aikido-pip" --target-version-major "3" $argv
end

View file

@ -50,15 +50,6 @@ function bunx() {
wrapSafeChainCommand "bunx" "aikido-bunx" "$@"
}
function pip() {
wrapSafeChainCommand "pip" "aikido-pip" --target-version-major "2" "$@"
}
function pip3() {
wrapSafeChainCommand "pip3" "aikido-pip" --target-version-major "3" "$@"
}
function npm() {
if [[ "$1" == "-v" || "$1" == "--version" ]] && [[ $# -eq 1 ]]; then
# If args is just -v or --version and nothing else, just run the npm version command
@ -69,3 +60,11 @@ function npm() {
wrapSafeChainCommand "npm" "aikido-npm" "$@"
}
function pip() {
wrapSafeChainCommand "pip" "aikido-pip" --target-version-major "2" "$@"
}
function pip3() {
wrapSafeChainCommand "pip3" "aikido-pip" --target-version-major "3" "$@"
}

View file

@ -86,3 +86,15 @@ function npm {
Invoke-WrappedCommand "npm" "aikido-npm" $args
}
function pip {
# Default to Python 2 major version when explicitly calling pip
$forward = @("--target-version-major", "2") + $args
Invoke-WrappedCommand "pip" "aikido-pip" $forward
}
function pip3 {
# Route to Python 3 when calling pip3
$forward = @("--target-version-major", "3") + $args
Invoke-WrappedCommand "pip3" "aikido-pip" $forward
}