wp-blank-scripts 2.6.8 → 2.6.11
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 -8
- package/package.json +1 -1
- package/utils/deploySQLFromCI.js +34 -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,7 +21,7 @@ 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
26
|
};
|
|
27
27
|
|
|
@@ -277,11 +277,13 @@ module.exports = async (selectOptions, callbacks) => {
|
|
|
277
277
|
}
|
|
278
278
|
|
|
279
279
|
if (options.sql) {
|
|
280
|
+
if (isCI()) {
|
|
281
|
+
return deploySQLFromCI(options);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
const file = await exportSql({ environment: options.environment });
|
|
280
285
|
await createTunnel();
|
|
281
286
|
await connectMySQL();
|
|
282
|
-
const file = isCI()
|
|
283
|
-
? getMostRecentSqlFile(true)
|
|
284
|
-
: await exportSql({ environment: options.environment });
|
|
285
287
|
|
|
286
288
|
if (file) {
|
|
287
289
|
await replaceSQL({
|
|
@@ -296,7 +298,5 @@ module.exports = async (selectOptions, callbacks) => {
|
|
|
296
298
|
await disconnectMySQL();
|
|
297
299
|
}
|
|
298
300
|
|
|
299
|
-
|
|
300
|
-
await bumpVersion(options);
|
|
301
|
-
}
|
|
301
|
+
await bumpVersion(options);
|
|
302
302
|
};
|
package/package.json
CHANGED
|
@@ -0,0 +1,34 @@
|
|
|
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(options) {
|
|
9
|
+
const { default: fetch } = await import('node-fetch');
|
|
10
|
+
const file = getMostRecentSqlFile(true);
|
|
11
|
+
console.log({ file, repo });
|
|
12
|
+
|
|
13
|
+
await replaceSQL({
|
|
14
|
+
environmentIn: 'local',
|
|
15
|
+
environmentOut: options.environment,
|
|
16
|
+
file,
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
const sql = fs.readFileSync(file, 'utf8');
|
|
20
|
+
|
|
21
|
+
const response = await fetch(DEPLOY_URL, {
|
|
22
|
+
method: 'POST',
|
|
23
|
+
body: JSON.stringify({
|
|
24
|
+
sql,
|
|
25
|
+
settings: getSettings(),
|
|
26
|
+
}),
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
console.log(response.status);
|
|
30
|
+
const body = await response.json();
|
|
31
|
+
console.log(body);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
module.exports = deploySQLFromCI;
|