diff --git a/README.md b/README.md
index c2e7b2e..beb9d58 100644
--- a/README.md
+++ b/README.md
@@ -1,10 +1,13 @@
# Create React WP Theme
-## Still Up to Date
+## Update to 3.4.1 Coming Soon
-Mar. 19, 2020
+Apr. 12, 2020
-It's been a while, so I thought I'd just let everyone know that [v3.4.0](https://github.com/facebook/create-react-app/releases/tag/v3.4.0) of `Create-React-App` is still the latest. I'll keep my eye on it and update this project whenever Facebook releases a new version.
+Facebook released [v3.4.1](https://github.com/facebook/create-react-app/releases/tag/v3.4.1) of `Create-React-App`. I'm preparing an update and should be done soon.
+
+Until then you can continue to create new projects using [v3.4.0](https://github.com/facebook/create-react-app/releases/tag/v3.4.0). When the new release is ready,
+[updating is easy](#updating-existing-themes)!
---
diff --git a/packages/create-react-wptheme-utils/getPublicUrlOrPath.js b/packages/create-react-wptheme-utils/getPublicUrlOrPath.js
deleted file mode 100644
index e6036d9..0000000
--- a/packages/create-react-wptheme-utils/getPublicUrlOrPath.js
+++ /dev/null
@@ -1,64 +0,0 @@
-/**
- * Copyright (c) 2015-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- */
-
-"use strict";
-
-const { URL } = require("url");
-
-module.exports = getPublicUrlOrPath;
-
-/**
- * Returns a URL or a path with slash at the end
- * In production can be URL, abolute path, relative path
- * In development always will be an absolute path
- * In development can use `path` module functions for operations
- *
- * @param {boolean} craIsEnvDevelopment; unused
- * @param {(string|undefined)} homepage a valid url or pathname
- * @param {(string|undefined)} envPublicUrl a valid url or pathname
- * @returns {string}
- */
-function getPublicUrlOrPath(craIsEnvDevelopment, homepage, envPublicUrl) {
- const isEnvDevelopment = false; // create-react-wptheme always uses PROD paths.
- const stubDomain = "https://create-react-wptheme.dev";
-
- if (envPublicUrl) {
- // ensure last slash exists
- envPublicUrl = envPublicUrl.endsWith("/") ? envPublicUrl : envPublicUrl + "/";
-
- // validate if `envPublicUrl` is a URL or path like
- // `stubDomain` is ignored if `envPublicUrl` contains a domain
- const validPublicUrl = new URL(envPublicUrl, stubDomain);
-
- return isEnvDevelopment
- ? envPublicUrl.startsWith(".")
- ? "/"
- : validPublicUrl.pathname
- : // Some apps do not use client-side routing with pushState.
- // For these, "homepage" can be set to "." to enable relative asset paths.
- envPublicUrl;
- }
-
- if (homepage) {
- // strip last slash if exists
- homepage = homepage.endsWith("/") ? homepage : homepage + "/";
-
- // validate if `homepage` is a URL or path like and use just pathname
- const validHomepagePathname = new URL(homepage, stubDomain).pathname;
- return isEnvDevelopment
- ? homepage.startsWith(".")
- ? "/"
- : validHomepagePathname
- : // Some apps do not use client-side routing with pushState.
- // For these, "homepage" can be set to "." to enable relative asset paths.
- homepage.startsWith(".")
- ? homepage
- : validHomepagePathname;
- }
-
- return "/";
-}
diff --git a/packages/create-react-wptheme-utils/getUserConfig.js b/packages/create-react-wptheme-utils/getUserConfig.js
index 2d12f27..7913977 100644
--- a/packages/create-react-wptheme-utils/getUserConfig.js
+++ b/packages/create-react-wptheme-utils/getUserConfig.js
@@ -26,21 +26,24 @@ function _getUserConfig(paths, configName, defaultConfig) {
userConfig = require(path.join(paths.appPath, configName));
} catch (err) {
userConfig = JSON.stringify(defaultConfig, null, 4);
- _writeUserConfig(paths, configName, userConfig);
+ // Issue 45; Always write the dev config on error; only write the prod config if it is complete.
+ if (configName === _userDevConfigName || (configName === _userProdConfigName && defaultConfig && typeof defaultConfig.homepage === "string")) {
+ _writeUserConfig(paths, configName, userConfig);
+ }
return defaultConfig;
}
return userConfig;
}
-module.exports = function(paths, nodeEnv) {
+module.exports = function (paths, nodeEnv) {
const appPackageJson = require(paths.appPackageJson);
const defaultUserDevConfig = {
fileWatcherPlugin: {
touchFile: "./public/index.php",
ignored: "./public/index.php",
- watchFileGlobs: ["./public/**/*.js", "./public/**/*.css", "./public/**/*.php"]
+ watchFileGlobs: ["./public/**/*.js", "./public/**/*.css", "./public/**/*.php"],
},
wpThemeServer: {
enable: true,
@@ -48,21 +51,22 @@ module.exports = function(paths, nodeEnv) {
port: 8090,
sslCert: null,
sslKey: null,
- watchFile: "../index.php"
+ watchFile: "../index.php",
},
injectWpThemeClient: {
override: null,
- file: "./build/index.php"
- }
+ file: "./build/index.php",
+ },
};
const defaultUserProdConfig = {
finalBuildPath: null,
- homepage: appPackageJson.homepage
+ homepage: appPackageJson.homepage,
};
// Create both files ASAP.
if (!wpThemePostInstallerInfo.postInstallerExists(paths)) {
+ nodeEnv = "init"; // Issue 45; this should only happen during setup of a new theme...
_getUserConfig(paths, _userDevConfigName, defaultUserDevConfig);
_getUserConfig(paths, _userProdConfigName, defaultUserProdConfig);
}
@@ -78,6 +82,7 @@ module.exports = function(paths, nodeEnv) {
switch (nodeEnv) {
case "dev":
case "development":
+ case "init":
return _getUserConfig(paths, _userDevConfigName, defaultUserDevConfig);
case "build":
case "prod":
diff --git a/packages/create-react-wptheme-utils/package.json b/packages/create-react-wptheme-utils/package.json
index 56cfd90..8fc640d 100644
--- a/packages/create-react-wptheme-utils/package.json
+++ b/packages/create-react-wptheme-utils/package.json
@@ -1,6 +1,6 @@
{
"name": "@devloco/create-react-wptheme-utils",
- "version": "3.4.0-wp.1",
+ "version": "3.4.0-wp.11",
"description": "Utilities used by create-react-wptheme.",
"engines": {
"node": ">=8"
@@ -20,7 +20,6 @@
"files": [
"fileFunctions.js",
"fileWatcherPlugin.js",
- "getPublicUrlOrPath.js",
"getUserConfig.js",
"postInstallerInfo.js",
"shell-js.js",
diff --git a/packages/create-react-wptheme/README.md b/packages/create-react-wptheme/README.md
index 369bedb..8466488 100644
--- a/packages/create-react-wptheme/README.md
+++ b/packages/create-react-wptheme/README.md
@@ -1,10 +1,17 @@
# Create React WP Theme
-## Still Up to Date
+Facebook released v3.4.1 of Create-React-App. I'm preparing an update that should be done soon.
-Mar. 19, 2020
+Until then you can continue to create new projects using v3.4.0. When the new release is ready, updating is easy!
+
+## Update to 3.4.1 Coming Soon
+
+Apr. 12, 2020
-It's been a while, so I thought I'd just let everyone know that [v3.4.0](https://github.com/facebook/create-react-app/releases/tag/v3.4.0) of `Create-React-App` is still the latest. I'll keep my eye on it and update this project whenever Facebook releases a new version.
+Facebook released [v3.4.1](https://github.com/facebook/create-react-app/releases/tag/v3.4.1) of `Create-React-App`. I'm preparing an update and should be done soon.
+
+Until then you can continue to create new projects using [v3.4.0](https://github.com/facebook/create-react-app/releases/tag/v3.4.0). When the new release is ready,
+[updating is easy](https://github.com/devloco/create-react-wptheme/tree/master#updating-existing-themes)!
---
diff --git a/packages/create-react-wptheme/createReactWpTheme.js b/packages/create-react-wptheme/createReactWpTheme.js
index e7a75a1..4f59626 100644
--- a/packages/create-react-wptheme/createReactWpTheme.js
+++ b/packages/create-react-wptheme/createReactWpTheme.js
@@ -43,23 +43,23 @@ const _wpThemeVersion = packageJson.version;
const _createReactAppVersion = _wpThemeVersion.split("-wp.")[0];
// Check these!!!!
-const _reactScriptsWpThemeVersion = "^3.4.0-wp.1";
-const _getScriptsPath = function() {
+const _reactScriptsWpThemeVersion = "^3.4.0-wp.9";
+const _getScriptsPath = function () {
return scriptsFromNpm();
};
-const scriptsFromNpm = function() {
+const scriptsFromNpm = function () {
//console.log("SCRIPTS FROM NPM");
return {
- path: `@devloco/react-scripts-wptheme@${_reactScriptsWpThemeVersion}`
+ path: `@devloco/react-scripts-wptheme@${_reactScriptsWpThemeVersion}`,
};
};
-const scriptsFromGit = function() {
+const scriptsFromGit = function () {
console.log("SCRIPTS FROM GIT");
const deleteFolderRecursive = (path) => {
if (fs.existsSync(path)) {
- fs.readdirSync(path).forEach(function(file) {
+ fs.readdirSync(path).forEach(function (file) {
let curPath = path + "/" + file;
if (fs.statSync(curPath).isDirectory()) {
// recurse
@@ -84,9 +84,9 @@ const scriptsFromGit = function() {
let scriptsPath = "file:" + path.join(tempPath, "create-react-app", "packages", "react-scripts");
return {
path: scriptsPath,
- callback: function() {
+ callback: function () {
deleteFolderRecursive(tempPath);
- }
+ },
};
};
@@ -122,11 +122,11 @@ if (program.info) {
Binaries: ["Node", "npm", "Yarn"],
Browsers: ["Chrome", "Edge", "Internet Explorer", "Firefox", "Safari"],
npmPackages: ["react", "react-dom", "react-scripts"],
- npmGlobalPackages: ["create-react-app"]
+ npmGlobalPackages: ["create-react-app"],
},
{
duplicates: true,
- showNotFound: true
+ showNotFound: true,
}
)
.then(console.log);
@@ -199,7 +199,7 @@ function createWpTheme(root, appName, version, verbose, originalDirectory, templ
.then((packageName) =>
checkIfOnline(useYarn).then((isOnline) => ({
isOnline: isOnline,
- packageName: packageName
+ packageName: packageName,
}))
)
.then((info) => {
@@ -241,14 +241,14 @@ function createReactApp(createWpThemeReactRoot, appName, version, verbose, origi
args.push(scriptsPath.path);
const child = spawn(command, args, { stdio: "inherit" })
- .on("error", function(err) {
+ .on("error", function (err) {
console.log(`createReactWpTheme.js ERROR for command: ${command} ${args.join(" ")}`);
throw err;
})
.on("close", (code) => {
if (code !== 0) {
reject({
- command: `${command} ${args.join(" ")}`
+ command: `${command} ${args.join(" ")}`,
});
return;
@@ -288,9 +288,7 @@ function getProxy() {
} else {
try {
// Trying to read https-proxy from .npmrc
- let httpsProxy = execSync("npm config get https-proxy")
- .toString()
- .trim();
+ let httpsProxy = execSync("npm config get https-proxy").toString().trim();
return httpsProxy !== "null" ? httpsProxy : undefined;
} catch (e) {
return;
diff --git a/packages/create-react-wptheme/package.json b/packages/create-react-wptheme/package.json
index bae196a..e47864e 100644
--- a/packages/create-react-wptheme/package.json
+++ b/packages/create-react-wptheme/package.json
@@ -1,6 +1,6 @@
{
"name": "create-react-wptheme",
- "version": "3.4.0-wp.3",
+ "version": "3.4.0-wp.7",
"description": "Create React-enabled WP themes.",
"main": "index.js",
"scripts": {