Skip to content

Auto generating npm commands and docs#302

Open
nmetulev wants to merge 10 commits intomainfrom
nmetulev/npm-func
Open

Auto generating npm commands and docs#302
nmetulev wants to merge 10 commits intomainfrom
nmetulev/npm-func

Conversation

@nmetulev
Copy link
Member

@nmetulev nmetulev commented Feb 20, 2026

Description

This PR exposes all winapp CLI commands as typed JS/TS functions in the npm package. It adds a script to autogenerate those exports from the cli-schema so they are always up to date. It also adds a script to auto generate the npm documentation.

Usage Example

import { init, packageApp, certGenerate } from '@microsoft/winappcli';

// Initialize a new project with defaults
await init({ useDefaults: true });

// Generate a dev certificate
await certGenerate({ install: true });

// Package the built app
await packageApp({ inputFolder: './dist', cert: './devcert.pfx' });

Related Issue

Type of Change

  • ✨ New feature
  • 📝 Documentation
  • 🔧 Config/build

Checklist

  • Tested locally on Windows
  • Main README.md updated (if applicable)
  • docs/usage.md updated (if CLI commands changed)

AI Description

This PR exposes all winapp CLI commands as typed JavaScript/TypeScript functions in the npm package, ensuring they are always up to date through auto-generated exports from the cli-schema. It also updates the documentation to reflect this new programmatic API for usage in JavaScript/TypeScript projects. Usage examples for initializing a project and packaging an app are provided in the documentation.

import { init, packageApp, certGenerate } from '@microsoft/winappcli';

// Initialize a new project with defaults
await init({ useDefaults: true });

// Generate a dev certificate
await certGenerate({ install: true });

// Package the built app
await packageApp({ inputFolder: './dist', cert: './devcert.pfx' });

@github-actions
Copy link

github-actions bot commented Feb 20, 2026

Build Metrics Report

Binary Sizes

Artifact Baseline Current Delta
CLI (ARM64) 13.65 MB 13.65 MB 📈 +1.0 KB (+0.01%)
CLI (x64) 12.95 MB 12.95 MB 📈 +1.0 KB (+0.01%)
MSIX (ARM64) 5.94 MB 5.94 MB 📈 +0.3 KB (+0.00%)
MSIX (x64) 6.17 MB 6.17 MB 📈 +0.2 KB (+0.00%)
NPM Package 12.09 MB 12.10 MB 📈 +7.9 KB (+0.06%)

Test Results

250 passed, 6 skipped out of 256 tests in 76.2s (+16.8s vs. baseline)

CLI Startup Time

36ms median (x64, winapp --version) · ✅ no change vs. baseline

Copy link
Contributor

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 auto-generation of npm commands and TypeScript documentation for the winapp CLI. It exposes all CLI commands as typed async functions in the npm package, ensuring they stay synchronized with the native CLI through automated code generation from the CLI schema.

Changes:

  • Adds callWinappCliCapture function to capture stdout/stderr programmatically instead of inheriting stdio
  • Generates TypeScript wrappers for all CLI commands with full type safety
  • Auto-generates comprehensive API documentation from TypeScript source using the TS Compiler API
  • Integrates code generation into build pipeline to ensure commands are always up-to-date

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/winapp-npm/src/winapp-commands.ts Auto-generated TypeScript wrappers for all CLI commands with typed options interfaces
src/winapp-npm/src/winapp-cli-utils.ts Adds callWinappCliCapture for programmatic CLI execution with output capture
src/winapp-npm/src/index.ts Exports new command functions and types for public API
src/winapp-npm/scripts/generate-commands.mjs Code generator that creates TypeScript wrappers from CLI schema
src/winapp-npm/scripts/generate-docs.mjs Documentation generator using TypeScript Compiler API
src/winapp-npm/package.json Adds npm scripts for code/docs generation and integrates into build pipeline
src/winapp-npm/README.md Documents new programmatic API with usage examples
src/winapp-npm/.prettierignore Excludes auto-generated files from formatting checks
scripts/build-cli.ps1 Integrates npm docs generation into build pipeline
docs/npm-usage.md Auto-generated comprehensive API documentation
docs/fragments/node-commands.md Documents Node.js-specific CLI commands
README.md Links to new npm programmatic API documentation

Copy link
Collaborator

@azchohfi azchohfi left a comment

Choose a reason for hiding this comment

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

Awesome to see this automated!

@nmetulev nmetulev requested a review from azchohfi February 20, 2026 22:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants