Merge pull request #1812 from roots/option-to-add-font-awesome
Add option to add Font Awesome
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
### 9.0.0-beta.2: TBD
|
### 9.0.0-beta.2: TBD
|
||||||
|
* Add option to add Font Awesome ([#1812](https://github.com/roots/sage/pull/1812))
|
||||||
* Add option to change theme file headers ([#1811](https://github.com/roots/sage/pull/1811))
|
* Add option to change theme file headers ([#1811](https://github.com/roots/sage/pull/1811))
|
||||||
* Add option to remove Bootstrap ([#1810](https://github.com/roots/sage/pull/1810))
|
* Add option to remove Bootstrap ([#1810](https://github.com/roots/sage/pull/1810))
|
||||||
* Remove Font Awesome ([#1809](https://github.com/roots/sage/pull/1809))
|
* Remove Font Awesome ([#1809](https://github.com/roots/sage/pull/1809))
|
||||||
|
|||||||
@@ -43,7 +43,8 @@
|
|||||||
],
|
],
|
||||||
"post-create-project-cmd": [
|
"post-create-project-cmd": [
|
||||||
"Roots\\Sage\\PostCreateProject::updateHeaders",
|
"Roots\\Sage\\PostCreateProject::updateHeaders",
|
||||||
"Roots\\Sage\\PostCreateProject::removeBootstrap"
|
"Roots\\Sage\\PostCreateProject::removeBootstrap",
|
||||||
|
"Roots\\Sage\\PostCreateProject::addFontAwesome"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ class PostCreateProject
|
|||||||
if ($io->isInteractive()) {
|
if ($io->isInteractive()) {
|
||||||
if ($io->askConfirmation('<info>Remove Bootstrap?</info> [<comment>y,N</comment>]? ', false)) {
|
if ($io->askConfirmation('<info>Remove Bootstrap?</info> [<comment>y,N</comment>]? ', false)) {
|
||||||
file_put_contents('package.json', str_replace(' "bootstrap": "^4.0.0-alpha.6",' . "\n", '', file_get_contents('package.json')));
|
file_put_contents('package.json', str_replace(' "bootstrap": "^4.0.0-alpha.6",' . "\n", '', file_get_contents('package.json')));
|
||||||
file_put_contents('assets/styles/main.scss', str_replace('// Import npm dependencies' . "\n", '', file_get_contents('assets/styles/main.scss')));
|
|
||||||
file_put_contents('assets/styles/main.scss', str_replace('@import "~bootstrap/scss/bootstrap";' . "\n", '', file_get_contents('assets/styles/main.scss')));
|
file_put_contents('assets/styles/main.scss', str_replace('@import "~bootstrap/scss/bootstrap";' . "\n", '', file_get_contents('assets/styles/main.scss')));
|
||||||
file_put_contents('assets/scripts/main.js', str_replace('import \'bootstrap/dist/js/bootstrap\';' . "\n", '', file_get_contents('assets/scripts/main.js')));
|
file_put_contents('assets/scripts/main.js', str_replace('import \'bootstrap/dist/js/bootstrap\';' . "\n", '', file_get_contents('assets/scripts/main.js')));
|
||||||
file_put_contents('assets/styles/components/_comments.scss', '');
|
file_put_contents('assets/styles/components/_comments.scss', '');
|
||||||
@@ -52,5 +51,24 @@ class PostCreateProject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function addFontAwesome(Event $event)
|
||||||
|
{
|
||||||
|
$io = $event->getIO();
|
||||||
|
|
||||||
|
if ($io->isInteractive()) {
|
||||||
|
if ($io->askConfirmation('<info>Add Font Awesome?</info> [<comment>y,N</comment>]? ', false)) {
|
||||||
|
$package = json_decode(file_get_contents('package.json'), true);
|
||||||
|
$dependencies = $package['dependencies'];
|
||||||
|
$dependencies = array_merge($dependencies, ['font-awesome' => '^4.7.0']);
|
||||||
|
$package['dependencies'] = $dependencies;
|
||||||
|
$package = str_replace(' ', ' ', json_encode($package, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . "\n");
|
||||||
|
|
||||||
|
$import_dep_str = '// Import npm dependencies' . "\n";
|
||||||
|
file_put_contents('assets/styles/main.scss', str_replace($import_dep_str, $import_dep_str . '@import "~font-awesome/scss/font-awesome";' . "\n", file_get_contents('assets/styles/main.scss')));
|
||||||
|
file_put_contents('assets/styles/common/_variables.scss', "\n" . '$fa-font-path: \'~font-awesome/fonts\';' . "\n", FILE_APPEND);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
// @codingStandardsIgnoreEnd
|
// @codingStandardsIgnoreEnd
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user