Skip to content

feat: add no frontend flag to new command #152

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -764,13 +764,14 @@ Create new dapp from template.
```
USAGE
$ terrain new [NAME] [--path <value>] [--framework react|vue|svelte|next|vite|lit] [--version <value>]
[--authors <value>]
[--authors <value>] [--no-frontend]

FLAGS
--authors=<value> [default: Terra Money <[email protected]>]
--framework=<option> [default: react] Choose the frontend framework you want to use. Non-react framework options have
better wallet-provider support but less streamlined contract integration.
<options: react|vue|svelte|next|vite|lit>
--no-frontend Setup terrain as a CLI tool only
--path=<value> [default: .] Path to create the workspace
--version=<value> [default: 1.0]

Expand All @@ -785,6 +786,8 @@ EXAMPLES
$ terrain new awesome-dapp --path path/to/dapp --authors "ExampleAuthor<[email protected]>"

$ terrain new awesome-dapp --path path/to/dapp --framework vue --authors "ExampleAuthor<[email protected]>"

$ terrain new awesome-dapp --path path/to/dapp --no-frontend
```

_See code: [src/commands/new.ts](https://github.com/terra-money/terrain/blob/v0.8.0/src/commands/new.ts)_
Expand Down
5 changes: 4 additions & 1 deletion src/commands/deploy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Command, flags } from '@oclif/command';
import dedent from 'dedent';
import { LCDClient } from '@terra-money/feather.js';
import { existsSync } from 'fs';
import {
loadConfig, loadConnections, loadGlobalConfig, CONFIG_FILE_NAME as execPath,
} from '../config';
Expand Down Expand Up @@ -105,7 +106,9 @@ export default class Deploy extends Command {
});
}

if (!flags['no-sync']) {
const hasFrontend = existsSync(flags['frontend-refs-path']);

if (!flags['no-sync'] && hasFrontend) {
await this.config.runCommand('sync-refs', [
'--refs-path',
flags['refs-path'],
Expand Down
63 changes: 36 additions & 27 deletions src/commands/new.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export default class New extends Command {
'$ terrain new awesome-dapp --path path/to/dapp',
'$ terrain new awesome-dapp --path path/to/dapp --authors "ExampleAuthor<[email protected]>"',
'$ terrain new awesome-dapp --path path/to/dapp --framework vue --authors "ExampleAuthor<[email protected]>"',
'$ terrain new awesome-dapp --path path/to/dapp --no-frontend',
];

static flags = {
Expand All @@ -37,6 +38,10 @@ export default class New extends Command {
authors: flags.string({
default: 'Terra Money <[email protected]>',
}),
'no-frontend': flags.boolean({
description: 'Setup terrain as a CLI tool only',
default: false,
}),
};

static args = [{ name: 'name', required: true }];
Expand Down Expand Up @@ -92,31 +97,33 @@ export default class New extends Command {
},
});
cli.action.stop();
if (!flags['no-frontend']) {
cli.action.start(' 💻 Frontend');

cli.action.start(' 💻 Frontend');
if (flags.framework === 'react') {
await TemplateScaffolding.from({
remoteUrl:
if (flags.framework === 'react') {
await TemplateScaffolding.from({
remoteUrl:
'https://codeload.github.com/terra-money/terrain-frontend-template/zip/refs/heads/main',
subFolder: 'terrain-frontend-template-main',
localOptions: {
folderUrl: frontendDir,
},
replace: {
entries: templateEntries,
},
});
} else {
await TemplateScaffolding.from({
remoteUrl:
subFolder: 'terrain-frontend-template-main',
localOptions: {
folderUrl: frontendDir,
},
replace: {
entries: templateEntries,
},
});
} else {
await TemplateScaffolding.from({
remoteUrl:
'https://codeload.github.com/terra-money/wallet-provider/zip/refs/heads/main',
subFolder: `wallet-provider-main/templates/${flags.framework}`,
localOptions: {
folderUrl: frontendDir,
},
});
subFolder: `wallet-provider-main/templates/${flags.framework}`,
localOptions: {
folderUrl: frontendDir,
},
});
}
cli.action.stop();
}
cli.action.stop();

// Install app dependencies.
process.chdir(appDir);
Expand All @@ -127,12 +134,14 @@ export default class New extends Command {
cli.action.stop();

// Install frontend dependencies.
process.chdir(frontendDir);
cli.action.start(' 🔧 Installing frontend dependencies');
await execSync('npm i --loglevel error', {
stdio: ['ignore', 'ignore', 'inherit'],
});
cli.action.stop();
if (!flags['no-frontend']) {
process.chdir(frontendDir);
cli.action.start(' 🔧 Installing frontend dependencies');
await execSync('npm i --loglevel error', {
stdio: ['ignore', 'ignore', 'inherit'],
});
cli.action.stop();
}

TerrainCLI.success(
dedent`
Expand Down