diff --git a/packages/codegen-ui-react/lib/__tests__/__snapshots__/react-studio-template-renderer-helper.test.ts.snap b/packages/codegen-ui-react/lib/__tests__/__snapshots__/react-studio-template-renderer-helper.test.ts.snap new file mode 100644 index 000000000..a59b3bfe5 --- /dev/null +++ b/packages/codegen-ui-react/lib/__tests__/__snapshots__/react-studio-template-renderer-helper.test.ts.snap @@ -0,0 +1,104 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`react-studio-template-renderer-helper transpile fails to transpile with ScriptTarget ESNext 1`] = `"ScriptTarget 99 not supported with type declarations enabled, expected one of [0,1,2,3,4,5,6,7,8]"`; + +exports[`react-studio-template-renderer-helper transpile fails to transpile with ScriptTarget Latest 1`] = `"ScriptTarget 99 not supported with type declarations enabled, expected one of [0,1,2,3,4,5,6,7,8]"`; + +exports[`react-studio-template-renderer-helper transpile successfully transpiles with ScriptTarget ES3 1`] = ` +"import React from \\"react\\"; +import { ViewTestProps } from \\"./ViewTest\\"; +import { EscapeHatchProps } from \\"@aws-amplify/ui-react\\"; +export declare type CustomParentAndChildrenProps = React.PropsWithChildren & { + overrides?: EscapeHatchProps | undefined | null; +}>; +export default function CustomParentAndChildren(props: CustomParentAndChildrenProps): React.ReactElement; +" +`; + +exports[`react-studio-template-renderer-helper transpile successfully transpiles with ScriptTarget ES5 1`] = ` +"import React from \\"react\\"; +import { ViewTestProps } from \\"./ViewTest\\"; +import { EscapeHatchProps } from \\"@aws-amplify/ui-react\\"; +export declare type CustomParentAndChildrenProps = React.PropsWithChildren & { + overrides?: EscapeHatchProps | undefined | null; +}>; +export default function CustomParentAndChildren(props: CustomParentAndChildrenProps): React.ReactElement; +" +`; + +exports[`react-studio-template-renderer-helper transpile successfully transpiles with ScriptTarget ES2015 1`] = ` +"import React from \\"react\\"; +import { ViewTestProps } from \\"./ViewTest\\"; +import { EscapeHatchProps } from \\"@aws-amplify/ui-react\\"; +export declare type CustomParentAndChildrenProps = React.PropsWithChildren & { + overrides?: EscapeHatchProps | undefined | null; +}>; +export default function CustomParentAndChildren(props: CustomParentAndChildrenProps): React.ReactElement; +" +`; + +exports[`react-studio-template-renderer-helper transpile successfully transpiles with ScriptTarget ES2016 1`] = ` +"import React from \\"react\\"; +import { ViewTestProps } from \\"./ViewTest\\"; +import { EscapeHatchProps } from \\"@aws-amplify/ui-react\\"; +export declare type CustomParentAndChildrenProps = React.PropsWithChildren & { + overrides?: EscapeHatchProps | undefined | null; +}>; +export default function CustomParentAndChildren(props: CustomParentAndChildrenProps): React.ReactElement; +" +`; + +exports[`react-studio-template-renderer-helper transpile successfully transpiles with ScriptTarget ES2017 1`] = ` +"import React from \\"react\\"; +import { ViewTestProps } from \\"./ViewTest\\"; +import { EscapeHatchProps } from \\"@aws-amplify/ui-react\\"; +export declare type CustomParentAndChildrenProps = React.PropsWithChildren & { + overrides?: EscapeHatchProps | undefined | null; +}>; +export default function CustomParentAndChildren(props: CustomParentAndChildrenProps): React.ReactElement; +" +`; + +exports[`react-studio-template-renderer-helper transpile successfully transpiles with ScriptTarget ES2018 1`] = ` +"import React from \\"react\\"; +import { ViewTestProps } from \\"./ViewTest\\"; +import { EscapeHatchProps } from \\"@aws-amplify/ui-react\\"; +export declare type CustomParentAndChildrenProps = React.PropsWithChildren & { + overrides?: EscapeHatchProps | undefined | null; +}>; +export default function CustomParentAndChildren(props: CustomParentAndChildrenProps): React.ReactElement; +" +`; + +exports[`react-studio-template-renderer-helper transpile successfully transpiles with ScriptTarget ES2019 1`] = ` +"import React from \\"react\\"; +import { ViewTestProps } from \\"./ViewTest\\"; +import { EscapeHatchProps } from \\"@aws-amplify/ui-react\\"; +export declare type CustomParentAndChildrenProps = React.PropsWithChildren & { + overrides?: EscapeHatchProps | undefined | null; +}>; +export default function CustomParentAndChildren(props: CustomParentAndChildrenProps): React.ReactElement; +" +`; + +exports[`react-studio-template-renderer-helper transpile successfully transpiles with ScriptTarget ES2020 1`] = ` +"import React from \\"react\\"; +import { ViewTestProps } from \\"./ViewTest\\"; +import { EscapeHatchProps } from \\"@aws-amplify/ui-react\\"; +export declare type CustomParentAndChildrenProps = React.PropsWithChildren & { + overrides?: EscapeHatchProps | undefined | null; +}>; +export default function CustomParentAndChildren(props: CustomParentAndChildrenProps): React.ReactElement; +" +`; + +exports[`react-studio-template-renderer-helper transpile successfully transpiles with ScriptTarget ES2021 1`] = ` +"import React from \\"react\\"; +import { ViewTestProps } from \\"./ViewTest\\"; +import { EscapeHatchProps } from \\"@aws-amplify/ui-react\\"; +export declare type CustomParentAndChildrenProps = React.PropsWithChildren & { + overrides?: EscapeHatchProps | undefined | null; +}>; +export default function CustomParentAndChildren(props: CustomParentAndChildrenProps): React.ReactElement; +" +`; diff --git a/packages/codegen-ui-react/lib/__tests__/react-studio-template-renderer-helper.test.ts b/packages/codegen-ui-react/lib/__tests__/react-studio-template-renderer-helper.test.ts new file mode 100644 index 000000000..128665cff --- /dev/null +++ b/packages/codegen-ui-react/lib/__tests__/react-studio-template-renderer-helper.test.ts @@ -0,0 +1,101 @@ +/* + Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ +import { StudioTemplateRendererFactory, StudioComponent } from '@aws-amplify/codegen-ui'; +import fs from 'fs'; +import { join } from 'path'; +import { ScriptTarget, ScriptKind } from '..'; +import { AmplifyRenderer } from '../amplify-ui-renderers/amplify-renderer'; + +function loadSchemaFromJSONFile(jsonSchemaFile: string): StudioComponent { + return JSON.parse( + fs.readFileSync(join(__dirname, 'studio-ui-json', `${jsonSchemaFile}.json`), 'utf-8'), + ) as StudioComponent; +} + +function generateDeclarationForScriptTarget(jsonSchemaFile: string, target: ScriptTarget): any { + const rendererFactory = new StudioTemplateRendererFactory( + (component: StudioComponent) => + new AmplifyRenderer(component, { target, script: ScriptKind.JS, renderTypeDeclarations: true }), + ); + const component = rendererFactory.buildRenderer(loadSchemaFromJSONFile(jsonSchemaFile)).renderComponent(); + return (component as unknown as { declaration: string }).declaration; +} + +describe('react-studio-template-renderer-helper', () => { + describe('transpile', () => { + it('successfully transpiles with ScriptTarget ES3', () => { + expect(generateDeclarationForScriptTarget('custom/customParentAndChildren', ScriptTarget.ES3)).toMatchSnapshot(); + }); + + it('successfully transpiles with ScriptTarget ES5', () => { + expect(generateDeclarationForScriptTarget('custom/customParentAndChildren', ScriptTarget.ES5)).toMatchSnapshot(); + }); + + it('successfully transpiles with ScriptTarget ES2015', () => { + expect( + generateDeclarationForScriptTarget('custom/customParentAndChildren', ScriptTarget.ES2015), + ).toMatchSnapshot(); + }); + + it('successfully transpiles with ScriptTarget ES2016', () => { + expect( + generateDeclarationForScriptTarget('custom/customParentAndChildren', ScriptTarget.ES2016), + ).toMatchSnapshot(); + }); + + it('successfully transpiles with ScriptTarget ES2017', () => { + expect( + generateDeclarationForScriptTarget('custom/customParentAndChildren', ScriptTarget.ES2017), + ).toMatchSnapshot(); + }); + + it('successfully transpiles with ScriptTarget ES2018', () => { + expect( + generateDeclarationForScriptTarget('custom/customParentAndChildren', ScriptTarget.ES2018), + ).toMatchSnapshot(); + }); + + it('successfully transpiles with ScriptTarget ES2019', () => { + expect( + generateDeclarationForScriptTarget('custom/customParentAndChildren', ScriptTarget.ES2019), + ).toMatchSnapshot(); + }); + + it('successfully transpiles with ScriptTarget ES2020', () => { + expect( + generateDeclarationForScriptTarget('custom/customParentAndChildren', ScriptTarget.ES2020), + ).toMatchSnapshot(); + }); + + it('successfully transpiles with ScriptTarget ES2021', () => { + expect( + generateDeclarationForScriptTarget('custom/customParentAndChildren', ScriptTarget.ES2021), + ).toMatchSnapshot(); + }); + + it('fails to transpile with ScriptTarget ESNext', () => { + expect(() => { + generateDeclarationForScriptTarget('custom/customParentAndChildren', ScriptTarget.ESNext); + }).toThrowErrorMatchingSnapshot(); + }); + + it('fails to transpile with ScriptTarget Latest', () => { + expect(() => { + generateDeclarationForScriptTarget('custom/customParentAndChildren', ScriptTarget.Latest); + }).toThrowErrorMatchingSnapshot(); + }); + }); +}); diff --git a/packages/codegen-ui-react/lib/react-studio-template-renderer-helper.ts b/packages/codegen-ui-react/lib/react-studio-template-renderer-helper.ts index 4f9a7fce8..421a0d9a4 100644 --- a/packages/codegen-ui-react/lib/react-studio-template-renderer-helper.ts +++ b/packages/codegen-ui-react/lib/react-studio-template-renderer-helper.ts @@ -17,8 +17,9 @@ import { isDataPropertyBinding, StudioComponentDataPropertyBinding, StudioComponentSimplePropertyBinding, + InternalError, + InvalidInputError, } from '@aws-amplify/codegen-ui'; - import ts, { createPrinter, createSourceFile, @@ -33,11 +34,10 @@ import ts, { ObjectLiteralExpression, createProgram, } from 'typescript'; +import { createDefaultMapFromNodeModules, createSystem, createVirtualCompilerHost } from '@typescript/vfs'; import prettier from 'prettier'; import parserTypescript from 'prettier/parser-typescript'; -import fs from 'fs'; import path from 'path'; -import temp from 'temp'; import { ReactRenderConfig, ScriptKind, ScriptTarget, ModuleKind } from './react-render-config'; export const defaultRenderConfig = { @@ -46,6 +46,18 @@ export const defaultRenderConfig = { module: ModuleKind.ESNext, }; +const supportedTranspilationTargets = [ + ScriptTarget.ES3, + ScriptTarget.ES5, + ScriptTarget.ES2015, + ScriptTarget.ES2016, + ScriptTarget.ES2017, + ScriptTarget.ES2018, + ScriptTarget.ES2019, + ScriptTarget.ES2020, + ScriptTarget.ES2021, +]; + export function transpile( code: string, renderConfig: ReactRenderConfig, @@ -63,33 +75,45 @@ export function transpile( const componentText = prettier.format(transpiledCode, { parser: 'typescript', plugins: [parserTypescript] }); - /* createProgram is less performant than traspileModule and should only be used when necessary. + /* + * createProgram is less performant than traspileModule and should only be used when necessary. * createProgram is used here becuase transpileModule cannot produce type declarations. + * We execute in a virtual filesystem to ensure we have no dependencies on platform fs in this stage. */ if (renderTypeDeclarations) { - temp.track(); // tracks temp resources created to then be deleted by temp.cleanupSync + if (target && !new Set(supportedTranspilationTargets).has(target)) { + throw new InvalidInputError( + `ScriptTarget ${target} not supported with type declarations enabled, expected one of ${JSON.stringify( + supportedTranspilationTargets, + )}`, + ); + } - try { - const tmpFile = temp.openSync({ suffix: '.tsx' }); - const tmpDir = temp.mkdirSync(); + const compilerOptions = { + target, + module, + declaration: true, + emitDeclarationOnly: true, + skipLibCheck: true, + }; - fs.writeFileSync(tmpFile.path, code); + const fsMap = createDefaultMapFromNodeModules(compilerOptions, ts); + fsMap.set('index.tsx', code); - createProgram([tmpFile.path], { - target, - module, - declaration: true, - emitDeclarationOnly: true, - outDir: tmpDir, - skipLibCheck: true, - }).emit(); + const host = createVirtualCompilerHost(createSystem(fsMap), compilerOptions, ts); + createProgram({ + rootNames: [...fsMap.keys()], + options: compilerOptions, + host: host.compilerHost, + }).emit(); - const declaration = fs.readFileSync(path.join(tmpDir, getDeclarationFilename(tmpFile.path)), 'utf8'); + const declaration = fsMap.get('index.d.ts'); - return { componentText, declaration }; - } finally { - temp.cleanupSync(); + if (!declaration) { + throw new InternalError('Component declaration file not generated'); } + + return { componentText, declaration }; } return { diff --git a/packages/codegen-ui-react/package-lock.json b/packages/codegen-ui-react/package-lock.json index d26605300..c64b5eb89 100644 --- a/packages/codegen-ui-react/package-lock.json +++ b/packages/codegen-ui-react/package-lock.json @@ -6,12 +6,11 @@ "packages": { "": { "name": "@aws-amplify/codegen-ui-react", - "version": "0.13.1", + "version": "1.0.0", "license": "Apache-2.0", "dependencies": { - "@types/temp": "^0.9.1", + "@typescript/vfs": "~1.3.5", "prettier": "2.3.2", - "temp": "^0.9.4", "typescript": "~4.4.4" }, "devDependencies": { @@ -7561,7 +7560,8 @@ }, "node_modules/@types/node": { "version": "16.10.9", - "integrity": "sha512-H9ReOt+yqIJPCutkTYjFjlyK6WEMQYT9hLZMlWtOjFQY2ItppsWZ6RJf8Aw+jz5qTYceuHvFgPIaKOHtLAEWBw==" + "integrity": "sha512-H9ReOt+yqIJPCutkTYjFjlyK6WEMQYT9hLZMlWtOjFQY2ItppsWZ6RJf8Aw+jz5qTYceuHvFgPIaKOHtLAEWBw==", + "dev": true }, "node_modules/@types/prop-types": { "version": "15.7.4", @@ -7583,13 +7583,6 @@ "integrity": "sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew==", "dev": true }, - "node_modules/@types/temp": { - "version": "0.9.1", - "integrity": "sha512-yDQ8Y+oQi9V7VkexwE6NBSVyNuyNFeGI275yWXASc2DjmxNicMi9O50KxDpNlST1kBbV9jKYBHGXhgNYFMPqtA==", - "dependencies": { - "@types/node": "*" - } - }, "node_modules/@types/yargs": { "version": "16.0.4", "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-16.0.4.tgz", @@ -7607,6 +7600,35 @@ "dev": true, "peer": true }, + "node_modules/@typescript/vfs": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/@typescript/vfs/-/vfs-1.3.5.tgz", + "integrity": "sha512-pI8Saqjupf9MfLw7w2+og+fmb0fZS0J6vsKXXrp4/PDXEFvntgzXmChCXC/KefZZS0YGS6AT8e0hGAJcTsdJlg==", + "dependencies": { + "debug": "^4.1.1" + } + }, + "node_modules/@typescript/vfs/node_modules/debug": { + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz", + "integrity": "sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/@typescript/vfs/node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + }, "node_modules/@xstate/react": { "version": "1.6.1", "integrity": "sha512-M3b32nGhA0K3N6NrYKAMXx3dgGlLmuZfJU/EsZT04kQyVbWSiT3z7p9rdPisQyaQYFUwdqspQZ68wRNWbUkfVQ==", @@ -8084,7 +8106,8 @@ }, "node_modules/balanced-match": { "version": "1.0.2", - "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true }, "node_modules/base": { "version": "0.11.2", @@ -8190,6 +8213,7 @@ "node_modules/brace-expansion": { "version": "1.1.11", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, "dependencies": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -8785,7 +8809,8 @@ }, "node_modules/concat-map": { "version": "0.0.1", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true }, "node_modules/connect": { "version": "3.7.0", @@ -9667,7 +9692,8 @@ }, "node_modules/fs.realpath": { "version": "1.0.0", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true }, "node_modules/fsevents": { "version": "2.3.2", @@ -9759,6 +9785,7 @@ "node_modules/glob": { "version": "7.2.0", "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", + "dev": true, "dependencies": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", @@ -10043,6 +10070,7 @@ "node_modules/inflight": { "version": "1.0.6", "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true, "dependencies": { "once": "^1.3.0", "wrappy": "1" @@ -10050,7 +10078,8 @@ }, "node_modules/inherits": { "version": "2.0.4", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true }, "node_modules/invariant": { "version": "2.2.4", @@ -11901,6 +11930,7 @@ "node_modules/minimatch": { "version": "3.0.4", "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, "dependencies": { "brace-expansion": "^1.1.7" }, @@ -11910,7 +11940,8 @@ }, "node_modules/minimist": { "version": "1.2.5", - "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==" + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", + "dev": true }, "node_modules/mixin-deep": { "version": "1.3.2", @@ -11929,6 +11960,8 @@ "node_modules/mkdirp": { "version": "0.5.5", "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", + "dev": true, + "peer": true, "dependencies": { "minimist": "^1.2.5" }, @@ -12339,6 +12372,7 @@ "node_modules/once": { "version": "1.4.0", "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, "dependencies": { "wrappy": "1" } @@ -12621,6 +12655,7 @@ "node_modules/path-is-absolute": { "version": "1.0.1", "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true, "engines": { "node": ">=0.10.0" } @@ -14626,27 +14661,6 @@ "node": ">=8" } }, - "node_modules/temp": { - "version": "0.9.4", - "integrity": "sha512-yYrrsWnrXMcdsnu/7YMYAofM1ktpL5By7vZhf15CrXijWWrEYZks5AXBudalfSWJLlnen/QUJUB5aoB0kqZUGA==", - "dependencies": { - "mkdirp": "^0.5.1", - "rimraf": "~2.6.2" - }, - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/temp/node_modules/rimraf": { - "version": "2.6.3", - "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==", - "dependencies": { - "glob": "^7.1.3" - }, - "bin": { - "rimraf": "bin.js" - } - }, "node_modules/throat": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/throat/-/throat-5.0.0.tgz", @@ -14791,6 +14805,7 @@ }, "node_modules/typescript": { "version": "4.4.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.4.tgz", "integrity": "sha512-DqGhF5IKoBl8WNf8C1gu8q0xZSInh9j1kJJMqT3a94w1JzVaBU4EXOSMrz9yDqMT0xt3selp83fuFMQ0uzv6qA==", "bin": { "tsc": "bin/tsc", @@ -15272,7 +15287,8 @@ }, "node_modules/wrappy": { "version": "1.0.2", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true }, "node_modules/write-file-atomic": { "version": "2.4.3", @@ -21757,7 +21773,8 @@ }, "@types/node": { "version": "16.10.9", - "integrity": "sha512-H9ReOt+yqIJPCutkTYjFjlyK6WEMQYT9hLZMlWtOjFQY2ItppsWZ6RJf8Aw+jz5qTYceuHvFgPIaKOHtLAEWBw==" + "integrity": "sha512-H9ReOt+yqIJPCutkTYjFjlyK6WEMQYT9hLZMlWtOjFQY2ItppsWZ6RJf8Aw+jz5qTYceuHvFgPIaKOHtLAEWBw==", + "dev": true }, "@types/prop-types": { "version": "15.7.4", @@ -21779,13 +21796,6 @@ "integrity": "sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew==", "dev": true }, - "@types/temp": { - "version": "0.9.1", - "integrity": "sha512-yDQ8Y+oQi9V7VkexwE6NBSVyNuyNFeGI275yWXASc2DjmxNicMi9O50KxDpNlST1kBbV9jKYBHGXhgNYFMPqtA==", - "requires": { - "@types/node": "*" - } - }, "@types/yargs": { "version": "16.0.4", "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-16.0.4.tgz", @@ -21803,6 +21813,29 @@ "dev": true, "peer": true }, + "@typescript/vfs": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/@typescript/vfs/-/vfs-1.3.5.tgz", + "integrity": "sha512-pI8Saqjupf9MfLw7w2+og+fmb0fZS0J6vsKXXrp4/PDXEFvntgzXmChCXC/KefZZS0YGS6AT8e0hGAJcTsdJlg==", + "requires": { + "debug": "^4.1.1" + }, + "dependencies": { + "debug": { + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz", + "integrity": "sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==", + "requires": { + "ms": "2.1.2" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + } + } + }, "@xstate/react": { "version": "1.6.1", "integrity": "sha512-M3b32nGhA0K3N6NrYKAMXx3dgGlLmuZfJU/EsZT04kQyVbWSiT3z7p9rdPisQyaQYFUwdqspQZ68wRNWbUkfVQ==", @@ -22196,7 +22229,8 @@ }, "balanced-match": { "version": "1.0.2", - "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true }, "base": { "version": "0.11.2", @@ -22275,6 +22309,7 @@ "brace-expansion": { "version": "1.1.11", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -22774,7 +22809,8 @@ }, "concat-map": { "version": "0.0.1", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true }, "connect": { "version": "3.7.0", @@ -23483,7 +23519,8 @@ }, "fs.realpath": { "version": "1.0.0", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true }, "fsevents": { "version": "2.3.2", @@ -23550,6 +23587,7 @@ "glob": { "version": "7.2.0", "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", + "dev": true, "requires": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", @@ -23765,6 +23803,7 @@ "inflight": { "version": "1.0.6", "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true, "requires": { "once": "^1.3.0", "wrappy": "1" @@ -23772,7 +23811,8 @@ }, "inherits": { "version": "2.0.4", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true }, "invariant": { "version": "2.2.4", @@ -25357,13 +25397,15 @@ "minimatch": { "version": "3.0.4", "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, "requires": { "brace-expansion": "^1.1.7" } }, "minimist": { "version": "1.2.5", - "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==" + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", + "dev": true }, "mixin-deep": { "version": "1.3.2", @@ -25379,6 +25421,8 @@ "mkdirp": { "version": "0.5.5", "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", + "dev": true, + "peer": true, "requires": { "minimist": "^1.2.5" } @@ -25709,6 +25753,7 @@ "once": { "version": "1.4.0", "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, "requires": { "wrappy": "1" } @@ -25944,7 +25989,8 @@ }, "path-is-absolute": { "version": "1.0.1", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true }, "path-key": { "version": "2.0.1", @@ -27582,23 +27628,6 @@ "has-flag": "^4.0.0" } }, - "temp": { - "version": "0.9.4", - "integrity": "sha512-yYrrsWnrXMcdsnu/7YMYAofM1ktpL5By7vZhf15CrXijWWrEYZks5AXBudalfSWJLlnen/QUJUB5aoB0kqZUGA==", - "requires": { - "mkdirp": "^0.5.1", - "rimraf": "~2.6.2" - }, - "dependencies": { - "rimraf": { - "version": "2.6.3", - "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==", - "requires": { - "glob": "^7.1.3" - } - } - } - }, "throat": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/throat/-/throat-5.0.0.tgz", @@ -27718,6 +27747,7 @@ }, "typescript": { "version": "4.4.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.4.tgz", "integrity": "sha512-DqGhF5IKoBl8WNf8C1gu8q0xZSInh9j1kJJMqT3a94w1JzVaBU4EXOSMrz9yDqMT0xt3selp83fuFMQ0uzv6qA==" }, "uglify-es": { @@ -28108,7 +28138,8 @@ }, "wrappy": { "version": "1.0.2", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true }, "write-file-atomic": { "version": "2.4.3", diff --git a/packages/codegen-ui-react/package.json b/packages/codegen-ui-react/package.json index bad06a1d2..46d3435c8 100644 --- a/packages/codegen-ui-react/package.json +++ b/packages/codegen-ui-react/package.json @@ -26,10 +26,9 @@ }, "dependencies": { "@aws-amplify/codegen-ui": "1.0.0", - "@types/temp": "^0.9.1", "prettier": "2.3.2", - "temp": "^0.9.4", - "typescript": "~4.4.4" + "typescript": "~4.4.4", + "@typescript/vfs": "~1.3.5" }, "peerDependencies": { "react": "^17.0.2", diff --git a/packages/codegen-ui/package-lock.json b/packages/codegen-ui/package-lock.json index 04b077ba5..d6cdd7d48 100644 --- a/packages/codegen-ui/package-lock.json +++ b/packages/codegen-ui/package-lock.json @@ -6,7 +6,7 @@ "packages": { "": { "name": "@aws-amplify/codegen-ui", - "version": "0.13.1", + "version": "1.0.0", "license": "Apache-2.0", "dependencies": { "yup": "^0.32.11" diff --git a/packages/test-generator/lib/generators/GenerateTestApp.ts b/packages/test-generator/lib/generators/GenerateTestApp.ts index 6b7d29cd5..9df953f17 100644 --- a/packages/test-generator/lib/generators/GenerateTestApp.ts +++ b/packages/test-generator/lib/generators/GenerateTestApp.ts @@ -40,8 +40,8 @@ const jsxGenerator = new NodeTestGenerator({ writeToLogger: false, writeToDisk: true, renderConfigOverride: { - module: ModuleKind.ESNext, - target: ScriptTarget.ESNext, + module: ModuleKind.ES2020, + target: ScriptTarget.ES2020, script: ScriptKind.JSX, renderTypeDeclarations: true, }, diff --git a/packages/test-generator/package-lock.json b/packages/test-generator/package-lock.json index a3f9fb95e..203110bb0 100644 --- a/packages/test-generator/package-lock.json +++ b/packages/test-generator/package-lock.json @@ -6,7 +6,7 @@ "packages": { "": { "name": "@aws-amplify/codegen-ui-test-generator", - "version": "0.13.1", + "version": "1.0.0", "license": "Apache-2.0", "dependencies": { "@types/node": "^15.12.1",