Skip to content
This repository has been archived by the owner on Aug 14, 2024. It is now read-only.
Arthur Bleil edited this page Mar 10, 2022 · 26 revisions

Beagle Backend TypeScript CLI

This is the CLI for Beagle Backend TypeScript, where you can quickly create a new project and generate screens.

Getting Started

In this section you will learn how to quickly set up a project and start using the Beagle Backend TypeScript!

Setting Up a Project

Install the Beagle Backend TypeScript CLI globally:

npm install -g @zup-it/beagle-backend-typescript-cli

Create a new project:

beagle-ts new [PROJECT NAME]

Run the application:

cd [PROJECT NAME]
npm run start

Generating a Basic Screen

Go to the project root and run:

beagle-ts generate-screen [SCREEN NAME]

The new screen will be generated inside the folder: src/screens, or inside the folder defined on the attribute screensFolderPath in the configuration file ./beagle-ts.json.

The generated screen code will be:

/** ./src/screens/screen-name.tsx */

import { BeagleJSX } from '@zup-it/beagle-backend-core'
import { Text } from '@zup-it/beagle-backend-components'

export const ScreenNameScreen = () => (
  <>
    <Text>This the ScreenNameScreen screen component!</Text>
  </>
)

Routing

Also, when you generate a screen, your new screen is added to the app RouteMap, like this:

/** ./src/screens/index.tsx */

import { RouteMap } from '@zup-it/beagle-backend-express'
import { Home } from './home'
import { Welcome } from './welcome'
import { ScreenName } from './screen-name'

export const routes: RouteMap = {
  '': Welcome,
  '/home': Home,
  '/screen-name': ScreenName,
}

CLI Commands and Options

In this section you will find all the options that the CLI has to offer.

Command: beagle-ts new [PROJECT NAME]

Creates a new Beagle Backend TypeScript project with a boilerplate structure.

Arguments:

Argument Description
Name of the project. eg. "name-of-my-project" (will be the name of the folder).

Options:

Option Alias Description Default Value
--base-path -bp Base path that will be the root of the API. ''
--port -p Port where the service will run. 3000

Command: beagle-ts generate-screen [SCREEN NAME] or beagle-ts gs [SCREEN NAME]

Creates a new Beagle Backend TypeScript project with a boilerplate structure.

Arguments:

Argument Description
Name of the screen that will be generated. eg. "name-of-my-screen".

Options (all options are boolean):

Option Alias Description Default Value
--with-route-params -wrp The screen will have parameters on the url. false
--with-headers -wh The screen will have headers to be sent in the request. false
--with-body -wb The screen will have a request body. Invalid for "GET" requests. false
--with-query -wq The screen will have properties in the urls query. false
--with-navigation-context -wnc The screen will have properties to be set in the navigation context. false
--with-context -wctx A Context that will be made available for this Screen and its children. false
--with-children -wc The children of this Screen. false
--with-accessibility -wac The Screen will support accessibility properties. false
--with-analytics -way The Screen will support analytics. false
--with-style -ws The style for this Screen. Use it to customize the background, layout, borders, etc. false
Clone this wiki locally