# tzed-cli

> A package for a cli, which should save everyday work.

Latest version **1.0.1** (published 2021-08-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install tzed-cli
pnpm add tzed-cli
yarn add tzed-cli
bun add tzed-cli
```

Provides the commands `tzed`, `tzed init`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2021-08-04 |
| First published | 2021-08-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=10.0.0 |
| Dependencies | 5 |
| Unpacked size | 105 KB |
| Known vulnerabilities | 0 (+24 in 2 direct dependencies) |
| Install scripts | no |
| Author | TZed |
| Maintainers | tzed |
| Keywords | cli, nodejs, express, swagger, api, create-files |

## Links

- npm: https://www.npmjs.com/package/tzed-cli
- Homepage: https://github.com/ToZw/tzed-cli
- Issues: https://github.com/ToZw/tzed-cli/issues
- npm.io page: https://npm.io/package/tzed-cli

## Dependencies (5)

- [npm](https://npm.io/package/npm.md) ^7.17.0
- [glob](https://npm.io/package/glob.md) ^7.1.7
- [axios](https://npm.io/package/axios.md) ^0.21.1
- [chalk](https://npm.io/package/chalk.md) ^4.1.2
- [yargs](https://npm.io/package/yargs.md) ^17.0.1

## Alternatives

- [@salesforce/cli](https://npm.io/package/@salesforce/cli.md) — 389.7K weekly downloads
- [@mintlify/cli](https://npm.io/package/@mintlify/cli.md) — 208.9K weekly downloads
- [@grafana/e2e-selectors](https://npm.io/package/@grafana/e2e-selectors.md) — 128.7K weekly downloads
- [mintlify](https://npm.io/package/mintlify.md) — 112.0K weekly downloads
- [@intlayer/cli](https://npm.io/package/@intlayer/cli.md) — 22.8K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2021-08-04
- 1.0.0 — 2021-08-04

## README

# tzed-cli

## A package for a cli, which should save everyday work.

# Getting Started

### Installation
This command installs tzed-cli globally.
```bash
npm i tzed-cli -g
```

# Available Commands
## init
#### Description:
This command creates your tzedconfig.json in your root folder for further configurations.

#### Constructions:
Navigate to your root folder of your project and insert in your command-line:
```bash
tzed init
```

## swagger
#### Description:
This command automatically creates all available REST APIs from the swagger URLs specified in tzedconfig.json.

#### Constructions:
Prepare your ```tzedconfig.json``` with your swagger URLs and call following command:
```bash
tzed swagger
```

##### Example:
```json
{
	"rootDir": "./",
	"outDir": "./dist",
	"sharedDir": "./dist/shared",
	"swaggerUrls": [
		"https://petstore.swagger.io/v2/swagger.json"
	]
}
```
- rootDir: Root directory of the project.
- outDir:  Directory in which the swagger files should be stored
- sharedDir: Directory in which the shared files for swagger should be stored
- swaggerUrls: All JSON swagger URLs whose API files should be automatically produced

## Create simple express app with swagger cli command
1. Create project folder
2. ```npm init```
3. ```tzed init```
4. Edit your ```tzedconfig.json``` and add your JSON Swagger URLs
5. ```tzed swagger```
6. Add ```index.ts``` file to your specified "outDir":

index.ts:
```typescript
import express from 'express';
import { init as globalInitRoutes } from './globalInitRoutes';

const app: express.Express = express();
const port: number = 3000;

app.get('/', (req, res) => res.send('Hello World!'));

globalInitRoutes(app, '/api');

app.listen(port, () => console.log(`Example app listening at http://localhost:${port}`));
```

6. Install missing dependencies:
```bash
npm i express && npm i glob && npm i axios && npm i --save-dev @types/express && npm i --save-dev @types/glob && npm i --save-dev tslib && npm i --save-dev rimraf
```

7. Add ```tsconfig.json``` in your root directory:

tsconfig.json:
```json
{
	"compilerOptions": {
		"baseUrl": "./",
		"outDir": "./bin/www",
		"sourceMap": true,
		"inlineSources": true,
		"strict": true,
		"forceConsistentCasingInFileNames": true,
		"esModuleInterop": true,
		"noImplicitReturns": true,
		"noFallthroughCasesInSwitch": true,
		"declaration": false,
		"downlevelIteration": true,
		"experimentalDecorators": true,
		"emitDecoratorMetadata": true,
		"moduleResolution": "node",
		"importHelpers": true,
		"target": "es5",
		"module": "commonjs",
		"lib": [
			"es2015",
			"dom"
		],
		"allowSyntheticDefaultImports": true
	}
}
```

8. Update your scripts in your ```package.json```:

package.json:
```json
{
	"name": "test-tzed-cli",
	"version": "1.0.0",
	"description": "",
	"scripts": {
		"start": "npm run build && node ./bin/www/index.js",
		"build": "npm run clean && npm run transpile",
		"transpile": "tsc -p ./tsconfig.json",
		"clean": "rimraf ./bin"
	},
	"author": "",
	"license": "ISC",
	"dependencies": {
		"axios": "^0.21.1",
		"express": "^4.17.1",
		"glob": "^7.1.7"
	},
	"devDependencies": {
		"@types/express": "^4.17.13",
		"@types/glob": "^7.1.4",
		"rimraf": "^3.0.2",
		"tslib": "^2.3.0"
	}
}
```

9. ```npm run start```
10. Browse to your swagger API URL: Example ```http://localhost:3000/api/v2/pet/1``` 

## Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

## License
[MIT](https://choosealicense.com/licenses/mit/)

---
_Source: https://npm.io/package/tzed-cli · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
