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

configuration.mddocs/

Options and Configuration

Comprehensive configuration options and validation utilities for customizing Strapi application generation.

Capabilities

New Options Interface

Complete configuration interface for application generation options.

/**
 * Configuration options for creating a new Strapi application
 */
interface NewOptions {
  /** Force use of npm instead of yarn even if yarn is available */
  useNpm: boolean;
  /** Whether to run the application after creation (default: true) */
  run: boolean;
  /** Enable debug mode with additional logging */
  debug: boolean;
  /** Use quickstart mode with SQLite (skip database prompts) */
  quickstart: boolean;
  /** Template URL or npm package name for custom project template */
  template: string;
  /** Starter configuration name */
  starter: string;
  /** Generate TypeScript project instead of JavaScript */
  typescript: boolean;
  /** Force database configuration without connection testing */
  dbforce: boolean;
  /** Database SSL configuration */
  dbssl: string;
  /** Database client type (mysql, postgres, sqlite) */
  dbclient: string;
  /** Database host address */
  dbhost: string;
  /** Database port number */
  dbport: string;
  /** Database name */
  dbname: string;
  /** Database username */
  dbusername: string;
  /** Database password */
  dbpassword: string;
  /** SQLite database file path */
  dbfile: string;
}

Scope Configuration

Internal configuration object that contains all generation parameters and derived settings.

/**
 * Complete configuration scope for project generation
 */
interface Scope {
  /** Project name (derived from directory name) */
  name?: string;
  /** Absolute path to project root directory */
  rootPath: string;
  /** Template URL or package name */
  template?: string;
  /** Strapi version to install */
  strapiVersion: string;
  /** Core Strapi dependencies to install */
  strapiDependencies: Array<string>;
  /** Whether to install dependencies automatically */
  installDependencies?: boolean;
  /** Additional dependencies (React, etc.) */
  additionalsDependencies: Record<string, string>;
  /** Whether running in Docker environment */
  docker: boolean;
  /** Whether to use Yarn package manager */
  useYarn: boolean;
  /** Whether to generate TypeScript project */
  useTypescript: boolean;
  /** Whether to run app after quickstart creation */
  runQuickstartApp: boolean;
  /** Whether in quickstart mode */
  quick?: boolean;
  /** Unique project identifier */
  uuid?: string;
  /** Machine identifier for telemetry */
  deviceId?: string;
  /** Force database configuration */
  dbforce?: boolean;
  /** Database configuration */
  database?: DatabaseInfo;
  /** Debug mode enabled */
  debug?: boolean;
  /** Temporary directory path */
  tmpPath: string;
  /** Package.json Strapi-specific configuration */
  packageJsonStrapi: Record<string, unknown>;
}

Installation Path Validation

Validates that the target directory is suitable for creating a new Strapi application.

/**
 * Validates that target directory exists and is empty
 * @param rootPath - Absolute path to target directory
 * @throws Error if path is not a directory or not empty
 */
function checkInstallPath(rootPath: string): Promise<void>;

Validation Rules:

  • Path must exist or be creatable
  • If path exists, it must be a directory
  • Directory must be empty (max 1 file allowed)
  • Provides clear error messages for validation failures

Usage Examples:

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

// Validate before generation
try {
  await checkInstallPath("./my-new-app");
  console.log("Path is valid for Strapi app creation");
} catch (error) {
  console.error("Invalid path:", error.message);
}

System Requirements Validation

Internal system requirements checking functionality.

/**
 * Validates system requirements for Strapi generation
 * Checks Node.js version and other system prerequisites
 */
function checkRequirements(): void;

Package Manager Detection

Automatic detection of available package managers.

/**
 * Detects if Yarn is available on the system
 * @returns true if yarn command is available
 */
function hasYarn(): boolean;

Database Argument Parsing

Parses and validates database configuration from command-line arguments.

/**
 * Parses database arguments from options and populates scope
 * @param params - Object containing scope and command-line args
 */
function parseDatabaseArguments(params: {
  scope: Scope;
  args: Partial<NewOptions>;
}): void;

Default Configuration Values

The generator includes sensible defaults:

// Default Strapi dependencies
const defaultStrapiDependencies = [
  '@strapi/strapi',
  '@strapi/plugin-users-permissions',
  '@strapi/plugin-i18n',
  '@strapi/plugin-cloud'
];

// Default additional dependencies
const defaultAdditionalDependencies = {
  'react': '^18.0.0',
  'react-dom': '^18.0.0',
  'react-router-dom': '5.3.4',
  'styled-components': '5.3.3'
};

// Default database configuration (SQLite)
const defaultDatabase = {
  client: 'sqlite',
  connection: {
    filename: '.tmp/data.db'
  },
  useNullAsDefault: true
};

Environment Detection

The generator automatically detects and configures for various environments:

// Docker detection
const isDocker = process.env.DOCKER === 'true';

// Package manager preference
const useYarn = !options.useNpm && hasYarn();

// UUID prefix support
const uuid = (process.env.STRAPI_UUID_PREFIX || '') + crypto.randomUUID();

Error Handling Configuration

Configuration includes comprehensive error tracking setup:

// Sentry configuration for error tracking
sentry.init({
  dsn: 'https://841d2b2c9b4d4b43a4cde92794cb705a@sentry.io/1762059'
});

// Telemetry tags
const telemetryTags = {
  os: os.type(),
  osPlatform: os.platform(),
  osArch: os.arch(),
  osRelease: os.release(),
  version: scope.strapiVersion,
  nodeVersion: process.versions.node,
  docker: scope.docker
};

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