@lazycatcloud/lzc-cli 1.1.0 → 1.1.1
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/lib/env.js +2 -3
- package/lib/key.js +6 -20
- package/lib/utils.js +1 -0
- package/package.json +1 -1
package/lib/env.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import fs from "fs";
|
|
3
3
|
import os from "os";
|
|
4
|
-
import { ensureDir, APP_CONFIG_FILE } from "./utils.js";
|
|
4
|
+
import { ensureDir, APP_CONFIG_FILE, GLOBAL_CONFIG_DIR } from "./utils.js";
|
|
5
5
|
|
|
6
6
|
const GLOBAL_CONFIG_NAME = "box-config.json";
|
|
7
7
|
|
|
@@ -22,8 +22,7 @@ class Env {
|
|
|
22
22
|
constructor(cwd) {
|
|
23
23
|
this.envPath = path.join(cwd, APP_CONFIG_FILE);
|
|
24
24
|
this.globalEnvPath = path.join(
|
|
25
|
-
|
|
26
|
-
".config/lazycat",
|
|
25
|
+
GLOBAL_CONFIG_DIR,
|
|
27
26
|
GLOBAL_CONFIG_NAME
|
|
28
27
|
);
|
|
29
28
|
this.load();
|
package/lib/key.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import inquirer from "inquirer";
|
|
2
2
|
import glob from "fast-glob";
|
|
3
3
|
import path from "path";
|
|
4
|
-
import os from "os";
|
|
5
4
|
import { Client } from "ssh2";
|
|
6
5
|
import process from "process";
|
|
7
6
|
import fs from "fs";
|
|
8
7
|
import execa from "execa";
|
|
9
8
|
import API from "./api.js";
|
|
9
|
+
import { GLOBAL_CONFIG_DIR } from "./utils.js";
|
|
10
10
|
|
|
11
11
|
const KEY_NAME = "lzc_box_key";
|
|
12
12
|
|
|
@@ -18,7 +18,7 @@ export default class Key {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
async generate() {
|
|
21
|
-
const privateKeyFile = path.join(
|
|
21
|
+
const privateKeyFile = path.join(GLOBAL_CONFIG_DIR, KEY_NAME);
|
|
22
22
|
await execa(
|
|
23
23
|
"ssh-keygen",
|
|
24
24
|
["-t", "ed25519", "-P", "", "-f", privateKeyFile],
|
|
@@ -85,28 +85,14 @@ export default class Key {
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
async getKeyPair() {
|
|
88
|
-
const results = await glob(path.join(
|
|
88
|
+
const results = await glob(path.join(GLOBAL_CONFIG_DIR, `/${KEY_NAME}*`));
|
|
89
89
|
if (results.length != 2) {
|
|
90
|
-
|
|
91
|
-
const answers = await inquirer.prompt([
|
|
92
|
-
{
|
|
93
|
-
name: "generate",
|
|
94
|
-
message: "未发现ssh秘钥, 是否生成?",
|
|
95
|
-
type: "confirm",
|
|
96
|
-
default: true,
|
|
97
|
-
},
|
|
98
|
-
]);
|
|
99
|
-
|
|
100
|
-
if (answers.generate) {
|
|
101
|
-
return await this.generate();
|
|
102
|
-
} else {
|
|
103
|
-
process.exit(1);
|
|
104
|
-
}
|
|
90
|
+
return await this.generate();
|
|
105
91
|
}
|
|
106
92
|
|
|
107
93
|
return {
|
|
108
|
-
private: path.join(
|
|
109
|
-
public: path.join(
|
|
94
|
+
private: path.join(GLOBAL_CONFIG_DIR, KEY_NAME),
|
|
95
|
+
public: path.join(GLOBAL_CONFIG_DIR, `${KEY_NAME}.pub`),
|
|
110
96
|
};
|
|
111
97
|
}
|
|
112
98
|
}
|
package/lib/utils.js
CHANGED
|
@@ -19,6 +19,7 @@ const META_MARK = "x-lazycat-app";
|
|
|
19
19
|
const APP_FOLDER = ".lazycat";
|
|
20
20
|
const APP_CONFIG_FILE = "app-config";
|
|
21
21
|
const APP_SDK_HOSTNAME = "box";
|
|
22
|
+
export const GLOBAL_CONFIG_DIR = path.join(os.homedir(), "/.config/lazycat")
|
|
22
23
|
|
|
23
24
|
export const envsubstr = async (templateContents, args) => {
|
|
24
25
|
const parse = await importDefault("envsub/js/envsub-parser.js");
|