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

Add option to remove Bootstrap when creating project #1810

Merged
merged 4 commits into from
Jan 15, 2017

Conversation

retlehs
Copy link
Member

@retlehs retlehs commented Jan 14, 2017

when creating a new sage project (composer create-project roots/sage your-theme-name) you will be prompted:

Remove Bootstrap? [y,N]?

if yes, bootstrap is removed from:

  • package.json
  • assets/styles/main.scss
  • assets/scripts/main.js
  • contents of these files are cleared out:
    • assets/styles/components/_comments.scss
    • assets/styles/components/_forms.scss
    • assets/styles/components/_wp-classes.scss
    • assets/styles/layouts/_header.scss


if (!$remove_bootstrap) {
return 1;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flip the default?

$io = $event->getIO();

if ($io->isInteractive()) {
    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('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/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/_forms.scss', '');
        file_put_contents('assets/styles/components/_wp-classes.scss', '');
        file_put_contents('assets/styles/layouts/_header.scss', '');
    }
}

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/scripts/main.js', str_replace('import \'bootstrap/dist/js/bootstrap\';' . "\n", '', file_get_contents('assets/scripts/main.js')));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"import 'bootstrap/dist/js/bootstrap';" will phpcs complain about this? :(

@retlehs retlehs merged commit b91ab89 into beta2 Jan 15, 2017
@retlehs retlehs deleted the option-to-remove-bootstrap branch January 15, 2017 02:58
@brandontamm
Copy link

One step further? Instead of removing bootstrap, maybe we could choose between bootstrap, foundation, etc..?

@retlehs
Copy link
Member Author

retlehs commented Jan 17, 2017 via email

@brandontamm
Copy link

brandontamm commented Jan 17, 2017

@retlehs you're the man! On a side note - check out https://github.com/iamdb/bedrock-wordpress-docker. I build all my sites with this type of setup. I adapt it and script deployment processes, of course - may be of interest to you 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants