@spfn/cli 0.0.3 → 0.0.4

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/lib/login.js +24 -44
  2. package/package.json +1 -1
package/lib/login.js CHANGED
@@ -7,52 +7,32 @@ import { execSync } from "child_process";
7
7
 
8
8
  const PORT = 5678;
9
9
 
10
- function mergeNetrc(
11
- username,
12
- token
13
- )
14
- {
15
- const name = process.platform === "win32" ? "_netrc" : ".netrc";
16
- const file = path.join(os.homedir(), name);
17
- let lines = [];
18
-
19
- if (fs.existsSync(file))
20
- {
21
- lines = fs.readFileSync(file, "utf-8").split(/\r?\n/);
22
- const filtered = [];
23
- let skip = false;
24
- for (const l of lines)
25
- {
26
- if (l.trim().startsWith("machine git.superfunctions.ai"))
27
- {
28
- skip = true;
29
- }
30
- if (!skip)
31
- {
32
- filtered.push(l);
33
- }
34
- if (skip && l.trim() === "")
35
- {
36
- skip = false;
37
- }
38
- }
39
- lines = filtered;
10
+ function installGitCredentials(username, token) {
11
+ // 1) credential helper 설정
12
+ if (process.platform === "win32") {
13
+ // Git Credential Manager (Windows)
14
+ execSync("git config --global credential.helper manager-core");
15
+ } else {
16
+ // 단순 파일 저장소
17
+ execSync("git config --global credential.helper store");
40
18
  }
41
19
 
42
- lines.push(
43
- "",
44
- "machine git.superfunctions.ai",
45
- ` login ${username}`,
46
- ` password ${token}`,
47
- ""
48
- );
20
+ // 2) 승인 명령어로 크리덴셜 저장
21
+ // git credential approve 는 stdin으로 프로토콜/호스트/유저/패스워드를 받습니다.
22
+ const cred = [
23
+ "protocol=https",
24
+ "host=git.superfunctions.ai",
25
+ `username=${username}`,
26
+ `password=${token}`,
27
+ "" // 빈 줄로 끝내야 인풋 종료
28
+ ].join("\n");
49
29
 
50
- fs.writeFileSync(file, lines.join("\n"), "utf-8");
51
- if (process.platform !== "win32")
52
- {
53
- fs.chmodSync(file, 0o600);
54
- }
55
- console.log(`✔️ Merged netrc: ${file}`);
30
+ execSync("git credential approve", {
31
+ input: cred,
32
+ stdio: ["pipe", "ignore", "inherit"]
33
+ });
34
+
35
+ console.log("✔️ Git credentials stored via credential helper");
56
36
  }
57
37
 
58
38
  function mergeGradleInit()
@@ -149,7 +129,7 @@ export function login()
149
129
  console.error("❌ npm config set failed:", e);
150
130
  }
151
131
 
152
- mergeNetrc(username, token);
132
+ installGitCredentials(username, token);
153
133
 
154
134
  res.writeHead(200, { "Content-Type": "text/plain" });
155
135
  res.end("✅ Login successful! You can now close this window.");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spfn/cli",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "Superfunction CLI",
5
5
  "keywords": [
6
6
  "cli",