Giter Site home page Giter Site logo

convert-bootstrap-2-to-3's Introduction

convert-bootstrap-2-to-3

Description

Convert Bootstrap 2 variables, class names and HTML to Bootstrap 3

Installation

<sudo> npm install -g convert-bootstrap-2-to-3

Running

The simplest way to run it is:

bs3 path/to/file

However, you can also check multiple files at once:

find . -name '*.css' | xargs bs3

or with options:

find . -name '*.css' | xargs -J{} bs3 {} -di

Options

There are some options that you can pass to the command:

-q, --quiet will set it so that it only shows files that have changes. By default it will log out all files and report 'clear' if there are no changes.

-o, --open If you have an editor specified in your gitconfig (under user.editor), this will open all of the files that need changes in your editor.

-i, --inline-edit For some of the changes (mainly the ones that can be safely changed), if you pass this option, it will modify the file and convert the old value to the new equivalent. I would recommend running this only on files that are checked into git or some VCS, as it may edit something incorrectly, and with the file in VCS, you can at least pick and choose which changes you'd like to keep.

-v, --variables This option, which is true by default will try to convert variables to their new equivalents (including the camelCased to dashed-base style of your variables), and will comment out (or remove, if you pass an additional option) variables that have been removed in Bootstrap 3. If you wish to have the CSS ignore variables, go ahead and pass either --no-v or --no-variables.

Experimental or less used options

-d, --diff This will display a colored diff of what would be changed on the line. This can get a bit noisy, but is useful if you want to see what will be changed by passing -i.

--removeold This will, if --variables is set, remove the entire line that old variables are on. Be careful with this, as it will remove not just var declarations, but any usage of the variable, so something like background: $white; would be deleted.

Known issues and Caveats

  • Does not handle HTML or CSS inside of Java or JavaScript files (still trying to think of how to best handle these cases, since it can be tough to tell what "mode" it should process in and look for).
  • JavaScript parsing is still currently the weakest portion. The issue stems from the fact that CSS selectors can be used (for querying the DOM), or HTML fragments can be created. However, parsing .btn and btn (as an example), when technically, the first could be a property of an object, and the second could be a variable name. So token parsing in this case is a little tough.
  • Dynamically created strings will more than likely be skipped, so something like:
<span class="btn <%= buttonType %>"></span>

would get flagged (since it's inside of a class attribute, and it can't tell if buttonType contains "btn-default" or "btn-primary", etc) and this:

<%
	String cssClass = "btn";

	if (buttonType == "default") {
		cssClass += " btn-default";
	}
%>
<span class="<%= cssClass %>"></span>

would not get flagged either (since the parser looks at attributes, but doesn't know their dynamically calculated values).

  • While it will check code inside of style tags and script tags (including aui:script), it won't be able to replace them, but it will output a message telling you what line the change needs to be made (and diff will still work)

convert-bootstrap-2-to-3's People

Contributors

natecavanaugh avatar tscole avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

convert-bootstrap-2-to-3's Issues

LESS files

Hi

I have runned bs3 on html files, and it seems to work since few files had been well modified.

Now I tried on LESS files and nothiing is outputed.
LESS files are almost CSS files but they have @variables.
Are they handled by bs3 ?

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory

Hi all,
I am upgrading liferay 6.2 theme to liferay 7 theme using "gulp upgrade" command and i am getting

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory

I have tried increasing memory but still the problem persists.

I am providing full logs while upgrading theme.

[22:25:18] Using gulpfile ~/PrivateExchange-A+-theme/gulpfile.js
[22:25:18] Starting 'upgrade'...
[22:25:18] Starting 'upgrade:create-backup-files'...
? Would you like to overwrite the existing _backup directory and it's contents?
No
[22:25:26] Finished 'upgrade:create-backup-files' after 7.67 s
[22:25:26] Starting 'upgrade:black-list'...
[22:25:26] Finished 'upgrade:black-list' after 36 ms
[22:25:26] Starting 'upgrade:replace-compass'...
[22:25:26] Finished 'upgrade:replace-compass' after 33 ms
[22:25:26] Starting 'upgrade:convert-bootstrap'...

<--- Last few GCs --->

10107 ms: Mark-sweep 1370.5 (1434.6) -> 1368.8 (1434.6) MB, 9.6 / 0.0 ms (+ 15.6 ms in 24 steps since start of marking, biggest step 2.2 ms) [allocation failure] [GC in old space requested].
10128 ms: Mark-sweep 1368.8 (1434.6) -> 1368.7 (1434.6) MB, 21.3 / 0.0 ms [allocation failure] [GC in old space requested].
10159 ms: Mark-sweep 1368.7 (1434.6) -> 1372.1 (1403.6) MB, 31.0 / 0.0 ms [last resort gc].
10189 ms: Mark-sweep 1372.1 (1403.6) -> 1375.6 (1403.6) MB, 29.6 / 0.0 ms [last resort gc].

<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 0x2bd78493fa99
1: exec [native regexp.js:~116] (this=0x2c5528b78f01 ,D=0x4c5597e3089 <Very long string[460281]>)
2: _extractRecursive [/root/.npm-packages/lib/node_modules/liferay-theme-tasks/node_modules/convert-bootstrap-2-to-3/lib/formatters/css.js:245] (this=0x2c5528b73ea9 <a constructor with map 0x1b5fe2eebca9>,str=0x4c5597e3089 <Very long string...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
1: node::Abort()
2: 0xff008c
3: v8::Utils::ReportApiFailure(char const*, char const*)
4: v8::internal:emoticon8::FatalProcessOutOfMemory(char const*, bool)
5: v8::internal::Factory::NewRawTwoByteString(int, v8::internal:emoticonretenureFlag)
6: v8::internal::String::SlowFlatten(v8::internal::Handlev8::internal::ConsString, v8::internal:emoticonretenureFlag)
7: v8::internal::RegExpImpl::IrregexpPrepare(v8::internal::Handlev8::internal::JSRegExp, v8::internal::Handlev8::internal::String)
8: v8::internal::RegExpImpl::IrregexpExec(v8::internal::Handlev8::internal::JSRegExp, v8::internal::Handlev8::internal::String, int, v8::internal::Handlev8::internal::JSArray)
9: v8::internal::RegExpImpl::Exec(v8::internal::Handlev8::internal::JSRegExp, v8::internal::Handlev8::internal::String, int, v8::internal::Handlev8::internal::JSArray)
10: v8::internal::Runtime_RegExpExec(int, v8::internal:emoticonbject**, v8::internal::Isolate*)
11: 0x3db704d060c7
Aborted (core dumped)

I am working on 64 bit RedHat Linux Environment with 4 gb ram.
Please help me in resolving this exception.

TypeError when checking padding on empty bodies

The tool will throw a TypeError exception when parsing through empty bodies in a file:

.portlet-column-content {}
.vv-form-group label {}

will cause:

TypeError: str.indexOf is not a function
    at constructor._checkPadding (/home/john/Liferay/MyTest-theme/node_modules/convert-bootstrap-2-to-3/lib/formatters/css.js:61:13)
    at constructor._extractRecursive (/home/john/Liferay/MyTest-theme/node_modules/convert-bootstrap-2-to-3/lib/formatters/css.js:247:6)
    at constructor.format (/home/john/Liferay/MyTest-theme/node_modules/convert-bootstrap-2-to-3/lib/formatters/css.js:23:14)
    at CLI.processFileData (/home/john/Liferay/MyTest-theme/node_modules/convert-bootstrap-2-to-3/lib/cli.js:181:28)
    ...

As the _checkPadding method assigns to either an object or a string, direct access to str.indexOf is not safe.

See liferay/liferay-js-themes-toolkit#80 for more information on the matter.

Php file with html and CSS

Is it possible to parse some php script that have css and html in bootstrap 2 to convert HTMLand/or CSS in bootstrap 3?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.