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); + } +})();