wp-blank-scripts 2.6.5 → 2.6.8
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/lib/deployProject.js +13 -9
- package/package.json +1 -1
package/lib/deployProject.js
CHANGED
|
@@ -11,6 +11,7 @@ const getMostRecentSqlFile = require('../utils/getMostRecentSqlFile');
|
|
|
11
11
|
const runProjectBuildTask = require('../utils/runProjectBuildTask');
|
|
12
12
|
const bumpVersion = require('../utils/bumpVersion');
|
|
13
13
|
const isCI = require('../utils/isCI');
|
|
14
|
+
const execAsync = require('../utils/execAsync');
|
|
14
15
|
const { DEPLOY_MODES } = require('../constants');
|
|
15
16
|
const getProjectPath = require('../utils/getProjectPath');
|
|
16
17
|
const getSettings = require('../utils/projectSettings');
|
|
@@ -19,8 +20,8 @@ const replaceSQL = require('../utils/replaceSQL');
|
|
|
19
20
|
|
|
20
21
|
// Default options
|
|
21
22
|
const defaultOptions = {
|
|
22
|
-
tunnelHost: '
|
|
23
|
-
tunnelPort:
|
|
23
|
+
tunnelHost: '127.0.0.1',
|
|
24
|
+
tunnelPort: 3307,
|
|
24
25
|
mySQLPort: 3306,
|
|
25
26
|
};
|
|
26
27
|
|
|
@@ -68,6 +69,12 @@ async function createTunnel() {
|
|
|
68
69
|
|
|
69
70
|
const { tunnelHost, tunnelPort, mySQLPort } = options;
|
|
70
71
|
|
|
72
|
+
if (isCI()) {
|
|
73
|
+
execAsync(`ssh -L ${tunnelPort}:${tunnelHost}:${mySQLPort} -N ${server.user}@${server.host}`);
|
|
74
|
+
logger.log(`Created tunnel to ${server.host}`);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
|
|
71
78
|
let serverPrivateKey;
|
|
72
79
|
if (options.serverPrivateKey) {
|
|
73
80
|
serverPrivateKey = fs.readFileSync(cleanShellPath(options.serverPrivateKey));
|
|
@@ -177,17 +184,16 @@ async function deployToServer() {
|
|
|
177
184
|
|
|
178
185
|
async function connectMySQL() {
|
|
179
186
|
// Environment info
|
|
180
|
-
const { host
|
|
187
|
+
const { host } = settings.server[options.environment];
|
|
181
188
|
const { user, password, database } = settings.mysql[options.environment];
|
|
182
189
|
|
|
183
190
|
// Tunnel info
|
|
184
191
|
const { tunnelHost, tunnelPort } = options;
|
|
185
|
-
const useTunnel = !isCI();
|
|
186
192
|
|
|
187
193
|
return new Promise((resolve, reject) => {
|
|
188
194
|
m = mysql.createConnection({
|
|
189
|
-
host:
|
|
190
|
-
port:
|
|
195
|
+
host: tunnelHost,
|
|
196
|
+
port: tunnelPort,
|
|
191
197
|
user,
|
|
192
198
|
password,
|
|
193
199
|
database,
|
|
@@ -271,9 +277,7 @@ module.exports = async (selectOptions, callbacks) => {
|
|
|
271
277
|
}
|
|
272
278
|
|
|
273
279
|
if (options.sql) {
|
|
274
|
-
|
|
275
|
-
await createTunnel();
|
|
276
|
-
}
|
|
280
|
+
await createTunnel();
|
|
277
281
|
await connectMySQL();
|
|
278
282
|
const file = isCI()
|
|
279
283
|
? getMostRecentSqlFile(true)
|