This repository has been archived by the owner on Jan 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 380
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(codegen): Add indexes and generate on create app (#508)
- Loading branch information
1 parent
5a8141e
commit a55cb92
Showing
4 changed files
with
27 additions
and
0 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
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,21 @@ | ||
import dedent from 'dedent'; | ||
import * as recast from 'recast'; | ||
|
||
import { strings } from '../strings'; | ||
|
||
import { formatAndWrite } from './utils'; | ||
|
||
export async function generateAppIndex(appId: string) { | ||
const appDefinitionName = `${strings.upperCase(appId)}_DEFINITION`; | ||
const appClassName = strings.titleCase(appId); | ||
|
||
const content = dedent` | ||
export { ${appDefinitionName}, ${appClassName}AppDefinition } from './${appId}.definition'; | ||
export { ${appClassName}AppModule } from './${appId}.module'; | ||
export { ${appClassName}ContractFactory } from './contracts'; | ||
`; | ||
|
||
const ast = recast.parse(content, { parser: require('recast/parsers/typescript') }); | ||
const prettyContent = recast.prettyPrint(ast).code; | ||
await formatAndWrite(`./src/apps/${appId}/index.ts`, prettyContent); | ||
} |
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,2 @@ | ||
export { RARI_FUSE_DEFINITION, RariFuseAppDefinition } from './rari-fuse.definition'; | ||
export { RariFuseContractFactory } from './contracts'; |
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,2 @@ | ||
export { SADDLE_DEFINITION, SaddleAppDefinition } from './saddle.definition'; | ||
export { SaddleContractFactory } from './contracts'; |