nWidart / laravel-modules

Module Management In Laravel
https://docs.laravelmodules.com
MIT License
5.57k stars 970 forks source link

No publishable resources for tag [config]. #1966

Closed jackchang1025 closed 2 weeks ago

jackchang1025 commented 1 month ago

Versions:

support issues : https://github.com/nWidart/laravel-modules/issues source : https://github.com/nWidart/laravel-modules/tree/v11.1.4

autoload files psr-4 Nwidart\Modules\ => src

requires ext-dom ext-json ext-simplexml * php >=8.2 wikimedia/composer-merge-plugin ^2.1

requires (dev) friendsofphp/php-cs-fixer ^v3.52 laravel/framework ^v11.0 laravel/pint ^1.16 mockery/mockery ^1.6 orchestra/testbench ^v9.0 phpstan/phpstan ^1.4 phpunit/phpunit ^11.0 spatie/phpunit-snapshot-assertions ^5.0

- Laravel Version: #.#.#
```bash
root@0f1c408a92d6:/var/www/html# php artisan --version
Laravel Framework 11.27.2

Description:

Steps To Reproduce:

root@0f1c408a92d6:/var/www/html# php artisan  module:make Demo

   INFO  Creating module: [Demo].

  Generating file Modules/Demo/module.json ................................................... 0.09ms DONE
  Generating file Modules/Demo/routes/web.php ................................................ 0.07ms DONE
  Generating file Modules/Demo/routes/api.php ................................................ 0.06ms DONE
  Generating file Modules/Demo/resources/views/index.blade.php ............................... 0.03ms DONE
  Generating file Modules/Demo/resources/views/layouts/master.blade.php ...................... 0.08ms DONE
  Generating file Modules/Demo/config/config.php ............................................. 0.03ms DONE
  Generating file Modules/Demo/composer.json ................................................. 0.09ms DONE
  Generating file Modules/Demo/database/seeders/DemoDatabaseSeeder.php ....................... 0.08ms DONE
  Generating file Modules/Demo/app/Providers/DemoServiceProvider.php ......................... 0.02ms DONE
  Generating file Modules/Demo/app/Providers/EventServiceProvider.php ........................ 0.03ms DONE
  Generating file Modules/Demo/app/Providers/RouteServiceProvider.php ........................ 0.02ms DONE
  Generating file Modules/Demo/app/Http/Controllers/DemoController.php ....................... 0.02ms DONE

   INFO  Module [Demo] created successfully.

//composer.json
{
    "name": "nwidart/demo",
    "description": "",
    "authors": [
        {
            "name": "Nicolas Widart",
            "email": "n.widart@gmail.com"
        }
    ],
    "extra": {
        "laravel": {
            "providers": [],
            "aliases": {

            }
        }
    },
    "autoload": {
        "psr-4": {
            "Modules\\Demo\\": "app/",
            "Modules\\Demo\\Database\\Factories\\": "database/factories/",
            "Modules\\Demo\\Database\\Seeders\\": "database/seeders/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "Modules\\Demo\\Tests\\": "tests/"
        }
    }
}

root@0f1c408a92d6:/var/www/html# php artisan module:publish-config Demo

   INFO  Publishing module config files ...

   INFO  No publishable resources for tag [config].

//this error
//vendor/nwidart/laravel-modules/src/Commands/Publish/PublishConfigurationCommand.php

namespace Nwidart\Modules\Commands\Publish;

use Illuminate\Support\Str;
use Nwidart\Modules\Commands\BaseCommand;
use Symfony\Component\Console\Input\InputOption;

class PublishConfigurationCommand extends BaseCommand
{
    /**
     * 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';

    public function executeAction($name): void
    {
        $this->call('vendor:publish', [
            '--provider' => $this->getServiceProviderForModule($name),
            '--force' => $this->option('force'),
            '--tag' => ['config'],
        ]);
    }

    public function getInfo(): ?string
    {
        return 'Publishing module config files ...';
    }

    /**
     * @param  string  $module
     */
    private function getServiceProviderForModule($module): string
    {
        $namespace = $this->laravel['config']->get('modules.namespace');
        $studlyName = Str::studly($module);
        $provider = $this->laravel['config']->get('modules.paths.generator.provider.path'); 

        //use config path, so path Modules/Demo/app/Providers/DemoServiceProvider.php
        //but register DemoServiceProvider path is Modules/Demo/Providers/DemoServiceProvider.php

        $provider = str_replace('/', '\\', $provider);

        return "$namespace\\$studlyName\\$provider\\{$studlyName}ServiceProvider";
    }

    protected function getOptions(): array
    {
        return [
            ['--force', '-f', InputOption::VALUE_NONE, 'Force the publishing of config files'],
        ];
    }
}
dcblogdev commented 2 weeks ago

identified the problem, applied a fix, will be doing a release shortly.