CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-strapi--generate-new

Generate a new Strapi application with TypeScript/JavaScript support, database configuration, and template system.

Pending
Overview
Eval results
Files

generation.mddocs/

Application Generation

Core application generation functionality that creates new Strapi projects with comprehensive configuration options, error handling, and telemetry.

Capabilities

Main Generator Function

Creates a new Strapi application with the specified configuration options.

/**
 * Creates a new Strapi application with comprehensive configuration options
 * @param projectDirectory - Target directory path for the new application
 * @param options - Configuration options for the application generation
 * @returns Promise that resolves when generation is complete
 */
function generateNewApp(
  projectDirectory: string,
  options: Partial<NewOptions>
): Promise<void>;

Key Features:

  • Automatic Sentry error tracking integration
  • System requirements validation
  • Package manager detection (npm/yarn)
  • Cross-platform process handling (Windows SIGINT support)
  • Comprehensive error handling with usage tracking

Usage Examples:

import { generateNewApp } from "@strapi/generate-new";

// Quickstart with TypeScript
await generateNewApp("./my-app", {
  quickstart: true,
  typescript: true
});

// Custom database configuration
await generateNewApp("./my-app", {
  dbclient: "postgres",
  dbhost: "localhost",
  dbport: "5432",
  dbname: "myapp",
  dbusername: "postgres",
  dbpassword: "password",
  typescript: true,
  run: false // Don't auto-start after creation
});

// Custom template with npm forced
await generateNewApp("./my-app", {
  template: "https://github.com/user/strapi-template",
  useNpm: true,
  debug: true
});

Generation Orchestrator

Internal orchestrator that routes to appropriate project creation methods based on configuration.

/**
 * Main generation orchestrator that routes based on configuration
 * @param scope - Complete configuration scope for project generation
 * @returns Promise that resolves when generation is complete
 */
function generateNew(scope: Scope): Promise<void>;

This function determines the appropriate generation strategy:

  • Database config provided → CLI database project
  • Quickstart mode → SQLite quickstart project
  • Default → Interactive customized project

Project Creation Strategies

Quickstart Project Creation

Creates a project with default SQLite configuration and optionally runs the application.

/**
 * Creates a quickstart project with SQLite database
 * @param scope - Project configuration scope
 * @returns Promise that resolves when project is created and optionally running
 */
function createQuickStartProject(scope: Scope): Promise<void>;

Customized Project Creation

Creates a project with interactive prompts for language and database configuration.

/**
 * Creates project with custom database configuration via interactive prompts
 * @param scope - Project configuration scope
 * @returns Promise that resolves when project is created
 */
function createCustomizedProject(scope: Scope): Promise<void>;

CLI Database Project Creation

Creates a project when database configuration is provided via command-line arguments.

/**
 * Creates project with pre-configured database from CLI arguments
 * @param scope - Project configuration scope with database info
 * @returns Promise that resolves when project is created
 */
function createCLIDatabaseProject(scope: Scope): Promise<void>;

Core Project Creation

Low-level project creation implementation that handles file operations, dependency installation, and configuration.

/**
 * Core project creation implementation
 * @param scope - Project configuration scope
 * @param configuration - Database and dependency configuration
 * @returns Promise that resolves when project files are created and dependencies installed
 */
function createProject(
  scope: Scope,
  configuration: Configuration
): Promise<void>;

This function performs:

  • File and template copying based on language choice (TypeScript/JavaScript)
  • Package.json generation with proper dependencies
  • Database configuration file creation
  • Environment file setup
  • TypeScript/JavaScript configuration files
  • Dependency installation with progress indication
  • Git repository initialization
  • Template merging (if specified)

Error Handling

The generation system includes comprehensive error handling:

interface StderrError extends Error {
  stderr: string;
}

function isStderrError(error: unknown): error is StderrError;

All errors are automatically tracked via Sentry with detailed context including:

  • Operating system information
  • Node.js version
  • Strapi version
  • Docker environment detection
  • Project configuration details

Process Management

The generator includes cross-platform process management:

// Windows SIGINT handling
if (process.platform === 'win32') {
  const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
  });
  rl.on('SIGINT', () => process.emit('SIGINT'));
}

// Universal SIGINT handling
process.on('SIGINT', () => process.exit(1));

Install with Tessl CLI

npx tessl i tessl/npm-strapi--generate-new

docs

configuration.md

database.md

generation.md

index.md

templates.md

tile.json