Skip to content

Commit b91ab89

Browse files
authored
Add option to remove Bootstrap when creating project (#1810)
* Add option to remove Bootstrap when creating project * Remove phpmd, per @QWp6t
1 parent ea7323a commit b91ab89

File tree

3 files changed

+44
-290
lines changed

3 files changed

+44
-290
lines changed

composer.json

+4-5
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,12 @@
3535
"illuminate/config": "~5.3.0"
3636
},
3737
"require-dev": {
38-
"squizlabs/php_codesniffer": "^2.5.1",
39-
"phpmd/phpmd": "^2.4.2"
38+
"squizlabs/php_codesniffer": "^2.5.1"
4039
},
4140
"scripts": {
4241
"test": [
43-
"vendor/bin/phpcs",
44-
"vendor/bin/phpmd src text cleancode,codesize,controversial,design,naming,unusedcode"
45-
]
42+
"vendor/bin/phpcs"
43+
],
44+
"post-create-project-cmd": "Roots\\Sage\\PostCreateProject::removeBootstrap"
4645
}
4746
}

composer.lock

+12-285
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/lib/Sage/PostCreateProject.php

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
namespace Roots\Sage;
4+
5+
use Composer\Script\Event;
6+
7+
class PostCreateProject
8+
{
9+
public static function removeBootstrap(Event $event)
10+
{
11+
$io = $event->getIO();
12+
13+
// @codingStandardsIgnoreStart
14+
if ($io->isInteractive()) {
15+
if ($io->askConfirmation('<info>Remove Bootstrap?</info> [<comment>y,N</comment>]? ', false)) {
16+
file_put_contents('package.json', str_replace(' "bootstrap": "^4.0.0-alpha.6",' . "\n", '', file_get_contents('package.json')));
17+
file_put_contents('assets/styles/main.scss', str_replace('// Import npm dependencies' . "\n", '', file_get_contents('assets/styles/main.scss')));
18+
file_put_contents('assets/styles/main.scss', str_replace('@import "~bootstrap/scss/bootstrap";' . "\n", '', file_get_contents('assets/styles/main.scss')));
19+
file_put_contents('assets/scripts/main.js', str_replace('import \'bootstrap/dist/js/bootstrap\';' . "\n", '', file_get_contents('assets/scripts/main.js')));
20+
file_put_contents('assets/styles/components/_comments.scss', '');
21+
file_put_contents('assets/styles/components/_forms.scss', '');
22+
file_put_contents('assets/styles/components/_wp-classes.scss', '');
23+
file_put_contents('assets/styles/layouts/_header.scss', '');
24+
}
25+
}
26+
// @codingStandardsIgnoreEnd
27+
}
28+
}

0 commit comments

Comments
 (0)