wp-blank-scripts 2.6.7 → 2.6.10
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 +8 -10
- package/package.json +1 -1
- package/utils/deploySQLFromCI.js +27 -0
package/lib/deployProject.js
CHANGED
|
@@ -7,13 +7,13 @@ const exportSql = require('./exportSQL');
|
|
|
7
7
|
const cleanShellPath = require('../utils/cleanShellPath');
|
|
8
8
|
const tunnel = require('../utils/tunnelSsh');
|
|
9
9
|
const git = require('../utils/git');
|
|
10
|
-
const getMostRecentSqlFile = require('../utils/getMostRecentSqlFile');
|
|
11
10
|
const runProjectBuildTask = require('../utils/runProjectBuildTask');
|
|
12
11
|
const bumpVersion = require('../utils/bumpVersion');
|
|
13
12
|
const isCI = require('../utils/isCI');
|
|
14
13
|
const execAsync = require('../utils/execAsync');
|
|
15
14
|
const { DEPLOY_MODES } = require('../constants');
|
|
16
15
|
const getProjectPath = require('../utils/getProjectPath');
|
|
16
|
+
const deploySQLFromCI = require('../utils/deploySQLFromCI');
|
|
17
17
|
const getSettings = require('../utils/projectSettings');
|
|
18
18
|
const logger = require('../logger');
|
|
19
19
|
const replaceSQL = require('../utils/replaceSQL');
|
|
@@ -21,9 +21,8 @@ const replaceSQL = require('../utils/replaceSQL');
|
|
|
21
21
|
// Default options
|
|
22
22
|
const defaultOptions = {
|
|
23
23
|
tunnelHost: '127.0.0.1',
|
|
24
|
-
tunnelPort:
|
|
24
|
+
tunnelPort: 3308,
|
|
25
25
|
mySQLPort: 3306,
|
|
26
|
-
mySQLSocket: '/var/lib/mysql/mysql.sock',
|
|
27
26
|
};
|
|
28
27
|
|
|
29
28
|
let m;
|
|
@@ -195,7 +194,6 @@ async function connectMySQL() {
|
|
|
195
194
|
m = mysql.createConnection({
|
|
196
195
|
host: tunnelHost,
|
|
197
196
|
port: tunnelPort,
|
|
198
|
-
socketPath: isCI() ? options.mySQLSocket : '/Applications/MAMP/tmp/mysql/mysql.sock',
|
|
199
197
|
user,
|
|
200
198
|
password,
|
|
201
199
|
database,
|
|
@@ -279,11 +277,13 @@ module.exports = async (selectOptions, callbacks) => {
|
|
|
279
277
|
}
|
|
280
278
|
|
|
281
279
|
if (options.sql) {
|
|
280
|
+
if (isCI()) {
|
|
281
|
+
return deploySQLFromCI();
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
const file = await exportSql({ environment: options.environment });
|
|
282
285
|
await createTunnel();
|
|
283
286
|
await connectMySQL();
|
|
284
|
-
const file = isCI()
|
|
285
|
-
? getMostRecentSqlFile(true)
|
|
286
|
-
: await exportSql({ environment: options.environment });
|
|
287
287
|
|
|
288
288
|
if (file) {
|
|
289
289
|
await replaceSQL({
|
|
@@ -298,7 +298,5 @@ module.exports = async (selectOptions, callbacks) => {
|
|
|
298
298
|
await disconnectMySQL();
|
|
299
299
|
}
|
|
300
300
|
|
|
301
|
-
|
|
302
|
-
await bumpVersion(options);
|
|
303
|
-
}
|
|
301
|
+
await bumpVersion(options);
|
|
304
302
|
};
|
package/package.json
CHANGED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
|
|
3
|
+
const getMostRecentSqlFile = require('./getMostRecentSqlFile');
|
|
4
|
+
const getSettings = require('./projectSettings');
|
|
5
|
+
|
|
6
|
+
const DEPLOY_URL = 'https://57e5-60-241-189-248.au.ngrok.io/prod/deploy';
|
|
7
|
+
|
|
8
|
+
async function deploySQLFromCI() {
|
|
9
|
+
const { default: fetch } = await import('node-fetch');
|
|
10
|
+
const file = getMostRecentSqlFile(true);
|
|
11
|
+
console.log({ file, repo });
|
|
12
|
+
const sql = fs.readFileSync(file, 'utf8');
|
|
13
|
+
|
|
14
|
+
const response = await fetch(DEPLOY_URL, {
|
|
15
|
+
method: 'POST',
|
|
16
|
+
body: JSON.stringify({
|
|
17
|
+
sql,
|
|
18
|
+
settings: getSettings(),
|
|
19
|
+
}),
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
console.log(response.status);
|
|
23
|
+
const body = await response.json();
|
|
24
|
+
console.log(body);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
module.exports = deploySQLFromCI;
|