Skip to content

Commit

Permalink
fix: new command (#78)
Browse files Browse the repository at this point in the history
* fix: new command

* fix: ChalkInstance -> Chalk
  • Loading branch information
emidev98 authored May 29, 2022
1 parent 56b1e12 commit 709ea35
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 46 deletions.
22 changes: 11 additions & 11 deletions src/TerrainCLI.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
import chalk, { ChalkInstance } from 'chalk';
import chalk, { Chalk } from 'chalk';
import cli from 'cli-ux';

/** TerrainCLI offers default log styling for terrain commands. */
class TerrainCLI {
prefix: string;

logStyle: ChalkInstance;
logStyle: Chalk;

successStyle: ChalkInstance;
successStyle: Chalk;

warningStyle: ChalkInstance;
warningStyle: Chalk;

errorStyle: ChalkInstance;
errorStyle: Chalk;

anykeyStyle: ChalkInstance;
anykeyStyle: Chalk;

constructor(
prefix: string,
logStyle: ChalkInstance,
successStyle: ChalkInstance,
warningStyle: ChalkInstance,
errorStyle: ChalkInstance,
anykeyStyle: ChalkInstance,
logStyle: Chalk,
successStyle: Chalk,
warningStyle: Chalk,
errorStyle: Chalk,
anykeyStyle: Chalk,
) {
this.prefix = prefix;
this.logStyle = logStyle;
Expand Down
37 changes: 2 additions & 35 deletions src/commands/new.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@ import { Command, flags } from '@oclif/command';
import { TemplateScaffolding } from '@terra-money/template-scaffolding';
import cli from 'cli-ux';
import * as path from 'path';
import * as fs from 'fs-extra';
import Zip from 'adm-zip';
import * as request from 'superagent';
import { execSync } from 'child_process';
import * as fs from 'fs';

export default class New extends Command {
static description = 'Create new dapp from a template.';
static description = 'Create new dapp from template.';

static examples = [
'$ terrain new awesome-dapp',
Expand Down Expand Up @@ -64,36 +61,6 @@ export default class New extends Command {
},
});
cli.action.stop();
process.chdir('..');

cli.action.start('- frontend');
if (flags.framework === 'react') {
await new Promise((resolve, reject) => {
const file = fs.createWriteStream('frontend.zip');
request
.get(
'https://github.com/terra-money/terrain-frontend-template/archive/refs/heads/main.zip',
)
.on('error', (error) => {
reject(error);
})
.pipe(file)
.on('finish', () => {
cli.action.stop();
resolve(null);
});
});
const zip = new Zip('frontend.zip');
zip.extractAllTo('.', true);
fs.renameSync('terrain-frontend-template-main', 'frontend');
fs.removeSync('frontend.zip');
} else {
execSync(
`npx copy-github-directory https://github.com/terra-money/wallet-provider/tree/main/templates/${flags.framework} frontend`,
);
process.chdir('frontend');
fs.removeSync('sandbox.config.json');
}

cli.action.start('- contract');
await TemplateScaffolding.from({
Expand Down

0 comments on commit 709ea35

Please sign in to comment.