Skip to content
This repository was archived by the owner on Aug 29, 2024. It is now read-only.

Commit 1d01fa7

Browse files
committed
Merge remote-tracking branch 'roots/10.0.0-dev' into 10.0.0-dev
* roots/10.0.0-dev: Add post-autoload-dump script for package discovery (roots#2201) Update dependencies New DOM router + dynamic imports (roots#2190) Simplify Mix Browsersync API (roots#2198) Fix version_compare() operators (roots#2195) Restructure (roots#2200)
2 parents 445623e + 2e14a43 commit 1d01fa7

File tree

18 files changed

+63
-140
lines changed

18 files changed

+63
-140
lines changed

.babelrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"plugins": ["@babel/plugin-syntax-dynamic-import"]
3+
}

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ orbs:
2929
- composer-v1-{{ checksum "composer.lock" }}
3030
- composer-v1-
3131
- run: composer install -n --prefer-dist
32-
- run: composer test
32+
- run: composer lint
3333
- save_cache:
3434
key: composer-v1-{{ checksum "composer.lock" }}
3535
paths:

app/setup.php

100644100755
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424
wp_enqueue_style('sage/reset.css', asset('styles/reset.css')->uri(), false, null);
2525
wp_enqueue_style('sage/app.css', asset('styles/app.css')->uri(), ['sage/reset.css'], null);
26-
2726
}, 100);
2827

2928
/**

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,11 @@
6060
"minimum-stability": "dev",
6161
"prefer-stable": true,
6262
"scripts": {
63-
"test": [
63+
"lint": [
6464
"phpcs"
65+
],
66+
"post-autoload-dump": [
67+
"Roots\\Acorn\\ComposerScripts::postAutoloadDump"
6568
]
6669
}
6770
}

config/view.php

100644100755
File mode changed.

resources/functions.php renamed to functions.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,21 @@
2121
/**
2222
* Ensure compatible version of PHP is used
2323
*/
24-
if (version_compare('7.1.3', phpversion(), '>=')) {
24+
if (version_compare('7.1.3', phpversion(), '>')) {
2525
$sage_error(__('You must be using PHP 7.1.3 or greater.', 'sage'), __('Invalid PHP version', 'sage'));
2626
}
2727

2828
/**
2929
* Ensure compatible version of WordPress is used
3030
*/
31-
if (version_compare('5.2', get_bloginfo('version'), '>=')) {
31+
if (version_compare('5.2', get_bloginfo('version'), '>')) {
3232
$sage_error(__('You must be using WordPress 5.2 or greater.', 'sage'), __('Invalid WordPress version', 'sage'));
3333
}
3434

3535
/**
3636
* Ensure dependencies are loaded
3737
*/
38-
if (! file_exists($composer = __DIR__ . '/../vendor/autoload.php')) {
38+
if (! file_exists($composer = __DIR__ . '/vendor/autoload.php')) {
3939
$sage_error(
4040
__('You must run <code>composer install</code> from the Sage directory.', 'sage'),
4141
__('Autoloader not found.', 'sage')
@@ -50,7 +50,7 @@
5050
* Add or remove files to the array as needed. Supports child theme overrides.
5151
*/
5252
array_map(function ($file) use ($sage_error) {
53-
$file = "../app/{$file}.php";
53+
$file = "app/{$file}.php";
5454
if (! locate_template($file, true, true)) {
5555
$sage_error(
5656
sprintf(__('Error locating <code>%s</code> for inclusion.', 'sage'), $file),
File renamed without changes.

package.json

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,41 +17,45 @@
1717
},
1818
"eslintConfig": {
1919
"root": true,
20+
"parser": "babel-eslint",
2021
"extends": [
2122
"plugin:genero/recommended",
2223
"plugin:genero/wordpress"
2324
]
2425
},
2526
"devDependencies": {
27+
"@babel/plugin-syntax-dynamic-import": "^7.2",
2628
"@wordpress/babel-preset-default": "^4.2.0",
27-
"browser-sync": "^2.26.5",
28-
"browser-sync-webpack-plugin": "2.0.1",
29+
"babel-eslint": "^10.0.1",
30+
"browser-sync": "^2.26",
31+
"browser-sync-webpack-plugin": "2.2",
2932
"classnames": "^2.2.6",
30-
"cross-env": "^5.2.0",
33+
"cross-env": "^5.2",
3134
"eslint": "^5.11",
3235
"eslint-plugin-genero": "git+https://github.com/generoi/eslint-plugin-genero.git",
33-
"eslint-plugin-import": "^2.14",
34-
"laravel-mix": "^4.0.15",
36+
"eslint-plugin-import": "^2.17",
37+
"laravel-mix": "^4.0",
3538
"laravel-mix-export-tailwind-config": "^0.1.2",
3639
"laravel-mix-wp-blocks": "^0.1.4",
37-
"npm-run-all": "^4.1.5",
40+
"npm-run-all": "^4.1",
3841
"postcss-import": "^12.0.1",
3942
"postcss-inline-svg": "^3.1.1",
4043
"postcss-nested": "^4.1.2",
4144
"postcss-preset-env": "^6.6.0",
4245
"postcss-scss": "^2.0.0",
4346
"prop-types": "^15.7.2",
4447
"rimraf": "^2.6",
45-
"sass": "^1.19.0",
48+
"sass": "^1.21",
4649
"sass-loader": "7.*",
47-
"stylelint": "^9.9",
50+
"stylelint": "^10.1",
4851
"stylelint-config-standard": "^18.2",
4952
"tailwindcss": "^1.0.1",
5053
"tailwindcss-gutenberg": "git+https://github.com/generoi/tailwindcss-gutenberg.git",
5154
"vue-template-compiler": "^2.6.10",
5255
"write-webpack-plugin": "^1.1.0"
5356
},
5457
"dependencies": {
55-
"jquery": "^3.4.0"
58+
"jquery": "^3.4",
59+
"js-dom-router": "^1.0"
5660
}
5761
}

phpcs.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
<description>Roots Coding Standards</description>
44

55
<!-- Scan these files -->
6-
<file>resources/functions.php</file>
7-
<file>resources/index.php</file>
6+
<file>functions.php</file>
7+
<file>index.php</file>
88
<file>app</file>
9+
<file>config</file>
910
<file>resources/views</file>
1011

1112
<!-- Show colors in console -->
@@ -15,7 +16,7 @@
1516
<arg value="s"/>
1617

1718
<!-- Use PSR-2 as a base -->
18-
<rule ref="PSR2"/>
19+
<rule ref="PSR12"/>
1920

2021
<!-- Exclusions below are for resources/views/ folder -->
2122

resources/assets/scripts/app.js

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,28 @@
11
/**
2-
* Local Dependencies
2+
* External Dependencies
33
*/
4-
import Router from './util/Router';
5-
import common from './routes/common';
6-
import aboutUs from './routes/about';
7-
import { ready } from './utils';
4+
import { router } from 'js-dom-router';
85

96
/**
10-
* Populate the Router instance with DOM routes.
7+
* DOM-based routing
8+
*/
9+
import about from './routes/about';
10+
11+
/**
12+
* Below is an example of a dynamic import; it will not be loaded until it's needed.
1113
*
12-
* common – Fired on all pages.
13-
* aboutUs – Fired on the About Us page, note the change from about-us to aboutUs (camelCase).
14+
* See: {@link https://webpack.js.org/guides/code-splitting/#dynamic-imports | Dynamic Imports}
1415
*/
15-
const routes = new Router({
16-
common,
17-
aboutUs,
18-
});
16+
const home = async () => import(/* webpackChunkName: "scripts/routes/home" */ './routes/home');
1917

2018
/**
21-
* Load Events
19+
* Set up DOM router
20+
*
21+
* .on(<name of body class>, callback)
22+
*
23+
* See: {@link http://goo.gl/EUTi53 | Markup-based Unobtrusive Comprehensive DOM-ready Execution} by Paul Irish
2224
*/
23-
ready(() => routes.loadEvents());
25+
router
26+
.on('about-us', about)
27+
.on('home', async (event) => (await home()).default(event))
28+
.ready();

0 commit comments

Comments
 (0)