Unverified Commit b4b952dc authored by Nicolas Widart's avatar Nicolas Widart Committed by GitHub

Merge pull request #580 from ChristianGiupponi/3.0

By default add the 1.0.0 version to all modules generated with asgard:module:scaffold
parents b16c521e cdad9b6c
...@@ -227,6 +227,7 @@ class ModuleScaffold ...@@ -227,6 +227,7 @@ class ModuleScaffold
$moduleJson = $this->loadProviders($moduleJson); $moduleJson = $this->loadProviders($moduleJson);
$moduleJson = $this->setModuleOrderOrder($moduleJson); $moduleJson = $this->setModuleOrderOrder($moduleJson);
$moduleJson = $this->setModuleVersion($moduleJson);
$moduleJson = $this->removeStartPhpFile($moduleJson); $moduleJson = $this->removeStartPhpFile($moduleJson);
$this->finder->put($this->getModulesPath('module.json'), $moduleJson); $this->finder->put($this->getModulesPath('module.json'), $moduleJson);
...@@ -259,6 +260,16 @@ JSON; ...@@ -259,6 +260,16 @@ JSON;
return str_replace('"order": 0,', '"order": 1,', $content); return str_replace('"order": 0,', '"order": 1,', $content);
} }
/**
* Set the module version to 1.0.0 by default
* @param string $content
* @return string
*/
private function setModuleVersion($content)
{
return str_replace("\"active\"", "\"version\": \"1.0.0\",\n\t\"active\"", $content);
}
/** /**
* Remove the start.php start file * Remove the start.php start file
* Also removes the auto loading of that file * Also removes the auto loading of that file
...@@ -301,7 +312,7 @@ JSON; ...@@ -301,7 +312,7 @@ JSON;
$replace = <<<JSON $replace = <<<JSON
"description": "", "description": "",
"type": "asgard-module", "type": "asgard-module",
"license": "MIT", "license": "MIT",
"require": { "require": {
"php": ">=7.0.0", "php": ">=7.0.0",
"composer/installers": "~1.0", "composer/installers": "~1.0",
......
{ {
"name": "{{theme-name}}", "name": "{{theme-name}}",
"description": "", "description": "",
"type": "{{type}}" "type": "{{type}}",
"version": "1.0.0"
} }
...@@ -553,6 +553,16 @@ class ModuleScaffoldTest extends BaseTestCase ...@@ -553,6 +553,16 @@ class ModuleScaffoldTest extends BaseTestCase
$this->cleanUp(); $this->cleanUp();
} }
/** @test */
public function it_add_default_version_on_module_json_file()
{
$this->scaffoldModuleWithEloquent();
$moduleFile = $this->getModuleFile();
$this->assertEquals('1.0.0', $moduleFile->version);
}
/** /**
* Get the contents of composer.json file * Get the contents of composer.json file
* @return string * @return string
......
...@@ -184,4 +184,15 @@ class ThemeScaffoldTest extends BaseTestCase ...@@ -184,4 +184,15 @@ class ThemeScaffoldTest extends BaseTestCase
$this->assertTrue($this->finder->isFile($this->testThemePath . '/assets/js/.gitignore')); $this->assertTrue($this->finder->isFile($this->testThemePath . '/assets/js/.gitignore'));
$this->assertTrue($this->finder->isFile($this->testThemePath . '/assets/images/.gitignore')); $this->assertTrue($this->finder->isFile($this->testThemePath . '/assets/images/.gitignore'));
} }
/** @test */
public function it_has_default_version_in_theme_json_file()
{
$this->scaffold->setFiles(['themeJson']);
$this->generateFrontendTheme();
$this->assertTrue($this->finder->isFile($this->testThemePath . '/theme.json'));
$this->assertTrue(str_contains($this->finder->get($this->testThemePath . '/theme.json'), '"version": "1.0.0"'));
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment