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

v4: Move to npm scripts #20332

Closed
wants to merge 2 commits into from
Closed
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
19 changes: 17 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,21 @@
"eslint": "eslint --config js/.eslintrc.json js/src",
"jscs": "jscs --config=js/.jscsrc js/src js/tests/unit docs/assets/js/src grunt Gruntfile.js docs/assets/js/ie-emulation-modes-warning.js docs/assets/js/ie10-viewport-bug-workaround.js",
"htmlhint": "htmlhint --config docs/.htmlhintrc _gh_pages/",
"postcss": "postcss --config grunt/postcss.js --replace dist/css/*.css",
"postcss": "./tasks/dist/postcss",
"postcss-docs": "postcss --config grunt/postcss.js --no-map --replace docs/assets/css/docs.min.css && postcss --config grunt/postcss.js --no-map --replace docs/examples/**/*.css",
"update-shrinkwrap": "npm shrinkwrap --dev && shx mv ./npm-shrinkwrap.json ./grunt/npm-shrinkwrap.json",
"test": "npm run eslint && npm run jscs && grunt test"
"test": "npm run eslint && npm run jscs && grunt test",
"build-css": "./tasks/dist/css",
"build-css-min": "./tasks/dist/css-min",
"stylelint": "./tasks/dist/stylelint",
"uglifyjs": "./tasks/dist/uglifyjs",
"docs-css-min": "./tasks/docs/css-min",
"docs-stylelint": "./tasks/docs/stylelint",
"docs-postcss": "./tasks/docs/postcss",
"watch-css": "./tasks/watch-css",
"watch-js": "./tasks/watch-js",
"docs": "npm run docs-css-min & npm run docs-stylelint & npm run docs-postcss",
"build": "npm run build-css & npm run build-css-min & npm run postcss"
},
"style": "dist/css/bootstrap.css",
"sass": "scss/bootstrap.scss",
Expand Down Expand Up @@ -69,10 +80,14 @@
"is-travis": "^1.0.0",
"jscs": "^3.0.4",
"load-grunt-tasks": "^3.4.0",
"nodemon": "^1.9.2",
"postcss-cli": "^2.5.2",
"postcss-flexbugs-fixes": "^2.0.0",
"shelljs": "^0.7.0",
"shx": "^0.1.2",
"stylelint": "^7.0.3",
"stylelint-scss": "^1.2.1",
"stylelint-selector-no-utility": "^1.2.0",
"time-grunt": "^1.2.1"
},
"engines": {
Expand Down
328 changes: 328 additions & 0 deletions scss/.stylelintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,328 @@
{
"plugins": [
"stylelint-scss",
"stylelint-selector-no-utility"
],
"rules": {
"at-rule-blacklist": ["extend"],
"at-rule-name-case": "lower",
"at-rule-name-space-after": "always-single-line",
"at-rule-semicolon-newline-after": "always",
"block-closing-brace-newline-after": "always",
"block-closing-brace-newline-before": "always-multi-line",
"block-closing-brace-space-before": "always-single-line",
"block-no-empty": true,
"block-opening-brace-newline-after": "always-multi-line",
"block-opening-brace-space-after": "always-single-line",
"block-opening-brace-space-before": "always",
"color-hex-case": "lower",
"color-hex-length": "short",
"color-named": "never",
"color-no-invalid-hex": true,
"comment-empty-line-before": [
"always",
{
"except": [
"first-nested"
],
"ignore": [
"stylelint-commands"
]
}
],
"comment-whitespace-inside": "always",
"declaration-bang-space-after": "never",
"declaration-bang-space-before": "always",
"declaration-block-no-duplicate-properties": [
true,
{
"ignore": [
"consecutive-duplicates"
]
}
],
"declaration-block-no-shorthand-property-overrides": true,
"declaration-block-properties-order": [
"position",
"top",
"right",
"bottom",
"left",
"z-index",
"display",
"float",
"width",
"min-width",
"max-width",
"height",
"min-height",
"max-height",
"box-sizing",
"padding",
"padding-top",
"padding-right",
"padding-bottom",
"padding-left",
"margin",
"margin-top",
"margin-right",
"margin-bottom",
"margin-left",
"overflow",
"overflow-x",
"overflow-y",
"clip",
"clear",
"font",
"font-family",
"font-size",
"font-style",
"font-weight",
"font-variant",
"font-size-adjust",
"font-stretch",
"font-effect",
"font-emphasize",
"font-emphasize-position",
"font-emphasize-style",
"font-smooth",
"hyphens",
"line-height",
"color",
"text-align",
"text-align-last",
"text-emphasis",
"text-emphasis-color",
"text-emphasis-style",
"text-emphasis-position",
"text-decoration",
"text-indent",
"text-justify",
"text-outline",
"text-overflow",
"text-overflow-ellipsis",
"text-overflow-mode",
"text-shadow",
"text-transform",
"text-wrap",
"letter-spacing",
"word-break",
"word-spacing",
"word-wrap",
"tab-size",
"white-space",
"vertical-align",
"list-style",
"list-style-position",
"list-style-type",
"list-style-image",
"pointer-events",
"fill",
"fill-opacity",
"stroke",
"stroke-opacity",
"stroke-width",
"shape-rendering",
"cursor",
"visibility",
"zoom",
"flex-direction",
"flex-order",
"flex-pack",
"flex-align",
"table-layout",
"empty-cells",
"caption-side",
"border-spacing",
"border-collapse",
"content",
"quotes",
"counter-reset",
"counter-increment",
"resize",
"user-select",
"nav-index",
"nav-up",
"nav-right",
"nav-down",
"nav-left",
"background",
"background-color",
"background-image",
"filter",
"background-repeat",
"background-attachment",
"background-position",
"background-position-x",
"background-position-y",
"background-clip",
"background-origin",
"background-size",
"border",
"border-color",
"border-style",
"border-width",
"border-top",
"border-top-color",
"border-top-style",
"border-top-width",
"border-right",
"border-right-color",
"border-right-style",
"border-right-width",
"border-bottom",
"border-bottom-color",
"border-bottom-style",
"border-bottom-width",
"border-left",
"border-left-color",
"border-left-style",
"border-left-width",
"border-radius",
"border-top-left-radius",
"border-top-right-radius",
"border-bottom-right-radius",
"border-bottom-left-radius",
"border-image",
"border-image-source",
"border-image-slice",
"border-image-width",
"border-image-outset",
"border-image-repeat",
"outline",
"outline-width",
"outline-style",
"outline-color",
"outline-offset",
"box-shadow",
"opacity",
"transition",
"transition-delay",
"transition-timing-function",
"transition-duration",
"transition-property",
"transform",
"transform-origin",
"animation",
"animation-name",
"animation-duration",
"animation-fill-mode",
"animation-play-state",
"animation-timing-function",
"animation-delay",
"animation-iteration-count",
"animation-direction"
],
"declaration-block-semicolon-newline-after": "always",
"declaration-block-semicolon-space-before": "never",
"declaration-block-single-line-max-declarations": 1,
"declaration-block-trailing-semicolon": "always",
"declaration-colon-newline-after": "always-multi-line",
"declaration-colon-space-after": "always-single-line",
"declaration-colon-space-before": "never",
"declaration-property-value-blacklist": {
"/^transition/": [
"/all/"
],
"/^background/": [
"http:",
"https:"
],
"/^border/": [
"none"
],
"/.+/": [
"initial"
]
},
"font-family-name-quotes": "always-where-recommended",
"function-calc-no-unspaced-operator": true,
"function-comma-newline-after": "always-multi-line",
"function-comma-space-after": "always-single-line",
"function-comma-space-before": "never",
"function-linear-gradient-no-nonstandard-direction": true,
"function-max-empty-lines": 0,
"function-name-case": "lower",
"function-parentheses-newline-inside": "always-multi-line",
"function-parentheses-space-inside": "never-single-line",
"function-url-quotes": "always",
"function-whitespace-after": "always",
"indentation": 2,
"max-empty-lines": 1,
"max-nesting-depth": 3,
"media-feature-colon-space-after": "always",
"media-feature-colon-space-before": "never",
"media-feature-no-missing-punctuation": true,
"media-feature-parentheses-space-inside": "never",
"media-feature-range-operator-space-after": "always",
"media-feature-range-operator-space-before": "always",
"media-query-list-comma-newline-after": "always-multi-line",
"media-query-list-comma-space-after": "always-single-line",
"media-query-list-comma-space-before": "never",
"no-duplicate-selectors": true,
"no-eol-whitespace": true,
"no-extra-semicolons": true,
"no-missing-end-of-source-newline": true,
"no-unsupported-browser-features": [true, {
"browsers": "> 5%, last 2 firefox versions, last 2 chrome versions, last 2 safari versions, last 2 edge versions, ie 11",
"severity": "warning"
}],
"number-leading-zero": "never",
"number-no-trailing-zeros": true,
"property-case": "lower",
"property-no-vendor-prefix": true,
"rule-nested-empty-line-before": [
"always-multi-line",
{
"except": [
"first-nested"
],
"ignore": [
"after-comment"
]
}
],
"rule-non-nested-empty-line-before": [
"always-multi-line",
{
"ignore": [
"after-comment"
]
}
],
"scss/selector-no-redundant-nesting-selector": true,
"selector-attribute-brackets-space-inside": "never",
"selector-attribute-operator-space-after": "never",
"selector-attribute-operator-space-before": "never",
"selector-class-pattern": [
"^(?!(js\\-))[a-z\\-0-9]+$",
{
"message": "Selector should be written in lowercase with hyphens (selector-class-pattern)"
}
],
"selector-combinator-space-after": "always",
"selector-combinator-space-before": "always",
"selector-list-comma-newline-after": "always",
"selector-list-comma-space-before": "never",
"selector-max-compound-selectors": 3,
"selector-max-empty-lines": 0,
"selector-max-specificity": "0,4,0",
"selector-no-id": true,
"selector-no-qualifying-type": true,
"selector-pseudo-class-case": "lower",
"selector-pseudo-class-parentheses-space-inside": "never",
"selector-pseudo-element-case": "lower",
"selector-pseudo-element-colon-notation": "double",
"selector-pseudo-element-no-unknown": true,
"selector-type-case": "lower",
"shorthand-property-no-redundant-values": true,
"string-no-newline": true,
"string-quotes": "double",
"unit-case": "lower",
"unit-no-unknown": true,
"value-list-comma-newline-after": "always-multi-line",
"value-list-comma-space-after": "always-single-line",
"value-list-comma-space-before": "never",
"value-no-vendor-prefix": true
}
}
1 change: 1 addition & 0 deletions tasks/dist/css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node-sass --output-style expanded --source-map true --precision 6 docs/assets/scss/docs.scss docs/assets/css/docs.css
Copy link
Member

Choose a reason for hiding this comment

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

probably better if you reference the local npm installs of these (in .bin ) so that people don't need global installs 👍

Copy link
Member

Choose a reason for hiding this comment

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

Well this whole approach will have issues on Windows. But I'll try it later
or tomorrow to verify this.

On Jul 20, 2016 22:44, "fat" notifications@github.com wrote:

In tasks/dist/css
#20332 (comment):

@@ -0,0 +1 @@
+node-sass --output-style expanded --source-map true --precision 6 docs/assets/scss/docs.scss docs/assets/css/docs.css

probably better if you reference the local npm installs of these (in .bin
) so that people don't need global installs 👍


You are receiving this because you are on a team that was mentioned.
Reply to this email directly, view it on GitHub
https://github.com/twbs/bootstrap/pull/20332/files/795f6d924b1c1eb9b637917a41f2c83655408c97#r71592896,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAVVtVO5bBIj0o15D8lDel5ya1-05Smrks5qXnqfgaJpZM4JRHjn
.

Copy link
Member Author

Choose a reason for hiding this comment

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

In https://docs.npmjs.com/cli/run-script, it sounded like if the devDependency is there, npm run will do that for us.

In addition to the shell's pre-existing PATH, npm run adds node_modules/.bin to the PATH provided to scripts. Any binaries provided by locally-installed dependencies can be used without the node_modules/.bin prefix. For example, if there is a devDependency on tap in your package, you should write:

Reading that, maybe I just need to add node-sass to devDependency? Again, I've no idea so I'm likely wrong 😁.

Copy link
Member

Choose a reason for hiding this comment

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

This is true for the case where you call the bin via package.json. Not sure
if it will work here since you call it in a js file. I'll try it when im
home and let you know.

On Jul 20, 2016 23:19, "Mark Otto" notifications@github.com wrote:

In tasks/dist/css
#20332 (comment):

@@ -0,0 +1 @@
+node-sass --output-style expanded --source-map true --precision 6 docs/assets/scss/docs.scss docs/assets/css/docs.css

In https://docs.npmjs.com/cli/run-script, it sounded like if the
devDependency is there, npm run will do that for us.

In addition to the shell's pre-existing PATH, npm run adds
node_modules/.bin to the PATH provided to scripts. Any binaries provided by
locally-installed dependencies can be used without the node_modules/.bin
prefix. For example, if there is a devDependency on tap in your package,
you should write:

Reading that, maybe I just need to add node-sass to devDependency? Again,
I've no idea so I'm likely wrong 😁.


You are receiving this because you are on a team that was mentioned.
Reply to this email directly, view it on GitHub
https://github.com/twbs/bootstrap/pull/20332/files/795f6d924b1c1eb9b637917a41f2c83655408c97#r71598457,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAVVtdykpzNATYk8LkXMda5OCPTJJQIlks5qXoLrgaJpZM4JRHjn
.

Copy link

@rogeruiz rogeruiz Jul 21, 2016

Choose a reason for hiding this comment

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

Running these task files using npm run * will run them in the npm environment. as you mentioned above @mdo

https://docs.npmjs.com/misc/scripts#environment

Dependency versus DevDependency just has to do with what gets installed when someone using the npm package run npm install you-package. Only dependencies needed at run-time will be installed on the user's system. DevDependencies will only be installed locally when npm install is called within the repository. It's useful / helpful to only include run-time dependencies in dependencies so devs know what's needed to be installed.

FWIW, bootstrap's run-time dependencies are all bundled in the project's files right? So it shouldn't have really have any dependencies.

More info on that here: https://docs.npmjs.com/files/package.json#devdependencies

1 change: 1 addition & 0 deletions tasks/dist/css-min
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node-sass docs/assets/scss/docs.scss | cleancss -o docs/assets/css/docs.min.css --source-map
1 change: 1 addition & 0 deletions tasks/dist/postcss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
postcss --use autoprefixer --autoprefixer.browsers "Chrome >= 35, Firefox >= 38, Edge >= 12, Explorer >= 9, iOS >= 8, Safari >= 8, Android 2.3, Android >= 4, Opera >= 12" --replace docs/assets/css/*.css
1 change: 1 addition & 0 deletions tasks/dist/stylelint
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
stylelint scss/**/*.scss --syntax scss --config scss/.stylelintrc
13 changes: 13 additions & 0 deletions tasks/dist/uglifyjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
uglifyjs js/src/util.js \
js/src/alert.js \
js/src/button.js \
js/src/carousel.js \
js/src/collapse.js \
js/src/dropdown.js \
js/src/modal.js \
js/src/scrollspy.js \
js/src/tab.js \
js/src/tooltip.js \
js/src/popover.js \
--output dist/js/bootstrap.min.js \
--compress --mangle --comments /^!|@preserve|@license|@cc_on/i
1 change: 1 addition & 0 deletions tasks/docs/css-min
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node-sass scss/bootstrap.scss | cleancss -o dist/css/bootstrap.min.css --source-map
1 change: 1 addition & 0 deletions tasks/docs/postcss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
postcss --use autoprefixer --autoprefixer.browsers "Chrome >= 35, Firefox >= 38, Edge >= 12, Explorer >= 9, iOS >= 8, Safari >= 8, Android 2.3, Android >= 4, Opera >= 12" --replace dist/css/*.css
1 change: 1 addition & 0 deletions tasks/docs/stylelint
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
stylelint docs/assets/scss/**/*.scss --syntax scss --config scss/.stylelintrc
1 change: 1 addition & 0 deletions tasks/watch-css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodemon -e scss -x "npm run build-css"
1 change: 1 addition & 0 deletions tasks/watch-js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodemon -e js -w public/js -x "npm run build-js"