spyne-cli is a command-line utility designed to streamline the process of generating and managing applications built using the SpyneJS framework. It simplifies the creation of ViewStream, DomElement, Channel, and SpyneTrait classes, making it easier to build scalable and modular single-page applications.
- Create a new SpyneJS application from either of two templates.
- Generate
ViewStream,DomElement,Channel, andSpyneTraitclasses, interactively or from flags. - Register generated channels in your application's
src/index.js. - Run every command non-interactively, with
--jsonoutput for tooling.
To install the spyne-cli, you need to have Node.js and npm installed on your system.
-
Install the package globally:
npm install -g spyne-cli
Node.js 18 or newer.
Run with no arguments for the picker:
npx spyne-cli? What would you like to create?
> App - Create a new SpyneJS application
ViewStream
DomElement
Channel
SpyneTrait
Selecting App prompts for a template and an application name. Selecting any of the four module types prompts for a file name, class name, and output directory, then writes the file into your project.
npx spyne-cli create-app my-appPrompts for a template when one is not supplied. To choose one directly:
npx spyne-cli create-app my-app --template shell| Template | Contents |
|---|---|
shell (default) |
pages, navigation, and UI components |
starter |
app.js and a hello-world view |
Options: -t, --template, --material for Material Design (below),
--no-install to skip dependency installation, --no-git to skip git
initialisation.
The shell template comes in a second design:
Material Design 3, an open-source design system created
by Google. It has the same pages, navigation,
and content as the shell, drawn with Material's colours, type, shapes, motion,
and components. See it at material.spynejs.com.
When you choose shell, the CLI asks:
Use Material Design 3?
Enter keeps the shell's own design. To answer without being asked:
npx spyne-cli create-app my-app --material--material works with a site description (--prompt) too. It is the shell
template in another design, so it is not offered for starter. The template is
an independent implementation, and is not affiliated with or endorsed by Google.
When you describe a site (--prompt), the generator finds matching photographs
on Pexels and includes them as placeholders — the CLI
prints "Photos provided by Pexels" when it does. Those photographs are under the
Pexels License, not your app's license, and
following it is your responsibility if you keep them. The generated app's
GETTING-STARTED.md, NOTICE.md, and image-manifest.json cover the terms and
per-photo credits.
Each module type is also a direct command, usable inside an existing project:
npx spyne-cli create-viewstream my-widget-view
npx spyne-cli create-domelement my-element
npx spyne-cli create-channel channel-cart
npx spyne-cli create-trait my-form-traitOptions: --className, -d, --fileDirectory. create-channel also accepts
--channelName and --replayLastPayload; create-trait accepts
--methodPrefix. Anything not supplied is derived from the file name.
create-channel also registers the channel in your src/index.js.
Every command runs from flags alone and never prompts when stdin is not a TTY,
so invocations are safe in CI. Add --json for machine-readable output:
npx spyne-cli create-app my-app -t starter --jsonExit codes: 0 success, 1 the command ran and failed, 2 usage error.
The command registry is exported as data, so tooling can enumerate every generation target and its arguments:
import { describeCommands } from 'spyne-cli/registry';
describeCommands(); // [{ name, summary, kind, args }, ...]create-app clones from the published SpyneJS templates. To point it somewhere
else — a fork, or a local mirror — set the matching environment variable:
SPYNE_CLI_STARTER_REPO=https://github.com/you/your-starter.git \
npx spyne-cli create-app my-appSPYNE_CLI_STARTER_REPO overrides the starter template;
SPYNE_CLI_SHELL_REPO overrides shell;
SPYNE_CLI_SHELL_MATERIAL_REPO overrides shell with --material.
spyne-cli new <app-name> still works and now runs create-app. It prints a
deprecation notice and will be removed in a future release.
The --spa flag was removed in 0.7.0. Choose a template with
--template starter or --template shell instead.
Contributions are welcome! Please feel free to submit a Pull Request or open an Issue on the GitHub repository.
Copyright (c) Frank Batista.
This project is licensed under the GNU Lesser General Public License v3.0 or later (LGPL-3.0-or-later), the same license family as the SpyneJS framework. See LICENSE.
The license covers the CLI itself. Applications default to MIT and files the CLI generates fall outside of this license.