generator-razor 14.0.50 → 14.1.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.
Files changed (25) hide show
  1. package/app/index.js +480 -206
  2. package/app/templates/143/db.sql +33 -1
  3. package/app/templates/143/typo3conf/PackageStates.php +3 -0
  4. package/app/templates/143/typo3conf/system/settings.php +3 -7
  5. package/app/templates/143-composer/_.htaccess-dev +691 -0
  6. package/app/templates/143-composer/_.htaccess-dev-ssl +691 -0
  7. package/app/templates/143-composer/composer.json +94 -0
  8. package/app/templates/143-composer/config/system/settings.php +105 -0
  9. package/app/templates/143-composer/db.sql +1688 -0
  10. package/app/templates/143-composer/packages/razorbootstrap/composer.json +39 -0
  11. package/app/templates/143-composer/packages/razorbootstrap/ext_emconf.php +32 -0
  12. package/app/templates/143-composer/packages/razorkickstart/Classes/Command/InstallCommand.php +138 -0
  13. package/app/templates/143-composer/packages/razorkickstart/Classes/Command/PrepareCommand.php +81 -0
  14. package/app/templates/143-composer/packages/razorkickstart/Classes/Command/UpdateTerCommand.php +64 -0
  15. package/app/templates/143-composer/packages/razorkickstart/Configuration/Services.yaml +8 -0
  16. package/app/templates/143-composer/packages/razorkickstart/composer.json +31 -0
  17. package/app/templates/143-composer/public/fileadmin/.htaccess +37 -0
  18. package/app/templates/143-composer/public/fileadmin/_temp_/.htaccess +15 -0
  19. package/app/templates/143-composer/public/fileadmin/_temp_/index.html +7 -0
  20. package/app/templates/143-composer/public/fileadmin/user_upload/.htaccess +33 -0
  21. package/app/templates/143-composer/public/fileadmin/user_upload/_temp_/importexport/.htaccess +15 -0
  22. package/app/templates/143-composer/public/fileadmin/user_upload/_temp_/importexport/index.html +7 -0
  23. package/app/templates/143-composer/public/fileadmin/user_upload/_temp_/index.html +0 -0
  24. package/app/templates/143-composer/public/fileadmin/user_upload/index.html +0 -0
  25. package/package.json +1 -1
package/app/index.js CHANGED
@@ -50,6 +50,27 @@ export default class extends Generator {
50
50
  message: 'Choose your project name',
51
51
  default: 'Project'
52
52
  }, {
53
+ type: 'select',
54
+ name: 'ComposerMode',
55
+ message: 'Install TYPO3 in Composer mode?',
56
+ choices: [{
57
+ name: 'No',
58
+ value: false
59
+ }, {
60
+ name: 'Yes',
61
+ value: true
62
+ }],
63
+ default: false,
64
+ store: true
65
+ },{
66
+ type: 'input',
67
+ name: 'ComposerVendor',
68
+ message: 'Composer vendor:',
69
+ default: 'gg',
70
+ store: true,
71
+ when: answers => answers.ComposerMode === true
72
+ }, {
73
+ when: answers => !answers.ComposerMode,
53
74
  type: 'input',
54
75
  name: 'SrcPath',
55
76
  message: 'What is the path to the TYPO3 source files?',
@@ -318,6 +339,7 @@ export default class extends Generator {
318
339
  }],
319
340
  store: true
320
341
  }, {
342
+ when: answers => !answers.ComposerMode,
321
343
  type: 'select',
322
344
  name: 'Picture',
323
345
  message: 'Download TYPO3 picture extension?',
@@ -347,17 +369,23 @@ export default class extends Generator {
347
369
  async writing () {
348
370
  const templateVersion = this._getTemplateVersion()
349
371
 
350
- const sourcePath = path.resolve(
351
- this.destinationRoot(),
352
- this.props.SrcPath,
353
- `typo3_src-${this.props.Version}`
354
- )
372
+ if (!this.props.ComposerMode) {
373
+ const sourcePath = path.resolve(
374
+ this.destinationRoot(),
375
+ this.props.SrcPath,
376
+ `typo3_src-${this.props.Version}`
377
+ )
355
378
 
356
- await this._ensureTypo3Source(sourcePath)
357
- await this._createSymlinks(sourcePath)
379
+ await this._ensureTypo3Source(sourcePath)
380
+ await this._createSymlinks(sourcePath)
381
+ }
358
382
 
359
383
  await fs.copy(
360
- this.templatePath(templateVersion),
384
+ this.templatePath(
385
+ this.props.ComposerMode
386
+ ? `${templateVersion}-composer`
387
+ : templateVersion
388
+ ),
361
389
  this.destinationPath(),
362
390
  {
363
391
  overwrite: true,
@@ -365,19 +393,25 @@ export default class extends Generator {
365
393
  }
366
394
  )
367
395
 
396
+ if (this.props.ComposerMode) {
397
+ await this._prepareComposerJson()
398
+ }
399
+
368
400
  await this._writeSystemSettings()
369
401
  await this._createDatabaseAndImportSql()
370
- await this._setRazorConfig()
402
+ await this._setrazorConfig()
371
403
  }
372
404
 
373
405
  async install () {
374
- const branch = this._getRazorBranch()
406
+ const branch = this._getrazorBranch()
375
407
 
376
408
  const packages = [
377
- `ssh://git@github.com/rafu1987/razor.git#${branch}`
409
+ this.props.ComposerMode
410
+ ? `ssh://git@github.com/rafu1987/razorsite.git#${branch}`
411
+ : `ssh://git@github.com/rafu1987/razor.git#${branch}`
378
412
  ]
379
413
 
380
- if (this.props.Picture) {
414
+ if (!this.props.ComposerMode && this.props.Picture) {
381
415
  const picturePackage = await this._getLatestGithubReleasePackage(
382
416
  'b13',
383
417
  'picture',
@@ -387,40 +421,141 @@ export default class extends Generator {
387
421
  packages.push(picturePackage)
388
422
  }
389
423
 
424
+ /*
425
+ * Classic:
426
+ * razor is downloaded through Yarn to typo3conf/ext/razor.
427
+ *
428
+ * Composer:
429
+ * only razorsite is downloaded through Yarn to
430
+ * packages/razorsite.
431
+ */
390
432
  await this._runCommand('yarn', [
391
433
  'add',
392
434
  '--dev',
393
435
  '--no-lockfile',
394
436
  '--modules-folder',
395
- 'typo3conf/ext/',
437
+ this._getExtensionRootPath(),
396
438
  ...packages
397
439
  ])
440
+
441
+ if (this.props.ComposerMode) {
442
+ const razorsiteComposer = await fs.readJson(
443
+ this.destinationPath('packages/razorsite/composer.json')
444
+ )
445
+
446
+ const razorsiteVersion =
447
+ razorsiteComposer.extra['typo3/cms'].version
448
+
449
+ const composerPath = this.destinationPath('composer.json')
450
+ const composer = await fs.readJson(composerPath)
451
+
452
+ const pathRepository = composer.repositories.find(
453
+ repository =>
454
+ repository.type === 'path' &&
455
+ repository.url === 'packages/*'
456
+ )
457
+
458
+ pathRepository.options.versions['rafu1987/razorsite'] =
459
+ razorsiteVersion
460
+
461
+ await fs.writeJson(composerPath, composer, { spaces: 4 })
462
+ }
463
+
464
+ /*
465
+ * Classic:
466
+ * razor contains the other private razor extensions inside
467
+ * Initialisation/Extensions. Copy them to typo3conf/ext/.
468
+ */
469
+ if (!this.props.ComposerMode) {
470
+ if (this._usesModernTypo3Structure()) {
471
+ const extensionsSource = this.destinationPath(
472
+ this._getExtensionRootPath(),
473
+ 'razor',
474
+ 'Initialisation',
475
+ 'Extensions'
476
+ )
477
+
478
+ if (await fs.pathExists(extensionsSource)) {
479
+ await fs.copy(
480
+ extensionsSource,
481
+ this.destinationPath(
482
+ this._getExtensionRootPath()
483
+ ),
484
+ {
485
+ overwrite: true,
486
+ errorOnExist: false,
487
+ dereference: false
488
+ }
489
+ )
490
+ }
491
+ }
492
+
493
+ return
494
+ }
495
+
496
+ /*
497
+ * Composer:
498
+ * TYPO3, razor, the reusable razor extensions and all PHP
499
+ * dependencies are installed through the root Composer project.
500
+ *
501
+ * packages/razorsite already exists at this point and is
502
+ * resolved through the local path repository.
503
+ */
504
+ await this._runCommand(
505
+ 'composer',
506
+ [
507
+ 'update',
508
+ '--with',
509
+ `typo3/cms-core:${this.props.Version}`,
510
+ '--no-blocking',
511
+ '--prefer-dist',
512
+ '--no-interaction',
513
+ '--no-progress',
514
+ '--optimize-autoloader'
515
+ ]
516
+ )
398
517
  }
399
518
 
400
519
  async end () {
401
520
  const orange = chalk.ansi256(208)
402
521
  const petrol = chalk.ansi256(24)
403
-
404
- await fs.remove(
405
- this.destinationPath('package.json')
406
- )
522
+
523
+ // await fs.remove(
524
+ // this.destinationPath('package.json')
525
+ // )
407
526
 
408
527
  await fs.remove(
409
- this.destinationPath('typo3conf/ext/.yarn-integrity')
528
+ this.destinationPath(
529
+ this._getExtensionRootPath(),
530
+ '.yarn-integrity'
531
+ )
410
532
  )
411
533
 
412
534
  /*
413
- * Copy Razor extensions provided by the Razor repository.
414
- */
415
- if (this._usesModernTypo3Structure()) {
535
+ * Copy razor extensions provided by the razor repository.
536
+ *
537
+ * Composer mode already had to do this during install(),
538
+ * before Composer dependency resolution.
539
+ *
540
+ * Classic mode keeps the existing behaviour here.
541
+ */
542
+ if (
543
+ !this.props.ComposerMode &&
544
+ this._usesModernTypo3Structure()
545
+ ) {
416
546
  const extensionsSource = this.destinationPath(
417
- 'typo3conf/ext/razor/Initialisation/Extensions'
547
+ this._getExtensionRootPath(),
548
+ 'razor',
549
+ 'Initialisation',
550
+ 'Extensions'
418
551
  )
419
552
 
420
553
  if (await fs.pathExists(extensionsSource)) {
421
554
  await fs.copy(
422
555
  extensionsSource,
423
- this.destinationPath('typo3conf/ext'),
556
+ this.destinationPath(
557
+ this._getExtensionRootPath()
558
+ ),
424
559
  {
425
560
  overwrite: true,
426
561
  errorOnExist: false,
@@ -431,151 +566,169 @@ export default class extends Generator {
431
566
  }
432
567
 
433
568
  /*
434
- * Restore temporary extensions from generator templates.
435
- *
436
- * Yarn and Razor's Initialisation/Extensions may have modified
437
- * typo3conf/ext before this point.
438
- */
439
- const templateVersion = this._getTemplateVersion()
440
-
569
+ * Restore temporary extensions from generator templates.
570
+ *
571
+ * These are only required in Classic mode.
572
+ */
441
573
  const temporaryExtensions = [
442
574
  'razorkickstart',
443
575
  'razorbootstrap'
444
576
  ]
445
577
 
446
- for (const extension of temporaryExtensions) {
447
- const source = this.templatePath(
448
- templateVersion,
449
- `typo3conf/ext/${extension}`
450
- )
578
+ if (!this.props.ComposerMode) {
579
+ const templateVersion = this._getTemplateVersion()
451
580
 
452
- const destination = this.destinationPath(
453
- `typo3conf/ext/${extension}`
454
- )
581
+ for (const extension of temporaryExtensions) {
582
+ const source = this.templatePath(
583
+ templateVersion,
584
+ `typo3conf/ext/${extension}`
585
+ )
455
586
 
456
- await fs.remove(destination)
587
+ const destination = this.destinationPath(
588
+ this._getExtensionRootPath(),
589
+ extension
590
+ )
457
591
 
458
- await fs.copy(
459
- source,
460
- destination,
461
- {
462
- overwrite: true,
463
- errorOnExist: false,
464
- dereference: false
465
- }
466
- )
592
+ await fs.remove(destination)
467
593
 
468
- if (!await fs.pathExists(
469
- path.join(destination, 'composer.json')
470
- )) {
471
- throw new Error(
472
- `${extension} was not copied from the generator template.`
594
+ await fs.copy(
595
+ source,
596
+ destination,
597
+ {
598
+ overwrite: true,
599
+ errorOnExist: false,
600
+ dereference: false
601
+ }
473
602
  )
603
+
604
+ if (!await fs.pathExists(
605
+ path.join(destination, 'composer.json')
606
+ )) {
607
+ throw new Error(
608
+ `${extension} was not copied from the generator template.`
609
+ )
610
+ }
474
611
  }
475
612
  }
476
613
 
477
614
  await this._fixProjectGroup()
478
615
  await this._fixWritableDirectoryPermissions()
479
616
 
480
- const typo3 = this.destinationPath(
481
- 'typo3/sysext/core/bin/typo3'
482
- )
617
+ const typo3 = this._getTypo3Binary()
483
618
 
484
619
  /*
485
- * Start TYPO3 with completely fresh caches.
620
+ * Start TYPO3 with completely fresh filesystem caches.
621
+ *
622
+ * In Composer mode we must not run cache:flush before
623
+ * extension:setup because Composer-installed extensions are already
624
+ * active and may require database tables that do not exist yet.
486
625
  */
487
626
  this.log(orange(
488
- `→ Preparing TYPO3 caches...`
627
+ '→ Preparing TYPO3 caches...'
489
628
  ))
490
629
 
491
630
  await fs.remove(
492
- this.destinationPath('typo3temp/var/cache')
493
- )
494
-
495
- await this._runCommand(
496
- typo3,
497
- ['cache:flush']
631
+ this.destinationPath(
632
+ this._getCachePath()
633
+ )
498
634
  )
499
635
 
500
- /*
501
- * Activate Razor Kickstart.
502
- *
503
- * This extension has no external dependencies and provides
504
- * the TER update and installation commands.
505
- */
506
- this.log(orange(
507
- `→ Activating razor kickstart...`
508
- ))
509
-
510
- await this._runCommand(
511
- typo3,
512
- ['extension:activate', 'razorkickstart']
513
- )
636
+ if (!this.props.ComposerMode) {
637
+ await this._runCommand(
638
+ typo3,
639
+ ['cache:flush']
640
+ )
641
+ }
514
642
 
515
643
  /*
516
- * Update TER extension list.
517
- */
518
- this.log(orange(
519
- `→ Updating TER extension list...`
520
- ))
521
-
522
- await this._runCommand(
523
- typo3,
524
- ['razorkickstart:ter:update']
525
- )
644
+ * Classic mode still needs razor Kickstart to resolve TER
645
+ * dependencies and update PackageStates.php.
646
+ *
647
+ * Composer mode already resolved and installed all packages.
648
+ */
649
+ if (!this.props.ComposerMode) {
650
+ /*
651
+ * Activate razor Kickstart.
652
+ */
653
+ this.log(orange(
654
+ '→ Activating razor kickstart...'
655
+ ))
656
+
657
+ await this._runCommand(
658
+ typo3,
659
+ ['extension:activate', 'razorkickstart']
660
+ )
526
661
 
527
- /*
528
- * Resolve and download all missing TER dependencies.
529
- *
530
- * Nothing is activated by this command.
531
- */
532
- this.log(orange(
533
- `→ Preparing razor dependencies...`
534
- ))
662
+ /*
663
+ * Update TER extension list.
664
+ */
665
+ this.log(orange(
666
+ '→ Updating TER extension list...'
667
+ ))
535
668
 
536
- await this._runCommand(
537
- typo3,
538
- ['razorkickstart:prepare']
539
- )
669
+ await this._runCommand(
670
+ typo3,
671
+ ['razorkickstart:ter:update']
672
+ )
540
673
 
541
- /*
542
- * Activate all Razor packages in PackageStates.php.
543
- *
544
- * This command must only update package states. It must not
545
- * perform TCA loading or extension setup in this process.
546
- */
547
- this.log(orange(
548
- `→ Activating razor packages...`
549
- ))
674
+ /*
675
+ * Resolve and download all missing TER dependencies.
676
+ *
677
+ * Nothing is activated by this command.
678
+ */
679
+ this.log(orange(
680
+ '→ Preparing razor dependencies...'
681
+ ))
682
+
683
+ await this._runCommand(
684
+ typo3,
685
+ ['razorkickstart:prepare']
686
+ )
550
687
 
551
- await this._runCommand(
552
- typo3,
553
- ['razorkickstart:install']
554
- )
688
+ /*
689
+ * Activate all razor packages in PackageStates.php.
690
+ *
691
+ * This command must only update package states. It must not
692
+ * perform TCA loading or extension setup in this process.
693
+ */
694
+ this.log(orange(
695
+ '→ Activating razor packages...'
696
+ ))
697
+
698
+ await this._runCommand(
699
+ typo3,
700
+ ['razorkickstart:install']
701
+ )
555
702
 
556
- /*
557
- * All dependencies now exist physically and are active in
558
- * PackageStates.php.
559
- *
560
- * Remove the old DI/cache state before starting TYPO3 again.
561
- */
562
- this.log(orange(
563
- `→ Preparing TYPO3 for razor setup...`
564
- ))
703
+ /*
704
+ * All dependencies now exist physically and are active in
705
+ * PackageStates.php.
706
+ *
707
+ * Remove the old DI/cache state before starting TYPO3 again.
708
+ */
709
+ this.log(orange(
710
+ '→ Preparing TYPO3 for razor setup...'
711
+ ))
565
712
 
566
- await fs.remove(
567
- this.destinationPath('typo3temp/var/cache')
568
- )
713
+ await fs.remove(
714
+ this.destinationPath(
715
+ this._getCachePath()
716
+ )
717
+ )
718
+ }
569
719
 
570
720
  /*
571
- * Fresh TYPO3 process.
572
- *
573
- * All Razor dependencies are already active when TYPO3 boots,
574
- * so their services can participate in DI compilation before
575
- * extension initialization and TCA loading starts.
576
- */
721
+ * Fresh TYPO3 process.
722
+ *
723
+ * Classic:
724
+ * All razor dependencies are already active when TYPO3 boots.
725
+ *
726
+ * Composer:
727
+ * All razor dependencies are already installed and active
728
+ * through Composer.
729
+ */
577
730
  this.log(orange(
578
- `→ Setting up razor framework...`
731
+ '→ Setting up razor framework...'
579
732
  ))
580
733
 
581
734
  await this._runCommand(
@@ -584,80 +737,82 @@ export default class extends Generator {
584
737
  )
585
738
 
586
739
  /*
587
- * Razor's InstallService should have run during extension setup
588
- * and created razor.sh.
589
- */
740
+ * razor's InstallService should have run during extension setup
741
+ * and created razor.sh.
742
+ */
590
743
  const razorScript = this.destinationPath(
591
744
  'razor.sh'
592
745
  )
593
746
 
594
747
  if (!await fs.pathExists(razorScript)) {
595
748
  throw new Error(
596
- 'razor.sh was not created during Razor installation.'
749
+ 'razor.sh was not created during razor installation.'
597
750
  )
598
751
  }
599
752
 
600
753
  /*
601
- * Install razor Composer dependencies.
602
- *
603
- * InstallService copied composer.json and composer.lock to the
604
- * project root. Composer is configured to install them directly
605
- * into vendor-razor.
606
- */
607
- this.log(orange(
608
- '→ Installing razor PHP dependencies...'
609
- ))
610
-
611
- await this._runCommand(
612
- 'composer',
613
- [
614
- 'install',
615
- '--no-dev',
616
- '--prefer-dist',
617
- '--no-interaction',
618
- '--no-progress',
619
- '--optimize-autoloader'
620
- ]
621
- )
622
-
623
- const razorAutoloadFile = this.destinationPath(
624
- 'vendor-razor/autoload.php'
625
- )
754
+ * Classic mode still installs the standalone razor Composer
755
+ * dependencies into vendor-razor.
756
+ *
757
+ * Composer mode already installed these dependencies together
758
+ * with TYPO3 in vendor/.
759
+ */
760
+ if (!this.props.ComposerMode) {
761
+ this.log(orange(
762
+ '→ Installing razor PHP dependencies...'
763
+ ))
764
+
765
+ await this._runCommand(
766
+ 'composer',
767
+ [
768
+ 'install',
769
+ '--prefer-dist',
770
+ '--no-interaction',
771
+ '--no-progress',
772
+ '--optimize-autoloader'
773
+ ]
774
+ )
626
775
 
627
- if (!await fs.pathExists(razorAutoloadFile)) {
628
- throw new Error(
629
- 'razor Composer dependencies were installed, but ' +
630
- 'vendor-razor/autoload.php was not created.'
776
+ const razorAutoloadFile = this.destinationPath(
777
+ 'vendor-razor/autoload.php'
631
778
  )
632
- }
633
779
 
634
- /*
635
- * Remove temporary helper extensions.
636
- */
637
- this.log(orange(
638
- `→ Removing razor bootstrap...`
639
- ))
780
+ if (!await fs.pathExists(razorAutoloadFile)) {
781
+ throw new Error(
782
+ 'razor Composer dependencies were installed, but ' +
783
+ 'vendor-razor/autoload.php was not created.'
784
+ )
785
+ }
640
786
 
641
- await this._runCommand(
642
- typo3,
643
- ['extension:deactivate', 'razorbootstrap']
644
- )
787
+ /*
788
+ * Remove temporary helper extensions.
789
+ */
790
+ this.log(orange(
791
+ '→ Removing razor bootstrap...'
792
+ ))
645
793
 
646
- this.log(orange(
647
- `→ Removing razor kickstart...`
648
- ))
794
+ await this._runCommand(
795
+ typo3,
796
+ ['extension:deactivate', 'razorbootstrap']
797
+ )
649
798
 
650
- await this._runCommand(
651
- typo3,
652
- ['extension:deactivate', 'razorkickstart']
653
- )
799
+ this.log(orange(
800
+ '→ Removing razor kickstart...'
801
+ ))
654
802
 
655
- for (const extension of temporaryExtensions) {
656
- await fs.remove(
657
- this.destinationPath(
658
- `typo3conf/ext/${extension}`
659
- )
803
+ await this._runCommand(
804
+ typo3,
805
+ ['extension:deactivate', 'razorkickstart']
660
806
  )
807
+
808
+ for (const extension of temporaryExtensions) {
809
+ await fs.remove(
810
+ this.destinationPath(
811
+ this._getExtensionRootPath(),
812
+ extension
813
+ )
814
+ )
815
+ }
661
816
  }
662
817
 
663
818
  this.log(orange(`
@@ -674,8 +829,8 @@ export default class extends Generator {
674
829
  ))
675
830
 
676
831
  /*
677
- * Hand over to the Razor installer.
678
- */
832
+ * Hand over to the razor installer.
833
+ */
679
834
  this.log('→ Starting razor installer...')
680
835
 
681
836
  await this._runCommand(
@@ -720,12 +875,19 @@ export default class extends Generator {
720
875
  await processPath(destination)
721
876
  }
722
877
 
723
- async _fixWritableDirectoryPermissions() {
724
- const writableDirectories = [
725
- 'fileadmin',
726
- 'typo3temp',
727
- 'typo3conf'
728
- ]
878
+ async _fixWritableDirectoryPermissions () {
879
+ const writableDirectories = this.props.ComposerMode
880
+ ? [
881
+ 'public/fileadmin',
882
+ 'public/typo3temp',
883
+ 'var',
884
+ 'config'
885
+ ]
886
+ : [
887
+ 'fileadmin',
888
+ 'typo3temp',
889
+ 'typo3conf'
890
+ ]
729
891
 
730
892
  for (const directory of writableDirectories) {
731
893
  await this._chmodDirectoriesRecursive(
@@ -734,7 +896,7 @@ export default class extends Generator {
734
896
  }
735
897
  }
736
898
 
737
- async _chmodDirectoriesRecursive(directory) {
899
+ async _chmodDirectoriesRecursive (directory) {
738
900
  if (!await fs.pathExists(directory)) {
739
901
  return
740
902
  }
@@ -850,7 +1012,7 @@ export default class extends Generator {
850
1012
  )
851
1013
  }
852
1014
 
853
- _getRazorBranch () {
1015
+ _getrazorBranch () {
854
1016
  if (this.props.Version.startsWith('14.3.')) {
855
1017
  return 'razor14-dev'
856
1018
  }
@@ -864,7 +1026,7 @@ export default class extends Generator {
864
1026
  }
865
1027
 
866
1028
  throw new Error(
867
- `No Razor branch configured for TYPO3 ${this.props.Version}`
1029
+ `No razor branch configured for TYPO3 ${this.props.Version}`
868
1030
  )
869
1031
  }
870
1032
 
@@ -874,6 +1036,108 @@ export default class extends Generator {
874
1036
  this.props.Version.startsWith('14.3.')
875
1037
  }
876
1038
 
1039
+ _getConfigPath () {
1040
+ return this.props.ComposerMode
1041
+ ? 'config'
1042
+ : 'typo3conf'
1043
+ }
1044
+
1045
+ _getPublicPath () {
1046
+ return this.props.ComposerMode
1047
+ ? 'public'
1048
+ : ''
1049
+ }
1050
+
1051
+ _getExtensionRootPath () {
1052
+ return this.props.ComposerMode
1053
+ ? 'packages'
1054
+ : 'typo3conf/ext'
1055
+ }
1056
+
1057
+ _getCachePath () {
1058
+ return this.props.ComposerMode
1059
+ ? 'var/cache'
1060
+ : 'typo3temp/var/cache'
1061
+ }
1062
+
1063
+ _getTypo3Binary () {
1064
+ return this.props.ComposerMode
1065
+ ? this.destinationPath('vendor/bin/typo3')
1066
+ : this.destinationPath('typo3/sysext/core/bin/typo3')
1067
+ }
1068
+
1069
+ async _prepareComposerJson () {
1070
+ const composerPath = this.destinationPath(
1071
+ 'composer.json'
1072
+ )
1073
+
1074
+ if (!await fs.pathExists(composerPath)) {
1075
+ throw new Error(
1076
+ 'Composer mode was selected, but the template did not ' +
1077
+ 'provide a composer.json file.'
1078
+ )
1079
+ }
1080
+
1081
+ let content = await fs.readFile(
1082
+ composerPath,
1083
+ 'utf8'
1084
+ )
1085
+
1086
+ const typo3Constraint = `^${this.props.Version}`
1087
+
1088
+ content = this._substituteMarker(
1089
+ content,
1090
+ '###TYPO3_VERSION###',
1091
+ typo3Constraint
1092
+ )
1093
+
1094
+ let composer
1095
+
1096
+ try {
1097
+ composer = JSON.parse(content)
1098
+ } catch (error) {
1099
+ throw new Error(
1100
+ `The generated composer.json is invalid: ${error.message}`,
1101
+ {
1102
+ cause: error
1103
+ }
1104
+ )
1105
+ }
1106
+
1107
+ const packageName = this.props.ProjectName
1108
+ .toLowerCase()
1109
+ .trim()
1110
+ .replace(/[^a-z0-9]+/g, '-')
1111
+ .replace(/^-+|-+$/g, '')
1112
+
1113
+ composer.name =
1114
+ `${this.props.ComposerVendor}/${packageName}`
1115
+
1116
+ composer.description =
1117
+ `${this.props.ProjectName} TYPO3 project`
1118
+
1119
+ /*
1120
+ * indexed_search is optional and controlled by the Search prompt.
1121
+ *
1122
+ * In Composer mode the extension must be installed through
1123
+ * Composer instead of extension:activate.
1124
+ */
1125
+ if (this.props.Search) {
1126
+ composer.require['typo3/cms-indexed-search'] =
1127
+ typo3Constraint
1128
+ } else {
1129
+ delete composer.require['typo3/cms-indexed-search']
1130
+ }
1131
+
1132
+ await fs.writeJson(
1133
+ composerPath,
1134
+ composer,
1135
+ {
1136
+ spaces: 4
1137
+ }
1138
+ )
1139
+ }
1140
+
877
1141
  async _ensureTypo3Source (sourcePath) {
878
1142
  if (await fs.pathExists(sourcePath)) {
879
1143
  this.log(
@@ -1013,7 +1277,8 @@ export default class extends Generator {
1013
1277
 
1014
1278
  async _writeSystemSettings () {
1015
1279
  const settingsPath = this.destinationPath(
1016
- 'typo3conf/system/settings.php'
1280
+ this._getConfigPath(),
1281
+ 'system/settings.php'
1017
1282
  )
1018
1283
 
1019
1284
  let content = await fs.readFile(
@@ -1164,8 +1429,11 @@ export default class extends Generator {
1164
1429
  .join(String(replacement))
1165
1430
  }
1166
1431
 
1167
- async _setRazorConfig () {
1168
- const devDomain = process.env.DEV_DOMAIN ?? ''
1432
+ async _setrazorConfig () {
1433
+ const devDomain = this.props.ComposerMode
1434
+ ? process.env.DEV_COMPOSER_DOMAIN ?? ''
1435
+ : process.env.DEV_DOMAIN ?? ''
1436
+
1169
1437
  const projectName = path.basename(this.destinationRoot())
1170
1438
 
1171
1439
  const config = {
@@ -1193,7 +1461,8 @@ export default class extends Generator {
1193
1461
  smtpEmail: this.props.SmtpEmail ?? '',
1194
1462
  smtpName: this.props.SmtpName ?? '',
1195
1463
  search: this.props.Search,
1196
- ssl: this.props.SSL
1464
+ ssl: this.props.SSL,
1465
+ composerMode: this.props.ComposerMode
1197
1466
  }
1198
1467
 
1199
1468
  const plainHtaccess = this.destinationPath(
@@ -1204,9 +1473,14 @@ export default class extends Generator {
1204
1473
  '_.htaccess-dev-ssl'
1205
1474
  )
1206
1475
 
1207
- const targetHtaccess = this.destinationPath(
1208
- '.htaccess-dev'
1209
- )
1476
+ const targetHtaccess = this.props.ComposerMode
1477
+ ? this.destinationPath(
1478
+ 'public',
1479
+ '.htaccess-dev'
1480
+ )
1481
+ : this.destinationPath(
1482
+ '.htaccess-dev'
1483
+ )
1210
1484
 
1211
1485
  if (!this.props.Htaccess) {
1212
1486
  await fs.remove(plainHtaccess)