Skip to content

CLI v2: OAuth, JSON output, and automation-first overhaul#47

Open
nicped wants to merge 12 commits intomainfrom
v2
Open

CLI v2: OAuth, JSON output, and automation-first overhaul#47
nicped wants to merge 12 commits intomainfrom
v2

Conversation

@nicped
Copy link
Copy Markdown
Member

@nicped nicped commented Apr 13, 2026

Summary

  • OAuth client_credentials authentication — new --oauth login flow, --auth flag to override auth mode, env-var-based client credentials (--clientIdEnv/--clientSecretEnv)
  • Structured JSON output--output json across all commands with consistent response envelope (ok, status, data, errors, meta), replacing the deprecated --json flag
  • File operations--delete, --copy, --move support with --asFile/--asDirectory overrides and interactive confirmation for destructive actions
  • Code qualityoutput.finish() via finally blocks, extracted isFilePath helper, encapsulated meta access in output objects, verbose logging for archive cleanup errors, fixed missing output parameter threading through setupEnv/interactiveEnv/interactiveOAuthLogin
  • Documentation — full v2 documentation article, changelog, updated README

QA test scripts

To run the unit tests:

npm test

For QA to run the test smoke harness against a real solution:

export DW_BASE_URL=https://your-solution.example.com
export DW_CLIENT_ID=your-client-id
export DW_CLIENT_SECRET=your-client-secret
npm run qa:smoke

Full instructions (profile format, CI usage, --mode flag, etc.) are in qa/README.md.
https://github.com/dynamicweb/CLI/blob/7ce694f8464dd53c659f26d1950d6fc947b8aebd/qa/README.md

Test plan

  • Run dw with no args — verify environment status display, including when env is missing
  • Run dw login --oauth — verify interactive OAuth setup stores config correctly
  • Run dw query <name> --output json — verify clean JSON output with no console noise
  • Run dw files --delete <path> — verify confirmation prompt and correct API call
  • Run dw files --copy <src> --output json — verify JSON envelope
  • Run dw files --export <path> -v — verify verbose log shows correct operation context
  • Verify --output json and --interactive conflict on the query command
  • Verify deprecated --json flag on files command emits warning and still works

nicped and others added 5 commits April 13, 2026 16:48
Complete rewrite of the CLI documentation for v2, structured around
the automation-first identity: OAuth client credentials, JSON output,
CI/CD patterns, and the updated config shape.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds OAuth client credentials support, --output json on all API-driven
commands, improved env/auth config shape, file workflow improvements
(-af, -ad, progress reporting), and structured error responses.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Supports deployment scenarios with dynamically named files that
accumulate over time. Adds --delete (with --empty modifier),
--copy, and --move flags backed by the DirectoryDelete,
DirectoryEmpty, FileDelete, AssetCopy, and AssetMove APIs.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a v2/beta overhaul of the DynamicWeb CLI focused on automation-first usage: OAuth client-credentials authentication, consistent --output json envelopes across API-driven commands, expanded file operations (delete/copy/move), and updated documentation/changelog to reflect the new behaviors.

Changes:

  • Add OAuth client-credentials support (--auth oauth, dw login --oauth, env-var based client ID/secret) and surface auth type in the base dw command.
  • Add structured JSON output (--output json, deprecated --json) to env, login, files, query, and command.
  • Expand dw files with destructive/mutating operations (--delete, --empty, --copy, --move) and update docs/README/changelog for v2.

Reviewed changes

Copilot reviewed 4 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
README.md Rewrites README for v2 beta: OAuth, JSON output, files workflows, CI/CD guidance.
package.json Bumps version to 2.0.0-beta.0.
package-lock.json Updates lockfile version metadata to 2.0.0-beta.0.
cliv2-documentation.md Adds full v2 documentation article covering auth, JSON envelopes, command refs.
CHANGELOG.md Adds v2 beta changelog entries for breaking changes/features/improvements.
bin/index.js Adds global OAuth flags and improves base command display (incl. auth type).
bin/commands/env.js Adds --output json support and restructures env command output/error handling.
bin/commands/login.js Adds OAuth login/config flow and JSON envelope support.
bin/commands/query.js Adds --output json, structured output envelope, and improved error propagation.
bin/commands/command.js Adds --output json and structured output envelope.
bin/commands/files.js Adds JSON output, deprecated flag aliases, and new delete/copy/move operations.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread CHANGELOG.md
nicped and others added 7 commits April 13, 2026 22:58
…de, improve error handling

- Login: block interactive prompts in JSON mode; add non-interactive OAuth
  login path; always apply --host override on existing environments
- Files: skip full-export confirmation in JSON mode
- Command: throw error for unimplemented --list instead of returning string
- Login: extract shared OAuth finalization into finalizeOAuthLogin helper
- Install: add JSON output example to README for documentation consistency
- Docs: include install in --output json command lists

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…or testability

- Export parseHostInput, getQueryParams, buildInteractiveQueryParams,
  buildQueryParamsFromArgv, extractQueryPropertyPrompts, getFieldNameFromPropertyPrompt,
  parseCookies, shouldUseOAuth, resolveOAuthConfig, prepareDownloadCommandData,
  isFilePath, wildcardToRegExp, getFilesOperation from their respective modules
- Add setConfigForTests() to config.js and guard getConfig() against null return
- Inject deps (interactiveEnvFn, getPropertiesFn, promptFn) via optional deps param
  in setupEnv and getQueryParams for easier unit testing
- Add test/ suite covering command, env, files, login, query, and utility helpers
- Add qa/ smoke harness (run-smoke.mjs) with fixtures, profile.example.json, and README
  covering saved-env and ephemeral CI flows against a real DynamicWeb solution
- Wire npm run test (node --test) and npm run qa:smoke scripts in package.json
- Bump version to 2.0.0-beta.1
- Ignore qa/artifacts/ and qa/profile.json in .gitignore

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…files; add tests for JSON parsing and formatting functions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants