generator-razor 14.0.11 → 14.0.13

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.
Files changed (2) hide show
  1. package/app/index.js +61 -65
  2. package/package.json +1 -1
package/app/index.js CHANGED
@@ -333,18 +333,13 @@ export default class extends Generator {
333
333
  await this._ensureTypo3Source(sourcePath)
334
334
  await this._createSymlinks(sourcePath)
335
335
 
336
- await fs.copy(
336
+ await this._copyWithInheritedGroup(
337
337
  this.templatePath(templateVersion),
338
- this.destinationPath(),
339
- {
340
- overwrite: true,
341
- errorOnExist: false
342
- }
338
+ this.destinationPath()
343
339
  )
344
340
 
345
341
  await this._writeSystemSettings()
346
342
  await this._writeLocalSettings()
347
- await this._chmodWritableDirectories()
348
343
  await this._createDatabaseAndImportSql()
349
344
  await this._setRazorConfig()
350
345
  }
@@ -392,14 +387,13 @@ export default class extends Generator {
392
387
  this.destinationPath('typo3conf/ext'),
393
388
  {
394
389
  overwrite: true,
395
- errorOnExist: false
390
+ errorOnExist: false,
391
+ dereference: false
396
392
  }
397
393
  )
398
394
  }
399
395
  }
400
396
 
401
- await this._fixPackageStatesPermissions()
402
-
403
397
  const orange = chalk.hex('#ff8700').bold
404
398
  const petrol = chalk.hex('#006792')
405
399
 
@@ -417,6 +411,63 @@ export default class extends Generator {
417
411
  ))
418
412
  }
419
413
 
414
+ async _copyWithInheritedGroup (source, destination) {
415
+ const sourceStats = await fs.lstat(source)
416
+
417
+ if (sourceStats.isDirectory()) {
418
+ await fs.ensureDir(destination)
419
+
420
+ // Files created afterwards inherit this directory's group.
421
+ await fs.chmod(destination, 0o2775)
422
+
423
+ const entries = await fs.readdir(
424
+ source,
425
+ {
426
+ withFileTypes: true
427
+ }
428
+ )
429
+
430
+ for (const entry of entries) {
431
+ await this._copyWithInheritedGroup(
432
+ path.join(source, entry.name),
433
+ path.join(destination, entry.name)
434
+ )
435
+ }
436
+
437
+ return
438
+ }
439
+
440
+ await fs.ensureDir(path.dirname(destination))
441
+
442
+ if (sourceStats.isSymbolicLink()) {
443
+ const linkTarget = await fs.readlink(source)
444
+
445
+ await fs.remove(destination)
446
+
447
+ // Preserve the relative link exactly as it exists in the template.
448
+ await fs.symlink(
449
+ linkTarget,
450
+ destination
451
+ )
452
+
453
+ return
454
+ }
455
+
456
+ // copyFile() would otherwise overwrite an existing inode and retain
457
+ // its previous group. Removing it first forces group inheritance.
458
+ await fs.remove(destination)
459
+
460
+ await fs.copyFile(
461
+ source,
462
+ destination
463
+ )
464
+
465
+ await fs.chmod(
466
+ destination,
467
+ sourceStats.mode & 0o777
468
+ )
469
+ }
470
+
420
471
  async _getTypo3Releases () {
421
472
  const url = 'https://get.typo3.org/json'
422
473
 
@@ -781,46 +832,6 @@ export default class extends Generator {
781
832
  )
782
833
  }
783
834
 
784
- async _chmodWritableDirectories () {
785
- const writableDirectories = [
786
- 'fileadmin',
787
- 'typo3temp',
788
- 'typo3conf'
789
- ]
790
-
791
- for (const directory of writableDirectories) {
792
- await this._chmodDirectoriesRecursive(
793
- this.destinationPath(directory)
794
- )
795
- }
796
- }
797
-
798
- async _chmodDirectoriesRecursive (directory) {
799
- if (!await fs.pathExists(directory)) {
800
- return
801
- }
802
-
803
- await fs.chmod(
804
- directory,
805
- 0o2775
806
- )
807
-
808
- const entries = await fs.readdir(
809
- directory,
810
- {
811
- withFileTypes: true
812
- }
813
- )
814
-
815
- for (const entry of entries) {
816
- if (entry.isDirectory()) {
817
- await this._chmodDirectoriesRecursive(
818
- path.join(directory, entry.name)
819
- )
820
- }
821
- }
822
- }
823
-
824
835
  async _createDatabaseAndImportSql () {
825
836
  const databaseName = this.props.DbNew.toLowerCase()
826
837
 
@@ -1024,21 +1035,6 @@ export default class extends Generator {
1024
1035
  return `${packageName}@https://github.com/${owner}/${repository}/archive/refs/tags/${release.tag_name}.tar.gz`
1025
1036
  }
1026
1037
 
1027
- async _fixPackageStatesPermissions () {
1028
- const file = this.destinationPath(
1029
- 'typo3conf/PackageStates.php'
1030
- )
1031
-
1032
- if (!await fs.pathExists(file)) {
1033
- return
1034
- }
1035
-
1036
- await this._runCommand('chgrp', [
1037
- 'developers',
1038
- file
1039
- ])
1040
- }
1041
-
1042
1038
  async _runCommand (command, argumentsList) {
1043
1039
  await new Promise((resolve, reject) => {
1044
1040
  const child = spawn(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "generator-razor",
3
- "version": "14.0.11",
3
+ "version": "14.0.13",
4
4
  "description": "Yeoman generator for razor TYPO3 distribution",
5
5
  "license": "MIT",
6
6
  "main": "app/index.js",