diff --git a/Dockerfile b/Dockerfile index 768291f..f2956aa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,10 @@ FROM hayd/alpine-deno:1.9.2 -WORKDIR /app USER deno +WORKDIR /bin COPY . . RUN deno cache --unstable readable.ts -CMD ["run", "--unstable", "--allow-read", "--allow-write", "readable.ts"] +ENTRYPOINT [ "deno", "run", "--unstable", "--allow-read", "--allow-write", "/bin/readable.ts" ] + +WORKDIR /data diff --git a/README.md b/README.md index 5d24d9e..183851b 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Using [Docker](https://www.docker.com/): ```sh docker pull ghcr.io/bobheadxi/readable:latest -docker run ghcr.io/bobheadxi/readable:latest +docker run -v $(pwd):/data ghcr.io/bobheadxi/readable:latest ``` ## Features @@ -42,21 +42,17 @@ Both these approaches have significant issues: - Line-breaking at some arbitrary character column looks nice when viewed, but is easily lost when making and suggesting edits, necessitating reflowing entire paragraphs. This leads to incomprehensible or uninformative diffs that are difficult to review. - - Writing entire paragraphs is reasonable readable nowadays due to most editors and viewers performing wrapping out-of-the-box, but they make suggestions and diffs difficult to review due to every single change causing a diff on entire paragraph. Readable performs a variant of [semantic line breaks](https://sembr.org/) that attempts to strike a balance between: - Making use of how most Markdown specifications ignore single new lines to still provide a good **rendered Markdown** experience. - - Leveraging modern line-wrapping in most viewers to maintain a good **raw Markdown** experience. - - Maintaining understandable diffs in Markdown documentation for a good **reviewing** experience. In general, Readable's semantic line breaks: - Allow multiple short sentences to be part of a single line. - - After a character threshold, breaks new sentences to a new line. This means that changes now reflect changes to *ideas* within semantic boundaries, and more accurately reflect the idea being changed. diff --git a/dev-tool.ts b/dev-tool.ts index d59d2ea..5c82588 100755 --- a/dev-tool.ts +++ b/dev-tool.ts @@ -227,6 +227,35 @@ const devScripts: DevScripts = { throw new Error(`unknown target ${target}`); } }, + "release": async (args, env) => { + const version = args[0]; + if (!version) { + throw new Error(`version required`); + } + + await Deno.writeTextFile( + "./version.ts", + `// Generated by dev-tool.ts + +export const READABLE_VERSION = "${version}"; +export const READABLE_COMMIT = "${env.commit}"; +`, + ); + const commit = Deno.run({ + cmd: ["git", "commit", "-a", "-m", `all: release readable@${version}`], + }); + const { code: commitStatus } = await commit.status(); + if (commitStatus) { + throw new Error("failed to commit"); + } + const tag = Deno.run({ + cmd: ["git", "tag", version, "-m", `readable@${version}`], + }); + const { code: tagStatus } = await tag.status(); + if (tagStatus) { + throw new Error("failed to tag"); + } + }, }; if (import.meta.main) { diff --git a/readable.ts b/readable.ts index 62ba629..18804c4 100644 --- a/readable.ts +++ b/readable.ts @@ -1,15 +1,20 @@ +import { READABLE_VERSION } from "./version.ts"; + import { cac } from "./deps/cac.ts"; -import check from "./cmd/check.ts"; +import check from "./cmd/check.ts"; import fmt from "./cmd/fmt.ts"; const cli = cac("readable"); + +cli.version(READABLE_VERSION); + /** * readable fmt */ cli.command("fmt [...globs]", "Format Markdown") .option("--to-stdout", "Output results to stdout instead of modifying files") - .action(async (globs: string[], opts) => { + .action(async (globs: string[], opts: any) => { console.debug("fmt"); await fmt(globs, opts); });