Generate a new Strapi application with TypeScript/JavaScript support, database configuration, and template system.
npx @tessl/cli install tessl/npm-strapi--generate-new@4.25.0@strapi/generate-new is a powerful generator tool for creating new Strapi applications with comprehensive template support, database configuration, and development tooling setup. It provides both interactive and command-line interfaces for scaffolding Strapi CMS projects with TypeScript or JavaScript, various database backends, and custom templates.
npm install @strapi/generate-newimport { generateNewApp, checkInstallPath } from "@strapi/generate-new";
import type { NewOptions } from "@strapi/generate-new";For CommonJS:
const { generateNewApp, checkInstallPath } = require("@strapi/generate-new");import { generateNewApp } from "@strapi/generate-new";
// Create a new Strapi application with default options
await generateNewApp("./my-strapi-app", {
quickstart: true,
typescript: true,
useNpm: false
});
// Create with custom database configuration
await generateNewApp("./my-strapi-app", {
dbclient: "postgres",
dbhost: "localhost",
dbport: "5432",
dbname: "myapp",
dbusername: "postgres",
dbpassword: "password",
typescript: true
});@strapi/generate-new is built around several key components:
generateNewApp function that orchestrates the entire project creation processCore application generation functionality that creates new Strapi projects with comprehensive configuration options.
function generateNewApp(
projectDirectory: string,
options: Partial<NewOptions>
): Promise<void>;Utility for validating that the target directory is suitable for creating a new Strapi application.
function checkInstallPath(rootPath: string): Promise<void>;Different project creation strategies based on configuration and user preferences.
interface NewOptions {
useNpm: boolean;
run: boolean;
debug: boolean;
quickstart: boolean;
template: string;
starter: string;
typescript: boolean;
dbforce: boolean;
dbssl: string;
dbclient: string;
dbhost: string;
dbport: string;
dbname: string;
dbusername: string;
dbpassword: string;
dbfile: string;
}Database setup and configuration utilities for multiple database backends.
interface DatabaseInfo {
client?: string;
connection: {
host?: string;
port?: string;
database?: string;
username?: string;
password?: string;
filename?: string;
ssl?: boolean;
};
useNullAsDefault?: boolean;
}
type ClientName = 'mysql' | 'mysql2' | 'postgres' | 'sqlite' | 'sqlite-legacy';Template processing and resource file management for project scaffolding.
interface TemplateConfig {
package: Record<string, unknown>;
}
interface PackageInfo {
name: string;
version: string;
}interface Scope {
name?: string;
rootPath: string;
template?: string;
strapiVersion: string;
strapiDependencies: Array<string>;
installDependencies?: boolean;
additionalsDependencies: Record<string, string>;
docker: boolean;
useYarn: boolean;
useTypescript: boolean;
runQuickstartApp: boolean;
quick?: boolean;
uuid?: string;
deviceId?: string;
dbforce?: boolean;
database?: DatabaseInfo;
debug?: boolean;
tmpPath: string;
packageJsonStrapi: Record<string, unknown>;
}
interface Configuration {
client: string;
connection: DatabaseInfo;
dependencies: Record<string, string>;
}
interface StderrError extends Error {
stderr: string;
}
function isStderrError(error: unknown): error is StderrError;