Skip to content

Commit

Permalink
refactor: update Taskfile
Browse files Browse the repository at this point in the history
  • Loading branch information
hendrikbehncke committed Jul 30, 2024
1 parent 1135186 commit 6867cfa
Show file tree
Hide file tree
Showing 3 changed files with 124 additions and 44 deletions.
10 changes: 9 additions & 1 deletion src/CreatePluginCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$variables = [
'NAME' => $name,
'PLUGIN' => $name,
'PLUGIN_CLASS' => 'plgSystem' . strtr($name, ['-' => '', '_' => '']),
'PLUGIN_CLASS' => 'plgSystem' . ucfirst(strtr($name, ['-' => '', '_' => ''])),
'TITLE' => $ask(new Question('Enter plugin title: ', $name)),
];

Expand All @@ -63,6 +63,14 @@ protected function execute(InputInterface $input, OutputInterface $output): int
);
}

if ($ask(new Question('Do you want to create a module?', 'yes')) === 'yes') {
$finder = (new Finder())->in("{$this->stubs}/module");

foreach ($finder->files() as $file) {
$fs->dumpFile("{$file->getRelativePathname()}", $file->getContents());
}
}

$output->writeln("Plugin '{$name}' created successfully.");

return Command::SUCCESS;
Expand Down
19 changes: 19 additions & 0 deletions src/stubs/module/bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

use YOOtheme\Builder;
use YOOtheme\Path;

return [
// Set theme configuration values
'theme' => [],

// Register event handlers
'events' => [],

// Load builder elements
'extend' => [
Builder::class => function (Builder $builder) {
$builder->addTypePath(Path::get('./elements/*/element.json'));
},
],
];
139 changes: 96 additions & 43 deletions src/stubs/plugin/Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,85 @@ vars:
AUTHORURL: '{{ AUTHORURL }}'

tasks:
copy-joomla:
internal: true
build:
deps:
- for: [joomla, wordpress]
task: build-{{ .ITEM }}

build-joomla:
cmds:
- task: utils:copy
vars:
cwd: build/joomla
src: '**'
dest: dist/joomla

- task: copy-module
vars:
SYSTEM: joomla

- task: copy-elements
vars:
SYSTEM: joomla

- task: placeholder-joomla

- task: utils:zip
vars:
cwd: dist/joomla
src: '**'
dest: dist/{{ .NAME }}-{{ .VERSION }}.zip

#- defer:
# task: clear-dist-joomla

build-wordpress:
cmds:
- task: utils:copy
vars:
cwd: build/wordpress
src: '*.php'
dest: dist/wordpress

- task: copy-module
vars:
SYSTEM: wordpress

- task: copy-elements
vars:
SYSTEM: wordpress

- task: placeholder-wordpress

- task: utils:zip
vars:
cwd: dist/wordpress
src: '**'
dest: dist/wp-{{ .NAME }}-{{ .VERSION }}.zip

- defer:
task: clear-dist-wordpress

copy-module:
internal: true
cmds:
- task: utils:copy
vars:
src: 'bootstrap.php'
dest: dist/{{ .SYSTEM }}

copy-elements:
internal: true
cmds:
- task: utils:copy
vars:
cwd: elements
src: '**'
dest: dist/{{ .SYSTEM }}/elements

placeholder-joomla:
internal: true
cmds:
- task: utils:placeholder
vars:
src: 'dist/joomla/**/*.xml'
Expand All @@ -40,15 +110,9 @@ tasks:
"NAME" "{{ .NAME }}"
"VERSION" "{{ .VERSION }}"
copy-wordpress:
placeholder-wordpress:
internal: true
cmds:
- task: utils:copy
vars:
cwd: build/wordpress
src: '*.php'
dest: dist/wordpress

- task: utils:placeholder
vars:
src: dist/wordpress/{{ .NAME }}.php
Expand All @@ -65,65 +129,54 @@ tasks:
"NAME" "{{ .NAME }}"
"VERSION" "{{ .VERSION }}"
remove-dist-joomla:
clear-dist-joomla:
internal: true
cmds:
- task: utils:remove
vars:
src: dist/joomla

remove-dist-wordpress:
clear-dist-wordpress:
internal: true
cmds:
- task: utils:remove
vars:
src: dist/wordpress

build-joomla:
deps:
- copy-joomla
cmds:
- task: utils:zip
vars:
cwd: dist/joomla
src: '**'
dest: dist/{{ .NAME }}-{{ .VERSION }}.zip
- defer:
task: remove-dist-joomla

build-wordpress:
deps:
- copy-wordpress
setup-joomla:
cmds:
- task: utils:zip
- task: utils:copy
vars:
cwd: dist/wordpress
cwd: build/joomla
src: '**'
dest: dist/wp-{{ .NAME }}-{{ .VERSION }}.zip
- defer:
task: remove-dist-wordpress
dest: dist/joomla

build:
deps:
- build-joomla
- build-wordpress
- task: placeholder-joomla

setup-joomla:
deps:
- copy-dist-joomla
cmds:
- task: utils:copy
vars:
cwd: dist/joomla
src: '**'
dest: ../joomla/plugins
dest: ./

- defer:
task: clear-dist-joomla

setup-wordpress:
deps:
- copy-dist-wordpress
cmds:
- task: utils:copy
vars:
cwd: build/wordpress
src: '*.php'
dest: dist/wordpress

- task: placeholder-wordpress

- task: utils:copy
vars:
cwd: dist/wordpress
src: '**'
dest: ../wordpress/wp-content/plugins
dest: ./

- defer:
task: clear-dist-wordpress

0 comments on commit 6867cfa

Please sign in to comment.