Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add -p, --prettier options to generate command #51

Merged
merged 1 commit into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
examples/src/
lib/
5 changes: 4 additions & 1 deletion .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,8 @@ jobs:
with:
node-version: 18

- name: TypeeScript
- name: Yarn install
run: yarn

- name: TypeScript
run: yarn test:types
587 changes: 278 additions & 309 deletions .pnp.cjs

Large diffs are not rendered by default.

44 changes: 15 additions & 29 deletions .pnp.loader.mjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed .yarn/cache/tr46-npm-0.0.3-de53018915-8f1f5aa6cb.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
672 changes: 336 additions & 336 deletions .yarn/releases/yarn-4.0.2.cjs → .yarn/releases/yarn-4.1.0.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ enableGlobalCache: false

npmPublishAccess: public

yarnPath: .yarn/releases/yarn-4.0.2.cjs
yarnPath: .yarn/releases/yarn-4.1.0.cjs
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# CHANGELOG.md

## Unreleased

- Add `-p,--prettier` option to the cli to format the generated code with prettier [#51](https://github.com/Embraser01/typoas/pull/51)

## 3.1.7 - 2024-02-23

## 3.1.6 - 2024-02-23

> Only the runtime was published, the generator and cli are still at 3.1.5
Expand Down
14 changes: 2 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,9 @@ writeFileSync('./src/client.ts', data, 'utf8');
Once the file is generated you'll be able to use it like this:

```typescript
import fetch from 'node-fetch';
import { ServerConfiguration } from '@typoas/runtime';
import { createContext, pullsList } from './client';

// Inject fetch polyfill into NodeJS env.
if (!globalThis.fetch) {
// @ts-ignore
globalThis.fetch = fetch;
}
const ctx = createContext();

pullsList(ctx, {
Expand All @@ -132,6 +126,8 @@ pullsList(ctx, {
.catch((err) => console.error('Error while getting PRs', err));
```

> The default `fetch` implementation is used (included in Node.js >= 18.0.0). You can always override the default fetch implementation in `createContext`
## Examples

You can find examples in the [`examples`](./examples) folder.
Expand Down Expand Up @@ -164,15 +160,9 @@ which allow [Tree Shaking](https://webpack.js.org/guides/tree-shaking/). To get
you can use `wrapApi` helper:

```typescript
import fetch from 'node-fetch';
import { ServerConfiguration, wrapApi } from '@typoas/runtime';
import { createContext, pullsList, issuesList } from './client';

// Inject fetch polyfill into NodeJS env.
if (!globalThis.fetch) {
// @ts-ignore
globalThis.fetch = fetch;
}
const ctx = createContext();
const ghClient = wrapApi(ctx, {
pullsList,
Expand Down
10 changes: 4 additions & 6 deletions examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,15 @@
"scripts": {
"start": "ts-node src/index.ts",
"test:types": "tsc --noEmit",
"generate": "ts-node scripts/generate.ts && prettier -w src/"
"generate": "ts-node scripts/generate.ts"
},
"dependencies": {
"@typoas/runtime": "workspace:^",
"node-fetch": "^2.6.11"
"@typoas/runtime": "workspace:^"
},
"devDependencies": {
"@types/node": "^20.2.3",
"@types/node-fetch": "^2.6.4",
"@types/node": "^20.11.24",
"@typoas/cli": "workspace:^",
"prettier": "^3.2.4",
"prettier": "^3.2.5",
"ts-node": "^10.9.2",
"typescript": "^5.3.3"
}
Expand Down
10 changes: 9 additions & 1 deletion examples/scripts/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,15 @@ async function run() {

for (const sample of samples) {
await cli.run(
['generate', '-i', sample.input, '-o', `./src/${sample.output}.ts`, '-e'],
[
'generate',
'-i',
sample.input,
'-o',
`./src/${sample.output}.ts`,
'-e',
'-p',
],
context,
);
}
Expand Down
Loading
Loading