@rpcbase/cli 0.118.0 → 0.119.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/cmd-deploy.js +34 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpcbase/cli",
3
- "version": "0.118.0",
3
+ "version": "0.119.0",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "bin": {
package/src/cmd-deploy.js CHANGED
@@ -8,6 +8,33 @@ import validator from "validator"
8
8
  import { purgeCloudflareCaches } from "./cloudflare-purge.js"
9
9
 
10
10
 
11
+ const detectComposeChanges = ({ keyPath, user, host, deployDir, log }) => {
12
+ const includeArgs = ["--include='*/'", "--include='*compose*.yml'", "--exclude='*'"]
13
+
14
+ const rsyncCmd = [
15
+ "rsync -avzn --delete --itemize-changes",
16
+ includeArgs.join(" "),
17
+ `-e "ssh -i '${keyPath}' -o StrictHostKeyChecking=no"`,
18
+ ".",
19
+ `${user}@${host}:~/apps/${deployDir}/`,
20
+ ].join(" ")
21
+
22
+ log(`Checking compose files (dry-run): ${rsyncCmd}`)
23
+
24
+ const out = execSync(rsyncCmd, { stdio: "pipe" }).toString()
25
+
26
+ // rsync --itemize-changes prefixes change lines; any line that isn't a summary indicates a diff
27
+ const changeLines = out
28
+ .split("\n")
29
+ .map((line) => line.trim())
30
+ .filter((line) => line && !line.startsWith("sending ") && !line.startsWith("sent ") && !line.startsWith("total size"))
31
+
32
+ const hasChanges = changeLines.length > 0
33
+
34
+ return { hasChanges, output: out }
35
+ }
36
+
37
+
11
38
  export const deploy = async (argv) => {
12
39
  const log = (message) => {
13
40
  if (argv.verbose) console.log(message)
@@ -87,6 +114,13 @@ export const deploy = async (argv) => {
87
114
  console.log(`${user}@${host}`, res)
88
115
  await ssh(`mkdir -p ~/apps/${deployDir}`)
89
116
 
117
+ const { hasChanges: infrastructureChanged, output: infrastructureDiff } = detectComposeChanges({ keyPath, user, host, deployDir, log })
118
+
119
+ if (infrastructureChanged) {
120
+ console.log("Infrastructure compose files differ between local and remote (info only; deploy proceeds).")
121
+ if (argv.verbose) console.log(infrastructureDiff)
122
+ }
123
+
90
124
  const excludeList = [
91
125
  ".husky/",
92
126
  ".github/",