Skip to content

Commit

Permalink
feat: Add -p, --prettier options to generate command
Browse files Browse the repository at this point in the history
  • Loading branch information
Embraser01 committed Mar 1, 2024
1 parent 68efc63 commit 88474d0
Show file tree
Hide file tree
Showing 63 changed files with 2,974 additions and 3,233 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
examples/src/
lib/
535 changes: 258 additions & 277 deletions .pnp.cjs

Large diffs are not rendered by default.

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.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# CHANGELOG.md

## 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

0 comments on commit 88474d0

Please sign in to comment.