Generate a new Strapi application with TypeScript/JavaScript support, database configuration, and template system.
—
Core application generation functionality that creates new Strapi projects with comprehensive configuration options, error handling, and telemetry.
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:
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
});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:
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>;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>;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>;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:
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:
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