or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

configuration.mddatabase.mdgeneration.mdindex.mdtemplates.md

index.mddocs/

0

# Strapi Generate New

1

2

@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.

3

4

## Package Information

5

6

- **Package Name**: @strapi/generate-new

7

- **Package Type**: npm

8

- **Language**: TypeScript

9

- **Installation**: `npm install @strapi/generate-new`

10

11

## Core Imports

12

13

```typescript

14

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

15

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

16

```

17

18

For CommonJS:

19

20

```javascript

21

const { generateNewApp, checkInstallPath } = require("@strapi/generate-new");

22

```

23

24

## Basic Usage

25

26

```typescript

27

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

28

29

// Create a new Strapi application with default options

30

await generateNewApp("./my-strapi-app", {

31

quickstart: true,

32

typescript: true,

33

useNpm: false

34

});

35

36

// Create with custom database configuration

37

await generateNewApp("./my-strapi-app", {

38

dbclient: "postgres",

39

dbhost: "localhost",

40

dbport: "5432",

41

dbname: "myapp",

42

dbusername: "postgres",

43

dbpassword: "password",

44

typescript: true

45

});

46

```

47

48

## Architecture

49

50

@strapi/generate-new is built around several key components:

51

52

- **Generation Engine**: Core `generateNewApp` function that orchestrates the entire project creation process

53

- **Project Creation Strategies**: Multiple creation modes (quickstart, customized, CLI database) based on user preferences

54

- **Template System**: Support for custom templates and starter configurations from npm or URLs

55

- **Database Integration**: Configuration and setup for SQLite, PostgreSQL, and MySQL databases

56

- **Package Manager Detection**: Automatic detection and support for both npm and Yarn workflows

57

- **File Generation**: Template-based file and configuration generation for both TypeScript and JavaScript projects

58

- **Error Tracking**: Integrated Sentry error reporting and usage analytics

59

60

## Capabilities

61

62

### Main Generator Function

63

64

Core application generation functionality that creates new Strapi projects with comprehensive configuration options.

65

66

```typescript { .api }

67

function generateNewApp(

68

projectDirectory: string,

69

options: Partial<NewOptions>

70

): Promise<void>;

71

```

72

73

[Application Generation](./generation.md)

74

75

### Installation Path Validation

76

77

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

78

79

```typescript { .api }

80

function checkInstallPath(rootPath: string): Promise<void>;

81

```

82

83

### Project Creation Types

84

85

Different project creation strategies based on configuration and user preferences.

86

87

```typescript { .api }

88

interface NewOptions {

89

useNpm: boolean;

90

run: boolean;

91

debug: boolean;

92

quickstart: boolean;

93

template: string;

94

starter: string;

95

typescript: boolean;

96

dbforce: boolean;

97

dbssl: string;

98

dbclient: string;

99

dbhost: string;

100

dbport: string;

101

dbname: string;

102

dbusername: string;

103

dbpassword: string;

104

dbfile: string;

105

}

106

```

107

108

[Options and Configuration](./configuration.md)

109

110

### Database Configuration

111

112

Database setup and configuration utilities for multiple database backends.

113

114

```typescript { .api }

115

interface DatabaseInfo {

116

client?: string;

117

connection: {

118

host?: string;

119

port?: string;

120

database?: string;

121

username?: string;

122

password?: string;

123

filename?: string;

124

ssl?: boolean;

125

};

126

useNullAsDefault?: boolean;

127

}

128

129

type ClientName = 'mysql' | 'mysql2' | 'postgres' | 'sqlite' | 'sqlite-legacy';

130

```

131

132

[Database Setup](./database.md)

133

134

### Template and Resource Management

135

136

Template processing and resource file management for project scaffolding.

137

138

```typescript { .api }

139

interface TemplateConfig {

140

package: Record<string, unknown>;

141

}

142

143

interface PackageInfo {

144

name: string;

145

version: string;

146

}

147

```

148

149

[Templates and Resources](./templates.md)

150

151

## Core Types

152

153

```typescript { .api }

154

interface Scope {

155

name?: string;

156

rootPath: string;

157

template?: string;

158

strapiVersion: string;

159

strapiDependencies: Array<string>;

160

installDependencies?: boolean;

161

additionalsDependencies: Record<string, string>;

162

docker: boolean;

163

useYarn: boolean;

164

useTypescript: boolean;

165

runQuickstartApp: boolean;

166

quick?: boolean;

167

uuid?: string;

168

deviceId?: string;

169

dbforce?: boolean;

170

database?: DatabaseInfo;

171

debug?: boolean;

172

tmpPath: string;

173

packageJsonStrapi: Record<string, unknown>;

174

}

175

176

interface Configuration {

177

client: string;

178

connection: DatabaseInfo;

179

dependencies: Record<string, string>;

180

}

181

182

interface StderrError extends Error {

183

stderr: string;

184

}

185

186

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

187

```