From 0b2479517fb17074cf6dace0d740cfbea9a0ece6 Mon Sep 17 00:00:00 2001 From: Tymoteusz Czech <2625371+Tymek@users.noreply.github.com> Date: Mon, 2 Sep 2024 15:14:48 +0200 Subject: [PATCH] feat: update Orval config (#8038) Simplify running frontend `gen:api` --- frontend/orval.config.js | 9 +++++---- frontend/scripts/clean_orval_generated.sh | 5 ++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/frontend/orval.config.js b/frontend/orval.config.js index 759eca3e7c..2e59e42e06 100644 --- a/frontend/orval.config.js +++ b/frontend/orval.config.js @@ -2,10 +2,8 @@ * How to generate OpenAPI client * * For now we only use generated types (src/openapi/models). - * We will use methods (src/openapi/apis) for new features soon. - * 1. `yarn gen:api` to generate the client - * 2. `rm -rf src/openapi/apis` to remove methods (! except if you want to use some of those) - * 3. clean up `src/openapi/index.ts` imports + * Run `yarn gen:api` to generate the client. + * We may use methods (src/openapi/apis) for new features in the future. */ module.exports = { unleashApi: { @@ -34,5 +32,8 @@ module.exports = { process.env.UNLEASH_OPENAPI_URL || 'http://localhost:4242/docs/openapi.json', }, + hooks: { + afterAllFilesWrite: './scripts/clean_orval_generated.sh', + }, }, }; diff --git a/frontend/scripts/clean_orval_generated.sh b/frontend/scripts/clean_orval_generated.sh index 28d698b591..c0dc2358c1 100755 --- a/frontend/scripts/clean_orval_generated.sh +++ b/frontend/scripts/clean_orval_generated.sh @@ -5,9 +5,8 @@ rm -rf src/openapi/apis # Remove all but last line from index.ts echo "Cleaning index.ts..." -tail -1 src/openapi/index.ts > index_tmp ; -cat index_tmp > src/openapi/index.ts ; -rm index_tmp +echo "export * from './models';" > src/openapi/index.ts +echo '' >> src/openapi/index.ts echo "Formatting..." yarn fmt