Skip to content

Commit

Permalink
Add composer.json
Browse files Browse the repository at this point in the history
  • Loading branch information
michielgerritsen committed Jun 26, 2024
1 parent fcc86bb commit 6c297f1
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 5 deletions.
24 changes: 24 additions & 0 deletions assets/stubs/composer.json.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "{{ VendorName }}/{{ ModuleName}}",
"authors": [
{
"name": "{{ VendorName }}",
"email": "[email protected]"
},
{
"name": "model-generator.com",
"email": "[email protected]"
}
],
"require": {
"php": "~8.1"
},
"autoload": {
"files": [
"src/registration.php"
],
"psr-4": {
"{{ VendorName }}\\{{ ModuleName }}\\": "src/"
}
}
}
15 changes: 10 additions & 5 deletions components/TopSidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,20 @@ const children = computed(() => {
})
const order = Object.keys(output.Children).sort();
// Registration.php should be the last file
const index = order.indexOf('registration.php');
if (index !== -1) {
order.push(order.splice(index, 1)[0]);
}
// Registration.php and composer.json should be the last files
moveFileDown(order, 'composer.json');
moveFileDown(order, 'registration.php');
return order.map(key => output.Children[key])
})
const moveFileDown = (order, fileName) => {
const index = order.indexOf(fileName);
if (index !== -1) {
order.push(order.splice(index, 1)[0]);
}
}
const includeNonMergable = computed({
get: () => downloadStore.includeNonMergable,
set: (value) => downloadStore.setIncludeNonMergable(value)
Expand Down
1 change: 1 addition & 0 deletions output/FileList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export default class FileList extends StateAware {
if (this.includeModuleRegistration()) {
files.push(new GeneratedFile('etc/module.xml.stub'))
files.push(new GeneratedFile('registration.php.stub'))
files.push(new GeneratedFile('composer.json.stub'))
}

if (this.includeDataModels()) {
Expand Down
3 changes: 3 additions & 0 deletions output/GeneratedFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import ModelResourceModelModelNamePhpStub from '@/assets/stubs/Model/ResourceMod
import ModelResourceModelModelNameCollectionPhpStub from '@/assets/stubs/Model/ResourceModel/ModelName/Collection.php.stub?raw'
import etcmoduleXmlStub from '@/assets/stubs/etc/module.xml.stub?raw'
import registrationPhpStub from '@/assets/stubs/registration.php.stub?raw'
import composerjsonstub from '@/assets/stubs/composer.json.stub?raw'
import ModelModelNameRepositoryWithDataModelPhpStub from '@/assets/stubs/Model/ModelNameRepositoryWithDataModel.php.stub?raw'
import ModelModelNameWithDataModelPhpStub from '@/assets/stubs/Model/ModelNameWithDataModel.php.stub?raw'
import ModelModelNameRepositoryWithoutDataModelPhpStub from '@/assets/stubs/Model/ModelNameRepositoryWithoutDataModel.php.stub?raw'
Expand Down Expand Up @@ -82,6 +83,7 @@ export default class GeneratedFile extends StateAware implements GeneratesFileIn
'Model/ResourceModel/ModelName/Collection.php.stub': ModelResourceModelModelNameCollectionPhpStub,
'etc/module.xml.stub': etcmoduleXmlStub,
'registration.php.stub': registrationPhpStub,
'composer.json.stub': composerjsonstub,
'Model/ModelNameRepositoryWithDataModel.php.stub': ModelModelNameRepositoryWithDataModelPhpStub,
'Model/ModelNameWithDataModel.php.stub': ModelModelNameWithDataModelPhpStub,
'Model/ModelNameRepositoryWithoutDataModel.php.stub': ModelModelNameRepositoryWithoutDataModelPhpStub,
Expand Down Expand Up @@ -125,6 +127,7 @@ export default class GeneratedFile extends StateAware implements GeneratesFileIn

isMergeable(): boolean {
return ![
'composer.json.stub',
'registration.php',
'etc/acl.xml',
'etc/di.xml',
Expand Down

0 comments on commit 6c297f1

Please sign in to comment.