CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-js-lib--cli

CLI tool for scaffolding JavaScript and TypeScript third-party libraries with modern development practices

Pending
Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

interactive-configuration.mddocs/

Interactive Configuration

Comprehensive prompt-based configuration system for collecting project metadata and user preferences during project creation via CLI commands.

Capabilities

Interactive Prompts System

The CLI automatically triggers interactive prompts to collect missing project configuration when creating new projects.

# When running: jslib new [projectname]
# The CLI prompts for any missing information:

# Project Name Prompt
project name: [default: projectname]

# NPM Package Name Prompt (with validation)
npm package name: [default: projectname]

# UMD Name Prompt
UMD name for package: [default: projectname]

# GitHub Username Prompt  
github user name: [required]

# Template Type Selection
select template:
❯ JavaScript
  TypeScript

# Package Manager Selection
package manager:
❯ npm
  no install

Prompt Details

The CLI presents interactive prompts with the following behavior:

Project Name Prompt

  • Message: "project name:"
  • Default: Uses the provided project directory name
  • Validation: Requires non-empty input

NPM Package Name Prompt

  • Message: "npm package name:"
  • Default: Uses the project directory name
  • Validation: Validates against NPM naming conventions using validate-npm-package-name
  • Supports: Scoped packages (e.g., @company/package-name)

UMD Name Prompt

  • Message: "UMD name for package:"
  • Default: Uses the project directory name
  • Validation: Requires non-empty input
  • Purpose: Global variable name for UMD builds

GitHub Username Prompt

  • Message: "github user name:"
  • Default: None (required input)
  • Validation: Requires non-empty input
  • Purpose: Used in generated README and package.json

Template Type Selection

  • Message: "select template:"
  • Choices: JavaScript, TypeScript
  • Default: None (user must select)
  • Result: Determines which project template to use

Package Manager Selection

  • Message: "package manager:"
  • Choices: npm, no install
  • Default: None (user must select)
  • Result: Whether to run npm install after project creation

Smart Prompting Logic

The prompt system is intelligent about what questions to ask:

  • Skip Provided Options: Only prompts for values not provided via command line
  • Conditional Prompts: Certain prompts depend on previous answers
  • Default Values: Sensible defaults based on project name or previous inputs
  • Validation: Real-time validation with helpful error messages

Validation Rules

Each prompt includes specific validation:

NPM Name Validation

  • Uses validate-npm-package-name library
  • Checks for valid NPM package naming conventions
  • Prevents reserved names and invalid characters
  • Allows scoped packages (e.g., @company/package)

General Name Validation

  • Requires non-empty strings
  • Trims whitespace automatically
  • Validates against common naming patterns

Template Type Validation

  • Restricts to supported template types
  • Maps user-friendly names to internal codes
  • Provides clear selection options

Usage Examples

# Full interactive mode (all prompts)
npx @js-lib/cli new

# Partial interactive mode (skip username prompt)
npx @js-lib/cli new my-lib --username johndoe

# Minimal interactive mode (only template type prompt)
npx @js-lib/cli new my-lib --npmname @company/my-lib --username johndoe --umdname MyLib

Integration with Inquirer

The system is built on the Inquirer.js library, providing:

  • Rich UI: Colored prompts with clear formatting
  • Input Validation: Real-time validation with error messages
  • Default Values: Smart defaults to speed up configuration
  • List Selection: Easy-to-use selection lists for choices
  • Cross-platform: Works consistently across operating systems

Error Handling

The prompt system handles various error conditions:

  • User Interruption: Graceful handling of Ctrl+C
  • Invalid Input: Clear error messages with retry options
  • Network Issues: Fallback behavior for validation that requires network access
  • Terminal Compatibility: Adapts to different terminal capabilities

docs

file-utilities.md

index.md

interactive-configuration.md

project-creation.md

project-updates.md

template-system.md

tile.json