Skip to content

@duffcloudservices/cli ​

Command-line interface for initializing and managing DCS (Duff Cloud Services) customer sites.

πŸ“¦ Package Info

npm: @duffcloudservices/cli

Installation ​

bash
# Global installation (recommended)
npm install -g @duffcloudservices/cli

# Or with pnpm
pnpm add -g @duffcloudservices/cli

# Or run directly with npx
npx @duffcloudservices/cli init

Quick Start ​

bash
# 1. Authenticate with Google OAuth
dcs login

# 2. Initialize a new customer site
cd /path/to/customer-site
dcs init --site-slug my-site --site-name "My Site"

# 3. Validate configuration
dcs validate

# 4. Generate integration plans
dcs plans

Commands ​

Authentication ​

dcs login ​

Authenticate with DCS Portal using Google OAuth (device flow).

bash
dcs login

The CLI will display a URL and code. Open the URL in your browser, enter the code, and sign in with Google. Tokens are stored securely in your OS keychain.

dcs logout ​

Clear stored credentials.

bash
dcs logout

dcs whoami ​

Display the current authenticated user.

bash
dcs whoami
# Output: Logged in as: user@example.com

Site Management ​

dcs sites list ​

List all sites you have access to manage.

bash
dcs sites list

dcs sites show <slug> ​

Show details for a specific site.

bash
dcs sites show my-site

Site Initialization ​

dcs init ​

Initialize DCS integration in a customer site repository.

bash
dcs init --site-slug <slug> --site-name "<name>" [options]

Options:

OptionAliasDescription
--site-slug <slug>-sURL-safe site identifier (required)
--site-name <name>-nHuman-readable site name (required)
--target <dir>-tTarget directory (default: current)
--framework <type>-fFramework: vue or astro (default: vue)
--dry-runPreview without creating files
--forceOverwrite existing files

Examples:

bash
# Initialize in current directory
dcs init -s kinetic-energy -n "Kinetic Energy Solutions"

# Initialize in a specific directory
dcs init -s my-site -n "My Site" -t ./my-site

# Specify Astro framework
dcs init -s my-site -n "My Site" -f astro

# Preview what would be created
dcs init -s my-site -n "My Site" --dry-run

Validation ​

dcs validate ​

Validate .dcs configuration files.

bash
dcs validate [options]

Options:

OptionAliasDescription
--target <dir>-tDirectory to validate (default: current)
--verbose-vShow detailed output

The validator checks:

  • Required configuration files exist
  • YAML syntax is valid
  • Required fields are present
  • Site slug format is correct
  • Pages configuration is valid

Integration Plans ​

dcs plans ​

Generate AI-assisted integration plans for implementing DCS features.

bash
dcs plans [options]

Options:

OptionDescription
--forceRegenerate existing plans

This creates markdown files in .plans/ that guide you through integrating DCS features step by step.


Generated Files ​

Running dcs init creates the following structure:

.dcs/
β”œβ”€β”€ site.yaml              # Site identity and Azure config
β”œβ”€β”€ pages.yaml             # Page registry for CMS
β”œβ”€β”€ content.yaml           # Text content (managed by Portal)
β”œβ”€β”€ seo.yaml               # SEO configuration (managed by Portal)
└── SECTION-CONVENTIONS.md # Documentation for content sections

.github/
└── copilot-instructions.md  # AI assistant context

.plans/
β”œβ”€β”€ README.md
β”œβ”€β”€ 00-audit-site.md           # Initial audit checklist
β”œβ”€β”€ 01-create-use-text-content.md  # Composable setup
β”œβ”€β”€ 02-integrate-home-page.md  # Home page integration
β”œβ”€β”€ 03-integrate-remaining-pages.md  # Other pages
β”œβ”€β”€ 04-capture-snapshots.md    # Portal snapshot setup
└── 05-verify-deployment.md    # Final verification

Configuration Files ​

.dcs/site.yaml ​

Site identity and Azure configuration:

yaml
site:
  slug: my-site
  name: My Site
  framework: vue

azure:
  staticWebApp:
    name: swa-my-site
    resourceGroup: rg-dcs-sites

.dcs/pages.yaml ​

Page registry for the CMS:

yaml
pages:
  - slug: home
    path: /
    type: static
    title: Home
    deletable: false
    textKeys: []

  - slug: about
    path: /about
    type: static
    title: About
    deletable: true
    textKeys: []

.dcs/content.yaml ​

Text content (managed via Portal):

yaml
version: 1
lastUpdated: null
updatedBy: null

global: {}

pages:
  home: {}
  about: {}

Authentication Flow ​

The CLI uses OAuth 2.0 Device Authorization Grant (RFC 8628):

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   CLI       │────▢│  DCS Portal API  │────▢│  Google OAuth   β”‚
β”‚  (Node.js)  │◀────│  /api/v1/auth/*  │◀────│  Consent Screen β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚
       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  OS Credential Store β”‚  (Encrypted token storage)
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
  1. Run dcs login
  2. CLI displays a URL and code
  3. Open URL in browser, enter code
  4. Sign in with Google
  5. CLI receives and stores tokens securely

Site Access Validation ​

Before creating configuration files, the CLI validates:

  1. You're authenticated
  2. You have access to the specified site (or can create it)
  3. You have editor/admin permissions

This prevents creating configs for sites you don't have access to.


Workflow: New Site Integration ​

Complete workflow for integrating a new customer site:

1. Install CLI ​

bash
npm install -g @duffcloudservices/cli

2. Authenticate ​

bash
dcs login

3. Initialize Site ​

bash
cd /path/to/customer-site
dcs init -s customer-name -n "Customer Name LLC"

4. Install CMS Package ​

bash
pnpm add @duffcloudservices/cms

5. Configure Vite ​

typescript
// vite.config.ts or .vitepress/config.ts
import { dcsContentPlugin, dcsSeoPlugin } from '@duffcloudservices/cms/plugins'

export default defineConfig({
  plugins: [
    dcsContentPlugin(),
    dcsSeoPlugin()
  ]
})

6. Follow Integration Plans ​

Work through the files in .plans/ directory:

bash
# Check progress
ls .plans/

# Open in VS Code
code .plans/

7. Validate Configuration ​

bash
dcs validate

8. Register in Portal ​

The site will be available for management in the DCS Portal once the first deployment completes.


Offline Mode ​

The CLI works offline for these commands:

  • dcs init β€” Creates configuration files locally
  • dcs validate β€” Validates local configuration
  • dcs plans β€” Generates integration plans

Authentication is required for:

  • dcs sites β€” Requires API access
  • Live validation features (future)

Troubleshooting ​

"Command not found: dcs" ​

Ensure the package is installed globally:

bash
npm install -g @duffcloudservices/cli
# Or use npx
npx @duffcloudservices/cli --help

Authentication fails ​

  1. Check your internet connection
  2. Ensure you have a valid Google account
  3. Try dcs logout then dcs login again

Validation errors ​

Run with verbose output for details:

bash
dcs validate -v

Site slug already exists ​

If you're re-initializing a site, use --force:

bash
dcs init -s my-site -n "My Site" --force

Requirements ​

  • Node.js >= 18.0.0
  • DCS Portal account with Google OAuth

Duff Cloud Services Documentation