@amritk/mjst 0.3.0 → 0.5.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 +3 -1
- package/dist/cli-config.d.ts +12 -1
- package/dist/cli.js +90225 -277
- package/dist/load-schema-module.d.ts +16 -0
- package/package.json +6 -5
- package/src/cli-config.ts +13 -1
- package/src/cli.ts +19 -3
- package/src/load-config.ts +8 -0
- package/src/load-schema-module.test.ts +49 -0
- package/src/load-schema-module.ts +52 -0
- package/src/parse-cli-args.ts +31 -0
package/README.md
CHANGED
|
@@ -63,7 +63,9 @@ npx mjst --config ./mjst.config.json
|
|
|
63
63
|
<!-- config-table-start -->
|
|
64
64
|
| | Property | CLI Flag | Type | Required | Default | Description |
|
|
65
65
|
|:---:|:---|:---|:---:|:---:|:---:|:---|
|
|
66
|
-
| 📄 | `schema` | `--schema <path>` | `string` | ✅ | — | Path to the JSON Schema file
|
|
66
|
+
| 📄 | `schema` | `--schema <path>` | `string` | ✅ | — | Path to the schema to process. With the default 'json' input this is a JSON Schema file that is read and parsed. With any other input format it is a JS/TS module that exports a schema, which is loaded and converted to JSON Schema via the matching adapter. |
|
|
67
|
+
| 🔌 | `input` | `--input <format>` | `string` | — | `"json"` | Source format of the schema. 'json' (default) reads a JSON Schema file directly. Any other format loads 'schema' as a module and converts it to JSON Schema with the matching adapter. Supported: 'typebox', 'zod' (zod v4+), 'valibot' (with @valibot/to-json-schema), and 'effect' — each requires the corresponding library installed in your project. |
|
|
68
|
+
| 📦 | `export` | `--export <name>` | `string` | — | — | Which export of the schema module to use when 'input' is not 'json'. Defaults to the default export, or the sole named export when the module has exactly one. |
|
|
67
69
|
| 📁 | `outDir` | `--outDir <dir>` | `string` | ✅ | — | Output directory for generated TypeScript files. The directory is created automatically if it does not exist. Subdirectories are created as needed when a generated file includes a nested path. |
|
|
68
70
|
| 🏷️ | `typesOnly` | `--types-only` | `boolean` | — | `false` | Generate only TypeScript type definitions without parser functions. Useful when you only need the type shapes and do not need runtime validation. |
|
|
69
71
|
| 🔨 | `build` | `--build` | `boolean` | — | `false` | Compile the generated TypeScript files to .js and .d.ts output. A temporary tsconfig is written to the output directory, tsc is invoked, and the intermediate .ts source files are removed when compilation succeeds. |
|
package/dist/cli-config.d.ts
CHANGED
|
@@ -1,10 +1,21 @@
|
|
|
1
|
+
import type { SourceFormat } from '@amritk/adapters/source-format';
|
|
1
2
|
/**
|
|
2
3
|
* Configuration for the CLI tool.
|
|
3
4
|
* These properties map 1:1 with CLI flags and config file keys.
|
|
4
5
|
*/
|
|
5
6
|
export type CliConfig = {
|
|
6
|
-
/** Path to the JSON Schema file
|
|
7
|
+
/** Path to the schema to process — a JSON Schema file, or a JS/TS module when `input` is set. */
|
|
7
8
|
readonly schema: string;
|
|
9
|
+
/**
|
|
10
|
+
* The source format of the schema. Defaults to `'json'` (a plain JSON Schema file).
|
|
11
|
+
* Any other format loads `schema` as a module and converts it via the matching adapter.
|
|
12
|
+
*/
|
|
13
|
+
readonly input?: SourceFormat;
|
|
14
|
+
/**
|
|
15
|
+
* Which export of the schema module to use when `input` is not `'json'`.
|
|
16
|
+
* Defaults to the default export, or the sole named export when there is exactly one.
|
|
17
|
+
*/
|
|
18
|
+
readonly export?: string;
|
|
8
19
|
/** Output directory for generated TypeScript files. */
|
|
9
20
|
readonly outDir: string;
|
|
10
21
|
/**
|