mirror of
https://gitlab.com/signalytic/client-external/streamline/streamline-emr.git
synced 2026-09-13 11:41:31 +00:00
Import latest app updates from streamline
An updated set of source files and initialization was provided by streamline to address issues observed during initial testing. These files have been updated in order to generate a new set of app images.
This commit is contained in:
@@ -1,14 +0,0 @@
|
||||
; This file is for unithyng the coding style for different editors and IDEs.
|
||||
|
||||
root = true;
|
||||
|
||||
[*]
|
||||
charset = utf_8
|
||||
indent_size = 4
|
||||
indent_style = space
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
@@ -1,4 +0,0 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: nwidart
|
||||
github: dcblogdev
|
||||
@@ -1,17 +0,0 @@
|
||||
# Number of days of inactivity before an issue becomes stale
|
||||
daysUntilStale: 15
|
||||
# Number of days of inactivity before a stale issue is closed
|
||||
daysUntilClose: 7
|
||||
# Issues with these labels will never be considered stale
|
||||
exemptLabels:
|
||||
- pinned
|
||||
- security
|
||||
# Label to use when marking an issue as stale
|
||||
staleLabel: stale
|
||||
# Comment to post when marking an issue as stale. Set to `false` to disable
|
||||
markComment: >
|
||||
This issue has been automatically marked as stale because it has not had
|
||||
recent activity. It will be closed if no further activity occurs. Thank you
|
||||
for your contributions.
|
||||
# Comment to post when closing a stale issue. Set to `false` to disable
|
||||
closeComment: false
|
||||
-33
@@ -1,33 +0,0 @@
|
||||
name: PHP Pipeline
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
max-parallel: 2
|
||||
matrix:
|
||||
php-versions: ['8.1', '8.2', '8.3']
|
||||
|
||||
name: PHP ${{ matrix.php-versions }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@master
|
||||
with:
|
||||
php-version: ${{ matrix.php-versions }}
|
||||
coverage: xdebug
|
||||
|
||||
- name: Validate composer.json and composer.lock
|
||||
run: composer validate
|
||||
|
||||
- name: Install dependencies
|
||||
run: composer install --prefer-dist --no-progress --no-suggest
|
||||
|
||||
- name: Run test suite
|
||||
run: composer run-script test
|
||||
@@ -1,53 +0,0 @@
|
||||
<?php
|
||||
|
||||
use PhpCsFixer\Config;
|
||||
use PhpCsFixer\Finder;
|
||||
|
||||
$rules = [
|
||||
'@PSR12' => true,
|
||||
// Concatenation should be used with at least one whitespace around.
|
||||
'concat_space' => ['spacing' => 'one'],
|
||||
// Unused use statements must be removed.
|
||||
'ordered_imports' => true,
|
||||
// Removes extra empty lines.
|
||||
'no_extra_blank_lines' => true,
|
||||
// An empty line feed should precede a return statement.
|
||||
'blank_line_before_statement' => true,
|
||||
// Unused use statements must be removed.
|
||||
'no_unused_imports' => true,
|
||||
// Remove trailing whitespace at the end of blank lines.
|
||||
'no_whitespace_in_blank_line' => true,
|
||||
// There MUST be one blank line after the namespace declaration.
|
||||
'blank_line_after_namespace' => true,
|
||||
// There should be exactly one blank line before a namespace declaration.
|
||||
'single_blank_line_before_namespace' => true,
|
||||
// Each namespace use MUST go on its own line and there MUST be one blank line after the use statements block.
|
||||
'single_line_after_imports' => true,
|
||||
// Ensure there is no code on the same line as the PHP open tag and it is followed by a blankline.
|
||||
'blank_line_after_opening_tag' => true,
|
||||
// Remove duplicated semicolons.
|
||||
'no_empty_statement' => true,
|
||||
// PHP multi-line arrays should have a trailing comma.
|
||||
'trailing_comma_in_multiline' => true,
|
||||
// There should be no empty lines after class opening brace.
|
||||
'no_blank_lines_after_class_opening' => true,
|
||||
// There should not be blank lines between docblock and the documented element.
|
||||
'no_blank_lines_after_phpdoc' => true,
|
||||
// Phpdocs should start and end with content, excluding the very first and last line of the docblocks.
|
||||
'phpdoc_trim' => true,
|
||||
];
|
||||
|
||||
$finder = Finder::create()
|
||||
->in(__DIR__)
|
||||
->exclude([
|
||||
'vendor',
|
||||
'tests/Commands/__snapshots__',
|
||||
])
|
||||
->ignoreDotFiles(true)
|
||||
->ignoreVCS(true);
|
||||
|
||||
return (new Config())
|
||||
->setFinder($finder)
|
||||
->setRules($rules)
|
||||
->setRiskyAllowed(true)
|
||||
->setUsingCache(true);
|
||||
@@ -1,753 +0,0 @@
|
||||
# Changelog
|
||||
|
||||
All Notable changes to `laravel-modules` will be documented in this file.
|
||||
|
||||
## Next
|
||||
|
||||
## 10.0.6 - 2024-01-28
|
||||
|
||||
## Added
|
||||
|
||||
- [@alissn](https://github.com/alissn) Add command module prune
|
||||
|
||||
## 10.0.5 - 2024-01-22
|
||||
|
||||
## Added
|
||||
|
||||
- [@azim-kordpour](https://github.com/azim-kordpour) Add PHPDoc static to all methods in Module facade
|
||||
|
||||
## Changed
|
||||
|
||||
- [@dcblogdev](https://github.com/dcblogdev) Reverted config to use `App` and `Database` namespace / folders by default
|
||||
- [@alissn](https://github.com/alissn) Command Synchronization and Alphabetical Sorting in ConsoleServiceProvider
|
||||
- [@fpermana](https://github.com/fpermana) Update ObserverMakeCommand.php
|
||||
|
||||
## Fixed
|
||||
|
||||
- [@alissn](https://github.com/alissn) revert extend class to ShowModelCommand
|
||||
- [@benjaminniess](https://github.com/benjaminniess) Fix ModelShowCommand extends property
|
||||
|
||||
|
||||
## 10.0.4 - 2023-11-13
|
||||
|
||||
## Changed
|
||||
- [@dcblogdev](https://github.com/dcblogdev) updated module:publish-config to a dynamic path to the service provider
|
||||
|
||||
## 10.0.3 - 2023-10-02
|
||||
|
||||
## Changed
|
||||
|
||||
- [@solomon-ochepa](https://github.com/solomon-ochepa) updated multiple & config stubs to follow modern laravel standards
|
||||
- [@dcblogdev](https://github.com/dcblogdev) updated enabled `$MODULE_NAMESPACE$` & `$CONTROLLER_NAMESPACE$` placeholders to be used inside stubs
|
||||
- [@hungthai1401](https://github.com/hungthai1401) updated rule stub
|
||||
|
||||
## Added
|
||||
|
||||
- [@dcblogdev](https://github.com/dcblogdev) added support for using modules inside the main `vite.config.js` file https://github.com/nWidart/laravel-modules/pull/1682
|
||||
- [@dcblogdev](https://github.com/dcblogdev) added option to generate a factory by using the flag `-f` when generating a model
|
||||
- [@hungthai1401](https://github.com/hungthai1401 ) added implicit rule https://github.com/nWidart/laravel-modules/pull/1664
|
||||
|
||||
|
||||
## 10.0.2 - 2023-09-18
|
||||
|
||||
## Changed
|
||||
|
||||
- reordered config commands and added missing observer command
|
||||
|
||||
## 10.0.1 - 2023-09-18
|
||||
|
||||
## Added
|
||||
|
||||
- [@JaberWiki](https://github.com/JaberWiki) Added Include an optional flag `subpath` for rolling back a module's specific migration file [#1626](https://github.com/nWidart/laravel-modules/pull/1626)
|
||||
- [@sergiy-petrov](https://github.com/sergiy-petrov) Added support for testing GitHub actions against PHP versions 8.2 and 8.3. [#1624](https://github.com/nWidart/laravel-modules/pull/1624)
|
||||
- [@hanieas](https://github.com/hanieas) Added make Observer command. [#1623](https://github.com/nWidart/laravel-modules/pull/1623)
|
||||
- [@alissn](https://github.com/alissn) Add phpdoc to Module facade class for IDE auto-completion. [#1589](https://github.com/nWidart/laravel-modules/pull/1589)
|
||||
- [@aryala7](https://github.com/aryala7) Add command to create broadcasting channel [#1599](https://github.com/nWidart/laravel-modules/pull/1599)
|
||||
|
||||
## Changed
|
||||
|
||||
- [@Rattone](https://github.com/Rattone) Updated stubs for command from `name` to `signature` [#1625](https://github.com/nWidart/laravel-modules/pull/1625)
|
||||
- [@moeen-basra](https://github.com/moeen-basra) Remove the unused Factory import [#1596](https://github.com/nWidart/laravel-modules/pull/1596)
|
||||
- [@moeen-basra](https://github.com/moeen-basra) Replace the \Config::get with config function [#1596](https://github.com/nWidart/laravel-modules/pull/1596)
|
||||
- [@aryala7](https://github.com/aryala7) Changed disable module Command to accept array of modules instead of single module to disable [#1591](https://github.com/nWidart/laravel-modules/pull/1591)
|
||||
|
||||
## 10.0.0 - 2023-02-14
|
||||
|
||||
### Changed
|
||||
|
||||
- Minimum PHP version to 8.1 for supporting Laravel 10
|
||||
- Laravel 10 version
|
||||
- Increased PHPUnit to 10.0
|
||||
- Increased Mockery to 1.5
|
||||
|
||||
## Updated
|
||||
|
||||
- [@dev-karpenko](https://github.com/dev-karpenko) updated get attributes cache [#1526](https://github.com/nWidart/laravel-modules/pull/1526)
|
||||
|
||||
## 9.0.7 - 2022-11-17
|
||||
|
||||
## Added
|
||||
|
||||
- [@alissn](https://github.com/alissn) implement command check lang folder, and show missing files [#1496](https://github.com/nWidart/laravel-modules/pull/1496)
|
||||
- [@kmizzi](https://github.com/kmizzi) Use AsCommand in lieu of defaultName for ModelShowCommand [#1503](https://github.com/nWidart/laravel-modules/pull/1503)
|
||||
|
||||
## 9.0.6 - 2022-10-28
|
||||
|
||||
## Added
|
||||
|
||||
- [@wikigods](https://github.com/wikigods) added vite compatibility [#1455](https://github.com/nWidart/laravel-modules/pull/1455)
|
||||
- [@WMOH-DEV](https://github.com/WMOH-DEV) Adding migrate fresh command [#1483](https://github.com/nWidart/laravel-modules/pull/1483)
|
||||
|
||||
## 9.0.5 - 2022-08-31
|
||||
|
||||
## Added
|
||||
|
||||
- [@alissn](https://github.com/alissn) add command show model information [#1429](https://github.com/nWidart/laravel-modules/pull/1429)
|
||||
- [@JaberWiki](https://github.com/JaberWiki) add optional flag for seeder or request in model generator command [#1431](https://github.com/nWidart/laravel-modules/pull/1431)
|
||||
|
||||
## Changed
|
||||
- [@alissn](https://github.com/alissn) updated command style to new version of artisan [#1430](https://github.com/nWidart/laravel-modules/pull/1430)
|
||||
- [@ChauDucGiang](https://github.com/ChauDucGiang) updated Feature/cache driver [#1443](https://github.com/nWidart/laravel-modules/pull/1443)
|
||||
|
||||
### Fixed
|
||||
|
||||
- [@ajayfroiden](https://github.com/alissn) fixed module:disable [#1438](https://github.com/nWidart/laravel-modules/pull/1438)
|
||||
- [@inovar-tecnologia](https://github.com/inovar-tecnologia) fixed DisableCommand.php[#1435](https://github.com/nWidart/laravel-modules/pull/1435)
|
||||
|
||||
## 9.0.4 - 2022-07-28
|
||||
|
||||
- 9.02 - 9.0.3 have been removed due to savere performance problems
|
||||
|
||||
|
||||
## 9.0.1 - 2022-02-28
|
||||
|
||||
### Added
|
||||
|
||||
- Added option to publish stubs for modules `php artisan vendor:publish --provider="Nwidart\Modules\LaravelModulesServiceProvider" --tag="stubs"`
|
||||
|
||||
### Changed
|
||||
|
||||
- [@iamine](https://github.com/iamine) Added Anonymous migration class as default like in Laravel 9.0 [#1363](https://github.com/nWidart/laravel-modules/pull/1363)
|
||||
|
||||
## 9.0 - 2022-02-10
|
||||
|
||||
### Changed
|
||||
|
||||
- Minimum PHP version to 8.0 for supporting Laravel 9
|
||||
- Laravel 9 version
|
||||
- Increased PHPUnit to 9.5
|
||||
- Increased Mockery to 1.4
|
||||
- Fixed test replaced expectsEvents with event fakes
|
||||
|
||||
## 8.3 - 2022-02-10
|
||||
|
||||
### Fixed
|
||||
|
||||
- The ability to override commands via config file.
|
||||
- Incorrectly placed config key
|
||||
- Class name when special characters are used in the rule name
|
||||
- Fix error on anonymous migration
|
||||
|
||||
### Changed
|
||||
|
||||
- Changed `View/Component` to `View/Components`
|
||||
- Updated test snapshots for the MakeCommand test snapshots
|
||||
- Command stub signature from `signature` to `name`
|
||||
- Revert PR1171 which causes tests to fail
|
||||
|
||||
### Added
|
||||
|
||||
- Added commands make class component and make view component
|
||||
- Test against php 8.0
|
||||
- Merge config in register method
|
||||
- Added optional controller flag to model generator command
|
||||
- Set module for make-controller command
|
||||
- Added tests for generating controller in model generator command
|
||||
- Added test for check if migration and controller flag are both present
|
||||
- Laravel mix v6 support
|
||||
|
||||
## 8.2 - 2020-11-11
|
||||
|
||||
### Added
|
||||
|
||||
- New `module:make-component` command to generate laravel components
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed bug: `Target class [Nwidart\Modules\Commands\] does not exist.`
|
||||
|
||||
## 8.1 - 2020-11-10
|
||||
|
||||
### Added
|
||||
|
||||
- Command management via configuration file
|
||||
- Laravel 8 Factories compatibility
|
||||
- New improved way to define controller types. `--web`, `--api` and `--plain` options.
|
||||
- New configuration option to make compose run in silent mode
|
||||
|
||||
### Changed
|
||||
|
||||
- New generated commands now use the `$signature` property instead of `$name`
|
||||
- Fixed issue where `order` was used instead of `priority`
|
||||
|
||||
## 8.0 - 2020-10-03
|
||||
|
||||
### Added
|
||||
|
||||
- Laravel 8 support
|
||||
|
||||
### Updated
|
||||
|
||||
- Update `ListenerMakeCommand` to properly use the `--events` option
|
||||
|
||||
## 7.2.0 - 2020-07-30
|
||||
|
||||
### Added
|
||||
|
||||
- Added return statements in artisan commands. Helpful to validate if something was successfully ran. (#1026)
|
||||
|
||||
### Changed
|
||||
|
||||
- Update JsonResource namespace, using the new `Illuminate\Http\Resources\Json\JsonResource`. (#969)
|
||||
- Enable command returns the status code (#978)
|
||||
- Removing module service provider from composer.json stub (#996)
|
||||
- Fixed custom stub path issue. Replacing a hardcoded stub path. (#1016)
|
||||
- Controller return type changed to `Illuminate\Contracts\Support\Renderable`. (#1020)
|
||||
- Change bigIncrements method to id (#1029)
|
||||
- Adding force option for module:seed (#1030)
|
||||
|
||||
## 7.1.0 - 2020-04-14
|
||||
|
||||
### Changed
|
||||
|
||||
- `php artsian module:enable` (without any arguments) will enable all modules
|
||||
- `php artsian module:disable` (without any arguments) will disable all modules
|
||||
- Updating Laravel Mix version as well as cross-env.
|
||||
|
||||
## 7.0.0 - 2020-03-26
|
||||
|
||||
### Added
|
||||
|
||||
- Laravel 7.0 support
|
||||
|
||||
## 6.2.0 - 2019-11-12
|
||||
|
||||
### Changed
|
||||
|
||||
- Properly guessing the namespace from the path (in `GeneratorPath` class)
|
||||
- Fixing generation of resource file if the resource has been disabled to generate
|
||||
- Fix when using a custom service provider namespace, namespace is correctly referenced in module.json and compose.json
|
||||
- Fix when using custom service provider namespace, module path is correctly referenced in the `RouteServiceProvider` and `ModuleServiceProvider`
|
||||
- Fix when using a custom path for controllers in the controller stub
|
||||
|
||||
## 6.1.0 - 2019-11-01
|
||||
|
||||
### Added
|
||||
|
||||
- Added new `module:delete` command
|
||||
|
||||
### Changed
|
||||
|
||||
- Add optional path parameter to `module_path` helper (PR#861)
|
||||
- The default path of the `module_statuses.json` file has been moved to the Application's base path. This is to improve its visibility and the fact that it can be committed by default.
|
||||
- Throw an exception when no proper activator class was configured
|
||||
|
||||
## 6.0.0 - 2019-09-19
|
||||
|
||||
### Added
|
||||
|
||||
- New File Activator feature. [PR #790](https://github.com/nWidart/laravel-modules/pull/790) from @ryssbowh
|
||||
|
||||
This feature changes how modules are activated and de-activated. Currently module statuses are stored on disk, this features adds the possibility of storing this status information in a database.
|
||||
|
||||
**Use the command `php artisan module:v6:migrate` to have old modules active status migrated to the new system.**
|
||||
|
||||
### Changed
|
||||
|
||||
- Alternate way to define the namespace of modules in [PR #776](https://github.com/nWidart/laravel-modules/pull/776) by @daison12006013
|
||||
|
||||
This allows to have the content of the module under an `src/` folder for example.
|
||||
- **BREAKING** New way to handle active and inactive modules.
|
||||
|
||||
Modules don't store their active status in their module.json file anymore, but in a file under the storage folder.
|
||||
Run `php artisan module:v6:migrate` to use the new system.
|
||||
- **BREAKING** Renamed method `enabled` to `isEnabled` in `\Nwidart\Modules\Module`.
|
||||
- **BREAKING** Renamed method `disabled` to `isDisabled` in `\Nwidart\Modules\Module`.
|
||||
- **BREAKING** Renamed method `enabled` to `isEnabled` in `\Nwidart\Modules\FileRepository`.
|
||||
- **BREAKING** Renamed method `disabled` to `isDisabled` in `\Nwidart\Modules\FileRepository`.
|
||||
- **BREAKING** Removed the `__get` magic method on the `\Nwidart\Modules\Module` class. Use `get()` or `json()->get()` instead.
|
||||
- The `module:make-listener` command now correctly uses the namespace configuration
|
||||
- The generated Factories now has type hints for the `\Illuminate\Database\Eloquent\Factory` class
|
||||
- Improved foreign key constraint generation
|
||||
- Exception handling in the `SeedCommand` has been improved
|
||||
|
||||
## 5.0.1 - 2019-05-11
|
||||
|
||||
### Added
|
||||
|
||||
- `artisan module:route-provider` has a `--force` option to overwrite existing file
|
||||
|
||||
### Changed
|
||||
|
||||
- Fixing the `RouteServiceProvider` generation to properly use the `routes/web` and `routes/api` stubs
|
||||
- Replacing `@stop` with `@endsection` in the view stub file
|
||||
- `Module` class does not extend Laravel's Service Provider class anymore
|
||||
|
||||
## 5.0.0 - 2019-03-18
|
||||
|
||||
### Added
|
||||
|
||||
- Laravel 5.8 support
|
||||
|
||||
### Changed
|
||||
|
||||
- Deprecated string and array methods have been replaced
|
||||
- Fixed caching not being cleared after disabling and enabling modules
|
||||
- Update Route Provider stub to not affect the root namespace of the URL generator (#727)
|
||||
|
||||
### Removed
|
||||
|
||||
- **PHP 7.1 support**
|
||||
|
||||
## 4.1.0 - 2019-03-04
|
||||
|
||||
### Changed
|
||||
|
||||
- Updated to laravel mix 4
|
||||
- Add `--api` argument to `module:make-controller` command
|
||||
- Seeding modules outside out `Modules` namespace
|
||||
|
||||
## 4.0.0 - 2018-09-30
|
||||
|
||||
### Added
|
||||
|
||||
- New way of handling routes by default using a RouteServiceProvider (instead of start.php)
|
||||
- Laravel 5.7 support
|
||||
|
||||
### Changed
|
||||
|
||||
- Allow class resolution on short name and abstract
|
||||
- `module:seed` accepts a `--class` option
|
||||
|
||||
## 3.3.1 - 2018-07-13
|
||||
|
||||
### Changed
|
||||
|
||||
- Added the ability to set a sub-namespace to controllers `module:make-controller Api\\TestController`
|
||||
|
||||
## 3.3.0 - 2018-06-21
|
||||
|
||||
### Changed
|
||||
|
||||
- `module:update` command has now the possibility to update all modules at once
|
||||
- Fixing commented code for Laravel Mix
|
||||
|
||||
## 3.2.0 - 2018-04-16
|
||||
|
||||
### Added
|
||||
|
||||
- Added possibility to update all modules at once if any not specified (PR #523)
|
||||
|
||||
### Changed
|
||||
|
||||
- Mix: Fix css relative urls by changing the route folder (PR #521)
|
||||
- Mix: Prevents every build from deleting previous Mix config file (PR #521)
|
||||
|
||||
## 3.1.0 - 2018-04-01
|
||||
|
||||
### Added
|
||||
|
||||
- Laravel mix configuration (https://nwidart.com/laravel-modules/v3/basic-usage/compiling-assets)
|
||||
|
||||
### Changed
|
||||
|
||||
- Allow symlinks in module path
|
||||
- Returns the parameter `--class` to the `SeedCommand`.
|
||||
- Generate folders recursively
|
||||
- Removing link that has become a 404
|
||||
- Fixed seed command exception typehint
|
||||
|
||||
### Removed
|
||||
|
||||
- Removed the optimize command on the `module:make-migration` command
|
||||
|
||||
## 3.0.1 - 2018-02-16
|
||||
|
||||
### Changed
|
||||
|
||||
- Update publish commands to use the new API to get all enabled modules (PR #483 )
|
||||
|
||||
## 3.0.0 - 2018-02-14
|
||||
|
||||
## Added
|
||||
|
||||
- Added support for laravel 5.6
|
||||
- Using phpunit 7
|
||||
|
||||
## Changed
|
||||
|
||||
- **BC:** `Repository` class: renamed `enabled` to `allEnabled`
|
||||
- **BC:** `Repository` class: renamed `disabled` to `allDisabled`
|
||||
- **BC:** `Repository` class: renamed `active` to `enabled`
|
||||
- **BC:** `Repository` class: renamed `notActive` to `disabled`
|
||||
|
||||
## Removed
|
||||
|
||||
- Dropped php 7.0 support
|
||||
- **BC:** `Module` class: Deprecated `active()` method, use `enabled()`
|
||||
- **BC:** `Module` class: Deprecated `notActive()` method, use `disabled()`
|
||||
- **BC:** `Repository` class: Deprecated `addPath()` method, use `addLocation()`
|
||||
- **BC:** `Repository` class: Deprecated `get()` method, use `find()`
|
||||
- **BC:** `Repository` class: Deprecated `getUsed()` method, use `getUsedNow()`
|
||||
|
||||
|
||||
## 2.7.0 - 2018-01-13
|
||||
|
||||
## Changed
|
||||
|
||||
- Rename the `before` method to `boot` in the `RouterServiceProvider` stub file
|
||||
- Fixing caching issue if modules were loaded from a different directory
|
||||
- Fixing how modules are loaded from vendor directory (#423 #417)
|
||||
- Update to Mockery 1.0
|
||||
- use default file stubs only if override does not exists
|
||||
- Fix non well formed numeric value in seed command
|
||||
|
||||
## 2.6.0 - 2017-11-07
|
||||
|
||||
## Added
|
||||
|
||||
- Ability to customise the destination folder & namespace of a generated class
|
||||
- Added `php artisan module:migrate-status` command
|
||||
- `config_path()` helper for Lumen
|
||||
- Added views tag to view config in ServiceProvider
|
||||
- added package auto discovery for laravel 5.5 in generated module `composer.json`
|
||||
|
||||
## Changed
|
||||
|
||||
- Adding the ability to correctly load modules from multiple locations, together
|
||||
- Custom seeder path now also used in the `module:seed` command
|
||||
|
||||
## 2.5.1 - 2017-10-13
|
||||
|
||||
## Changed
|
||||
|
||||
- added config_path helper to helpers for Lumen support
|
||||
- updated readme on how to install laravel-modules in Lumen
|
||||
|
||||
## 2.5.0 - 2017-10-03
|
||||
|
||||
## Changed
|
||||
|
||||
- Making the path to migrations for `loadMigrationsFrom()` call dynamic based of configuration
|
||||
- Making the factory path dynamic for master service provider & make-factory command
|
||||
- Make the route file location dynamic in start.php based of `stubs.files.routes`
|
||||
- Making the route path dynamic on the route service provider based of `stubs.files.routes`
|
||||
- New structure in configuration to set which folders will be generated on `module:make` (old format still supported)
|
||||
- Setting new sensible defaults to what folders to generate by default.
|
||||
- Change the assets directory default location `resources/assets`
|
||||
|
||||
## 2.4.1 - 2017-09-27
|
||||
|
||||
## Changed
|
||||
|
||||
- Setting a default value for `modules.paths.modules` configuration key
|
||||
|
||||
|
||||
## 2.4.0 - 2017-09-27
|
||||
|
||||
## Added
|
||||
|
||||
- New `module:make-resource` command to generate resource classes
|
||||
- New `module:make-test` command to generate test classes
|
||||
|
||||
## Changed
|
||||
|
||||
- Improved error output of the `module:seed` command
|
||||
- Marking methods that served as proxies in `Module` and `Repository` classes as deprecated for next major
|
||||
- Fixed `module:make` and `module:make-provider` to generate the correct master service provider
|
||||
- Tests: tests are now using `spatie/phpunit-snapshot-assertions` to make sure the generated files have the correct content
|
||||
- Adding a sync option to the `module:make-job` command to make a synchronous job class
|
||||
- Changed `module:make-event` command to allow duck typed events (not type hinted event class)
|
||||
- Changed `module:make-listener` to allow a `--queued` option to make the event queueable
|
||||
- Changed `module:make-listener` command to not use the full class typehint when class was previous imported
|
||||
|
||||
## 2.3.0 - 2017-09-26
|
||||
|
||||
## Added
|
||||
|
||||
- Ability to ignore some folders to generate
|
||||
- Creating an module:unuse command to forget the previously saved module
|
||||
- New command to generate Policy classes
|
||||
- New command for creating factories
|
||||
- New command for creating rules
|
||||
- new `public_path` helper for Lumen
|
||||
|
||||
## Changed
|
||||
|
||||
- Refactored class names that generate something to be fully consistent
|
||||
|
||||
## 2.2.1 - 2017-09-14
|
||||
|
||||
## Changed
|
||||
|
||||
- Fixed class namespace to `Repository` in `ContractsServiceProvider`
|
||||
|
||||
## 2.2.0 - 2017-09-14
|
||||
|
||||
### Added
|
||||
|
||||
- Lumen compatibility with new way to register providers
|
||||
|
||||
|
||||
## 2.1.0 - 2017-09-10
|
||||
|
||||
### Changed
|
||||
|
||||
- Register module migrations
|
||||
- Fixed issue with `module:migrate-refresh` command
|
||||
- Improved module loading of their service providers. Using laravel caching system. Allowing usage of deferred providers.
|
||||
- Fixed path to module factories
|
||||
|
||||
## 2.0.0 - 2017-08-31
|
||||
|
||||
### Added
|
||||
|
||||
- Support Laravel 5.5
|
||||
|
||||
|
||||
## 1.27.2 - 2017-08-29
|
||||
|
||||
### Changed
|
||||
|
||||
- Allow migrate-refresh command to be run without module argument
|
||||
- Module name was added to the module enable and disable events
|
||||
|
||||
## 1.27.1 - 2017-07-31
|
||||
|
||||
### Changed
|
||||
|
||||
- Only run composer require on the module:update command if there's something to require
|
||||
- Fixing lumen support
|
||||
|
||||
## 1.27.0 - 2017-07-19
|
||||
|
||||
### Added
|
||||
|
||||
- Laravel Lumen support
|
||||
|
||||
### Changed
|
||||
|
||||
- Update dev dependencies grumphp and phpcsfixer to latest versions
|
||||
- The `make:model` command with the `-m` flag to create the associated migration is now using a current migration file name
|
||||
|
||||
## 1.26.0 - 2017-07-06
|
||||
|
||||
### Changed
|
||||
|
||||
- Throw an exception if asset name structure was not correct when using `{!! Module::asset() !!}`
|
||||
- Create the module used file if non existent. Will provide for a better error message if module is omitted in console commands without a module:use.
|
||||
|
||||
## 1.25.1 - 2017-06-29
|
||||
|
||||
### Changed
|
||||
|
||||
- More flexibility to the `json()` method, while keeping the performance improvements.
|
||||
|
||||
## 1.25.0 - 2017-06-29
|
||||
|
||||
### Changed
|
||||
|
||||
- Improving performance by only instantiating Json class for the module.json file once
|
||||
- Added support for generic git hosts
|
||||
|
||||
## 1.24.0 - 2017-06-12
|
||||
|
||||
### Changed
|
||||
|
||||
- Using `resource_path` to register module views
|
||||
- Changed the method to load additional eloquent factory paths
|
||||
|
||||
## 1.23.0 - 2017-06-09
|
||||
|
||||
## Added
|
||||
|
||||
- A `--migration` flag to the `module:make-model` command to generate the migration file with a model
|
||||
- Factories are now also defined in the master service providers. This is used in the `module:make` command without the `--plain` flag, or using `module:make-provider` with the `--master` flag.
|
||||
- `module_path()` helper function.
|
||||
|
||||
### Changed
|
||||
|
||||
- The default location of event listeners is now in `Listeners/`, from `Events/Handlers`
|
||||
|
||||
## 1.22.0 - 2017-05-22
|
||||
|
||||
### Changed
|
||||
|
||||
- Fixed the `--plain` on the `make:module` command, to not include a service provider in the `module.json` file as it's not generated.
|
||||
- Add command description to the `GenerateNotificationCommand`.
|
||||
|
||||
## 1.21.0 - 2017-05-10
|
||||
|
||||
### Added
|
||||
|
||||
- Added the `Macroable` trait to the `Module` class.
|
||||
|
||||
### Changed
|
||||
|
||||
- The `collections` method now accepts an optional parameter to get modules by status, in a laravel collection.
|
||||
- Allow laravel `5.5.*` to be used.
|
||||
|
||||
|
||||
## 1.20.0 - 2017-04-19
|
||||
|
||||
### Changed
|
||||
|
||||
- `module:update`: Copy over the scripts key to main composer.json file
|
||||
- Add a `--subpath` option to migrate command
|
||||
- `module:update`: Install / require all require & require-dev package at once, instead of multiple calls to composer require.
|
||||
- `module:publish-config` command now uses the namespace set up in the configuration file.
|
||||
|
||||
## 1.19.0 - 2017-03-16
|
||||
|
||||
### Changed
|
||||
|
||||
- `module:update` command now also takes the `require-dev` key into account
|
||||
- Making the `$migrations` parameter optional on `getLastBatchNumber()`
|
||||
|
||||
## 1.18.0 - 2017-03-13
|
||||
|
||||
### Changed
|
||||
|
||||
- The module list command (`module:list`) now returns the native module name
|
||||
|
||||
## 1.17.1 - 2017-03-02
|
||||
|
||||
### Changed
|
||||
|
||||
- Fixed issues with route file location in `start.php`
|
||||
|
||||
## 1.17.0 - 2017-02-27
|
||||
|
||||
### Changed
|
||||
|
||||
- Add checking for failure to parse module JSON
|
||||
|
||||
## 1.16.0 - 2017-01-24
|
||||
|
||||
### Added
|
||||
|
||||
- Support for Laravel 5.4
|
||||
- Adding show method on resource controller
|
||||
- Added check for cached routes to not load them multiple times
|
||||
|
||||
## 1.15.0 - 2017-01-12
|
||||
|
||||
### Added
|
||||
|
||||
- Module requirements (PR #117)
|
||||
- Added `Macroable` trait to `Module` class (PR #116)
|
||||
|
||||
### Changed
|
||||
|
||||
- Added missing import of the `Schema` facade on migration stubs
|
||||
- A default plain migration will be used if the name was not matched against a predefined structure (create, add, delete and drop)
|
||||
- Add tests for all the different migration structures above
|
||||
- Fix: respecting order in reverse migrations (PR #98)
|
||||
- Fix: `module:reset` and `module:migrate-rollback` didn't have `--database` option (PR #88)
|
||||
- Fix: `Module::asset()`, removed obsolete backslash. (PR #91)
|
||||
|
||||
## 1.14.0 - 2016-10-19
|
||||
|
||||
### Added
|
||||
|
||||
- `module:make-notification` command to generate a notification class
|
||||
|
||||
### Changed
|
||||
|
||||
- Usage of the `lists()` method on the laravel collection has been removed in favor of `pluck()`
|
||||
- Modules can now overwrite the default migration and seed paths in the `module.json` file
|
||||
|
||||
## 0.13.1 - 2016-09-09
|
||||
|
||||
### Changed
|
||||
|
||||
- Generated emails are now generated in the `Emails` folder by default
|
||||
|
||||
## 0.13.0 - 2016-09-08
|
||||
|
||||
### Changed
|
||||
|
||||
- Ability to set default value on the config() method of a module.
|
||||
- Mail: Setting default value to config. Using that as the namespace.
|
||||
- Using PSR2 for generated stubs
|
||||
|
||||
|
||||
## 0.12.0 - 2016-09-08
|
||||
|
||||
### Added
|
||||
|
||||
- Generation of Mailable classes
|
||||
|
||||
|
||||
## 0.11.2 - 2016-08-29
|
||||
|
||||
### Changed
|
||||
|
||||
- Using stable version of laravelcollective/html (5.3)
|
||||
|
||||
## 0.11.1 - 2016-08-25
|
||||
|
||||
### Changed
|
||||
|
||||
- Using stable development of laravelcollective/html
|
||||
|
||||
|
||||
## 0.11 - 2016-08-24
|
||||
|
||||
### Added
|
||||
|
||||
- Adding `module:make-job` command to generate a job class
|
||||
- Adding support for Laravel 5.3
|
||||
|
||||
### Changed
|
||||
|
||||
- Added force option to module:seed command
|
||||
|
||||
## 0.10 - 2016-08-10
|
||||
|
||||
### Added
|
||||
|
||||
- Experimental Laravel 5.3 support
|
||||
|
||||
### Changed
|
||||
|
||||
- Make sure the class name has `Controller` appended to it as well. Previously only the file had it suffixed.
|
||||
|
||||
### Removed
|
||||
|
||||
- Dependencies: `pingpong/support` and `pingpong/generators`
|
||||
|
||||
## 0.9 - 2016-07-30
|
||||
|
||||
### Added
|
||||
|
||||
- Adding a plain option to the generate controller command
|
||||
|
||||
### Changed
|
||||
|
||||
- Generate controller command now generates all resource methods
|
||||
|
||||
## 0.8 - 2016-07-28
|
||||
|
||||
### Fixed
|
||||
|
||||
- Module generation namespace now works with `StudlyCase` ([Issue #14](https://github.com/nWidart/laravel-modules/issues/14))
|
||||
- No module namespace fix (#13)
|
||||
|
||||
### Changed
|
||||
|
||||
- Using new service provider stub for module generation too
|
||||
|
||||
## 0.1 - 2016-06-27
|
||||
|
||||
Initial release
|
||||
@@ -1,23 +0,0 @@
|
||||
# The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Pingpong Labs
|
||||
|
||||
Copyright (c) 2016 Nicolas Widart bvba <n.widart@gmail.com>
|
||||
|
||||
> 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.
|
||||
@@ -1,85 +0,0 @@
|
||||
# Laravel-Modules
|
||||
|
||||
[](https://packagist.org/packages/nwidart/laravel-modules)
|
||||
[](LICENSE.md)
|
||||
[](https://travis-ci.org/nWidart/laravel-modules)
|
||||
[](https://scrutinizer-ci.com/g/nWidart/laravel-modules/?branch=master)
|
||||
[](https://scrutinizer-ci.com/g/nWidart/laravel-modules)
|
||||
[](https://packagist.org/packages/nwidart/laravel-modules)
|
||||
|
||||
| **Laravel** | **laravel-modules** |
|
||||
|-------------|---------------------|
|
||||
| 5.4 | ^1.0 |
|
||||
| 5.5 | ^2.0 |
|
||||
| 5.6 | ^3.0 |
|
||||
| 5.7 | ^4.0 |
|
||||
| 5.8 | ^5.0 |
|
||||
| 6.0 | ^6.0 |
|
||||
| 7.0 | ^7.0 |
|
||||
| 8.0 | ^8.0 |
|
||||
| 9.0 | ^9.0 |
|
||||
| 10.0 | ^10.0 |
|
||||
|
||||
`nwidart/laravel-modules` is a Laravel package which created to manage your large Laravel app using modules. Module is like a Laravel package, it has some views, controllers or models. This package is supported and tested in Laravel 10.
|
||||
|
||||
This package is a re-published, re-organised and maintained version of [pingpong/modules](https://github.com/pingpong-labs/modules), which isn't maintained anymore. This package is used in [AsgardCMS](https://github.com/AsgardCms).
|
||||
|
||||
With one big added bonus that the original package didn't have: **tests**.
|
||||
|
||||
Find out why you should use this package in the article: [Writing modular applications with laravel-modules](https://nicolaswidart.com/blog/writing-modular-applications-with-laravel-modules).
|
||||
|
||||
## Install
|
||||
|
||||
To install via Composer, run:
|
||||
|
||||
``` bash
|
||||
composer require nwidart/laravel-modules
|
||||
```
|
||||
|
||||
The package will automatically register a service provider and alias.
|
||||
|
||||
Optionally, publish the package's configuration file by running:
|
||||
|
||||
``` bash
|
||||
php artisan vendor:publish --provider="Nwidart\Modules\LaravelModulesServiceProvider"
|
||||
```
|
||||
|
||||
### Autoloading
|
||||
By default, module classes aren't loaded automatically. To autoload them using psr-4, add the following line to the end of the root composer.json file under the autoload section:
|
||||
``` json
|
||||
{
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"App\\": "app/",
|
||||
"Database\\Factories\\": "database/factories/",
|
||||
"Database\\Seeders\\": "database/seeders/",
|
||||
"Modules\\": "Modules/"
|
||||
}
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
**Tip: don't forget to run `composer dump-autoload` afterwards.**
|
||||
|
||||
## Documentation
|
||||
|
||||
You'll find installation instructions and full documentation on [https://docs.laravelmodules.com/](https://docs.laravelmodules.com/).
|
||||
|
||||
## Community
|
||||
|
||||
We also have a Discord community. [https://discord.gg/hkF7BRvRZK](https://discord.gg/hkF7BRvRZK) For quick help, ask questions in the appropriate channel.
|
||||
|
||||
## Credits
|
||||
|
||||
- [Nicolas Widart](https://github.com/nwidart)
|
||||
- [David Carr](https://github.com/dcblogdev)
|
||||
- [gravitano](https://github.com/gravitano)
|
||||
- [All Contributors](../../contributors)
|
||||
|
||||
## About Nicolas Widart
|
||||
|
||||
Nicolas Widart is a freelance web developer specialising on the Laravel framework. View all my packages [on my website](https://nwidart.com/), or visit [my website](https://nicolaswidart.com).
|
||||
|
||||
## License
|
||||
|
||||
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
|
||||
@@ -1,68 +0,0 @@
|
||||
{
|
||||
"name": "nwidart/laravel-modules",
|
||||
"description": "Laravel Module management",
|
||||
"keywords": [
|
||||
"modules",
|
||||
"laravel",
|
||||
"nwidart",
|
||||
"module",
|
||||
"rad"
|
||||
],
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Nicolas Widart",
|
||||
"email": "n.widart@gmail.com",
|
||||
"homepage": "https://nicolaswidart.com",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=8.1",
|
||||
"ext-json": "*"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^10.0",
|
||||
"mockery/mockery": "^1.5",
|
||||
"orchestra/testbench": "^8.0",
|
||||
"friendsofphp/php-cs-fixer": "^3.6",
|
||||
"laravel/framework": "^10.41",
|
||||
"spatie/phpunit-snapshot-assertions": "^5.0",
|
||||
"phpstan/phpstan": "^1.4"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Nwidart\\Modules\\": "src"
|
||||
},
|
||||
"files": [
|
||||
"src/helpers.php"
|
||||
]
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Nwidart\\Modules\\Tests\\": "tests",
|
||||
"Modules\\Recipe\\": "tests/stubs/valid/Recipe"
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"Nwidart\\Modules\\LaravelModulesServiceProvider"
|
||||
],
|
||||
"aliases": {
|
||||
"Module": "Nwidart\\Modules\\Facades\\Module"
|
||||
}
|
||||
},
|
||||
"branch-alias": {
|
||||
"dev-master": "10.0-dev"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"update-snapshots": "./vendor/bin/phpunit --no-coverage -d --update-snapshots",
|
||||
"test": "vendor/bin/phpunit",
|
||||
"test-coverage": "vendor/bin/phpunit --coverage-html coverage",
|
||||
"pcf": "vendor/bin/php-cs-fixer fix --verbose"
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"prefer-stable": true
|
||||
}
|
||||
@@ -1,232 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Nwidart\Modules\Activators\FileActivator;
|
||||
use Nwidart\Modules\Providers\ConsoleServiceProvider;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Module Namespace
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Default module namespace.
|
||||
|
|
||||
*/
|
||||
|
||||
'namespace' => 'Modules',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Module Stubs
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Default module stubs.
|
||||
|
|
||||
*/
|
||||
|
||||
'stubs' => [
|
||||
'enabled' => false,
|
||||
'path' => base_path('vendor/nwidart/laravel-modules/src/Commands/stubs'),
|
||||
'files' => [
|
||||
'routes/web' => 'routes/web.php',
|
||||
'routes/api' => 'routes/api.php',
|
||||
'views/index' => 'resources/views/index.blade.php',
|
||||
'views/master' => 'resources/views/layouts/master.blade.php',
|
||||
'scaffold/config' => 'config/config.php',
|
||||
'composer' => 'composer.json',
|
||||
'assets/js/app' => 'resources/assets/js/app.js',
|
||||
'assets/sass/app' => 'resources/assets/sass/app.scss',
|
||||
'vite' => 'vite.config.js',
|
||||
'package' => 'package.json',
|
||||
],
|
||||
'replacements' => [
|
||||
'routes/web' => ['LOWER_NAME', 'STUDLY_NAME', 'MODULE_NAMESPACE', 'CONTROLLER_NAMESPACE'],
|
||||
'routes/api' => ['LOWER_NAME', 'STUDLY_NAME'],
|
||||
'vite' => ['LOWER_NAME'],
|
||||
'json' => ['LOWER_NAME', 'STUDLY_NAME', 'MODULE_NAMESPACE', 'PROVIDER_NAMESPACE'],
|
||||
'views/index' => ['LOWER_NAME'],
|
||||
'views/master' => ['LOWER_NAME', 'STUDLY_NAME'],
|
||||
'scaffold/config' => ['STUDLY_NAME'],
|
||||
'composer' => [
|
||||
'LOWER_NAME',
|
||||
'STUDLY_NAME',
|
||||
'VENDOR',
|
||||
'AUTHOR_NAME',
|
||||
'AUTHOR_EMAIL',
|
||||
'MODULE_NAMESPACE',
|
||||
'PROVIDER_NAMESPACE',
|
||||
],
|
||||
],
|
||||
'gitkeep' => true,
|
||||
],
|
||||
'paths' => [
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Modules path
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This path is used to save the generated module.
|
||||
| This path will also be added automatically to the list of scanned folders.
|
||||
|
|
||||
*/
|
||||
|
||||
'modules' => base_path('Modules'),
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Modules assets path
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may update the modules' assets path.
|
||||
|
|
||||
*/
|
||||
|
||||
'assets' => public_path('modules'),
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| The migrations' path
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Where you run the 'module:publish-migration' command, where do you publish the
|
||||
| the migration files?
|
||||
|
|
||||
*/
|
||||
|
||||
'migration' => base_path('database/migrations'),
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Generator path
|
||||
|--------------------------------------------------------------------------
|
||||
| Customise the paths where the folders will be generated.
|
||||
| Setting the generate key to false will not generate that folder
|
||||
*/
|
||||
'generator' => [
|
||||
'config' => ['path' => 'config', 'generate' => true],
|
||||
'command' => ['path' => 'App/Console', 'generate' => false],
|
||||
'channels' => ['path' => 'App/Broadcasting', 'generate' => false],
|
||||
'migration' => ['path' => 'Database/migrations', 'generate' => false],
|
||||
'seeder' => ['path' => 'Database/Seeders', 'generate' => true],
|
||||
'factory' => ['path' => 'Database/Factories', 'generate' => false],
|
||||
'model' => ['path' => 'App/Models', 'generate' => false],
|
||||
'observer' => ['path' => 'App/Observers', 'generate' => false],
|
||||
'routes' => ['path' => 'routes', 'generate' => true],
|
||||
'controller' => ['path' => 'App/Http/Controllers', 'generate' => true],
|
||||
'filter' => ['path' => 'App/Http/Middleware', 'generate' => false],
|
||||
'request' => ['path' => 'App/Http/Requests', 'generate' => false],
|
||||
'provider' => ['path' => 'App/Providers', 'generate' => true],
|
||||
'assets' => ['path' => 'resources/assets', 'generate' => false],
|
||||
'lang' => ['path' => 'lang', 'generate' => false],
|
||||
'views' => ['path' => 'resources/views', 'generate' => true],
|
||||
'test' => ['path' => 'tests/Unit', 'generate' => false],
|
||||
'test-feature' => ['path' => 'tests/Feature', 'generate' => false],
|
||||
'repository' => ['path' => 'App/Repositories', 'generate' => false],
|
||||
'event' => ['path' => 'App/Events', 'generate' => false],
|
||||
'listener' => ['path' => 'App/Listeners', 'generate' => false],
|
||||
'policies' => ['path' => 'App/Policies', 'generate' => false],
|
||||
'rules' => ['path' => 'App/Rules', 'generate' => false],
|
||||
'jobs' => ['path' => 'App/Jobs', 'generate' => false],
|
||||
'emails' => ['path' => 'App/Emails', 'generate' => false],
|
||||
'notifications' => ['path' => 'App/Notifications', 'generate' => false],
|
||||
'resource' => ['path' => 'App/resources', 'generate' => false],
|
||||
'component-view' => ['path' => 'resources/views/components', 'generate' => false],
|
||||
'component-class' => ['path' => 'App/View/Components', 'generate' => false],
|
||||
],
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Package commands
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you can define which commands will be visible and used in your
|
||||
| application. You can add your own commands to merge section.
|
||||
|
|
||||
*/
|
||||
'commands' => ConsoleServiceProvider::defaultCommands()
|
||||
->merge([
|
||||
// New commands go here
|
||||
])->toArray(),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Scan Path
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you define which folder will be scanned. By default will scan vendor
|
||||
| directory. This is useful if you host the package in packagist website.
|
||||
|
|
||||
*/
|
||||
|
||||
'scan' => [
|
||||
'enabled' => false,
|
||||
'paths' => [
|
||||
base_path('vendor/*/*'),
|
||||
],
|
||||
],
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Composer File Template
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here is the config for the composer.json file, generated by this package
|
||||
|
|
||||
*/
|
||||
|
||||
'composer' => [
|
||||
'vendor' => 'nwidart',
|
||||
'author' => [
|
||||
'name' => 'Nicolas Widart',
|
||||
'email' => 'n.widart@gmail.com',
|
||||
],
|
||||
'composer-output' => false,
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Caching
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here is the config for setting up the caching feature.
|
||||
|
|
||||
*/
|
||||
'cache' => [
|
||||
'enabled' => false,
|
||||
'driver' => 'file',
|
||||
'key' => 'laravel-modules',
|
||||
'lifetime' => 60,
|
||||
],
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Choose what laravel-modules will register as custom namespaces.
|
||||
| Setting one to false will require you to register that part
|
||||
| in your own Service Provider class.
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'register' => [
|
||||
'translations' => true,
|
||||
/**
|
||||
* load files on boot or register method
|
||||
*/
|
||||
'files' => 'register',
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Activators
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| You can define new types of activators here, file, database, etc. The only
|
||||
| required parameter is 'class'.
|
||||
| The file activator will store the activation status in storage/installed_modules
|
||||
*/
|
||||
'activators' => [
|
||||
'file' => [
|
||||
'class' => FileActivator::class,
|
||||
'statuses-file' => base_path('modules_statuses.json'),
|
||||
'cache-key' => 'activator.installed',
|
||||
'cache-lifetime' => 604800,
|
||||
],
|
||||
],
|
||||
|
||||
'activator' => 'file',
|
||||
];
|
||||
-45
@@ -1,45 +0,0 @@
|
||||
import fs from 'fs/promises';
|
||||
import path from 'path';
|
||||
|
||||
async function collectModuleAssetsPaths(paths, modulesPath) {
|
||||
modulesPath = path.join(__dirname, modulesPath);
|
||||
|
||||
const moduleStatusesPath = path.join(__dirname, 'modules_statuses.json');
|
||||
|
||||
try {
|
||||
// Read module_statuses.json
|
||||
const moduleStatusesContent = await fs.readFile(moduleStatusesPath, 'utf-8');
|
||||
const moduleStatuses = JSON.parse(moduleStatusesContent);
|
||||
|
||||
// Read module directories
|
||||
const moduleDirectories = await fs.readdir(modulesPath);
|
||||
|
||||
for (const moduleDir of moduleDirectories) {
|
||||
if (moduleDir === '.DS_Store') {
|
||||
// Skip .DS_Store directory
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check if the module is enabled (status is true)
|
||||
if (moduleStatuses[moduleDir] === true) {
|
||||
const viteConfigPath = path.join(modulesPath, moduleDir, 'vite.config.js');
|
||||
const stat = await fs.stat(viteConfigPath);
|
||||
|
||||
if (stat.isFile()) {
|
||||
// Import the module-specific Vite configuration
|
||||
const moduleConfig = await import(viteConfigPath);
|
||||
|
||||
if (moduleConfig.paths && Array.isArray(moduleConfig.paths)) {
|
||||
paths.push(...moduleConfig.paths);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Error reading module statuses or module configurations: ${error}`);
|
||||
}
|
||||
|
||||
return paths;
|
||||
}
|
||||
|
||||
export default collectModuleAssetsPaths;
|
||||
-210
@@ -1,210 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Nwidart\Modules\Activators;
|
||||
|
||||
use Illuminate\Cache\CacheManager;
|
||||
use Illuminate\Config\Repository as Config;
|
||||
use Illuminate\Container\Container;
|
||||
use Illuminate\Contracts\Filesystem\FileNotFoundException;
|
||||
use Illuminate\Filesystem\Filesystem;
|
||||
use Nwidart\Modules\Contracts\ActivatorInterface;
|
||||
use Nwidart\Modules\Module;
|
||||
|
||||
class FileActivator implements ActivatorInterface
|
||||
{
|
||||
/**
|
||||
* Laravel cache instance
|
||||
*
|
||||
* @var CacheManager
|
||||
*/
|
||||
private $cache;
|
||||
|
||||
/**
|
||||
* Laravel Filesystem instance
|
||||
*
|
||||
* @var Filesystem
|
||||
*/
|
||||
private $files;
|
||||
|
||||
/**
|
||||
* Laravel config instance
|
||||
*
|
||||
* @var Config
|
||||
*/
|
||||
private $config;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $cacheKey;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $cacheLifetime;
|
||||
|
||||
/**
|
||||
* Array of modules activation statuses
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $modulesStatuses;
|
||||
|
||||
/**
|
||||
* File used to store activation statuses
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $statusesFile;
|
||||
|
||||
public function __construct(Container $app)
|
||||
{
|
||||
$this->cache = $app['cache'];
|
||||
$this->files = $app['files'];
|
||||
$this->config = $app['config'];
|
||||
$this->statusesFile = $this->config('statuses-file');
|
||||
$this->cacheKey = $this->config('cache-key');
|
||||
$this->cacheLifetime = $this->config('cache-lifetime');
|
||||
$this->modulesStatuses = $this->getModulesStatuses();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the path of the file where statuses are stored
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getStatusesFilePath(): string
|
||||
{
|
||||
return $this->statusesFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function reset(): void
|
||||
{
|
||||
if ($this->files->exists($this->statusesFile)) {
|
||||
$this->files->delete($this->statusesFile);
|
||||
}
|
||||
$this->modulesStatuses = [];
|
||||
$this->flushCache();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function enable(Module $module): void
|
||||
{
|
||||
$this->setActiveByName($module->getName(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function disable(Module $module): void
|
||||
{
|
||||
$this->setActiveByName($module->getName(), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function hasStatus(Module $module, bool $status): bool
|
||||
{
|
||||
if (!isset($this->modulesStatuses[$module->getName()])) {
|
||||
return $status === false;
|
||||
}
|
||||
|
||||
return $this->modulesStatuses[$module->getName()] === $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setActive(Module $module, bool $active): void
|
||||
{
|
||||
$this->setActiveByName($module->getName(), $active);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setActiveByName(string $name, bool $status): void
|
||||
{
|
||||
$this->modulesStatuses[$name] = $status;
|
||||
$this->writeJson();
|
||||
$this->flushCache();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function delete(Module $module): void
|
||||
{
|
||||
if (!isset($this->modulesStatuses[$module->getName()])) {
|
||||
return;
|
||||
}
|
||||
unset($this->modulesStatuses[$module->getName()]);
|
||||
$this->writeJson();
|
||||
$this->flushCache();
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the activation statuses in a file, as json
|
||||
*/
|
||||
private function writeJson(): void
|
||||
{
|
||||
$this->files->put($this->statusesFile, json_encode($this->modulesStatuses, JSON_PRETTY_PRINT));
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the json file that contains the activation statuses.
|
||||
* @return array
|
||||
* @throws FileNotFoundException
|
||||
*/
|
||||
private function readJson(): array
|
||||
{
|
||||
if (!$this->files->exists($this->statusesFile)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return json_decode($this->files->get($this->statusesFile), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get modules statuses, either from the cache or from
|
||||
* the json statuses file if the cache is disabled.
|
||||
* @return array
|
||||
* @throws FileNotFoundException
|
||||
*/
|
||||
private function getModulesStatuses(): array
|
||||
{
|
||||
if (!$this->config->get('modules.cache.enabled')) {
|
||||
return $this->readJson();
|
||||
}
|
||||
|
||||
return $this->cache->store($this->config->get('modules.cache.driver'))->remember($this->cacheKey, $this->cacheLifetime, function () {
|
||||
return $this->readJson();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a config parameter under the 'activators.file' key
|
||||
*
|
||||
* @param string $key
|
||||
* @param $default
|
||||
* @return mixed
|
||||
*/
|
||||
private function config(string $key, $default = null)
|
||||
{
|
||||
return $this->config->get('modules.activators.file.' . $key, $default);
|
||||
}
|
||||
|
||||
/**
|
||||
* Flushes the modules activation statuses cache
|
||||
*/
|
||||
private function flushCache(): void
|
||||
{
|
||||
$this->cache->store($this->config->get('modules.cache.driver'))->forget($this->cacheKey);
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Nwidart\Modules;
|
||||
|
||||
use Illuminate\Contracts\Support\Arrayable;
|
||||
use Illuminate\Support\Collection as BaseCollection;
|
||||
|
||||
class Collection extends BaseCollection
|
||||
{
|
||||
/**
|
||||
* Get items collections.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getItems()
|
||||
{
|
||||
return $this->items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the collection of items as a plain array.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function toArray()
|
||||
{
|
||||
return array_map(function ($value) {
|
||||
if ($value instanceof Module) {
|
||||
$attributes = $value->json()->getAttributes();
|
||||
$attributes["path"] = $value->getPath();
|
||||
|
||||
return $attributes;
|
||||
}
|
||||
|
||||
return $value instanceof Arrayable ? $value->toArray() : $value;
|
||||
}, $this->items);
|
||||
}
|
||||
}
|
||||
-87
@@ -1,87 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Nwidart\Modules\Commands;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Nwidart\Modules\Support\Config\GenerateConfigReader;
|
||||
use Nwidart\Modules\Support\Stub;
|
||||
use Nwidart\Modules\Traits\ModuleCommandTrait;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
|
||||
final class ChannelMakeCommand extends GeneratorCommand
|
||||
{
|
||||
use ModuleCommandTrait;
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'module:make-channel';
|
||||
|
||||
protected $argumentName = 'name';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Create a new channel class for the specified module.';
|
||||
|
||||
public function getDefaultNamespace(): string
|
||||
{
|
||||
$module = $this->laravel['modules'];
|
||||
|
||||
return $module->config('paths.generator.channels.namespace') ?: $module->config('paths.generator.channels.path', 'Broadcasting');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get template contents.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getTemplateContents()
|
||||
{
|
||||
$module = $this->laravel['modules']->findOrFail($this->getModuleName());
|
||||
|
||||
return (new Stub('/channel.stub', [
|
||||
'NAMESPACE' => $this->getClassNamespace($module),
|
||||
'CLASS' => $this->getClass(),
|
||||
]))->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the destination file path.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getDestinationFilePath()
|
||||
{
|
||||
$path = $this->laravel['modules']->getModulePath($this->getModuleName());
|
||||
|
||||
$channelPath = GenerateConfigReader::read('channels');
|
||||
|
||||
return $path . $channelPath->getPath() . '/' . $this->getFileName() . '.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private function getFileName()
|
||||
{
|
||||
return Str::studly($this->argument('name'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getArguments()
|
||||
{
|
||||
return [
|
||||
['name', InputArgument::REQUIRED, 'The name of the channel class.'],
|
||||
['module', InputArgument::OPTIONAL, 'The name of module will be used.'],
|
||||
];
|
||||
}
|
||||
}
|
||||
-251
@@ -1,251 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Nwidart\Modules\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Collection;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
|
||||
class CheckLangCommand extends Command
|
||||
{
|
||||
|
||||
private $langPath;
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'module:lang';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Check missing language keys in the specified module.';
|
||||
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
|
||||
$this->langPath = DIRECTORY_SEPARATOR . config('modules.paths.generator.lang.path', 'Resources/lang');
|
||||
|
||||
$this->components->alert('Checking languages ...');
|
||||
|
||||
$this->newLine();
|
||||
|
||||
if ($name = $this->argument('module')) {
|
||||
$this->check($name);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
$this->checkAll();
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* enableAll
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function checkAll()
|
||||
{
|
||||
$modules = $this->laravel['modules']->all();
|
||||
|
||||
foreach ($modules as $module) {
|
||||
$this->check($module);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* enable
|
||||
*
|
||||
* @param string $name
|
||||
* @return void
|
||||
*/
|
||||
public function check($name)
|
||||
{
|
||||
if ($name instanceof Module) {
|
||||
$module = $name;
|
||||
} else {
|
||||
$module = $this->laravel['modules']->findOrFail($name);
|
||||
}
|
||||
|
||||
$directories = $this->getDirectories($module);
|
||||
|
||||
if (! $directories) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->checkMissingFiles($directories);
|
||||
|
||||
$this->checkMissingKeys($directories);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getArguments()
|
||||
{
|
||||
return [
|
||||
['module', InputArgument::OPTIONAL, 'Module name.'],
|
||||
];
|
||||
}
|
||||
|
||||
private function getLangFiles($module)
|
||||
{
|
||||
$files = [];
|
||||
$path = $module->getPath() . $this->langPath;
|
||||
if (is_dir($path)) {
|
||||
$files = array_merge($files, $this->laravel['files']->all($path));
|
||||
}
|
||||
|
||||
return $files;
|
||||
}
|
||||
|
||||
private function getDirectories($module)
|
||||
{
|
||||
$moduleName = $module->getStudlyName();
|
||||
$path = $module->getPath() . '/Resources/lang';
|
||||
if (is_dir($path)) {
|
||||
$directories = $this->laravel['files']->directories($path);
|
||||
$directories = array_map(function ($directory) use ($moduleName) {
|
||||
return [
|
||||
'name' => basename($directory),
|
||||
'module' => $moduleName,
|
||||
'path' => $directory,
|
||||
'files' => array_map(function ($file) {
|
||||
return basename($file);
|
||||
}, \File::glob($directory . DIRECTORY_SEPARATOR . "*")),
|
||||
];
|
||||
}, $directories);
|
||||
}
|
||||
|
||||
if (count($directories) == 0) {
|
||||
$this->components->info("No language files found in module $moduleName");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (count($directories) == 1) {
|
||||
$this->components->warn("Only one language file found in module $moduleName");
|
||||
return false;
|
||||
}
|
||||
|
||||
return collect($directories);
|
||||
}
|
||||
|
||||
private function checkMissingFiles(Collection $directories)
|
||||
{
|
||||
//show missing files
|
||||
$missingFilesMessage = [];
|
||||
|
||||
$uniqeLangFiles = $directories->pluck('files')->flatten()->unique()->values();
|
||||
|
||||
$directories->each(function ($directory) use ($uniqeLangFiles, &$missingFilesMessage) {
|
||||
|
||||
$missingFiles = $uniqeLangFiles->diff($directory['files']);
|
||||
|
||||
if ($missingFiles->count() > 0) {
|
||||
$missingFiles->each(function ($missingFile) use ($directory, &$missingFilesMessage) {
|
||||
$missingFilesMessage[$directory['name']][] = " {$directory['module']} - Missing language file: {$directory['name']}/{$missingFile}";
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
if (count($missingFilesMessage) > 0) {
|
||||
|
||||
collect($missingFilesMessage)->each(function ($messages, $langDirectory) {
|
||||
|
||||
$this->components->error("Missing language files in $langDirectory directory");
|
||||
|
||||
$this->components->bulletList(
|
||||
collect($messages)->unique()->values()->toArray()
|
||||
);
|
||||
|
||||
$this->newLine();
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private function checkMissingKeys(Collection $directories)
|
||||
{
|
||||
//show missing keys
|
||||
$uniqeLangFiles = $directories->pluck('files')->flatten()->unique();
|
||||
$langDirectories = $directories->pluck('name');
|
||||
|
||||
|
||||
$missingKeysMessage = [];
|
||||
$directories->each(function ($directory) use ($uniqeLangFiles, $langDirectories, &$missingKeysMessage) {
|
||||
|
||||
$uniqeLangFiles->each(function ($file) use ($directory, $langDirectories, &$missingKeysMessage) {
|
||||
$langKeys = $this->getLangKeys($directory['path'] . DIRECTORY_SEPARATOR . $file);
|
||||
|
||||
if ($langKeys == false) {
|
||||
return;
|
||||
}
|
||||
|
||||
$langDirectories->each(function ($langDirectory) use ($directory, $file, $langKeys, &$missingKeysMessage) {
|
||||
|
||||
if ($directory['name'] != $langDirectory) {
|
||||
|
||||
$basePath = str_replace($directory['name'], $langDirectory, $directory['path']);
|
||||
|
||||
$otherLangKeys = $this->getLangKeys($basePath . DIRECTORY_SEPARATOR . $file);
|
||||
|
||||
if ($otherLangKeys == false) {
|
||||
return;
|
||||
}
|
||||
|
||||
$missingKeys = $langKeys->diff($otherLangKeys);
|
||||
if ($missingKeys->count() > 0) {
|
||||
|
||||
$missingKeys->each(function ($missingKey) use ($directory, $langDirectory, $file, &$missingKeysMessage) {
|
||||
$missingKeysMessage[$langDirectory][] = " {$directory['module']} - Missing language key: {$langDirectory}/{$file} | key: $missingKey";
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
if (count($missingKeysMessage) > 0) {
|
||||
|
||||
collect($missingKeysMessage)->each(function ($messages, $langDirectory) {
|
||||
|
||||
$this->components->error("Missing language keys for directory $langDirectory:");
|
||||
|
||||
$this->components->bulletList(
|
||||
collect($messages)->unique()->values()->toArray()
|
||||
);
|
||||
|
||||
$this->newLine();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private function getLangKeys($file)
|
||||
{
|
||||
if (\File::exists($file)) {
|
||||
$lang = \File::getRequire($file);
|
||||
return collect(\Arr::dot($lang))->keys();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
-110
@@ -1,110 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Nwidart\Modules\Commands;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Nwidart\Modules\Support\Config\GenerateConfigReader;
|
||||
use Nwidart\Modules\Support\Stub;
|
||||
use Nwidart\Modules\Traits\ModuleCommandTrait;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
class CommandMakeCommand extends GeneratorCommand
|
||||
{
|
||||
use ModuleCommandTrait;
|
||||
|
||||
/**
|
||||
* The name of argument name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $argumentName = 'name';
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'module:make-command';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Generate new Artisan command for the specified module.';
|
||||
|
||||
public function getDefaultNamespace(): string
|
||||
{
|
||||
$module = $this->laravel['modules'];
|
||||
|
||||
return $module->config('paths.generator.command.namespace') ?: $module->config('paths.generator.command.path', 'Console');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getArguments()
|
||||
{
|
||||
return [
|
||||
['name', InputArgument::REQUIRED, 'The name of the command.'],
|
||||
['module', InputArgument::OPTIONAL, 'The name of module will be used.'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command options.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
return [
|
||||
['command', null, InputOption::VALUE_OPTIONAL, 'The terminal command that should be assigned.', null],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getTemplateContents()
|
||||
{
|
||||
$module = $this->laravel['modules']->findOrFail($this->getModuleName());
|
||||
|
||||
return (new Stub('/command.stub', [
|
||||
'COMMAND_NAME' => $this->getCommandName(),
|
||||
'NAMESPACE' => $this->getClassNamespace($module),
|
||||
'CLASS' => $this->getClass(),
|
||||
]))->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private function getCommandName()
|
||||
{
|
||||
return $this->option('command') ?: 'command:name';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getDestinationFilePath()
|
||||
{
|
||||
$path = $this->laravel['modules']->getModulePath($this->getModuleName());
|
||||
|
||||
$commandPath = GenerateConfigReader::read('command');
|
||||
|
||||
return $path . $commandPath->getPath() . '/' . $this->getFileName() . '.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private function getFileName()
|
||||
{
|
||||
return Str::studly($this->argument('name'));
|
||||
}
|
||||
}
|
||||
Vendored
-107
@@ -1,107 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Nwidart\Modules\Commands;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Nwidart\Modules\Support\Config\GenerateConfigReader;
|
||||
use Nwidart\Modules\Support\Stub;
|
||||
use Nwidart\Modules\Traits\ModuleCommandTrait;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
|
||||
class ComponentClassMakeCommand extends GeneratorCommand
|
||||
{
|
||||
use ModuleCommandTrait;
|
||||
|
||||
/**
|
||||
* The name of argument name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $argumentName = 'name';
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'module:make-component';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Create a new component-class for the specified module.';
|
||||
|
||||
public function handle(): int
|
||||
{
|
||||
if (parent::handle() === E_ERROR) {
|
||||
return E_ERROR;
|
||||
}
|
||||
$this->writeComponentViewTemplate();
|
||||
|
||||
return 0;
|
||||
}
|
||||
/**
|
||||
* Write the view template for the component.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function writeComponentViewTemplate()
|
||||
{
|
||||
$this->call('module:make-component-view', ['name' => $this->argument('name') , 'module' => $this->argument('module')]);
|
||||
}
|
||||
|
||||
public function getDefaultNamespace(): string
|
||||
{
|
||||
$module = $this->laravel['modules'];
|
||||
|
||||
return $module->config('paths.generator.component-class.namespace') ?: $module->config('paths.generator.component-class.path', 'View/Component');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getArguments()
|
||||
{
|
||||
return [
|
||||
['name', InputArgument::REQUIRED, 'The name of the component.'],
|
||||
['module', InputArgument::OPTIONAL, 'The name of module will be used.'],
|
||||
];
|
||||
}
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getTemplateContents()
|
||||
{
|
||||
$module = $this->laravel['modules']->findOrFail($this->getModuleName());
|
||||
|
||||
return (new Stub('/component-class.stub', [
|
||||
'NAMESPACE' => $this->getClassNamespace($module),
|
||||
'CLASS' => $this->getClass(),
|
||||
'LOWER_NAME' => $module->getLowerName(),
|
||||
'COMPONENT_NAME' => 'components.' . Str::lower($this->argument('name')),
|
||||
]))->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getDestinationFilePath()
|
||||
{
|
||||
$path = $this->laravel['modules']->getModulePath($this->getModuleName());
|
||||
$factoryPath = GenerateConfigReader::read('component-class');
|
||||
|
||||
return $path . $factoryPath->getPath() . '/' . $this->getFileName();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private function getFileName()
|
||||
{
|
||||
return Str::studly($this->argument('name')) . '.php';
|
||||
}
|
||||
}
|
||||
Vendored
-76
@@ -1,76 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Nwidart\Modules\Commands;
|
||||
|
||||
use Illuminate\Foundation\Inspiring;
|
||||
use Illuminate\Support\Str;
|
||||
use Nwidart\Modules\Support\Config\GenerateConfigReader;
|
||||
use Nwidart\Modules\Support\Stub;
|
||||
use Nwidart\Modules\Traits\ModuleCommandTrait;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
|
||||
class ComponentViewMakeCommand extends GeneratorCommand
|
||||
{
|
||||
use ModuleCommandTrait;
|
||||
|
||||
/**
|
||||
* The name of argument name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $argumentName = 'name';
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'module:make-component-view';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Create a new component-view for the specified module.';
|
||||
|
||||
/**
|
||||
* Get the console command arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getArguments()
|
||||
{
|
||||
return [
|
||||
['name', InputArgument::REQUIRED, 'The name of the component.'],
|
||||
['module', InputArgument::OPTIONAL, 'The name of module will be used.'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getTemplateContents()
|
||||
{
|
||||
return (new Stub('/component-view.stub', ['QUOTE'=> Inspiring::quote()]))->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getDestinationFilePath()
|
||||
{
|
||||
$path = $this->laravel['modules']->getModulePath($this->getModuleName());
|
||||
$factoryPath = GenerateConfigReader::read('component-view');
|
||||
|
||||
return $path . $factoryPath->getPath() . '/' . $this->getFileName();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private function getFileName()
|
||||
{
|
||||
return Str::lower($this->argument('name')) . '.blade.php';
|
||||
}
|
||||
}
|
||||
Vendored
-141
@@ -1,141 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Nwidart\Modules\Commands;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Nwidart\Modules\Support\Config\GenerateConfigReader;
|
||||
use Nwidart\Modules\Support\Stub;
|
||||
use Nwidart\Modules\Traits\ModuleCommandTrait;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
class ControllerMakeCommand extends GeneratorCommand
|
||||
{
|
||||
use ModuleCommandTrait;
|
||||
|
||||
/**
|
||||
* The name of argument being used.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $argumentName = 'controller';
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'module:make-controller';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Generate new restful controller for the specified module.';
|
||||
|
||||
/**
|
||||
* Get controller name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDestinationFilePath()
|
||||
{
|
||||
$path = $this->laravel['modules']->getModulePath($this->getModuleName());
|
||||
|
||||
$controllerPath = GenerateConfigReader::read('controller');
|
||||
|
||||
return $path . $controllerPath->getPath() . '/' . $this->getControllerName() . '.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function getTemplateContents()
|
||||
{
|
||||
$module = $this->laravel['modules']->findOrFail($this->getModuleName());
|
||||
|
||||
return (new Stub($this->getStubName(), [
|
||||
'MODULENAME' => $module->getStudlyName(),
|
||||
'CONTROLLERNAME' => $this->getControllerName(),
|
||||
'NAMESPACE' => $module->getStudlyName(),
|
||||
'CLASS_NAMESPACE' => $this->getClassNamespace($module),
|
||||
'CLASS' => $this->getControllerNameWithoutNamespace(),
|
||||
'LOWER_NAME' => $module->getLowerName(),
|
||||
'MODULE' => $this->getModuleName(),
|
||||
'NAME' => $this->getModuleName(),
|
||||
'STUDLY_NAME' => $module->getStudlyName(),
|
||||
'MODULE_NAMESPACE' => $this->laravel['modules']->config('namespace'),
|
||||
]))->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getArguments()
|
||||
{
|
||||
return [
|
||||
['controller', InputArgument::REQUIRED, 'The name of the controller class.'],
|
||||
['module', InputArgument::OPTIONAL, 'The name of module will be used.'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
return [
|
||||
['plain', 'p', InputOption::VALUE_NONE, 'Generate a plain controller', null],
|
||||
['api', null, InputOption::VALUE_NONE, 'Exclude the create and edit methods from the controller.'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|string
|
||||
*/
|
||||
protected function getControllerName()
|
||||
{
|
||||
$controller = Str::studly($this->argument('controller'));
|
||||
|
||||
if (Str::contains(strtolower($controller), 'controller') === false) {
|
||||
$controller .= 'Controller';
|
||||
}
|
||||
|
||||
return $controller;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|string
|
||||
*/
|
||||
private function getControllerNameWithoutNamespace()
|
||||
{
|
||||
return class_basename($this->getControllerName());
|
||||
}
|
||||
|
||||
public function getDefaultNamespace(): string
|
||||
{
|
||||
$module = $this->laravel['modules'];
|
||||
|
||||
return $module->config('paths.generator.controller.namespace') ?: $module->config('paths.generator.controller.path', 'Http/Controllers');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the stub file name based on the options
|
||||
* @return string
|
||||
*/
|
||||
protected function getStubName()
|
||||
{
|
||||
if ($this->option('plain') === true) {
|
||||
$stub = '/controller-plain.stub';
|
||||
} elseif ($this->option('api') === true) {
|
||||
$stub = '/controller-api.stub';
|
||||
} else {
|
||||
$stub = '/controller.stub';
|
||||
}
|
||||
|
||||
return $stub;
|
||||
}
|
||||
}
|
||||
-101
@@ -1,101 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Nwidart\Modules\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Nwidart\Modules\Module;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
|
||||
class DisableCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'module:disable';
|
||||
|
||||
/**
|
||||
* The console command signature.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'module:disable {module?*}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Disable an array of modules.';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
$this->components->info('Disabling module ...');
|
||||
|
||||
if (count($this->argument('module'))) {
|
||||
foreach($this->argument('module') as $name) {
|
||||
$this->disable($name);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
$this->disableAll();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* disableAll
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function disableAll()
|
||||
{
|
||||
/** @var Modules $modules */
|
||||
$modules = $this->laravel['modules']->all();
|
||||
|
||||
foreach ($modules as $module) {
|
||||
$this->disable($module);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* disable
|
||||
*
|
||||
* @param string $name
|
||||
* @return void
|
||||
*/
|
||||
public function disable($name)
|
||||
{
|
||||
if ($name instanceof Module) {
|
||||
$module = $name;
|
||||
}else {
|
||||
$module = $this->laravel['modules']->findOrFail($name);
|
||||
}
|
||||
|
||||
if ($module->isEnabled()) {
|
||||
$module->disable();
|
||||
|
||||
$this->components->info("Module [{$module}] disabled successful.");
|
||||
} else {
|
||||
$this->components->warn("Module [{$module}] has already disabled.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getArguments()
|
||||
{
|
||||
return [
|
||||
['module', InputArgument::OPTIONAL, 'Module name.'],
|
||||
];
|
||||
}
|
||||
}
|
||||
-85
@@ -1,85 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Nwidart\Modules\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Nwidart\Modules\Module;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
|
||||
class DumpCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'module:dump';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Dump-autoload the specified module or for all module.';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
$this->components->info('Generating optimized autoload modules.');
|
||||
|
||||
if ($name = $this->argument('module') ) {
|
||||
$this->dump($name);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
$this->dumpAll();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* dumpAll
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function dumpAll()
|
||||
{
|
||||
/** @var Modules $modules */
|
||||
$modules = $this->laravel['modules']->all();
|
||||
|
||||
foreach ($modules as $module) {
|
||||
$this->dump($module);
|
||||
}
|
||||
}
|
||||
|
||||
public function dump($name)
|
||||
{
|
||||
if ($name instanceof Module) {
|
||||
$module = $name;
|
||||
} else {
|
||||
$module = $this->laravel['modules']->findOrFail($name);
|
||||
}
|
||||
|
||||
$this->components->task("$module", function () use ($module) {
|
||||
chdir($module->getPath());
|
||||
|
||||
passthru('composer dump -o -n -q');
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getArguments()
|
||||
{
|
||||
return [
|
||||
['module', InputArgument::OPTIONAL, 'Module name.'],
|
||||
];
|
||||
}
|
||||
}
|
||||
-94
@@ -1,94 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Nwidart\Modules\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Nwidart\Modules\Module;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
|
||||
class EnableCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'module:enable';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Enable the specified module.';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
|
||||
$this->components->info('Enabling module ...');
|
||||
|
||||
if ($name = $this->argument('module') ) {
|
||||
$this->enable($name);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
$this->enableAll();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* enableAll
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function enableAll()
|
||||
{
|
||||
/** @var Modules $modules */
|
||||
$modules = $this->laravel['modules']->all();
|
||||
|
||||
foreach ($modules as $module) {
|
||||
$this->enable($module);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* enable
|
||||
*
|
||||
* @param string $name
|
||||
* @return void
|
||||
*/
|
||||
public function enable($name)
|
||||
{
|
||||
if ($name instanceof Module) {
|
||||
$module = $name;
|
||||
}else {
|
||||
$module = $this->laravel['modules']->findOrFail($name);
|
||||
}
|
||||
|
||||
if ($module->isDisabled()) {
|
||||
$module->enable();
|
||||
|
||||
$this->components->info("Module [{$module}] enabled successful.");
|
||||
}else {
|
||||
$this->components->warn("Module [{$module}] has already enabled.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getArguments()
|
||||
{
|
||||
return [
|
||||
['module', InputArgument::OPTIONAL, 'Module name.'],
|
||||
];
|
||||
}
|
||||
}
|
||||
-77
@@ -1,77 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Nwidart\Modules\Commands;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Nwidart\Modules\Support\Config\GenerateConfigReader;
|
||||
use Nwidart\Modules\Support\Stub;
|
||||
use Nwidart\Modules\Traits\ModuleCommandTrait;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
|
||||
class EventMakeCommand extends GeneratorCommand
|
||||
{
|
||||
use ModuleCommandTrait;
|
||||
|
||||
protected $argumentName = 'name';
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'module:make-event';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Create a new event class for the specified module';
|
||||
|
||||
public function getTemplateContents()
|
||||
{
|
||||
$module = $this->laravel['modules']->findOrFail($this->getModuleName());
|
||||
|
||||
return (new Stub('/event.stub', [
|
||||
'NAMESPACE' => $this->getClassNamespace($module),
|
||||
'CLASS' => $this->getClass(),
|
||||
]))->render();
|
||||
}
|
||||
|
||||
public function getDestinationFilePath()
|
||||
{
|
||||
$path = $this->laravel['modules']->getModulePath($this->getModuleName());
|
||||
|
||||
$eventPath = GenerateConfigReader::read('event');
|
||||
|
||||
return $path . $eventPath->getPath() . '/' . $this->getFileName() . '.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function getFileName()
|
||||
{
|
||||
return Str::studly($this->argument('name'));
|
||||
}
|
||||
|
||||
public function getDefaultNamespace(): string
|
||||
{
|
||||
$module = $this->laravel['modules'];
|
||||
|
||||
return $module->config('paths.generator.event.namespace') ?: $module->config('paths.generator.event.path', 'Events');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getArguments()
|
||||
{
|
||||
return [
|
||||
['name', InputArgument::REQUIRED, 'The name of the event.'],
|
||||
['module', InputArgument::OPTIONAL, 'The name of module will be used.'],
|
||||
];
|
||||
}
|
||||
}
|
||||
-116
@@ -1,116 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Nwidart\Modules\Commands;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Nwidart\Modules\Support\Config\GenerateConfigReader;
|
||||
use Nwidart\Modules\Support\Stub;
|
||||
use Nwidart\Modules\Traits\ModuleCommandTrait;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
|
||||
class FactoryMakeCommand extends GeneratorCommand
|
||||
{
|
||||
use ModuleCommandTrait;
|
||||
|
||||
/**
|
||||
* The name of argument name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $argumentName = 'name';
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'module:make-factory';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Create a new model factory for the specified module.';
|
||||
|
||||
/**
|
||||
* Get the console command arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getArguments()
|
||||
{
|
||||
return [
|
||||
['name', InputArgument::REQUIRED, 'The name of the model.'],
|
||||
['module', InputArgument::OPTIONAL, 'The name of module will be used.'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getTemplateContents()
|
||||
{
|
||||
$module = $this->laravel['modules']->findOrFail($this->getModuleName());
|
||||
|
||||
return (new Stub('/factory.stub', [
|
||||
'NAMESPACE' => $this->getClassNamespace($module),
|
||||
'NAME' => $this->getModelName(),
|
||||
'MODEL_NAMESPACE' => $this->getModelNamespace(),
|
||||
]))->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getDestinationFilePath()
|
||||
{
|
||||
$path = $this->laravel['modules']->getModulePath($this->getModuleName());
|
||||
|
||||
$factoryPath = GenerateConfigReader::read('factory');
|
||||
|
||||
return $path . $factoryPath->getPath() . '/' . $this->getFileName();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private function getFileName()
|
||||
{
|
||||
return Str::studly($this->argument('name')) . 'Factory.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed|string
|
||||
*/
|
||||
private function getModelName()
|
||||
{
|
||||
return Str::studly($this->argument('name'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get default namespace.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDefaultNamespace(): string
|
||||
{
|
||||
$module = $this->laravel['modules'];
|
||||
|
||||
return $module->config('paths.generator.factory.namespace') ?: $module->config('paths.generator.factory.path');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get model namespace.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getModelNamespace(): string
|
||||
{
|
||||
$path = $this->laravel['modules']->config('paths.generator.model.path', 'Entities');
|
||||
|
||||
$path = str_replace('/', '\\', $path);
|
||||
|
||||
return $this->laravel['modules']->config('namespace') . '\\' . $this->laravel['modules']->findOrFail($this->getModuleName()) . '\\' . $path;
|
||||
}
|
||||
}
|
||||
-105
@@ -1,105 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Nwidart\Modules\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Nwidart\Modules\Exceptions\FileAlreadyExistException;
|
||||
use Nwidart\Modules\Generators\FileGenerator;
|
||||
|
||||
abstract class GeneratorCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name of 'name' argument.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $argumentName = '';
|
||||
|
||||
/**
|
||||
* Get template contents.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
abstract protected function getTemplateContents();
|
||||
|
||||
/**
|
||||
* Get the destination file path.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
abstract protected function getDestinationFilePath();
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
$path = str_replace('\\', '/', $this->getDestinationFilePath());
|
||||
|
||||
if (!$this->laravel['files']->isDirectory($dir = dirname($path))) {
|
||||
$this->laravel['files']->makeDirectory($dir, 0777, true);
|
||||
}
|
||||
|
||||
$contents = $this->getTemplateContents();
|
||||
|
||||
try {
|
||||
$this->components->task("Generating file {$path}",function () use ($path,$contents) {
|
||||
$overwriteFile = $this->hasOption('force') ? $this->option('force') : false;
|
||||
(new FileGenerator($path, $contents))->withFileOverwrite($overwriteFile)->generate();
|
||||
});
|
||||
|
||||
} catch (FileAlreadyExistException $e) {
|
||||
$this->components->error("File : {$path} already exists.");
|
||||
|
||||
return E_ERROR;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get class name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getClass()
|
||||
{
|
||||
return class_basename($this->argument($this->argumentName));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get default namespace.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDefaultNamespace(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get class namespace.
|
||||
*
|
||||
* @param \Nwidart\Modules\Module $module
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getClassNamespace($module)
|
||||
{
|
||||
$extra = str_replace($this->getClass(), '', $this->argument($this->argumentName));
|
||||
|
||||
$extra = str_replace('/', '\\', $extra);
|
||||
|
||||
$namespace = $this->laravel['modules']->config('namespace');
|
||||
|
||||
$namespace .= '\\' . $module->getStudlyName();
|
||||
|
||||
$namespace .= '\\' . $this->getDefaultNamespace();
|
||||
|
||||
$namespace .= '\\' . $extra;
|
||||
|
||||
$namespace = str_replace('/', '\\', $namespace);
|
||||
|
||||
return trim($namespace, '\\');
|
||||
}
|
||||
}
|
||||
-148
@@ -1,148 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Nwidart\Modules\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Nwidart\Modules\Json;
|
||||
use Nwidart\Modules\Process\Installer;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
class InstallCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'module:install';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Install the specified module by given package name (vendor/name).';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
if (is_null($this->argument('name'))) {
|
||||
return $this->installFromFile();
|
||||
}
|
||||
|
||||
$this->install(
|
||||
$this->argument('name'),
|
||||
$this->argument('version'),
|
||||
$this->option('type'),
|
||||
$this->option('tree')
|
||||
);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Install modules from modules.json file.
|
||||
*/
|
||||
protected function installFromFile(): int
|
||||
{
|
||||
if (!file_exists($path = base_path('modules.json'))) {
|
||||
$this->error("File 'modules.json' does not exist in your project root.");
|
||||
|
||||
return E_ERROR;
|
||||
}
|
||||
|
||||
$modules = Json::make($path);
|
||||
|
||||
$dependencies = $modules->get('require', []);
|
||||
|
||||
foreach ($dependencies as $module) {
|
||||
$module = collect($module);
|
||||
|
||||
$this->install(
|
||||
$module->get('name'),
|
||||
$module->get('version'),
|
||||
$module->get('type')
|
||||
);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Install the specified module.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $version
|
||||
* @param string $type
|
||||
* @param bool $tree
|
||||
*/
|
||||
protected function install($name, $version = 'dev-master', $type = 'composer', $tree = false)
|
||||
{
|
||||
$installer = new Installer(
|
||||
$name,
|
||||
$version,
|
||||
$type ?: $this->option('type'),
|
||||
$tree ?: $this->option('tree')
|
||||
);
|
||||
|
||||
$installer->setRepository($this->laravel['modules']);
|
||||
|
||||
$installer->setConsole($this);
|
||||
|
||||
if ($timeout = $this->option('timeout')) {
|
||||
$installer->setTimeout($timeout);
|
||||
}
|
||||
|
||||
if ($path = $this->option('path')) {
|
||||
$installer->setPath($path);
|
||||
}
|
||||
|
||||
$installer->run();
|
||||
|
||||
if (!$this->option('no-update')) {
|
||||
$this->call('module:update', [
|
||||
'module' => $installer->getModuleName(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getArguments()
|
||||
{
|
||||
return [
|
||||
['name', InputArgument::OPTIONAL, 'The name of module will be installed.'],
|
||||
['version', InputArgument::OPTIONAL, 'The version of module will be installed.'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command options.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
return [
|
||||
['timeout', null, InputOption::VALUE_OPTIONAL, 'The process timeout.', null],
|
||||
['path', null, InputOption::VALUE_OPTIONAL, 'The installation path.', null],
|
||||
['type', null, InputOption::VALUE_OPTIONAL, 'The type of installation.', null],
|
||||
['tree', null, InputOption::VALUE_NONE, 'Install the module as a git subtree', null],
|
||||
['no-update', null, InputOption::VALUE_NONE, 'Disables the automatic update of the dependencies.', null],
|
||||
];
|
||||
}
|
||||
}
|
||||
-112
@@ -1,112 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Nwidart\Modules\Commands;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Nwidart\Modules\Support\Config\GenerateConfigReader;
|
||||
use Nwidart\Modules\Support\Stub;
|
||||
use Nwidart\Modules\Traits\ModuleCommandTrait;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
class JobMakeCommand extends GeneratorCommand
|
||||
{
|
||||
use ModuleCommandTrait;
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'module:make-job';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Create a new job class for the specified module';
|
||||
|
||||
protected $argumentName = 'name';
|
||||
|
||||
public function getDefaultNamespace(): string
|
||||
{
|
||||
$module = $this->laravel['modules'];
|
||||
|
||||
return $module->config('paths.generator.jobs.namespace') ?: $module->config('paths.generator.jobs.path', 'Jobs');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getArguments()
|
||||
{
|
||||
return [
|
||||
['name', InputArgument::REQUIRED, 'The name of the job.'],
|
||||
['module', InputArgument::OPTIONAL, 'The name of module will be used.'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command options.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
return [
|
||||
['sync', null, InputOption::VALUE_NONE, 'Indicates that job should be synchronous.'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get template contents.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getTemplateContents()
|
||||
{
|
||||
$module = $this->laravel['modules']->findOrFail($this->getModuleName());
|
||||
|
||||
return (new Stub($this->getStubName(), [
|
||||
'NAMESPACE' => $this->getClassNamespace($module),
|
||||
'CLASS' => $this->getClass(),
|
||||
]))->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the destination file path.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getDestinationFilePath()
|
||||
{
|
||||
$path = $this->laravel['modules']->getModulePath($this->getModuleName());
|
||||
|
||||
$jobPath = GenerateConfigReader::read('jobs');
|
||||
|
||||
return $path . $jobPath->getPath() . '/' . $this->getFileName() . '.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private function getFileName()
|
||||
{
|
||||
return Str::studly($this->argument('name'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function getStubName(): string
|
||||
{
|
||||
if ($this->option('sync')) {
|
||||
return '/job.stub';
|
||||
}
|
||||
|
||||
return '/job-queued.stub';
|
||||
}
|
||||
}
|
||||
Vendored
-39
@@ -1,39 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Nwidart\Modules\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Nwidart\Modules\Contracts\RepositoryInterface;
|
||||
use Nwidart\Modules\Module;
|
||||
|
||||
class LaravelModulesV6Migrator extends Command
|
||||
{
|
||||
protected $name = 'module:v6:migrate';
|
||||
protected $description = 'Migrate laravel-modules v5 modules statuses to v6.';
|
||||
|
||||
public function handle(): int
|
||||
{
|
||||
$moduleStatuses = [];
|
||||
/** @var RepositoryInterface $modules */
|
||||
$modules = $this->laravel['modules'];
|
||||
|
||||
$modules = $modules->all();
|
||||
/** @var Module $module */
|
||||
foreach ($modules as $module) {
|
||||
if ($module->json()->get('active') === 1) {
|
||||
$module->enable();
|
||||
$moduleStatuses[] = [$module->getName(), 'Enabled'];
|
||||
}
|
||||
if ($module->json()->get('active') === 0) {
|
||||
$module->disable();
|
||||
$moduleStatuses[] = [$module->getName(), 'Disabled'];
|
||||
}
|
||||
}
|
||||
$this->info('All modules have been migrated.');
|
||||
$this->table(['Module name', 'Status'], $moduleStatuses);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
-98
@@ -1,98 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Nwidart\Modules\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Nwidart\Modules\Module;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
class ListCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'module:list';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Show list of all modules.';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
$this->components->twoColumnDetail('<fg=gray>Status / Name</>', '<fg=gray>Path / priority</>');
|
||||
collect($this->getRows())->each(function ($row) {
|
||||
|
||||
$this->components->twoColumnDetail("[{$row[1]}] {$row[0]}", "{$row[3]} [{$row[2]}]");
|
||||
});
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get table rows.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getRows()
|
||||
{
|
||||
$rows = [];
|
||||
|
||||
/** @var Module $module */
|
||||
foreach ($this->getModules() as $module) {
|
||||
$rows[] = [
|
||||
$module->getName(),
|
||||
$module->isEnabled() ? '<fg=green>Enabled</>' : '<fg=red>Disabled</>',
|
||||
$module->get('priority'),
|
||||
$module->getPath(),
|
||||
];
|
||||
}
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
public function getModules()
|
||||
{
|
||||
switch ($this->option('only')) {
|
||||
case 'enabled':
|
||||
return $this->laravel['modules']->getByStatus(1);
|
||||
|
||||
break;
|
||||
|
||||
case 'disabled':
|
||||
return $this->laravel['modules']->getByStatus(0);
|
||||
|
||||
break;
|
||||
|
||||
case 'priority':
|
||||
return $this->laravel['modules']->getPriority($this->option('direction'));
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
return $this->laravel['modules']->all();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command options.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
return [
|
||||
['only', 'o', InputOption::VALUE_OPTIONAL, 'Types of modules will be displayed.', null],
|
||||
['direction', 'd', InputOption::VALUE_OPTIONAL, 'The direction of ordering.', 'asc'],
|
||||
];
|
||||
}
|
||||
}
|
||||
-129
@@ -1,129 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Nwidart\Modules\Commands;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Nwidart\Modules\Module;
|
||||
use Nwidart\Modules\Support\Config\GenerateConfigReader;
|
||||
use Nwidart\Modules\Support\Stub;
|
||||
use Nwidart\Modules\Traits\ModuleCommandTrait;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
class ListenerMakeCommand extends GeneratorCommand
|
||||
{
|
||||
use ModuleCommandTrait;
|
||||
|
||||
protected $argumentName = 'name';
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'module:make-listener';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Create a new event listener class for the specified module';
|
||||
|
||||
/**
|
||||
* Get the console command arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getArguments()
|
||||
{
|
||||
return [
|
||||
['name', InputArgument::REQUIRED, 'The name of the command.'],
|
||||
['module', InputArgument::OPTIONAL, 'The name of module will be used.'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command options.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
return [
|
||||
['event', 'e', InputOption::VALUE_OPTIONAL, 'The event class being listened for.'],
|
||||
['queued', null, InputOption::VALUE_NONE, 'Indicates the event listener should be queued.'],
|
||||
];
|
||||
}
|
||||
|
||||
protected function getTemplateContents()
|
||||
{
|
||||
$module = $this->laravel['modules']->findOrFail($this->getModuleName());
|
||||
|
||||
return (new Stub($this->getStubName(), [
|
||||
'NAMESPACE' => $this->getClassNamespace($module),
|
||||
'EVENTNAME' => $this->getEventName($module),
|
||||
'SHORTEVENTNAME' => $this->getShortEventName(),
|
||||
'CLASS' => $this->getClass(),
|
||||
]))->render();
|
||||
}
|
||||
|
||||
public function getDefaultNamespace(): string
|
||||
{
|
||||
$module = $this->laravel['modules'];
|
||||
|
||||
return $module->config('paths.generator.listener.namespace') ?: $module->config('paths.generator.listener.path', 'Listeners');
|
||||
}
|
||||
|
||||
protected function getEventName(Module $module)
|
||||
{
|
||||
$namespace = $this->laravel['modules']->config('namespace') . "\\" . $module->getStudlyName();
|
||||
$eventPath = GenerateConfigReader::read('event');
|
||||
|
||||
$eventName = $namespace . "\\" . $eventPath->getPath() . "\\" . $this->option('event');
|
||||
|
||||
return str_replace('/', '\\', $eventName);
|
||||
}
|
||||
|
||||
protected function getShortEventName()
|
||||
{
|
||||
return class_basename($this->option('event'));
|
||||
}
|
||||
|
||||
protected function getDestinationFilePath()
|
||||
{
|
||||
$path = $this->laravel['modules']->getModulePath($this->getModuleName());
|
||||
|
||||
$listenerPath = GenerateConfigReader::read('listener');
|
||||
|
||||
return $path . $listenerPath->getPath() . '/' . $this->getFileName() . '.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function getFileName()
|
||||
{
|
||||
return Str::studly($this->argument('name'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function getStubName(): string
|
||||
{
|
||||
if ($this->option('queued')) {
|
||||
if ($this->option('event')) {
|
||||
return '/listener-queued.stub';
|
||||
}
|
||||
|
||||
return '/listener-queued-duck.stub';
|
||||
}
|
||||
|
||||
if ($this->option('event')) {
|
||||
return '/listener.stub';
|
||||
}
|
||||
|
||||
return '/listener-duck.stub';
|
||||
}
|
||||
}
|
||||
-87
@@ -1,87 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Nwidart\Modules\Commands;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Nwidart\Modules\Support\Config\GenerateConfigReader;
|
||||
use Nwidart\Modules\Support\Stub;
|
||||
use Nwidart\Modules\Traits\ModuleCommandTrait;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
|
||||
class MailMakeCommand extends GeneratorCommand
|
||||
{
|
||||
use ModuleCommandTrait;
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'module:make-mail';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Create a new email class for the specified module';
|
||||
|
||||
protected $argumentName = 'name';
|
||||
|
||||
public function getDefaultNamespace(): string
|
||||
{
|
||||
$module = $this->laravel['modules'];
|
||||
|
||||
return $module->config('paths.generator.emails.namespace') ?: $module->config('paths.generator.emails.path', 'Emails');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getArguments()
|
||||
{
|
||||
return [
|
||||
['name', InputArgument::REQUIRED, 'The name of the mailable.'],
|
||||
['module', InputArgument::OPTIONAL, 'The name of module will be used.'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get template contents.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getTemplateContents()
|
||||
{
|
||||
$module = $this->laravel['modules']->findOrFail($this->getModuleName());
|
||||
|
||||
return (new Stub('/mail.stub', [
|
||||
'NAMESPACE' => $this->getClassNamespace($module),
|
||||
'CLASS' => $this->getClass(),
|
||||
]))->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the destination file path.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getDestinationFilePath()
|
||||
{
|
||||
$path = $this->laravel['modules']->getModulePath($this->getModuleName());
|
||||
|
||||
$mailPath = GenerateConfigReader::read('emails');
|
||||
|
||||
return $path . $mailPath->getPath() . '/' . $this->getFileName() . '.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private function getFileName()
|
||||
{
|
||||
return Str::studly($this->argument('name'));
|
||||
}
|
||||
}
|
||||
Vendored
-101
@@ -1,101 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Nwidart\Modules\Commands;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Nwidart\Modules\Support\Config\GenerateConfigReader;
|
||||
use Nwidart\Modules\Support\Stub;
|
||||
use Nwidart\Modules\Traits\ModuleCommandTrait;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
|
||||
class MiddlewareMakeCommand extends GeneratorCommand
|
||||
{
|
||||
use ModuleCommandTrait;
|
||||
|
||||
/**
|
||||
* The name of argument name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $argumentName = 'name';
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'module:make-middleware';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Create a new middleware class for the specified module.';
|
||||
|
||||
public function getDefaultNamespace(): string
|
||||
{
|
||||
$module = $this->laravel['modules'];
|
||||
|
||||
return $module->config('paths.generator.filter.namespace') ?: $module->config('paths.generator.filter.path', 'Http/Middleware');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getArguments()
|
||||
{
|
||||
return [
|
||||
['name', InputArgument::REQUIRED, 'The name of the command.'],
|
||||
['module', InputArgument::OPTIONAL, 'The name of module will be used.'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getTemplateContents()
|
||||
{
|
||||
$module = $this->laravel['modules']->findOrFail($this->getModuleName());
|
||||
|
||||
return (new Stub('/middleware.stub', [
|
||||
'NAMESPACE' => $this->getClassNamespace($module),
|
||||
'CLASS' => $this->getClass(),
|
||||
]))->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getDestinationFilePath()
|
||||
{
|
||||
$path = $this->laravel['modules']->getModulePath($this->getModuleName());
|
||||
|
||||
$middlewarePath = GenerateConfigReader::read('filter');
|
||||
|
||||
return $path . $middlewarePath->getPath() . '/' . $this->getFileName() . '.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private function getFileName()
|
||||
{
|
||||
return Str::studly($this->argument('name'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the command.
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
|
||||
$this->components->info('Creating middleware...');
|
||||
|
||||
parent::handle();
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
-113
@@ -1,113 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Nwidart\Modules\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Nwidart\Modules\Migrations\Migrator;
|
||||
use Nwidart\Modules\Module;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
class MigrateCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'module:migrate';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Migrate the migrations from the specified module or from all modules.';
|
||||
|
||||
/**
|
||||
* @var \Nwidart\Modules\Contracts\RepositoryInterface
|
||||
*/
|
||||
protected $module;
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
$this->module = $this->laravel['modules'];
|
||||
|
||||
$name = $this->argument('module');
|
||||
|
||||
if ($name) {
|
||||
$module = $this->module->findOrFail($name);
|
||||
|
||||
$this->migrate($module);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
foreach ($this->module->getOrdered($this->option('direction')) as $module) {
|
||||
$this->line('Running for module: <info>' . $module->getName() . '</info>');
|
||||
|
||||
$this->migrate($module);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migration from the specified module.
|
||||
*
|
||||
* @param Module $module
|
||||
*/
|
||||
protected function migrate(Module $module)
|
||||
{
|
||||
$path = str_replace(base_path(), '', (new Migrator($module, $this->getLaravel()))->getPath());
|
||||
|
||||
if ($this->option('subpath')) {
|
||||
$path = $path . "/" . $this->option("subpath");
|
||||
}
|
||||
|
||||
$this->call('migrate', [
|
||||
'--path' => $path,
|
||||
'--database' => $this->option('database'),
|
||||
'--pretend' => $this->option('pretend'),
|
||||
'--force' => $this->option('force'),
|
||||
]);
|
||||
|
||||
if ($this->option('seed')) {
|
||||
$this->call('module:seed', ['module' => $module->getName(), '--force' => $this->option('force')]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getArguments()
|
||||
{
|
||||
return [
|
||||
['module', InputArgument::OPTIONAL, 'The name of module will be used.'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command options.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
return [
|
||||
['direction', 'd', InputOption::VALUE_OPTIONAL, 'The direction of ordering.', 'asc'],
|
||||
['database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use.'],
|
||||
['pretend', null, InputOption::VALUE_NONE, 'Dump the SQL queries that would be run.'],
|
||||
['force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production.'],
|
||||
['seed', null, InputOption::VALUE_NONE, 'Indicates if the seed task should be re-run.'],
|
||||
['subpath', null, InputOption::VALUE_OPTIONAL, 'Indicate a subpath to run your migrations from'],
|
||||
];
|
||||
}
|
||||
}
|
||||
-91
@@ -1,91 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Nwidart\Modules\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Nwidart\Modules\Traits\ModuleCommandTrait;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
class MigrateFreshCommand extends Command
|
||||
{
|
||||
use ModuleCommandTrait;
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'module:migrate-fresh';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Drop all database tables and re-run all migrations';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
$module = $this->argument('module');
|
||||
|
||||
if ($module && !$this->getModuleName()) {
|
||||
$this->error("Module [$module] does not exists.");
|
||||
|
||||
return E_ERROR;
|
||||
}
|
||||
|
||||
$this->call('migrate:fresh');
|
||||
|
||||
$this->call('module:migrate', [
|
||||
'module' => $this->getModuleName(),
|
||||
'--database' => $this->option('database'),
|
||||
'--force' => $this->option('force'),
|
||||
'--seed' => $this->option('seed'),
|
||||
]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getArguments()
|
||||
{
|
||||
return [
|
||||
['module', InputArgument::OPTIONAL, 'The name of module will be used.'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command options.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
return [
|
||||
['database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use.'],
|
||||
['force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production.'],
|
||||
['seed', null, InputOption::VALUE_NONE, 'Indicates if the seed task should be re-run.'],
|
||||
];
|
||||
}
|
||||
|
||||
public function getModuleName()
|
||||
{
|
||||
$module = $this->argument('module');
|
||||
|
||||
if (!$module) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$module = app('modules')->find($module);
|
||||
|
||||
return $module ? $module->getStudlyName() : null;
|
||||
}
|
||||
}
|
||||
Vendored
-100
@@ -1,100 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Nwidart\Modules\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Nwidart\Modules\Traits\ModuleCommandTrait;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
class MigrateRefreshCommand extends Command
|
||||
{
|
||||
use ModuleCommandTrait;
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'module:migrate-refresh';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Rollback & re-migrate the modules migrations.';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
$module = $this->argument('module');
|
||||
|
||||
if ($module && !$this->getModuleName()) {
|
||||
$this->error("Module [$module] does not exists.");
|
||||
|
||||
return E_ERROR;
|
||||
}
|
||||
|
||||
$this->call('module:migrate-reset', [
|
||||
'module' => $this->getModuleName(),
|
||||
'--database' => $this->option('database'),
|
||||
'--force' => $this->option('force'),
|
||||
]);
|
||||
|
||||
$this->call('module:migrate', [
|
||||
'module' => $this->getModuleName(),
|
||||
'--database' => $this->option('database'),
|
||||
'--force' => $this->option('force'),
|
||||
]);
|
||||
|
||||
if ($this->option('seed')) {
|
||||
$this->call('module:seed', [
|
||||
'module' => $this->getModuleName(),
|
||||
]);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getArguments()
|
||||
{
|
||||
return [
|
||||
['module', InputArgument::OPTIONAL, 'The name of module will be used.'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command options.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
return [
|
||||
['database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use.'],
|
||||
['force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production.'],
|
||||
['seed', null, InputOption::VALUE_NONE, 'Indicates if the seed task should be re-run.'],
|
||||
];
|
||||
}
|
||||
|
||||
public function getModuleName()
|
||||
{
|
||||
$module = $this->argument('module');
|
||||
|
||||
if (!$module) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$module = app('modules')->find($module);
|
||||
|
||||
return $module ? $module->getStudlyName() : null;
|
||||
}
|
||||
}
|
||||
-116
@@ -1,116 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Nwidart\Modules\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Nwidart\Modules\Migrations\Migrator;
|
||||
use Nwidart\Modules\Traits\MigrationLoaderTrait;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
class MigrateResetCommand extends Command
|
||||
{
|
||||
use MigrationLoaderTrait;
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'module:migrate-reset';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Reset the modules migrations.';
|
||||
|
||||
/**
|
||||
* @var \Nwidart\Modules\Contracts\RepositoryInterface
|
||||
*/
|
||||
protected $module;
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
$this->module = $this->laravel['modules'];
|
||||
|
||||
$name = $this->argument('module');
|
||||
|
||||
if (!empty($name)) {
|
||||
$this->reset($name);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
foreach ($this->module->getOrdered($this->option('direction')) as $module) {
|
||||
$this->line('Running for module: <info>' . $module->getName() . '</info>');
|
||||
|
||||
$this->reset($module);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rollback migration from the specified module.
|
||||
*
|
||||
* @param $module
|
||||
*/
|
||||
public function reset($module)
|
||||
{
|
||||
if (is_string($module)) {
|
||||
$module = $this->module->findOrFail($module);
|
||||
}
|
||||
|
||||
$migrator = new Migrator($module, $this->getLaravel());
|
||||
|
||||
$database = $this->option('database');
|
||||
|
||||
if (!empty($database)) {
|
||||
$migrator->setDatabase($database);
|
||||
}
|
||||
|
||||
$migrated = $migrator->reset();
|
||||
|
||||
if (count($migrated)) {
|
||||
foreach ($migrated as $migration) {
|
||||
$this->line("Rollback: <info>{$migration}</info>");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->comment('Nothing to rollback.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getArguments()
|
||||
{
|
||||
return [
|
||||
['module', InputArgument::OPTIONAL, 'The name of module will be used.'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command options.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
return [
|
||||
['direction', 'd', InputOption::VALUE_OPTIONAL, 'The direction of ordering.', 'desc'],
|
||||
['database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use.'],
|
||||
['force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production.'],
|
||||
['pretend', null, InputOption::VALUE_NONE, 'Dump the SQL queries that would be run.'],
|
||||
];
|
||||
}
|
||||
}
|
||||
Vendored
-117
@@ -1,117 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Nwidart\Modules\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Nwidart\Modules\Migrations\Migrator;
|
||||
use Nwidart\Modules\Traits\MigrationLoaderTrait;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
class MigrateRollbackCommand extends Command
|
||||
{
|
||||
use MigrationLoaderTrait;
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'module:migrate-rollback';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Rollback the modules migrations.';
|
||||
|
||||
/**
|
||||
* @var \Nwidart\Modules\Contracts\RepositoryInterface
|
||||
*/
|
||||
protected $module;
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
$this->module = $this->laravel['modules'];
|
||||
|
||||
$name = $this->argument('module');
|
||||
|
||||
if (!empty($name)) {
|
||||
$this->rollback($name);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
foreach ($this->module->getOrdered($this->option('direction')) as $module) {
|
||||
$this->line('Running for module: <info>' . $module->getName() . '</info>');
|
||||
|
||||
$this->rollback($module);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rollback migration from the specified module.
|
||||
*
|
||||
* @param $module
|
||||
*/
|
||||
public function rollback($module)
|
||||
{
|
||||
if (is_string($module)) {
|
||||
$module = $this->module->findOrFail($module);
|
||||
}
|
||||
|
||||
$migrator = new Migrator($module, $this->getLaravel(), $this->option('subpath'));
|
||||
|
||||
$database = $this->option('database');
|
||||
|
||||
if (!empty($database)) {
|
||||
$migrator->setDatabase($database);
|
||||
}
|
||||
|
||||
$migrated = $migrator->rollback();
|
||||
|
||||
if (count($migrated)) {
|
||||
foreach ($migrated as $migration) {
|
||||
$this->line("Rollback: <info>{$migration}</info>");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->comment('Nothing to rollback.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getArguments()
|
||||
{
|
||||
return [
|
||||
['module', InputArgument::OPTIONAL, 'The name of module will be used.'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command options.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
return [
|
||||
['direction', 'd', InputOption::VALUE_OPTIONAL, 'The direction of ordering.', 'desc'],
|
||||
['database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use.'],
|
||||
['force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production.'],
|
||||
['pretend', null, InputOption::VALUE_NONE, 'Dump the SQL queries that would be run.'],
|
||||
['subpath', null, InputOption::VALUE_OPTIONAL, 'Indicate a subpath for modules specific migration file']
|
||||
];
|
||||
}
|
||||
}
|
||||
-98
@@ -1,98 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Nwidart\Modules\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Nwidart\Modules\Migrations\Migrator;
|
||||
use Nwidart\Modules\Module;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
class MigrateStatusCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'module:migrate-status';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Status for all module migrations';
|
||||
|
||||
/**
|
||||
* @var \Nwidart\Modules\Contracts\RepositoryInterface
|
||||
*/
|
||||
protected $module;
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
$this->module = $this->laravel['modules'];
|
||||
|
||||
$name = $this->argument('module');
|
||||
|
||||
if ($name) {
|
||||
$module = $this->module->findOrFail($name);
|
||||
|
||||
$this->migrateStatus($module);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
foreach ($this->module->getOrdered($this->option('direction')) as $module) {
|
||||
$this->line('Running for module: <info>' . $module->getName() . '</info>');
|
||||
$this->migrateStatus($module);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migration from the specified module.
|
||||
*
|
||||
* @param Module $module
|
||||
*/
|
||||
protected function migrateStatus(Module $module)
|
||||
{
|
||||
$path = str_replace(base_path(), '', (new Migrator($module, $this->getLaravel()))->getPath());
|
||||
|
||||
$this->call('migrate:status', [
|
||||
'--path' => $path,
|
||||
'--database' => $this->option('database'),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getArguments()
|
||||
{
|
||||
return [
|
||||
['module', InputArgument::OPTIONAL, 'The name of module will be used.'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command options.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
return [
|
||||
['direction', 'd', InputOption::VALUE_OPTIONAL, 'The direction of ordering.', 'asc'],
|
||||
['database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use.'],
|
||||
];
|
||||
}
|
||||
}
|
||||
-169
@@ -1,169 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Nwidart\Modules\Commands;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Nwidart\Modules\Support\Config\GenerateConfigReader;
|
||||
use Nwidart\Modules\Support\Migrations\NameParser;
|
||||
use Nwidart\Modules\Support\Migrations\SchemaParser;
|
||||
use Nwidart\Modules\Support\Stub;
|
||||
use Nwidart\Modules\Traits\ModuleCommandTrait;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
class MigrationMakeCommand extends GeneratorCommand
|
||||
{
|
||||
use ModuleCommandTrait;
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'module:make-migration';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Create a new migration for the specified module.';
|
||||
|
||||
/**
|
||||
* Get the console command arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getArguments()
|
||||
{
|
||||
return [
|
||||
['name', InputArgument::REQUIRED, 'The migration name will be created.'],
|
||||
['module', InputArgument::OPTIONAL, 'The name of module will be created.'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command options.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
return [
|
||||
['fields', null, InputOption::VALUE_OPTIONAL, 'The specified fields table.', null],
|
||||
['plain', null, InputOption::VALUE_NONE, 'Create plain migration.'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get schema parser.
|
||||
*
|
||||
* @return SchemaParser
|
||||
*/
|
||||
public function getSchemaParser()
|
||||
{
|
||||
return new SchemaParser($this->option('fields'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getTemplateContents()
|
||||
{
|
||||
$parser = new NameParser($this->argument('name'));
|
||||
|
||||
if ($parser->isCreate()) {
|
||||
return Stub::create('/migration/create.stub', [
|
||||
'class' => $this->getClass(),
|
||||
'table' => $parser->getTableName(),
|
||||
'fields' => $this->getSchemaParser()->render(),
|
||||
]);
|
||||
} elseif ($parser->isAdd()) {
|
||||
return Stub::create('/migration/add.stub', [
|
||||
'class' => $this->getClass(),
|
||||
'table' => $parser->getTableName(),
|
||||
'fields_up' => $this->getSchemaParser()->up(),
|
||||
'fields_down' => $this->getSchemaParser()->down(),
|
||||
]);
|
||||
} elseif ($parser->isDelete()) {
|
||||
return Stub::create('/migration/delete.stub', [
|
||||
'class' => $this->getClass(),
|
||||
'table' => $parser->getTableName(),
|
||||
'fields_down' => $this->getSchemaParser()->up(),
|
||||
'fields_up' => $this->getSchemaParser()->down(),
|
||||
]);
|
||||
} elseif ($parser->isDrop()) {
|
||||
return Stub::create('/migration/drop.stub', [
|
||||
'class' => $this->getClass(),
|
||||
'table' => $parser->getTableName(),
|
||||
'fields' => $this->getSchemaParser()->render(),
|
||||
]);
|
||||
}
|
||||
|
||||
return Stub::create('/migration/plain.stub', [
|
||||
'class' => $this->getClass(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getDestinationFilePath()
|
||||
{
|
||||
$path = $this->laravel['modules']->getModulePath($this->getModuleName());
|
||||
|
||||
$generatorPath = GenerateConfigReader::read('migration');
|
||||
|
||||
return $path . $generatorPath->getPath() . '/' . $this->getFileName() . '.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private function getFileName()
|
||||
{
|
||||
return date('Y_m_d_His_') . $this->getSchemaName();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|string
|
||||
*/
|
||||
private function getSchemaName()
|
||||
{
|
||||
return $this->argument('name');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private function getClassName()
|
||||
{
|
||||
return Str::studly($this->argument('name'));
|
||||
}
|
||||
|
||||
public function getClass()
|
||||
{
|
||||
return $this->getClassName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the command.
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
|
||||
$this->components->info('Creating migration...');
|
||||
|
||||
if (parent::handle() === E_ERROR) {
|
||||
return E_ERROR;
|
||||
}
|
||||
|
||||
if (app()->environment() === 'testing') {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
-245
@@ -1,245 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Nwidart\Modules\Commands;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Nwidart\Modules\Support\Config\GenerateConfigReader;
|
||||
use Nwidart\Modules\Support\Stub;
|
||||
use Nwidart\Modules\Traits\ModuleCommandTrait;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
class ModelMakeCommand extends GeneratorCommand
|
||||
{
|
||||
use ModuleCommandTrait;
|
||||
|
||||
/**
|
||||
* The name of argument name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $argumentName = 'model';
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'module:make-model';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Create a new model for the specified module.';
|
||||
|
||||
public function handle(): int
|
||||
{
|
||||
if (parent::handle() === E_ERROR) {
|
||||
return E_ERROR;
|
||||
}
|
||||
|
||||
$this->handleOptionalMigrationOption();
|
||||
$this->handleOptionalControllerOption();
|
||||
$this->handleOptionalSeedOption();
|
||||
$this->handleOptionalFactoryOption();
|
||||
$this->handleOptionalRequestOption();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a proper migration name:
|
||||
* ProductDetail: product_details
|
||||
* Product: products
|
||||
* @return string
|
||||
*/
|
||||
private function createMigrationName()
|
||||
{
|
||||
$pieces = preg_split('/(?=[A-Z])/', $this->argument('model'), -1, PREG_SPLIT_NO_EMPTY);
|
||||
|
||||
$string = '';
|
||||
foreach ($pieces as $i => $piece) {
|
||||
if ($i+1 < count($pieces)) {
|
||||
$string .= strtolower($piece) . '_';
|
||||
} else {
|
||||
$string .= Str::plural(strtolower($piece));
|
||||
}
|
||||
}
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getArguments()
|
||||
{
|
||||
return [
|
||||
['model', InputArgument::REQUIRED, 'The name of model will be created.'],
|
||||
['module', InputArgument::OPTIONAL, 'The name of module will be used.'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command options.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
return [
|
||||
['fillable', null, InputOption::VALUE_OPTIONAL, 'The fillable attributes.', null],
|
||||
['migration', 'm', InputOption::VALUE_NONE, 'Flag to create associated migrations', null],
|
||||
['controller', 'c', InputOption::VALUE_NONE, 'Flag to create associated controllers', null],
|
||||
['seed', 's', InputOption::VALUE_NONE, 'Create a new seeder for the model', null],
|
||||
['factory', 'f', InputOption::VALUE_NONE, 'Create a new factory for the model', null],
|
||||
['request', 'r', InputOption::VALUE_NONE, 'Create a new request for the model', null],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the migration file with the given model if migration flag was used
|
||||
*/
|
||||
private function handleOptionalMigrationOption()
|
||||
{
|
||||
if ($this->option('migration') === true) {
|
||||
$migrationName = 'create_' . $this->createMigrationName() . '_table';
|
||||
$this->call('module:make-migration', ['name' => $migrationName, 'module' => $this->argument('module')]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the controller file for the given model if controller flag was used
|
||||
*/
|
||||
private function handleOptionalControllerOption()
|
||||
{
|
||||
if ($this->option('controller') === true) {
|
||||
$controllerName = "{$this->getModelName()}Controller";
|
||||
|
||||
$this->call('module:make-controller', array_filter([
|
||||
'controller' => $controllerName,
|
||||
'module' => $this->argument('module'),
|
||||
]));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a seeder file for the model.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function handleOptionalSeedOption()
|
||||
{
|
||||
if ($this->option('seed') === true) {
|
||||
$seedName = "{$this->getModelName()}Seeder";
|
||||
|
||||
$this->call('module:make-seed', array_filter([
|
||||
'name' => $seedName,
|
||||
'module' => $this->argument('module')
|
||||
]));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a seeder file for the model.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function handleOptionalFactoryOption()
|
||||
{
|
||||
if ($this->option('factory') === true) {
|
||||
$this->call('module:make-factory', array_filter([
|
||||
'name' => $this->getModelName(),
|
||||
'module' => $this->argument('module')
|
||||
]));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a request file for the model.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function handleOptionalRequestOption()
|
||||
{
|
||||
if ($this->option('request') === true) {
|
||||
$requestName = "{$this->getModelName()}Request";
|
||||
|
||||
$this->call('module:make-request', array_filter([
|
||||
'name' => $requestName,
|
||||
'module' => $this->argument('module')
|
||||
]));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getTemplateContents()
|
||||
{
|
||||
$module = $this->laravel['modules']->findOrFail($this->getModuleName());
|
||||
|
||||
return (new Stub('/model.stub', [
|
||||
'NAME' => $this->getModelName(),
|
||||
'FILLABLE' => $this->getFillable(),
|
||||
'NAMESPACE' => $this->getClassNamespace($module),
|
||||
'CLASS' => $this->getClass(),
|
||||
'LOWER_NAME' => $module->getLowerName(),
|
||||
'MODULE' => $this->getModuleName(),
|
||||
'STUDLY_NAME' => $module->getStudlyName(),
|
||||
'MODULE_NAMESPACE' => $this->laravel['modules']->config('namespace'),
|
||||
]))->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getDestinationFilePath()
|
||||
{
|
||||
$path = $this->laravel['modules']->getModulePath($this->getModuleName());
|
||||
|
||||
$modelPath = GenerateConfigReader::read('model');
|
||||
|
||||
return $path . $modelPath->getPath() . '/' . $this->getModelName() . '.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed|string
|
||||
*/
|
||||
private function getModelName()
|
||||
{
|
||||
return Str::studly($this->argument('model'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private function getFillable()
|
||||
{
|
||||
$fillable = $this->option('fillable');
|
||||
|
||||
if (!is_null($fillable)) {
|
||||
$arrays = explode(',', $fillable);
|
||||
|
||||
return json_encode($arrays);
|
||||
}
|
||||
|
||||
return '[]';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get default namespace.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDefaultNamespace(): string
|
||||
{
|
||||
$module = $this->laravel['modules'];
|
||||
|
||||
return $module->config('paths.generator.model.namespace') ?: $module->config('paths.generator.model.path', 'Entities');
|
||||
}
|
||||
}
|
||||
-119
@@ -1,119 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Nwidart\Modules\Commands;
|
||||
|
||||
use Illuminate\Contracts\Console\PromptsForMissingInput;
|
||||
use Illuminate\Database\Console\PruneCommand;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Str;
|
||||
use InvalidArgumentException;
|
||||
use Nwidart\Modules\Facades\Module;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Finder\Finder;
|
||||
use function Laravel\Prompts\multiselect;
|
||||
|
||||
class ModelPruneCommand extends PruneCommand implements PromptsForMissingInput
|
||||
{
|
||||
const ALL = 'All';
|
||||
|
||||
protected $name = 'module:prune';
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'module:prune {module*}
|
||||
{--all : Check all Modules}
|
||||
{--model=* : Class names of the models to be pruned}
|
||||
{--except=* : Class names of the models to be excluded from pruning}
|
||||
{--path=* : Absolute path(s) to directories where models are located}
|
||||
{--chunk=1000 : The number of models to retrieve per chunk of models to be deleted}
|
||||
{--pretend : Display the number of prunable records found instead of deleting them}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Prune models by module that are no longer needed';
|
||||
|
||||
protected function promptForMissingArguments(InputInterface $input, OutputInterface $output): void
|
||||
{
|
||||
if ($this->option('all')) {
|
||||
$input->setArgument('module', [self::ALL]);
|
||||
return;
|
||||
}
|
||||
|
||||
$selected_item = multiselect(
|
||||
label : 'What Module want to check?',
|
||||
options : [
|
||||
self::ALL,
|
||||
...array_keys(Module::all()),
|
||||
],
|
||||
required: 'You must select at least one module',
|
||||
);
|
||||
|
||||
$input->setArgument('module',
|
||||
value: in_array(self::ALL, $selected_item)
|
||||
? [self::ALL]
|
||||
: $selected_item
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determine the models that should be pruned.
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
protected function models(): Collection
|
||||
{
|
||||
if (! empty($models = $this->option('model'))) {
|
||||
return collect($models)->filter(function ($model) {
|
||||
return class_exists($model);
|
||||
})->values();
|
||||
}
|
||||
|
||||
$except = $this->option('except');
|
||||
|
||||
if (! empty($models) && ! empty($except)) {
|
||||
throw new InvalidArgumentException('The --models and --except options cannot be combined.');
|
||||
}
|
||||
|
||||
if ($this->argument('module') == [self::ALL]) {
|
||||
$path = sprintf('%s/*/%s',
|
||||
config('modules.paths.modules'),
|
||||
config('modules.paths.generator.model.path')
|
||||
);
|
||||
}
|
||||
else {
|
||||
$path = sprintf('%s/{%s}/%s',
|
||||
config('modules.paths.modules'),
|
||||
collect($this->argument('module'))->implode(','),
|
||||
config('modules.paths.generator.model.path'));
|
||||
}
|
||||
|
||||
return collect(Finder::create()->in($path)->files()->name('*.php'))
|
||||
->map(function ($model) {
|
||||
|
||||
$namespace = config('modules.namespace');
|
||||
return $namespace . str_replace(
|
||||
['/', '.php'],
|
||||
['\\', ''],
|
||||
Str::after($model->getRealPath(), realpath(config('modules.paths.modules')))
|
||||
);
|
||||
})->values()
|
||||
->when(! empty($except), function ($models) use ($except) {
|
||||
return $models->reject(function ($model) use ($except) {
|
||||
return in_array($model, $except);
|
||||
});
|
||||
})->filter(function ($model) {
|
||||
return class_exists($model);
|
||||
})->filter(function ($model) {
|
||||
return $this->isPrunable($model);
|
||||
})->values();
|
||||
}
|
||||
|
||||
}
|
||||
-63
@@ -1,63 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Nwidart\Modules\Commands;
|
||||
|
||||
use Illuminate\Database\Console\ShowModelCommand;
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
|
||||
#[AsCommand('module:model-show', 'Show information about an Eloquent model in modules')]
|
||||
class ModelShowCommand extends ShowModelCommand
|
||||
{
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'module:model-show';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Show information about an Eloquent model in modules';
|
||||
|
||||
/**
|
||||
* The console command signature.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'module:model-show {model : The model to show}
|
||||
{--database= : The database connection to use}
|
||||
{--json : Output the model as JSON}';
|
||||
|
||||
|
||||
/**
|
||||
* Qualify the given model class base name.
|
||||
*
|
||||
* @param string $model
|
||||
* @return string
|
||||
*
|
||||
* @see \Illuminate\Console\GeneratorCommand
|
||||
*/
|
||||
protected function qualifyModel(string $model): string
|
||||
{
|
||||
if (str_contains($model, '\\') && class_exists($model)) {
|
||||
return $model;
|
||||
}
|
||||
|
||||
$rootNamespace = config('modules.namespace');
|
||||
|
||||
$modelPath = glob($rootNamespace . DIRECTORY_SEPARATOR .
|
||||
'*' . DIRECTORY_SEPARATOR .
|
||||
config('modules.paths.generator.model.path') . DIRECTORY_SEPARATOR .
|
||||
"$model.php");
|
||||
|
||||
if (!count($modelPath)) {
|
||||
return $model;
|
||||
}
|
||||
|
||||
return str_replace(['/', '.php'], ['\\', ''], $modelPath[0]);
|
||||
}
|
||||
|
||||
}
|
||||
-28
@@ -1,28 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Nwidart\Modules\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
|
||||
class ModuleDeleteCommand extends Command
|
||||
{
|
||||
protected $name = 'module:delete';
|
||||
protected $description = 'Delete a module from the application';
|
||||
|
||||
public function handle(): int
|
||||
{
|
||||
$this->laravel['modules']->delete($this->argument('module'));
|
||||
|
||||
$this->components->info("Module {$this->argument('module')} has been deleted.");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected function getArguments()
|
||||
{
|
||||
return [
|
||||
['module', InputArgument::REQUIRED, 'The name of module to delete.'],
|
||||
];
|
||||
}
|
||||
}
|
||||
-100
@@ -1,100 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Nwidart\Modules\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Nwidart\Modules\Contracts\ActivatorInterface;
|
||||
use Nwidart\Modules\Generators\ModuleGenerator;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
class ModuleMakeCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'module:make';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Create a new module.';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
$names = $this->argument('name');
|
||||
$success = true;
|
||||
|
||||
foreach ($names as $name) {
|
||||
$code = with(new ModuleGenerator($name))
|
||||
->setFilesystem($this->laravel['files'])
|
||||
->setModule($this->laravel['modules'])
|
||||
->setConfig($this->laravel['config'])
|
||||
->setActivator($this->laravel[ActivatorInterface::class])
|
||||
->setConsole($this)
|
||||
->setComponent($this->components)
|
||||
->setForce($this->option('force'))
|
||||
->setType($this->getModuleType())
|
||||
->setActive(!$this->option('disabled'))
|
||||
->generate();
|
||||
|
||||
if ($code === E_ERROR) {
|
||||
$success = false;
|
||||
}
|
||||
}
|
||||
|
||||
return $success ? 0 : E_ERROR;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getArguments()
|
||||
{
|
||||
return [
|
||||
['name', InputArgument::IS_ARRAY, 'The names of modules will be created.'],
|
||||
];
|
||||
}
|
||||
|
||||
protected function getOptions()
|
||||
{
|
||||
return [
|
||||
['plain', 'p', InputOption::VALUE_NONE, 'Generate a plain module (without some resources).'],
|
||||
['api', null, InputOption::VALUE_NONE, 'Generate an api module.'],
|
||||
['web', null, InputOption::VALUE_NONE, 'Generate a web module.'],
|
||||
['disabled', 'd', InputOption::VALUE_NONE, 'Do not enable the module at creation.'],
|
||||
['force', null, InputOption::VALUE_NONE, 'Force the operation to run when the module already exists.'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get module type .
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getModuleType()
|
||||
{
|
||||
$isPlain = $this->option('plain');
|
||||
$isApi = $this->option('api');
|
||||
|
||||
if ($isPlain && $isApi) {
|
||||
return 'web';
|
||||
}
|
||||
if ($isPlain) {
|
||||
return 'plain';
|
||||
} elseif ($isApi) {
|
||||
return 'api';
|
||||
} else {
|
||||
return 'web';
|
||||
}
|
||||
}
|
||||
}
|
||||
Vendored
-87
@@ -1,87 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Nwidart\Modules\Commands;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Nwidart\Modules\Support\Config\GenerateConfigReader;
|
||||
use Nwidart\Modules\Support\Stub;
|
||||
use Nwidart\Modules\Traits\ModuleCommandTrait;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
|
||||
final class NotificationMakeCommand extends GeneratorCommand
|
||||
{
|
||||
use ModuleCommandTrait;
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'module:make-notification';
|
||||
|
||||
protected $argumentName = 'name';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Create a new notification class for the specified module.';
|
||||
|
||||
public function getDefaultNamespace(): string
|
||||
{
|
||||
$module = $this->laravel['modules'];
|
||||
|
||||
return $module->config('paths.generator.notifications.namespace') ?: $module->config('paths.generator.notifications.path', 'Notifications');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get template contents.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getTemplateContents()
|
||||
{
|
||||
$module = $this->laravel['modules']->findOrFail($this->getModuleName());
|
||||
|
||||
return (new Stub('/notification.stub', [
|
||||
'NAMESPACE' => $this->getClassNamespace($module),
|
||||
'CLASS' => $this->getClass(),
|
||||
]))->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the destination file path.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getDestinationFilePath()
|
||||
{
|
||||
$path = $this->laravel['modules']->getModulePath($this->getModuleName());
|
||||
|
||||
$notificationPath = GenerateConfigReader::read('notifications');
|
||||
|
||||
return $path . $notificationPath->getPath() . '/' . $this->getFileName() . '.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private function getFileName()
|
||||
{
|
||||
return Str::studly($this->argument('name'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getArguments()
|
||||
{
|
||||
return [
|
||||
['name', InputArgument::REQUIRED, 'The name of the notification class.'],
|
||||
['module', InputArgument::OPTIONAL, 'The name of module will be used.'],
|
||||
];
|
||||
}
|
||||
}
|
||||
-135
@@ -1,135 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Nwidart\Modules\Commands;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Nwidart\Modules\Support\Config\GenerateConfigReader;
|
||||
use Nwidart\Modules\Support\Stub;
|
||||
use Nwidart\Modules\Traits\ModuleCommandTrait;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
|
||||
class ObserverMakeCommand extends GeneratorCommand
|
||||
{
|
||||
use ModuleCommandTrait;
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'module:make-observer';
|
||||
|
||||
|
||||
/**
|
||||
* The name of argument name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $argumentName = 'name';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Create a new observer for the specified module.';
|
||||
|
||||
/**
|
||||
* Get the console command arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getArguments()
|
||||
{
|
||||
return [
|
||||
['name', InputArgument::REQUIRED, 'The observer name will be created.'],
|
||||
['module', InputArgument::OPTIONAL, 'The name of module will be created.'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getTemplateContents()
|
||||
{
|
||||
$module = $this->laravel['modules']->findOrFail($this->getModuleName());
|
||||
return (new Stub('/observer.stub', [
|
||||
'NAMESPACE' => $this->getClassNamespace($module),
|
||||
'NAME' => $this->getModelName(),
|
||||
'MODEL_NAMESPACE' => $this->getModelNamespace(),
|
||||
'NAME_VARIABLE' => $this->getModelVariable(),
|
||||
]))->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get model namespace.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getModelNamespace(): string
|
||||
{
|
||||
$path = $this->laravel['modules']->config('paths.generator.model.path', 'Entities');
|
||||
|
||||
$path = str_replace('/', '\\', $path);
|
||||
|
||||
return $this->laravel['modules']->config('namespace') . '\\' . $this->laravel['modules']->findOrFail($this->getModuleName()) . '\\' . $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed|string
|
||||
*/
|
||||
private function getModelName()
|
||||
{
|
||||
return Str::studly($this->argument('name'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed|string
|
||||
*/
|
||||
private function getModelVariable() : string
|
||||
{
|
||||
return '$'.Str::lower($this->argument('name'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getDestinationFilePath()
|
||||
{
|
||||
$path = $this->laravel['modules']->getModulePath($this->getModuleName());
|
||||
|
||||
$observerPath = GenerateConfigReader::read('observer');
|
||||
|
||||
return $path . $observerPath->getPath() . '/' . $this->getFileName();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private function getFileName()
|
||||
{
|
||||
return Str::studly($this->argument('name')) . 'Observer.php';
|
||||
}
|
||||
|
||||
|
||||
public function handle(): int
|
||||
{
|
||||
$this->components->info('Creating observer...');
|
||||
|
||||
parent::handle();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get default namespace.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDefaultNamespace(): string
|
||||
{
|
||||
$module = $this->laravel['modules'];
|
||||
|
||||
return $module->config('paths.generator.observer.namespace') ?: $module->config('paths.generator.observer.path', 'Observers');
|
||||
}
|
||||
}
|
||||
-88
@@ -1,88 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Nwidart\Modules\Commands;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Nwidart\Modules\Support\Config\GenerateConfigReader;
|
||||
use Nwidart\Modules\Support\Stub;
|
||||
use Nwidart\Modules\Traits\ModuleCommandTrait;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
|
||||
class PolicyMakeCommand extends GeneratorCommand
|
||||
{
|
||||
use ModuleCommandTrait;
|
||||
|
||||
/**
|
||||
* The name of argument name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $argumentName = 'name';
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'module:make-policy';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Create a new policy class for the specified module.';
|
||||
|
||||
public function getDefaultNamespace(): string
|
||||
{
|
||||
$module = $this->laravel['modules'];
|
||||
|
||||
return $module->config('paths.generator.policies.namespace') ?: $module->config('paths.generator.policies.path', 'Policies');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getArguments()
|
||||
{
|
||||
return [
|
||||
['name', InputArgument::REQUIRED, 'The name of the policy class.'],
|
||||
['module', InputArgument::OPTIONAL, 'The name of module will be used.'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getTemplateContents()
|
||||
{
|
||||
$module = $this->laravel['modules']->findOrFail($this->getModuleName());
|
||||
|
||||
return (new Stub('/policy.plain.stub', [
|
||||
'NAMESPACE' => $this->getClassNamespace($module),
|
||||
'CLASS' => $this->getClass(),
|
||||
]))->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getDestinationFilePath()
|
||||
{
|
||||
$path = $this->laravel['modules']->getModulePath($this->getModuleName());
|
||||
|
||||
$policyPath = GenerateConfigReader::read('policies');
|
||||
|
||||
return $path . $policyPath->getPath() . '/' . $this->getFileName() . '.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private function getFileName()
|
||||
{
|
||||
return Str::studly($this->argument('name'));
|
||||
}
|
||||
}
|
||||
-115
@@ -1,115 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Nwidart\Modules\Commands;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Nwidart\Modules\Module;
|
||||
use Nwidart\Modules\Support\Config\GenerateConfigReader;
|
||||
use Nwidart\Modules\Support\Stub;
|
||||
use Nwidart\Modules\Traits\ModuleCommandTrait;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
class ProviderMakeCommand extends GeneratorCommand
|
||||
{
|
||||
use ModuleCommandTrait;
|
||||
|
||||
/**
|
||||
* The name of argument name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $argumentName = 'name';
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'module:make-provider';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Create a new service provider class for the specified module.';
|
||||
|
||||
public function getDefaultNamespace(): string
|
||||
{
|
||||
$module = $this->laravel['modules'];
|
||||
|
||||
return $module->config('paths.generator.provider.namespace') ?: $module->config('paths.generator.provider.path', 'Providers');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getArguments()
|
||||
{
|
||||
return [
|
||||
['name', InputArgument::REQUIRED, 'The service provider name.'],
|
||||
['module', InputArgument::OPTIONAL, 'The name of module will be used.'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command options.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
return [
|
||||
['master', null, InputOption::VALUE_NONE, 'Indicates the master service provider', null],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getTemplateContents()
|
||||
{
|
||||
$stub = $this->option('master') ? 'scaffold/provider' : 'provider';
|
||||
|
||||
/** @var Module $module */
|
||||
$module = $this->laravel['modules']->findOrFail($this->getModuleName());
|
||||
|
||||
return (new Stub('/' . $stub . '.stub', [
|
||||
'NAMESPACE' => $this->getClassNamespace($module),
|
||||
'CLASS' => $this->getClass(),
|
||||
'LOWER_NAME' => $module->getLowerName(),
|
||||
'MODULE' => $this->getModuleName(),
|
||||
'NAME' => $this->getFileName(),
|
||||
'STUDLY_NAME' => $module->getStudlyName(),
|
||||
'MODULE_NAMESPACE' => $this->laravel['modules']->config('namespace'),
|
||||
'PATH_VIEWS' => GenerateConfigReader::read('views')->getPath(),
|
||||
'PATH_LANG' => GenerateConfigReader::read('lang')->getPath(),
|
||||
'PATH_CONFIG' => GenerateConfigReader::read('config')->getPath(),
|
||||
'MIGRATIONS_PATH' => GenerateConfigReader::read('migration')->getPath(),
|
||||
'FACTORIES_PATH' => GenerateConfigReader::read('factory')->getPath(),
|
||||
]))->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getDestinationFilePath()
|
||||
{
|
||||
$path = $this->laravel['modules']->getModulePath($this->getModuleName());
|
||||
|
||||
$generatorPath = GenerateConfigReader::read('provider');
|
||||
|
||||
return $path . $generatorPath->getPath() . '/' . $this->getFileName() . '.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private function getFileName()
|
||||
{
|
||||
return Str::studly($this->argument('name'));
|
||||
}
|
||||
}
|
||||
-86
@@ -1,86 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Nwidart\Modules\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Nwidart\Modules\Module;
|
||||
use Nwidart\Modules\Publishing\AssetPublisher;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
|
||||
class PublishCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'module:publish';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Publish a module\'s assets to the application';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
$this->components->info('Publishing module assets...');
|
||||
|
||||
if ($name = $this->argument('module')) {
|
||||
$this->publish($name);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
$this->publishAll();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Publish assets from all modules.
|
||||
*/
|
||||
public function publishAll()
|
||||
{
|
||||
foreach ($this->laravel['modules']->allEnabled() as $module) {
|
||||
$this->publish($module);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Publish assets from the specified module.
|
||||
*
|
||||
* @param string $name
|
||||
*/
|
||||
public function publish($name)
|
||||
{
|
||||
if ($name instanceof Module) {
|
||||
$module = $name;
|
||||
} else {
|
||||
$module = $this->laravel['modules']->findOrFail($name);
|
||||
}
|
||||
|
||||
with(new AssetPublisher($module))
|
||||
->setRepository($this->laravel['modules'])
|
||||
->setConsole($this)
|
||||
->publish();
|
||||
|
||||
$this->components->task($module->getStudlyName(), fn()=>true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getArguments()
|
||||
{
|
||||
return [
|
||||
['module', InputArgument::OPTIONAL, 'The name of module will be used.'],
|
||||
];
|
||||
}
|
||||
}
|
||||
Vendored
-93
@@ -1,93 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Nwidart\Modules\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Str;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
class PublishConfigurationCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'module:publish-config';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Publish a module\'s config files to the application';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
$this->components->info('publishing module config files...');
|
||||
|
||||
if ($module = $this->argument('module')) {
|
||||
$this->publishConfiguration($module);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
foreach ($this->laravel['modules']->allEnabled() as $module) {
|
||||
$this->publishConfiguration($module->getName());
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $module
|
||||
* @return string
|
||||
*/
|
||||
private function getServiceProviderForModule($module)
|
||||
{
|
||||
$namespace = $this->laravel['config']->get('modules.namespace');
|
||||
$studlyName = Str::studly($module);
|
||||
$provider = $this->laravel['config']->get('modules.paths.generator.provider.path');
|
||||
$provider = str_replace('/', '\\', $provider);
|
||||
|
||||
return "$namespace\\$studlyName\\$provider\\{$studlyName}ServiceProvider";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $module
|
||||
*/
|
||||
private function publishConfiguration($module)
|
||||
{
|
||||
$this->call('vendor:publish', [
|
||||
'--provider' => $this->getServiceProviderForModule($module),
|
||||
'--force' => $this->option('force'),
|
||||
'--tag' => ['config'],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getArguments()
|
||||
{
|
||||
return [
|
||||
['module', InputArgument::OPTIONAL, 'The name of module being used.'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
return [
|
||||
['--force', '-f', InputOption::VALUE_NONE, 'Force the publishing of config files'],
|
||||
];
|
||||
}
|
||||
}
|
||||
Vendored
-72
@@ -1,72 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Nwidart\Modules\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Nwidart\Modules\Migrations\Migrator;
|
||||
use Nwidart\Modules\Publishing\MigrationPublisher;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
|
||||
class PublishMigrationCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'module:publish-migration';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = "Publish a module's migrations to the application";
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
$this->components->info('publishing module migrations...');
|
||||
|
||||
if ($name = $this->argument('module')) {
|
||||
$module = $this->laravel['modules']->findOrFail($name);
|
||||
|
||||
$this->publish($module);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
foreach ($this->laravel['modules']->allEnabled() as $module) {
|
||||
$this->publish($module);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Publish migration for the specified module.
|
||||
*
|
||||
* @param \Nwidart\Modules\Module $module
|
||||
*/
|
||||
public function publish($module)
|
||||
{
|
||||
with(new MigrationPublisher(new Migrator($module, $this->getLaravel())))
|
||||
->setRepository($this->laravel['modules'])
|
||||
->setConsole($this)
|
||||
->publish();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getArguments()
|
||||
{
|
||||
return [
|
||||
['module', InputArgument::OPTIONAL, 'The name of module being used.'],
|
||||
];
|
||||
}
|
||||
}
|
||||
Vendored
-86
@@ -1,86 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Nwidart\Modules\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Nwidart\Modules\Module;
|
||||
use Nwidart\Modules\Publishing\LangPublisher;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
|
||||
class PublishTranslationCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'module:publish-translation';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Publish a module\'s translations to the application';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
$this->components->info('Publishing module translations...');
|
||||
|
||||
if ($name = $this->argument('module')) {
|
||||
$this->publish($name);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
$this->publishAll();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Publish assets from all modules.
|
||||
*/
|
||||
public function publishAll()
|
||||
{
|
||||
foreach ($this->laravel['modules']->allEnabled() as $module) {
|
||||
$this->publish($module);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Publish assets from the specified module.
|
||||
*
|
||||
* @param string $name
|
||||
*/
|
||||
public function publish($name)
|
||||
{
|
||||
if ($name instanceof Module) {
|
||||
$module = $name;
|
||||
} else {
|
||||
$module = $this->laravel['modules']->findOrFail($name);
|
||||
}
|
||||
|
||||
with(new LangPublisher($module))
|
||||
->setRepository($this->laravel['modules'])
|
||||
->setConsole($this)
|
||||
->publish();
|
||||
|
||||
$this->line("<info>Published</info>: {$module->getStudlyName()}");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getArguments()
|
||||
{
|
||||
return [
|
||||
['module', InputArgument::OPTIONAL, 'The name of module will be used.'],
|
||||
];
|
||||
}
|
||||
}
|
||||
-88
@@ -1,88 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Nwidart\Modules\Commands;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Nwidart\Modules\Support\Config\GenerateConfigReader;
|
||||
use Nwidart\Modules\Support\Stub;
|
||||
use Nwidart\Modules\Traits\ModuleCommandTrait;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
|
||||
class RequestMakeCommand extends GeneratorCommand
|
||||
{
|
||||
use ModuleCommandTrait;
|
||||
|
||||
/**
|
||||
* The name of argument name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $argumentName = 'name';
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'module:make-request';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Create a new form request class for the specified module.';
|
||||
|
||||
public function getDefaultNamespace(): string
|
||||
{
|
||||
$module = $this->laravel['modules'];
|
||||
|
||||
return $module->config('paths.generator.request.namespace') ?: $module->config('paths.generator.request.path', 'Http/Requests');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getArguments()
|
||||
{
|
||||
return [
|
||||
['name', InputArgument::REQUIRED, 'The name of the form request class.'],
|
||||
['module', InputArgument::OPTIONAL, 'The name of module will be used.'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getTemplateContents()
|
||||
{
|
||||
$module = $this->laravel['modules']->findOrFail($this->getModuleName());
|
||||
|
||||
return (new Stub('/request.stub', [
|
||||
'NAMESPACE' => $this->getClassNamespace($module),
|
||||
'CLASS' => $this->getClass(),
|
||||
]))->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getDestinationFilePath()
|
||||
{
|
||||
$path = $this->laravel['modules']->getModulePath($this->getModuleName());
|
||||
|
||||
$requestPath = GenerateConfigReader::read('request');
|
||||
|
||||
return $path . $requestPath->getPath() . '/' . $this->getFileName() . '.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private function getFileName()
|
||||
{
|
||||
return Str::studly($this->argument('name'));
|
||||
}
|
||||
}
|
||||
-102
@@ -1,102 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Nwidart\Modules\Commands;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Nwidart\Modules\Support\Config\GenerateConfigReader;
|
||||
use Nwidart\Modules\Support\Stub;
|
||||
use Nwidart\Modules\Traits\ModuleCommandTrait;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
class ResourceMakeCommand extends GeneratorCommand
|
||||
{
|
||||
use ModuleCommandTrait;
|
||||
|
||||
protected $argumentName = 'name';
|
||||
protected $name = 'module:make-resource';
|
||||
protected $description = 'Create a new resource class for the specified module.';
|
||||
|
||||
public function getDefaultNamespace(): string
|
||||
{
|
||||
$module = $this->laravel['modules'];
|
||||
|
||||
return $module->config('paths.generator.resource.namespace') ?: $module->config('paths.generator.resource.path', 'Transformers');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getArguments()
|
||||
{
|
||||
return [
|
||||
['name', InputArgument::REQUIRED, 'The name of the resource class.'],
|
||||
['module', InputArgument::OPTIONAL, 'The name of module will be used.'],
|
||||
];
|
||||
}
|
||||
|
||||
protected function getOptions()
|
||||
{
|
||||
return [
|
||||
['collection', 'c', InputOption::VALUE_NONE, 'Create a resource collection.'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getTemplateContents()
|
||||
{
|
||||
$module = $this->laravel['modules']->findOrFail($this->getModuleName());
|
||||
|
||||
return (new Stub($this->getStubName(), [
|
||||
'NAMESPACE' => $this->getClassNamespace($module),
|
||||
'CLASS' => $this->getClass(),
|
||||
]))->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getDestinationFilePath()
|
||||
{
|
||||
$path = $this->laravel['modules']->getModulePath($this->getModuleName());
|
||||
|
||||
$resourcePath = GenerateConfigReader::read('resource');
|
||||
|
||||
return $path . $resourcePath->getPath() . '/' . $this->getFileName() . '.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private function getFileName()
|
||||
{
|
||||
return Str::studly($this->argument('name'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the command is generating a resource collection.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function collection(): bool
|
||||
{
|
||||
return $this->option('collection') ||
|
||||
Str::endsWith($this->argument('name'), 'Collection');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function getStubName(): string
|
||||
{
|
||||
if ($this->collection()) {
|
||||
return '/resource-collection.stub';
|
||||
}
|
||||
|
||||
return '/resource.stub';
|
||||
}
|
||||
}
|
||||
Vendored
-125
@@ -1,125 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Nwidart\Modules\Commands;
|
||||
|
||||
use Nwidart\Modules\Support\Config\GenerateConfigReader;
|
||||
use Nwidart\Modules\Support\Stub;
|
||||
use Nwidart\Modules\Traits\ModuleCommandTrait;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
class RouteProviderMakeCommand extends GeneratorCommand
|
||||
{
|
||||
use ModuleCommandTrait;
|
||||
|
||||
protected $argumentName = 'module';
|
||||
|
||||
/**
|
||||
* The command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'module:route-provider';
|
||||
|
||||
/**
|
||||
* The command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Create a new route service provider for the specified module.';
|
||||
|
||||
/**
|
||||
* The command arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getArguments()
|
||||
{
|
||||
return [
|
||||
['module', InputArgument::OPTIONAL, 'The name of module will be used.'],
|
||||
];
|
||||
}
|
||||
|
||||
protected function getOptions()
|
||||
{
|
||||
return [
|
||||
['force', null, InputOption::VALUE_NONE, 'Force the operation to run when the file already exists.'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get template contents.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getTemplateContents()
|
||||
{
|
||||
$module = $this->laravel['modules']->findOrFail($this->getModuleName());
|
||||
|
||||
return (new Stub('/route-provider.stub', [
|
||||
'NAMESPACE' => $this->getClassNamespace($module),
|
||||
'CLASS' => $this->getFileName(),
|
||||
'MODULE_NAMESPACE' => $this->laravel['modules']->config('namespace'),
|
||||
'MODULE' => $this->getModuleName(),
|
||||
'CONTROLLER_NAMESPACE' => $this->getControllerNameSpace(),
|
||||
'WEB_ROUTES_PATH' => $this->getWebRoutesPath(),
|
||||
'API_ROUTES_PATH' => $this->getApiRoutesPath(),
|
||||
'LOWER_NAME' => $module->getLowerName(),
|
||||
]))->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private function getFileName()
|
||||
{
|
||||
return 'RouteServiceProvider';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the destination file path.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getDestinationFilePath()
|
||||
{
|
||||
$path = $this->laravel['modules']->getModulePath($this->getModuleName());
|
||||
|
||||
$generatorPath = GenerateConfigReader::read('provider');
|
||||
|
||||
return $path . $generatorPath->getPath() . '/' . $this->getFileName() . '.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getWebRoutesPath()
|
||||
{
|
||||
return '/' . $this->laravel['modules']->config('stubs.files.routes/web', 'Routes/web.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getApiRoutesPath()
|
||||
{
|
||||
return '/' . $this->laravel['modules']->config('stubs.files.routes/api', 'Routes/api.php');
|
||||
}
|
||||
|
||||
public function getDefaultNamespace(): string
|
||||
{
|
||||
$module = $this->laravel['modules'];
|
||||
|
||||
return $module->config('paths.generator.provider.namespace') ?: $module->config('paths.generator.provider.path', 'Providers');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private function getControllerNameSpace(): string
|
||||
{
|
||||
$module = $this->laravel['modules'];
|
||||
|
||||
return str_replace('/', '\\', $module->config('paths.generator.controller.namespace') ?: $module->config('paths.generator.controller.path', 'Controller'));
|
||||
}
|
||||
}
|
||||
-105
@@ -1,105 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Nwidart\Modules\Commands;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Nwidart\Modules\Support\Config\GenerateConfigReader;
|
||||
use Nwidart\Modules\Support\Stub;
|
||||
use Nwidart\Modules\Traits\ModuleCommandTrait;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
class RuleMakeCommand extends GeneratorCommand
|
||||
{
|
||||
use ModuleCommandTrait;
|
||||
|
||||
/**
|
||||
* The name of argument name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $argumentName = 'name';
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'module:make-rule';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Create a new validation rule for the specified module.';
|
||||
|
||||
public function getDefaultNamespace(): string
|
||||
{
|
||||
$module = $this->laravel['modules'];
|
||||
|
||||
return $module->config('paths.generator.rules.namespace') ?: $module->config('paths.generator.rules.path', 'Rules');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getArguments()
|
||||
{
|
||||
return [
|
||||
['name', InputArgument::REQUIRED, 'The name of the rule class.'],
|
||||
['module', InputArgument::OPTIONAL, 'The name of module will be used.'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command options.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
return [
|
||||
['implicit', 'i', InputOption::VALUE_NONE, 'Generate an implicit rule'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getTemplateContents()
|
||||
{
|
||||
$module = $this->laravel['modules']->findOrFail($this->getModuleName());
|
||||
|
||||
$stub = $this->option('implicit')
|
||||
? '/rule.implicit.stub'
|
||||
: '/rule.stub';
|
||||
|
||||
return (new Stub($stub, [
|
||||
'NAMESPACE' => $this->getClassNamespace($module),
|
||||
'CLASS' => $this->getFileName(),
|
||||
]))->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getDestinationFilePath()
|
||||
{
|
||||
$path = $this->laravel['modules']->getModulePath($this->getModuleName());
|
||||
|
||||
$rulePath = GenerateConfigReader::read('rules');
|
||||
|
||||
return $path . $rulePath->getPath() . '/' . $this->getFileName() . '.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private function getFileName()
|
||||
{
|
||||
return Str::studly($this->argument('name'));
|
||||
}
|
||||
}
|
||||
-246
@@ -1,246 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Nwidart\Modules\Commands;
|
||||
|
||||
use ErrorException;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Contracts\Debug\ExceptionHandler;
|
||||
use Illuminate\Support\Str;
|
||||
use Nwidart\Modules\Contracts\RepositoryInterface;
|
||||
use Nwidart\Modules\Module;
|
||||
use Nwidart\Modules\Support\Config\GenerateConfigReader;
|
||||
use Nwidart\Modules\Traits\ModuleCommandTrait;
|
||||
use RuntimeException;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
class SeedCommand extends Command
|
||||
{
|
||||
use ModuleCommandTrait;
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'module:seed';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Run database seeder from the specified module or from all modules.';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
try {
|
||||
if ($name = $this->argument('module')) {
|
||||
$name = Str::studly($name);
|
||||
$this->moduleSeed($this->getModuleByName($name));
|
||||
} else {
|
||||
$modules = $this->getModuleRepository()->getOrdered();
|
||||
array_walk($modules, [$this, 'moduleSeed']);
|
||||
$this->info('All modules seeded.');
|
||||
}
|
||||
} catch (\Error $e) {
|
||||
$e = new ErrorException($e->getMessage(), $e->getCode(), 1, $e->getFile(), $e->getLine(), $e);
|
||||
$this->reportException($e);
|
||||
$this->renderException($this->getOutput(), $e);
|
||||
|
||||
return E_ERROR;
|
||||
} catch (\Exception $e) {
|
||||
$this->reportException($e);
|
||||
$this->renderException($this->getOutput(), $e);
|
||||
|
||||
return E_ERROR;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
* @return RepositoryInterface
|
||||
*/
|
||||
public function getModuleRepository(): RepositoryInterface
|
||||
{
|
||||
$modules = $this->laravel['modules'];
|
||||
if (!$modules instanceof RepositoryInterface) {
|
||||
throw new RuntimeException('Module repository not found!');
|
||||
}
|
||||
|
||||
return $modules;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
*
|
||||
* @throws RuntimeException
|
||||
*
|
||||
* @return Module
|
||||
*/
|
||||
public function getModuleByName($name)
|
||||
{
|
||||
$modules = $this->getModuleRepository();
|
||||
if ($modules->has($name) === false) {
|
||||
throw new RuntimeException("Module [$name] does not exists.");
|
||||
}
|
||||
|
||||
return $modules->find($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Module $module
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function moduleSeed(Module $module)
|
||||
{
|
||||
$seeders = [];
|
||||
$name = $module->getName();
|
||||
$config = $module->get('migration');
|
||||
if (is_array($config) && array_key_exists('seeds', $config)) {
|
||||
foreach ((array)$config['seeds'] as $class) {
|
||||
if (class_exists($class)) {
|
||||
$seeders[] = $class;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$class = $this->getSeederName($name); //legacy support
|
||||
if (class_exists($class)) {
|
||||
$seeders[] = $class;
|
||||
} else {
|
||||
//look at other namespaces
|
||||
$classes = $this->getSeederNames($name);
|
||||
foreach ($classes as $class) {
|
||||
if (class_exists($class)) {
|
||||
$seeders[] = $class;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (count($seeders) > 0) {
|
||||
array_walk($seeders, [$this, 'dbSeed']);
|
||||
$this->info("Module [$name] seeded.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Seed the specified module.
|
||||
*
|
||||
* @param string $className
|
||||
*/
|
||||
protected function dbSeed($className)
|
||||
{
|
||||
if ($option = $this->option('class')) {
|
||||
$params['--class'] = Str::finish(substr($className, 0, strrpos($className, '\\')), '\\') . $option;
|
||||
} else {
|
||||
$params = ['--class' => $className];
|
||||
}
|
||||
|
||||
if ($option = $this->option('database')) {
|
||||
$params['--database'] = $option;
|
||||
}
|
||||
|
||||
if ($option = $this->option('force')) {
|
||||
$params['--force'] = $option;
|
||||
}
|
||||
|
||||
$this->call('db:seed', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get master database seeder name for the specified module.
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSeederName($name)
|
||||
{
|
||||
$name = Str::studly($name);
|
||||
|
||||
$namespace = $this->laravel['modules']->config('namespace');
|
||||
$config = GenerateConfigReader::read('seeder');
|
||||
$seederPath = str_replace('/', '\\', $config->getPath());
|
||||
|
||||
return $namespace . '\\' . $name . '\\' . $seederPath . '\\' . $name . 'DatabaseSeeder';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get master database seeder name for the specified module under a different namespace than Modules.
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return array $foundModules array containing namespace paths
|
||||
*/
|
||||
public function getSeederNames($name)
|
||||
{
|
||||
$name = Str::studly($name);
|
||||
|
||||
$seederPath = GenerateConfigReader::read('seeder');
|
||||
$seederPath = str_replace('/', '\\', $seederPath->getPath());
|
||||
|
||||
$foundModules = [];
|
||||
foreach ($this->laravel['modules']->config('scan.paths') as $path) {
|
||||
$namespace = array_slice(explode('/', $path), -1)[0];
|
||||
$foundModules[] = $namespace . '\\' . $name . '\\' . $seederPath . '\\' . $name . 'DatabaseSeeder';
|
||||
}
|
||||
|
||||
return $foundModules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Report the exception to the exception handler.
|
||||
*
|
||||
* @param \Symfony\Component\Console\Output\OutputInterface $output
|
||||
* @param \Throwable $e
|
||||
* @return void
|
||||
*/
|
||||
protected function renderException($output, \Exception $e)
|
||||
{
|
||||
$this->laravel[ExceptionHandler::class]->renderForConsole($output, $e);
|
||||
}
|
||||
|
||||
/**
|
||||
* Report the exception to the exception handler.
|
||||
*
|
||||
* @param \Throwable $e
|
||||
* @return void
|
||||
*/
|
||||
protected function reportException(\Exception $e)
|
||||
{
|
||||
$this->laravel[ExceptionHandler::class]->report($e);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getArguments()
|
||||
{
|
||||
return [
|
||||
['module', InputArgument::OPTIONAL, 'The name of module will be used.'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command options.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
return [
|
||||
['class', null, InputOption::VALUE_OPTIONAL, 'The class name of the root seeder.'],
|
||||
['database', null, InputOption::VALUE_OPTIONAL, 'The database connection to seed.'],
|
||||
['force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production.'],
|
||||
];
|
||||
}
|
||||
}
|
||||
-104
@@ -1,104 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Nwidart\Modules\Commands;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Nwidart\Modules\Support\Config\GenerateConfigReader;
|
||||
use Nwidart\Modules\Support\Stub;
|
||||
use Nwidart\Modules\Traits\CanClearModulesCache;
|
||||
use Nwidart\Modules\Traits\ModuleCommandTrait;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
class SeedMakeCommand extends GeneratorCommand
|
||||
{
|
||||
use CanClearModulesCache;
|
||||
use ModuleCommandTrait;
|
||||
|
||||
protected $argumentName = 'name';
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*/
|
||||
protected $name = 'module:make-seed';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*/
|
||||
protected $description = 'Generate new seeder for the specified module.';
|
||||
|
||||
/**
|
||||
* Get the console command arguments.
|
||||
*/
|
||||
protected function getArguments(): array
|
||||
{
|
||||
return [
|
||||
['name', InputArgument::REQUIRED, 'The name of seeder will be created.'],
|
||||
['module', InputArgument::OPTIONAL, 'The name of module will be used.'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command options.
|
||||
*/
|
||||
protected function getOptions(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
'master',
|
||||
null,
|
||||
InputOption::VALUE_NONE,
|
||||
'Indicates the seeder will created is a master database seeder.',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
protected function getTemplateContents(): mixed
|
||||
{
|
||||
$module = $this->laravel['modules']->findOrFail($this->getModuleName());
|
||||
|
||||
return (new Stub('/seeder.stub', [
|
||||
'NAME' => $this->getSeederName(),
|
||||
'MODULE' => $this->getModuleName(),
|
||||
'NAMESPACE' => $this->getClassNamespace($module),
|
||||
|
||||
]))->render();
|
||||
}
|
||||
|
||||
protected function getDestinationFilePath(): mixed
|
||||
{
|
||||
$this->clearCache();
|
||||
|
||||
$path = $this->laravel['modules']->getModulePath($this->getModuleName());
|
||||
|
||||
$seederPath = GenerateConfigReader::read('seeder');
|
||||
|
||||
return $path . $seederPath->getPath() . '/' . $this->getSeederName() . '.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the seeder name.
|
||||
*/
|
||||
private function getSeederName(): string
|
||||
{
|
||||
$string = $this->argument('name');
|
||||
$string .= $this->option('master') ? 'Database' : '';
|
||||
$suffix = 'Seeder';
|
||||
|
||||
if (strpos($string, $suffix) === false) {
|
||||
$string .= $suffix;
|
||||
}
|
||||
|
||||
return Str::studly($string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get default namespace.
|
||||
*/
|
||||
public function getDefaultNamespace(): string
|
||||
{
|
||||
$module = $this->laravel['modules'];
|
||||
|
||||
return $module->config('paths.generator.seeder.namespace') ?: $module->config('paths.generator.seeder.path', 'Database/Seeders');
|
||||
}
|
||||
}
|
||||
-79
@@ -1,79 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Nwidart\Modules\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class SetupCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'module:setup';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Setting up modules folders for first use.';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
$code = $this->generateModulesFolder();
|
||||
|
||||
return $this->generateAssetsFolder() | $code;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the modules folder.
|
||||
*/
|
||||
public function generateModulesFolder()
|
||||
{
|
||||
return $this->generateDirectory(
|
||||
$this->laravel['modules']->config('paths.modules'),
|
||||
'Modules directory created successfully',
|
||||
'Modules directory already exist'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the assets folder.
|
||||
*/
|
||||
public function generateAssetsFolder()
|
||||
{
|
||||
return $this->generateDirectory(
|
||||
$this->laravel['modules']->config('paths.assets'),
|
||||
'Assets directory created successfully',
|
||||
'Assets directory already exist'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the specified directory by given $dir.
|
||||
*
|
||||
* @param $dir
|
||||
* @param $success
|
||||
* @param $error
|
||||
* @return int
|
||||
*/
|
||||
protected function generateDirectory($dir, $success, $error): int
|
||||
{
|
||||
if (!$this->laravel['files']->isDirectory($dir)) {
|
||||
$this->laravel['files']->makeDirectory($dir, 0755, true, true);
|
||||
|
||||
$this->components->info($success);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
$this->components->error($error);
|
||||
|
||||
return E_ERROR;
|
||||
}
|
||||
}
|
||||
-97
@@ -1,97 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Nwidart\Modules\Commands;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Nwidart\Modules\Support\Config\GenerateConfigReader;
|
||||
use Nwidart\Modules\Support\Stub;
|
||||
use Nwidart\Modules\Traits\ModuleCommandTrait;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
class TestMakeCommand extends GeneratorCommand
|
||||
{
|
||||
use ModuleCommandTrait;
|
||||
|
||||
protected $argumentName = 'name';
|
||||
protected $name = 'module:make-test';
|
||||
protected $description = 'Create a new test class for the specified module.';
|
||||
|
||||
public function getDefaultNamespace(): string
|
||||
{
|
||||
$module = $this->laravel['modules'];
|
||||
|
||||
if ($this->option('feature')) {
|
||||
return $module->config('paths.generator.test-feature.namespace') ?: $module->config('paths.generator.test-feature.path', 'Tests/Feature');
|
||||
}
|
||||
|
||||
return $module->config('paths.generator.test.namespace') ?: $module->config('paths.generator.test.path', 'Tests/Unit');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getArguments()
|
||||
{
|
||||
return [
|
||||
['name', InputArgument::REQUIRED, 'The name of the form request class.'],
|
||||
['module', InputArgument::OPTIONAL, 'The name of module will be used.'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command options.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
return [
|
||||
['feature', false, InputOption::VALUE_NONE, 'Create a feature test.'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getTemplateContents()
|
||||
{
|
||||
$module = $this->laravel['modules']->findOrFail($this->getModuleName());
|
||||
$stub = '/unit-test.stub';
|
||||
|
||||
if ($this->option('feature')) {
|
||||
$stub = '/feature-test.stub';
|
||||
}
|
||||
|
||||
return (new Stub($stub, [
|
||||
'NAMESPACE' => $this->getClassNamespace($module),
|
||||
'CLASS' => $this->getClass(),
|
||||
]))->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getDestinationFilePath()
|
||||
{
|
||||
$path = $this->laravel['modules']->getModulePath($this->getModuleName());
|
||||
|
||||
if ($this->option('feature')) {
|
||||
$testPath = GenerateConfigReader::read('test-feature');
|
||||
} else {
|
||||
$testPath = GenerateConfigReader::read('test');
|
||||
}
|
||||
|
||||
return $path . $testPath->getPath() . '/' . $this->getFileName() . '.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private function getFileName()
|
||||
{
|
||||
return Str::studly($this->argument('name'));
|
||||
}
|
||||
}
|
||||
-34
@@ -1,34 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Nwidart\Modules\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class UnUseCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'module:unuse';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Forget the used module with module:use';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
$this->laravel['modules']->forgetUsed();
|
||||
|
||||
$this->components->info('Previous module used successfully forgotten.');
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
-85
@@ -1,85 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Nwidart\Modules\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Nwidart\Modules\Module;
|
||||
use Nwidart\Modules\Traits\ModuleCommandTrait;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
|
||||
class UpdateCommand extends Command
|
||||
{
|
||||
use ModuleCommandTrait;
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'module:update';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Update dependencies for the specified module or for all modules.';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
$this->components->info('Updating module ...');
|
||||
|
||||
if ($name = $this->argument('module')) {
|
||||
$this->updateModule($name);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
$this->updateAllModule();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
protected function updateAllModule()
|
||||
{
|
||||
/** @var \Nwidart\Modules\Module $module */
|
||||
$modules = $this->laravel['modules']->getOrdered();
|
||||
|
||||
foreach ($modules as $module) {
|
||||
$this->updateModule($module);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected function updateModule($name)
|
||||
{
|
||||
|
||||
if ($name instanceof Module) {
|
||||
$module = $name;
|
||||
}else {
|
||||
$module = $this->laravel['modules']->findOrFail($name);
|
||||
}
|
||||
|
||||
$this->components->task("Updating {$module->getName()} module", function () use ($module) {
|
||||
$this->laravel['modules']->update($module);
|
||||
});
|
||||
$this->laravel['modules']->update($name);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getArguments()
|
||||
{
|
||||
return [
|
||||
['module', InputArgument::OPTIONAL, 'The name of module will be updated.'],
|
||||
];
|
||||
}
|
||||
}
|
||||
-56
@@ -1,56 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Nwidart\Modules\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Str;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
|
||||
class UseCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'module:use';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Use the specified module.';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
$module = Str::studly($this->argument('module'));
|
||||
|
||||
if (!$this->laravel['modules']->has($module)) {
|
||||
$this->error("Module [{$module}] does not exists.");
|
||||
|
||||
return E_ERROR;
|
||||
}
|
||||
|
||||
$this->laravel['modules']->setUsed($module);
|
||||
|
||||
$this->info("Module [{$module}] used successfully.");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getArguments()
|
||||
{
|
||||
return [
|
||||
['module', InputArgument::REQUIRED, 'The name of module will be used.'],
|
||||
];
|
||||
}
|
||||
}
|
||||
Vendored
-24
@@ -1,24 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace $NAMESPACE$;
|
||||
|
||||
class $CLASS$
|
||||
{
|
||||
|
||||
/**
|
||||
* Create a new channel instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Authenticate the user's access to the channel.
|
||||
*/
|
||||
public function join(Operator $user): array|bool
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
}
|
||||
-56
@@ -1,56 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace $NAMESPACE$;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
|
||||
class $CLASS$ extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*/
|
||||
protected $signature = '$COMMAND_NAME$';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*/
|
||||
protected $description = 'Command description.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command arguments.
|
||||
*/
|
||||
protected function getArguments(): array
|
||||
{
|
||||
return [
|
||||
['example', InputArgument::REQUIRED, 'An example argument.'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command options.
|
||||
*/
|
||||
protected function getOptions(): array
|
||||
{
|
||||
return [
|
||||
['example', null, InputOption::VALUE_OPTIONAL, 'An example option.', null],
|
||||
];
|
||||
}
|
||||
}
|
||||
Vendored
-25
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace $NAMESPACE$;
|
||||
|
||||
use Illuminate\View\Component;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class $CLASS$ extends Component
|
||||
{
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view/contents that represent the component.
|
||||
*/
|
||||
public function render(): View|string
|
||||
{
|
||||
return view('$LOWER_NAME$::$COMPONENT_NAME$');
|
||||
}
|
||||
}
|
||||
Vendored
-3
@@ -1,3 +0,0 @@
|
||||
<div>
|
||||
<!-- $QUOTE$ -->
|
||||
</div>
|
||||
-31
@@ -1,31 +0,0 @@
|
||||
{
|
||||
"name": "$VENDOR$/$LOWER_NAME$",
|
||||
"description": "",
|
||||
"authors": [
|
||||
{
|
||||
"name": "$AUTHOR_NAME$",
|
||||
"email": "$AUTHOR_EMAIL$"
|
||||
}
|
||||
],
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [],
|
||||
"aliases": {
|
||||
|
||||
}
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"$MODULE_NAMESPACE$\\$STUDLY_NAME$\\": "",
|
||||
"$MODULE_NAMESPACE$\\$STUDLY_NAME$\\App\\": "app/",
|
||||
"$MODULE_NAMESPACE$\\$STUDLY_NAME$\\Database\\Factories\\": "database/factories/",
|
||||
"$MODULE_NAMESPACE$\\$STUDLY_NAME$\\Database\\Seeders\\": "database/seeders/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"$MODULE_NAMESPACE$\\$STUDLY_NAME$\\Tests\\": "tests/"
|
||||
}
|
||||
}
|
||||
}
|
||||
Vendored
-62
@@ -1,62 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace $CLASS_NAMESPACE$;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class $CLASS$ extends Controller
|
||||
{
|
||||
public array $data = [];
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index(): JsonResponse
|
||||
{
|
||||
//
|
||||
|
||||
return response()->json($this->data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request): JsonResponse
|
||||
{
|
||||
//
|
||||
|
||||
return response()->json($this->data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
*/
|
||||
public function show($id): JsonResponse
|
||||
{
|
||||
//
|
||||
|
||||
return response()->json($this->data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, $id): JsonResponse
|
||||
{
|
||||
//
|
||||
|
||||
return response()->json($this->data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy($id): JsonResponse
|
||||
{
|
||||
//
|
||||
|
||||
return response()->json($this->data);
|
||||
}
|
||||
}
|
||||
Vendored
-9
@@ -1,9 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace $CLASS_NAMESPACE$;
|
||||
|
||||
use Illuminate\Routing\Controller;
|
||||
|
||||
class $CLASS$ extends Controller
|
||||
{
|
||||
}
|
||||
-67
@@ -1,67 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace $CLASS_NAMESPACE$;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class $CLASS$ extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return view('$LOWER_NAME$::index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('$LOWER_NAME$::create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
return view('$LOWER_NAME$::show');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
return view('$LOWER_NAME$::edit');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, $id): RedirectResponse
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
-26
@@ -1,26 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace $NAMESPACE$;
|
||||
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class $CLASS$
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the channels the event should be broadcast on.
|
||||
*/
|
||||
public function broadcastOn(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
-22
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace $NAMESPACE$;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class $NAME$Factory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*/
|
||||
protected $model = \$MODEL_NAMESPACE$\$NAME$::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
-20
@@ -1,20 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace $NAMESPACE$;
|
||||
|
||||
use Tests\TestCase;
|
||||
use Illuminate\Foundation\Testing\WithFaker;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
|
||||
class $CLASS$ extends TestCase
|
||||
{
|
||||
/**
|
||||
* A basic feature test example.
|
||||
*/
|
||||
public function testExample(): void
|
||||
{
|
||||
$response = $this->get('/');
|
||||
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
}
|
||||
-30
@@ -1,30 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace $NAMESPACE$;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
|
||||
class $CLASS$ implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*/
|
||||
public function handle(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
-27
@@ -1,27 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace $NAMESPACE$;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
|
||||
class $CLASS$ implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, Queueable;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*/
|
||||
public function handle(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
{
|
||||
"name": "$STUDLY_NAME$",
|
||||
"alias": "$LOWER_NAME$",
|
||||
"description": "",
|
||||
"keywords": [],
|
||||
"priority": 0,
|
||||
"providers": [
|
||||
"$MODULE_NAMESPACE$\\$STUDLY_NAME$\\$PROVIDER_NAMESPACE$\\$STUDLY_NAME$ServiceProvider"
|
||||
],
|
||||
"files": []
|
||||
}
|
||||
-25
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace $NAMESPACE$;
|
||||
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
|
||||
class $CLASS$
|
||||
{
|
||||
/**
|
||||
* Create the event listener.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the event.
|
||||
*/
|
||||
public function handle($event): void
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
Vendored
-27
@@ -1,27 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace $NAMESPACE$;
|
||||
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
|
||||
class $CLASS$ implements ShouldQueue
|
||||
{
|
||||
use InteractsWithQueue;
|
||||
|
||||
/**
|
||||
* Create the event listener
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the event.
|
||||
*/
|
||||
public function handle($event): void
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
Vendored
-28
@@ -1,28 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace $NAMESPACE$;
|
||||
|
||||
use $EVENTNAME$;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
|
||||
class $CLASS$ implements ShouldQueue
|
||||
{
|
||||
use InteractsWithQueue;
|
||||
|
||||
/**
|
||||
* Create the event listener.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the event.
|
||||
*/
|
||||
public function handle($SHORTEVENTNAME$ $event): void
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
-26
@@ -1,26 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace $NAMESPACE$;
|
||||
|
||||
use $EVENTNAME$;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
|
||||
class $CLASS$
|
||||
{
|
||||
/**
|
||||
* Create the event listener.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the event.
|
||||
*/
|
||||
public function handle($SHORTEVENTNAME$ $event): void
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
-29
@@ -1,29 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace $NAMESPACE$;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
|
||||
class $CLASS$ extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the message.
|
||||
*/
|
||||
public function build(): self
|
||||
{
|
||||
return $this->view('view.name');
|
||||
}
|
||||
}
|
||||
-17
@@ -1,17 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace $NAMESPACE$;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class $CLASS$
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*/
|
||||
public function handle(Request $request, Closure $next)
|
||||
{
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
-28
@@ -1,28 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('$TABLE$', function (Blueprint $table) {
|
||||
$FIELDS_UP$
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('$TABLE$', function (Blueprint $table) {
|
||||
$FIELDS_DOWN$
|
||||
});
|
||||
}
|
||||
};
|
||||
Vendored
-28
@@ -1,28 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('$TABLE$', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$FIELDS$
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('$TABLE$');
|
||||
}
|
||||
};
|
||||
Vendored
-28
@@ -1,28 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('$TABLE$', function (Blueprint $table) {
|
||||
$FIELDS_UP$
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('$TABLE$', function (Blueprint $table) {
|
||||
$FIELDS_DOWN$
|
||||
});
|
||||
}
|
||||
};
|
||||
Vendored
-28
@@ -1,28 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::dropIfExists('$TABLE$');
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::create('$TABLE$', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$FIELDS$
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
};
|
||||
Vendored
-24
@@ -1,24 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
};
|
||||
-22
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace $NAMESPACE$;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use $MODULE_NAMESPACE$\$MODULE$\Database\factories\$NAME$Factory;
|
||||
|
||||
class $CLASS$ extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected $fillable = $FILLABLE$;
|
||||
|
||||
protected static function newFactory(): $NAME$Factory
|
||||
{
|
||||
//return $NAME$Factory::new();
|
||||
}
|
||||
}
|
||||
-48
@@ -1,48 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace $NAMESPACE$;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
|
||||
class $CLASS$ extends Notification
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
/**
|
||||
* Create a new notification instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the notification's delivery channels.
|
||||
*/
|
||||
public function via($notifiable): array
|
||||
{
|
||||
return ['mail'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mail representation of the notification.
|
||||
*/
|
||||
public function toMail($notifiable): MailMessage
|
||||
{
|
||||
return (new MailMessage)
|
||||
->line('The introduction to the notification.')
|
||||
->action('Notification Action', 'https://laravel.com')
|
||||
->line('Thank you for using our application!');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the array representation of the notification.
|
||||
*/
|
||||
public function toArray($notifiable): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
-48
@@ -1,48 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace $NAMESPACE$;
|
||||
|
||||
use $MODEL_NAMESPACE$\$NAME$;
|
||||
|
||||
class $NAME$Observer
|
||||
{
|
||||
/**
|
||||
* Handle the $NAME$ "created" event.
|
||||
*/
|
||||
public function created($NAME$ $NAME_VARIABLE$): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the $NAME$ "updated" event.
|
||||
*/
|
||||
public function updated($NAME$ $NAME_VARIABLE$): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the $NAME$ "deleted" event.
|
||||
*/
|
||||
public function deleted($NAME$ $NAME_VARIABLE$): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the $NAME$ "restored" event.
|
||||
*/
|
||||
public function restored($NAME$ $NAME_VARIABLE$): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the $NAME$ "force deleted" event.
|
||||
*/
|
||||
public function forceDeleted($NAME$ $NAME_VARIABLE$): void
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
{
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build"
|
||||
},
|
||||
"devDependencies": {
|
||||
"axios": "^1.1.2",
|
||||
"laravel-vite-plugin": "^0.7.5",
|
||||
"sass": "^1.69.5",
|
||||
"postcss": "^8.3.7",
|
||||
"vite": "^4.0.0"
|
||||
}
|
||||
}
|
||||
-18
@@ -1,18 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace $NAMESPACE$;
|
||||
|
||||
use Illuminate\Auth\Access\HandlesAuthorization;
|
||||
|
||||
class $CLASS$
|
||||
{
|
||||
use HandlesAuthorization;
|
||||
|
||||
/**
|
||||
* Create a new policy instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
-24
@@ -1,24 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace $NAMESPACE$;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class $CLASS$ extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Register the service provider.
|
||||
*/
|
||||
public function register(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the services provided by the provider.
|
||||
*/
|
||||
public function provides(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
-26
@@ -1,26 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace $NAMESPACE$;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class $CLASS$ extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Vendored
-16
@@ -1,16 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace $NAMESPACE$;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class $CLASS$ extends ResourceCollection
|
||||
{
|
||||
/**
|
||||
* Transform the resource collection into an array.
|
||||
*/
|
||||
public function toArray($request): array
|
||||
{
|
||||
return parent::toArray($request);
|
||||
}
|
||||
}
|
||||
-16
@@ -1,16 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace $NAMESPACE$;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class $CLASS$ extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*/
|
||||
public function toArray($request): array
|
||||
{
|
||||
return parent::toArray($request);
|
||||
}
|
||||
}
|
||||
Vendored
-59
@@ -1,59 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace $NAMESPACE$;
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
|
||||
class $CLASS$ extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The module namespace to assume when generating URLs to actions.
|
||||
*/
|
||||
protected string $moduleNamespace = '$MODULE_NAMESPACE$\$MODULE$\$CONTROLLER_NAMESPACE$';
|
||||
|
||||
/**
|
||||
* Called before routes are registered.
|
||||
*
|
||||
* Register any model bindings or pattern based filters.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
parent::boot();
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the routes for the application.
|
||||
*/
|
||||
public function map(): void
|
||||
{
|
||||
$this->mapApiRoutes();
|
||||
|
||||
$this->mapWebRoutes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the "web" routes for the application.
|
||||
*
|
||||
* These routes all receive session state, CSRF protection, etc.
|
||||
*/
|
||||
protected function mapWebRoutes(): void
|
||||
{
|
||||
Route::middleware('web')
|
||||
->namespace($this->moduleNamespace)
|
||||
->group(module_path('$MODULE$', '$WEB_ROUTES_PATH$'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the "api" routes for the application.
|
||||
*
|
||||
* These routes are typically stateless.
|
||||
*/
|
||||
protected function mapApiRoutes(): void
|
||||
{
|
||||
Route::prefix('api')
|
||||
->middleware('api')
|
||||
->namespace($this->moduleNamespace)
|
||||
->group(module_path('$MODULE$', '$API_ROUTES_PATH$'));
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user