Skip to content

Commit 96a12ea

Browse files
authored
Merge pull request #44 from devloco/3.4.0
3.4.0
2 parents f4c5d40 + 31259d3 commit 96a12ea

File tree

18 files changed

+788
-724
lines changed

18 files changed

+788
-724
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
## Updated!
44

5-
Feb. 9, 2020
5+
Feb. 17, 2020
66
<br />
7-
Be sure to check out the new features (and bug fixes!) that Facebook added to [v3.3.1](https://github.com/facebook/create-react-app/releases/tag/v3.3.1) of `Create-React-App`.
7+
Be sure to check out the new features (and bug fixes!) that Facebook added to [v3.4.0](https://github.com/facebook/create-react-app/releases/tag/v3.4.0) of `Create-React-App`.
88

99
## Good to Know!
1010

11-
[Create-React-App](https://create-react-app.dev/) is **more than** just **React.** `Create-React-App` is a full stack of tested and battle-hardened tools, guaranteed to be configured correctly to work together to make your job easier.
11+
[Create-React-App](https://create-react-app.dev/) is **more than** just **React.** `Create-React-App` is a suite of battle-hardened tools, guaranteed to be configured correctly to work together to make your job easier.
1212

1313
**No need for weird CORS setups** or server proxies. **Why in the world** would you want to **maintain two servers** anyway? No need for that, just use `Create-React-WPTheme` instead. The biggest difference between `Create-React-WPTheme` and `Create-React-App` is that this project here **uses your WordPress server as the development server instead of the Webpack Dev Server.**
1414

packages/cra-template-wptheme-typescript/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cra-template-wptheme-typescript",
3-
"version": "3.3.1-wp.1",
3+
"version": "3.4.0-wp.3",
44
"keywords": [
55
"react",
66
"create-react-app",

packages/cra-template-wptheme-typescript/template/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ See the section about [deployment](https://facebook.github.io/create-react-app/d
3333

3434
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
3535

36-
Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
36+
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
3737

3838
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
3939

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,21 @@
1-
import React from 'react';
2-
import logo from './logo.svg';
3-
import './App.css';
1+
import React from "react";
2+
import logo from "./logo.svg";
3+
import "./App.css";
44

5-
const App = () => {
6-
return (
7-
<div className="App">
8-
<header className="App-header">
9-
<img src={logo} className="App-logo" alt="logo" />
10-
<p>
11-
Edit <code>react-src/src/App.tsx</code> and save to reload.
12-
</p>
13-
<a
14-
className="App-link"
15-
href="https://reactjs.org"
16-
target="_blank"
17-
rel="noopener noreferrer"
18-
>
19-
Learn React
20-
</a>
21-
</header>
22-
</div>
23-
);
5+
function App() {
6+
return (
7+
<div className="App">
8+
<header className="App-header">
9+
<img src={logo} className="App-logo" alt="logo" />
10+
<p>
11+
Edit <code>react-src/src/App.tsx</code> and save to reload.
12+
</p>
13+
<a className="App-link" href="https://reactjs.org" target="_blank" rel="noopener noreferrer">
14+
Learn React
15+
</a>
16+
</header>
17+
</div>
18+
);
2419
}
2520

2621
export default App;
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import React from 'react';
2-
import ReactDOM from 'react-dom';
3-
import './index.css';
4-
import App from './App';
5-
// import * as serviceWorker from './serviceWorker';
1+
import React from "react";
2+
import ReactDOM from "react-dom";
3+
import "./index.css";
4+
import App from "./App";
5+
import * as serviceWorker from "./serviceWorker";
66

7-
ReactDOM.render(<App />, document.getElementById('root'));
7+
ReactDOM.render(<App />, document.getElementById("root"));
88

99
// If you want your app to work offline and load faster, you can change
1010
// unregister() to register() below. Note this comes with some pitfalls.
1111
// Learn more about service workers: https://bit.ly/CRA-PWA
12-
// serviceWorker.unregister();
12+
serviceWorker.unregister();

packages/cra-template-wptheme-typescript/template/src/serviceWorker.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,12 @@ function checkValidServiceWorker(swUrl: string, config?: Config) {
138138

139139
export function unregister() {
140140
if ('serviceWorker' in navigator) {
141-
navigator.serviceWorker.ready.then(registration => {
142-
registration.unregister();
143-
});
141+
navigator.serviceWorker.ready
142+
.then(registration => {
143+
registration.unregister();
144+
})
145+
.catch(error => {
146+
console.error(error.message);
147+
});
144148
}
145149
}

packages/cra-template-wptheme/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cra-template-wptheme",
3-
"version": "3.3.1-wp.1",
3+
"version": "3.4.0-wp.2",
44
"keywords": [
55
"wordpress",
66
"create-react-app",

packages/cra-template-wptheme/template/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ See the section about [deployment](https://facebook.github.io/create-react-app/d
3333

3434
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
3535

36-
Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
36+
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
3737

3838
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
3939

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,21 @@
1-
import React from 'react';
2-
import logo from './logo.svg';
3-
import './App.css';
1+
import React from "react";
2+
import logo from "./logo.svg";
3+
import "./App.css";
44

55
function App() {
6-
return (
7-
<div className="App">
8-
<header className="App-header">
9-
<img src={logo} className="App-logo" alt="logo" />
10-
<p>
11-
Edit <code>react-src/src/App.js</code> and save to reload.
12-
</p>
13-
<a
14-
className="App-link"
15-
href="https://reactjs.org"
16-
target="_blank"
17-
rel="noopener noreferrer"
18-
>
19-
Learn React
20-
</a>
21-
</header>
22-
</div>
23-
);
6+
return (
7+
<div className="App">
8+
<header className="App-header">
9+
<img src={logo} className="App-logo" alt="logo" />
10+
<p>
11+
Edit <code>react-src/src/App.js</code> and save to reload.
12+
</p>
13+
<a className="App-link" href="https://reactjs.org" target="_blank" rel="noopener noreferrer">
14+
Learn React
15+
</a>
16+
</header>
17+
</div>
18+
);
2419
}
2520

2621
export default App;
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import React from 'react';
2-
import ReactDOM from 'react-dom';
3-
import './index.css';
4-
import App from './App';
5-
// import * as serviceWorker from './serviceWorker';
1+
import React from "react";
2+
import ReactDOM from "react-dom";
3+
import "./index.css";
4+
import App from "./App";
5+
import * as serviceWorker from "./serviceWorker";
66

7-
ReactDOM.render(<App />, document.getElementById('root'));
7+
ReactDOM.render(<App />, document.getElementById("root"));
88

99
// If you want your app to work offline and load faster, you can change
1010
// unregister() to register() below. Note this comes with some pitfalls.
1111
// Learn more about service workers: https://bit.ly/CRA-PWA
12-
// serviceWorker.unregister();
12+
serviceWorker.unregister();

packages/cra-template-wptheme/template/src/serviceWorker.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,12 @@ function checkValidServiceWorker(swUrl, config) {
130130

131131
export function unregister() {
132132
if ('serviceWorker' in navigator) {
133-
navigator.serviceWorker.ready.then(registration => {
134-
registration.unregister();
135-
});
133+
navigator.serviceWorker.ready
134+
.then(registration => {
135+
registration.unregister();
136+
})
137+
.catch(error => {
138+
console.error(error.message);
139+
});
136140
}
137141
}

packages/create-react-wptheme-utils/create-react-wptheme-error-overlay/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devloco/create-react-wptheme-error-overlay",
3-
"version": "3.3.1-wp.1",
3+
"version": "3.4.0-wp.1",
44
"description": "create-react-wptheme client with error overlay",
55
"main": "wptheme-error-overlay.js",
66
"scripts": {
@@ -17,15 +17,15 @@
1717
"wpThemeErrorOverlay.js"
1818
],
1919
"dependencies": {
20-
"react-dev-utils": "^10.1.0",
21-
"react-error-overlay": "^6.0.5"
20+
"react-dev-utils": "^10.2.0",
21+
"react-error-overlay": "^6.0.6"
2222
},
2323
"devDependencies": {
2424
"@babel/code-frame": "^7.8.3",
2525
"@babel/core": "^7.8.4",
2626
"@webpack-cli/info": "^0.2.0",
2727
"babel-loader": "^8.0.6",
28-
"webpack": "^4.41.5",
29-
"webpack-cli": "^3.3.10"
28+
"webpack": "^4.41.6",
29+
"webpack-cli": "^3.3.11"
3030
}
3131
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/**
2+
* Copyright (c) 2015-present, Facebook, Inc.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
"use strict";
9+
10+
const { URL } = require("url");
11+
12+
module.exports = getPublicUrlOrPath;
13+
14+
/**
15+
* Returns a URL or a path with slash at the end
16+
* In production can be URL, abolute path, relative path
17+
* In development always will be an absolute path
18+
* In development can use `path` module functions for operations
19+
*
20+
* @param {boolean} craIsEnvDevelopment; unused
21+
* @param {(string|undefined)} homepage a valid url or pathname
22+
* @param {(string|undefined)} envPublicUrl a valid url or pathname
23+
* @returns {string}
24+
*/
25+
function getPublicUrlOrPath(craIsEnvDevelopment, homepage, envPublicUrl) {
26+
const isEnvDevelopment = false; // create-react-wptheme always uses PROD paths.
27+
const stubDomain = "https://create-react-wptheme.dev";
28+
29+
if (envPublicUrl) {
30+
// ensure last slash exists
31+
envPublicUrl = envPublicUrl.endsWith("/") ? envPublicUrl : envPublicUrl + "/";
32+
33+
// validate if `envPublicUrl` is a URL or path like
34+
// `stubDomain` is ignored if `envPublicUrl` contains a domain
35+
const validPublicUrl = new URL(envPublicUrl, stubDomain);
36+
37+
return isEnvDevelopment
38+
? envPublicUrl.startsWith(".")
39+
? "/"
40+
: validPublicUrl.pathname
41+
: // Some apps do not use client-side routing with pushState.
42+
// For these, "homepage" can be set to "." to enable relative asset paths.
43+
envPublicUrl;
44+
}
45+
46+
if (homepage) {
47+
// strip last slash if exists
48+
homepage = homepage.endsWith("/") ? homepage : homepage + "/";
49+
50+
// validate if `homepage` is a URL or path like and use just pathname
51+
const validHomepagePathname = new URL(homepage, stubDomain).pathname;
52+
return isEnvDevelopment
53+
? homepage.startsWith(".")
54+
? "/"
55+
: validHomepagePathname
56+
: // Some apps do not use client-side routing with pushState.
57+
// For these, "homepage" can be set to "." to enable relative asset paths.
58+
homepage.startsWith(".")
59+
? homepage
60+
: validHomepagePathname;
61+
}
62+
63+
return "/";
64+
}

packages/create-react-wptheme-utils/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devloco/create-react-wptheme-utils",
3-
"version": "3.3.1-wp.1",
3+
"version": "3.4.0-wp.1",
44
"description": "Utilities used by create-react-wptheme.",
55
"engines": {
66
"node": ">=8"
@@ -20,6 +20,7 @@
2020
"files": [
2121
"fileFunctions.js",
2222
"fileWatcherPlugin.js",
23+
"getPublicUrlOrPath.js",
2324
"getUserConfig.js",
2425
"postInstallerInfo.js",
2526
"shell-js.js",
@@ -28,7 +29,7 @@
2829
"wpThemeServer.js"
2930
],
3031
"dependencies": {
31-
"chalk": "^3.0.0",
32+
"chalk": "2.4.2",
3233
"chokidar": "^3.3.1",
3334
"shelljs": "^0.8.3",
3435
"fs-extra": "^8.1.0",

0 commit comments

Comments
 (0)