politty 0.11.8 → 0.12.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 +31 -0
- package/dist/augment.js +1 -3
- package/dist/cli-run-MIwiURm8.js +1 -0
- package/dist/cli.js +1 -20
- package/dist/compile-cache.js +1 -3
- package/dist/completion.js +1 -3
- package/dist/docs.js +1 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -18
- package/dist/prompt-clack.js +1 -3
- package/dist/prompt-inquirer.js +1 -3
- package/dist/prompt.js +1 -3
- package/dist/skill.js +1 -3
- package/package.json +2 -2
- package/dist/cli-run-DGe88d0G.js +0 -14
package/README.md
CHANGED
|
@@ -62,6 +62,37 @@ runMain(command);
|
|
|
62
62
|
|
|
63
63
|
Field descriptions can also come from valibot's own metadata actions. They are actions, not schemas, so they belong inside `v.pipe(...)`: `v.pipe(v.string(), v.description("..."))` or `v.pipe(v.string(), v.metadata({ description: "..." }))`. The one zod-only feature without a valibot counterpart is the `politty/augment` module (zod `GlobalMeta` interface augmentation) — use `arg()` or `v.metadata()` instead. The `politty` package itself remains the zod flavor (an alias of `@politty/zod`).
|
|
64
64
|
|
|
65
|
+
### Using zod/mini instead of zod
|
|
66
|
+
|
|
67
|
+
politty is also available as [`@politty/zod-mini`](https://www.npmjs.com/package/@politty/zod-mini), built on [`zod/mini`](https://zod.dev/) — the same `zod` package's minimal, function-style entry point instead of its chainable classic API — for a smaller bundle. Same API (`defineCommand`, `arg`, `runMain`, and all subpath modules):
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
npm install @politty/zod-mini zod
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
```typescript
|
|
74
|
+
import * as z from "zod/mini";
|
|
75
|
+
import { defineCommand, runMain, arg } from "@politty/zod-mini";
|
|
76
|
+
|
|
77
|
+
const command = defineCommand({
|
|
78
|
+
name: "greet",
|
|
79
|
+
args: z.object({
|
|
80
|
+
name: arg(z.string(), { description: "Name to greet", positional: true }),
|
|
81
|
+
loud: arg(z._default(z.boolean(), false), { alias: "l" }),
|
|
82
|
+
}),
|
|
83
|
+
run: (args) => {
|
|
84
|
+
const greeting = `Hello, ${args.name}!`;
|
|
85
|
+
console.log(args.loud ? greeting.toUpperCase() : greeting);
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
runMain(command);
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
`zod/mini` drops classic zod's chainable sugar (`.optional()`, `.default()`, `.describe()`, `.meta()`), so schemas are built with functions instead (`z.optional(z.string())`, `z._default(z.string(), "x")`). Field descriptions come from `arg()` or from zod's own metadata registry: `schema.register(z.globalRegistry, { description: "..." })`. The `politty/augment` module (classic zod's `GlobalMeta` interface augmentation) has no `@politty/zod-mini` counterpart for the same reason it has none for valibot — use `arg()` or the registry instead.
|
|
93
|
+
|
|
94
|
+
You can write your schemas against either `import * as z from "zod/mini"` or [`import * as z from "@zod/mini"`](https://zod.dev/packages/mini) — `@zod/mini` re-exports `zod/mini` (same classes, same `globalRegistry`), so schemas built either way are fully interchangeable. Per zod's own installation instructions, install `@zod/mini` alongside `zod` (`npm install zod @zod/mini`), not instead of it — `@zod/mini` only re-exports `zod/mini` from a peer dependency on `zod`, so `zod` still needs to be resolvable in your project either way.
|
|
95
|
+
|
|
65
96
|
## Quick Start
|
|
66
97
|
|
|
67
98
|
```typescript
|
package/dist/augment.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{runPolittyCli as e}from"@politty/zod";await e(`politty`);export{};
|
package/dist/cli.js
CHANGED
|
@@ -1,21 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
//#region src/cli.ts
|
|
5
|
-
/**
|
|
6
|
-
* Bin shim for the `politty` bin of this compatibility alias.
|
|
7
|
-
*
|
|
8
|
-
* Cannot simply re-run `@politty/zod`'s CLI: the CLI bakes the name of the
|
|
9
|
-
* package running it into the shims `generate-shim` writes, and for a CLI
|
|
10
|
-
* depending on `politty` alone that name has to be `politty` — under a strict
|
|
11
|
-
* node_modules layout (pnpm) its own package cannot resolve `@politty/zod`.
|
|
12
|
-
*
|
|
13
|
-
* Mirrors `@politty/zod`'s entry otherwise: enable the on-disk V8 compile
|
|
14
|
-
* cache before the real CLI graph is compiled, then load that graph through a
|
|
15
|
-
* dynamic import so it is what the cache covers.
|
|
16
|
-
*/
|
|
17
|
-
enableCompileCache("politty");
|
|
18
|
-
await import("./cli-run-DGe88d0G.js");
|
|
19
|
-
|
|
20
|
-
//#endregion
|
|
21
|
-
export { };
|
|
2
|
+
import{enableCompileCache as e}from"@politty/zod/compile-cache";e(`politty`),await import(`./cli-run-MIwiURm8.js`);export{};
|
package/dist/compile-cache.js
CHANGED
package/dist/completion.js
CHANGED
package/dist/docs.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -9,6 +9,6 @@ export * from "@politty/zod";
|
|
|
9
9
|
* resolve `@politty/zod` from its own package under a strict node_modules
|
|
10
10
|
* layout (pnpm), so a shim naming it would silently lose the compile cache.
|
|
11
11
|
*/
|
|
12
|
-
declare const generateCompileCacheShim:
|
|
12
|
+
declare const generateCompileCacheShim: (options?: import("@politty/zod").GenerateCompileCacheShimOptions) => import("@politty/zod").GenerateCompileCacheShimResult[];
|
|
13
13
|
//#endregion
|
|
14
14
|
export { generateCompileCacheShim };
|
package/dist/index.js
CHANGED
|
@@ -1,18 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
export * from "@politty/zod"
|
|
4
|
-
|
|
5
|
-
//#region src/index.ts
|
|
6
|
-
/**
|
|
7
|
-
* Generate compile-cache bin shims that import the cache helper from
|
|
8
|
-
* `politty/compile-cache`.
|
|
9
|
-
*
|
|
10
|
-
* Overrides `@politty/zod`'s binding of the same name — the one thing this
|
|
11
|
-
* alias cannot re-export as-is. A CLI depending on `politty` alone cannot
|
|
12
|
-
* resolve `@politty/zod` from its own package under a strict node_modules
|
|
13
|
-
* layout (pnpm), so a shim naming it would silently lose the compile cache.
|
|
14
|
-
*/
|
|
15
|
-
const generateCompileCacheShim = createCompileCacheShimGenerator("politty");
|
|
16
|
-
|
|
17
|
-
//#endregion
|
|
18
|
-
export { generateCompileCacheShim };
|
|
1
|
+
import{createCompileCacheShimGenerator as e}from"@politty/zod";export*from"@politty/zod";const t=e(`politty`);export{t as generateCompileCacheShim};
|
package/dist/prompt-clack.js
CHANGED
package/dist/prompt-inquirer.js
CHANGED
package/dist/prompt.js
CHANGED
package/dist/skill.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "politty",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "A lightweight CLI framework inspired by citty with zod v4 registry integration for type-safe metadata management",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"argument-parser",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
}
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
|
-
"@politty/zod": "^0.
|
|
70
|
+
"@politty/zod": "^0.2.0"
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
73
73
|
"@types/node": "25.9.5",
|
package/dist/cli-run-DGe88d0G.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { runPolittyCli } from "@politty/zod";
|
|
2
|
-
|
|
3
|
-
//#region src/cli-run.ts
|
|
4
|
-
/**
|
|
5
|
-
* The real CLI graph behind this package's bin shim.
|
|
6
|
-
*
|
|
7
|
-
* Importing `@politty/zod` registers the zod adapter as a side effect of that
|
|
8
|
-
* package's entry, so the adapter is installed before the politty CLI can
|
|
9
|
-
* dynamically load user command modules carrying zod schemas.
|
|
10
|
-
*/
|
|
11
|
-
await runPolittyCli("politty");
|
|
12
|
-
|
|
13
|
-
//#endregion
|
|
14
|
-
export { };
|