import { RuntimeProxyAdapter } from "../utils/runtimeProxyAdapter" ; import { testState , RuntimeLogLevels , normalizeProjectInput , RuntimeProps , FileOverwriteBehaviors , Project , RuntimeAdapterProps , GeneratorProps , buildTokenCasing , ProjectInput , ProjectBuild , } from "@codotype/core" ; import { InMemoryFileSystemAdapter } from "../InMemoryFileSystemAdapter" ; import { NodeRuntime } from "../node-runtime" ; export const projectInput = { schemas : [ testState . userSchema , testState . movieSchema ] , relations : [ ] , configuration : { } , pluginID : "123" , pluginVersion : "0.1.1" , id : "project-id" , identifiers : buildTokenCasing ( "My Project" ) , } ; export const project = normalizeProjectInput ( { projectInput , } ) ; export const build = { projectInput , startTime : new Date ( ) . toISOString ( ) , endTime : new Date ( ) . toISOString ( ) , } ; export const runtimeProps = { cwd : "/test-cwd/" , fileSystemAdapter : new InMemoryFileSystemAdapter ( ) , } ; export const baseRuntimeAdapterProps = { destinationPath : "destination" , generatorResolvedPath : "my/resolved/path" , project , plugin : testState . cdkPluginMeta , runtime : new NodeRuntime ( runtimeProps ) , } ; export const generatorPrototype = { name : "Prototype Generator" , write : jest . fn ( ) , renderInPlace : [ ] , forEachSchema : jest . fn ( ) , forEachRelation : jest . fn ( ) , forEachReferencedBy : jest . fn ( ) , } ; const jsonFileContents = '{name: "project", "main": "dist/index","types": "dist/index","files": ["dist"],"repository": {"type": "git","url": "git+https://github.com/codotype/codotype-runtime.git"},"author": "Alexander Schwartzberg","license": "MIT"}' ; const htmlFileContents = "<html><head><title>Page Title</title></head><body><h1>Hello, HTML!</h1></body></html>" ; export const generatorPrototype01 = { name : "ModuleComponents" , async write ( { runtime } ) { await runtime . writeFile ( "package.json" , jsonFileContents , { prettify : { parser : "json" , } , } ) ; await runtime . writeFile ( "package-no-prettify.json" , jsonFileContents ) ; await runtime . writeFile ( "index.html" , htmlFileContents , { prettify : { parser : "json" , } , } ) ; await runtime . writeFile ( "index-no-prettify.html" , htmlFileContents ) ; await runtime . writeFile ( "README.md" , "# Your New Project" ) ; await runtime . renderTemplate ( { src : "prettify-test.js.ejs" , dest : `prettify-test.js` , data : { } , options : { prettify : { parser : "babel" , semi : true , } , } , } ) ; await runtime . renderTemplate ( { src : "prettify-test.js.ejs" , dest : `prettify-test-no-semi.js` , data : { } , options : { prettify : { parser : "babel" , semi : false , } , } , } ) ; } , async forEachSchema ( { schema , runtime } ) { await runtime . renderTemplate ( { src : "page.tsx.ejs" , dest : `pages/${ schema . identifiers . plural . snake }.tsx` , data : { schema } , } ) ; } , } ;