diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..b2e2ee1 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,7 @@ +# Changelog + +All notable changes to `filament-product` will be documented in this file. + +## 1.0.0 - 202X-XX-XX + +- initial release diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..01818cb --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) red-jasmine + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..2fd6e11 --- /dev/null +++ b/README.md @@ -0,0 +1,78 @@ +# This is my package filament-product + +[![Latest Version on Packagist](https://img.shields.io/packagist/v/red-jasmine/filament-product.svg?style=flat-square)](https://packagist.org/packages/red-jasmine/filament-product) +[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/red-jasmine/filament-product/run-tests.yml?branch=main&label=tests&style=flat-square)](https://github.com/red-jasmine/filament-product/actions?query=workflow%3Arun-tests+branch%3Amain) +[![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/red-jasmine/filament-product/fix-php-code-styling.yml?branch=main&label=code%20style&style=flat-square)](https://github.com/red-jasmine/filament-product/actions?query=workflow%3A"Fix+PHP+code+styling"+branch%3Amain) +[![Total Downloads](https://img.shields.io/packagist/dt/red-jasmine/filament-product.svg?style=flat-square)](https://packagist.org/packages/red-jasmine/filament-product) + + + +This is where your description should go. Limit it to a paragraph or two. Consider adding a small example. + +## Installation + +You can install the package via composer: + +```bash +composer require red-jasmine/filament-product +``` + +You can publish and run the migrations with: + +```bash +php artisan vendor:publish --tag="filament-product-migrations" +php artisan migrate +``` + +You can publish the config file with: + +```bash +php artisan vendor:publish --tag="filament-product-config" +``` + +Optionally, you can publish the views using + +```bash +php artisan vendor:publish --tag="filament-product-views" +``` + +This is the contents of the published config file: + +```php +return [ +]; +``` + +## Usage + +```php +$filamentProduct = new Redjasmine\FilamentProduct(); +echo $filamentProduct->echoPhrase('Hello, Redjasmine!'); +``` + +## Testing + +```bash +composer test +``` + +## Changelog + +Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently. + +## Contributing + +Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details. + +## Security Vulnerabilities + +Please review [our security policy](../../security/policy) on how to report security vulnerabilities. + +## Credits + +- [liushoukun](https://github.com/red-jasmine) +- [All Contributors](../../contributors) + +## License + +The MIT License (MIT). Please see [License File](LICENSE.md) for more information. diff --git a/bin/build.js b/bin/build.js new file mode 100644 index 0000000..29d9a35 --- /dev/null +++ b/bin/build.js @@ -0,0 +1,50 @@ +import esbuild from 'esbuild' + +const isDev = process.argv.includes('--dev') + +async function compile(options) { + const context = await esbuild.context(options) + + if (isDev) { + await context.watch() + } else { + await context.rebuild() + await context.dispose() + } +} + +const defaultOptions = { + define: { + 'process.env.NODE_ENV': isDev ? `'development'` : `'production'`, + }, + bundle: true, + mainFields: ['module', 'main'], + platform: 'neutral', + sourcemap: isDev ? 'inline' : false, + sourcesContent: isDev, + treeShaking: true, + target: ['es2020'], + minify: !isDev, + plugins: [{ + name: 'watchPlugin', + setup: function (build) { + build.onStart(() => { + console.log(`Build started at ${new Date(Date.now()).toLocaleTimeString()}: ${build.initialOptions.outfile}`) + }) + + build.onEnd((result) => { + if (result.errors.length > 0) { + console.log(`Build failed at ${new Date(Date.now()).toLocaleTimeString()}: ${build.initialOptions.outfile}`, result.errors) + } else { + console.log(`Build finished at ${new Date(Date.now()).toLocaleTimeString()}: ${build.initialOptions.outfile}`) + } + }) + } + }], +} + +compile({ + ...defaultOptions, + entryPoints: ['./resources/js/index.js'], + outfile: './resources/dist/filament-product.js', +}) diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..579dd30 --- /dev/null +++ b/composer.json @@ -0,0 +1,70 @@ +{ + "name": "red-jasmine/filament-product", + "description": "This is my package filament-product", + "keywords": [ + "red-jasmine", + "laravel", + "filament-product" + ], + "homepage": "https://github.com/red-jasmine/filament-product", + "support": { + "issues": "https://github.com/red-jasmine/filament-product/issues", + "source": "https://github.com/red-jasmine/filament-product" + }, + "license": "MIT", + "authors": [ + { + "name": "liushoukun", + "email": "liushoukun66@gmail.com", + "role": "Developer" + } + ], + "require": { + "php": "^8.1", + "filament/filament": "^3.0", + "spatie/laravel-package-tools": "^1.15.0" + }, + "require-dev": { + "nunomaduro/collision": "^7.9", + "orchestra/testbench": "^8.0", + "pestphp/pest": "^2.1", + "pestphp/pest-plugin-arch": "^2.0", + "pestphp/pest-plugin-laravel": "^2.0", + "spatie/laravel-ray": "^1.26" + }, + "autoload": { + "psr-4": { + "Redjasmine\\FilamentProduct\\": "src/", + "Redjasmine\\FilamentProduct\\Database\\Factories\\": "database/factories/" + } + }, + "autoload-dev": { + "psr-4": { + "Redjasmine\\FilamentProduct\\Tests\\": "tests/" + } + }, + "scripts": { + "post-autoload-dump": "@php ./vendor/bin/testbench package:discover --ansi", + "test": "vendor/bin/pest", + "test-coverage": "vendor/bin/pest --coverage" + }, + "config": { + "sort-packages": true, + "allow-plugins": { + "pestphp/pest-plugin": true, + "phpstan/extension-installer": true + } + }, + "extra": { + "laravel": { + "providers": [ + "Redjasmine\\FilamentProduct\\FilamentProductServiceProvider" + ], + "aliases": { + "FilamentProduct": "Redjasmine\\FilamentProduct\\Facades\\FilamentProduct" + } + } + }, + "minimum-stability": "dev", + "prefer-stable": true +} \ No newline at end of file diff --git a/config/product.php b/config/product.php new file mode 100644 index 0000000..5040d18 --- /dev/null +++ b/config/product.php @@ -0,0 +1,6 @@ +id(); + + // add fields + + $table->timestamps(); + }); + } +}; diff --git a/postcss.config.cjs b/postcss.config.cjs new file mode 100644 index 0000000..2855394 --- /dev/null +++ b/postcss.config.cjs @@ -0,0 +1,8 @@ +module.exports = { + plugins: { + "postcss-import": {}, + "tailwindcss/nesting": {}, + tailwindcss: {}, + autoprefixer: {}, + }, +} diff --git a/resources/css/index.css b/resources/css/index.css new file mode 100644 index 0000000..b3949d5 --- /dev/null +++ b/resources/css/index.css @@ -0,0 +1 @@ +@import '../../vendor/filament/filament/resources/css/theme.css'; diff --git a/resources/dist/.gitkeep b/resources/dist/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/resources/js/index.js b/resources/js/index.js new file mode 100644 index 0000000..e69de29 diff --git a/resources/lang/en/product.php b/resources/lang/en/product.php new file mode 100644 index 0000000..60bb73f --- /dev/null +++ b/resources/lang/en/product.php @@ -0,0 +1,6 @@ +comment('All done'); + + return self::SUCCESS; + } +} diff --git a/src/Facades/FilamentProduct.php b/src/Facades/FilamentProduct.php new file mode 100644 index 0000000..6126fec --- /dev/null +++ b/src/Facades/FilamentProduct.php @@ -0,0 +1,16 @@ +getId()); + + return $plugin; + } +} diff --git a/src/FilamentProductServiceProvider.php b/src/FilamentProductServiceProvider.php new file mode 100644 index 0000000..d321f5f --- /dev/null +++ b/src/FilamentProductServiceProvider.php @@ -0,0 +1,152 @@ +name(static::$name) + ->hasCommands($this->getCommands()) + ->hasInstallCommand(function (InstallCommand $command) { + $command + ->publishConfigFile() + ->publishMigrations() + ->askToRunMigrations() + ->askToStarRepoOnGitHub('red-jasmine/filament-product'); + }); + + $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/filament-product/{$file->getFilename()}"), + ], 'filament-product-stubs'); + } + } + + // Testing + Testable::mixin(new TestsFilamentProduct); + } + + protected function getAssetPackageName(): ?string + { + return 'red-jasmine/filament-product'; + } + + /** + * @return array + */ + protected function getAssets(): array + { + return [ + // AlpineComponent::make('filament-product', __DIR__ . '/../resources/dist/components/filament-product.js'), + Css::make('filament-product-styles', __DIR__ . '/../resources/dist/filament-product.css'), + Js::make('filament-product-scripts', __DIR__ . '/../resources/dist/filament-product.js'), + ]; + } + + /** + * @return array + */ + protected function getCommands(): array + { + return [ + FilamentProductCommand::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_filament-product_table', + ]; + } +} diff --git a/src/Testing/TestsFilamentProduct.php b/src/Testing/TestsFilamentProduct.php new file mode 100644 index 0000000..9e5dbcd --- /dev/null +++ b/src/Testing/TestsFilamentProduct.php @@ -0,0 +1,13 @@ +