From 7e4ce8d6a9f4cb6b10230447ec17623ea000d735 Mon Sep 17 00:00:00 2001 From: "Kamat, Trivikram" <16024985+trivikr@users.noreply.github.com> Date: Thu, 28 Oct 2021 18:50:30 +0000 Subject: [PATCH] feat: add generate:clients:generic script --- package.json | 1 + scripts/generate-clients/generic.js | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 scripts/generate-clients/generic.js diff --git a/package.json b/package.json index 2041674261ee..f3976dd57476 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "copy-models": "node ./scripts/copy-models", "downlevel-dts": "node --es-module-specifier-resolution=node ./scripts/downlevel-dts", "generate-clients": "node ./scripts/generate-clients", + "generate:clients:generic": "node ./scripts/generate-clients/generic", "bootstrap": "yarn", "clean": "yarn clear-build-cache && yarn clear-build-info && lerna clean", "clear-build-cache": "rimraf ./packages/*/dist ./clients/*/dist ./lib/*/dist ./private/*/dist", diff --git a/scripts/generate-clients/generic.js b/scripts/generate-clients/generic.js new file mode 100644 index 000000000000..d6a7dd7cd351 --- /dev/null +++ b/scripts/generate-clients/generic.js @@ -0,0 +1,25 @@ +// @ts-check +const path = require("path"); +const { emptyDirSync } = require("fs-extra"); +const { generateGenericClient } = require("./code-gen"); +const { copyToClients } = require("./copy-to-clients"); +const { CODE_GEN_GENERIC_CLIENT_OUTPUT_DIR } = require("./code-gen-dir"); +const { prettifyCode } = require("./code-prettify"); +const { eslintFixCode } = require("./code-eslint-fix"); + +const PRIVATE_CLIENTS_DIR = path.normalize(path.join(__dirname, "..", "..", "private")); + +// TODO: remove this script when generate-clients code is refactored. +(async () => { + try { + await generateGenericClient(); + + await eslintFixCode(); + await prettifyCode(CODE_GEN_GENERIC_CLIENT_OUTPUT_DIR); + await copyToClients(CODE_GEN_GENERIC_CLIENT_OUTPUT_DIR, PRIVATE_CLIENTS_DIR); + emptyDirSync(CODE_GEN_GENERIC_CLIENT_OUTPUT_DIR); + } catch (e) { + console.log(e); + process.exit(1); + } +})();