diff --git a/cli/commands/create-app.ts b/cli/commands/create-app.ts index f7eee077d..fb1bb67ff 100644 --- a/cli/commands/create-app.ts +++ b/cli/commands/create-app.ts @@ -4,6 +4,7 @@ import { zipObject } from 'lodash'; import { AppAction } from '../../src/app/app.interface'; import { generateAppDefinition } from '../generators/generate-app-definition'; +import { generateAppIndex } from '../generators/generate-app-index'; import { generateAppModule } from '../generators/generate-app-module'; import { promptAppDescription, @@ -40,6 +41,7 @@ export default class CreateApp extends Command { } await generateAppModule(appId); + await generateAppIndex(appId); await generateAppDefinition({ id: appId, name: appName, diff --git a/cli/generators/generate-app-index.ts b/cli/generators/generate-app-index.ts new file mode 100644 index 000000000..a3dcd66ad --- /dev/null +++ b/cli/generators/generate-app-index.ts @@ -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); +} diff --git a/src/apps/rari-fuse/index.ts b/src/apps/rari-fuse/index.ts new file mode 100644 index 000000000..c2c74a26a --- /dev/null +++ b/src/apps/rari-fuse/index.ts @@ -0,0 +1,2 @@ +export { RARI_FUSE_DEFINITION, RariFuseAppDefinition } from './rari-fuse.definition'; +export { RariFuseContractFactory } from './contracts'; diff --git a/src/apps/saddle/index.ts b/src/apps/saddle/index.ts new file mode 100644 index 000000000..edd2d9db7 --- /dev/null +++ b/src/apps/saddle/index.ts @@ -0,0 +1,2 @@ +export { SADDLE_DEFINITION, SaddleAppDefinition } from './saddle.definition'; +export { SaddleContractFactory } from './contracts';