This repository has been archived by the owner on Jan 24, 2024. It is now read-only.
/
create-app.ts
59 lines (52 loc) · 1.88 KB
/
create-app.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import { Command } from '@oclif/core';
import { ensureDir } from 'fs-extra';
import { zipObject } from 'lodash';
import { AppAction } from '../../src/app/app.interface';
import { generateAppDefinition } from '../generators/generate-app-definition';
import { generateAppModule } from '../generators/generate-app-module';
import {
promptAppDescription,
promptAppId,
promptAppName,
promptAppNetworks,
promptAppTags,
promptAppUrl,
} from '../prompts';
import { strings } from '../strings';
import { generateContractFactory } from './generate-contract-factory';
export default class CreateApp extends Command {
static description = 'Creates the starting point for an app integration';
static examples = [`$ ./studio create-app`];
static flags = {};
static args = [{ name: 'appId', description: 'The application id ', required: true }];
async run(): Promise<void> {
const appName = await promptAppName();
const appId = await promptAppId(strings.kebabCase(appName));
const appDescription = await promptAppDescription();
const appUrl = await promptAppUrl();
const networks = await promptAppNetworks();
const tags = await promptAppTags();
await ensureDir(`./src/apps/${appId}`);
await ensureDir(`./src/apps/${appId}/assets`);
await ensureDir(`./src/apps/${appId}/contracts`);
await ensureDir(`./src/apps/${appId}/contracts/abis`);
for (const network of networks) {
await ensureDir(`./src/apps/${appId}/${network}`);
}
await generateAppModule(appId);
await generateAppDefinition({
id: appId,
name: appName,
description: appDescription,
url: appUrl,
tags,
links: {},
supportedNetworks: zipObject(
networks,
networks.map(() => [AppAction.VIEW]),
),
});
await generateContractFactory(`./src/apps/${appId}`);
this.log(`You can now fill/update ${appId}.definition.ts`);
}
}