Skip to content
Merged
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
24 changes: 24 additions & 0 deletions .github/workflows/checks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Checks

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
lint-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 24
check-latest: true
cache: npm
- run: npm ci
- run: npm run format:check
- run: npm run lint
- run: npm test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.DS_Store
node_modules
dist
dist-test
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
node_modules
dist
dist-test
.DS_Store

5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ SimpleDoc defines two types of files:

- Date-prefixed Markdown files SHOULD be used for most documents that are tied to a specific time.
- MUST put date-prefixed files in a top level `docs/` folder, or a subfolder `docs/<topic>/`. Subfolders MAY be nested indefinitely.
- MUST use ISO 8601 date-prefixed (`YYYY-MM-DD`) filenames, with dash `-` character as the word delimiter: e.g. `docs/2025-12-22-implementation-plan.md`.
- MUST NOT use spaces or underscores to delimit words.
- MUST use ISO 8601 date prefixes (`YYYY-MM-DD`) the date MUST contain dashes.
- After the date prefix, lowercase filenames SHOULD use dashes (`-`) as word delimiters (kebab-case). Avoid spaces and underscores.
- MUST NOT use capital letters in filename for Latin, Greek, Cyrillic and other writing systems that have lowercase/uppercase distinction.
- MAY use non-ASCII characters, e.g. `docs/2025-12-22-postmortem-login-ausfälle.md`, `docs/2025-12-22-功能-设计说明.md`.
- Date-prefixed files SHOULD contain YAML frontmatter with at least `title`, `author` and `date` fields, but we are all people and sometimes don't have time to write a proper frontmatter, so it is not required. E.g.
Expand All @@ -32,6 +32,7 @@ SimpleDoc defines two types of files:
### 2. Capitalized files

- Capitalized files SHOULD be used for general documents that are not tied to a specific time, e.g. `README.md`, `AGENTS.md`, `INSTALL.md`, `HOW_TO_DEBUG.md`.
- If a capitalized filename has multiple words, it SHOULD use underscores (`CODE_OF_CONDUCT.md`). Dashes are common in the wild but not preferred by this spec.

## Installation

Expand Down
5 changes: 3 additions & 2 deletions docs/HOW_TO_DOC.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ If the name and email are not available for some reason, ask the user to provide

## File Naming

- Format: `YYYY-MM-DD-descriptive-title.md`. Always use lower case, words separated by hyphens.
- Format: `YYYY-MM-DD-descriptive-title.md`. The date MUST use dashes; the rest SHOULD be lowercase with hyphens (avoid underscores).
- Choose names that reflect the problem or topic, not the team or author.
- Example: `2025-06-20-api-migration-guide.md`.
- Place the file in the appropriate folder before committing.
Expand Down Expand Up @@ -81,7 +81,8 @@ SimpleDoc Guidelines:

## Final Checks Before Submitting

- [ ] Filename follows the `YYYY-MM-DD-…` pattern and lives in the correct directory.
- [ ] Filename follows the `YYYY-MM-DD-…` pattern (date uses dashes) and lives in the correct directory.
- [ ] Capitalized multi-word filenames use underscores (e.g., `CODE_OF_CONDUCT.md`).
- [ ] Timeless vs. dated classification is correct and filenames reflect the choice.
- [ ] Front matter is complete and accurate.
- [ ] Links to related documentation exist where applicable.
11 changes: 11 additions & 0 deletions docs/TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# TODO

## Refactors (production hardening)

- [x] Extract naming rules into `src/naming.ts` (date-prefix parsing, canonical detection, normalization) and reuse from both `src/migrator.ts` and `src/cli.ts`.
- [x] Introduce a `classifyDoc(relPath)` helper that returns `{ kind, desiredMode, shouldDatePrefix }` and refactor migration planning to use it (less nested logic, fewer edge-case bugs).
- [x] Make git lookups lazy + cached: only run `git log --follow` for files that actually need a date/author (date-prefixing + frontmatter), not for every candidate.
- [x] Harden renames on case-insensitive filesystems: force 2-phase renames when `from.toLowerCase() === to.toLowerCase()` (case-only renames like `readme.md -> README.md` can be flaky otherwise).
- [x] Split `src/cli.ts` into step modules (`src/cli/steps/*.ts`) so each step owns: detect → preview → prompt → apply, and new steps don’t bloat one giant function.
- [x] Tighten reference updates: add size limits/ignore rules (skip huge files), and optionally support more link patterns (`[text](docs/...)`, `<docs/...>`) without scanning everything blindly.
- [x] Centralize git operations in `src/git.ts` (async `spawn`, concurrency limiter, injectable `GitClient`) and use it from `src/migrator.ts`.
2 changes: 1 addition & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import tseslint from "typescript-eslint";

export default tseslint.config(
{
ignores: ["dist/**", "node_modules/**"],
ignores: ["dist/**", "dist-test/**", "node_modules/**"],
},
js.configs.recommended,
...tseslint.configs.recommended,
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@simpledoc/simpledoc",
"version": "0.1.0",
"version": "0.1.1",
"description": "SimpleDoc conventions and CLI tooling for Markdown documentation in codebases.",
"license": "MIT",
"author": "Onur Solmaz <info@solmaz.io>",
Expand All @@ -25,13 +25,15 @@
},
"scripts": {
"build": "tsc -p tsconfig.json",
"build:test": "tsc -p tsconfig.test.json",
"format": "prettier --write . --ignore-unknown",
"format:check": "prettier --check . --ignore-unknown",
"lint": "eslint . --max-warnings 0",
"prepack": "npm run build",
"prepare": "husky",
"migrate": "npm run -s build && node ./dist/bin/simpledoc.js migrate",
"migrate:dry": "npm run -s build && node ./dist/bin/simpledoc.js migrate --dry-run"
"migrate:dry": "npm run -s build && node ./dist/bin/simpledoc.js migrate --dry-run",
"test": "npm run -s build:test && node --test dist-test/test/integration/*.test.js"
},
"engines": {
"node": ">=18"
Expand Down
2 changes: 1 addition & 1 deletion src/bin/simpledoc.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env node
import { runCli } from "../cli.js";
import { runCli } from "../cli/index.js";

await runCli(process.argv);
Loading