@thinknimble/tnm-cli
v0.0.3-c
Published
`tnm-cli` is a command line interface for auto-generating [tn-models](https://github.com/thinknimble/tn-models-fp) model definitions for your app's frontend from OpenAPI schema files provided by your app's backend. This is the standard pattern we use in a
Downloads
11
Maintainers
Keywords
Readme
TN Models CLI
tnm-cli
is a command line interface for auto-generating tn-models model definitions for your app's frontend from OpenAPI schema files provided by your app's backend. This is the standard pattern we use in all apps at ThinkNimble.
Installation
First, install bun
(required):
curl -fsSL https://bun.sh/install | bash
Then use the CLI by installing it from NPM or BUN
npm install -g tnm-cli
bun install -g tnm-cli
OR use npx/bunx
npx/bunx @thinknimble/tnm-cli read <source>
Usage
Generate Models from a ThinkNimble App Schema
assuming you are retrieving the yaml file from swagger on a TN App you may also need to pass a token
bunx @thinknimble/tnm-cli read 'https://YOUR_PROJECT.com/api/schema?format=yaml' -t YOUR_API_KEY -u '/api/users/' -o somepath.ts
Options:
-u
,--uri
- the uri to the resource you want models of, this must be an exact match with the opening and trailing slash-t
,--auth
- auth token to the url if it is behind authentication-o
,--output
- output file otherwise the output is logged
Make Models from a Local Schema
You can also generate models using a local yaml file
bunx @thinknimble/tnm-cli read 'some-yaml-path.yaml' -u '/api/users/ -o somepath.ts'
bunx @thinknimble/tnm-cli read 'some-yaml-url.com/sample.yaml' -u'/api/users/ -o somepath.ts'
with output
bunx @thinknimble/tnm-cli read 'your-local-file.yaml' -u '/api/users/' -o somepath.ts
tnm-cli Development
To install dependencies:
bun install
To run:
bun run index.ts
This project was created using bun init
in bun v1.1.22. Bun is a fast all-in-one JavaScript runtime.