@rawsql-ts/ddl-docs-cli 0.2.2 → 0.2.4

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/AGENTS.md CHANGED
@@ -1,27 +1,27 @@
1
- # Package Scope
2
- - Applies to `packages/ddl-docs-cli`.
3
- - Defines contract rules for the development CLI package.
4
-
5
- # Policy
6
- ## REQUIRED
7
- - SQL parsing behavior MUST stay AST-first through `rawsql-ts` APIs.
8
- - Regex parsing fallback MUST be guarded and limited to unsupported AST gaps.
9
- - Package dependency footprint MUST remain minimal.
10
-
11
- ## ALLOWED
12
- - CLI-only development usage MAY depend on package-local tooling.
13
-
14
- ## PROHIBITED
15
- - Treating this package as runtime application `src/` dependency.
16
-
17
- # Mandatory Workflow
18
- - Before committing changes under `packages/ddl-docs-cli`, run:
19
- - `pnpm --filter @rawsql-ts/ddl-docs-cli lint`
20
- - `pnpm --filter @rawsql-ts/ddl-docs-cli test`
21
- - `pnpm --filter @rawsql-ts/ddl-docs-cli build`
22
-
23
- # Hygiene
24
- - Temporary debug output MUST be removed before commit.
25
-
26
- # References
27
- - Parent policy context: [../../AGENTS.md](../../AGENTS.md)
1
+ # Package Scope
2
+ - Applies to `packages/ddl-docs-cli`.
3
+ - Defines contract rules for the development CLI package.
4
+
5
+ # Policy
6
+ ## REQUIRED
7
+ - SQL parsing behavior MUST stay AST-first through `rawsql-ts` APIs.
8
+ - Regex parsing fallback MUST be guarded and limited to unsupported AST gaps.
9
+ - Package dependency footprint MUST remain minimal.
10
+
11
+ ## ALLOWED
12
+ - CLI-only development usage MAY depend on package-local tooling.
13
+
14
+ ## PROHIBITED
15
+ - Treating this package as runtime application `src/` dependency.
16
+
17
+ # Mandatory Workflow
18
+ - Before committing changes under `packages/ddl-docs-cli`, run:
19
+ - `pnpm --filter @rawsql-ts/ddl-docs-cli lint`
20
+ - `pnpm --filter @rawsql-ts/ddl-docs-cli test`
21
+ - `pnpm --filter @rawsql-ts/ddl-docs-cli build`
22
+
23
+ # Hygiene
24
+ - Temporary debug output MUST be removed before commit.
25
+
26
+ # References
27
+ - Parent policy context: [../../AGENTS.md](../../AGENTS.md)
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 MSugiura
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,86 +1,86 @@
1
- # @rawsql-ts/ddl-docs-cli
2
-
3
- Generate Markdown table definition documents from DDL files.
4
-
5
- - DDL is treated as SSOT.
6
- - SQL parsing uses `rawsql-ts`.
7
- - `CREATE TABLE` and `ALTER TABLE ... ADD CONSTRAINT` are applied across the full DDL stream.
8
- - `COMMENT ON TABLE/COLUMN` is parsed via `rawsql-ts`.
9
-
10
- ## Install
11
-
12
- ```bash
13
- pnpm --filter @rawsql-ts/ddl-docs-cli build
14
- ```
15
-
16
- ## Usage
17
-
18
- ```bash
19
- ddl-docs generate --ddl-dir ztd/ddl --out-dir ztd/docs/tables
20
- ```
21
-
22
- Show help:
23
-
24
- ```bash
25
- ddl-docs help
26
- ddl-docs help generate
27
- ddl-docs help prune
28
- ```
29
-
30
- Generated layout:
31
-
32
- - `ztd/docs/tables/index.md`
33
- - `ztd/docs/tables/<schema>/index.md`
34
- - `ztd/docs/tables/<schema>/<table>.md`
35
-
36
- Options:
37
-
38
- - `--ddl-dir <directory>` repeatable recursive directory input
39
- - `--ddl-file <file>` repeatable explicit file input
40
- - `--ddl <file>` alias of `--ddl-file`
41
- - `--ddl-glob <pattern>` repeatable glob pattern input
42
- - `--extensions <csv>` default `.sql`
43
- - `--out-dir <directory>` output root (default `ztd/docs/tables`)
44
- - `--config <path>` optional `ztd.config.json` path
45
- - `--default-schema <name>` schema override for unqualified table names
46
- - `--search-path <csv>` schema search path override
47
- - `--no-index` skip index page generation
48
- - `--strict` fail when warnings exist
49
- - `--column-order <mode>` `definition` (default) or `name`
50
-
51
- Prune generated files:
52
-
53
- ```bash
54
- ddl-docs prune --out-dir ztd/docs/tables
55
- ```
56
-
57
- Prune preview:
58
-
59
- ```bash
60
- ddl-docs prune --out-dir ztd/docs/tables --dry-run
61
- ```
62
-
63
- Optional orphan cleanup:
64
-
65
- ```bash
66
- ddl-docs prune --out-dir ztd/docs/tables --prune-orphans
67
- ```
68
-
69
- ## VitePress Integration
70
-
71
- This tool emits plain Markdown files and index pages.
72
- If you prefer VitePress-side navigation generation, run with `--no-index` and let your site config build navigation from the generated table pages.
73
-
74
- ## Warnings
75
-
76
- Warnings are emitted to `<outDir>/_meta/warnings.json`.
77
- Use `--strict` in CI to treat warnings as failures.
78
-
79
- ## Memory Notes
80
-
81
- Current implementation prioritizes correctness by applying the full DDL stream and aggregating table metadata before rendering.
82
- For large schemas (for example, ~300 tables), follow-up optimization should focus on reducing peak memory by keeping only compact table metadata and discarding statement-level objects early.
83
-
84
- ## Minimal E2E Sample
85
-
86
- See `packages/ddl-docs-cli/examples/minimal-e2e`.
1
+ # @rawsql-ts/ddl-docs-cli
2
+
3
+ Generate Markdown table definition documents from DDL files.
4
+
5
+ - DDL is treated as SSOT.
6
+ - SQL parsing uses `rawsql-ts`.
7
+ - `CREATE TABLE` and `ALTER TABLE ... ADD CONSTRAINT` are applied across the full DDL stream.
8
+ - `COMMENT ON TABLE/COLUMN` is parsed via `rawsql-ts`.
9
+
10
+ ## Install
11
+
12
+ ```bash
13
+ pnpm --filter @rawsql-ts/ddl-docs-cli build
14
+ ```
15
+
16
+ ## Usage
17
+
18
+ ```bash
19
+ ddl-docs generate --ddl-dir ztd/ddl --out-dir ztd/docs/tables
20
+ ```
21
+
22
+ Show help:
23
+
24
+ ```bash
25
+ ddl-docs help
26
+ ddl-docs help generate
27
+ ddl-docs help prune
28
+ ```
29
+
30
+ Generated layout:
31
+
32
+ - `ztd/docs/tables/index.md`
33
+ - `ztd/docs/tables/<schema>/index.md`
34
+ - `ztd/docs/tables/<schema>/<table>.md`
35
+
36
+ Options:
37
+
38
+ - `--ddl-dir <directory>` repeatable recursive directory input
39
+ - `--ddl-file <file>` repeatable explicit file input
40
+ - `--ddl <file>` alias of `--ddl-file`
41
+ - `--ddl-glob <pattern>` repeatable glob pattern input
42
+ - `--extensions <csv>` default `.sql`
43
+ - `--out-dir <directory>` output root (default `ztd/docs/tables`)
44
+ - `--config <path>` optional `ztd.config.json` path
45
+ - `--default-schema <name>` schema override for unqualified table names
46
+ - `--search-path <csv>` schema search path override
47
+ - `--no-index` skip index page generation
48
+ - `--strict` fail when warnings exist
49
+ - `--column-order <mode>` `definition` (default) or `name`
50
+
51
+ Prune generated files:
52
+
53
+ ```bash
54
+ ddl-docs prune --out-dir ztd/docs/tables
55
+ ```
56
+
57
+ Prune preview:
58
+
59
+ ```bash
60
+ ddl-docs prune --out-dir ztd/docs/tables --dry-run
61
+ ```
62
+
63
+ Optional orphan cleanup:
64
+
65
+ ```bash
66
+ ddl-docs prune --out-dir ztd/docs/tables --prune-orphans
67
+ ```
68
+
69
+ ## VitePress Integration
70
+
71
+ This tool emits plain Markdown files and index pages.
72
+ If you prefer VitePress-side navigation generation, run with `--no-index` and let your site config build navigation from the generated table pages.
73
+
74
+ ## Warnings
75
+
76
+ Warnings are emitted to `<outDir>/_meta/warnings.json`.
77
+ Use `--strict` in CI to treat warnings as failures.
78
+
79
+ ## Memory Notes
80
+
81
+ Current implementation prioritizes correctness by applying the full DDL stream and aggregating table metadata before rendering.
82
+ For large schemas (for example, ~300 tables), follow-up optimization should focus on reducing peak memory by keeping only compact table metadata and discarding statement-level objects early.
83
+
84
+ ## Minimal E2E Sample
85
+
86
+ See `packages/ddl-docs-cli/examples/minimal-e2e`.
package/dist/src/cli.js CHANGED
@@ -219,29 +219,29 @@ function dedupe(values) {
219
219
  return Array.from(new Set(values));
220
220
  }
221
221
  function printHelp(target) {
222
- const generateHelp = `ddl-docs generate [options]
223
- --ddl-instance <name> DB instance name for subsequent --ddl-dir/--ddl-file/--ddl-glob (repeatable)
224
- --ddl-dir <directory> Recursively scan DDL files under directory (repeatable)
225
- --ddl-file <file> Include explicit DDL file (repeatable)
226
- --ddl <file> Alias of --ddl-file
227
- --ddl-glob <pattern> Glob pattern for DDL files (repeatable)
228
- --extensions <list> Comma-separated extensions (default: .sql)
229
- --out-dir <directory> Output root directory (default: ztd/docs/tables)
230
- --config <path> Optional ztd.config.json path
231
- --dictionary <path> Optional column dictionary json
232
- --locale <code> Dictionary locale (fallback: LANG -> en -> first)
233
- --default-schema <name> Override default schema for unqualified tables
234
- --search-path <list> Comma-separated schema search path
235
- --no-index Skip schema/table index page generation
236
- --strict Exit non-zero when warnings exist
237
- --column-order <mode> Column order: definition|name (default: definition)
238
- --label-separator <pat> Regex to split comment into Label+Comment columns (if omitted, no Label column)
239
- --filter-pg-dump Strip GRANT/REVOKE/OWNER TO/SET/\\connect statements from pg_dump output
222
+ const generateHelp = `ddl-docs generate [options]
223
+ --ddl-instance <name> DB instance name for subsequent --ddl-dir/--ddl-file/--ddl-glob (repeatable)
224
+ --ddl-dir <directory> Recursively scan DDL files under directory (repeatable)
225
+ --ddl-file <file> Include explicit DDL file (repeatable)
226
+ --ddl <file> Alias of --ddl-file
227
+ --ddl-glob <pattern> Glob pattern for DDL files (repeatable)
228
+ --extensions <list> Comma-separated extensions (default: .sql)
229
+ --out-dir <directory> Output root directory (default: ztd/docs/tables)
230
+ --config <path> Optional ztd.config.json path
231
+ --dictionary <path> Optional column dictionary json
232
+ --locale <code> Dictionary locale (fallback: LANG -> en -> first)
233
+ --default-schema <name> Override default schema for unqualified tables
234
+ --search-path <list> Comma-separated schema search path
235
+ --no-index Skip schema/table index page generation
236
+ --strict Exit non-zero when warnings exist
237
+ --column-order <mode> Column order: definition|name (default: definition)
238
+ --label-separator <pat> Regex to split comment into Label+Comment columns (if omitted, no Label column)
239
+ --filter-pg-dump Strip GRANT/REVOKE/OWNER TO/SET/\\connect statements from pg_dump output
240
240
  `;
241
- const pruneHelp = `ddl-docs prune [options]
242
- --out-dir <directory> Output root directory (default: ztd/docs/tables)
243
- --dry-run Print deletion targets without deleting files
244
- --prune-orphans Also prune generated markdown not listed in manifest
241
+ const pruneHelp = `ddl-docs prune [options]
242
+ --out-dir <directory> Output root directory (default: ztd/docs/tables)
243
+ --dry-run Print deletion targets without deleting files
244
+ --prune-orphans Also prune generated markdown not listed in manifest
245
245
  `;
246
246
  if (target === 'generate') {
247
247
  console.log(generateHelp);
@@ -251,14 +251,14 @@ function printHelp(target) {
251
251
  console.log(pruneHelp);
252
252
  return;
253
253
  }
254
- console.log(`ddl-docs <command> [options]
255
-
256
- Commands:
257
- generate Generate markdown docs from DDL
258
- prune Remove stale generated markdown docs
259
- help [command] Show help for all commands or one command
260
-
261
- ${generateHelp}
254
+ console.log(`ddl-docs <command> [options]
255
+
256
+ Commands:
257
+ generate Generate markdown docs from DDL
258
+ prune Remove stale generated markdown docs
259
+ help [command] Show help for all commands or one command
260
+
261
+ ${generateHelp}
262
262
  ${pruneHelp}`);
263
263
  }
264
264
  //# sourceMappingURL=cli.js.map
package/dist/src/index.js CHANGED
File without changes
package/package.json CHANGED
@@ -1,43 +1,47 @@
1
- {
2
- "name": "@rawsql-ts/ddl-docs-cli",
3
- "version": "0.2.2",
4
- "description": "CLI tool that generates Markdown table definition docs from DDL files using rawsql-ts",
5
- "main": "dist/src/index.js",
6
- "bin": {
7
- "ddl-docs": "dist/src/index.js"
8
- },
9
- "scripts": {
10
- "prepack": "node -e \"const fs=require('fs');const cp=require('child_process');const npm=process.platform==='win32'?'npm.cmd':'npm';if(!fs.existsSync('dist/src/index.js')){process.exit(cp.spawnSync(npm,['run','build'],{stdio:'inherit'}).status??1)}\"",
11
- "build": "tsc -p tsconfig.json",
12
- "test": "vitest run",
13
- "lint": "eslint src --ext .ts"
14
- },
15
- "keywords": [
16
- "rawsql-ts",
17
- "ddl",
18
- "markdown",
19
- "docs",
20
- "cli"
21
- ],
22
- "author": "msugiura",
23
- "license": "MIT",
24
- "publishConfig": {
25
- "access": "public"
26
- },
27
- "engines": {
28
- "node": ">=20"
29
- },
30
- "dependencies": {
31
- "rawsql-ts": "workspace:^"
32
- },
33
- "devDependencies": {
34
- "@types/node": "^22.13.10",
35
- "typescript": "^5.8.2",
36
- "vitest": "^4.0.7"
37
- },
38
- "files": [
39
- "dist",
40
- "README.md",
41
- "AGENTS.md"
42
- ]
43
- }
1
+ {
2
+ "name": "@rawsql-ts/ddl-docs-cli",
3
+ "version": "0.2.4",
4
+ "description": "CLI tool that generates Markdown table definition docs from DDL files using rawsql-ts",
5
+ "main": "dist/src/index.js",
6
+ "bin": {
7
+ "ddl-docs": "dist/src/index.js"
8
+ },
9
+ "keywords": [
10
+ "rawsql-ts",
11
+ "ddl",
12
+ "markdown",
13
+ "docs",
14
+ "cli"
15
+ ],
16
+ "author": "msugiura",
17
+ "license": "MIT",
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "https://github.com/mk3008/rawsql-ts",
21
+ "directory": "packages/ddl-docs-cli"
22
+ },
23
+ "publishConfig": {
24
+ "access": "public"
25
+ },
26
+ "engines": {
27
+ "node": ">=20"
28
+ },
29
+ "dependencies": {
30
+ "rawsql-ts": "^0.17.0"
31
+ },
32
+ "devDependencies": {
33
+ "@types/node": "^22.13.10",
34
+ "typescript": "^5.8.2",
35
+ "vitest": "^4.0.7"
36
+ },
37
+ "files": [
38
+ "dist",
39
+ "README.md",
40
+ "AGENTS.md"
41
+ ],
42
+ "scripts": {
43
+ "build": "tsc -p tsconfig.json",
44
+ "test": "vitest run",
45
+ "lint": "eslint src --ext .ts"
46
+ }
47
+ }