Skip to content
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

Add app create command #404

Merged
merged 4 commits into from
Dec 8, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 2 additions & 0 deletions cmd/flow/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/spf13/cobra"

"github.com/onflow/flow-cli/internal/accounts"
"github.com/onflow/flow-cli/internal/app"
"github.com/onflow/flow-cli/internal/blocks"
"github.com/onflow/flow-cli/internal/cadence"
"github.com/onflow/flow-cli/internal/collections"
Expand Down Expand Up @@ -63,6 +64,7 @@ func main() {
cmd.AddCommand(collections.Cmd)
cmd.AddCommand(project.Cmd)
cmd.AddCommand(config.Cmd)
cmd.AddCommand(app.Cmd)

command.InitFlags(cmd)

Expand Down
132 changes: 132 additions & 0 deletions docs/project-app.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
---
title: Create Flow app from scaffold
sidebar_title: Create App
description: How to create a Flow app with recommended structure
---

The Flow CLI provides a command to create an app from examples
and templates.

```shell
flow app create
```

## Example Usage

```shell
> flow app create my-app

Enumerating objects: 349, done.
Counting objects: 100% (349/349), done.
Compressing objects: 100% (261/261), done.
Total 349 (delta 55), reused 347 (delta 53), pack-reused 0
? Which do you want to start with? Template
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is here something missing in the question?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The question I mean is if a user wants to start from an (example) app that can be built and run (kitty-items) with changing very few or no code or a template have only necessary files (framework, scaffold). Since I'm not a native English speaker, could you recommend a clear and succinct question, please?

Copy link

@mwufi mwufi Nov 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm.. maybe you can set it up like this? (idk, maybe look at create-react-app for inspiration!)

Project scaffolding
> Start with sample app
  Minimal

? Which API template you want to start with? express
? Which Cadence template you want to start with? default
? Which Web template you want to start with? react

Created /path/to/my-app
Api express
Cadence default
Web react
```

## Arguments
sideninja marked this conversation as resolved.
Show resolved Hide resolved

### Path

- Name: `path`
- Valid Input: Path

A relative path to the app location. Can be a new folder name or existing empty folder.
You can start with a full featured example or a custom template.

If you start with an example, there are some exmples included (may not up-to-date):

- `kitty-items`: An app based on CryptoKitties. ([Repo](https://github.com/onflow/kitty-items))

If you start with a template, there will be 3 folder `api`, `cadence`, and `web`.

- `api`: Backend service will be put in here, you can provide functions which cannot be
implemented in client side, such as draw, whitelist registration, KYC, or some works can be
offloaded from client side, such as DEX price, NFT lists. Following are some templates
included (may not up-to-date):
_ `default`: Leave it blank for you.
_ `express`: A popular web framework for node. Check out [Express.js](https://expressjs.com/)
for details.
- `cadence`: Contracts will be put in here. Following are some templates included (may not
up-to-date):
- `default`: Leave it blank for you.
- `web`: Frontend app will be put in here, users will use the app to interact with your Cadence
contracts. Check out [fcl.js](https://github.com/onflow/fcl-js) to get more details. Following
are some templates included (may not up-to-date):
_ `default`: Leave it blank for you.
_ `react`: A popular frontend framework supported by Facebook. Check out
[React.js](https://reactjs.org/) for details.
_ `react-ts`: `react` and added TypeScript inside.
_ `vue`: A popular frontend framework. Check out [Vue.js](https://vuejs.org/) for details.

## Flags

### Host

- Flag: `--host`
- Valid inputs: an IP address or hostname.
- Default: `127.0.0.1:3569` (Flow Emulator)

Specify the hostname of the Access API that will be
used to execute the command. This flag overrides
any host defined by the `--network` flag.

### Network

- Flag: `--network`
- Short Flag: `-n`
- Valid inputs: the name of a network defined in the configuration (`flow.json`).
- Default: `emulator`

Specify which network you want the command to use for execution.
sideninja marked this conversation as resolved.
Show resolved Hide resolved

### Filter

- Flag: `--filter`
- Short Flag: `-x`
- Valid inputs: a case-sensitive name of the result property.

Specify any property name from the result you want to return as the only value.

### Output

- Flag: `--output`
- Short Flag: `-o`
- Valid inputs: `json`, `inline`

Specify the format of the command results.

### Save

- Flag: `--save`
- Short Flag: `-s`
- Valid inputs: a path in the current filesystem.

Specify the filename where you want the result to be saved

### Log

- Flag: `--log`
- Short Flag: `-l`
- Valid inputs: `none`, `error`, `debug`
- Default: `info`

Specify the log level. Control how much output you want to see during command execution.

### Configuration

- Flag: `--config-path`
- Short Flag: `-f`
- Valid inputs: a path in the current filesystem.
- Default: `flow.json`

Specify the path to the `flow.json` configuration file.
You can use the `-f` flag multiple times to merge
several configuration files.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.13

require (
github.com/a8m/envsubst v1.2.0
github.com/go-git/go-git/v5 v5.4.2
github.com/gosuri/uilive v0.0.4
github.com/joho/godotenv v1.3.0
github.com/manifoldco/promptui v0.8.0
Expand All @@ -18,7 +19,6 @@ require (
github.com/spf13/cobra v1.1.3
github.com/stretchr/testify v1.7.0
github.com/thoas/go-funk v0.7.0
golang.org/x/tools v0.1.4 // indirect
gonum.org/v1/gonum v0.6.1
google.golang.org/grpc v1.37.0
)
Loading