@atomicsmash/cli 9.0.1-beta.2 → 9.0.1-beta.3
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pull-database.d.ts","sourceRoot":"","sources":["../../src/commands/pull-database.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pull-database.d.ts","sourceRoot":"","sources":["../../src/commands/pull-database.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,OAAO,kBAAkB,CAAC;AACvC,eAAO,MAAM,QAAQ,oEAC6C,CAAC;AACnE,wBAAsB,OAAO,kBA4I5B"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { exec } from "node:child_process";
|
|
2
|
-
import { createReadStream, createWriteStream } from "node:fs";
|
|
3
2
|
import { unlink as deleteFile } from "node:fs/promises";
|
|
4
3
|
import { performance } from "node:perf_hooks";
|
|
5
|
-
import readline from "node:readline";
|
|
6
4
|
import { promisify } from "node:util";
|
|
7
5
|
import { convertMeasureToPrettyString, getSmashConfig, startRunningMessage, } from "../utils.js";
|
|
8
6
|
export const command = "pull-database";
|
|
@@ -40,7 +38,6 @@ export async function handler() {
|
|
|
40
38
|
await (async () => {
|
|
41
39
|
const tmpFile = "/tmp/staging-database.sql";
|
|
42
40
|
const dbPrefixFile = "/tmp/db-prefix.txt";
|
|
43
|
-
const tmpFileProcessed = "/tmp/staging-database.processed.sql";
|
|
44
41
|
const tablesToExclude = [
|
|
45
42
|
// WordFence
|
|
46
43
|
"wfauditevents",
|
|
@@ -81,26 +78,11 @@ export async function handler() {
|
|
|
81
78
|
.then(async () => {
|
|
82
79
|
await stopRunningMessage();
|
|
83
80
|
console.log("Database downloaded.");
|
|
84
|
-
const stopRunningMessage2 = startRunningMessage("
|
|
85
|
-
await
|
|
86
|
-
const readStream = createReadStream(tmpFile, { encoding: "utf8" });
|
|
87
|
-
const writeStream = createWriteStream(tmpFileProcessed, {
|
|
88
|
-
encoding: "utf8",
|
|
89
|
-
});
|
|
90
|
-
const rl = readline.createInterface({ input: readStream });
|
|
91
|
-
rl.on("line", (line) => {
|
|
92
|
-
writeStream.write(line.replaceAll(stagingUrl, `//${projectName}.test`) + "\n");
|
|
93
|
-
});
|
|
94
|
-
rl.on("close", () => {
|
|
95
|
-
writeStream.end();
|
|
96
|
-
});
|
|
97
|
-
writeStream.on("finish", resolve);
|
|
98
|
-
writeStream.on("error", reject);
|
|
99
|
-
readStream.on("error", reject);
|
|
100
|
-
})
|
|
81
|
+
const stopRunningMessage2 = startRunningMessage("Importing database");
|
|
82
|
+
await execute(`wp db query < ${tmpFile}`)
|
|
101
83
|
.then(async () => {
|
|
102
84
|
await stopRunningMessage2();
|
|
103
|
-
console.log("
|
|
85
|
+
console.log("Database imported.");
|
|
104
86
|
})
|
|
105
87
|
.catch(async (error) => {
|
|
106
88
|
await stopRunningMessage2();
|
|
@@ -108,20 +90,22 @@ export async function handler() {
|
|
|
108
90
|
});
|
|
109
91
|
})
|
|
110
92
|
.then(async () => {
|
|
111
|
-
const stopRunningMessage3 = startRunningMessage("
|
|
112
|
-
await execute(`wp
|
|
93
|
+
const stopRunningMessage3 = startRunningMessage("Running search and replace");
|
|
94
|
+
await execute(`wp search-replace --url=${projectName}.test ${stagingUrl} '//${projectName}.test' --skip-columns=guid`)
|
|
113
95
|
.then(async () => {
|
|
114
96
|
await stopRunningMessage3();
|
|
97
|
+
console.log("Search and replace completed.");
|
|
115
98
|
})
|
|
116
99
|
.catch(async (error) => {
|
|
117
100
|
await stopRunningMessage3();
|
|
118
101
|
throw error;
|
|
119
102
|
});
|
|
103
|
+
})
|
|
104
|
+
.then(async () => {
|
|
120
105
|
const stopRunningMessage4 = startRunningMessage("Cleaning up");
|
|
121
106
|
await Promise.allSettled([
|
|
122
107
|
deleteFile(tmpFile),
|
|
123
108
|
deleteFile(dbPrefixFile),
|
|
124
|
-
deleteFile(tmpFileProcessed),
|
|
125
109
|
]).then(async () => {
|
|
126
110
|
await stopRunningMessage4();
|
|
127
111
|
});
|
|
@@ -134,7 +118,6 @@ export async function handler() {
|
|
|
134
118
|
const cleanupResults = await Promise.allSettled([
|
|
135
119
|
deleteFile(tmpFile),
|
|
136
120
|
deleteFile(dbPrefixFile),
|
|
137
|
-
deleteFile(tmpFileProcessed),
|
|
138
121
|
]);
|
|
139
122
|
const failedCleanups = cleanupResults.filter((result) => result.status === "rejected");
|
|
140
123
|
if (failedCleanups.length > 0) {
|