@atomicsmash/cli 9.0.0-beta.10 → 9.0.0-beta.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.
@@ -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,kBA6J5B"}
@@ -13,6 +13,7 @@ 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_";
16
17
  const stagingUrl = process.env.STAGING_URL?.endsWith("/")
17
18
  ? process.env.STAGING_URL.slice(0, -1)
18
19
  : process.env.STAGING_URL;
@@ -37,8 +38,45 @@ export async function handler() {
37
38
  performance.mark("Start");
38
39
  await (async () => {
39
40
  const tmpFile = "/tmp/staging-database.sql";
41
+ const dbPrefixFile = "/tmp/db-prefix.txt";
40
42
  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}`)
43
+ const tablesToExclude = [
44
+ // WordFence
45
+ "wfauditevents",
46
+ "wfblockediplog",
47
+ "wfblocks7",
48
+ "wfconfig",
49
+ "wfcrawlers",
50
+ "wffilemods",
51
+ "wfhits",
52
+ "wfhoover",
53
+ "wfissues",
54
+ "wfknownfilelist",
55
+ "wflivetraffichuman",
56
+ "wflocs",
57
+ "wflogins",
58
+ "wfls_2fa_secrets",
59
+ "wfls_role_counts",
60
+ "wfls_settings",
61
+ "wfnotifications",
62
+ "wfpendingissues",
63
+ "wfreversecache",
64
+ "wfsecurityevents",
65
+ "wfsnipcache",
66
+ "wfstatus",
67
+ "wftrafficrates",
68
+ "wfwaffailures",
69
+ // WP All Import/Export
70
+ "pmxi_files",
71
+ "pmxi_geocoding",
72
+ "pmxi_hash",
73
+ "pmxi_history",
74
+ "pmxi_images",
75
+ "pmxi_imports",
76
+ "pmxi_posts",
77
+ "pmxi_templates",
78
+ ].map((tableName) => stagingDBPrefix + tableName);
79
+ await execute(`ssh -o "StrictHostKeyChecking no" ${stagingSSHUsername}@${stagingSSHHost} -p ${stagingSSHPort} "cd public/current && wp db export - --add-drop-table --exclude_tables=${tablesToExclude.join(",")}" > ${tmpFile}`)
42
80
  .then(async () => {
43
81
  await stopRunningMessage();
44
82
  console.log("Database downloaded.");
@@ -81,6 +119,7 @@ export async function handler() {
81
119
  const stopRunningMessage4 = startRunningMessage("Cleaning up");
82
120
  await Promise.allSettled([
83
121
  deleteFile(tmpFile),
122
+ deleteFile(dbPrefixFile),
84
123
  deleteFile(tmpFileProcessed),
85
124
  ]).then(async () => {
86
125
  await stopRunningMessage4();
@@ -93,6 +132,7 @@ export async function handler() {
93
132
  console.error("Error during database pull:", error);
94
133
  const cleanupResults = await Promise.allSettled([
95
134
  deleteFile(tmpFile),
135
+ deleteFile(dbPrefixFile),
96
136
  deleteFile(tmpFileProcessed),
97
137
  ]);
98
138
  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.11",
4
4
  "description": "A collection of CLI tools by Atomic Smash.",
5
5
  "keywords": [],
6
6
  "homepage": "https://www.atomicsmash.co.uk/",