@moloodev/cli 0.9.0 → 0.10.0
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/README.md +1 -1
- package/bin/local-cli.mjs +17 -0
- package/bin/moloo.mjs +10 -2
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -10,6 +10,6 @@ Create a standalone editor with `moloo editor create <publisher>.<name>` (for ex
|
|
|
10
10
|
|
|
11
11
|
The `moloo` bin delegates to a project's installed `@moloodev/cli`, searching from the current directory upward. This keeps global invocations on the project's CLI version.
|
|
12
12
|
|
|
13
|
-
`moloo --version` (or `-v`) prints the version of the CLI
|
|
13
|
+
`moloo --version` (or `-v`) is never delegated. It prints the version of the CLI you invoked; inside a project whose own `@moloodev/cli` has a different version it adds it, e.g. `0.9.0 (local 0.6.0)`. Same versions print once.
|
|
14
14
|
|
|
15
15
|
`moloo upgrade` upgrades the globally installed CLI to the npm `latest` version and is never delegated to a project's CLI. It detects npm, pnpm, yarn or bun from the install path and runs that manager's global install; if the version is already latest it only says so. When the running CLI is a project dependency, it prints how to upgrade it with the project's package manager and changes nothing.
|
package/bin/local-cli.mjs
CHANGED
|
@@ -22,3 +22,20 @@ export function findLocalCli(cwd, currentBin, env = process.env) {
|
|
|
22
22
|
if (dirname(directory) === directory) return null;
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
+
|
|
26
|
+
/** `moloo --version`: the running CLI, plus the project's CLI when it differs. */
|
|
27
|
+
export function versionLine(currentBin, local) {
|
|
28
|
+
const own = packageVersion(currentBin);
|
|
29
|
+
const project = local ? packageVersion(local) : own;
|
|
30
|
+
return project === own ? own : `${own} (local ${project})`;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function packageVersion(bin) {
|
|
34
|
+
for (let directory = dirname(realpathSync(bin)); ; directory = dirname(directory)) {
|
|
35
|
+
try {
|
|
36
|
+
return JSON.parse(readFileSync(join(directory, "package.json"), "utf8")).version;
|
|
37
|
+
} catch (error) {
|
|
38
|
+
if (error.code !== "ENOENT" || dirname(directory) === directory) throw error;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
package/bin/moloo.mjs
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { spawnSync } from "node:child_process";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
|
-
import { findLocalCli, LOCAL_CLI_ENV } from "./local-cli.mjs";
|
|
4
|
+
import { findLocalCli, LOCAL_CLI_ENV, versionLine } from "./local-cli.mjs";
|
|
5
5
|
|
|
6
|
+
const self = fileURLToPath(import.meta.url);
|
|
7
|
+
const args = process.argv.slice(2);
|
|
8
|
+
// `--version`/`-v` report this CLI (and the project's, if different) without handing off,
|
|
9
|
+
// so older project CLIs that lack the flag never see it.
|
|
10
|
+
if (args.length === 1 && (args[0] === "--version" || args[0] === "-v")) {
|
|
11
|
+
console.log(versionLine(self, findLocalCli(process.cwd(), self)));
|
|
12
|
+
process.exit(0);
|
|
13
|
+
}
|
|
6
14
|
// `upgrade` targets the globally installed CLI itself, so it never hands off.
|
|
7
|
-
const local =
|
|
15
|
+
const local = args[0] === "upgrade" ? null : findLocalCli(process.cwd(), self);
|
|
8
16
|
if (local) {
|
|
9
17
|
const child = spawnSync(process.execPath, [local, ...process.argv.slice(2)], {
|
|
10
18
|
stdio: "inherit",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moloodev/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"moloo": "./bin/moloo.mjs"
|
|
@@ -24,15 +24,15 @@
|
|
|
24
24
|
"tw-animate-css": "^1.4.0",
|
|
25
25
|
"vite": "^8.2.2",
|
|
26
26
|
"zod": "^4.5.4",
|
|
27
|
-
"@moloodev/editor-sdk": "0.
|
|
28
|
-
"@moloodev/editor-store": "0.
|
|
29
|
-
"@moloodev/
|
|
30
|
-
"@moloodev/
|
|
27
|
+
"@moloodev/editor-sdk": "0.10.0",
|
|
28
|
+
"@moloodev/editor-store": "0.10.0",
|
|
29
|
+
"@moloodev/ui": "0.10.0",
|
|
30
|
+
"@moloodev/platform": "0.10.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@types/node": "^24.13.3",
|
|
34
34
|
"typescript": "^7.0.2",
|
|
35
|
-
"@moloodev/typescript-config": "0.
|
|
35
|
+
"@moloodev/typescript-config": "0.10.0"
|
|
36
36
|
},
|
|
37
37
|
"publishConfig": {
|
|
38
38
|
"access": "public"
|