@atomicsmash/cli 9.0.0-beta.10 → 9.0.0-beta.12

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":"AAYA,eAAO,MAAM,OAAO,kBAAkB,CAAC;AACvC,eAAO,MAAM,QAAQ,oEAC6C,CAAC;AACnE,wBAAsB,OAAO,kBAqH5B"}
1
+ {"version":3,"file":"pull-database.d.ts","sourceRoot":"","sources":["../../src/commands/pull-database.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,OAAO,kBAAkB,CAAC;AACvC,eAAO,MAAM,QAAQ,oEAC6C,CAAC;AACnE,wBAAsB,OAAO,kBA8J5B"}
@@ -13,6 +13,8 @@ export async function handler() {
13
13
  const stagingSSHUsername = process.env.STAGING_SSH_USERNAME;
14
14
  const stagingSSHHost = process.env.STAGING_SSH_HOST;
15
15
  const stagingSSHPort = process.env.STAGING_SSH_PORT;
16
+ const stagingDBPrefix = process.env.STAGING_DB_PREFIX ?? "wp_";
17
+ const stagingWebRoot = process.env.STAGING_WEB_ROOT ?? "public/current";
16
18
  const stagingUrl = process.env.STAGING_URL?.endsWith("/")
17
19
  ? process.env.STAGING_URL.slice(0, -1)
18
20
  : process.env.STAGING_URL;
@@ -37,8 +39,45 @@ export async function handler() {
37
39
  performance.mark("Start");
38
40
  await (async () => {
39
41
  const tmpFile = "/tmp/staging-database.sql";
42
+ const dbPrefixFile = "/tmp/db-prefix.txt";
40
43
  const tmpFileProcessed = "/tmp/staging-database.processed.sql";
41
- await execute(`ssh -o "StrictHostKeyChecking no" ${stagingSSHUsername}@${stagingSSHHost} -p ${stagingSSHPort} "cd public/current && wp db export - --add-drop-table" > ${tmpFile}`)
44
+ const tablesToExclude = [
45
+ // WordFence
46
+ "wfauditevents",
47
+ "wfblockediplog",
48
+ "wfblocks7",
49
+ "wfconfig",
50
+ "wfcrawlers",
51
+ "wffilemods",
52
+ "wfhits",
53
+ "wfhoover",
54
+ "wfissues",
55
+ "wfknownfilelist",
56
+ "wflivetraffichuman",
57
+ "wflocs",
58
+ "wflogins",
59
+ "wfls_2fa_secrets",
60
+ "wfls_role_counts",
61
+ "wfls_settings",
62
+ "wfnotifications",
63
+ "wfpendingissues",
64
+ "wfreversecache",
65
+ "wfsecurityevents",
66
+ "wfsnipcache",
67
+ "wfstatus",
68
+ "wftrafficrates",
69
+ "wfwaffailures",
70
+ // WP All Import/Export
71
+ "pmxi_files",
72
+ "pmxi_geocoding",
73
+ "pmxi_hash",
74
+ "pmxi_history",
75
+ "pmxi_images",
76
+ "pmxi_imports",
77
+ "pmxi_posts",
78
+ "pmxi_templates",
79
+ ].map((tableName) => stagingDBPrefix + tableName);
80
+ await execute(`ssh -o "StrictHostKeyChecking no" ${stagingSSHUsername}@${stagingSSHHost} -p ${stagingSSHPort} "${stagingWebRoot !== "" ? `cd ${stagingWebRoot} && ` : ""}wp db export - --add-drop-table --exclude_tables=${tablesToExclude.join(",")}" > ${tmpFile}`)
42
81
  .then(async () => {
43
82
  await stopRunningMessage();
44
83
  console.log("Database downloaded.");
@@ -81,6 +120,7 @@ export async function handler() {
81
120
  const stopRunningMessage4 = startRunningMessage("Cleaning up");
82
121
  await Promise.allSettled([
83
122
  deleteFile(tmpFile),
123
+ deleteFile(dbPrefixFile),
84
124
  deleteFile(tmpFileProcessed),
85
125
  ]).then(async () => {
86
126
  await stopRunningMessage4();
@@ -93,6 +133,7 @@ export async function handler() {
93
133
  console.error("Error during database pull:", error);
94
134
  const cleanupResults = await Promise.allSettled([
95
135
  deleteFile(tmpFile),
136
+ deleteFile(dbPrefixFile),
96
137
  deleteFile(tmpFileProcessed),
97
138
  ]);
98
139
  const failedCleanups = cleanupResults.filter((result) => result.status === "rejected");
@@ -10,7 +10,7 @@ async function downloadFiles(remotePath, localPath, ssh) {
10
10
  // Create local directory if it doesn't exist
11
11
  await mkdir(localPath, { recursive: true });
12
12
  // Download files using scp
13
- await execute(`scp -r -p -O -P -o "StrictHostKeyChecking no" ${ssh.port} "${ssh.username}@${ssh.host}:${remotePath}" "${localPath}"`);
13
+ await execute(`scp -r -p -O -o "StrictHostKeyChecking no" -P ${ssh.port} "${ssh.username}@${ssh.host}:${remotePath}" "${localPath}"`);
14
14
  }
15
15
  catch (error) {
16
16
  console.log(`Failed to download ${remotePath}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atomicsmash/cli",
3
- "version": "9.0.0-beta.10",
3
+ "version": "9.0.0-beta.12",
4
4
  "description": "A collection of CLI tools by Atomic Smash.",
5
5
  "keywords": [],
6
6
  "homepage": "https://www.atomicsmash.co.uk/",