Source commit: be1f654ae8de7d5eeb2005b4e1a05bf1ebf3124f Public tree identity: sha256:ab53679496be4be7d1e02bc00723072774d1a3f87e10cc56558a752f28f6abb1
61 lines
1.7 KiB
JavaScript
Executable file
61 lines
1.7 KiB
JavaScript
Executable file
#!/usr/bin/env node
|
|
|
|
const assert = require("assert");
|
|
const cp = require("child_process");
|
|
const fs = require("fs");
|
|
const os = require("os");
|
|
const path = require("path");
|
|
|
|
const repo = path.resolve(__dirname, "..");
|
|
const temp = fs.mkdtempSync(path.join(os.tmpdir(), "clusterflux-cli-install-"));
|
|
const installRoot = path.join(temp, "install");
|
|
const targetDir =
|
|
process.env.CLUSTERFLUX_CLI_INSTALL_CARGO_TARGET_DIR ||
|
|
process.env.CARGO_TARGET_DIR ||
|
|
path.join(repo, "target");
|
|
const project = path.join(repo, "examples/launch-build-demo");
|
|
const binName = process.platform === "win32" ? "clusterflux.exe" : "clusterflux";
|
|
const installedBin = path.join(installRoot, "bin", binName);
|
|
|
|
try {
|
|
cp.execFileSync(
|
|
"cargo",
|
|
[
|
|
"install",
|
|
"--path",
|
|
"crates/clusterflux-cli",
|
|
"--bin",
|
|
"clusterflux",
|
|
"--root",
|
|
installRoot,
|
|
"--debug"
|
|
],
|
|
{
|
|
cwd: repo,
|
|
env: {
|
|
...process.env,
|
|
CARGO_TARGET_DIR: targetDir
|
|
},
|
|
stdio: "inherit"
|
|
}
|
|
);
|
|
|
|
assert(fs.existsSync(installedBin), "installed clusterflux binary must exist");
|
|
|
|
const inspection = JSON.parse(
|
|
cp.execFileSync(
|
|
installedBin,
|
|
["bundle", "inspect", "--project", project, "--json"],
|
|
{ cwd: repo, encoding: "utf8" }
|
|
)
|
|
);
|
|
|
|
assert.strictEqual(inspection.project, project);
|
|
assert.strictEqual(inspection.metadata.embeds_full_container_images, false);
|
|
assert(inspection.metadata.environments.some((env) => env.name === "linux"));
|
|
assert(inspection.metadata.selected_inputs.some((input) => input.path === "src/build.rs"));
|
|
} finally {
|
|
fs.rmSync(temp, { recursive: true, force: true });
|
|
}
|
|
|
|
console.log("CLI install smoke passed");
|