Skip to content

Commit

Permalink
Merge pull request #2 from flotiq/hotfix/model-imports
Browse files Browse the repository at this point in the history
Fix typescript declaration build
  • Loading branch information
andrzejwp authored Apr 23, 2024
2 parents 0ebb47b + ea89002 commit 86bab73
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@ const flotiq = new FlotiqApi(FLOTIQ_RO_API_KEY);
const eventList = await flotiq.Event.list({limit:100});
```

## Generating declarations

To generate a set of `d.ts` files for Typescript follow these steps:

1. Execute `npx flotiq-codegen-ts generate` as usual
2. Go to `./flotiqApi` directory
3. Execute `../clean_duplicate_import.sh`
4. Execute `npm run build`

This will render the declarations in the `flotiqApi/dist` folder.

## Collaborating

If you wish to talk with us about this project, feel free to hop on our [![Discord Chat](https://img.shields.io/discord/682699728454025410.svg)](https://discord.gg/FwXcHnX).
Expand Down
13 changes: 13 additions & 0 deletions clean_duplicate_import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

file_patterns="src/models/*WithoutInternal.ts src/models/*WithoutRequired.ts"
delete_line="import { DataSource, DataSourceFromJSON } from './DataSource';"

escaped_delete_line=$(printf '%s\n' "$delete_line" | sed 's:[][\/.^$*]:\\&:g')

for file in $file_patterns; do
if grep -Fq "$delete_line" "$file"; then
sed -i '' "/$escaped_delete_line/d" "$file"
fi
done

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "flotiq-codegen-ts",
"version": "1.0.3",
"version": "1.0.4",
"description": "CLI tool to generate API clients using Flotiq API and OpenAPI Generator",
"main": "index.js",
"bin": {
Expand Down
4 changes: 3 additions & 1 deletion templates/modelGeneric.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import {
{{.}}ToJSON,
} from './{{.}}{{importFileExtension}}';
{{/imports}}
//import { DataSource, DataSourceFromJSON } from './DataSource';

import { DataSource, DataSourceFromJSON } from './DataSource';

{{/hasImports}}
{{#discriminator}}
import {
Expand Down

0 comments on commit 86bab73

Please sign in to comment.