Skip to content

Repository files navigation

DXWorks CLI

The DXWorks CLI (dxw) is a command-line tool for managing DXWorks plugins and tools. It provides a plugin-based architecture that allows extending functionality through installable packages.

Overview

This is an Nx monorepo containing the following packages:

Package Description
@dxworks/cli Main CLI application with plugin and hub commands
@dxworks/common Shared utilities (logging, downloads, git, compression)
@dxworks/voyenv Voyager environment CLI for managing instrument releases

DXW CLI Commands

The dxw CLI provides the following commands:

Plugin Commands

Command Aliases Description
dxw plugin list ls List installed plugins. Use -a to show all available plugins
dxw plugin install <plugins...> i, add Install plugins. Use -a for all, -f to force unknown plugins
dxw plugin update [plugins...] upgrade, up Update plugins. Use -l for latest versions
dxw plugin outdated - List outdated plugins
dxw plugin uninstall <plugins...> remove, rm Uninstall plugins
dxw plugin link [path] ln Link a local project as a plugin

Hub Commands

Command Aliases Description
dxw hub update pull, fetch, get Update dxworks-hub data
dxw hub refresh reset, rs Remove and re-clone dxworks-hub

Running the CLI Locally

# Build the CLI
pnpm build

# Run directly
node packages/cli/dist/index.js --help

# Or link globally for development
cd packages/cli && npm link
dxw --help

How to Add New Commands

To add a new command to the CLI:

  1. Create the command file in packages/cli/src/commands/<group>/<command>.ts
  2. Export a Commander Command instance with name, description, options, and action
  3. Register in the group index file (e.g., packages/cli/src/commands/plugin/index.ts)
  4. If creating a new group, register it in packages/cli/src/index.ts

Example Command

// packages/cli/src/commands/plugin/example.ts
import { Command } from 'commander';

export const pluginExample = new Command()
  .name('example')
  .alias('ex') // Optional alias
  .description('An example command')
  .argument('[name]', 'Optional argument') // Use <name> for required
  .option('-f, --flag', 'A boolean flag', false)
  .action(async (name: string | undefined, options: { flag: boolean }) => {
    console.log(`Hello ${name ?? 'world'}!`);
    if (options.flag) {
      console.log('Flag was set');
    }
  });

Then register it in the group index:

// packages/cli/src/commands/plugin/index.ts
import { pluginExample } from './example.js';

export const pluginCommand = new Command()
  .name('plugin')
  .description('handles dxworks cli plugins')
  .addCommand(pluginExample); // Add new command here

Quick Start

# Install dependencies
pnpm install

# Build all packages
pnpm build

# Run tests
pnpm test

# Lint code
pnpm lint

Common pnpm Commands

pnpm install              # Install all dependencies
pnpm build                # Build all packages
pnpm test                 # Run all tests
pnpm test:watch           # Run tests in watch mode
pnpm test:coverage        # Run tests with coverage report
pnpm lint                 # Check for lint errors
pnpm lint:fix             # Auto-fix lint errors
pnpm format               # Format code with Prettier

Package-Specific Commands

pnpm nx build cli         # Build only the CLI package
pnpm nx test common       # Test only the common package
pnpm nx lint voyenv       # Lint only the voyenv package

Adding a New Library/Package

To add a new library to the workspace:

# Create a publishable library
npx nx g @nx/js:lib packages/my-lib --publishable --importPath=@dxworks/my-lib

# Create an internal library (not published)
npx nx g @nx/js:lib packages/my-lib --importPath=@dxworks/my-lib

After generating:

  1. Update the package.json with appropriate dependencies
  2. Configure exports in package.json if needed
  3. Add the package to workspace dependencies where it's used

Nx Workspace

This workspace is built with Nx. Run npx nx graph to visually explore the project structure.

Generate a library

npx nx g @nx/js:lib packages/pkg1 --publishable --importPath=@my-org/pkg1

Run tasks

To build the library use:

npx nx build pkg1

To run any task with Nx use:

npx nx <target> <project-name>

These targets are either inferred automatically or defined in the project.json or package.json files.

More about running tasks in the docs »

Versioning and releasing

To version and release the library use

npx nx release

Pass --dry-run to see what would happen without actually releasing the library.

Learn more about Nx release »

Keep TypeScript project references up to date

Nx automatically updates TypeScript project references in tsconfig.json files to ensure they remain accurate based on your project dependencies (import or require statements). This sync is automatically done when running tasks such as build or typecheck, which require updated references to function correctly.

To manually trigger the process to sync the project graph dependencies information to the TypeScript project references, run the following command:

npx nx sync

You can enforce that the TypeScript project references are always in the correct state when running in CI by adding a step to your CI job configuration that runs the following command:

npx nx sync:check

Learn more about nx sync

Set up CI!

Step 1

To connect to Nx Cloud, run the following command:

npx nx connect

Connecting to Nx Cloud ensures a fast and scalable CI pipeline. It includes features such as:

Step 2

Use the following command to configure a CI workflow for your workspace:

npx nx g ci-workflow

Learn more about Nx on CI

Install Nx Console

Nx Console is an editor extension that enriches your developer experience. It lets you run tasks, generate code, and improves code autocompletion in your IDE. It is available for VSCode and IntelliJ.

Install Nx Console »

Useful links

Learn more:

And join the Nx community:

About

new and improved cli

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages