This repository was archived by the owner on Nov 10, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 56
General FE Workflow [DO NOT MERGE] #245
Closed
Closed
Changes from 63 commits
Commits
Show all changes
65 commits
Select commit
Hold shift + click to select a range
4aa2f6a
Add initial setup of the front-end workflow based on Node and Gulp (t…
delawski 390fb81
Make it possible to use multiple front-end workflows directly from `p…
delawski f7d55d8
Add the JS workflow based on Browserify allowing for multiple bundles…
delawski 5b702cb
Fix minor code typos.
delawski f5feb46
Use `browserslist` with `babel-preset-env` and `babelify` to compile …
delawski 522be75
Add JS Lint task to the workflow.
delawski da8c5f0
Use better name for the config module.
delawski fbfdf3b
Add `watch` task to the workflow.
delawski ec5b126
Fix typo in prop name.
delawski 1c84803
Add `images` task.
delawski 14b16b2
Add `copy` task.
delawski 839ecd8
Improve `env` parameter handling.
delawski 4f6696d
Rename `fe-workflow` to more general `workflows`
delawski d0b8f1a
Introduce `TaskHelper` class and make use of it in Gulp tasks.
delawski c6e1f74
Update `package.json` template.
delawski 3abb4b6
Add support for `postcss-assets` processor. Improve PostCSS processor…
delawski 57bf6ca
Update `package.json`.
delawski 36cbf7b
Updated to Gulp 4
mehigh 96b7461
Updated devDependencies
mehigh f0d873d
Run Gulp 4 tasks sequentially. Simplify `css-lint` task configuration.
delawski 221eb85
Merge branch 'feature/front-end-workflow' into feature/front-end-work…
delawski 34fd6ee
Make sure all tasks have proper display names.
delawski 7952f41
Filtred undefined paths
mehigh 60bc56b
Replacing yarn by npm
mehigh afb19b0
Use `merge-stream` instead of `event-stream` in order to have task co…
delawski 42c949f
Flatten `workflows` object - no need for separate `env` definition.
delawski d81cb5e
Improve tasks handling in the `gulpfile`.
delawski d800e72
Run `clean` task in series with other tasks being run in parallel.
delawski 42e8d5d
Get rid of `cwd` in the tasks list as soon as possible.
delawski 3b71783
Add preliminary test for Node min. version. Improve parallel/serial t…
delawski 4ef3741
Updated browserslist to match Wordpress standards
mehigh d90f671
Updated the path to include the ./dev-lib such that it can be run fro…
mehigh f14ec3c
Updating minimum requirement to 6.11 (in node's stable tag)
mehigh bc1152e
Add support for `schemas`.
delawski f271623
Merge branch 'feature/front-end-workflow-update' of github.com:xwp/wp…
delawski d0ab033
Adjusted css schema to have /css
mehigh 0df8259
Webpack JS
mehigh 432e8cb
Added webpack dependencies, removed babelify browserify. added basic …
mehigh 93541b2
JS: Added default theme schema
mehigh eb3e393
JS: Cleaned package.json - added sample vendors.js 2nd js compilation
mehigh 6fcb209
Adding jQuery global to ESLint due to high percentage of WP sites usi…
mehigh a6a08fb
Added no unsupported browser features to the styles linting plugin
mehigh d4e0316
Disabled eslint.format in dev to avoid the formatting updates from tr…
mehigh 924a9e3
Added plumber and eslint to webpack workflow
mehigh 152a6eb
Updated comment about task that watches for JS
mehigh 487d181
Updated authors / contributors + shrank the dependencies list accordi…
mehigh d285e82
ESLint Ignored the dist directory
mehigh 66746b8
Added back empty test script
mehigh cd8c9ad
Fixed contributors
mehigh 7cb7a13
Remove unneeded code in the `JS` task.
delawski 07106c4
Remove commented out code and slight code improvements.
delawski b807afd
Recommendations for workflow updates.
kopepasah 5e02f9d
Update FE workflow:
delawski 7c4b07a
Update quotes for JSON.
kopepasah f63fc78
Set rules as null to not enforce.
kopepasah 193fcce
Merge branch 'feature/front-end-workflow-update' into feature/front-e…
kopepasah 49de169
Make it possible to ignore tasks from the initial list.
delawski 63b0dfb
Merge pull request #246 from xwp/feature/front-end-workflow-update-recs
mehigh 57b7055
Use `dependencies` instead of `devDependencies`.
delawski fea9cc0
Merge branch 'feature/front-end-workflow-update' of github.com:xwp/wp…
delawski db047d4
Add transpiled gulpfile.
delawski 5187884
Transpile whole directory, not single file.
delawski 0431731
Split Workflows into `src` and `dist` folders. Clean up `package.json`.
delawski 53023b1
Update `package.json`.
delawski 7083b04
Ignore `npm-debug.log`.
delawski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| **/*.min.js | ||
| **/node_modules/** | ||
| **/vendor/** | ||
| **/dist/** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| codecept.phar | ||
| node_modules |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -e | ||
|
|
||
| rm -rf ./workflows/dist | ||
| ./node_modules/.bin/babel ./workflows/src --out-dir ./workflows/dist | ||
| mv ./workflows/dist/gulpfile.babel.js ./workflows/dist/gulpfile.js |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,18 +2,136 @@ | |
| "name": "wp-dev-lib", | ||
| "version": "1.0.0", | ||
| "description": "Common code used during development of WordPress plugins and themes", | ||
| "scripts": { | ||
| "test": "echo \"Error: no test specified\" && exit 1" | ||
| }, | ||
| "repository": "xwp/wp-dev-lib", | ||
| "engines": { | ||
| "node": ">=6.11.x" | ||
| }, | ||
| "keywords": [ | ||
| "wordpress", | ||
| "plugins", | ||
| "themes", | ||
| "development", | ||
| "tools" | ||
| ], | ||
| "author": "Weston Ruter <weston@xwp.co> (https://xwp.co)", | ||
| "author": { | ||
| "name": "Weston Ruter", | ||
| "email": "weston.ruter@xwp.co", | ||
| "url": "https://www.xwp.co" | ||
| }, | ||
| "contributors": [ | ||
| { | ||
| "name": "Piotr Delawski", | ||
| "email": "piotr.delawski@xwp.co" | ||
| }, | ||
| { | ||
| "name": "Mike Crantea", | ||
| "email": "mike.crantea@xwp.co" | ||
| }, | ||
| { | ||
| "name": "Justin Kopepasah", | ||
| "email": "justin.kopepasah@xwp.co", | ||
| "url": "https://kopepasah.com" | ||
| } | ||
| ], | ||
| "license": "MIT", | ||
| "homepage": "https://github.com/xwp/wp-dev-lib#readme" | ||
| "homepage": "https://github.com/xwp/wp-dev-lib#readme", | ||
| "scripts": { | ||
| "build:self": "./build-workflows.sh", | ||
| "test": "echo \"Error: no test specified\" && exit 1" | ||
| }, | ||
| "browserslist": [ | ||
| "last 2 Chrome versions", | ||
| "last 2 Firefox versions", | ||
| "last 2 Safari versions", | ||
| "last 2 Edge versions", | ||
| "last 2 Opera versions", | ||
| "last 2 iOS versions", | ||
| "last 1 Android version", | ||
| "last 1 ChromeAndroid version", | ||
| "ie 11", | ||
| "> 1%" | ||
| ], | ||
| "babel": { | ||
| "presets": [ | ||
| [ | ||
| "env" | ||
| ] | ||
| ] | ||
| }, | ||
| "stylelint": { | ||
| "extends": "stylelint-config-wordpress/scss", | ||
| "plugins": [ | ||
| "stylelint-no-unsupported-browser-features" | ||
| ], | ||
| "rules": { | ||
| "string-quotes": "single", | ||
| "color-hex-length": null, | ||
| "function-parentheses-space-inside": null, | ||
| "function-url-quotes": "always", | ||
| "at-rule-empty-line-before": [ | ||
| "always", | ||
| { | ||
| "except": [ | ||
| "first-nested", | ||
| "blockless-after-same-name-blockless" | ||
| ], | ||
| "ignore": [ | ||
| "after-comment" | ||
| ], | ||
| "ignoreAtRules": [ | ||
| "else", | ||
| "elseif" | ||
| ] | ||
| } | ||
| ], | ||
| "plugin/no-unsupported-browser-features": [ | ||
| true, | ||
| { | ||
| "severity": "warning" | ||
| } | ||
| ], | ||
| "selector-pseudo-element-colon-notation": "double", | ||
| "value-keyword-case": null | ||
| } | ||
| }, | ||
| "dependencies": { | ||
| "autoprefixer": "^7.1.2", | ||
| "babel-cli": "^6.24.1", | ||
| "babel-core": "^6.25.0", | ||
| "babel-loader": "^7.1.1", | ||
| "babel-preset-env": "^1.6.0", | ||
| "del": "^3.0.0", | ||
| "eslint": "^4.3.0", | ||
| "eslint-config-wordpress": "^2.0.0", | ||
| "eslint-loader": "^1.9.0", | ||
| "eslint-plugin-compat": "^1.0.4", | ||
| "gulp": "gulpjs/gulp.git#4.0", | ||
| "gulp-cached": "^1.1.1", | ||
| "gulp-eslint": "^4.0.0", | ||
| "gulp-if": "^2.0.2", | ||
| "gulp-imagemin": "^3.3.0", | ||
| "gulp-plumber": "^1.1.0", | ||
| "gulp-postcss": "^7.0.0", | ||
| "gulp-progeny": "^0.4.0", | ||
| "gulp-sass": "^3.1.0", | ||
| "gulp-sourcemaps": "^2.6.0", | ||
| "gulp-watch": "^4.3.11", | ||
| "lodash": "^4.17.4", | ||
| "postcss": "^6.0.8", | ||
| "postcss-assets": "^4.2.0", | ||
| "postcss-cssnext": "^3.0.2", | ||
| "postcss-pxtorem": "^4.0.1", | ||
| "postcss-reporter": "^4.0.0", | ||
| "postcss-scss": "^1.0.2", | ||
| "progress-bar-webpack-plugin": "^1.10.0", | ||
| "require-dir": "^0.3.2", | ||
| "stylelint": "^7.13.0", | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch! Thank you. We will update the |
||
| "stylelint-config-wordpress": "^12.0.0", | ||
| "stylelint-no-unsupported-browser-features": "^1.0.0", | ||
| "validate-node-version": "^1.1.1", | ||
| "webpack": "^3.3.0", | ||
| "webpack-config-utils": "^2.3.0", | ||
| "webpack-stream": "^3.2.0", | ||
| "yargs": "^8.0.2" | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| 'use strict'; | ||
|
|
||
| var _gulp = require('gulp'); | ||
|
|
||
| var _gulp2 = _interopRequireDefault(_gulp); | ||
|
|
||
| var _preCheck = require('./utils/pre-check'); | ||
|
|
||
| var _getTasks = require('./utils/get-tasks'); | ||
|
|
||
| function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
|
|
||
| // Check Node version and workflow setup. | ||
| (0, _preCheck.preCheck)(); | ||
|
|
||
| // Define default task. | ||
| _gulp2.default.task('default', _gulp2.default.series((0, _getTasks.getTasks)())); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| 'use strict'; | ||
|
|
||
| var _gulp = require('gulp'); | ||
|
|
||
| var _gulp2 = _interopRequireDefault(_gulp); | ||
|
|
||
| var _getConfig = require('../utils/get-config'); | ||
|
|
||
| var _del = require('del'); | ||
|
|
||
| var _del2 = _interopRequireDefault(_del); | ||
|
|
||
| var _TaskHelper = require('../utils/TaskHelper'); | ||
|
|
||
| var _TaskHelper2 = _interopRequireDefault(_TaskHelper); | ||
|
|
||
| function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
|
|
||
| var task = new _TaskHelper2.default({ | ||
| name: 'clean', | ||
| requiredPaths: ['src'], | ||
| config: _getConfig.tasks | ||
| }); | ||
|
|
||
| _gulp2.default.task(task.name, function (done) { | ||
| if (task.isValid()) { | ||
| (0, _del2.default)(task.src).then(function () { | ||
| return done(); | ||
| }); | ||
| } | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| 'use strict'; | ||
|
|
||
| var _gulp = require('gulp'); | ||
|
|
||
| var _gulp2 = _interopRequireDefault(_gulp); | ||
|
|
||
| var _gulpIf = require('gulp-if'); | ||
|
|
||
| var _gulpIf2 = _interopRequireDefault(_gulpIf); | ||
|
|
||
| var _gulpCached = require('gulp-cached'); | ||
|
|
||
| var _gulpCached2 = _interopRequireDefault(_gulpCached); | ||
|
|
||
| var _getConfig = require('../utils/get-config'); | ||
|
|
||
| var _TaskHelper = require('../utils/TaskHelper'); | ||
|
|
||
| var _TaskHelper2 = _interopRequireDefault(_TaskHelper); | ||
|
|
||
| function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
|
|
||
| var task = new _TaskHelper2.default({ | ||
| name: 'copy', | ||
| requiredPaths: ['src', 'dest'], | ||
| config: _getConfig.tasks | ||
| }); | ||
|
|
||
| _gulp2.default.task(task.name, function () { | ||
| if (!task.isValid()) { | ||
| return null; | ||
| } | ||
|
|
||
| return task.start().pipe((0, _gulpIf2.default)(_getConfig.isDev, (0, _gulpCached2.default)(task.cacheName, { optimizeMemory: false }))).pipe(task.end()); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| 'use strict'; | ||
|
|
||
| var _gulp = require('gulp'); | ||
|
|
||
| var _gulp2 = _interopRequireDefault(_gulp); | ||
|
|
||
| var _gulpCached = require('gulp-cached'); | ||
|
|
||
| var _gulpCached2 = _interopRequireDefault(_gulpCached); | ||
|
|
||
| var _getConfig = require('../utils/get-config'); | ||
|
|
||
| var _gulpIf = require('gulp-if'); | ||
|
|
||
| var _gulpIf2 = _interopRequireDefault(_gulpIf); | ||
|
|
||
| var _gulpPostcss = require('gulp-postcss'); | ||
|
|
||
| var _gulpPostcss2 = _interopRequireDefault(_gulpPostcss); | ||
|
|
||
| var _postcssReporter = require('postcss-reporter'); | ||
|
|
||
| var _postcssReporter2 = _interopRequireDefault(_postcssReporter); | ||
|
|
||
| var _postcssScss = require('postcss-scss'); | ||
|
|
||
| var _postcssScss2 = _interopRequireDefault(_postcssScss); | ||
|
|
||
| var _stylelint = require('stylelint'); | ||
|
|
||
| var _stylelint2 = _interopRequireDefault(_stylelint); | ||
|
|
||
| var _TaskHelper = require('../utils/TaskHelper'); | ||
|
|
||
| var _TaskHelper2 = _interopRequireDefault(_TaskHelper); | ||
|
|
||
| function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
|
|
||
| var task = new _TaskHelper2.default({ | ||
| name: 'css-lint', | ||
| requiredPaths: ['src'], | ||
| config: _getConfig.tasks, | ||
| configSlug: 'css' | ||
| }); | ||
|
|
||
| if (undefined !== task.config) { | ||
| _gulp2.default.task(task.name, function () { | ||
| if (!task.isValid()) { | ||
| return null; | ||
| } | ||
|
|
||
| return task.start().pipe((0, _gulpIf2.default)(_getConfig.isDev, (0, _gulpCached2.default)(task.cacheName))).pipe((0, _gulpPostcss2.default)([(0, _stylelint2.default)(), (0, _postcssReporter2.default)({ clearAllMessages: true })], { syntax: _postcssScss2.default })); | ||
| }); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are the WordPress CSS Coding Standards being overridden here?
(For clarification, there are 8 rules being overridden, not easily reviewable in the PR review view)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See also the stylelint pull request #239 where the proposal is to use
styelint-config-wordpressas is without overriding any rulesThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ntwb Thank you for your comment.
First of all, please note that this ruleset is still a work in progress and may change.
To answer your question - we decided to relax or override some of the rules defined in the
stylelint-config-wordpress/scssbased on the way we usually format our SCSS code.In some points our best practices align quite well with the CSS rules set by Automattic in the Calypso project:
string-quotes). It reflects the way strings in PHP and JS are treated in WordPress.urlfunctions too (function-url-quotes).function-parentheses-space-inside). It, again, better reflects the way we format PHP and JS code.color-hex-length), since they will get optimized/shortened in the SCSS compilation process.There are also grey areas, not defined in the WordPress CSS Coding Standards, e.g.:
at-rule-empty-line-beforerule in this particular way. We feel that the code is easier to read with the such setup.selector-pseudo-element-colon-notation. Our guess is that the requirement for a single colon is included in thestylelint-config-wordpressto maintain the Internet Explorer 8 support. Since IE 8 is no longer supported by WordPress as of version 4.8, we feel our code should use the valid CSS notation, i.e. double colons.When it comes to the
value-keyword-casemy opinion is that is should not be overridden here. We should always use lowercase for CSS values. @mehigh and @kopepasah what do you think about it?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree
value-keyword-caseshould be enforced to lower.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where we diverge from core standards, should we not create a separate ruleset like
stylelint-ruleset-xwpthat inherits fromstylelint-ruleset-wordpress? Then wp-dev-lib can continue to just usestylelint-ruleset-wordpressand our projects can override thepackage.jsonto specify our flavour. Otherwise, we should try to upstream our changes if they are compelling.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the detailed explanation @delawski, I now see what I was missing here was a bit of context that @westonruter has now clarified. As is obvious that this repo is a XWP project, I also know quite a few people outside of XWP use this repo(or least parts of it) so diverging from WordPress' Coding Standards had me a little perplexed.
Going the route of creating
stylelint-config-xwpwould be 👌Your guess in regard to
selector-pseudo-element-colon-notationis correct, it was because of IE8, I've created WordPress-Coding-Standards/stylelint-config-wordpress#165 to update to double colons 👍There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sounds really good. I went ahead and created a
stylelint-config-xwpbased on thestylelint-config-wordpress.I will update the
wp-dev-libto usestylelint-config-wordpresswhile on most non-Core projects we will usestylelint-config-xwp.