generator-razor 14.1.9 → 14.1.11
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 +47 -11
- package/package.json +1 -1
package/app/index.js
CHANGED
|
@@ -20,6 +20,48 @@ export default class extends Generator {
|
|
|
20
20
|
this.props = {}
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Yeoman stores global prompt answers in ~/.yo-rc-global.json under
|
|
25
|
+
* "<generator>:<version>", so every release starts with empty defaults.
|
|
26
|
+
* Use a version-independent key instead and migrate the answers from the
|
|
27
|
+
* newest versioned entry once, then drop the obsolete versioned entries.
|
|
28
|
+
*/
|
|
29
|
+
_getGlobalStorage () {
|
|
30
|
+
const storageDir = this.options.localConfigOnly ? this.destinationRoot() : os.homedir()
|
|
31
|
+
const storePath = path.join(storageDir, '.yo-rc-global.json')
|
|
32
|
+
const name = this.rootGeneratorName()
|
|
33
|
+
|
|
34
|
+
const rootStorage = this.createStorage(storePath, { allowOutsideRoot: true })
|
|
35
|
+
const storage = this.createStorage(storePath, { name, allowOutsideRoot: true })
|
|
36
|
+
|
|
37
|
+
const compareVersions = (a, b) => {
|
|
38
|
+
const pa = a.split('.').map(Number)
|
|
39
|
+
const pb = b.split('.').map(Number)
|
|
40
|
+
for (let i = 0; i < Math.max(pa.length, pb.length); i++) {
|
|
41
|
+
const diff = (pa[i] || 0) - (pb[i] || 0)
|
|
42
|
+
if (diff !== 0) return diff
|
|
43
|
+
}
|
|
44
|
+
return 0
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const versionedKeys = Object.keys(rootStorage.getAll())
|
|
48
|
+
.filter(key => key.startsWith(`${name}:`))
|
|
49
|
+
.sort((a, b) => compareVersions(a.slice(name.length + 1), b.slice(name.length + 1)))
|
|
50
|
+
|
|
51
|
+
if (versionedKeys.length > 0) {
|
|
52
|
+
if (!storage.get('promptValues')) {
|
|
53
|
+
const latest = rootStorage.get(versionedKeys[versionedKeys.length - 1])
|
|
54
|
+
if (latest?.promptValues) {
|
|
55
|
+
storage.set('promptValues', latest.promptValues)
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
versionedKeys.forEach(key => rootStorage.delete(key))
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return storage
|
|
63
|
+
}
|
|
64
|
+
|
|
23
65
|
async prompting () {
|
|
24
66
|
const orange = chalk.ansi256(208)
|
|
25
67
|
const petrol = chalk.ansi256(24)
|
|
@@ -197,21 +239,15 @@ export default class extends Generator {
|
|
|
197
239
|
type: 'select',
|
|
198
240
|
name: 'Encrypt',
|
|
199
241
|
message: 'SMTP encrypt?',
|
|
200
|
-
|
|
242
|
+
// Not stored on purpose: a saved answer would override the port-based default.
|
|
243
|
+
default: answers => /:465$/.test((answers.SmtpServer ?? '').trim()),
|
|
201
244
|
choices: [{
|
|
202
|
-
name: 'true (
|
|
245
|
+
name: 'true (implicit TLS / SMTPS, port 465)',
|
|
203
246
|
value: true
|
|
204
247
|
}, {
|
|
205
|
-
name: 'false (
|
|
248
|
+
name: 'false (plain, or STARTTLS if offered - ports 25, 587, 1025/Mailpit)',
|
|
206
249
|
value: false
|
|
207
|
-
}
|
|
208
|
-
name: 'ssl (TYPO3 9.5.x)',
|
|
209
|
-
value: 'ssl'
|
|
210
|
-
}, {
|
|
211
|
-
name: 'tls (TYPO3 9.5.x)',
|
|
212
|
-
value: 'tls'
|
|
213
|
-
}],
|
|
214
|
-
store: true
|
|
250
|
+
}]
|
|
215
251
|
}, {
|
|
216
252
|
when: answers => answers.Transport === 'smtp',
|
|
217
253
|
type: 'input',
|