mirror of
https://github.com/AikidoSec/safe-chain.git
synced 2026-05-26 12:10:49 +00:00
Some cleanup
This commit is contained in:
parent
a6956db8dc
commit
9bd29056c6
4 changed files with 10 additions and 70 deletions
|
|
@ -8,12 +8,12 @@ import { main } from "../src/main.js";
|
||||||
// Set eco system
|
// Set eco system
|
||||||
setEcoSystem(ECOSYSTEM_PY);
|
setEcoSystem(ECOSYSTEM_PY);
|
||||||
|
|
||||||
|
// Strip nodejs and wrapper script from args
|
||||||
// Strip '-m pip' or '-m pip3' from args if present
|
|
||||||
let argv = process.argv.slice(2);
|
let argv = process.argv.slice(2);
|
||||||
if (argv[0] === '-m' && argv[1] === 'pip') {
|
// If no args are passed, argv[0] and argv[1] are undefined, so this condition just evaluates to false and does not throw.
|
||||||
|
if (argv[0] === '-m' && (argv[1] === 'pip' || argv[1] === 'pip3')) {
|
||||||
setEcoSystem(ECOSYSTEM_PY);
|
setEcoSystem(ECOSYSTEM_PY);
|
||||||
setCurrentPipInvocation(PIP_INVOCATIONS.PY_PIP);
|
setCurrentPipInvocation(argv[1] === 'pip3' ? PIP_INVOCATIONS.PY3_PIP : PIP_INVOCATIONS.PY_PIP);
|
||||||
initializePackageManager(PIP_PACKAGE_MANAGER);
|
initializePackageManager(PIP_PACKAGE_MANAGER);
|
||||||
argv = argv.slice(2);
|
argv = argv.slice(2);
|
||||||
var exitCode = await main(argv);
|
var exitCode = await main(argv);
|
||||||
|
|
|
||||||
|
|
@ -10,11 +10,11 @@ setEcoSystem(ECOSYSTEM_PY);
|
||||||
|
|
||||||
// Strip nodejs and wrapper script from args
|
// Strip nodejs and wrapper script from args
|
||||||
let argv = process.argv.slice(2);
|
let argv = process.argv.slice(2);
|
||||||
if (argv[0] === '-m' && argv[1] === 'pip') {
|
// If no args are passed, argv[0] and argv[1] are undefined, so this condition just evaluates to false and does not throw.
|
||||||
|
if (argv[0] === '-m' && (argv[1] === 'pip' || argv[1] === 'pip3')) {
|
||||||
setEcoSystem(ECOSYSTEM_PY);
|
setEcoSystem(ECOSYSTEM_PY);
|
||||||
setCurrentPipInvocation(PIP_INVOCATIONS.PY3_PIP);
|
setCurrentPipInvocation(argv[1] === 'pip3' ? PIP_INVOCATIONS.PY3_PIP : PIP_INVOCATIONS.PY_PIP);
|
||||||
initializePackageManager(PIP_PACKAGE_MANAGER);
|
initializePackageManager(PIP_PACKAGE_MANAGER);
|
||||||
// Strip '-m pip' or '-m pip3' from args if present
|
|
||||||
argv = argv.slice(2);
|
argv = argv.slice(2);
|
||||||
var exitCode = await main(argv);
|
var exitCode = await main(argv);
|
||||||
process.exit(exitCode);
|
process.exit(exitCode);
|
||||||
|
|
|
||||||
|
|
@ -146,66 +146,5 @@ describe("Setup CI shell integration", () => {
|
||||||
const unixNpmShim = path.join(mockShimsDir, "npm");
|
const unixNpmShim = path.join(mockShimsDir, "npm");
|
||||||
assert.ok(!fs.existsSync(unixNpmShim), "Unix npm shim should not exist on Windows");
|
assert.ok(!fs.existsSync(unixNpmShim), "Unix npm shim should not exist on Windows");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should create python and python3 shims from unix-python wrapper template", async () => {
|
|
||||||
// Add unix-python wrapper template to mock templates
|
|
||||||
const unixPythonTemplatePath = path.join(
|
|
||||||
mockTemplateDir,
|
|
||||||
"path-wrappers",
|
|
||||||
"templates",
|
|
||||||
"unix-python-wrapper.template.sh"
|
|
||||||
);
|
|
||||||
fs.writeFileSync(
|
|
||||||
unixPythonTemplatePath,
|
|
||||||
"#!/bin/bash\n# Python wrapper\nexec aikido-pip \"$@\"\n",
|
|
||||||
"utf-8"
|
|
||||||
);
|
|
||||||
|
|
||||||
await setupCi();
|
|
||||||
|
|
||||||
// Check if python shim was created
|
|
||||||
const pythonShimPath = path.join(mockShimsDir, "python");
|
|
||||||
assert.ok(fs.existsSync(pythonShimPath), "python shim should exist");
|
|
||||||
// Check if python3 shim was created
|
|
||||||
const python3ShimPath = path.join(mockShimsDir, "python3");
|
|
||||||
assert.ok(fs.existsSync(python3ShimPath), "python3 shim should exist");
|
|
||||||
// Check content of python shim
|
|
||||||
const pythonShimContent = fs.readFileSync(pythonShimPath, "utf-8");
|
|
||||||
assert.ok(pythonShimContent.includes("Python wrapper"), "python shim should use unix-python wrapper template");
|
|
||||||
// Check content of python3 shim
|
|
||||||
const python3ShimContent = fs.readFileSync(python3ShimPath, "utf-8");
|
|
||||||
assert.ok(python3ShimContent.includes("Python wrapper"), "python3 shim should use unix-python wrapper template");
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should create python.cmd and python3.cmd shims from windows-python wrapper template on win32 platform", async () => {
|
|
||||||
mockPlatform = "win32";
|
|
||||||
// Add windows-python wrapper template to mock templates
|
|
||||||
const windowsPythonTemplatePath = path.join(
|
|
||||||
mockTemplateDir,
|
|
||||||
"path-wrappers",
|
|
||||||
"templates",
|
|
||||||
"windows-python-wrapper.template.cmd"
|
|
||||||
);
|
|
||||||
fs.writeFileSync(
|
|
||||||
windowsPythonTemplatePath,
|
|
||||||
"@echo off\nREM Python wrapper\n{{AIKIDO_COMMAND}} %*\n",
|
|
||||||
"utf-8"
|
|
||||||
);
|
|
||||||
|
|
||||||
await setupCi();
|
|
||||||
|
|
||||||
// Check if python.cmd shim was created
|
|
||||||
const pythonCmdShimPath = path.join(mockShimsDir, "python.cmd");
|
|
||||||
assert.ok(fs.existsSync(pythonCmdShimPath), "python.cmd shim should exist");
|
|
||||||
// Check if python3.cmd shim was created
|
|
||||||
const python3CmdShimPath = path.join(mockShimsDir, "python3.cmd");
|
|
||||||
assert.ok(fs.existsSync(python3CmdShimPath), "python3.cmd shim should exist");
|
|
||||||
// Check content of python.cmd shim
|
|
||||||
const pythonCmdShimContent = fs.readFileSync(pythonCmdShimPath, "utf-8");
|
|
||||||
assert.ok(pythonCmdShimContent.includes("Python wrapper"), "python.cmd should use windows-python wrapper template");
|
|
||||||
// Check content of python3.cmd shim
|
|
||||||
const python3CmdShimContent = fs.readFileSync(python3CmdShimPath, "utf-8");
|
|
||||||
assert.ok(python3CmdShimContent.includes("Python wrapper"), "python3.cmd should use windows-python wrapper template");
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -50,6 +50,7 @@ RUN volta install pnpm@${PNPM_VERSION}
|
||||||
# Install Bun
|
# Install Bun
|
||||||
RUN curl -fsSL https://bun.sh/install | bash
|
RUN curl -fsSL https://bun.sh/install | bash
|
||||||
|
|
||||||
|
|
||||||
# Install Python and pip (pip3)
|
# Install Python and pip (pip3)
|
||||||
RUN apt-get update && apt-get install -y python${PYTHON_VERSION} python3-pip && \
|
RUN apt-get update && apt-get install -y python${PYTHON_VERSION} python3-pip && \
|
||||||
ln -sf /usr/bin/python${PYTHON_VERSION} /usr/local/bin/python3 && \
|
ln -sf /usr/bin/python${PYTHON_VERSION} /usr/local/bin/python3 && \
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue