@atomicsmash/cli 9.0.0-beta.8 → 9.0.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,CAAC,CA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AC;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,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}`);
@@ -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,kBAkM5B"}
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,kBA4P5B"}
@@ -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,33 +29,68 @@ 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
- if ((existsSync(resolve(process.cwd(), "herd.yaml")) ||
48
- existsSync(resolve(process.cwd(), "herd.yml"))) &&
49
- (await execute(`herd --version`)
50
- .then(() => true)
51
- .catch(() => false))) {
62
+ if (await execute(`herd --version`)
63
+ .then(() => true)
64
+ .catch(() => false)) {
65
+ if (!existsSync(resolve(process.cwd(), "herd.yaml")) &&
66
+ !existsSync(resolve(process.cwd(), "herd.yml"))) {
67
+ throw new Error("Herd is present on your machine, but the project is missing a herd.yaml file. Please do the initial setup by running herd init.");
68
+ }
52
69
  await execute(`herd init`)
53
70
  .then(() => {
54
- 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"))})`);
55
90
  })
56
91
  .catch((error) => {
57
92
  console.error(error);
58
- throw new Error("Failed to link the site using herd.");
93
+ throw new Error("Failed to isolate the site using Herd.");
59
94
  });
60
95
  }
61
96
  else if (await execute(`valet --version`)
@@ -71,7 +106,7 @@ export async function handler() {
71
106
  });
72
107
  }
73
108
  else {
74
- console.log(`Neither Herd nor Valet is available. Site has not been linked.`);
109
+ throw new Error(`Neither Herd nor Valet is present on your machine, check everything is installed correctly.`);
75
110
  }
76
111
  })(),
77
112
  ]),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atomicsmash/cli",
3
- "version": "9.0.0-beta.8",
3
+ "version": "9.0.0",
4
4
  "description": "A collection of CLI tools by Atomic Smash.",
5
5
  "keywords": [],
6
6
  "homepage": "https://www.atomicsmash.co.uk/",
@@ -42,43 +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
+ "cosmiconfig": "^9.0.0",
54
55
  "css-loader": "^7.1.2",
55
- "cssnano": "^7.1.0",
56
+ "cssnano": "^7.1.1",
56
57
  "fast-glob": "^3.3.3",
57
58
  "glob-promise": "^6.0.7",
58
- "mini-css-extract-plugin": "^2.9.2",
59
+ "mini-css-extract-plugin": "^2.9.4",
59
60
  "path": "^0.12.7",
60
61
  "postcss": "^8.5.6",
61
62
  "postcss-load-config": "^6.0.1",
62
- "postcss-loader": "^8.1.1",
63
+ "postcss-loader": "^8.2.0",
63
64
  "react-refresh": "^0.14.2",
64
65
  "read-pkg-up": "^7.0.1",
65
66
  "rtlcss-webpack-plugin": "^4.0.7",
66
- "sass": "^1.89.2",
67
+ "sass": "^1.93.2",
67
68
  "sass-loader": "^16.0.5",
68
- "schema-utils": "^4.3.2",
69
+ "schema-utils": "^4.3.3",
69
70
  "source-map-loader": "^3.0.2",
70
71
  "svg-sprite": "^2.0.4",
71
72
  "terser-webpack-plugin": "^5.3.14",
72
73
  "tsconfig-paths": "^4.2.0",
73
74
  "tsconfig-paths-webpack-plugin": "^4.2.0",
74
- "tsx": "^4.20.3",
75
+ "tsx": "^4.20.6",
75
76
  "vinyl": "^3.0.1",
76
- "webpack": "^5.100.2",
77
+ "webpack": "^5.102.1",
77
78
  "webpack-bundle-analyzer": "^4.10.2",
78
79
  "yargs": "^18.0.0"
79
80
  },
80
81
  "devDependencies": {
81
- "@atomicsmash/blocks-helpers": "^7.1.0-beta.1",
82
+ "@atomicsmash/blocks-helpers": "^7.1.0",
82
83
  "@types/glob": "^8.1.0",
83
84
  "@types/svg-sprite": "^0.0.39",
84
85
  "@types/vinyl": "^2.0.12",
@@ -86,6 +87,7 @@
86
87
  "type-fest": "^4.41.0"
87
88
  },
88
89
  "peerDependencies": {
89
- "dotenv": "^16.6.1"
90
+ "dotenv": "^16.6.1",
91
+ "typescript": "^5.8.3"
90
92
  }
91
93
  }