diff --git a/src/CreatePluginCommand.php b/src/CreatePluginCommand.php index 922e722..3d9a1ac 100644 --- a/src/CreatePluginCommand.php +++ b/src/CreatePluginCommand.php @@ -29,7 +29,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int $cwd = getcwd(); $name = $input->getArgument('name'); - $path = Path::join($cwd, 'build'); $fn = [$this->getHelper('question'), 'ask']; $ask = $this->partial($fn, $input, $output); @@ -47,10 +46,20 @@ protected function execute(InputInterface $input, OutputInterface $output): int 'TITLE' => $ask(new Question('Enter plugin title: ', $name)), ]; + $questions = $variables + [ + 'DESCRIPTION' => $ask(new Question('Enter plugin description: ')), + 'AUTHOR' => $ask(new Question('Enter author name: ')), + 'AUTHOREMAIL' => $ask(new Question('Enter author email: ')), + 'AUTHORURL' => $ask(new Question('Enter author url: ')), + ]; + foreach ($finder->files() as $file) { $fs->dumpFile( - strtr("{$path}/{$file->getRelativePathname()}", $filemap), - Str::placeholder($file->getContents(), $variables), + strtr("{$cwd}/{$file->getRelativePathname()}", $filemap), + Str::placeholder( + $file->getContents(), + $file->getBasename() === 'Taskfile.yml' ? $questions : $variables, + ), ); } diff --git a/src/stubs/plugin/Taskfile.yml b/src/stubs/plugin/Taskfile.yml new file mode 100644 index 0000000..f638c5e --- /dev/null +++ b/src/stubs/plugin/Taskfile.yml @@ -0,0 +1,129 @@ +version: '3' + +includes: + utils: vendor/yootheme/starter-utils + +vars: + NAME: '{{ TITLE }}' + VERSION: '0.0.1' + DESCRIPTION: '{{ DESCRIPTION }}' + DATE: '{{ now | date "2006-01-02" }}' + COPYRIGHT: 'Copyright (C)' + LICENSE: 'GNU General Public License' + AUTHOR: '{{ AUTHOR }}' + AUTHOREMAIL: '{{ AUTHOREMAIL }}' + AUTHORURL: '{{ AUTHORURL }}' + +tasks: + copy-joomla: + internal: true + cmds: + - task: utils:copy + vars: + cwd: build/joomla + src: '**' + dest: dist/joomla + + - task: utils:placeholder + vars: + src: 'dist/joomla/**/*.xml' + replace: + ref: > + dict + "AUTHOR" "{{ .AUTHOR }}" + "AUTHOREMAIL" "{{ .AUTHOREMAIL }}" + "AUTHORURL" "{{ .AUTHORURL }}" + "COPYRIGHT" "{{ .COPYRIGHT }}" + "DATE" "{{ .DATE }}" + "DESCRIPTION" "{{ .DESCRIPTION }}" + "LICENSE" "{{ .LICENSE }}" + "NAME" "{{ .NAME }}" + "VERSION" "{{ .VERSION }}" + + copy-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 + replace: + ref: > + dict + "AUTHOR" "{{ .AUTHOR }}" + "AUTHOREMAIL" "{{ .AUTHOREMAIL }}" + "AUTHORURL" "{{ .AUTHORURL }}" + "COPYRIGHT" "{{ .COPYRIGHT }}" + "DATE" "{{ .DATE }}" + "DESCRIPTION" "{{ .DESCRIPTION }}" + "LICENSE" "{{ .LICENSE }}" + "NAME" "{{ .NAME }}" + "VERSION" "{{ .VERSION }}" + + remove-dist-joomla: + internal: true + cmds: + - task: utils:remove + vars: + src: dist/joomla + + remove-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 + cmds: + - task: utils:zip + vars: + cwd: dist/wordpress + src: '**' + dest: dist/wp-{{ .NAME }}-{{ .VERSION }}.zip + - defer: + task: remove-dist-wordpress + + build: + deps: + - build-joomla + - build-wordpress + + setup-joomla: + deps: + - copy-dist-joomla + cmds: + - task: utils:copy + vars: + cwd: dist/joomla + src: '**' + dest: ../joomla/plugins + + setup-wordpress: + deps: + - copy-dist-wordpress + cmds: + - task: utils:copy + vars: + cwd: dist/wordpress + src: '**' + dest: ../wordpress/wp-content/plugins diff --git a/src/stubs/plugin/joomla/plugin.stub b/src/stubs/plugin/build/joomla/plugin.stub similarity index 100% rename from src/stubs/plugin/joomla/plugin.stub rename to src/stubs/plugin/build/joomla/plugin.stub diff --git a/src/stubs/plugin/joomla/plugin.xml b/src/stubs/plugin/build/joomla/plugin.xml similarity index 100% rename from src/stubs/plugin/joomla/plugin.xml rename to src/stubs/plugin/build/joomla/plugin.xml diff --git a/src/stubs/plugin/wordpress/plugin.stub b/src/stubs/plugin/build/wordpress/plugin.stub similarity index 100% rename from src/stubs/plugin/wordpress/plugin.stub rename to src/stubs/plugin/build/wordpress/plugin.stub