@atomicsmash/cli 9.0.0-beta.9 → 9.0.1-beta.0

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":"blocks.d.ts","sourceRoot":"","sources":["../../src/commands/blocks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAIjE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAwBhD,OAAO,OAAO,MAAM,SAAS,CAAC;AAM9B,eAAO,MAAM,OAAO,WAAW,CAAC;AAChC,eAAO,MAAM,QAAQ,8DACuC,CAAC;AAC7D,eAAO,MAAM,UAAU,uHAC8F,CAAC;AACtH,eAAO,MAAM,OAAO,GAAa,OAAO,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA0ClC,MAAM,EAAE;;;;;;;;;;;;;GAqB1B,CAAC;AAEF,wBAAsB,OAAO,CAC5B,IAAI,EAAE,kBAAkB,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,iBA4CrE;AAqJD,wBAAsB,wBAAwB,CAAC,EAC9C,SAAS,EACT,gBAAgB,GAChB,EAAE;IACF,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,MAAM,EAAE,CAAC;CAC3B,gCAmCA;AAED,wBAAgB,yBAAyB,CAAC,EACzC,SAAS,EACT,MAAM,GACN,EAAE;IACF,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CACb,MAAM,EACN;QACC,WAAW,EAAE,MAAM,CAAC;QACpB,SAAS,EAAE,SAAS,CAAC;KACrB,CACD,CAAC;CACF,uBAkCA;AAED,KAAK,SAAS,GAAG,aAAa,CAAC,KAAK,EAAE,KAAK,CA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AS,CAAC;KACrB,CACD,CAAC;CACF,uBAkCA;AAED,KAAK,SAAS,GAAG,aAAa,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AAE7C,wBAAsB,iBAAiB,CACtC,SAAS,EAAE,MAAM,EACjB,aAAa,EAAE,MAAM,EAAE;iBAUqB,MAAM;eAAa,SAAS;IAuBxE;AAED,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,SAAS,6EAW5D;AAED,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,SAAS,0EAW3D"}
@@ -165,6 +165,9 @@ async function runCommand({ srcFolder, distFolder, tsConfigLocation, postcssConf
165
165
  mode: isProduction ? "production" : "development",
166
166
  node: { global: false },
167
167
  });
168
+ if (!compiler) {
169
+ throw new Error("Failed to initialise compiler.");
170
+ }
168
171
  if (isWatch) {
169
172
  console.log("The blocks command is now deprecated. " + deprecated);
170
173
  const watching = compiler.watch({
@@ -175,7 +178,7 @@ async function runCommand({ srcFolder, distFolder, tsConfigLocation, postcssConf
175
178
  if (error) {
176
179
  console.error(error.stack ?? error);
177
180
  process.exitCode = 1;
178
- watching.close((closeError) => {
181
+ watching?.close((closeError) => {
179
182
  console.error(closeError);
180
183
  });
181
184
  }
@@ -190,7 +193,7 @@ async function runCommand({ srcFolder, distFolder, tsConfigLocation, postcssConf
190
193
  }
191
194
  });
192
195
  process.on("SIGINT", function () {
193
- watching.close((closeError) => {
196
+ watching?.close((closeError) => {
194
197
  console.log("The blocks command is now deprecated. " + deprecated);
195
198
  console.error(closeError);
196
199
  });
@@ -198,8 +201,8 @@ async function runCommand({ srcFolder, distFolder, tsConfigLocation, postcssConf
198
201
  }
199
202
  else {
200
203
  const stopRunningMessage = startRunningMessage("Building blocks");
201
- compiler.run(async (error, stats) => {
202
- await stopRunningMessage();
204
+ compiler.run((error, stats) => {
205
+ void stopRunningMessage();
203
206
  if (error) {
204
207
  console.error(error);
205
208
  process.exitCode = 1;
@@ -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,kBA+J5B"}
@@ -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,12 +133,14 @@ 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");
99
140
  if (failedCleanups.length > 0) {
100
141
  console.warn(`Warning: Failed to delete ${failedCleanups.length} temporary file(s). You may need to clean them up manually.`);
101
142
  }
143
+ process.exitCode = 1;
102
144
  });
103
145
  })();
104
146
  }
@@ -1 +1 @@
1
- {"version":3,"file":"pull-media.d.ts","sourceRoot":"","sources":["../../src/commands/pull-media.ts"],"names":[],"mappings":"AAmCA,eAAO,MAAM,OAAO,eAAe,CAAC;AACpC,eAAO,MAAM,QAAQ,gDAAgD,CAAC;AACtE,wBAAsB,OAAO,kBA4E5B"}
1
+ {"version":3,"file":"pull-media.d.ts","sourceRoot":"","sources":["../../src/commands/pull-media.ts"],"names":[],"mappings":"AAmCA,eAAO,MAAM,OAAO,eAAe,CAAC;AACpC,eAAO,MAAM,QAAQ,gDAAgD,CAAC;AACtE,wBAAsB,OAAO,kBA6E5B"}
@@ -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}`);
@@ -94,6 +94,7 @@ export async function handler() {
94
94
  .catch(async () => {
95
95
  await stopRunningMessage();
96
96
  console.log("There was an error downloading the media, see the message above.");
97
+ process.exitCode = 1;
97
98
  });
98
99
  }
99
100
  }
@@ -1 +1 @@
1
- {"version":3,"file":"setup-database.d.ts","sourceRoot":"","sources":["../../src/commands/setup-database.ts"],"names":[],"mappings":"AAQA,OAAO,eAAe,CAAC;AAEvB,eAAO,MAAM,OAAO,mBAAmB,CAAC;AACxC,eAAO,MAAM,QAAQ,mEAC4C,CAAC;AAClE,wBAAsB,OAAO,kBAsF5B"}
1
+ {"version":3,"file":"setup-database.d.ts","sourceRoot":"","sources":["../../src/commands/setup-database.ts"],"names":[],"mappings":"AAQA,OAAO,eAAe,CAAC;AAEvB,eAAO,MAAM,OAAO,mBAAmB,CAAC;AACxC,eAAO,MAAM,QAAQ,mEAC4C,CAAC;AAClE,wBAAsB,OAAO,kBAuF5B"}
@@ -55,6 +55,7 @@ export async function handler() {
55
55
  }
56
56
  else {
57
57
  console.error(error);
58
+ process.exitCode = 1;
58
59
  }
59
60
  });
60
61
  }
@@ -1 +1 @@
1
- {"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/commands/setup.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,OAAO,UAAU,CAAC;AAC/B,eAAO,MAAM,QAAQ,kDAAkD,CAAC;AACxE,wBAAsB,OAAO,kBAwM5B"}
1
+ {"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/commands/setup.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,OAAO,UAAU,CAAC;AAC/B,eAAO,MAAM,QAAQ,kDAAkD,CAAC;AACxE,wBAAsB,OAAO,kBA+P5B"}
@@ -1,6 +1,6 @@
1
1
  import { exec } from "node:child_process";
2
2
  import { existsSync } from "node:fs";
3
- import { constants, copyFile } from "node:fs/promises";
3
+ import { constants, copyFile, unlink as deleteFile, mkdir, } from "node:fs/promises";
4
4
  import { resolve } from "node:path";
5
5
  import { performance } from "node:perf_hooks";
6
6
  import { promisify } from "node:util";
@@ -29,20 +29,35 @@ export async function handler() {
29
29
  ...(shouldInstallAndBuildOnly
30
30
  ? []
31
31
  : [
32
- copyFile(".env.example", ".env", constants.COPYFILE_EXCL)
33
- .then(() => {
34
- console.log(`.env.example file copied to .env. (${convertMeasureToPrettyString(performance.measure("Copy env file", "Start"))})`);
35
- })
36
- .catch((error) => {
37
- if (error instanceof Error &&
38
- "code" in error &&
39
- error.code === "EEXIST") {
40
- console.log(`Didn't copy .env file because one already exists. (${convertMeasureToPrettyString(performance.measure("Copy env file", "Start"))})`);
41
- return;
32
+ (async () => {
33
+ if (existsSync(".env.example")) {
34
+ if (existsSync(".config/environments/.env.dev")) {
35
+ throw new Error("Both .env.example and .config/environments/.env.dev files found. Please copy values from the .env.example to the .config/environments/.env.dev file and then delete the .env.example file.");
36
+ }
37
+ else {
38
+ console.log("Moving .env.example to .config/environments/.env.dev");
39
+ if (!existsSync(".config/environments")) {
40
+ await mkdir(".config/environments", { recursive: true });
41
+ }
42
+ await copyFile(".env.example", ".config/environments/.env.dev", constants.COPYFILE_EXCL);
43
+ await deleteFile(".env.example");
44
+ }
42
45
  }
43
- console.error(error);
44
- throw new Error("Failed to copy .env file.");
45
- }),
46
+ await copyFile(".config/environments/.env.dev", ".env", constants.COPYFILE_EXCL)
47
+ .then(() => {
48
+ console.log(`.config/environments/.env.dev file copied to .env. (${convertMeasureToPrettyString(performance.measure("Copy env file", "Start"))})`);
49
+ })
50
+ .catch((error) => {
51
+ if (error instanceof Error &&
52
+ "code" in error &&
53
+ error.code === "EEXIST") {
54
+ console.log(`Didn't copy .env file because one already exists. (${convertMeasureToPrettyString(performance.measure("Copy env file", "Start"))})`);
55
+ return;
56
+ }
57
+ console.error(error);
58
+ throw new Error("Failed to copy .env file.");
59
+ });
60
+ })(),
46
61
  (async () => {
47
62
  if (await execute(`herd --version`)
48
63
  .then(() => true)
@@ -53,11 +68,29 @@ export async function handler() {
53
68
  }
54
69
  await execute(`herd init`)
55
70
  .then(() => {
56
- console.log(`Herd is linked, secured and isolated. (${convertMeasureToPrettyString(performance.measure("herd-or-valet", "Start"))})`);
71
+ performance.mark("herd init done");
72
+ console.log(`Herd is configured. (${convertMeasureToPrettyString(performance.measure("herd-or-valet", "Start"))})`);
73
+ })
74
+ .catch((error) => {
75
+ console.error(error);
76
+ throw new Error("Failed to configure the site using Herd.");
77
+ });
78
+ await execute(`herd link ${projectName} --secure`)
79
+ .then(() => {
80
+ performance.mark("herd link done");
81
+ console.log(`Herd is linked and secured. (${convertMeasureToPrettyString(performance.measure("herd link", "herd init done"))})`);
82
+ })
83
+ .catch((error) => {
84
+ console.error(error);
85
+ throw new Error("Failed to link the site using Herd.");
86
+ });
87
+ await execute(`herd isolate`)
88
+ .then(() => {
89
+ console.log(`Herd is isolated. (${convertMeasureToPrettyString(performance.measure("herd isolate", "herd link done"))})`);
57
90
  })
58
91
  .catch((error) => {
59
92
  console.error(error);
60
- throw new Error("Failed to link the site using herd.");
93
+ throw new Error("Failed to isolate the site using Herd.");
61
94
  });
62
95
  }
63
96
  else if (await execute(`valet --version`)
@@ -141,6 +174,9 @@ export async function handler() {
141
174
  else {
142
175
  console.log(`Setup is complete. ${convertMeasureToPrettyString(performance.measure("everything", "Start"))}`);
143
176
  }
177
+ }).catch((error) => {
178
+ console.error(error);
179
+ process.exitCode = 1;
144
180
  });
145
181
  }
146
182
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atomicsmash/cli",
3
- "version": "9.0.0-beta.9",
3
+ "version": "9.0.1-beta.0",
4
4
  "description": "A collection of CLI tools by Atomic Smash.",
5
5
  "keywords": [],
6
6
  "homepage": "https://www.atomicsmash.co.uk/",
@@ -42,44 +42,44 @@
42
42
  "dependencies": {
43
43
  "@atomicsmash/date-php": "^2.1.0",
44
44
  "@pmmmwh/react-refresh-webpack-plugin": "^0.5.17",
45
- "@wordpress/babel-preset-default": "^8.27.0",
46
- "@wordpress/dependency-extraction-webpack-plugin": "^6.27.0",
47
- "@wordpress/postcss-plugins-preset": "^5.27.0",
45
+ "@wordpress/babel-preset-default": "^8.32.0",
46
+ "@wordpress/dependency-extraction-webpack-plugin": "^6.32.0",
47
+ "@wordpress/postcss-plugins-preset": "^5.32.0",
48
48
  "autoprefixer": "^10.4.21",
49
49
  "babel-loader": "^9.2.1",
50
- "browserslist": "^4.25.1",
50
+ "browserslist": "^4.26.3",
51
51
  "chalk": "^4.1.2",
52
52
  "clean-webpack-plugin": "^4.0.0",
53
53
  "copy-webpack-plugin": "^12.0.2",
54
54
  "cosmiconfig": "^9.0.0",
55
55
  "css-loader": "^7.1.2",
56
- "cssnano": "^7.1.0",
56
+ "cssnano": "^7.1.1",
57
57
  "fast-glob": "^3.3.3",
58
58
  "glob-promise": "^6.0.7",
59
- "mini-css-extract-plugin": "^2.9.2",
59
+ "mini-css-extract-plugin": "^2.9.4",
60
60
  "path": "^0.12.7",
61
61
  "postcss": "^8.5.6",
62
62
  "postcss-load-config": "^6.0.1",
63
- "postcss-loader": "^8.1.1",
63
+ "postcss-loader": "^8.2.0",
64
64
  "react-refresh": "^0.14.2",
65
65
  "read-pkg-up": "^7.0.1",
66
66
  "rtlcss-webpack-plugin": "^4.0.7",
67
- "sass": "^1.89.2",
67
+ "sass": "^1.93.2",
68
68
  "sass-loader": "^16.0.5",
69
- "schema-utils": "^4.3.2",
69
+ "schema-utils": "^4.3.3",
70
70
  "source-map-loader": "^3.0.2",
71
71
  "svg-sprite": "^2.0.4",
72
72
  "terser-webpack-plugin": "^5.3.14",
73
73
  "tsconfig-paths": "^4.2.0",
74
74
  "tsconfig-paths-webpack-plugin": "^4.2.0",
75
- "tsx": "^4.20.3",
75
+ "tsx": "^4.20.6",
76
76
  "vinyl": "^3.0.1",
77
- "webpack": "^5.100.2",
77
+ "webpack": "^5.102.1",
78
78
  "webpack-bundle-analyzer": "^4.10.2",
79
79
  "yargs": "^18.0.0"
80
80
  },
81
81
  "devDependencies": {
82
- "@atomicsmash/blocks-helpers": "^7.1.0-beta.1",
82
+ "@atomicsmash/blocks-helpers": "^7.1.0",
83
83
  "@types/glob": "^8.1.0",
84
84
  "@types/svg-sprite": "^0.0.39",
85
85
  "@types/vinyl": "^2.0.12",
@@ -88,6 +88,6 @@
88
88
  },
89
89
  "peerDependencies": {
90
90
  "dotenv": "^16.6.1",
91
- "typescript": ">=4.9.5"
91
+ "typescript": "^5.8.3"
92
92
  }
93
93
  }