Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ on the machine it fetches a private official Node first:
curl -fsSL https://readm3.com/install.sh | sh
```

Run it again to update; remove with `sh ~/.local/share/readm3/uninstall.sh`.
Update with `readm3 update` and remove with `readm3 uninstall`; both work the way readm3
was installed (this installer, npm, bun, pnpm or yarn), through
[@profullstack/cli](https://github.com/profullstack/cli).
Add `--desktop` to install the desktop editor as well (Linux x64; macOS and Windows
download it, see
[Desktop app](#desktop-app)):
Expand Down
3 changes: 3 additions & 0 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion desktop/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "readm3-desktop",
"productName": "readm3",
"version": "0.13.1",
"version": "0.13.2",
"private": true,
"description": "readm3 as a desktop app: a plain, fast text editor for Markdown and code.",
"author": "Profullstack, Inc. <hello@profullstack.com>",
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@profullstack/readm3",
"version": "0.13.1",
"version": "0.13.2",
"description": "Markdown editing and sharing for people and teams. Web/PWA, CLI, API and MCP with version history, view/edit links, and a terminal reader.",
"type": "module",
"license": "MIT",
Expand Down Expand Up @@ -43,6 +43,7 @@
},
"dependencies": {
"@modelcontextprotocol/sdk": "^1.30.0",
"@profullstack/cli": "^0.1.0",
"@profullstack/hqtui": "^0.5.0",
"@profullstack/synconfig": "^0.1.3",
"highlight.js": "^11.12.0",
Expand Down
18 changes: 15 additions & 3 deletions src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
/**
* Argument parsing and entry point. `readm3 --help` is the contract.
*/
import { statSync } from "node:fs";
import { dirname, resolve } from "node:path";
import { existsSync, realpathSync, statSync } from "node:fs";
import { dirname, join, resolve } from "node:path";
import { detectInstall, lifecycle, lifecycleUsage } from "@profullstack/cli";
import { pathToFileURL } from "node:url";
import { themeList } from "@profullstack/hqtui";
import { FLAVORS, isFlavor, type Flavor } from "./flavors.ts";
Expand All @@ -11,7 +12,7 @@ import { run, type ViewerOptions } from "./viewer.ts";
import { isCloudCommand, cloudMain, CLOUD_USAGE } from "./cloud-cli.ts";
import { isDesktopCommand, desktopMain, installedDesktop, prefersDesktop, DESKTOP_USAGE } from "./desktop-cli.ts";

export const VERSION = "0.13.1";
export const VERSION = "0.13.2";

/** The help text, exported so a test can hold it to the flags it documents. */
export const USAGE = `readm3 — a plain text editor for Markdown and code
Expand Down Expand Up @@ -61,6 +62,7 @@ Editing
ctrl+g keys for editing tab indent two spaces

${DESKTOP_USAGE}
${lifecycleUsage("readm3")}
${CLOUD_USAGE}`;

export interface ParsedArgs extends ViewerOptions {
Expand Down Expand Up @@ -186,7 +188,17 @@ export function parseArgs(argv: string[]): ParsedArgs {
return parsed;
}

/** An installer copy that also installed the desktop app keeps it on update. */
function keepDesktop(): string[] {
let script: string | undefined;
try { script = process.argv[1] && realpathSync(process.argv[1]); } catch { return []; }
const { share } = detectInstall({ name: "readm3", script });
return share && (existsSync(join(share, "desktop")) || existsSync(join(share, "readm3.AppImage"))) ? ["--desktop"] : [];
}

export async function main(argv: string[] = process.argv.slice(2)): Promise<void> {
// readm3 update / uninstall (remove): done the way this copy was installed.
if (await lifecycle(argv, { name: "readm3", package: "@profullstack/readm3", version: VERSION, installer: "https://readm3.com/install.sh", installerArgs: keepDesktop })) return;
const { accountCommand } = await import("./sync-cli.ts");
if (await accountCommand(argv)) return;
if (isCloudCommand(argv[0])) { await cloudMain(argv); return; }
Expand Down
5 changes: 5 additions & 0 deletions test/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ import { readFile } from "node:fs/promises";
import { parseArgs, USAGE, VERSION } from "../src/cli.ts";
import { FLAVORS } from "../src/flavors.ts";

test("help names update and uninstall", () => {
assert.match(USAGE, /readm3 update \[--check\]/);
assert.match(USAGE, /readm3 uninstall \[--yes\]/);
});

test("no arguments browse the working directory", () => {
const args = parseArgs([]);
assert.equal(args.root, process.cwd());
Expand Down
Loading