agent-enderun 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -0
- package/README.md +4 -2
- package/bin/cli.js +42 -13
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Agent Enderun (v0.0.
|
|
1
|
+
# Agent Enderun (v0.0.3)
|
|
2
2
|
|
|
3
3
|
[English](#english) | [Türkçe](#türkçe)
|
|
4
4
|
|
|
@@ -94,10 +94,12 @@ AGENT_ENDERUN_PACKAGE_MANAGER=pnpm npx agent-enderun init gemini
|
|
|
94
94
|
|
|
95
95
|
```bash
|
|
96
96
|
npx agent-enderun init gemini
|
|
97
|
-
|
|
97
|
+
pnpm install && pnpm run enderun:build
|
|
98
98
|
agent-enderun check
|
|
99
99
|
```
|
|
100
100
|
|
|
101
|
+
>If your repository uses workspace dependencies, Agent Enderun will prefer `pnpm` automatically. If `pnpm` is not installed, the CLI will try to enable it via Corepack or fall back to `npx pnpm`.
|
|
102
|
+
|
|
101
103
|
If you already use `pnpm` or `yarn`, the CLI will prefer the correct lockfile and runtime environment.
|
|
102
104
|
|
|
103
105
|
## CLI Quick Reference
|
package/bin/cli.js
CHANGED
|
@@ -5,6 +5,7 @@ import fs from "fs";
|
|
|
5
5
|
import path from "path";
|
|
6
6
|
import { fileURLToPath } from "url";
|
|
7
7
|
import crypto from "crypto";
|
|
8
|
+
import { execSync } from "child_process";
|
|
8
9
|
|
|
9
10
|
const __filename = fileURLToPath(import.meta.url);
|
|
10
11
|
const __dirname = path.dirname(__filename);
|
|
@@ -287,20 +288,47 @@ function getPackageManager() {
|
|
|
287
288
|
if (override) return override.toLowerCase();
|
|
288
289
|
|
|
289
290
|
const userAgent = process.env.npm_config_user_agent || "";
|
|
290
|
-
if (userAgent.includes("pnpm")) return "pnpm";
|
|
291
|
-
if (userAgent.includes("yarn")) return "yarn";
|
|
292
|
-
if (userAgent.includes("npm")) return "npm";
|
|
293
|
-
|
|
294
291
|
const npmExecPath = process.env.npm_execpath || "";
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
if (
|
|
300
|
-
if (
|
|
292
|
+
const hasPnpmLock = fs.existsSync(path.join(process.cwd(), "pnpm-lock.yaml"));
|
|
293
|
+
const hasPnpmWorkspace = fs.existsSync(path.join(process.cwd(), "pnpm-workspace.yaml"));
|
|
294
|
+
const hasYarnLock = fs.existsSync(path.join(process.cwd(), "yarn.lock")) || fs.existsSync(path.join(process.cwd(), "yarn.lock.json"));
|
|
295
|
+
|
|
296
|
+
if (userAgent.includes("pnpm") || npmExecPath.includes("pnpm")) return "pnpm";
|
|
297
|
+
if (userAgent.includes("yarn") || npmExecPath.includes("yarn")) return "yarn";
|
|
298
|
+
if (userAgent.includes("npm") || npmExecPath.includes("npm")) return "npm";
|
|
299
|
+
if (hasPnpmLock || hasPnpmWorkspace || usesWorkspaceProtocol()) return "pnpm";
|
|
300
|
+
if (hasYarnLock) return "yarn";
|
|
301
301
|
return "npm";
|
|
302
302
|
}
|
|
303
303
|
|
|
304
|
+
function usesWorkspaceProtocol() {
|
|
305
|
+
try {
|
|
306
|
+
const rootPkgPath = path.join(process.cwd(), "package.json");
|
|
307
|
+
if (!fs.existsSync(rootPkgPath)) return false;
|
|
308
|
+
const data = JSON.parse(fs.readFileSync(rootPkgPath, "utf8"));
|
|
309
|
+
if (data.workspaces || String(data.packageManager || "").includes("pnpm")) return true;
|
|
310
|
+
const checkDeps = (deps) => deps && Object.values(deps).some(v => typeof v === "string" && v.startsWith("workspace:"));
|
|
311
|
+
return checkDeps(data.dependencies) || checkDeps(data.devDependencies) || checkDeps(data.peerDependencies) || checkDeps(data.optionalDependencies);
|
|
312
|
+
} catch {
|
|
313
|
+
return false;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
function ensurePackageManagerAvailable(manager) {
|
|
318
|
+
if (manager !== "pnpm") return manager;
|
|
319
|
+
try {
|
|
320
|
+
execSync("pnpm --version", { stdio: "ignore" });
|
|
321
|
+
return "pnpm";
|
|
322
|
+
} catch {
|
|
323
|
+
try {
|
|
324
|
+
execSync("corepack enable pnpm", { stdio: "ignore" });
|
|
325
|
+
return "pnpm";
|
|
326
|
+
} catch {
|
|
327
|
+
return "npx pnpm";
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
|
|
304
332
|
/**
|
|
305
333
|
* Scaffold the framework into the target project.
|
|
306
334
|
*/
|
|
@@ -461,9 +489,10 @@ async function initCommand(selectedAdapter) {
|
|
|
461
489
|
}
|
|
462
490
|
|
|
463
491
|
const pkgMgr = getPackageManager();
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
const
|
|
492
|
+
const resolvedPkgMgr = ensurePackageManagerAvailable(pkgMgr);
|
|
493
|
+
console.log(`\nℹ️ Detected package manager: ${resolvedPkgMgr}`);
|
|
494
|
+
const installCmd = `${resolvedPkgMgr} install`;
|
|
495
|
+
const buildCmd = `${resolvedPkgMgr} run enderun:build`;
|
|
467
496
|
|
|
468
497
|
console.log("\n✨ Framework scaffolded! (v" + FRAMEWORK_VERSION + ")");
|
|
469
498
|
|