or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

configuration.mddatabase.mdgeneration.mdindex.mdtemplates.md

generation.mddocs/

0

# Application Generation

1

2

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

3

4

## Capabilities

5

6

### Main Generator Function

7

8

Creates a new Strapi application with the specified configuration options.

9

10

```typescript { .api }

11

/**

12

* Creates a new Strapi application with comprehensive configuration options

13

* @param projectDirectory - Target directory path for the new application

14

* @param options - Configuration options for the application generation

15

* @returns Promise that resolves when generation is complete

16

*/

17

function generateNewApp(

18

projectDirectory: string,

19

options: Partial<NewOptions>

20

): Promise<void>;

21

```

22

23

**Key Features:**

24

- Automatic Sentry error tracking integration

25

- System requirements validation

26

- Package manager detection (npm/yarn)

27

- Cross-platform process handling (Windows SIGINT support)

28

- Comprehensive error handling with usage tracking

29

30

**Usage Examples:**

31

32

```typescript

33

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

34

35

// Quickstart with TypeScript

36

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

37

quickstart: true,

38

typescript: true

39

});

40

41

// Custom database configuration

42

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

43

dbclient: "postgres",

44

dbhost: "localhost",

45

dbport: "5432",

46

dbname: "myapp",

47

dbusername: "postgres",

48

dbpassword: "password",

49

typescript: true,

50

run: false // Don't auto-start after creation

51

});

52

53

// Custom template with npm forced

54

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

55

template: "https://github.com/user/strapi-template",

56

useNpm: true,

57

debug: true

58

});

59

```

60

61

### Generation Orchestrator

62

63

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

64

65

```typescript { .api }

66

/**

67

* Main generation orchestrator that routes based on configuration

68

* @param scope - Complete configuration scope for project generation

69

* @returns Promise that resolves when generation is complete

70

*/

71

function generateNew(scope: Scope): Promise<void>;

72

```

73

74

This function determines the appropriate generation strategy:

75

- Database config provided → CLI database project

76

- Quickstart mode → SQLite quickstart project

77

- Default → Interactive customized project

78

79

### Project Creation Strategies

80

81

#### Quickstart Project Creation

82

83

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

84

85

```typescript { .api }

86

/**

87

* Creates a quickstart project with SQLite database

88

* @param scope - Project configuration scope

89

* @returns Promise that resolves when project is created and optionally running

90

*/

91

function createQuickStartProject(scope: Scope): Promise<void>;

92

```

93

94

#### Customized Project Creation

95

96

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

97

98

```typescript { .api }

99

/**

100

* Creates project with custom database configuration via interactive prompts

101

* @param scope - Project configuration scope

102

* @returns Promise that resolves when project is created

103

*/

104

function createCustomizedProject(scope: Scope): Promise<void>;

105

```

106

107

#### CLI Database Project Creation

108

109

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

110

111

```typescript { .api }

112

/**

113

* Creates project with pre-configured database from CLI arguments

114

* @param scope - Project configuration scope with database info

115

* @returns Promise that resolves when project is created

116

*/

117

function createCLIDatabaseProject(scope: Scope): Promise<void>;

118

```

119

120

### Core Project Creation

121

122

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

123

124

```typescript { .api }

125

/**

126

* Core project creation implementation

127

* @param scope - Project configuration scope

128

* @param configuration - Database and dependency configuration

129

* @returns Promise that resolves when project files are created and dependencies installed

130

*/

131

function createProject(

132

scope: Scope,

133

configuration: Configuration

134

): Promise<void>;

135

```

136

137

This function performs:

138

- File and template copying based on language choice (TypeScript/JavaScript)

139

- Package.json generation with proper dependencies

140

- Database configuration file creation

141

- Environment file setup

142

- TypeScript/JavaScript configuration files

143

- Dependency installation with progress indication

144

- Git repository initialization

145

- Template merging (if specified)

146

147

## Error Handling

148

149

The generation system includes comprehensive error handling:

150

151

```typescript { .api }

152

interface StderrError extends Error {

153

stderr: string;

154

}

155

156

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

157

```

158

159

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

160

- Operating system information

161

- Node.js version

162

- Strapi version

163

- Docker environment detection

164

- Project configuration details

165

166

## Process Management

167

168

The generator includes cross-platform process management:

169

170

```typescript

171

// Windows SIGINT handling

172

if (process.platform === 'win32') {

173

const rl = readline.createInterface({

174

input: process.stdin,

175

output: process.stdout,

176

});

177

rl.on('SIGINT', () => process.emit('SIGINT'));

178

}

179

180

// Universal SIGINT handling

181

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

182

```