mirror of
https://github.com/moltbot/moltbot.git
synced 2026-03-08 06:54:24 +00:00
feat: automated completion setup in postinstall and onboarding
This commit is contained in:
@@ -248,12 +248,37 @@ function applyPatchFile({ patchPath, targetDir }) {
|
||||
applyPatchSet({ patchText, targetDir });
|
||||
}
|
||||
|
||||
function trySetupCompletion(repoRoot) {
|
||||
// Skip in CI or if explicitly disabled
|
||||
if (process.env.CI || process.env.OPENCLAW_SKIP_COMPLETION_SETUP) return;
|
||||
|
||||
const binPath = path.join(repoRoot, "openclaw.mjs");
|
||||
if (!fs.existsSync(binPath)) return;
|
||||
|
||||
// In development, dist might not exist yet during postinstall
|
||||
const distEntry = path.join(repoRoot, "dist", "index.js");
|
||||
if (!fs.existsSync(distEntry)) return;
|
||||
|
||||
try {
|
||||
// Run with OPENCLAW_SKIP_POSTINSTALL to avoid any weird recursion,
|
||||
// though distinct from this script.
|
||||
spawnSync(process.execPath, [binPath, "completion", "--install", "--yes"], {
|
||||
cwd: repoRoot,
|
||||
stdio: "inherit",
|
||||
env: { ...process.env, OPENCLAW_SKIP_POSTINSTALL: "1" },
|
||||
});
|
||||
} catch (err) {
|
||||
// Ignore errors to not break install
|
||||
}
|
||||
}
|
||||
|
||||
function main() {
|
||||
const repoRoot = getRepoRoot();
|
||||
process.chdir(repoRoot);
|
||||
|
||||
ensureExecutable(path.join(repoRoot, "dist", "entry.js"));
|
||||
setupGitHooks({ repoRoot });
|
||||
trySetupCompletion(repoRoot);
|
||||
|
||||
if (!shouldApplyPnpmPatchedDependenciesFallback()) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user