From caf5a6f15ee95fbfda13e899b74625e2837d51cb Mon Sep 17 00:00:00 2001 From: Josh Torres Date: Wed, 4 Oct 2023 16:15:23 -0700 Subject: [PATCH] - add initial config - add files from forms module --- config/catalyst-forms-plugin.php | 6 + ...reate_catalyst_forms_plugin_table.php.stub | 19 +++ resources/lang/en/catalyst-forms-plugin.php | 6 + src/CatalystFormsPlugin.php | 7 + src/CatalystFormsPluginPlugin.php | 37 +++++ src/CatalystFormsPluginServiceProvider.php | 154 ++++++++++++++++++ src/Commands/CatalystFormsPluginCommand.php | 19 +++ src/Facades/CatalystFormsPlugin.php | 16 ++ src/Testing/TestsCatalystFormsPlugin.php | 13 ++ 9 files changed, 277 insertions(+) create mode 100644 config/catalyst-forms-plugin.php create mode 100644 database/migrations/create_catalyst_forms_plugin_table.php.stub create mode 100644 resources/lang/en/catalyst-forms-plugin.php create mode 100644 src/CatalystFormsPlugin.php create mode 100644 src/CatalystFormsPluginPlugin.php create mode 100644 src/CatalystFormsPluginServiceProvider.php create mode 100644 src/Commands/CatalystFormsPluginCommand.php create mode 100644 src/Facades/CatalystFormsPlugin.php create mode 100644 src/Testing/TestsCatalystFormsPlugin.php diff --git a/config/catalyst-forms-plugin.php b/config/catalyst-forms-plugin.php new file mode 100644 index 0000000..c1a8e7a --- /dev/null +++ b/config/catalyst-forms-plugin.php @@ -0,0 +1,6 @@ +id(); + + // add fields + + $table->timestamps(); + }); + } +}; diff --git a/resources/lang/en/catalyst-forms-plugin.php b/resources/lang/en/catalyst-forms-plugin.php new file mode 100644 index 0000000..f207df2 --- /dev/null +++ b/resources/lang/en/catalyst-forms-plugin.php @@ -0,0 +1,6 @@ +getId()); + + return $plugin; + } +} diff --git a/src/CatalystFormsPluginServiceProvider.php b/src/CatalystFormsPluginServiceProvider.php new file mode 100644 index 0000000..a27bd02 --- /dev/null +++ b/src/CatalystFormsPluginServiceProvider.php @@ -0,0 +1,154 @@ +name(static::$name) + ->hasCommands($this->getCommands()) + ->hasInstallCommand(function (InstallCommand $command) { + $command + ->publishConfigFile() + ->publishMigrations() + ->askToRunMigrations() + ->askToStarRepoOnGitHub('omnia-digital/catalyst-forms-plugin'); + }); + + $configFileName = $package->shortName(); + + if (file_exists($package->basePath("/../config/{$configFileName}.php"))) { + $package->hasConfigFile(); + } + + if (file_exists($package->basePath('/../database/migrations'))) { + $package->hasMigrations($this->getMigrations()); + } + + if (file_exists($package->basePath('/../resources/lang'))) { + $package->hasTranslations(); + } + + if (file_exists($package->basePath('/../resources/views'))) { + $package->hasViews(static::$viewNamespace); + } + } + + public function packageRegistered(): void + { + } + + public function packageBooted(): void + { + // Asset Registration + FilamentAsset::register( + $this->getAssets(), + $this->getAssetPackageName() + ); + + FilamentAsset::registerScriptData( + $this->getScriptData(), + $this->getAssetPackageName() + ); + + // Icon Registration + FilamentIcon::register($this->getIcons()); + + // Handle Stubs + if (app()->runningInConsole()) { + foreach (app(Filesystem::class)->files(__DIR__ . '/../stubs/') as $file) { + $this->publishes([ + $file->getRealPath() => base_path("stubs/catalyst-forms-plugin/{$file->getFilename()}"), + ], 'catalyst-forms-plugin-stubs'); + } + } + + // Testing + Testable::mixin(new TestsCatalystFormsPlugin()); + } + + protected function getAssetPackageName(): ?string + { + return 'omnia-digital/catalyst-forms-plugin'; + } + + /** + * @return array + */ + protected function getAssets(): array + { + return [ + // AlpineComponent::make('catalyst-forms-plugin', __DIR__ . '/../resources/dist/components/catalyst-forms-plugin.js'), + Css::make('catalyst-forms-plugin-styles', __DIR__ . '/../resources/dist/catalyst-forms-plugin.css'), + Js::make('catalyst-forms-plugin-scripts', __DIR__ . '/../resources/dist/catalyst-forms-plugin.js'), + ]; + } + + /** + * @return array + */ + protected function getCommands(): array + { + return [ + CatalystFormsPluginCommand::class, + ]; + } + + /** + * @return array + */ + protected function getIcons(): array + { + return []; + } + + /** + * @return array + */ + protected function getRoutes(): array + { + return []; + } + + /** + * @return array + */ + protected function getScriptData(): array + { + return []; + } + + /** + * @return array + */ + protected function getMigrations(): array + { + return [ + 'create_catalyst-forms-plugin_table', + ]; + } +} diff --git a/src/Commands/CatalystFormsPluginCommand.php b/src/Commands/CatalystFormsPluginCommand.php new file mode 100644 index 0000000..4e0c422 --- /dev/null +++ b/src/Commands/CatalystFormsPluginCommand.php @@ -0,0 +1,19 @@ +comment('All done'); + + return self::SUCCESS; + } +} diff --git a/src/Facades/CatalystFormsPlugin.php b/src/Facades/CatalystFormsPlugin.php new file mode 100644 index 0000000..ea427a4 --- /dev/null +++ b/src/Facades/CatalystFormsPlugin.php @@ -0,0 +1,16 @@ +