@spfn/cli 0.0.6 → 0.0.7
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/login.js +48 -37
- package/package.json +1 -1
package/lib/login.js
CHANGED
@@ -47,43 +47,54 @@ function installGitCredentials(
|
|
47
47
|
console.log(`✔️ Stored credentials for git.superfunctions.ai/${repoPath}`);
|
48
48
|
}
|
49
49
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
50
|
+
/**
|
51
|
+
* 시스템 전역에 SF_USERNAME, SF_ACCESS_TOKEN 환경변수를 등록합니다.
|
52
|
+
* - Windows: setx 명령 사용
|
53
|
+
* - macOS/Linux: 쉘 RC 파일(~/.zshrc or ~/.bash_profile)에 export 라인 추가
|
54
|
+
*/
|
55
|
+
function persistEnvVars(username, token) {
|
56
|
+
try {
|
57
|
+
if (process.platform === "win32") {
|
58
|
+
// Windows 환경변수 등록(기존 값이 있으면 덮어쓰기)
|
59
|
+
execSync(`setx SF_USERNAME "${username}"`);
|
60
|
+
execSync(`setx SF_ACCESS_TOKEN "${token}"`);
|
61
|
+
console.log("✔️ Windows 환경변수에 SF_USERNAME, SF_ACCESS_TOKEN 등록/갱신 완료");
|
62
|
+
} else {
|
63
|
+
// macOS/Linux: 사용자 쉘 RC 파일 선택
|
64
|
+
const shell = process.env.SHELL || "";
|
65
|
+
const rcFile = shell.includes("zsh") ? ".zshrc" : ".bash_profile";
|
66
|
+
const rcPath = path.join(os.homedir(), rcFile);
|
67
|
+
|
68
|
+
// RC 파일 내용을 읽어서 기존 export 라인 제거
|
69
|
+
const existing = fs.existsSync(rcPath)
|
70
|
+
? fs.readFileSync(rcPath, "utf8").split(/\r?\n/)
|
71
|
+
: [];
|
72
|
+
|
73
|
+
const filtered = existing.filter(
|
74
|
+
(line) =>
|
75
|
+
!/^export\s+SF_USERNAME=/.test(line) &&
|
76
|
+
!/^export\s+SF_ACCESS_TOKEN=/.test(line) &&
|
77
|
+
!/^# Superfunctions CLI 로그인/.test(line)
|
78
|
+
);
|
79
|
+
|
80
|
+
// 새 export 라인 추가
|
81
|
+
const exportBlock = [
|
82
|
+
"",
|
83
|
+
"# Superfunctions CLI 로그인",
|
84
|
+
`export SF_USERNAME="${username}"`,
|
85
|
+
`export SF_ACCESS_TOKEN="${token}"`,
|
86
|
+
""
|
87
|
+
];
|
88
|
+
|
89
|
+
const updated = filtered.concat(exportBlock);
|
90
|
+
fs.writeFileSync(rcPath, updated.join(os.EOL), { encoding: "utf8" });
|
91
|
+
|
92
|
+
console.log(`✔️ ${rcFile}에 SF_USERNAME, SF_ACCESS_TOKEN export 추가/갱신 완료`);
|
93
|
+
console.log(` 적용하려면: source ~/${rcFile} 또는 터미널 재시작`);
|
94
|
+
}
|
95
|
+
} catch (e) {
|
96
|
+
console.error("❌ 전역 환경변수 등록/갱신 실패:", e);
|
63
97
|
}
|
64
|
-
|
65
|
-
const block = [
|
66
|
-
start,
|
67
|
-
"allprojects {",
|
68
|
-
" repositories {",
|
69
|
-
" maven {",
|
70
|
-
" name = 'Gitea'",
|
71
|
-
" url = uri('https://git.superfunctions.ai/api/packages/sf/maven')",
|
72
|
-
" credentials {",
|
73
|
-
` username = '${username}'`,
|
74
|
-
` password = '${token}'`,
|
75
|
-
" }",
|
76
|
-
" }",
|
77
|
-
" mavenCentral()",
|
78
|
-
" }",
|
79
|
-
"}",
|
80
|
-
end,
|
81
|
-
""
|
82
|
-
].join("\n");
|
83
|
-
|
84
|
-
fs.mkdirSync(dir, { recursive: true });
|
85
|
-
fs.writeFileSync(file, content + "\n" + block, "utf-8");
|
86
|
-
console.log(`✔️ Merged Gradle init script: ${file}`);
|
87
98
|
}
|
88
99
|
|
89
100
|
export function login()
|
@@ -118,7 +129,7 @@ export function login()
|
|
118
129
|
return;
|
119
130
|
}
|
120
131
|
|
121
|
-
|
132
|
+
persistEnvVars(username, token);
|
122
133
|
|
123
134
|
// npm registry 설정 (생략)
|
124
135
|
try
|