-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(test-generator): run all schemas (#39)
- Loading branch information
Showing
3 changed files
with
50 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,51 @@ | ||
import { StudioComponent } from '@amzn/amplify-ui-codegen-schema'; | ||
import { StudioTemplateRendererManager, StudioTemplateRendererFactory } from '@amzn/studio-ui-codegen'; | ||
import { | ||
StudioComponent, | ||
} from "@amzn/amplify-ui-codegen-schema" | ||
import { | ||
StudioTemplateRendererManager, | ||
StudioTemplateRendererFactory, | ||
} from "@amzn/studio-ui-codegen"; | ||
import { | ||
AmplifyRenderer, | ||
AmplifyRenderer, | ||
ReactOutputConfig, | ||
JSModuleEnum, | ||
CompileTargetEnum, | ||
JSOutputFormatEnum | ||
} from "@amzn/studio-ui-codegen-react"; | ||
JSOutputFormatEnum, | ||
} from '@amzn/studio-ui-codegen-react'; | ||
import path from 'path'; | ||
|
||
import * as schema from "./lib/dataBindingWithDataStore.json"; | ||
import * as schemas from './lib'; | ||
|
||
Error.stackTraceLimit = Infinity; | ||
|
||
const rendererFactory = new StudioTemplateRendererFactory( | ||
(component: StudioComponent) => new AmplifyRenderer(component) | ||
(component: StudioComponent) => new AmplifyRenderer(component), | ||
); | ||
|
||
const outputPathDir = path.resolve(path.join(__dirname, '..', 'ui-components')); | ||
const outputConfig: ReactOutputConfig = { | ||
outputPathDir, | ||
module: JSModuleEnum.CommonJS, | ||
compileTarget: CompileTargetEnum.ES6, | ||
outputFormat: JSOutputFormatEnum.tsx | ||
outputFormat: JSOutputFormatEnum.tsx, | ||
}; | ||
const rendererManager = new StudioTemplateRendererManager(rendererFactory, outputConfig); | ||
|
||
console.log(rendererManager); | ||
|
||
rendererManager.renderSchemaToTemplate(schema as any); | ||
|
||
const compOnly = rendererFactory.buildRenderer(schema as any).renderComponentOnly(); | ||
console.log("Component Only Output"); | ||
console.log("componentText "); | ||
console.log(compOnly.compText); | ||
console.log("componentImports "); | ||
console.log(compOnly.importsText); | ||
|
||
const compOnlyAppSample = rendererFactory.buildRenderer(schema as any).renderSampleCodeSnippet(); | ||
console.log("Code Snippet Output"); | ||
console.log("componentText "); | ||
console.log(compOnlyAppSample.compText); | ||
console.log("componentImports "); | ||
console.log(compOnlyAppSample.importsText); | ||
Object.entries(schemas).forEach(([name, schema]) => { | ||
console.log(name); | ||
try { | ||
rendererManager.renderSchemaToTemplate(schema as any); | ||
const buildRenderer = rendererFactory.buildRenderer(schema as any); | ||
|
||
const compOnly = buildRenderer.renderComponentOnly(); | ||
console.log('Component Only Output'); | ||
console.log('componentImports '); | ||
console.log(compOnly.importsText); | ||
console.log('componentText '); | ||
console.log(compOnly.compText); | ||
|
||
const compOnlyAppSample = buildRenderer.renderSampleCodeSnippet(); | ||
console.log('Code Snippet Output'); | ||
console.log('componentImports '); | ||
console.log(compOnlyAppSample.importsText); | ||
console.log('componentText '); | ||
console.log(compOnlyAppSample.compText); | ||
} catch (err) { | ||
console.log(`${name} failed with error:`); | ||
console.log(err); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
export { default as BoxGolden } from './boxGolden.json'; | ||
export { default as BoxTest } from './boxTest.json'; | ||
export { default as ButtonGolden } from './buttonGolden.json'; | ||
export { default as CustomChild } from './customChild.json'; | ||
export { default as CustomTimeline } from './customTimeline.json'; | ||
export { default as DataBindingWithDataStore } from './dataBindingWithDataStore.json'; | ||
export { default as ExposedAsTest } from './exposedAsTest.json'; | ||
export { default as HeaderWithAction } from './headerWithAction.json'; | ||
export { default as PropertyListing } from './propertyListing.json'; | ||
export { default as RedBadge } from './redBadge.json'; | ||
export { default as SampleCodeSnippet } from './sampleCodeSnippet.json'; | ||
export { default as Studio } from './studio.json'; | ||
export { default as TextGolden } from './textGolden.json'; | ||
export { default as TextsCollection } from './textsCollection.json'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters