Skip to content

Command line interface Pre-release

@elenajs/cli is an interactive command line tool for scaffolding Elena components. It generates JavaScript, TypeScript, or single-file HTML source files and scoped CSS with all Elena Progressive Web Component patterns pre-configured.

Elena command line interface

Install

sh
npm install --save-dev @elenajs/cli
sh
yarn add --dev @elenajs/cli
sh
pnpm add --save-dev @elenajs/cli
sh
bun add --dev @elenajs/cli

Usage

Interactive mode

Run without arguments to be guided through all options:

bash
npx elena-create

With a component name

Pass a kebab-case name (must contain at least one hyphen) to skip the name prompt:

bash
npx elena-create my-button
npx elena-create my-stack

Prompts

The CLI walks you through the following steps:

PromptDescriptionDefault
Component nameKebab-case name with at least one hyphen (e.g. my-button, my-stack). Skipped if passed as argument.
Component featuresFeature toggles for the generated code. See Component features below.None selected
LanguageJavaScript, TypeScript, or HTML.
Output directoryWhere to generate the component folder.src/components

Component features

You can toggle features to include in the generated code:

OptionDescription
PropsAdds example props with @property / @type JSDoc annotations.
EventsAdds events option and @event JSDoc annotations.
MethodsAdds an example method stub.
CSS VariablesAdds @cssprop JSDoc annotations and CSS custom property declarations.
CSS EncapsulationAdds the all: unset reset to prevent global styles from leaking in.
CSS Pre-hydrationAdds :scope:not([hydrated]) styles for pre-hydration rendering.
Code CommentsIncludes JSDoc annotations and CSS comments in the generated code.

Generated files

For a component named my-button, the CLI creates:

src/components/my-button/
├── my-button.js (or .ts)
└── my-button.css

When using the HTML language, a single file is generated instead:

src/components/my-button/
└── my-button.html