generator-razor 13.4.134 → 14.0.1
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 +921 -515
- package/package.json +15 -16
package/app/index.js
CHANGED
|
@@ -1,607 +1,1013 @@
|
|
|
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: 'input',
|
|
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: 'input',
|
|
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: 'input',
|
|
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 srcPath = 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'
|
|
394
|
+
|
|
395
|
+
let response
|
|
345
396
|
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
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
|
+
)
|
|
352
417
|
}
|
|
353
418
|
|
|
354
|
-
|
|
355
|
-
|
|
419
|
+
if (!response.ok) {
|
|
420
|
+
throw new Error(
|
|
421
|
+
'Could not retrieve TYPO3 releases: ' +
|
|
422
|
+
`${response.status} ${response.statusText}`
|
|
423
|
+
)
|
|
424
|
+
}
|
|
356
425
|
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
426
|
+
let data
|
|
427
|
+
|
|
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
|
+
)
|
|
437
|
+
}
|
|
362
438
|
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
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
|
+
})
|
|
367
457
|
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
458
|
+
if (supportedVersions.length === 0) {
|
|
459
|
+
throw new Error(
|
|
460
|
+
'The TYPO3 release API returned no supported releases.'
|
|
461
|
+
)
|
|
371
462
|
}
|
|
463
|
+
|
|
464
|
+
return supportedVersions.map(version => ({
|
|
465
|
+
name: version,
|
|
466
|
+
value: version
|
|
467
|
+
}))
|
|
372
468
|
}
|
|
373
469
|
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
json: true
|
|
379
|
-
}, (error, response, body) => {
|
|
380
|
-
if (!error && response.statusCode === 200) {
|
|
381
|
-
const releases12 = body['12']['releases']
|
|
382
|
-
const releases13 = body['13']['releases']
|
|
383
|
-
const releases14 = body['14']['releases']
|
|
384
|
-
|
|
385
|
-
const releasesObj = t._mergeOptions(releases14, releases13, releases12)
|
|
386
|
-
|
|
387
|
-
const keys = Object.keys(releasesObj)
|
|
388
|
-
const len = keys.length
|
|
389
|
-
const arr = []
|
|
390
|
-
|
|
391
|
-
// Filter out only 12.4.x 13.4.x, 14.3.x
|
|
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
|
-
}
|
|
470
|
+
_getTemplateVersion () {
|
|
471
|
+
if (this.props.Version.startsWith('14.3.')) {
|
|
472
|
+
return '143'
|
|
473
|
+
}
|
|
400
474
|
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
}
|
|
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
|
+
}
|
|
482
|
+
|
|
483
|
+
throw new Error(
|
|
484
|
+
`Unsupported TYPO3 version: ${this.props.Version}`
|
|
485
|
+
)
|
|
404
486
|
}
|
|
405
487
|
|
|
406
|
-
|
|
407
|
-
|
|
488
|
+
_getRazorBranch () {
|
|
489
|
+
if (this.props.Version.startsWith('14.3.')) {
|
|
490
|
+
return 'razor14-dev'
|
|
491
|
+
}
|
|
408
492
|
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
493
|
+
if (this.props.Version.startsWith('13.4.')) {
|
|
494
|
+
return 'razor13-dev'
|
|
495
|
+
}
|
|
412
496
|
|
|
413
|
-
|
|
497
|
+
if (this.props.Version.startsWith('12.4.')) {
|
|
498
|
+
return 'razor12-dev'
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
throw new Error(
|
|
502
|
+
`No Razor branch configured for TYPO3 ${this.props.Version}`
|
|
503
|
+
)
|
|
414
504
|
}
|
|
415
505
|
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
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
|
+
}
|
|
511
|
+
|
|
512
|
+
async _ensureTypo3Source (sourcePath) {
|
|
513
|
+
if (await fs.pathExists(sourcePath)) {
|
|
514
|
+
this.log(
|
|
515
|
+
`Using existing TYPO3 source: ${sourcePath}`
|
|
516
|
+
)
|
|
517
|
+
|
|
518
|
+
return
|
|
420
519
|
}
|
|
421
520
|
|
|
422
|
-
|
|
423
|
-
link(path, 'typo3_src')
|
|
424
|
-
link('typo3_src/typo3', 'typo3')
|
|
425
|
-
link('typo3_src/index.php', 'index.php')
|
|
521
|
+
const sourceDirectory = path.dirname(sourcePath)
|
|
426
522
|
|
|
427
|
-
|
|
428
|
-
|
|
523
|
+
await fs.ensureDir(sourceDirectory)
|
|
524
|
+
|
|
525
|
+
this.log(
|
|
526
|
+
`Downloading TYPO3 ${this.props.Version} to ` +
|
|
527
|
+
`${sourceDirectory}...`
|
|
528
|
+
)
|
|
429
529
|
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
newContent = t._substituteMarker(newContent, '###HOST###', rzr.DbHostname, true)
|
|
434
|
-
newContent = t._substituteMarker(newContent, '###PROJECTNAME###', rzr.ProjectName, true)
|
|
530
|
+
const temporaryDirectory = await fs.mkdtemp(
|
|
531
|
+
path.join(os.tmpdir(), 'generator-razor-')
|
|
532
|
+
)
|
|
435
533
|
|
|
436
|
-
|
|
437
|
-
|
|
534
|
+
const archivePath = path.join(
|
|
535
|
+
temporaryDirectory,
|
|
536
|
+
`typo3_src-${this.props.Version}.tar.gz`
|
|
537
|
+
)
|
|
438
538
|
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
539
|
+
try {
|
|
540
|
+
await this._downloadFile(
|
|
541
|
+
`https://get.typo3.org/${this.props.Version}`,
|
|
542
|
+
archivePath
|
|
543
|
+
)
|
|
442
544
|
|
|
443
|
-
|
|
545
|
+
await tar.x({
|
|
546
|
+
file: archivePath,
|
|
547
|
+
cwd: sourceDirectory,
|
|
548
|
+
strict: true
|
|
444
549
|
})
|
|
550
|
+
} finally {
|
|
551
|
+
await fs.remove(temporaryDirectory)
|
|
552
|
+
}
|
|
445
553
|
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
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
|
+
)
|
|
559
|
+
}
|
|
450
560
|
}
|
|
451
561
|
|
|
452
|
-
|
|
453
|
-
|
|
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
|
+
}
|
|
586
|
+
|
|
587
|
+
if (!response.ok) {
|
|
588
|
+
throw new Error(
|
|
589
|
+
`Could not download ${url}: ` +
|
|
590
|
+
`${response.status} ${response.statusText}`
|
|
591
|
+
)
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
if (!response.body) {
|
|
595
|
+
throw new Error(
|
|
596
|
+
`The download response for ${url} had no body.`
|
|
597
|
+
)
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
await fs.ensureDir(
|
|
601
|
+
path.dirname(destination)
|
|
602
|
+
)
|
|
603
|
+
|
|
604
|
+
const fileStream = fs.createWriteStream(
|
|
605
|
+
destination
|
|
606
|
+
)
|
|
607
|
+
|
|
608
|
+
const responseStream = Readable.fromWeb(
|
|
609
|
+
response.body
|
|
610
|
+
)
|
|
611
|
+
|
|
612
|
+
await pipeline(
|
|
613
|
+
responseStream,
|
|
614
|
+
fileStream
|
|
615
|
+
)
|
|
454
616
|
}
|
|
455
617
|
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
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
|
+
)
|
|
461
639
|
}
|
|
462
640
|
|
|
463
|
-
fs.
|
|
464
|
-
let newContent = t._substituteMarker(content, '###TRANSPORT###', rzr.Transport, true)
|
|
465
|
-
newContent = t._substituteMarker(newContent, encryptVariable, rzr.Encrypt, true)
|
|
466
|
-
newContent = t._substituteMarker(newContent, '###SMTP_PASS###', rzr.SmtpPass, true)
|
|
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)
|
|
471
|
-
|
|
472
|
-
fs.writeFile('typo3conf/system/local.php', newContent, 'utf8', () => {})
|
|
641
|
+
await fs.remove(link.destination)
|
|
473
642
|
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
fs.unlink('typo3conf/system/local.php', () => {})
|
|
643
|
+
await fs.ensureSymlink(
|
|
644
|
+
link.source,
|
|
645
|
+
link.destination,
|
|
646
|
+
link.type
|
|
647
|
+
)
|
|
480
648
|
}
|
|
481
649
|
}
|
|
482
650
|
|
|
483
|
-
|
|
484
|
-
const
|
|
485
|
-
|
|
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
|
+
}
|
|
486
705
|
|
|
487
|
-
|
|
488
|
-
const
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
password: rzr.DbPassword,
|
|
492
|
-
socketPath: rzr.DbSocket,
|
|
493
|
-
multipleStatements: true
|
|
494
|
-
})
|
|
706
|
+
async _writeLocalSettings () {
|
|
707
|
+
const localSettingsPath = this.destinationPath(
|
|
708
|
+
'typo3conf/system/local.php'
|
|
709
|
+
)
|
|
495
710
|
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
})
|
|
711
|
+
if (this.props.Transport !== 'smtp') {
|
|
712
|
+
await fs.remove(localSettingsPath)
|
|
713
|
+
return
|
|
714
|
+
}
|
|
501
715
|
|
|
502
|
-
|
|
716
|
+
let content = await fs.readFile(
|
|
717
|
+
localSettingsPath,
|
|
718
|
+
'utf8'
|
|
719
|
+
)
|
|
503
720
|
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
721
|
+
let encryptionMarker = '###SMTP_ENCRYPT###'
|
|
722
|
+
|
|
723
|
+
if (
|
|
724
|
+
this.props.Encrypt === true ||
|
|
725
|
+
this.props.Encrypt === false
|
|
726
|
+
) {
|
|
727
|
+
encryptionMarker = "'###SMTP_ENCRYPT###'"
|
|
728
|
+
}
|
|
508
729
|
|
|
509
|
-
|
|
510
|
-
|
|
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
|
+
)
|
|
746
|
+
}
|
|
511
747
|
|
|
512
|
-
|
|
748
|
+
await fs.writeFile(
|
|
749
|
+
localSettingsPath,
|
|
750
|
+
content,
|
|
751
|
+
'utf8'
|
|
752
|
+
)
|
|
513
753
|
}
|
|
514
754
|
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
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
|
+
)
|
|
766
|
+
}
|
|
767
|
+
}
|
|
521
768
|
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
769
|
+
async _chmodDirectoriesRecursive (directory) {
|
|
770
|
+
if (!await fs.pathExists(directory)) {
|
|
771
|
+
return
|
|
772
|
+
}
|
|
526
773
|
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
774
|
+
await fs.chmod(
|
|
775
|
+
directory,
|
|
776
|
+
0o2775
|
|
777
|
+
)
|
|
531
778
|
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
console.error(err)
|
|
779
|
+
const entries = await fs.readdir(
|
|
780
|
+
directory,
|
|
781
|
+
{
|
|
782
|
+
withFileTypes: true
|
|
537
783
|
}
|
|
784
|
+
)
|
|
538
785
|
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
786
|
+
for (const entry of entries) {
|
|
787
|
+
if (entry.isDirectory()) {
|
|
788
|
+
await this._chmodDirectoriesRecursive(
|
|
789
|
+
path.join(directory, entry.name)
|
|
790
|
+
)
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
}
|
|
544
794
|
|
|
545
|
-
|
|
546
|
-
|
|
795
|
+
async _createDatabaseAndImportSql () {
|
|
796
|
+
const databaseName = this.props.DbNew.toLowerCase()
|
|
547
797
|
|
|
548
|
-
|
|
549
|
-
|
|
798
|
+
const connectionOptions = {
|
|
799
|
+
host: this.props.DbHostname,
|
|
800
|
+
user: this.props.DbUsername,
|
|
801
|
+
password: this.props.DbPassword,
|
|
802
|
+
multipleStatements: true
|
|
803
|
+
}
|
|
550
804
|
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
})
|
|
555
|
-
})
|
|
556
|
-
}
|
|
805
|
+
if (this.props.DbPort) {
|
|
806
|
+
connectionOptions.port = Number(this.props.DbPort)
|
|
807
|
+
}
|
|
557
808
|
|
|
558
|
-
|
|
559
|
-
|
|
809
|
+
if (this.props.DbSocket) {
|
|
810
|
+
connectionOptions.socketPath = this.props.DbSocket
|
|
811
|
+
}
|
|
560
812
|
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
813
|
+
const connection = await mysql.createConnection(
|
|
814
|
+
connectionOptions
|
|
815
|
+
)
|
|
816
|
+
|
|
817
|
+
try {
|
|
818
|
+
const escapedDatabase = connection.escapeId(
|
|
819
|
+
databaseName
|
|
820
|
+
)
|
|
821
|
+
|
|
822
|
+
const escapedUsername = connection.escape(
|
|
823
|
+
databaseName
|
|
824
|
+
)
|
|
825
|
+
|
|
826
|
+
const escapedPassword = connection.escape(
|
|
827
|
+
databaseName
|
|
828
|
+
)
|
|
829
|
+
|
|
830
|
+
await connection.query(
|
|
831
|
+
`CREATE DATABASE ${escapedDatabase} ` +
|
|
832
|
+
'CHARACTER SET utf8mb4 ' +
|
|
833
|
+
'COLLATE utf8mb4_unicode_ci'
|
|
834
|
+
)
|
|
835
|
+
|
|
836
|
+
await connection.query(
|
|
837
|
+
`CREATE USER ${escapedUsername}@'%' ` +
|
|
838
|
+
`IDENTIFIED BY ${escapedPassword}`
|
|
839
|
+
)
|
|
840
|
+
|
|
841
|
+
await connection.query(
|
|
842
|
+
`GRANT ALL PRIVILEGES ON ${escapedDatabase}.* ` +
|
|
843
|
+
`TO ${escapedUsername}@'%'`
|
|
844
|
+
)
|
|
845
|
+
|
|
846
|
+
await connection.query(
|
|
847
|
+
`USE ${escapedDatabase}`
|
|
848
|
+
)
|
|
849
|
+
|
|
850
|
+
const sqlPath = this.destinationPath(
|
|
851
|
+
'db.sql'
|
|
852
|
+
)
|
|
853
|
+
|
|
854
|
+
let sql = await fs.readFile(
|
|
855
|
+
sqlPath,
|
|
856
|
+
'utf8'
|
|
857
|
+
)
|
|
858
|
+
|
|
859
|
+
sql = this._substituteMarker(
|
|
860
|
+
sql,
|
|
861
|
+
'###ADMIN###',
|
|
862
|
+
this.props.User
|
|
863
|
+
)
|
|
864
|
+
|
|
865
|
+
const passwordHash = await argon2.hash(
|
|
866
|
+
this.props.Pass
|
|
867
|
+
)
|
|
868
|
+
|
|
869
|
+
sql = this._substituteMarker(
|
|
870
|
+
sql,
|
|
871
|
+
'###PASS###',
|
|
872
|
+
passwordHash
|
|
873
|
+
)
|
|
874
|
+
|
|
875
|
+
await connection.query(sql)
|
|
876
|
+
|
|
877
|
+
await fs.remove(sqlPath)
|
|
878
|
+
} finally {
|
|
879
|
+
await connection.end()
|
|
565
880
|
}
|
|
566
881
|
}
|
|
567
882
|
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
883
|
+
_substituteMarker (content, marker, replacement) {
|
|
884
|
+
return String(content)
|
|
885
|
+
.split(marker)
|
|
886
|
+
.join(String(replacement))
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
async _setRazorConfig () {
|
|
890
|
+
const config = {
|
|
891
|
+
siteName: this.props.ProjectName,
|
|
892
|
+
user: this.props.User,
|
|
893
|
+
adminEmail: this.props.AdminEmail,
|
|
894
|
+
english: this.props.English,
|
|
895
|
+
englishDefault: this.props.EnglishDefault,
|
|
896
|
+
author: this.props.Author,
|
|
897
|
+
email: this.props.Email,
|
|
898
|
+
website: this.props.Website,
|
|
899
|
+
copyright: this.props.Copyright,
|
|
900
|
+
fontawesome: this.props.FontAwesome,
|
|
901
|
+
cols: this.props.Cols,
|
|
902
|
+
htaccess: this.props.Htaccess,
|
|
903
|
+
smtpemail: this.props.SmtpEmail ?? '',
|
|
904
|
+
search: this.props.Search,
|
|
905
|
+
ssl: this.props.SSL
|
|
585
906
|
}
|
|
586
907
|
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
908
|
+
const plainHtaccess = this.destinationPath(
|
|
909
|
+
'_.htaccess-dev'
|
|
910
|
+
)
|
|
911
|
+
|
|
912
|
+
const sslHtaccess = this.destinationPath(
|
|
913
|
+
'_.htaccess-dev-ssl'
|
|
914
|
+
)
|
|
915
|
+
|
|
916
|
+
const targetHtaccess = this.destinationPath(
|
|
917
|
+
'.htaccess-dev'
|
|
918
|
+
)
|
|
919
|
+
|
|
920
|
+
if (!this.props.Htaccess) {
|
|
921
|
+
await fs.remove(plainHtaccess)
|
|
922
|
+
await fs.remove(sslHtaccess)
|
|
923
|
+
await fs.remove(targetHtaccess)
|
|
924
|
+
} else if (this.props.SSL) {
|
|
925
|
+
await fs.move(
|
|
926
|
+
sslHtaccess,
|
|
927
|
+
targetHtaccess,
|
|
928
|
+
{
|
|
929
|
+
overwrite: true
|
|
930
|
+
}
|
|
931
|
+
)
|
|
932
|
+
|
|
933
|
+
await fs.remove(plainHtaccess)
|
|
596
934
|
} else {
|
|
597
|
-
fs.
|
|
598
|
-
|
|
935
|
+
await fs.move(
|
|
936
|
+
plainHtaccess,
|
|
937
|
+
targetHtaccess,
|
|
938
|
+
{
|
|
939
|
+
overwrite: true
|
|
940
|
+
}
|
|
941
|
+
)
|
|
942
|
+
|
|
943
|
+
await fs.remove(sslHtaccess)
|
|
599
944
|
}
|
|
600
945
|
|
|
601
|
-
fs.
|
|
602
|
-
|
|
603
|
-
|
|
946
|
+
await fs.writeJson(
|
|
947
|
+
this.destinationPath('razor.json'),
|
|
948
|
+
config,
|
|
949
|
+
{
|
|
950
|
+
spaces: 2
|
|
604
951
|
}
|
|
952
|
+
)
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
async _runCommand (command, argumentsList) {
|
|
956
|
+
await new Promise((resolve, reject) => {
|
|
957
|
+
const child = spawn(
|
|
958
|
+
command,
|
|
959
|
+
argumentsList,
|
|
960
|
+
{
|
|
961
|
+
cwd: this.destinationRoot(),
|
|
962
|
+
env: process.env,
|
|
963
|
+
stdio: 'inherit'
|
|
964
|
+
}
|
|
965
|
+
)
|
|
966
|
+
|
|
967
|
+
let settled = false
|
|
968
|
+
|
|
969
|
+
child.once('error', error => {
|
|
970
|
+
if (settled) {
|
|
971
|
+
return
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
settled = true
|
|
975
|
+
|
|
976
|
+
if (error.code === 'ENOENT') {
|
|
977
|
+
reject(
|
|
978
|
+
new Error(
|
|
979
|
+
`Could not execute "${command}". ` +
|
|
980
|
+
'Make sure it is installed and available in PATH.',
|
|
981
|
+
{
|
|
982
|
+
cause: error
|
|
983
|
+
}
|
|
984
|
+
)
|
|
985
|
+
)
|
|
986
|
+
|
|
987
|
+
return
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
reject(error)
|
|
991
|
+
})
|
|
992
|
+
|
|
993
|
+
child.once('close', code => {
|
|
994
|
+
if (settled) {
|
|
995
|
+
return
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
settled = true
|
|
999
|
+
|
|
1000
|
+
if (code === 0) {
|
|
1001
|
+
resolve()
|
|
1002
|
+
return
|
|
1003
|
+
}
|
|
1004
|
+
|
|
1005
|
+
reject(
|
|
1006
|
+
new Error(
|
|
1007
|
+
`"${command}" exited with status code ${code}.`
|
|
1008
|
+
)
|
|
1009
|
+
)
|
|
1010
|
+
})
|
|
605
1011
|
})
|
|
606
1012
|
}
|
|
607
1013
|
}
|