mirror of
https://github.com/actionbook/actionbook.git
synced 2026-09-19 03:28:06 +08:00
731cc340d8
* [packages/cli]test: add comprehensive CLI test suite with E2E browser tests - Add unit tests for wrapper (actionbook.js), postinstall, config, profile, search, get, and sources commands - Add Tier 1 browser tests (arg validation, help output, defaults) - Add Tier 2 browser E2E tests (navigation, interaction, screenshots, cookies, tabs, error handling, JSON output) - Fix E2E test reliability: add --wait for element readiness after navigation, use eval-based form submit for login flow, match actual CLI exit codes - Suppress macOS Keychain dialogs in tests via --use-mock-keychain config - Set testTimeout to 60s for browser E2E operations - Export modules from actionbook.js and postinstall.js for testability Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * [packages/cli]fix: resolve Windows .exe suffix when locating test CLI binary Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * [packages/cli]fix: skip shell-script mock tests on Windows Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
72 lines
1.7 KiB
JavaScript
72 lines
1.7 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
/**
|
|
* Postinstall script for @actionbookdev/cli.
|
|
*
|
|
* Ensures the installed platform binary keeps executable permissions.
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
const fs = require("fs");
|
|
const path = require("path");
|
|
|
|
const PLATFORM_PACKAGES = {
|
|
"darwin-arm64": "@actionbookdev/cli-darwin-arm64",
|
|
"darwin-x64": "@actionbookdev/cli-darwin-x64",
|
|
"linux-x64": "@actionbookdev/cli-linux-x64-gnu",
|
|
"linux-arm64": "@actionbookdev/cli-linux-arm64-gnu",
|
|
"win32-x64": "@actionbookdev/cli-win32-x64",
|
|
"win32-arm64": "@actionbookdev/cli-win32-arm64",
|
|
};
|
|
|
|
function getBinaryPath() {
|
|
const platformKey = `${process.platform}-${process.arch}`;
|
|
const packageName = PLATFORM_PACKAGES[platformKey];
|
|
|
|
if (!packageName) {
|
|
return null;
|
|
}
|
|
|
|
const binaryName = process.platform === "win32" ? "actionbook.exe" : "actionbook";
|
|
|
|
const packageDir = resolvePackageDir(packageName);
|
|
if (!packageDir) {
|
|
return null;
|
|
}
|
|
|
|
return path.join(packageDir, "bin", binaryName);
|
|
}
|
|
|
|
function resolvePackageDir(packageName) {
|
|
try {
|
|
const packageJsonPath = require.resolve(`${packageName}/package.json`);
|
|
return path.dirname(packageJsonPath);
|
|
} catch {
|
|
const unscoped = packageName.split("/")[1];
|
|
const packageDir = path.join(__dirname, "..", "..", unscoped);
|
|
const packageJsonPath = path.join(packageDir, "package.json");
|
|
if (fs.existsSync(packageJsonPath)) {
|
|
return packageDir;
|
|
}
|
|
return null;
|
|
}
|
|
}
|
|
|
|
function main() {
|
|
const binaryPath = getBinaryPath();
|
|
if (!binaryPath) {
|
|
process.exit(0);
|
|
}
|
|
|
|
if (fs.existsSync(binaryPath) && process.platform !== "win32") {
|
|
fs.chmodSync(binaryPath, 0o755);
|
|
}
|
|
}
|
|
|
|
if (require.main === module) {
|
|
main();
|
|
}
|
|
|
|
module.exports = { main, getBinaryPath, resolvePackageDir, PLATFORM_PACKAGES };
|