@rpcbase/cli 0.119.0 → 0.120.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.
- package/package.json +1 -1
- package/src/cmd-deploy.js +53 -20
package/package.json
CHANGED
package/src/cmd-deploy.js
CHANGED
|
@@ -8,26 +8,65 @@ import validator from "validator"
|
|
|
8
8
|
import { purgeCloudflareCaches } from "./cloudflare-purge.js"
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
const
|
|
11
|
+
const baseExcludeList = [
|
|
12
|
+
".husky/",
|
|
13
|
+
".github/",
|
|
14
|
+
".git/",
|
|
15
|
+
".wireit/",
|
|
16
|
+
"coverage/",
|
|
17
|
+
"node_modules/",
|
|
18
|
+
"infrastructure/data/",
|
|
19
|
+
".gitignore",
|
|
20
|
+
"*.css.map",
|
|
21
|
+
// "*.env*",
|
|
22
|
+
// "*.js.map",
|
|
23
|
+
"*.md",
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
const detectComposeChanges = ({ keyPath, user, host, deployDir, log, extraExcludes = [] }) => {
|
|
12
28
|
const includeArgs = ["--include='*/'", "--include='*compose*.yml'", "--exclude='*'"]
|
|
29
|
+
const excludeArgs = baseExcludeList
|
|
30
|
+
.concat(extraExcludes)
|
|
31
|
+
.map((p) => `--exclude='${p}'`)
|
|
32
|
+
.join(" ")
|
|
13
33
|
|
|
34
|
+
// keep --delete so remote-only compose files show up as *deleting in dry-run; dropping it hides stale files
|
|
14
35
|
const rsyncCmd = [
|
|
15
|
-
"rsync -avzn --delete --itemize-changes",
|
|
36
|
+
"rsync -avzn --delete --itemize-changes --filter=':- .gitignore'",
|
|
16
37
|
includeArgs.join(" "),
|
|
38
|
+
excludeArgs,
|
|
17
39
|
`-e "ssh -i '${keyPath}' -o StrictHostKeyChecking=no"`,
|
|
18
40
|
".",
|
|
19
41
|
`${user}@${host}:~/apps/${deployDir}/`,
|
|
20
|
-
].join(" ")
|
|
42
|
+
].filter(Boolean).join(" ")
|
|
21
43
|
|
|
22
44
|
log(`Checking compose files (dry-run): ${rsyncCmd}`)
|
|
23
45
|
|
|
24
|
-
|
|
46
|
+
let out
|
|
47
|
+
try {
|
|
48
|
+
out = execSync(rsyncCmd, { stdio: "pipe" }).toString()
|
|
49
|
+
} catch (error) {
|
|
50
|
+
const allowedExitCodes = [23, 24]
|
|
51
|
+
if (allowedExitCodes.includes(error?.status) && error?.stdout) {
|
|
52
|
+
out = error.stdout.toString()
|
|
53
|
+
} else {
|
|
54
|
+
throw error
|
|
55
|
+
}
|
|
56
|
+
}
|
|
25
57
|
|
|
26
58
|
// rsync --itemize-changes prefixes change lines; any line that isn't a summary indicates a diff
|
|
27
59
|
const changeLines = out
|
|
28
60
|
.split("\n")
|
|
29
61
|
.map((line) => line.trim())
|
|
30
|
-
.filter((line) =>
|
|
62
|
+
.filter((line) => {
|
|
63
|
+
if (!line) return false
|
|
64
|
+
if (line.startsWith("sending ")) return false
|
|
65
|
+
if (line.startsWith("sent ")) return false
|
|
66
|
+
if (line.startsWith("total size")) return false
|
|
67
|
+
if (line.startsWith("receiving incremental file list")) return false
|
|
68
|
+
return true
|
|
69
|
+
})
|
|
31
70
|
|
|
32
71
|
const hasChanges = changeLines.length > 0
|
|
33
72
|
|
|
@@ -114,27 +153,21 @@ export const deploy = async (argv) => {
|
|
|
114
153
|
console.log(`${user}@${host}`, res)
|
|
115
154
|
await ssh(`mkdir -p ~/apps/${deployDir}`)
|
|
116
155
|
|
|
117
|
-
const { hasChanges: infrastructureChanged, output: infrastructureDiff } = detectComposeChanges({
|
|
156
|
+
const { hasChanges: infrastructureChanged, output: infrastructureDiff } = detectComposeChanges({
|
|
157
|
+
keyPath,
|
|
158
|
+
user,
|
|
159
|
+
host,
|
|
160
|
+
deployDir,
|
|
161
|
+
log,
|
|
162
|
+
extraExcludes: argv.ignore || [],
|
|
163
|
+
})
|
|
118
164
|
|
|
119
165
|
if (infrastructureChanged) {
|
|
120
166
|
console.log("Infrastructure compose files differ between local and remote (info only; deploy proceeds).")
|
|
121
167
|
if (argv.verbose) console.log(infrastructureDiff)
|
|
122
168
|
}
|
|
123
169
|
|
|
124
|
-
const excludeList =
|
|
125
|
-
".husky/",
|
|
126
|
-
".github/",
|
|
127
|
-
".git/",
|
|
128
|
-
".wireit/",
|
|
129
|
-
"coverage/",
|
|
130
|
-
"node_modules/",
|
|
131
|
-
"infrastructure/data/",
|
|
132
|
-
".gitignore",
|
|
133
|
-
"*.css.map",
|
|
134
|
-
// "*.env*",
|
|
135
|
-
// "*.js.map",
|
|
136
|
-
"*.md",
|
|
137
|
-
].concat(argv.ignore)
|
|
170
|
+
const excludeList = baseExcludeList.concat(argv.ignore)
|
|
138
171
|
|
|
139
172
|
|
|
140
173
|
const excludeArgs = excludeList.map((p) => `--exclude='${p}'`).join(" ")
|