@lazycatcloud/lzc-cli 1.2.32 → 1.2.33

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,8 +1,7 @@
1
1
  import { spawn, spawnSync } from "child_process"
2
2
  import fs from "node:fs"
3
3
  import shellApi from "../shellapi.js"
4
- import inquirer from "inquirer"
5
- import { isDebugMode, resolveDomain, sleep } from "../utils.js"
4
+ import { isDebugMode, resolveDomain, sleep, sshCmd } from "../utils.js"
6
5
  import logger from "loglevel"
7
6
 
8
7
  export class DebugBridge {
@@ -10,13 +9,17 @@ export class DebugBridge {
10
9
  this.uid = shellApi.uid
11
10
  this.boxname = shellApi.boxname
12
11
  this.domain = `dev.${this.boxname}.heiyu.space`
13
- this.sshCmd = `ssh ${isDebugMode() ? "-vv" : ""} -p 22222 box@${this.domain}`
12
+ this.sshCmd = sshCmd(
13
+ `${isDebugMode() ? "-vv" : ""}`,
14
+ "-p 22222",
15
+ `box@${this.domain}`
16
+ )
14
17
  }
15
18
 
16
19
  async common(cmd, args) {
17
20
  const resolvedIp = await resolveDomain(this.domain)
18
- const sshCmd = cmd.replace(this.domain, resolvedIp)
19
- const ssh = spawnSync(sshCmd, args, {
21
+ const resolvedCmd = cmd.replace(this.domain, resolvedIp)
22
+ const ssh = spawnSync(resolvedCmd, args, {
20
23
  shell: true,
21
24
  encoding: "utf-8",
22
25
  stdio: ["pipe", "pipe", "pipe"]
@@ -25,7 +28,7 @@ export class DebugBridge {
25
28
  ssh.status == 0
26
29
  ? resolve(ssh.stdout)
27
30
  : reject(
28
- `执行命令 ${sshCmd} ${args.join(" ")} 出错\n${ssh.stderr ?? ""}`
31
+ `执行命令 ${resolvedCmd} ${args.join(" ")} 出错\n${ssh.stderr ?? ""}`
29
32
  )
30
33
  })
31
34
  }
@@ -39,7 +42,7 @@ export class DebugBridge {
39
42
  const stream = fs.createReadStream(lpkPath)
40
43
  const resolvedIp = await resolveDomain(this.domain)
41
44
  const ssh = spawn(
42
- `ssh -p 22222 box@${resolvedIp}`,
45
+ sshCmd("-p 22222", `box@${resolvedIp}`),
43
46
  [`install --uid ${this.uid} --pkgId ${pkgId}`],
44
47
  {
45
48
  shell: true,
@@ -61,7 +64,9 @@ export class DebugBridge {
61
64
 
62
65
  async sshCopyId() {
63
66
  const resolvedIp = await resolveDomain(this.domain)
64
- return this.common(`ssh-copy-id`, [`-f -p 22222 box@${resolvedIp}`])
67
+ return this.common(`ssh-copy-id`, [
68
+ `-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -f -p 22222 box@${resolvedIp}`
69
+ ])
65
70
  }
66
71
 
67
72
  async status(appId) {
@@ -85,7 +90,6 @@ export class DebugBridge {
85
90
  }
86
91
 
87
92
  async devshell(appId, isUserApp, onconnect = null) {
88
- const resolvedIp = await resolveDomain(this.domain)
89
93
  let waiting = true
90
94
  while (waiting) {
91
95
  if (await this.isDevshell(appId)) {
@@ -96,8 +100,10 @@ export class DebugBridge {
96
100
  await sleep(100)
97
101
  }
98
102
 
103
+ const resolvedIp = await resolveDomain(this.domain)
104
+
99
105
  const stream = spawn(
100
- `ssh -p 22222 box@${resolvedIp}`,
106
+ sshCmd("-p 22222", `box@${resolvedIp}`),
101
107
  [
102
108
  "-t",
103
109
  "devshell",
@@ -127,8 +133,9 @@ export class DebugBridge {
127
133
  const tag = `debug.bridge/${label}`
128
134
  const resolvedIp = await resolveDomain(this.domain)
129
135
  const stream = fs.createReadStream(contextTar)
136
+
130
137
  const ssh = spawn(
131
- `ssh -p 22222 box@${resolvedIp}`,
138
+ sshCmd("-p 22222", `box@${resolvedIp}`),
132
139
  [`build --tag ${tag}`],
133
140
  {
134
141
  shell: true,
@@ -18,8 +18,7 @@ import {
18
18
  isUserApp,
19
19
  createTemplateFileCommon,
20
20
  isDebugMode,
21
- resolveDomain,
22
- sleep
21
+ resolveDomain
23
22
  } from "../utils.js"
24
23
  import os from "node:os"
25
24
  import commandExists from "command-exists"
@@ -412,8 +411,8 @@ class DevShell {
412
411
  const resolvedIp = await resolveDomain(`dev.${shellApi.boxname}.heiyu.space`);
413
412
  let rsh = [
414
413
  "ssh",
415
- "-J",
416
- `box@[${resolvedIp}]:22222`,
414
+ "-o",
415
+ `"ProxyCommand ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -q -W %h:%p -p 22222 box@${resolvedIp}"`,
417
416
  "-p",
418
417
  `22222`,
419
418
  "-o",
package/lib/utils.js CHANGED
@@ -464,3 +464,14 @@ export async function resolveDomain(domain) {
464
464
  throw new Error(`无法解析域名 ${domain}: ${error.message}`)
465
465
  }
466
466
  }
467
+
468
+ export function sshCmd(...args) {
469
+ const baseCommand = "ssh"
470
+ const defaultOptions = [
471
+ "-o StrictHostKeyChecking=no",
472
+ "-o UserKnownHostsFile=/dev/null",
473
+ "-q"
474
+ ]
475
+ const options = [...defaultOptions, ...args].join(" ")
476
+ return `${baseCommand} ${options}`
477
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lazycatcloud/lzc-cli",
3
- "version": "1.2.32",
3
+ "version": "1.2.33",
4
4
  "description": "lazycat cloud developer kit",
5
5
  "files": [
6
6
  "template",