Examples

Example 1

import { runCli } from '@setu-ts/cli';
import { createDenoRuntimeServices } from '@setu-ts/runtime';

const runtime = createDenoRuntimeServices();
const code = await runCli(['generate', 'service', 'billing'], {
  fs: runtime.fs!,
  cwd: Deno.cwd(),
  now: () => runtime.now(),
  log: console.log,
  error: console.error,
});

Functions

f
deriveNames(raw: string): DerivedNames

Derive all five naming forms from a raw input string.

f
detectPlugins(
fs: IFileSystem,
dir: string
): Promise<ReadonlySet<string>>

Detects the @setu-ts packages a project depends on.

f
runCli(
argv: readonly string[],
deps: CliDependencies
): Promise<number>

Parses argv, runs the requested command, and returns its exit code.

Interfaces

I
CliDependencies

Everything the CLI reaches the outside world through.

I
DerivedNames

The five naming forms derived from an input string.

  • camel: string

    camelCase: lowercase first letter, no separators (e.g., userProfile).

  • kebab: string

    kebab-case: lowercase with hyphens (e.g., user-profile).

  • pascal: string

    PascalCase: uppercase first letter, no separators (e.g., UserProfile).

  • raw: string

    The raw input as provided by the user.

  • screaming: string

    SCREAMING_SNAKE_CASE: uppercase with underscores (e.g., USER_PROFILE).

I
GeneratedFile

One file a schematic asks the command layer to create.

I
PromptChoice

One selectable answer to a scaffold question.

  • label: string

    One line describing what the choice does, shown above the question.

  • value: string

    The value written into the flag record when chosen.

I
Prompter

Asks the scaffold questions setu new accepts as flags.

I
SchematicOptions

Options handed to every schematic.

Type Aliases

T
AppLoader = ModuleLoader

Loads the project's config module by URL.

T
Schematic = (
names: DerivedNames,
options: SchematicOptions
) => readonly GeneratedFile[]

The contract every schematic satisfies — a pure function from a name to the files to create. Schematics perform no I/O; the command layer writes.

T
TemplateName = (TEMPLATES)[number]

A project template accepted by setu new --template.

Variables

v
PROGRAM_NAME: "setu"

The name of the CLI executable.

Usage

import * as __setu_ts_cli____the__setu__command_line_tool___Provides_project_scaffolding___setu_new___and_plugin_aware_code_generation___setu_generate__schematic___name_____This_barrel_is_the_programmatic_surface__the_executable_entry_point_is__src_main_ts___ from "cli/src/index.ts";