From ea48bf33450cbf40bf2801482fc89f7c0a774744 Mon Sep 17 00:00:00 2001 From: Ritesh Kumar Date: Tue, 29 Sep 2020 08:06:37 +0530 Subject: [PATCH] fix errors (#245) * fix errors * fixes --- constants/data.ts | 10 ++++---- pages/api/typescript-to-flow.ts | 2 ++ pages/api/typescript-to-json-schema.ts | 14 +++++++++-- patches/relay-compiler+9.1.0.patch | 13 ---------- yarn.lock | 33 +++++++++++++++++++++++++- 5 files changed, 50 insertions(+), 22 deletions(-) delete mode 100644 patches/relay-compiler+9.1.0.patch diff --git a/constants/data.ts b/constants/data.ts index cb6c5e0..fc5630e 100644 --- a/constants/data.ts +++ b/constants/data.ts @@ -405,17 +405,15 @@ export const ShowStoredUser: React.FC = (props) => { import { useState, useEffect } from 'react'; -export const CounterExample = () => { +export const CounterExample: React.FC<{}> = () => { const [count, setCount] = useState(0); - - useEffect(() => { - document.title = \`You clicked $\{count\} times\`; - }); + + const handleClick = () => setCount(count + 1) return (

You clicked {count} times

-
diff --git a/pages/api/typescript-to-flow.ts b/pages/api/typescript-to-flow.ts index 17f606c..b50c417 100644 --- a/pages/api/typescript-to-flow.ts +++ b/pages/api/typescript-to-flow.ts @@ -7,6 +7,8 @@ export default (req: NextApiRequest, res: NextApiResponse) => { const result = compiler.compileDefinitionString(req.body); res.status(200).send(beautify(result)); } catch (e) { + console.log(e); + res.status(500).send(e.message); } }; diff --git a/pages/api/typescript-to-json-schema.ts b/pages/api/typescript-to-json-schema.ts index 5ada355..0872b31 100644 --- a/pages/api/typescript-to-json-schema.ts +++ b/pages/api/typescript-to-json-schema.ts @@ -1,11 +1,20 @@ import { NextApiRequest, NextApiResponse } from "next"; import { Config } from "ts-json-schema-generator/dist/src/Config"; -import tempy from "tempy"; import * as tsj from "ts-json-schema-generator"; +import os from "os"; +import crypto from "crypto"; +import path from "path"; +import fs from "fs"; + +const tmpDir = os.tmpdir?.(); export default (req: NextApiRequest, res: NextApiResponse) => { + const filePath = + path.join(tmpDir, crypto.randomBytes(16).toString("hex")) + ".ts"; try { - const filePath = tempy.writeSync(req.body, { extension: "ts" }); + fs.writeFileSync(filePath, req.body, { + encoding: "utf-8" + }); const config: Config = { path: filePath, expose: "all", @@ -18,4 +27,5 @@ export default (req: NextApiRequest, res: NextApiResponse) => { } catch (e) { res.status(500).send(e.message); } + fs.unlinkSync(filePath); }; diff --git a/patches/relay-compiler+9.1.0.patch b/patches/relay-compiler+9.1.0.patch deleted file mode 100644 index 0fd1a25..0000000 --- a/patches/relay-compiler+9.1.0.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/node_modules/relay-compiler/lib/core/GraphQLCompilerProfiler.js b/node_modules/relay-compiler/lib/core/GraphQLCompilerProfiler.js -index 443d7f5..90119ec 100644 ---- a/node_modules/relay-compiler/lib/core/GraphQLCompilerProfiler.js -+++ b/node_modules/relay-compiler/lib/core/GraphQLCompilerProfiler.js -@@ -189,6 +189,8 @@ function instrumentWait(fn, name) { - return instrumented; - } - -+process.hrtime = () => {} -+ - var T_ZERO = process.hrtime(); // Return a Uint32 of microtime duration since program start. - - function microtime() { diff --git a/yarn.lock b/yarn.lock index 1cfc2a4..d19b633 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6359,6 +6359,14 @@ lil-uuid@^0.1.1: resolved "https://registry.yarnpkg.com/lil-uuid/-/lil-uuid-0.1.1.tgz#f9edcf23f00e42bf43f0f843d98d8b53f3341f16" integrity sha1-+e3PI/AOQr9D8PhD2Y2LU/M0HxY= +line-column@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/line-column/-/line-column-1.0.2.tgz#d25af2936b6f4849172b312e4792d1d987bc34a2" + integrity sha1-0lryk2tvSEkXKzEuR5LR2Ye8NKI= + dependencies: + isarray "^1.0.0" + isobject "^2.0.0" + lines-and-columns@^1.1.6: version "1.1.6" resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.1.6.tgz#1c00c743b433cd0a4e80758f7b64a57440d9ff00" @@ -7033,6 +7041,11 @@ nanoid@^2.1.0: resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-2.1.11.tgz#ec24b8a758d591561531b4176a01e3ab4f0f0280" integrity sha512-s/snB+WGm6uwi0WjsZdaVcuf3KJXlfGl2LcxgwkEwJF0D/BWzVWAZW/XY4bFaiR7s0Jk3FPvlnepg1H1b1UwlA== +nanoid@^3.1.12: + version "3.1.12" + resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.1.12.tgz#6f7736c62e8d39421601e4a0c77623a97ea69654" + integrity sha512-1qstj9z5+x491jfiC4Nelk+f8XBad7LN20PmyWINJEMRSf3wcAjAWysw1qaA8z6NSKe2sjq1hRSDpBH5paCb6A== + nanomatch@^1.2.9: version "1.2.13" resolved "https://registry.yarnpkg.com/nanomatch/-/nanomatch-1.2.13.tgz#b87a8aa4fc0de8fe6be88895b38983ff265bd119" @@ -8054,7 +8067,7 @@ postcss-functions@^3.0.0: postcss "^6.0.9" postcss-value-parser "^3.3.0" -postcss-js@^2.0.0, postcss-js@^2.0.3: +postcss-js@^2.0.0: version "2.0.3" resolved "https://registry.yarnpkg.com/postcss-js/-/postcss-js-2.0.3.tgz#a96f0f23ff3d08cec7dc5b11bf11c5f8077cdab9" integrity sha512-zS59pAk3deu6dVHyrGqmC3oDXBdNdajk4k1RyxeVXCrcEDBUBHoIhE4QTsmhxgzXxsaqFDAkUZfmMa5f/N/79w== @@ -8062,6 +8075,14 @@ postcss-js@^2.0.0, postcss-js@^2.0.3: camelcase-css "^2.0.1" postcss "^7.0.18" +postcss-js@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/postcss-js/-/postcss-js-3.0.1.tgz#e467efdce80ca02e072c60b42e0b35ad2f950a94" + integrity sha512-m1DgECmEbOK9JhGkdctaP9ZRVheJuEnkk2eb/d3K+5uN10C3S004Ng6Hat4Aha7PsLt824x0xwrT7rVwGRVLHg== + dependencies: + camelcase-css "^2.0.1" + postcss "^8.1.0" + postcss-load-config@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/postcss-load-config/-/postcss-load-config-2.1.0.tgz#c84d692b7bb7b41ddced94ee62e8ab31b417b003" @@ -8414,6 +8435,16 @@ postcss@^6.0.1, postcss@^6.0.23, postcss@^6.0.9: source-map "^0.6.1" supports-color "^5.4.0" +postcss@^8.1.0: + version "8.1.1" + resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.1.1.tgz#c3a287dd10e4f6c84cb3791052b96a5d859c9389" + integrity sha512-9DGLSsjooH3kSNjTZUOt2eIj2ZTW0VI2PZ/3My+8TC7KIbH2OKwUlISfDsf63EP4aiRUt3XkEWMWvyJHvJelEg== + dependencies: + colorette "^1.2.1" + line-column "^1.0.2" + nanoid "^3.1.12" + source-map "^0.6.1" + postinstall-postinstall@^2.0.0, postinstall-postinstall@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/postinstall-postinstall/-/postinstall-postinstall-2.1.0.tgz#4f7f77441ef539d1512c40bd04c71b06a4704ca3"