@moloodev/cli 0.8.0 → 0.9.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 +2 -0
- package/package.json +6 -6
- package/src/cli.ts +6 -2
- package/src/upgrade.ts +10 -1
package/README.md
CHANGED
|
@@ -10,4 +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 that runs the command. Inside a project with its own `@moloodev/cli`, commands are delegated to that CLI, so this shows the project's version.
|
|
14
|
+
|
|
13
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moloodev/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.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/platform": "0.
|
|
30
|
-
"@moloodev/ui": "0.
|
|
27
|
+
"@moloodev/editor-sdk": "0.9.0",
|
|
28
|
+
"@moloodev/editor-store": "0.9.0",
|
|
29
|
+
"@moloodev/platform": "0.9.0",
|
|
30
|
+
"@moloodev/ui": "0.9.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.9.0"
|
|
36
36
|
},
|
|
37
37
|
"publishConfig": {
|
|
38
38
|
"access": "public"
|
package/src/cli.ts
CHANGED
|
@@ -7,13 +7,13 @@ import { promoteEditorPackage, publishEditorPackage } from "./publish";
|
|
|
7
7
|
import { printEditorStatus } from "./editor-status";
|
|
8
8
|
import { createEditor, EDITOR_CREATE_USAGE } from "./editor-create";
|
|
9
9
|
import { apiErrorMessage, readApiBody } from "./api-result";
|
|
10
|
-
import { upgradeCli, UPGRADE_USAGE } from "./upgrade";
|
|
10
|
+
import { cliVersion, upgradeCli, UPGRADE_USAGE } from "./upgrade";
|
|
11
11
|
import { listWorkspaces, useWorkspace, type WorkspaceOptions } from "./workspace";
|
|
12
12
|
|
|
13
13
|
const EDITOR_USAGE =
|
|
14
14
|
`${EDITOR_CREATE_USAGE}\nUsage: moloo editor <dev|build|publish|status> [--dir <path>] [--out-dir <path>] [--view-port <port>] [--workspace <slug>]\nUsage: moloo editor publish [--track stable|beta] [--dir <path>] [--workspace <slug>]\nUsage: moloo editor promote beta stable [--dir <path>] [--workspace <slug>]\nDev view port: 4310 (default)`;
|
|
15
15
|
const WORKSPACE_USAGE = "Usage: moloo workspace list | use <slug>";
|
|
16
|
-
const USAGE = `Usage: moloo <command>\n\nCommands:\n login [--device]\n logout\n whoami\n upgrade\n workspace list | use <slug>\n editor create | dev | build | publish | promote | status\n\n${WORKSPACE_USAGE}\n${EDITOR_USAGE}`;
|
|
16
|
+
const USAGE = `Usage: moloo <command>\n moloo --version | -v\n\nCommands:\n login [--device]\n logout\n whoami\n upgrade\n workspace list | use <slug>\n editor create | dev | build | publish | promote | status\n\n${WORKSPACE_USAGE}\n${EDITOR_USAGE}`;
|
|
17
17
|
|
|
18
18
|
type Command = (args: readonly string[], options: WorkspaceOptions) => Promise<number>;
|
|
19
19
|
|
|
@@ -162,6 +162,10 @@ export async function runCli(argv: readonly string[], options: WorkspaceOptions
|
|
|
162
162
|
const [name, ...args] = argv;
|
|
163
163
|
const command =
|
|
164
164
|
name === undefined ? undefined : Object.hasOwn(commands, name) ? commands[name] : undefined;
|
|
165
|
+
if (argv.length === 1 && (name === "--version" || name === "-v")) {
|
|
166
|
+
console.log(cliVersion());
|
|
167
|
+
return 0;
|
|
168
|
+
}
|
|
165
169
|
const wantsHelp = argv.includes("--help") || argv.includes("-h");
|
|
166
170
|
if (wantsHelp) {
|
|
167
171
|
console.log(command?.usage ?? USAGE);
|
package/src/upgrade.ts
CHANGED
|
@@ -41,7 +41,7 @@ export interface UpgradeDeps {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
export async function upgradeCli(deps: UpgradeDeps = {}): Promise<number> {
|
|
44
|
-
const packageRoot = deps.packageRoot ??
|
|
44
|
+
const packageRoot = deps.packageRoot ?? cliPackageRoot();
|
|
45
45
|
const current = deps.currentVersion ?? readVersion(packageRoot);
|
|
46
46
|
const log = deps.log ?? console.log;
|
|
47
47
|
const install = detectInstall(packageRoot);
|
|
@@ -83,6 +83,15 @@ export function compareVersions(a: string, b: string): number {
|
|
|
83
83
|
return preA.localeCompare(preB, "en", { numeric: true });
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
+
function cliPackageRoot(): string {
|
|
87
|
+
return realpathSync(join(dirname(fileURLToPath(import.meta.url)), ".."));
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** Version of the CLI package that is running this code. */
|
|
91
|
+
export function cliVersion(): string {
|
|
92
|
+
return readVersion(cliPackageRoot());
|
|
93
|
+
}
|
|
94
|
+
|
|
86
95
|
function readVersion(packageRoot: string): string {
|
|
87
96
|
const pkg = JSON.parse(readFileSync(join(packageRoot, "package.json"), "utf8")) as { version?: unknown };
|
|
88
97
|
if (typeof pkg.version !== "string") throw new Error(`No version in ${packageRoot}/package.json`);
|