Skip to content

3.4.0 issue.45 #46

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

Merged
merged 3 commits into from
Apr 13, 2020
Merged
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
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# Create React WP Theme <!-- omit in toc -->

## Still Up to Date
## Update to 3.4.1 Coming Soon

Mar. 19, 2020
Apr. 12, 2020
<br />
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)!

---

Expand Down
64 changes: 0 additions & 64 deletions packages/create-react-wptheme-utils/getPublicUrlOrPath.js

This file was deleted.

19 changes: 12 additions & 7 deletions packages/create-react-wptheme-utils/getUserConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,43 +26,47 @@ 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,
host: "127.0.0.1",
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);
}
Expand All @@ -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":
Expand Down
3 changes: 1 addition & 2 deletions packages/create-react-wptheme-utils/package.json
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -20,7 +20,6 @@
"files": [
"fileFunctions.js",
"fileWatcherPlugin.js",
"getPublicUrlOrPath.js",
"getUserConfig.js",
"postInstallerInfo.js",
"shell-js.js",
Expand Down
13 changes: 10 additions & 3 deletions packages/create-react-wptheme/README.md
Original file line number Diff line number Diff line change
@@ -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
<br />
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)!

---

Expand Down
30 changes: 14 additions & 16 deletions packages/create-react-wptheme/createReactWpTheme.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}
},
};
};

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion packages/create-react-wptheme/package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down