generator-razor 13.4.13 → 14.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/index.js +919 -516
- package/package.json +15 -16
package/app/index.js
CHANGED
|
@@ -1,607 +1,1010 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
)
|
|
26
|
-
|
|
27
|
-
this.
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}, {
|
|
105
|
-
name: 'sendmail',
|
|
106
|
-
value: 'sendmail'
|
|
107
|
-
}],
|
|
108
|
-
store: true
|
|
109
|
-
}, {
|
|
110
|
-
when: answers => answers.Transport === 'smtp',
|
|
111
|
-
type: 'input',
|
|
112
|
-
name: 'SmtpServer',
|
|
113
|
-
message: 'SMTP server?',
|
|
114
|
-
default: 'localhost:25',
|
|
115
|
-
store: true
|
|
116
|
-
}, {
|
|
117
|
-
when: answers => answers.Transport === 'smtp',
|
|
118
|
-
type: 'list',
|
|
119
|
-
name: 'Encrypt',
|
|
120
|
-
message: 'SMTP encrypt?',
|
|
121
|
-
default: true,
|
|
122
|
-
choices: [{
|
|
123
|
-
name: 'true (TYPO3 >= 10 - if port 465 or other)',
|
|
124
|
-
value: true
|
|
125
|
-
}, {
|
|
126
|
-
name: 'false (TYPO3 >= 10 - if port 587)',
|
|
127
|
-
value: false
|
|
128
|
-
}, {
|
|
129
|
-
name: 'ssl (TYPO3 9.5.x)',
|
|
130
|
-
value: 'ssl'
|
|
131
|
-
}, {
|
|
132
|
-
name: 'tls (TYPO3 9.5.x)',
|
|
133
|
-
value: 'tls'
|
|
134
|
-
}],
|
|
135
|
-
store: true
|
|
136
|
-
}, {
|
|
137
|
-
when: answers => answers.Transport === 'smtp',
|
|
138
|
-
type: 'input',
|
|
139
|
-
name: 'SmtpUser',
|
|
140
|
-
message: 'SMTP username?',
|
|
141
|
-
default: '',
|
|
142
|
-
store: true
|
|
143
|
-
}, {
|
|
144
|
-
when: answers => answers.Transport === 'smtp',
|
|
145
|
-
type: 'input',
|
|
146
|
-
name: 'SmtpPass',
|
|
147
|
-
message: 'SMTP password?',
|
|
148
|
-
default: '',
|
|
149
|
-
store: true
|
|
1
|
+
import Generator from 'yeoman-generator'
|
|
2
|
+
import chalk from 'chalk'
|
|
3
|
+
import mysql from 'mysql2/promise'
|
|
4
|
+
import fs from 'fs-extra'
|
|
5
|
+
import argon2 from 'argon2'
|
|
6
|
+
import * as tar from 'tar'
|
|
7
|
+
|
|
8
|
+
import crypto from 'node:crypto'
|
|
9
|
+
import path from 'node:path'
|
|
10
|
+
import os from 'node:os'
|
|
11
|
+
import process from 'node:process'
|
|
12
|
+
import { spawn } from 'node:child_process'
|
|
13
|
+
import { Readable } from 'node:stream'
|
|
14
|
+
import { pipeline } from 'node:stream/promises'
|
|
15
|
+
|
|
16
|
+
export default class extends Generator {
|
|
17
|
+
constructor (args, options) {
|
|
18
|
+
super(args, options)
|
|
19
|
+
|
|
20
|
+
this.props = {}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async prompting () {
|
|
24
|
+
const orange = chalk.hex('#ff8700').bold
|
|
25
|
+
const petrol = chalk.hex('#006792')
|
|
26
|
+
|
|
27
|
+
this.log(orange(`
|
|
28
|
+
██████╗ █████╗ ███████╗ ██████╗ ██████╗
|
|
29
|
+
██╔══██╗██╔══██╗╚══███╔╝██╔═══██╗██╔══██╗
|
|
30
|
+
██████╔╝███████║ ███╔╝ ██║ ██║██████╔╝
|
|
31
|
+
██╔══██╗██╔══██║ ███╔╝ ██║ ██║██╔══██╗
|
|
32
|
+
██║ ██║██║ ██║███████╗╚██████╔╝██║ ██║
|
|
33
|
+
╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝ ╚═════╝ ╚═╝ ╚═╝
|
|
34
|
+
`))
|
|
35
|
+
|
|
36
|
+
this.log(petrol(`
|
|
37
|
+
________ ______ ____ _____ __
|
|
38
|
+
/_ __/\\ \\/ / __ \\/ __ \\__ / ____ ____ ____ ___ _________ _/ /_____ _____
|
|
39
|
+
/ / \\ / /_/ / / / //_ < / __ \`/ _ \\/ __ \\/ _ \\/ ___/ __ \`/ __/ __ \\/ ___/
|
|
40
|
+
/ / / / ____/ /_/ /__/ / / /_/ / __/ / / / __/ / / /_/ / /_/ /_/ / /
|
|
41
|
+
/_/ /_/_/ \\____/____/ \\__, /\\___/_/ /_/\\___/_/ \\__,_/\\__/\\____/_/
|
|
42
|
+
/____/
|
|
43
|
+
`))
|
|
44
|
+
|
|
45
|
+
const releases = await this._getTypo3Releases()
|
|
46
|
+
|
|
47
|
+
const prompts = [{
|
|
48
|
+
type: 'input',
|
|
49
|
+
name: 'ProjectName',
|
|
50
|
+
message: 'Choose your project name',
|
|
51
|
+
default: 'Project'
|
|
52
|
+
}, {
|
|
53
|
+
type: 'input',
|
|
54
|
+
name: 'SrcPath',
|
|
55
|
+
message: 'What is the path to the TYPO3 source files?',
|
|
56
|
+
default: '../typo3_src',
|
|
57
|
+
store: true
|
|
58
|
+
}, {
|
|
59
|
+
type: 'select',
|
|
60
|
+
name: 'Version',
|
|
61
|
+
message: 'Choose your TYPO3 version',
|
|
62
|
+
choices: releases,
|
|
63
|
+
store: true
|
|
64
|
+
}, {
|
|
65
|
+
type: 'input',
|
|
66
|
+
name: 'DbUsername',
|
|
67
|
+
message: 'Database username?',
|
|
68
|
+
default: 'root',
|
|
69
|
+
store: true
|
|
70
|
+
}, {
|
|
71
|
+
type: 'password',
|
|
72
|
+
name: 'DbPassword',
|
|
73
|
+
message: 'Database password?',
|
|
74
|
+
default: 'root',
|
|
75
|
+
store: true
|
|
76
|
+
}, {
|
|
77
|
+
type: 'input',
|
|
78
|
+
name: 'DbHostname',
|
|
79
|
+
message: 'Database hostname?',
|
|
80
|
+
default: 'localhost',
|
|
81
|
+
store: true
|
|
82
|
+
}, {
|
|
83
|
+
type: 'input',
|
|
84
|
+
name: 'DbPort',
|
|
85
|
+
message: 'Database port?',
|
|
86
|
+
default: 3306,
|
|
87
|
+
store: true,
|
|
88
|
+
validate: value => {
|
|
89
|
+
const port = Number(value)
|
|
90
|
+
|
|
91
|
+
if (Number.isInteger(port) && port >= 1 && port <= 65535) {
|
|
92
|
+
return true
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return 'Enter a valid TCP port.'
|
|
96
|
+
}
|
|
97
|
+
}, {
|
|
98
|
+
type: 'select',
|
|
99
|
+
name: 'DbSocket',
|
|
100
|
+
message: 'Database socket path?',
|
|
101
|
+
choices: [{
|
|
102
|
+
name: 'None',
|
|
103
|
+
value: ''
|
|
150
104
|
}, {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
105
|
+
name: 'MAMP',
|
|
106
|
+
value: '/Applications/MAMP/tmp/mysql/mysql.sock'
|
|
107
|
+
}],
|
|
108
|
+
store: true
|
|
109
|
+
}, {
|
|
110
|
+
type: 'input',
|
|
111
|
+
name: 'DbNew',
|
|
112
|
+
message: 'New database name? A new database, username and password will be created.',
|
|
113
|
+
default: 'newproject',
|
|
114
|
+
validate: value => {
|
|
115
|
+
if (/^[a-zA-Z0-9_]+$/.test(value)) {
|
|
116
|
+
return true
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return 'Use only letters, numbers and underscores.'
|
|
120
|
+
}
|
|
121
|
+
}, {
|
|
122
|
+
type: 'input',
|
|
123
|
+
name: 'User',
|
|
124
|
+
message: 'TYPO3 admin username?',
|
|
125
|
+
default: 'admin',
|
|
126
|
+
store: true
|
|
127
|
+
}, {
|
|
128
|
+
type: 'password',
|
|
129
|
+
name: 'Pass',
|
|
130
|
+
message: 'TYPO3 install tool & admin user password?',
|
|
131
|
+
default: 'joh316'
|
|
132
|
+
}, {
|
|
133
|
+
type: 'input',
|
|
134
|
+
name: 'AdminEmail',
|
|
135
|
+
message: 'TYPO3 admin email?',
|
|
136
|
+
default: 'john@doe.com',
|
|
137
|
+
store: true
|
|
138
|
+
}, {
|
|
139
|
+
type: 'select',
|
|
140
|
+
name: 'Transport',
|
|
141
|
+
message: 'How to send emails?',
|
|
142
|
+
choices: [{
|
|
143
|
+
name: 'smtp',
|
|
144
|
+
value: 'smtp'
|
|
157
145
|
}, {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
146
|
+
name: 'sendmail',
|
|
147
|
+
value: 'sendmail'
|
|
148
|
+
}],
|
|
149
|
+
store: true
|
|
150
|
+
}, {
|
|
151
|
+
when: answers => answers.Transport === 'smtp',
|
|
152
|
+
type: 'input',
|
|
153
|
+
name: 'SmtpServer',
|
|
154
|
+
message: 'SMTP server?',
|
|
155
|
+
default: 'localhost:25',
|
|
156
|
+
store: true
|
|
157
|
+
}, {
|
|
158
|
+
when: answers => answers.Transport === 'smtp',
|
|
159
|
+
type: 'select',
|
|
160
|
+
name: 'Encrypt',
|
|
161
|
+
message: 'SMTP encrypt?',
|
|
162
|
+
default: true,
|
|
163
|
+
choices: [{
|
|
164
|
+
name: 'true (TYPO3 >= 10 - if port 465 or other)',
|
|
165
|
+
value: true
|
|
164
166
|
}, {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
message: 'Activate English language in TYPO3?',
|
|
168
|
-
choices: [{
|
|
169
|
-
name: 'No',
|
|
170
|
-
value: false
|
|
171
|
-
}, {
|
|
172
|
-
name: 'Yes',
|
|
173
|
-
value: true
|
|
174
|
-
}],
|
|
175
|
-
store: true
|
|
167
|
+
name: 'false (TYPO3 >= 10 - if port 587)',
|
|
168
|
+
value: false
|
|
176
169
|
}, {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
message: 'Set English as default language?',
|
|
180
|
-
choices: [{
|
|
181
|
-
name: 'No',
|
|
182
|
-
value: false
|
|
183
|
-
}, {
|
|
184
|
-
name: 'Yes',
|
|
185
|
-
value: true
|
|
186
|
-
}],
|
|
187
|
-
store: true
|
|
170
|
+
name: 'ssl (TYPO3 9.5.x)',
|
|
171
|
+
value: 'ssl'
|
|
188
172
|
}, {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
173
|
+
name: 'tls (TYPO3 9.5.x)',
|
|
174
|
+
value: 'tls'
|
|
175
|
+
}],
|
|
176
|
+
store: true
|
|
177
|
+
}, {
|
|
178
|
+
when: answers => answers.Transport === 'smtp',
|
|
179
|
+
type: 'input',
|
|
180
|
+
name: 'SmtpUser',
|
|
181
|
+
message: 'SMTP username?',
|
|
182
|
+
default: '',
|
|
183
|
+
store: true
|
|
184
|
+
}, {
|
|
185
|
+
when: answers => answers.Transport === 'smtp',
|
|
186
|
+
type: 'password',
|
|
187
|
+
name: 'SmtpPass',
|
|
188
|
+
message: 'SMTP password?',
|
|
189
|
+
default: '',
|
|
190
|
+
store: true
|
|
191
|
+
}, {
|
|
192
|
+
when: answers => answers.Transport === 'smtp',
|
|
193
|
+
type: 'input',
|
|
194
|
+
name: 'SmtpEmail',
|
|
195
|
+
message: 'Sender email?',
|
|
196
|
+
default: '',
|
|
197
|
+
store: true
|
|
198
|
+
}, {
|
|
199
|
+
when: answers => answers.Transport === 'smtp',
|
|
200
|
+
type: 'input',
|
|
201
|
+
name: 'SmtpName',
|
|
202
|
+
message: 'Sender name?',
|
|
203
|
+
default: '',
|
|
204
|
+
store: true
|
|
205
|
+
}, {
|
|
206
|
+
type: 'select',
|
|
207
|
+
name: 'English',
|
|
208
|
+
message: 'Activate English language in TYPO3?',
|
|
209
|
+
choices: [{
|
|
210
|
+
name: 'No',
|
|
211
|
+
value: false
|
|
194
212
|
}, {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
213
|
+
name: 'Yes',
|
|
214
|
+
value: true
|
|
215
|
+
}],
|
|
216
|
+
store: true
|
|
217
|
+
}, {
|
|
218
|
+
type: 'select',
|
|
219
|
+
name: 'EnglishDefault',
|
|
220
|
+
message: 'Set English as default language?',
|
|
221
|
+
choices: [{
|
|
222
|
+
name: 'No',
|
|
223
|
+
value: false
|
|
200
224
|
}, {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
225
|
+
name: 'Yes',
|
|
226
|
+
value: true
|
|
227
|
+
}],
|
|
228
|
+
store: true
|
|
229
|
+
}, {
|
|
230
|
+
type: 'input',
|
|
231
|
+
name: 'Author',
|
|
232
|
+
message: 'Author name',
|
|
233
|
+
default: 'John Doe',
|
|
234
|
+
store: true
|
|
235
|
+
}, {
|
|
236
|
+
type: 'input',
|
|
237
|
+
name: 'Email',
|
|
238
|
+
message: 'Author eMail',
|
|
239
|
+
default: 'john@doe.com',
|
|
240
|
+
store: true
|
|
241
|
+
}, {
|
|
242
|
+
type: 'input',
|
|
243
|
+
name: 'Website',
|
|
244
|
+
message: 'Author website',
|
|
245
|
+
default: 'www.johndoe.com',
|
|
246
|
+
store: true
|
|
247
|
+
}, {
|
|
248
|
+
type: 'select',
|
|
249
|
+
name: 'Copyright',
|
|
250
|
+
message: 'Add copyright?',
|
|
251
|
+
choices: [{
|
|
252
|
+
name: 'No',
|
|
253
|
+
value: false
|
|
206
254
|
}, {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
255
|
+
name: 'Gandayo',
|
|
256
|
+
value: true
|
|
257
|
+
}],
|
|
258
|
+
store: true
|
|
259
|
+
}, {
|
|
260
|
+
type: 'select',
|
|
261
|
+
name: 'Htaccess',
|
|
262
|
+
message: 'Add .htaccess-dev file for development?',
|
|
263
|
+
choices: [{
|
|
264
|
+
name: 'Yes',
|
|
265
|
+
value: true
|
|
218
266
|
}, {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
267
|
+
name: 'No',
|
|
268
|
+
value: false
|
|
269
|
+
}],
|
|
270
|
+
store: true
|
|
271
|
+
}, {
|
|
272
|
+
type: 'select',
|
|
273
|
+
name: 'FontAwesome',
|
|
274
|
+
message: 'FontAwesome Pro?',
|
|
275
|
+
choices: [{
|
|
276
|
+
name: 'Yes',
|
|
277
|
+
value: true
|
|
230
278
|
}, {
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
279
|
+
name: 'No',
|
|
280
|
+
value: false
|
|
281
|
+
}],
|
|
282
|
+
store: true
|
|
283
|
+
}, {
|
|
284
|
+
type: 'select',
|
|
285
|
+
name: 'Search',
|
|
286
|
+
message: 'Activate search?',
|
|
287
|
+
choices: [{
|
|
288
|
+
name: 'No',
|
|
289
|
+
value: false
|
|
242
290
|
}, {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
291
|
+
name: 'Yes',
|
|
292
|
+
value: true
|
|
293
|
+
}]
|
|
294
|
+
}, {
|
|
295
|
+
type: 'select',
|
|
296
|
+
name: 'SSL',
|
|
297
|
+
message: 'Activate SSL/https for dev?',
|
|
298
|
+
choices: [{
|
|
299
|
+
name: 'Yes',
|
|
300
|
+
value: true
|
|
253
301
|
}, {
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
302
|
+
name: 'No',
|
|
303
|
+
value: false
|
|
304
|
+
}],
|
|
305
|
+
store: true
|
|
306
|
+
}, {
|
|
307
|
+
type: 'select',
|
|
308
|
+
name: 'Cols',
|
|
309
|
+
message: 'Bootstrap columns?',
|
|
310
|
+
choices: [{
|
|
311
|
+
name: '24',
|
|
312
|
+
value: 24
|
|
265
313
|
}, {
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
value: 24
|
|
272
|
-
}, {
|
|
273
|
-
name: '12',
|
|
274
|
-
value: 12
|
|
275
|
-
}],
|
|
276
|
-
store: true
|
|
277
|
-
}]
|
|
314
|
+
name: '12',
|
|
315
|
+
value: 12
|
|
316
|
+
}],
|
|
317
|
+
store: true
|
|
318
|
+
}]
|
|
278
319
|
|
|
279
|
-
|
|
280
|
-
t.props = answers
|
|
281
|
-
done()
|
|
282
|
-
})
|
|
283
|
-
})
|
|
320
|
+
this.props = await this.prompt(prompts)
|
|
284
321
|
}
|
|
285
322
|
|
|
286
|
-
writing () {
|
|
287
|
-
const
|
|
288
|
-
rzr = this.props
|
|
289
|
-
const path = rzr.SrcPath + '/typo3_src-' + rzr.Version
|
|
290
|
-
|
|
291
|
-
// Version
|
|
292
|
-
let version = '124'
|
|
293
|
-
if (rzr.Version.indexOf('13.4') !== -1) {
|
|
294
|
-
version = '134'
|
|
295
|
-
} else if (rzr.Version.indexOf('14.3') !== -1) {
|
|
296
|
-
version = '143'
|
|
297
|
-
}
|
|
323
|
+
async writing () {
|
|
324
|
+
const templateVersion = this._getTemplateVersion()
|
|
298
325
|
|
|
299
|
-
|
|
300
|
-
|
|
326
|
+
const sourcePath = path.resolve(
|
|
327
|
+
this.destinationRoot(),
|
|
328
|
+
this.props.SrcPath,
|
|
329
|
+
`typo3_src-${this.props.Version}`
|
|
330
|
+
)
|
|
301
331
|
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
t._localSettings(t)
|
|
332
|
+
await this._ensureTypo3Source(sourcePath)
|
|
333
|
+
await this._createSymlinks(sourcePath)
|
|
305
334
|
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
path.join(destination, directory)
|
|
315
|
-
)
|
|
316
|
-
})
|
|
335
|
+
await fs.copy(
|
|
336
|
+
this.templatePath(templateVersion),
|
|
337
|
+
this.destinationPath(),
|
|
338
|
+
{
|
|
339
|
+
overwrite: true,
|
|
340
|
+
errorOnExist: false
|
|
341
|
+
}
|
|
342
|
+
)
|
|
317
343
|
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
})
|
|
324
|
-
})
|
|
344
|
+
await this._writeSystemSettings()
|
|
345
|
+
await this._writeLocalSettings()
|
|
346
|
+
await this._chmodWritableDirectories()
|
|
347
|
+
await this._createDatabaseAndImportSql()
|
|
348
|
+
await this._setRazorConfig()
|
|
325
349
|
}
|
|
326
350
|
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
351
|
+
async install () {
|
|
352
|
+
const branch = this._getRazorBranch()
|
|
353
|
+
const packageName = `ssh://git@github.com/rafu1987/razor.git#${branch}`
|
|
354
|
+
|
|
355
|
+
await this._runCommand('yarn', [
|
|
356
|
+
'add',
|
|
357
|
+
'--dev',
|
|
358
|
+
'--no-lockfile',
|
|
359
|
+
'--modules-folder',
|
|
360
|
+
'typo3conf/ext/',
|
|
361
|
+
packageName
|
|
362
|
+
])
|
|
363
|
+
}
|
|
333
364
|
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
365
|
+
async end () {
|
|
366
|
+
await fs.remove(
|
|
367
|
+
this.destinationPath('package.json')
|
|
368
|
+
)
|
|
369
|
+
|
|
370
|
+
await fs.remove(
|
|
371
|
+
this.destinationPath('typo3conf/ext/.yarn-integrity')
|
|
372
|
+
)
|
|
373
|
+
|
|
374
|
+
if (this._usesModernTypo3Structure()) {
|
|
375
|
+
const extensionsSource = this.destinationPath(
|
|
376
|
+
'typo3conf/ext/razor/Initialisation/Extensions'
|
|
377
|
+
)
|
|
378
|
+
|
|
379
|
+
if (await fs.pathExists(extensionsSource)) {
|
|
380
|
+
await fs.copy(
|
|
381
|
+
extensionsSource,
|
|
382
|
+
this.destinationPath('typo3conf/ext'),
|
|
383
|
+
{
|
|
384
|
+
overwrite: true,
|
|
385
|
+
errorOnExist: false
|
|
386
|
+
}
|
|
338
387
|
)
|
|
339
388
|
}
|
|
340
|
-
}
|
|
389
|
+
}
|
|
341
390
|
}
|
|
342
391
|
|
|
343
|
-
|
|
344
|
-
|
|
392
|
+
async _getTypo3Releases () {
|
|
393
|
+
const url = 'https://get.typo3.org/json'
|
|
345
394
|
|
|
346
|
-
|
|
347
|
-
let branch = 'razor12-dev'
|
|
348
|
-
if (rzr.Version.indexOf('13.4') !== -1) {
|
|
349
|
-
branch = 'razor13-dev'
|
|
350
|
-
} else if (rzr.Version.indexOf('14.3') !== -1) {
|
|
351
|
-
branch = 'razor14-dev'
|
|
352
|
-
}
|
|
395
|
+
let response
|
|
353
396
|
|
|
354
|
-
|
|
355
|
-
|
|
397
|
+
try {
|
|
398
|
+
response = await fetch(url, {
|
|
399
|
+
headers: {
|
|
400
|
+
accept: 'application/json',
|
|
401
|
+
'user-agent': 'generator-razor'
|
|
402
|
+
},
|
|
403
|
+
redirect: 'follow',
|
|
404
|
+
signal: AbortSignal.timeout(30000)
|
|
405
|
+
})
|
|
406
|
+
} catch (error) {
|
|
407
|
+
const cause = error.cause
|
|
408
|
+
? ` ${error.cause.code ?? ''}: ${error.cause.message ?? error.cause}`
|
|
409
|
+
: ''
|
|
410
|
+
|
|
411
|
+
throw new Error(
|
|
412
|
+
`Could not connect to ${url}.${cause}`,
|
|
413
|
+
{
|
|
414
|
+
cause: error
|
|
415
|
+
}
|
|
416
|
+
)
|
|
417
|
+
}
|
|
356
418
|
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
419
|
+
if (!response.ok) {
|
|
420
|
+
throw new Error(
|
|
421
|
+
'Could not retrieve TYPO3 releases: ' +
|
|
422
|
+
`${response.status} ${response.statusText}`
|
|
423
|
+
)
|
|
424
|
+
}
|
|
362
425
|
|
|
363
|
-
|
|
364
|
-
// Delete package.json and .yarn-integrity files when finished
|
|
365
|
-
fs.unlink('package.json', () => {})
|
|
366
|
-
fs.unlink('typo3conf/ext/.yarn-integrity', () => {})
|
|
426
|
+
let data
|
|
367
427
|
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
428
|
+
try {
|
|
429
|
+
data = await response.json()
|
|
430
|
+
} catch (error) {
|
|
431
|
+
throw new Error(
|
|
432
|
+
`The TYPO3 release API returned invalid JSON from ${response.url}.`,
|
|
433
|
+
{
|
|
434
|
+
cause: error
|
|
435
|
+
}
|
|
436
|
+
)
|
|
371
437
|
}
|
|
372
|
-
}
|
|
373
438
|
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
for (let i = 0; i < len; i++) {
|
|
393
|
-
if (keys[i].indexOf('12.4.') !== -1 || keys[i].indexOf('13.4.') !== -1 || keys[i].indexOf('14.3.') !== -1) {
|
|
394
|
-
arr.push({
|
|
395
|
-
name: keys[i],
|
|
396
|
-
value: keys[i]
|
|
397
|
-
})
|
|
398
|
-
}
|
|
399
|
-
}
|
|
439
|
+
const releases = [
|
|
440
|
+
...Object.keys(data['14']?.releases ?? {}),
|
|
441
|
+
...Object.keys(data['13']?.releases ?? {}),
|
|
442
|
+
...Object.keys(data['12']?.releases ?? {})
|
|
443
|
+
]
|
|
444
|
+
|
|
445
|
+
const supportedVersions = [...new Set(releases)]
|
|
446
|
+
.filter(version => {
|
|
447
|
+
return version.startsWith('12.4.') ||
|
|
448
|
+
version.startsWith('13.4.') ||
|
|
449
|
+
version.startsWith('14.3.')
|
|
450
|
+
})
|
|
451
|
+
.sort((a, b) => {
|
|
452
|
+
return b.localeCompare(a, undefined, {
|
|
453
|
+
numeric: true,
|
|
454
|
+
sensitivity: 'base'
|
|
455
|
+
})
|
|
456
|
+
})
|
|
400
457
|
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
458
|
+
if (supportedVersions.length === 0) {
|
|
459
|
+
throw new Error(
|
|
460
|
+
'The TYPO3 release API returned no supported releases.'
|
|
461
|
+
)
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
return supportedVersions.map(version => ({
|
|
465
|
+
name: version,
|
|
466
|
+
value: version
|
|
467
|
+
}))
|
|
404
468
|
}
|
|
405
469
|
|
|
406
|
-
|
|
407
|
-
|
|
470
|
+
_getTemplateVersion () {
|
|
471
|
+
if (this.props.Version.startsWith('14.3.')) {
|
|
472
|
+
return '143'
|
|
473
|
+
}
|
|
408
474
|
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
475
|
+
if (this.props.Version.startsWith('13.4.')) {
|
|
476
|
+
return '134'
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
if (this.props.Version.startsWith('12.4.')) {
|
|
480
|
+
return '124'
|
|
481
|
+
}
|
|
412
482
|
|
|
413
|
-
|
|
483
|
+
throw new Error(
|
|
484
|
+
`Unsupported TYPO3 version: ${this.props.Version}`
|
|
485
|
+
)
|
|
414
486
|
}
|
|
415
487
|
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
remote.extract('https://get.typo3.org/' + rzr.Version, rzr.SrcPath, () => {})
|
|
488
|
+
_getRazorBranch () {
|
|
489
|
+
if (this.props.Version.startsWith('14.3.')) {
|
|
490
|
+
return 'razor14-dev'
|
|
420
491
|
}
|
|
421
492
|
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
493
|
+
if (this.props.Version.startsWith('13.4.')) {
|
|
494
|
+
return 'razor13-dev'
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
if (this.props.Version.startsWith('12.4.')) {
|
|
498
|
+
return 'razor12-dev'
|
|
499
|
+
}
|
|
426
500
|
|
|
427
|
-
|
|
501
|
+
throw new Error(
|
|
502
|
+
`No Razor branch configured for TYPO3 ${this.props.Version}`
|
|
503
|
+
)
|
|
428
504
|
}
|
|
429
505
|
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
506
|
+
_usesModernTypo3Structure () {
|
|
507
|
+
return this.props.Version.startsWith('12.4.') ||
|
|
508
|
+
this.props.Version.startsWith('13.4.') ||
|
|
509
|
+
this.props.Version.startsWith('14.3.')
|
|
510
|
+
}
|
|
435
511
|
|
|
436
|
-
|
|
437
|
-
|
|
512
|
+
async _ensureTypo3Source (sourcePath) {
|
|
513
|
+
if (await fs.pathExists(sourcePath)) {
|
|
514
|
+
this.log(
|
|
515
|
+
`Using existing TYPO3 source: ${sourcePath}`
|
|
516
|
+
)
|
|
438
517
|
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
newContent = t._substituteMarker(newContent, '###PASS###', res, true)
|
|
518
|
+
return
|
|
519
|
+
}
|
|
442
520
|
|
|
443
|
-
|
|
444
|
-
})
|
|
521
|
+
const sourceDirectory = path.dirname(sourcePath)
|
|
445
522
|
|
|
446
|
-
|
|
447
|
-
console.error('error setting settings.php')
|
|
448
|
-
}
|
|
449
|
-
})
|
|
450
|
-
}
|
|
523
|
+
await fs.ensureDir(sourceDirectory)
|
|
451
524
|
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
525
|
+
this.log(
|
|
526
|
+
`Downloading TYPO3 ${this.props.Version} to ` +
|
|
527
|
+
`${sourceDirectory}...`
|
|
528
|
+
)
|
|
455
529
|
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
if (rzr.Encrypt === true || rzr.Encrypt === false) {
|
|
460
|
-
encryptVariable = "'###SMTP_ENCRYPT###'"
|
|
461
|
-
}
|
|
530
|
+
const temporaryDirectory = await fs.mkdtemp(
|
|
531
|
+
path.join(os.tmpdir(), 'generator-razor-')
|
|
532
|
+
)
|
|
462
533
|
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
newContent = t._substituteMarker(newContent, '###SMTP_SERVER###', rzr.SmtpServer, true)
|
|
468
|
-
newContent = t._substituteMarker(newContent, '###SMTP_USER###', rzr.SmtpUser, true)
|
|
469
|
-
newContent = t._substituteMarker(newContent, '###SMTP_EMAIL###', rzr.SmtpEmail, true)
|
|
470
|
-
newContent = t._substituteMarker(newContent, '###SMTP_NAME###', rzr.SmtpName, true)
|
|
534
|
+
const archivePath = path.join(
|
|
535
|
+
temporaryDirectory,
|
|
536
|
+
`typo3_src-${this.props.Version}.tar.gz`
|
|
537
|
+
)
|
|
471
538
|
|
|
472
|
-
|
|
539
|
+
try {
|
|
540
|
+
await this._downloadFile(
|
|
541
|
+
`https://get.typo3.org/${this.props.Version}`,
|
|
542
|
+
archivePath
|
|
543
|
+
)
|
|
473
544
|
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
545
|
+
await tar.x({
|
|
546
|
+
file: archivePath,
|
|
547
|
+
cwd: sourceDirectory,
|
|
548
|
+
strict: true
|
|
477
549
|
})
|
|
478
|
-
}
|
|
479
|
-
fs.
|
|
550
|
+
} finally {
|
|
551
|
+
await fs.remove(temporaryDirectory)
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
if (!await fs.pathExists(sourcePath)) {
|
|
555
|
+
throw new Error(
|
|
556
|
+
'TYPO3 archive was extracted, but the expected directory ' +
|
|
557
|
+
`was not found: ${sourcePath}`
|
|
558
|
+
)
|
|
480
559
|
}
|
|
481
560
|
}
|
|
482
561
|
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
562
|
+
async _downloadFile (url, destination) {
|
|
563
|
+
let response
|
|
564
|
+
|
|
565
|
+
try {
|
|
566
|
+
response = await fetch(url, {
|
|
567
|
+
headers: {
|
|
568
|
+
accept: 'application/gzip, application/octet-stream',
|
|
569
|
+
'user-agent': 'generator-razor'
|
|
570
|
+
},
|
|
571
|
+
redirect: 'follow',
|
|
572
|
+
signal: AbortSignal.timeout(120000)
|
|
573
|
+
})
|
|
574
|
+
} catch (error) {
|
|
575
|
+
const cause = error.cause
|
|
576
|
+
? ` ${error.cause.code ?? ''}: ${error.cause.message ?? error.cause}`
|
|
577
|
+
: ''
|
|
578
|
+
|
|
579
|
+
throw new Error(
|
|
580
|
+
`Could not connect to ${url}.${cause}`,
|
|
581
|
+
{
|
|
582
|
+
cause: error
|
|
583
|
+
}
|
|
584
|
+
)
|
|
585
|
+
}
|
|
486
586
|
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
multipleStatements: true
|
|
494
|
-
})
|
|
587
|
+
if (!response.ok) {
|
|
588
|
+
throw new Error(
|
|
589
|
+
`Could not download ${url}: ` +
|
|
590
|
+
`${response.status} ${response.statusText}`
|
|
591
|
+
)
|
|
592
|
+
}
|
|
495
593
|
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
}
|
|
594
|
+
if (!response.body) {
|
|
595
|
+
throw new Error(
|
|
596
|
+
`The download response for ${url} had no body.`
|
|
597
|
+
)
|
|
598
|
+
}
|
|
501
599
|
|
|
502
|
-
|
|
600
|
+
await fs.ensureDir(
|
|
601
|
+
path.dirname(destination)
|
|
602
|
+
)
|
|
503
603
|
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
connection.query('GRANT ALL PRIVILEGES ON `' + dbNew + '`.* TO "' + dbNew + '"@"%";')
|
|
604
|
+
const fileStream = fs.createWriteStream(
|
|
605
|
+
destination
|
|
606
|
+
)
|
|
508
607
|
|
|
509
|
-
|
|
510
|
-
|
|
608
|
+
const responseStream = Readable.fromWeb(
|
|
609
|
+
response.body
|
|
610
|
+
)
|
|
511
611
|
|
|
512
|
-
|
|
612
|
+
await pipeline(
|
|
613
|
+
responseStream,
|
|
614
|
+
fileStream
|
|
615
|
+
)
|
|
513
616
|
}
|
|
514
617
|
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
618
|
+
async _createSymlinks (sourcePath) {
|
|
619
|
+
const links = [{
|
|
620
|
+
source: sourcePath,
|
|
621
|
+
destination: this.destinationPath('typo3_src'),
|
|
622
|
+
type: 'dir'
|
|
623
|
+
}, {
|
|
624
|
+
source: path.join(sourcePath, 'typo3'),
|
|
625
|
+
destination: this.destinationPath('typo3'),
|
|
626
|
+
type: 'dir'
|
|
627
|
+
}, {
|
|
628
|
+
source: path.join(sourcePath, 'index.php'),
|
|
629
|
+
destination: this.destinationPath('index.php'),
|
|
630
|
+
type: 'file'
|
|
631
|
+
}]
|
|
632
|
+
|
|
633
|
+
for (const link of links) {
|
|
634
|
+
if (!await fs.pathExists(link.source)) {
|
|
635
|
+
throw new Error(
|
|
636
|
+
'Cannot create symlink because the source does not exist: ' +
|
|
637
|
+
link.source
|
|
638
|
+
)
|
|
520
639
|
}
|
|
521
640
|
|
|
522
|
-
|
|
523
|
-
const hash = argon2.hash(rzr.Pass)
|
|
524
|
-
hash.then(function (res) {
|
|
525
|
-
result = t._substituteMarker(result, '###PASS###', res, false)
|
|
641
|
+
await fs.remove(link.destination)
|
|
526
642
|
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
643
|
+
await fs.ensureSymlink(
|
|
644
|
+
link.source,
|
|
645
|
+
link.destination,
|
|
646
|
+
link.type
|
|
647
|
+
)
|
|
648
|
+
}
|
|
530
649
|
}
|
|
531
650
|
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
651
|
+
async _writeSystemSettings () {
|
|
652
|
+
const settingsPath = this.destinationPath(
|
|
653
|
+
'typo3conf/system/settings.php'
|
|
654
|
+
)
|
|
655
|
+
|
|
656
|
+
let content = await fs.readFile(
|
|
657
|
+
settingsPath,
|
|
658
|
+
'utf8'
|
|
659
|
+
)
|
|
660
|
+
|
|
661
|
+
content = this._substituteMarker(
|
|
662
|
+
content,
|
|
663
|
+
'###DBNEW###',
|
|
664
|
+
this.props.DbNew.toLowerCase()
|
|
665
|
+
)
|
|
666
|
+
|
|
667
|
+
content = this._substituteMarker(
|
|
668
|
+
content,
|
|
669
|
+
'###HOST###',
|
|
670
|
+
this.props.DbHostname
|
|
671
|
+
)
|
|
672
|
+
|
|
673
|
+
content = this._substituteMarker(
|
|
674
|
+
content,
|
|
675
|
+
'###PROJECTNAME###',
|
|
676
|
+
this.props.ProjectName
|
|
677
|
+
)
|
|
678
|
+
|
|
679
|
+
const encryptionKey = crypto
|
|
680
|
+
.randomBytes(48)
|
|
681
|
+
.toString('hex')
|
|
682
|
+
|
|
683
|
+
content = this._substituteMarker(
|
|
684
|
+
content,
|
|
685
|
+
'###ENCRYPTION_KEY###',
|
|
686
|
+
encryptionKey
|
|
687
|
+
)
|
|
688
|
+
|
|
689
|
+
const passwordHash = await argon2.hash(
|
|
690
|
+
this.props.Pass
|
|
691
|
+
)
|
|
692
|
+
|
|
693
|
+
content = this._substituteMarker(
|
|
694
|
+
content,
|
|
695
|
+
'###PASS###',
|
|
696
|
+
passwordHash
|
|
697
|
+
)
|
|
698
|
+
|
|
699
|
+
await fs.writeFile(
|
|
700
|
+
settingsPath,
|
|
701
|
+
content,
|
|
702
|
+
'utf8'
|
|
703
|
+
)
|
|
704
|
+
}
|
|
538
705
|
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
connection.end()
|
|
706
|
+
async _writeLocalSettings () {
|
|
707
|
+
const localSettingsPath = this.destinationPath(
|
|
708
|
+
'typo3conf/system/local.php'
|
|
709
|
+
)
|
|
544
710
|
|
|
545
|
-
|
|
546
|
-
|
|
711
|
+
if (this.props.Transport !== 'smtp') {
|
|
712
|
+
await fs.remove(localSettingsPath)
|
|
713
|
+
return
|
|
714
|
+
}
|
|
547
715
|
|
|
548
|
-
|
|
549
|
-
|
|
716
|
+
let content = await fs.readFile(
|
|
717
|
+
localSettingsPath,
|
|
718
|
+
'utf8'
|
|
719
|
+
)
|
|
550
720
|
|
|
551
|
-
|
|
552
|
-
console.error(err)
|
|
553
|
-
}
|
|
554
|
-
})
|
|
555
|
-
})
|
|
556
|
-
}
|
|
721
|
+
let encryptionMarker = '###SMTP_ENCRYPT###'
|
|
557
722
|
|
|
558
|
-
|
|
559
|
-
|
|
723
|
+
if (
|
|
724
|
+
this.props.Encrypt === true ||
|
|
725
|
+
this.props.Encrypt === false
|
|
726
|
+
) {
|
|
727
|
+
encryptionMarker = "'###SMTP_ENCRYPT###'"
|
|
728
|
+
}
|
|
560
729
|
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
730
|
+
const replacements = [
|
|
731
|
+
['###TRANSPORT###', this.props.Transport],
|
|
732
|
+
[encryptionMarker, this.props.Encrypt],
|
|
733
|
+
['###SMTP_PASS###', this.props.SmtpPass ?? ''],
|
|
734
|
+
['###SMTP_SERVER###', this.props.SmtpServer ?? ''],
|
|
735
|
+
['###SMTP_USER###', this.props.SmtpUser ?? ''],
|
|
736
|
+
['###SMTP_EMAIL###', this.props.SmtpEmail ?? ''],
|
|
737
|
+
['###SMTP_NAME###', this.props.SmtpName ?? '']
|
|
738
|
+
]
|
|
739
|
+
|
|
740
|
+
for (const [marker, value] of replacements) {
|
|
741
|
+
content = this._substituteMarker(
|
|
742
|
+
content,
|
|
743
|
+
marker,
|
|
744
|
+
value
|
|
745
|
+
)
|
|
565
746
|
}
|
|
747
|
+
|
|
748
|
+
await fs.writeFile(
|
|
749
|
+
localSettingsPath,
|
|
750
|
+
content,
|
|
751
|
+
'utf8'
|
|
752
|
+
)
|
|
566
753
|
}
|
|
567
754
|
|
|
568
|
-
|
|
569
|
-
const
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
fontawesome: rzr.FontAwesome,
|
|
580
|
-
cols: rzr.Cols,
|
|
581
|
-
htaccess: rzr.Htaccess,
|
|
582
|
-
smtpemail: rzr.SmtpEmail,
|
|
583
|
-
search: rzr.Search,
|
|
584
|
-
ssl: rzr.SSL
|
|
755
|
+
async _chmodWritableDirectories () {
|
|
756
|
+
const writableDirectories = [
|
|
757
|
+
'fileadmin',
|
|
758
|
+
'typo3temp',
|
|
759
|
+
'typo3conf'
|
|
760
|
+
]
|
|
761
|
+
|
|
762
|
+
for (const directory of writableDirectories) {
|
|
763
|
+
await this._chmodDirectoriesRecursive(
|
|
764
|
+
this.destinationPath(directory)
|
|
765
|
+
)
|
|
585
766
|
}
|
|
767
|
+
}
|
|
586
768
|
|
|
587
|
-
|
|
588
|
-
if (
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
769
|
+
async _chmodDirectoriesRecursive (directory) {
|
|
770
|
+
if (!await fs.pathExists(directory)) {
|
|
771
|
+
return
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
await fs.chmod(
|
|
775
|
+
directory,
|
|
776
|
+
0o2775
|
|
777
|
+
)
|
|
778
|
+
|
|
779
|
+
const entries = await fs.readdir(
|
|
780
|
+
directory,
|
|
781
|
+
{
|
|
782
|
+
withFileTypes: true
|
|
595
783
|
}
|
|
784
|
+
)
|
|
785
|
+
|
|
786
|
+
for (const entry of entries) {
|
|
787
|
+
if (entry.isDirectory()) {
|
|
788
|
+
await this._chmodDirectoriesRecursive(
|
|
789
|
+
path.join(directory, entry.name)
|
|
790
|
+
)
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
async _createDatabaseAndImportSql () {
|
|
796
|
+
const databaseName = this.props.DbNew.toLowerCase()
|
|
797
|
+
|
|
798
|
+
const connectionOptions = {
|
|
799
|
+
host: this.props.DbHostname,
|
|
800
|
+
port: Number(this.props.DbPort),
|
|
801
|
+
user: this.props.DbUsername,
|
|
802
|
+
password: this.props.DbPassword,
|
|
803
|
+
multipleStatements: true
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
if (this.props.DbSocket) {
|
|
807
|
+
connectionOptions.socketPath = this.props.DbSocket
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
const connection = await mysql.createConnection(
|
|
811
|
+
connectionOptions
|
|
812
|
+
)
|
|
813
|
+
|
|
814
|
+
try {
|
|
815
|
+
const escapedDatabase = connection.escapeId(
|
|
816
|
+
databaseName
|
|
817
|
+
)
|
|
818
|
+
|
|
819
|
+
const escapedUsername = connection.escape(
|
|
820
|
+
databaseName
|
|
821
|
+
)
|
|
822
|
+
|
|
823
|
+
const escapedPassword = connection.escape(
|
|
824
|
+
databaseName
|
|
825
|
+
)
|
|
826
|
+
|
|
827
|
+
await connection.query(
|
|
828
|
+
`CREATE DATABASE ${escapedDatabase} ` +
|
|
829
|
+
'CHARACTER SET utf8mb4 ' +
|
|
830
|
+
'COLLATE utf8mb4_unicode_ci'
|
|
831
|
+
)
|
|
832
|
+
|
|
833
|
+
await connection.query(
|
|
834
|
+
`CREATE USER ${escapedUsername}@'%' ` +
|
|
835
|
+
`IDENTIFIED BY ${escapedPassword}`
|
|
836
|
+
)
|
|
837
|
+
|
|
838
|
+
await connection.query(
|
|
839
|
+
`GRANT ALL PRIVILEGES ON ${escapedDatabase}.* ` +
|
|
840
|
+
`TO ${escapedUsername}@'%'`
|
|
841
|
+
)
|
|
842
|
+
|
|
843
|
+
await connection.query(
|
|
844
|
+
`USE ${escapedDatabase}`
|
|
845
|
+
)
|
|
846
|
+
|
|
847
|
+
const sqlPath = this.destinationPath(
|
|
848
|
+
'db.sql'
|
|
849
|
+
)
|
|
850
|
+
|
|
851
|
+
let sql = await fs.readFile(
|
|
852
|
+
sqlPath,
|
|
853
|
+
'utf8'
|
|
854
|
+
)
|
|
855
|
+
|
|
856
|
+
sql = this._substituteMarker(
|
|
857
|
+
sql,
|
|
858
|
+
'###ADMIN###',
|
|
859
|
+
this.props.User
|
|
860
|
+
)
|
|
861
|
+
|
|
862
|
+
const passwordHash = await argon2.hash(
|
|
863
|
+
this.props.Pass
|
|
864
|
+
)
|
|
865
|
+
|
|
866
|
+
sql = this._substituteMarker(
|
|
867
|
+
sql,
|
|
868
|
+
'###PASS###',
|
|
869
|
+
passwordHash
|
|
870
|
+
)
|
|
871
|
+
|
|
872
|
+
await connection.query(sql)
|
|
873
|
+
|
|
874
|
+
await fs.remove(sqlPath)
|
|
875
|
+
} finally {
|
|
876
|
+
await connection.end()
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
_substituteMarker (content, marker, replacement) {
|
|
881
|
+
return String(content)
|
|
882
|
+
.split(marker)
|
|
883
|
+
.join(String(replacement))
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
async _setRazorConfig () {
|
|
887
|
+
const config = {
|
|
888
|
+
siteName: this.props.ProjectName,
|
|
889
|
+
user: this.props.User,
|
|
890
|
+
adminEmail: this.props.AdminEmail,
|
|
891
|
+
english: this.props.English,
|
|
892
|
+
englishDefault: this.props.EnglishDefault,
|
|
893
|
+
author: this.props.Author,
|
|
894
|
+
email: this.props.Email,
|
|
895
|
+
website: this.props.Website,
|
|
896
|
+
copyright: this.props.Copyright,
|
|
897
|
+
fontawesome: this.props.FontAwesome,
|
|
898
|
+
cols: this.props.Cols,
|
|
899
|
+
htaccess: this.props.Htaccess,
|
|
900
|
+
smtpemail: this.props.SmtpEmail ?? '',
|
|
901
|
+
search: this.props.Search,
|
|
902
|
+
ssl: this.props.SSL
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
const plainHtaccess = this.destinationPath(
|
|
906
|
+
'_.htaccess-dev'
|
|
907
|
+
)
|
|
908
|
+
|
|
909
|
+
const sslHtaccess = this.destinationPath(
|
|
910
|
+
'_.htaccess-dev-ssl'
|
|
911
|
+
)
|
|
912
|
+
|
|
913
|
+
const targetHtaccess = this.destinationPath(
|
|
914
|
+
'.htaccess-dev'
|
|
915
|
+
)
|
|
916
|
+
|
|
917
|
+
if (!this.props.Htaccess) {
|
|
918
|
+
await fs.remove(plainHtaccess)
|
|
919
|
+
await fs.remove(sslHtaccess)
|
|
920
|
+
await fs.remove(targetHtaccess)
|
|
921
|
+
} else if (this.props.SSL) {
|
|
922
|
+
await fs.move(
|
|
923
|
+
sslHtaccess,
|
|
924
|
+
targetHtaccess,
|
|
925
|
+
{
|
|
926
|
+
overwrite: true
|
|
927
|
+
}
|
|
928
|
+
)
|
|
929
|
+
|
|
930
|
+
await fs.remove(plainHtaccess)
|
|
596
931
|
} else {
|
|
597
|
-
fs.
|
|
598
|
-
|
|
932
|
+
await fs.move(
|
|
933
|
+
plainHtaccess,
|
|
934
|
+
targetHtaccess,
|
|
935
|
+
{
|
|
936
|
+
overwrite: true
|
|
937
|
+
}
|
|
938
|
+
)
|
|
939
|
+
|
|
940
|
+
await fs.remove(sslHtaccess)
|
|
599
941
|
}
|
|
600
942
|
|
|
601
|
-
fs.
|
|
602
|
-
|
|
603
|
-
|
|
943
|
+
await fs.writeJson(
|
|
944
|
+
this.destinationPath('razor.json'),
|
|
945
|
+
config,
|
|
946
|
+
{
|
|
947
|
+
spaces: 2
|
|
604
948
|
}
|
|
949
|
+
)
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
async _runCommand (command, argumentsList) {
|
|
953
|
+
await new Promise((resolve, reject) => {
|
|
954
|
+
const child = spawn(
|
|
955
|
+
command,
|
|
956
|
+
argumentsList,
|
|
957
|
+
{
|
|
958
|
+
cwd: this.destinationRoot(),
|
|
959
|
+
env: process.env,
|
|
960
|
+
stdio: 'inherit'
|
|
961
|
+
}
|
|
962
|
+
)
|
|
963
|
+
|
|
964
|
+
let settled = false
|
|
965
|
+
|
|
966
|
+
child.once('error', error => {
|
|
967
|
+
if (settled) {
|
|
968
|
+
return
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
settled = true
|
|
972
|
+
|
|
973
|
+
if (error.code === 'ENOENT') {
|
|
974
|
+
reject(
|
|
975
|
+
new Error(
|
|
976
|
+
`Could not execute "${command}". ` +
|
|
977
|
+
'Make sure it is installed and available in PATH.',
|
|
978
|
+
{
|
|
979
|
+
cause: error
|
|
980
|
+
}
|
|
981
|
+
)
|
|
982
|
+
)
|
|
983
|
+
|
|
984
|
+
return
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
reject(error)
|
|
988
|
+
})
|
|
989
|
+
|
|
990
|
+
child.once('close', code => {
|
|
991
|
+
if (settled) {
|
|
992
|
+
return
|
|
993
|
+
}
|
|
994
|
+
|
|
995
|
+
settled = true
|
|
996
|
+
|
|
997
|
+
if (code === 0) {
|
|
998
|
+
resolve()
|
|
999
|
+
return
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
reject(
|
|
1003
|
+
new Error(
|
|
1004
|
+
`"${command}" exited with status code ${code}.`
|
|
1005
|
+
)
|
|
1006
|
+
)
|
|
1007
|
+
})
|
|
605
1008
|
})
|
|
606
1009
|
}
|
|
607
1010
|
}
|