generator-razor 14.0.11 → 14.0.12

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 +52 -70
  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
  }
@@ -387,19 +382,13 @@ export default class extends Generator {
387
382
  )
388
383
 
389
384
  if (await fs.pathExists(extensionsSource)) {
390
- await fs.copy(
385
+ await this._copyWithInheritedGroup(
391
386
  extensionsSource,
392
- this.destinationPath('typo3conf/ext'),
393
- {
394
- overwrite: true,
395
- errorOnExist: false
396
- }
387
+ this.destinationPath('typo3conf/ext')
397
388
  )
398
389
  }
399
390
  }
400
391
 
401
- await this._fixPackageStatesPermissions()
402
-
403
392
  const orange = chalk.hex('#ff8700').bold
404
393
  const petrol = chalk.hex('#006792')
405
394
 
@@ -417,6 +406,54 @@ export default class extends Generator {
417
406
  ))
418
407
  }
419
408
 
409
+ async _copyWithInheritedGroup (source, destination) {
410
+ const sourceStats = await fs.lstat(source)
411
+
412
+ if (sourceStats.isDirectory()) {
413
+ await fs.ensureDir(destination)
414
+
415
+ // Set setgid before creating anything inside this directory.
416
+ await fs.chmod(destination, 0o2775)
417
+
418
+ const entries = await fs.readdir(
419
+ source,
420
+ {
421
+ withFileTypes: true
422
+ }
423
+ )
424
+
425
+ for (const entry of entries) {
426
+ await this._copyWithInheritedGroup(
427
+ path.join(source, entry.name),
428
+ path.join(destination, entry.name)
429
+ )
430
+ }
431
+
432
+ return
433
+ }
434
+
435
+ if (sourceStats.isSymbolicLink()) {
436
+ const linkTarget = await fs.readlink(source)
437
+
438
+ await fs.remove(destination)
439
+ await fs.ensureSymlink(linkTarget, destination)
440
+
441
+ return
442
+ }
443
+
444
+ await fs.ensureDir(path.dirname(destination))
445
+
446
+ // The parent directory already has setgid, so a newly created file
447
+ // inherits its group.
448
+ await fs.copyFile(source, destination)
449
+
450
+ // Preserve the original file permissions without changing ownership.
451
+ await fs.chmod(
452
+ destination,
453
+ sourceStats.mode & 0o777
454
+ )
455
+ }
456
+
420
457
  async _getTypo3Releases () {
421
458
  const url = 'https://get.typo3.org/json'
422
459
 
@@ -781,46 +818,6 @@ export default class extends Generator {
781
818
  )
782
819
  }
783
820
 
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
821
  async _createDatabaseAndImportSql () {
825
822
  const databaseName = this.props.DbNew.toLowerCase()
826
823
 
@@ -1024,21 +1021,6 @@ export default class extends Generator {
1024
1021
  return `${packageName}@https://github.com/${owner}/${repository}/archive/refs/tags/${release.tag_name}.tar.gz`
1025
1022
  }
1026
1023
 
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
1024
  async _runCommand (command, argumentsList) {
1043
1025
  await new Promise((resolve, reject) => {
1044
1026
  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.12",
4
4
  "description": "Yeoman generator for razor TYPO3 distribution",
5
5
  "license": "MIT",
6
6
  "main": "app/index.js",