Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

By default add the 1.0.0 version to all modules generated with asgard:module:scaffold #580

Merged
merged 5 commits into from
Aug 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"'));
}
}