/** * Install modules from modules.json file. */ protected function installFromFile() { if (!file_exists($path = base_path('modules.json'))) { $this->error("File 'modules.json' does not exist in your project root."); return; } $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')); } }
/** @test */ public function it_makes_json_class() { $path = __DIR__ . '/stubs/module.json'; $json = Json::make($path, $this->app['files']); $this->assertInstanceOf(Json::class, $json); }
/** * Get & scan all modules. * * @return array */ public function scan() { $paths = $this->getScanPaths(); $modules = []; foreach ($paths as $key => $path) { $manifests = $this->app['files']->glob("{$path}/module.json"); is_array($manifests) || ($manifests = []); foreach ($manifests as $manifest) { $name = Json::make($manifest)->get('name'); $modules[$name] = new Module($this->app, $name, dirname($manifest)); } } return $modules; }