@ideasonpurpose/build-tools-wordpress 1.1.2 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +58 -0
- package/README.md +6 -25
- package/bin/port-reporter.js +32 -14
- package/index.js +19 -15
- package/lib/AfterDoneReporterPlugin.js +5 -4
- package/lib/DependencyManifestPlugin.js +2 -2
- package/lib/WatchRunReporterPlugin.js +1 -3
- package/lib/buildConfig.js +30 -21
- package/lib/devserver-proxy.js +6 -6
- package/lib/find-local-docker-port.js +19 -0
- package/package.json +24 -9
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
### Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file. Dates are displayed in UTC.
|
|
4
|
+
|
|
5
|
+
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
6
|
+
|
|
7
|
+
#### v1.1.3
|
|
8
|
+
|
|
9
|
+
> 24 January 2024
|
|
10
|
+
|
|
11
|
+
- reconfigure imports, port-reporter to module, lots of deps
|
|
12
|
+
- add changelog, update readme (badges)
|
|
13
|
+
- fix path to port-reporter script
|
|
14
|
+
|
|
15
|
+
#### v1.1.2
|
|
16
|
+
|
|
17
|
+
> 23 January 2024
|
|
18
|
+
|
|
19
|
+
#### v1.1.1
|
|
20
|
+
|
|
21
|
+
> 23 January 2024
|
|
22
|
+
|
|
23
|
+
- versioning, github actions, bump deps, README
|
|
24
|
+
- update version in readme
|
|
25
|
+
|
|
26
|
+
#### v1.1.0
|
|
27
|
+
|
|
28
|
+
> 23 January 2024
|
|
29
|
+
|
|
30
|
+
- add packages
|
|
31
|
+
- name change, prepare for npm publish
|
|
32
|
+
- add port-reporter script, giving up on linking local pacakges
|
|
33
|
+
|
|
34
|
+
#### v1.0.4
|
|
35
|
+
|
|
36
|
+
> 16 January 2024
|
|
37
|
+
|
|
38
|
+
- embed default.config
|
|
39
|
+
|
|
40
|
+
#### v1.0.3
|
|
41
|
+
|
|
42
|
+
> 16 January 2024
|
|
43
|
+
|
|
44
|
+
- buildConfig
|
|
45
|
+
|
|
46
|
+
#### v1.0.2
|
|
47
|
+
|
|
48
|
+
> 16 January 2024
|
|
49
|
+
|
|
50
|
+
- add sass-embedded
|
|
51
|
+
|
|
52
|
+
#### v1.0.1
|
|
53
|
+
|
|
54
|
+
> 16 January 2024
|
|
55
|
+
|
|
56
|
+
- add modules
|
|
57
|
+
- add lib, temp exports
|
|
58
|
+
- Initial commit
|
package/README.md
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
# @ideasonpurpose/build-tools-wordpress
|
|
2
2
|
|
|
3
|
-
#### Version 1.1.
|
|
3
|
+
#### Version 1.1.4
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+

|
|
7
|
+
|
|
4
8
|
|
|
5
9
|
Build scripts and dependencies for IOP's WordPress development environments.
|
|
6
10
|
|
|
@@ -8,8 +12,6 @@ Build scripts and dependencies for IOP's WordPress development environments.
|
|
|
8
12
|
|
|
9
13
|
These tools were migrated from our [Docker-based WordPress build tools](https://github.com/ideasonpurpose/docker-build) to speed up development and began the process of moving our build tools away from webpack. Gathering dependencies also simplifies the package.json files in host projects, making those slightly more manageable.
|
|
10
14
|
|
|
11
|
-
This may end up being the container for all tools required for building a project. That would allow us to clean out most of the cruft from our project directories and only have a single dependency which packages everything we need.
|
|
12
|
-
|
|
13
15
|
The included webpack.config.js file works best when paired with a PHP environment like our [Docker WordPress environments](https://github.com/ideasonpurpose/docker-wordpress-dev). It's capable of proxying to other servers, but that's sort of crazy.
|
|
14
16
|
|
|
15
17
|
### Additional Notes
|
|
@@ -18,33 +20,12 @@ This project expects an entirely ES Module based environment and specifies all d
|
|
|
18
20
|
|
|
19
21
|
#### Publishing to [npm](https://www.npmjs.com/package/@ideasonpurpose/build-tools-wordpress)
|
|
20
22
|
|
|
21
|
-
A GitHub action will auto-publish version-tagged releases to npm. In order to publish, the repository must have an `NPM_TOKEN` secret set with the token from npm. Log into npmjs.org with a publish-authorized account, then find the token linked from the Profile page sidebar.
|
|
23
|
+
A GitHub action will auto-publish version-tagged releases to npm. In order to publish, the repository must have an `NPM_TOKEN` secret set with the token from npm. [Log into npmjs.org](https://www.npmjs.com/login) with a publish-authorized account, then find the token page linked from the Profile page sidebar. Generate a new token and update the repository secret.
|
|
22
24
|
|
|
23
25
|
##
|
|
24
26
|
|
|
25
|
-
#### Brought to you by IOP
|
|
26
|
-
|
|
27
|
-
<a href="https://www.ideasonpurpose.com"><img src="https://raw.githubusercontent.com/ideasonpurpose/ideasonpurpose/master/iop-logo-mint-on-black-88px.png" height="44" align="top" alt="IOP Logo"></a><img src="https://raw.githubusercontent.com/ideasonpurpose/ideasonpurpose/master/spacer.png" align="middle" width="4" height="54"> This project is actively developed and used in production at <a href="https://www.ideasonpurpose.com">Ideas On Purpose</a>.
|
|
28
27
|
|
|
29
28
|
#### Brought to you by IOP
|
|
30
29
|
|
|
31
30
|
<a href="https://www.ideasonpurpose.com"><img src="https://raw.githubusercontent.com/ideasonpurpose/ideasonpurpose/master/iop-logo-white-on-black-88px.png" height="44" align="top" alt="IOP Logo"></a><img src="https://raw.githubusercontent.com/ideasonpurpose/ideasonpurpose/master/spacer.png" align="middle" width="4" height="54"> This project is actively developed and used in production at <a href="https://www.ideasonpurpose.com">Ideas On Purpose</a>.
|
|
32
31
|
|
|
33
|
-
#### Brought to you by IOP
|
|
34
|
-
|
|
35
|
-
<a href="https://www.ideasonpurpose.com"><img src="https://raw.githubusercontent.com/ideasonpurpose/ideasonpurpose/master/iop-logo-clay-on-black-88px.png" height="44" align="top" alt="IOP Logo"></a><img src="https://raw.githubusercontent.com/ideasonpurpose/ideasonpurpose/master/spacer.png" align="middle" width="4" height="54"> This project is actively developed and used in production at <a href="https://www.ideasonpurpose.com">Ideas On Purpose</a>.
|
|
36
|
-
|
|
37
|
-
#### Brought to you by IOP
|
|
38
|
-
|
|
39
|
-
<a href="https://www.ideasonpurpose.com"><img src="https://raw.githubusercontent.com/ideasonpurpose/ideasonpurpose/master/iop-logo-white-on-mint-88px.png" height="44" align="top" alt="IOP Logo"></a><img src="https://raw.githubusercontent.com/ideasonpurpose/ideasonpurpose/master/spacer.png" align="middle" width="4" height="54"> This project is actively developed and used in production at <a href="https://www.ideasonpurpose.com">Ideas On Purpose</a>.
|
|
40
|
-
|
|
41
|
-
#### Brought to you by IOP
|
|
42
|
-
|
|
43
|
-
<a href="https://www.ideasonpurpose.com"><img src="https://raw.githubusercontent.com/ideasonpurpose/ideasonpurpose/master/iop-logo-black-on-mint-88px.png" height="44" align="top" alt="IOP Logo"></a><img src="https://raw.githubusercontent.com/ideasonpurpose/ideasonpurpose/master/spacer.png" align="middle" width="4" height="54"> This project is actively developed and used in production at <a href="https://www.ideasonpurpose.com">Ideas On Purpose</a>.
|
|
44
|
-
|
|
45
|
-
#### Brought to you by IOP
|
|
46
|
-
|
|
47
|
-
<a href="https://www.ideasonpurpose.com"><img src="https://raw.githubusercontent.com/ideasonpurpose/ideasonpurpose/master/iop-logo-white-on-darkmint-88px.png" height="44" align="top" alt="IOP Logo"></a><img src="https://raw.githubusercontent.com/ideasonpurpose/ideasonpurpose/master/spacer.png" align="middle" width="4" height="54"> This project is actively developed and used in production at <a href="https://www.ideasonpurpose.com">Ideas On Purpose</a>.
|
|
48
|
-
|
|
49
|
-
> _logo test..._
|
|
50
|
-
> 😂
|
package/bin/port-reporter.js
CHANGED
|
@@ -1,22 +1,40 @@
|
|
|
1
1
|
#! /usr/bin/env node
|
|
2
|
-
import { exec } from "node:child_process";
|
|
3
2
|
|
|
4
3
|
import chalk from "chalk";
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
import { findLocalPort } from "../index.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* This is a reporting/display wrapper for the local port discovery module
|
|
9
|
+
*/
|
|
10
|
+
const main = async () => {
|
|
11
|
+
const info = await findLocalPort().catch((error) => ({ error }));
|
|
13
12
|
|
|
14
|
-
|
|
13
|
+
if (info && info.port && info.hostname) {
|
|
14
|
+
console.log(
|
|
15
|
+
"\n",
|
|
15
16
|
" 🚀 ",
|
|
16
|
-
|
|
17
|
-
chalk.magenta(`http
|
|
17
|
+
chalk.bold("Local WP site:"),
|
|
18
|
+
chalk.magenta(`http://${info.hostname}:${chalk.bold(info.port)}`),
|
|
19
|
+
"\n",
|
|
18
20
|
);
|
|
21
|
+
} else {
|
|
22
|
+
let errString, showDebug;
|
|
23
|
+
|
|
24
|
+
if (info.error) {
|
|
25
|
+
errString = info.error.toString();
|
|
26
|
+
} else {
|
|
27
|
+
errString = "Unknown error occurred. Unable to discover local port";
|
|
28
|
+
showDebug = true;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
errString = errString.split("\n").join("\n ");
|
|
32
|
+
|
|
33
|
+
console.log("\n", " 🤖 ", chalk.red.bold(errString));
|
|
34
|
+
if (showDebug) {
|
|
35
|
+
console.log(chalk.green(" 🐛 Debug:"), info);
|
|
36
|
+
}
|
|
19
37
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
main();
|
package/index.js
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
export { AfterDoneReporterPlugin } from "./lib/AfterDoneReporterPlugin.js";
|
|
2
|
+
export { buildConfig } from "./lib/buildConfig.js";
|
|
3
|
+
export { DependencyManifestPlugin } from "./lib/DependencyManifestPlugin.js";
|
|
4
|
+
// export * from "./lib/DependencyManifestPlugin.js";
|
|
5
|
+
export { devserverProxy } from "./lib/devserver-proxy.js";
|
|
6
|
+
export { WatchRunReporterPlugin } from "./lib/WatchRunReporterPlugin.js";
|
|
7
|
+
export { findLocalPort } from "./lib/find-local-docker-port.js";
|
|
8
|
+
// export * from "./lib/find-local-docker-port.js";
|
|
9
|
+
// import findLocalPort from "./lib/find-local-docker-port.js";
|
|
6
10
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
//
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
// export default {
|
|
12
|
+
// // AfterDoneReporterPlugin,
|
|
13
|
+
// // buildConfig,
|
|
14
|
+
// // DependencyManifestPlugin,
|
|
15
|
+
// // devserverProxy,
|
|
16
|
+
// // WatchRunReporterPlugin,
|
|
17
|
+
// // findLocalPort,
|
|
18
|
+
// // // moo: () => console.log("COW SAYS"),
|
|
19
|
+
// };
|
|
20
|
+
// export const moo = () => console.log("COW SAYS");
|
|
@@ -8,7 +8,7 @@ import humanizeDuration from "humanize-duration";
|
|
|
8
8
|
*
|
|
9
9
|
* new AfterDoneReporterPlugin({message: "Your Message Here"})
|
|
10
10
|
*/
|
|
11
|
-
export
|
|
11
|
+
export class AfterDoneReporterPlugin {
|
|
12
12
|
constructor(options = {}) {
|
|
13
13
|
const defaults = {
|
|
14
14
|
echo: true,
|
|
@@ -23,12 +23,13 @@ export default class AfterDoneReporterPlugin {
|
|
|
23
23
|
apply(compiler) {
|
|
24
24
|
compiler.hooks.done.tapPromise(this.name, async (stats) => {
|
|
25
25
|
if (this.config.echo) {
|
|
26
|
+
// console.log(compiler.options, stats);
|
|
26
27
|
const { host, port } = compiler.options.devServer;
|
|
27
28
|
const { startTime, endTime, modules, assetsInfo } = stats.compilation;
|
|
28
29
|
const hostname = host === "0.0.0.0" ? "localhost" : host;
|
|
29
30
|
|
|
30
31
|
const time = chalk.yellow.bold(
|
|
31
|
-
humanizeDuration(endTime - startTime, { units: ["h", "m", "s"] })
|
|
32
|
+
humanizeDuration(endTime - startTime, { units: ["h", "m", "s"] }),
|
|
32
33
|
);
|
|
33
34
|
const mCount = chalk.yellow(modules.size);
|
|
34
35
|
const aCount = chalk.yellow.bold(assetsInfo.size);
|
|
@@ -39,10 +40,10 @@ export default class AfterDoneReporterPlugin {
|
|
|
39
40
|
this.config.message,
|
|
40
41
|
]
|
|
41
42
|
.filter((m) => m.length)
|
|
42
|
-
.join("\n" + this.config.prefix);
|
|
43
|
+
.join("\n" + this.config.prefix + " ");
|
|
43
44
|
|
|
44
45
|
setTimeout(() =>
|
|
45
|
-
console.log("\n" + this.config.prefix + " " + messages)
|
|
46
|
+
console.log("\n" + this.config.prefix + " " + messages),
|
|
46
47
|
);
|
|
47
48
|
}
|
|
48
49
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from "fs-extra";
|
|
2
2
|
import path from "path";
|
|
3
3
|
|
|
4
|
-
class DependencyManifestPlugin {
|
|
4
|
+
export class DependencyManifestPlugin {
|
|
5
5
|
constructor(options) {
|
|
6
6
|
const defaults = {
|
|
7
7
|
writeManifestFile: false,
|
|
@@ -74,4 +74,4 @@ class DependencyManifestPlugin {
|
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
export default DependencyManifestPlugin;
|
|
77
|
+
// export default DependencyManifestPlugin;
|
|
@@ -7,7 +7,7 @@ import chalk from "chalk";
|
|
|
7
7
|
*
|
|
8
8
|
* new WatchRunReporterPlugin({message: "Your Message Here"})
|
|
9
9
|
*/
|
|
10
|
-
class WatchRunReporterPlugin {
|
|
10
|
+
export class WatchRunReporterPlugin {
|
|
11
11
|
constructor(options = {}) {
|
|
12
12
|
const defaults = {
|
|
13
13
|
echo: true,
|
|
@@ -50,5 +50,3 @@ class WatchRunReporterPlugin {
|
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
-
|
|
54
|
-
export default WatchRunReporterPlugin;
|
package/lib/buildConfig.js
CHANGED
|
@@ -2,6 +2,8 @@ import fs from "fs-extra";
|
|
|
2
2
|
import { posix as path } from "path";
|
|
3
3
|
import chalk from "chalk";
|
|
4
4
|
|
|
5
|
+
import { findLocalPort } from "../index.js";
|
|
6
|
+
|
|
5
7
|
// import defaultConfig from "../default.config.js";
|
|
6
8
|
|
|
7
9
|
const defaultConfig = {
|
|
@@ -12,15 +14,11 @@ const defaultConfig = {
|
|
|
12
14
|
contentBase: "/dist/", // TODO: Should this be false?
|
|
13
15
|
manifestFile: "./dependency-manifest.json",
|
|
14
16
|
sass: "sass-embedded",
|
|
15
|
-
port: 8080,
|
|
17
|
+
// port: 8080,
|
|
16
18
|
transpileDependencies: ["ansi-regex", "normalize-url"],
|
|
17
|
-
proxy:
|
|
19
|
+
proxy: "wordpress",
|
|
18
20
|
};
|
|
19
21
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
22
|
/**
|
|
25
23
|
* This file encapsulates all the config file massaging and allows
|
|
26
24
|
* for asynchronous values.
|
|
@@ -29,7 +27,7 @@ const defaultConfig = {
|
|
|
29
27
|
* -
|
|
30
28
|
*/
|
|
31
29
|
|
|
32
|
-
export
|
|
30
|
+
export async function buildConfig(configFile = { config: {} }) {
|
|
33
31
|
/**
|
|
34
32
|
* This is a temporary workaround for a problem with using `process.env.NAME` in
|
|
35
33
|
* base ideasonpurpose.config.js files. `NAME` is often set in the environment
|
|
@@ -42,7 +40,7 @@ export default (configFile = { config: {} }) => {
|
|
|
42
40
|
if (configFile.filepath) {
|
|
43
41
|
const rawConfigFile = fs.readFileSync(configFile.filepath);
|
|
44
42
|
const packageJson = fs.readJsonSync(
|
|
45
|
-
path.resolve(configFile.filepath, "../package.json")
|
|
43
|
+
path.resolve(configFile.filepath, "../package.json"),
|
|
46
44
|
);
|
|
47
45
|
// console.log({ p: process.env.NAME });
|
|
48
46
|
if (
|
|
@@ -154,11 +152,11 @@ export default (configFile = { config: {} }) => {
|
|
|
154
152
|
console.log(
|
|
155
153
|
"⚠️ ",
|
|
156
154
|
chalk.bold.yellow("NOTICE"),
|
|
157
|
-
chalk.yellow("NOTICE node-sass is no longer supported. The js-compiled")
|
|
155
|
+
chalk.yellow("NOTICE node-sass is no longer supported. The js-compiled"),
|
|
158
156
|
);
|
|
159
157
|
console.log(chalk.yellow(" dart-sass package will be used instead."));
|
|
160
158
|
console.log(
|
|
161
|
-
chalk.cyan(" https://sass-lang.com/blog/libsass-is-deprecated/")
|
|
159
|
+
chalk.cyan(" https://sass-lang.com/blog/libsass-is-deprecated/"),
|
|
162
160
|
);
|
|
163
161
|
console.log(chalk.cyan(" https://www.npmjs.com/package/sass"));
|
|
164
162
|
}
|
|
@@ -169,9 +167,20 @@ export default (configFile = { config: {} }) => {
|
|
|
169
167
|
if (config.proxy === true) {
|
|
170
168
|
config.proxy = defaultConfig.proxy;
|
|
171
169
|
}
|
|
170
|
+
const localPort = await findLocalPort();
|
|
171
|
+
|
|
172
|
+
config.proxy = `http://${localPort.hostname}:${localPort.port}`;
|
|
173
|
+
console.log(
|
|
174
|
+
chalk.cyan.bold(
|
|
175
|
+
`FOUND THE PORT IN BUILDCONFIG ${localPort.port}`,
|
|
176
|
+
config.proxy,
|
|
177
|
+
),
|
|
178
|
+
);
|
|
179
|
+
|
|
180
|
+
/// TODO: Move the port-finding stuff in here?
|
|
172
181
|
|
|
173
182
|
return config;
|
|
174
|
-
}
|
|
183
|
+
}
|
|
175
184
|
|
|
176
185
|
/**
|
|
177
186
|
* Warnings are broken out below
|
|
@@ -180,8 +189,8 @@ const noSrcExists = (src) => {
|
|
|
180
189
|
console.log(
|
|
181
190
|
"🛑 ",
|
|
182
191
|
chalk.bold.red(
|
|
183
|
-
`ERROR: The src directory ${chalk.white(src)} does not exist
|
|
184
|
-
)
|
|
192
|
+
`ERROR: The src directory ${chalk.white(src)} does not exist.`,
|
|
193
|
+
),
|
|
185
194
|
);
|
|
186
195
|
};
|
|
187
196
|
|
|
@@ -189,23 +198,23 @@ const nameEnvVarWarning = () => {
|
|
|
189
198
|
console.log(
|
|
190
199
|
"⚠️ ",
|
|
191
200
|
chalk.yellow.bold(
|
|
192
|
-
"WARNING: $NAME is set in the environment and the project's config file."
|
|
193
|
-
)
|
|
201
|
+
"WARNING: $NAME is set in the environment and the project's config file.",
|
|
202
|
+
),
|
|
194
203
|
);
|
|
195
204
|
console.log(
|
|
196
205
|
chalk.yellow(
|
|
197
|
-
" The value of $NAME will likely conflict with the name property from"
|
|
198
|
-
)
|
|
206
|
+
" The value of $NAME will likely conflict with the name property from",
|
|
207
|
+
),
|
|
199
208
|
);
|
|
200
209
|
console.log(
|
|
201
210
|
chalk.yellow(
|
|
202
|
-
" package.json. Please update the project's config.js file. To silence "
|
|
203
|
-
)
|
|
211
|
+
" package.json. Please update the project's config.js file. To silence ",
|
|
212
|
+
),
|
|
204
213
|
);
|
|
205
214
|
console.log(
|
|
206
215
|
chalk.yellow(
|
|
207
|
-
" this message, set $NAME in the environment to match the project's"
|
|
208
|
-
)
|
|
216
|
+
" this message, set $NAME in the environment to match the project's",
|
|
217
|
+
),
|
|
209
218
|
);
|
|
210
219
|
console.log(chalk.yellow(" package.json `name` property."));
|
|
211
220
|
};
|
package/lib/devserver-proxy.js
CHANGED
|
@@ -10,10 +10,10 @@ import { isIP } from "net";
|
|
|
10
10
|
* If config.proxy is explicitly not false, return a {proxy} object
|
|
11
11
|
* otherwise return an empty object.
|
|
12
12
|
*/
|
|
13
|
-
export
|
|
13
|
+
export async function devserverProxy(config) {
|
|
14
14
|
let target;
|
|
15
15
|
|
|
16
|
-
console.log({config});
|
|
16
|
+
// console.log({config});
|
|
17
17
|
|
|
18
18
|
// if (
|
|
19
19
|
// config.proxy ===
|
|
@@ -130,7 +130,7 @@ export default async (config) => {
|
|
|
130
130
|
if (typeof header == "string") {
|
|
131
131
|
header = header.replace(
|
|
132
132
|
new RegExp(config.proxyUrl.host, "gi"),
|
|
133
|
-
req.headers.host
|
|
133
|
+
req.headers.host,
|
|
134
134
|
);
|
|
135
135
|
}
|
|
136
136
|
res.setHeader(String(key).trim(), header);
|
|
@@ -140,11 +140,11 @@ export default async (config) => {
|
|
|
140
140
|
let newBody;
|
|
141
141
|
const type = (proxyRes.headers["content-type"] || "").split(";")[0];
|
|
142
142
|
const wpRegexp = new RegExp(
|
|
143
|
-
"^/wp-(?:admin|includes|content/plugins).*(?:css|js|map)$"
|
|
143
|
+
"^/wp-(?:admin|includes|content/plugins).*(?:css|js|map)$",
|
|
144
144
|
);
|
|
145
145
|
const originRegExp = new RegExp(
|
|
146
146
|
`(http:\\\\/\\\\/|http://)${config.proxyUrl.host}`,
|
|
147
|
-
"gi"
|
|
147
|
+
"gi",
|
|
148
148
|
);
|
|
149
149
|
|
|
150
150
|
if (contentTypes.includes(type) && !wpRegexp.test(req.path)) {
|
|
@@ -163,4 +163,4 @@ export default async (config) => {
|
|
|
163
163
|
};
|
|
164
164
|
|
|
165
165
|
return { proxy };
|
|
166
|
-
}
|
|
166
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { exec } from "node:child_process";
|
|
2
|
+
|
|
3
|
+
export function findLocalPort() {
|
|
4
|
+
// export default () => {
|
|
5
|
+
return new Promise((resolve, reject) => {
|
|
6
|
+
exec("docker compose port wordpress 80", (error, stdout, stderr) => {
|
|
7
|
+
if (error) {
|
|
8
|
+
reject(error);
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
if (stdout) {
|
|
13
|
+
const [addr, port] = stdout.trim().split(":");
|
|
14
|
+
const hostname = addr === "0.0.0.0" ? "localhost" : addr;
|
|
15
|
+
resolve({ hostname, port, stdout: stdout.trim() });
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ideasonpurpose/build-tools-wordpress",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4",
|
|
4
4
|
"description": "Build scripts and dependencies for IOP's WordPress development environments.",
|
|
5
5
|
"homepage": "https://github.com/ideasonpurpose/build-tools-wordpress#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -19,12 +19,18 @@
|
|
|
19
19
|
"type": "module",
|
|
20
20
|
"main": "index.js",
|
|
21
21
|
"bin": {
|
|
22
|
-
"iop-build-port-reporter": "port-reporter.js"
|
|
22
|
+
"iop-build-port-reporter": "./bin/port-reporter.js"
|
|
23
|
+
},
|
|
24
|
+
"directories": {
|
|
25
|
+
"lib": "lib"
|
|
23
26
|
},
|
|
24
27
|
"scripts": {
|
|
25
28
|
"version": "version-everything && auto-changelog && git add -u"
|
|
26
29
|
},
|
|
30
|
+
"prettier": "@ideasonpurpose/prettier-config",
|
|
27
31
|
"dependencies": {
|
|
32
|
+
"@ideasonpurpose/prettier-config": "^0.0.4",
|
|
33
|
+
"@prettier/plugin-php": "^0.22.1",
|
|
28
34
|
"@rollup/plugin-commonjs": "^25.0.7",
|
|
29
35
|
"@rollup/plugin-json": "^6.1.0",
|
|
30
36
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
@@ -38,14 +44,19 @@
|
|
|
38
44
|
"body-parser": "^1.20.2",
|
|
39
45
|
"caniuse-lite": "^1.0.30001579",
|
|
40
46
|
"chalk": "^5.3.0",
|
|
47
|
+
"chalk-cli": "^5.0.1",
|
|
48
|
+
"classnames": "^2.5.1",
|
|
41
49
|
"cli-truncate": "^4.0.0",
|
|
42
50
|
"copy-webpack-plugin": "^12.0.2",
|
|
43
51
|
"cosmiconfig": "^9.0.0",
|
|
52
|
+
"cross-env": "^7.0.3",
|
|
44
53
|
"css-loader": "^6.9.1",
|
|
45
54
|
"cssnano": "^6.0.1",
|
|
46
55
|
"del": "^7.1.0",
|
|
47
|
-
"dotenv": "^16.
|
|
56
|
+
"dotenv": "^16.4.0",
|
|
48
57
|
"esbuild-loader": "^4.0.3",
|
|
58
|
+
"eslint": "^8.56.0",
|
|
59
|
+
"eslint-plugin-react": "^7.33.2",
|
|
49
60
|
"filesize": "^10.0.12",
|
|
50
61
|
"fs-extra": "^11.1.1",
|
|
51
62
|
"globby": "^14.0.0",
|
|
@@ -58,19 +69,27 @@
|
|
|
58
69
|
"node-sass": "^9.0.0",
|
|
59
70
|
"postcss": "^8.4.29",
|
|
60
71
|
"postcss-loader": "^8.0.0",
|
|
72
|
+
"postcss-scss": "^4.0.9",
|
|
73
|
+
"prettier": "^3.2.4",
|
|
74
|
+
"prettier-eslint": "^16.3.0",
|
|
61
75
|
"pretty-hrtime": "^1.0.3",
|
|
62
76
|
"replacestream": "^4.0.3",
|
|
63
77
|
"sass": "^1.70.0",
|
|
64
78
|
"sass-embedded": "^1.70.0",
|
|
65
79
|
"sass-loader": "^14.0.0",
|
|
80
|
+
"semver": "^7.5.4",
|
|
66
81
|
"sharp": "^0.33.2",
|
|
82
|
+
"sort-package-json": "^2.6.0",
|
|
67
83
|
"source-map-explorer": "^2.5.3",
|
|
68
84
|
"string-length": "^6.0.0",
|
|
69
85
|
"style-loader": "^3.3.3",
|
|
86
|
+
"stylelint": "^16.2.0",
|
|
87
|
+
"stylelint-order": "^6.0.4",
|
|
88
|
+
"stylelint-prettier": "^5.0.0",
|
|
70
89
|
"svgo": "^3.0.2",
|
|
71
90
|
"svgo-loader": "^4.0.0",
|
|
72
91
|
"version-everything": "^0.11.0",
|
|
73
|
-
"webpack": "^5.
|
|
92
|
+
"webpack": "^5.90.0",
|
|
74
93
|
"webpack-bundle-analyzer": "^4.9.1",
|
|
75
94
|
"webpack-cli": "^5.1.4",
|
|
76
95
|
"webpack-dev-middleware": "^7.0.0",
|
|
@@ -80,9 +99,5 @@
|
|
|
80
99
|
"files": [
|
|
81
100
|
"README.md"
|
|
82
101
|
]
|
|
83
|
-
}
|
|
84
|
-
"directories": {
|
|
85
|
-
"lib": "lib"
|
|
86
|
-
},
|
|
87
|
-
"devDependencies": {}
|
|
102
|
+
}
|
|
88
103
|
}
|