wp-blank-scripts 3.1.19 → 4.0.0-alpha.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wp-blank-scripts",
3
- "version": "3.1.19",
3
+ "version": "4.0.0-alpha.1",
4
4
  "description": "Personal Wordpress Scripts",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -10,7 +10,7 @@
10
10
  "test": "echo \"Error: no test specified\" && exit 1"
11
11
  },
12
12
  "engines": {
13
- "node": ">=10"
13
+ "node": ">=18"
14
14
  },
15
15
  "files": [
16
16
  "cli",
@@ -31,63 +31,58 @@
31
31
  "author": "ViVO Digital",
32
32
  "license": "ISC",
33
33
  "dependencies": {
34
- "@pmmmwh/react-refresh-webpack-plugin": "^0.5.10",
35
- "@prettier/plugin-php": "^0.19.6",
36
- "@swc/cli": "^0.1.62",
37
- "@swc/core": "^1.3.67",
38
- "browser-sync": "^2.29.3",
34
+ "@pmmmwh/react-refresh-webpack-plugin": "^0.5.17",
35
+ "@prettier/plugin-php": "^0.19.7",
36
+ "@swc/core": "^1.15.18",
37
+ "browser-sync": "^3.0.4",
39
38
  "chalk": "4.1.2",
40
39
  "copy-webpack-plugin": "^11.0.0",
41
- "core-js": "^3.31.0",
42
- "css-loader": "^6.8.1",
43
- "cssnano": "^6.0.1",
44
- "esbuild-loader": "^3.0.1",
45
- "eslint": "^8.42.0",
40
+ "css-loader": "^6.11.0",
41
+ "cssnano": "^6.1.2",
42
+ "eslint": "^8.57.1",
46
43
  "eslint-config-airbnb": "^19.0.4",
47
- "eslint-config-prettier": "^8.8.0",
48
- "eslint-import-resolver-node": "^0.3.7",
49
- "eslint-plugin-import": "^2.27.5",
50
- "eslint-plugin-jsx-a11y": "^6.7.1",
51
- "eslint-plugin-prettier": "^4.2.1",
52
- "eslint-plugin-react": "^7.32.2",
44
+ "eslint-config-prettier": "^8.10.2",
45
+ "eslint-import-resolver-node": "^0.3.9",
46
+ "eslint-plugin-import": "^2.32.0",
47
+ "eslint-plugin-jsx-a11y": "^6.10.2",
48
+ "eslint-plugin-prettier": "^4.2.5",
49
+ "eslint-plugin-react": "^7.37.5",
50
+ "eslint-plugin-react-hooks": "^4.6.2",
53
51
  "get-port": "5.1.1",
54
- "glob": "^10.2.7",
55
- "html-webpack-plugin": "^5.5.3",
56
- "husky": "^8.0.3",
52
+ "glob": "^10.5.0",
53
+ "html-webpack-plugin": "^5.6.6",
54
+ "husky": "^9.1.7",
57
55
  "inquirer": "3.0.4",
58
- "lint-staged": "^13.2.2",
59
- "mini-css-extract-plugin": "^2.7.6",
56
+ "lint-staged": "^13.3.0",
57
+ "mini-css-extract-plugin": "^2.10.1",
60
58
  "mysql": "^2.18.1",
61
- "node-fetch": "2",
59
+ "node-fetch": "^2.7.0",
62
60
  "ora": "^5.4.1",
63
- "postcss": "^8.4.24",
64
- "postcss-loader": "^7.3.3",
65
- "postcss-preset-env": "^8.5.0",
61
+ "postcss": "^8.5.8",
62
+ "postcss-loader": "^7.3.4",
63
+ "postcss-preset-env": "^8.5.1",
66
64
  "prettier": "^2.8.8",
67
- "raw-loader": "^4.0.2",
68
- "react-refresh": "^0.14.0",
69
- "replace-in-file": "^7.0.1",
70
- "rimraf": "^5.0.5",
65
+ "react-refresh": "^0.14.2",
66
+ "replace-in-file": "^7.2.0",
67
+ "rimraf": "^5.0.10",
71
68
  "rsync": "^0.6.1",
72
- "sass": "^1.97.3",
69
+ "sass": "^1.98.0",
73
70
  "sass-loader": "16.0.7",
74
- "semver": "^7.5.2",
75
- "slugify": "^1.6.6",
76
- "ssh2": "0.8.9",
77
- "style-loader": "^3.3.3",
78
- "swc-loader": "^0.2.3",
71
+ "semver": "^7.7.4",
72
+ "slugify": "^1.6.8",
73
+ "ssh2": "^1.17.0",
74
+ "style-loader": "^3.3.4",
75
+ "swc-loader": "^0.2.7",
79
76
  "tempy": "^0.2.1",
80
- "terser-webpack-plugin": "^5.3.9",
81
- "webpack": "^5.87.0",
82
- "webpack-dev-middleware": "^6.1.1",
83
- "webpack-hot-middleware": "^2.25.3",
84
- "webpack-merge": "^5.9.0",
85
- "webpack-remove-empty-scripts": "^1.0.3",
77
+ "terser-webpack-plugin": "^5.4.0",
78
+ "webpack": "^5.105.4",
79
+ "webpack-dev-middleware": "^6.1.3",
80
+ "webpack-hot-middleware": "^2.26.1",
81
+ "webpack-merge": "^5.10.0",
82
+ "webpack-remove-empty-scripts": "^1.1.1",
86
83
  "yargs": "^17.7.2"
87
84
  },
88
85
  "devDependencies": {
89
- "eslint-plugin-import": "^2.14.0",
90
- "eslint-plugin-jsx-a11y": "^6.1.2",
91
86
  "eslint-plugin-node": "^11.1.0"
92
87
  }
93
- }
88
+ }
@@ -16,7 +16,7 @@ async function getCurrentNodeVersion() {
16
16
 
17
17
  async function getProjectNodeVersion() {
18
18
  try {
19
- const nvm = await fs.readFileSync(getProjectPath('.nvmrc'), 'utf8');
19
+ const nvm = await fs.promises.readFile(getProjectPath('.nvmrc'), 'utf8');
20
20
  return nvm.trim();
21
21
  } catch (err) {
22
22
  // No file, nevermind
@@ -29,7 +29,7 @@ function isValidNodeVersion(version, currentNodeVersion) {
29
29
  return semver.gte(cleanNvmString(version), currentNodeVersion, true);
30
30
  }
31
31
 
32
- async function checkNodeVerion() {
32
+ async function checkNodeVersion() {
33
33
  const projectVersion = await getProjectNodeVersion();
34
34
  const currentVersion = await getCurrentNodeVersion();
35
35
 
@@ -40,4 +40,4 @@ async function checkNodeVerion() {
40
40
  }
41
41
  }
42
42
 
43
- module.exports = checkNodeVerion;
43
+ module.exports = checkNodeVersion;
@@ -0,0 +1,24 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+
4
+ const getProjectPath = require('./getProjectPath');
5
+ const logger = require('../logger');
6
+
7
+ /**
8
+ * Ensures a given pattern exists in the project's .gitignore.
9
+ * Appends it if missing, does nothing if already present.
10
+ */
11
+ module.exports = function ensureGitignore(pattern) {
12
+ const gitignorePath = getProjectPath('.gitignore');
13
+
14
+ if (!fs.existsSync(gitignorePath)) return;
15
+
16
+ const contents = fs.readFileSync(gitignorePath, 'utf8');
17
+ const lines = contents.split('\n').map((l) => l.trim());
18
+
19
+ if (lines.includes(pattern)) return;
20
+
21
+ const separator = contents.endsWith('\n') ? '' : '\n';
22
+ fs.writeFileSync(gitignorePath, `${contents}${separator}${pattern}\n`);
23
+ logger.info(`Added "${pattern}" to .gitignore`);
24
+ };
package/utils/execSsh.js CHANGED
@@ -1,8 +1,8 @@
1
- const ssh2 = require('ssh2');
1
+ const { Client } = require('ssh2');
2
2
 
3
3
  async function execSsh(command, options) {
4
4
  return new Promise((resolve, reject) => {
5
- const client = new ssh2.Client();
5
+ const client = new Client();
6
6
 
7
7
  client.connect({
8
8
  port: options.port || 22,
package/utils/git.js CHANGED
@@ -11,53 +11,6 @@ async function commitAll(message = 'Commit all') {
11
11
  return commitFile('.', message);
12
12
  }
13
13
 
14
- async function checkoutBranch(name) {
15
- await execAsync(`git checkout ${name}`, { cwd: CWD });
16
- }
17
-
18
- async function createBranch(name, commit) {
19
- // Make sure the branch doesn't exist
20
- await execAsync('git checkout master', { cwd: CWD });
21
- const branchAlreadyExists = await branchExists(name);
22
- if (branchAlreadyExists) {
23
- await deleteBranch(name);
24
- }
25
- // NOTE: Commit is optional
26
- await execAsync(`git checkout -b ${name} ${commit || ''}`, { cwd: CWD });
27
- }
28
-
29
- async function mergeBranch(to, from) {
30
- await execAsync(`git checkout ${to}`, { cwd: CWD });
31
- await execAsync(`git merge ${from}`, { cwd: CWD });
32
- }
33
-
34
- async function deleteBranch(name) {
35
- try {
36
- await execAsync(`git branch -d ${name}`, { cwd: CWD });
37
- } catch (e) {
38
- // Nevermind
39
- }
40
- }
41
-
42
- async function resetBranchToCommit(name, commitHash) {
43
- try {
44
- await execAsync(`git checkout ${name}`, { cwd: CWD });
45
- await execAsync(`git reset --hard ${commitHash}`, { cwd: CWD });
46
- } catch (e) {
47
- // Nevermind
48
- }
49
- }
50
-
51
- async function deleteAllBranchButMaster() {
52
- await execAsync('git branch | grep -v "master" | xargs git branch -D', {
53
- cwd: CWD,
54
- });
55
- }
56
-
57
- async function deleteAllTags() {
58
- await execAsync('git tag | xargs git tag -d', { cwd: CWD });
59
- }
60
-
61
14
  async function discardUnstagedFiles() {
62
15
  await execAsync('git reset --hard', { cwd: CWD });
63
16
  }
@@ -66,7 +19,7 @@ async function createTag(name) {
66
19
  await execAsync(`git tag ${name}`, { cwd: CWD });
67
20
  }
68
21
 
69
- async function getCurrentBrachName() {
22
+ async function getCurrentBranchName() {
70
23
  /* eslint-disable-next-line no-useless-escape */
71
24
  const branchName = await execAsync('git rev-parse --abbrev-ref HEAD', {
72
25
  cwd: CWD,
@@ -95,42 +48,20 @@ async function getChangedFiles(sha, sha2) {
95
48
  const fileList = await execAsync(`git diff --name-only ${sha} ${sha2}`, {
96
49
  cwd: CWD,
97
50
  });
98
- return fileList
99
- .trim()
100
- .split(/\r?\n/)
101
- .filter(Boolean);
51
+ return fileList.trim().split(/\r?\n/).filter(Boolean);
102
52
  }
103
53
 
104
- async function getMergeChangedFiles(ref) {
105
- const fileList = await execAsync(
106
- 'git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD',
107
- { cwd: CWD }
108
- );
109
- return fileList
110
- .trim()
111
- .split(/\r?\n/)
112
- .filter(Boolean);
54
+ async function getMergeChangedFiles() {
55
+ const fileList = await execAsync('git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD', {
56
+ cwd: CWD,
57
+ });
58
+ return fileList.trim().split(/\r?\n/).filter(Boolean);
113
59
  }
114
60
 
115
61
  async function getUnstagedFiles() {
116
62
  const fileList = await execAsync('git diff --name-only', { cwd: CWD });
117
- const untrackedFileList = await execAsync(
118
- 'git ls-files -o --exclude-standard',
119
- { cwd: CWD }
120
- );
121
- return fileList
122
- .split(/\r?\n/)
123
- .concat(untrackedFileList.split(/\r?\n/))
124
- .filter(Boolean);
125
- }
126
-
127
- async function branchExists(name) {
128
- try {
129
- await execAsync(`git rev-parse --verify ${name}`, { cwd: CWD });
130
- return true;
131
- } catch (e) {
132
- return false;
133
- }
63
+ const untrackedFileList = await execAsync('git ls-files -o --exclude-standard', { cwd: CWD });
64
+ return fileList.split(/\r?\n/).concat(untrackedFileList.split(/\r?\n/)).filter(Boolean);
134
65
  }
135
66
 
136
67
  async function getRefCommitHash(ref) {
@@ -147,22 +78,14 @@ async function getRefCommitHash(ref) {
147
78
  module.exports = {
148
79
  commitFile,
149
80
  commitAll,
150
- checkoutBranch,
151
- createBranch,
152
- mergeBranch,
153
- deleteBranch,
154
- resetBranchToCommit,
155
- deleteAllBranchButMaster,
156
- deleteAllTags,
157
81
  discardUnstagedFiles,
158
- getCurrentBrachName,
82
+ getCurrentBranchName,
159
83
  getCommitParent,
160
84
  getCurrentCommitHash,
161
85
  getMasterCommitHash,
162
86
  getMergeChangedFiles,
163
87
  getChangedFiles,
164
88
  getUnstagedFiles,
165
- branchExists,
166
89
  getRefCommitHash,
167
90
  createTag,
168
91
  };
@@ -1,12 +1,15 @@
1
1
  const fs = require('fs');
2
2
 
3
3
  const getProjectPath = require('./getProjectPath');
4
+ const bypassReact = process.env.BYPASS_REACT || false;
4
5
 
5
6
  // Cache the value
6
7
  let _isReactProject;
7
8
 
8
9
  // Check for react in the project deps, if it's there treat this project as headless
9
10
  function isReactProject() {
11
+ // Some non-headless projects want to use 'react' so let them. Pass BYPASS_REACT=true in package.json
12
+ if (bypassReact) return false;
10
13
  if (typeof _isReactProject === 'undefined') {
11
14
  const projectPckPath = getProjectPath('package.json');
12
15
  const pckFile = fs.readFileSync(projectPckPath);
@@ -7,9 +7,9 @@ const getSettings = require('../utils/projectSettings');
7
7
 
8
8
  // Taken from https://github.com/dword-design/mysqldump-search-replace-node
9
9
  function makeSerializeReplacement(match, length, value) {
10
- var unescapedValue = value.replace(/(?<!\\)\\(?!\\)/g, '').replace(/\\\\/g, '\\');
11
- var escapedLength = Buffer.byteLength(unescapedValue, 'utf-8');
12
- return `s:${escapedLength}:\\"${value}\\";`
10
+ const unescapedValue = value.replace(/(?<!\\)\\(?!\\)/g, '').replace(/\\\\/g, '\\');
11
+ const escapedLength = Buffer.byteLength(unescapedValue, 'utf-8');
12
+ return `s:${escapedLength}:\\"${value}\\";`;
13
13
  }
14
14
 
15
15
  module.exports = async ({ environmentIn, environmentOut, file, override = true }) => {
@@ -21,15 +21,11 @@ module.exports = async ({ environmentIn, environmentOut, file, override = true }
21
21
 
22
22
  // Check we have both urls to replace
23
23
  if (!settings.url[environmentIn]) {
24
- throw new Error(
25
- `Couldn't find SQL url in settings for ${environmentIn} environment`
26
- );
24
+ throw new Error(`Couldn't find SQL url in settings for ${environmentIn} environment`);
27
25
  }
28
26
 
29
27
  if (!settings.url[environmentOut]) {
30
- throw new Error(
31
- `Couldn't find SQL url in settings for ${environmentOut} environment`
32
- );
28
+ throw new Error(`Couldn't find SQL url in settings for ${environmentOut} environment`);
33
29
  }
34
30
 
35
31
  // Handle any port number in localhost
@@ -39,7 +35,7 @@ module.exports = async ({ environmentIn, environmentOut, file, override = true }
39
35
  : settings.url[environmentIn].replace('8888', '[0-9]*');
40
36
 
41
37
  const urlRegexReplace = new RegExp(urlToReplace, 'g');
42
- const serializeReplace = /s:([1-9]\d*):\\"(.*?)\\";/g
38
+ const serializeReplace = /s:([1-9]\d*):\\"(.*?)\\";/g;
43
39
 
44
40
  if (!override) {
45
41
  const tempFilePath = tempy.file({ extension: 'sql' });
@@ -4,16 +4,20 @@ const ora = require('ora');
4
4
 
5
5
  const getProjectPath = require('./getProjectPath');
6
6
 
7
- module.exports = async environment => {
7
+ const DEPLOY_BUILD_DIR = 'dist-deploy';
8
+
9
+ module.exports = async (environment) => {
8
10
  logger.log(`Building project for ${environment}`);
9
11
  const spinner = ora();
10
12
  spinner.prefixText = logger.prefix;
11
13
 
12
14
  spinner.start();
13
- await execAsync(`BUILD_ENV=${environment} npm run build`, {
15
+ await execAsync(`BUILD_ENV=${environment} DEPLOY_OUT_DIR=${DEPLOY_BUILD_DIR} npm run build`, {
14
16
  cwd: getProjectPath(),
15
17
  });
16
18
  spinner.stop();
17
19
 
18
20
  logger.success(`Successfully built for ${environment}`);
21
+
22
+ return DEPLOY_BUILD_DIR;
19
23
  };
@@ -4,16 +4,16 @@ const fs = require('fs');
4
4
  const logger = require('../logger');
5
5
  const { isWindows } = require('./checkPlatform');
6
6
 
7
- const mamp6Path = '/Applications/MAMP/bin';
8
- const mamp7Path = '/Applications/MAMP/Library/bin'; //MAMP7 moved mysql path
9
-
10
- const mampPath = fs.existsSync(mamp7Path) ? mamp7Path : mamp6Path;
7
+ const MAMP_START_SCRIPT = '/Applications/MAMP/bin/start.sh';
11
8
 
12
9
  function startMAMP() {
13
10
  if (isWindows) {
14
11
  return;
15
12
  }
16
- cp.execFile(`${mampPath}/start.sh`);
13
+ if (!fs.existsSync(MAMP_START_SCRIPT)) {
14
+ return;
15
+ }
16
+ cp.execFile('/bin/sh', [MAMP_START_SCRIPT]);
17
17
  logger.info('MAMP Started');
18
18
  }
19
19
 
@@ -1,11 +1,11 @@
1
1
  const net = require('net');
2
- const Connection = require('ssh2');
2
+ const { Client: Connection } = require('ssh2');
3
3
  const events = require('events');
4
4
 
5
5
  const noop = () => {};
6
6
 
7
7
  function createConfig(config) {
8
- var env = process.env;
8
+ const env = process.env;
9
9
 
10
10
  config = {
11
11
  username: env.TUNNELSSH_USER || env.USER || env.USERNAME || 'root',
@@ -33,17 +33,17 @@ function createConfig(config) {
33
33
  }
34
34
 
35
35
  function bindSSHConnection(config, netConnection) {
36
- var sshConnection = new Connection();
36
+ const sshConnection = new Connection();
37
37
  netConnection.on('close', sshConnection.end.bind(sshConnection));
38
38
 
39
- sshConnection.on('ready', function() {
39
+ sshConnection.on('ready', function () {
40
40
  netConnection.emit('sshConnection', sshConnection, netConnection);
41
41
  sshConnection.forwardOut(
42
42
  config.srcHost,
43
43
  config.srcPort,
44
44
  config.dstHost,
45
45
  config.dstPort,
46
- function(err, sshStream) {
46
+ function (err, sshStream) {
47
47
  if (err) {
48
48
  // Bubble up the error => netConnection => server
49
49
  netConnection.emit('error', err);
@@ -59,19 +59,19 @@ function bindSSHConnection(config, netConnection) {
59
59
  }
60
60
 
61
61
  function createServer(config) {
62
- var server;
63
- var connections = [];
64
- var connectionCount = 0;
62
+ let server;
63
+ const connections = [];
64
+ let connectionCount = 0;
65
65
 
66
- server = net.createServer(function(netConnection) {
67
- var sshConnection;
66
+ server = net.createServer(function (netConnection) {
67
+ let sshConnection;
68
68
  connectionCount++;
69
69
  netConnection.on('error', server.emit.bind(server, 'error'));
70
- netConnection.on('close', function() {
70
+ netConnection.on('close', function () {
71
71
  connectionCount--;
72
72
  if (connectionCount === 0) {
73
73
  if (!config.keepAlive) {
74
- setTimeout(function() {
74
+ setTimeout(function () {
75
75
  if (connectionCount === 0) {
76
76
  server.close();
77
77
  }
@@ -84,8 +84,8 @@ function createServer(config) {
84
84
  sshConnection = bindSSHConnection(config, netConnection);
85
85
  sshConnection.on('error', server.emit.bind(server, 'error'));
86
86
 
87
- netConnection.on('sshStream', function(sshStream) {
88
- sshStream.on('error', function() {
87
+ netConnection.on('sshStream', function (sshStream) {
88
+ sshStream.on('error', function () {
89
89
  server.close();
90
90
  });
91
91
  });
@@ -98,8 +98,8 @@ function createServer(config) {
98
98
  }
99
99
  });
100
100
 
101
- server.on('close', function() {
102
- connections.forEach(function(connection) {
101
+ server.on('close', function () {
102
+ connections.forEach(function (connection) {
103
103
  connection.end();
104
104
  });
105
105
  });
@@ -108,8 +108,8 @@ function createServer(config) {
108
108
  }
109
109
 
110
110
  function tunnel(configArgs, callback) {
111
- var server;
112
- var config;
111
+ let server;
112
+ let config;
113
113
 
114
114
  if (!callback) {
115
115
  callback = noop;
@@ -118,12 +118,12 @@ function tunnel(configArgs, callback) {
118
118
  config = createConfig(configArgs);
119
119
  server = createServer(config);
120
120
 
121
- server.listen(config.localPort, config.localHost, function(error) {
121
+ server.listen(config.localPort, config.localHost, function (error) {
122
122
  callback(error, server);
123
123
  });
124
124
  } catch (e) {
125
125
  server = new events.EventEmitter();
126
- setImmediate(function() {
126
+ setImmediate(function () {
127
127
  callback(e);
128
128
  server.emit('error', e);
129
129
  });