Skip to content

Commit

Permalink
feat: Add init command (#44)
Browse files Browse the repository at this point in the history
* Add generate config property helper

* Init prompts POC

- Using `ink` as renderer
- Adding graphql codegen to talk with github API

Overall I really like `prompt` API (simple promise base API and fully typesafe).
The only and major problem is the ink `app` management. When I have two `this.promt.input`, the output is not following…

* Add rxjs

* Refactor prompts to have only one App

This is avoid the bug around ctrl+C and permit to have the answer displayed

* Remove ink-text-input (not compatible with es module)

* Add `addImport` helper

* Add logo & badges

* Add `getText` util

* Mark private method

* Make initCommand works with `--dry-run`

* Add cli-highlight

* Make dry-run works

* Dirty test fix (esm problems)

* Finallize happy path

* Fix cross-fetch dependency

* Apply @moltar suggestion

* Inject baseUrl if available

* Improve getting started
  • Loading branch information
fabien0102 authored Mar 17, 2022
1 parent 1d8055e commit 2ccd5ec
Show file tree
Hide file tree
Showing 39 changed files with 37,588 additions and 1,376 deletions.
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"cli": "1.3.1",
"plugins/typescript": "2.0.0"
}
}
21 changes: 21 additions & 0 deletions LICENCE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2021

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
# OpenAPI Codegen
<div align="center" style="margin-bottom: 16px">
<img src="openapi-codegen-logo.svg" width="400px" />
</div>

⚠️ This project is in an early stage, please check the issues to see what’s missing! ⚠️

-> Insert logo and badges here
[![npm](https://img.shields.io/npm/v/@openapi-codegen/cli.svg?style=for-the-badge)](https://www.npmjs.com/package/@openapi-codegen/cli)
[![License](https://img.shields.io/npm/l/@openapi-codegen/cli.svg?style=for-the-badge)](https://github.com/fabien0102/openapi-codegen/blob/main/LICENSE)

Tooling to give you full type-safety around OpenAPI specs.

**For frontend:**

This will give you full auto-completion and type-safety of your APIs

**For backend:**
**For backend: (in coming)**

This will generate everything you need to deliver a perfect API, spec driven.

## Getting started

```bash
$ npx @openapi-codegen/cli init
$ npm i -D @openapi-codegen/{cli,typescript}
$ npx openapi-codegen init
```

Follow the steps, this will generate a configuration file for you (openapi-codegen.config.ts) and update your `package.json`

```bash
$ yarn gen # or the defined alias
```
Follow the steps, this will generate a configuration file for you (openapi-codegen.config.ts).

You should have a bunch of types / components ready to be used.

Note: The generated `{namespace}Fetcher.ts` assume a global `fetch` and the `qs` package, this is just a suggestion, you can do what ever you want on this file as soon as the types are compliant.

## Philosophy

In software development, communication between components and documentation around it is often no fun.
Expand Down
1 change: 1 addition & 0 deletions cli/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GITHUB_TOKEN=secret
15 changes: 5 additions & 10 deletions cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,30 @@

### [1.3.1](https://github.com/fabien0102/openapi-codegen/compare/cli-v1.3.0...cli-v1.3.1) (2022-02-22)


### Bug Fixes

* Fix `path` usage for node 14 ([#34](https://github.com/fabien0102/openapi-codegen/issues/34)) ([4422e61](https://github.com/fabien0102/openapi-codegen/commit/4422e61b317ffd4d3aa0b30340592063c4a222cc))
- Fix `path` usage for node 14 ([#34](https://github.com/fabien0102/openapi-codegen/issues/34)) ([4422e61](https://github.com/fabien0102/openapi-codegen/commit/4422e61b317ffd4d3aa0b30340592063c4a222cc))

## [1.3.0](https://github.com/fabien0102/openapi-codegen/compare/cli-v1.2.0...cli-v1.3.0) (2022-01-27)


### Features

* Add support for flags in `gen` command ([#27](https://github.com/fabien0102/openapi-codegen/issues/27)) ([ec263c2](https://github.com/fabien0102/openapi-codegen/commit/ec263c2f55e4cc4fcb1bc427bf2c9fd1152f640d))
- Add support for flags in `gen` command ([#27](https://github.com/fabien0102/openapi-codegen/issues/27)) ([ec263c2](https://github.com/fabien0102/openapi-codegen/commit/ec263c2f55e4cc4fcb1bc427bf2c9fd1152f640d))

## [1.2.0](https://github.com/fabien0102/openapi-codegen/compare/cli-v1.1.0...cli-v1.2.0) (2022-01-20)


### Features

* [generateFetchers] Add extra props support ([#25](https://github.com/fabien0102/openapi-codegen/issues/25)) ([35fc219](https://github.com/fabien0102/openapi-codegen/commit/35fc219d9c644becdf38b0b3e38e1512d095d2d0))
- [generateFetchers] Add extra props support ([#25](https://github.com/fabien0102/openapi-codegen/issues/25)) ([35fc219](https://github.com/fabien0102/openapi-codegen/commit/35fc219d9c644becdf38b0b3e38e1512d095d2d0))

## [1.1.0](https://github.com/fabien0102/openapi-codegen/compare/cli-v1.0.0...cli-v1.1.0) (2022-01-19)


### Features

* generate fetchers only ([#22](https://github.com/fabien0102/openapi-codegen/issues/22)) ([b1d5c4a](https://github.com/fabien0102/openapi-codegen/commit/b1d5c4a6cc104904f4bc72777974973cdda7832d))
- generate fetchers only ([#22](https://github.com/fabien0102/openapi-codegen/issues/22)) ([b1d5c4a](https://github.com/fabien0102/openapi-codegen/commit/b1d5c4a6cc104904f4bc72777974973cdda7832d))

## 1.0.0 (2022-01-17)


### Bug Fixes

* adjust documentation with the current state of the project ([2a55e01](https://github.com/fabien0102/openapi-codegen/commit/2a55e0119e1155c0280cd16e5cee95b39e9e7bca))
- adjust documentation with the current state of the project ([2a55e01](https://github.com/fabien0102/openapi-codegen/commit/2a55e0119e1155c0280cd16e5cee95b39e9e7bca))
12 changes: 12 additions & 0 deletions cli/codegen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
overwrite: true
schema:
- "https://api.github.com/graphql":
headers:
Authorization: Bearer ${GITHUB_TOKEN}
documents: "src/**/*.graphql"
generates:
src/prompts/queries/github.tsx:
plugins:
- "typescript"
- "typescript-operations"
- "typescript-react-apollo"
1 change: 1 addition & 0 deletions cli/examples/openapi-codegen.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { defineConfig } from "../lib/index.js";
import { generateFetchers } from "@openapi-codegen/typescript";

export default defineConfig({
withFile: {
Expand Down
Loading

0 comments on commit 2ccd5ec

Please sign in to comment.