Skip to content

Commit

Permalink
Merge pull request #580 from ChristianGiupponi/3.0
Browse files Browse the repository at this point in the history
By default add the 1.0.0 version to all modules generated with asgard:module:scaffold
  • Loading branch information
nWidart authored Aug 30, 2018
2 parents b16c521 + cdad9b6 commit b4b952d
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 2 deletions.
13 changes: 12 additions & 1 deletion Modules/Workshop/Scaffold/Module/ModuleScaffold.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ private function cleanUpModuleJson()

$moduleJson = $this->loadProviders($moduleJson);
$moduleJson = $this->setModuleOrderOrder($moduleJson);
$moduleJson = $this->setModuleVersion($moduleJson);
$moduleJson = $this->removeStartPhpFile($moduleJson);

$this->finder->put($this->getModulesPath('module.json'), $moduleJson);
Expand Down Expand Up @@ -259,6 +260,16 @@ private function setModuleOrderOrder($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
* Also removes the auto loading of that file
Expand Down Expand Up @@ -301,7 +312,7 @@ private function addDataToComposerFile()
$replace = <<<JSON
"description": "",
"type": "asgard-module",
"license": "MIT",
"license": "MIT",
"require": {
"php": ">=7.0.0",
"composer/installers": "~1.0",
Expand Down
3 changes: 2 additions & 1 deletion Modules/Workshop/Scaffold/Theme/stubs/themeJson.stub
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "{{theme-name}}",
"description": "",
"type": "{{type}}"
"type": "{{type}}",
"version": "1.0.0"
}
10 changes: 10 additions & 0 deletions Modules/Workshop/Tests/ModuleScaffoldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,16 @@ public function it_can_overwrite_stub_files_with_custom_ones()
$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
* @return string
Expand Down
11 changes: 11 additions & 0 deletions Modules/Workshop/Tests/ThemeScaffoldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,4 +184,15 @@ public function it_creates_empty_assets_folder()
$this->assertTrue($this->finder->isFile($this->testThemePath . '/assets/js/.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"'));
}
}

0 comments on commit b4b952d

Please sign in to comment.