nvicode 0.1.17 → 0.1.18
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/dist/cli.js +13 -10
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -173,6 +173,13 @@ const promptApiKeyUpdate = async (config, provider) => {
|
|
|
173
173
|
? { openrouterApiKey: nextKey, nvidiaApiKey: config.nvidiaApiKey }
|
|
174
174
|
: { nvidiaApiKey: nextKey, openrouterApiKey: config.openrouterApiKey };
|
|
175
175
|
};
|
|
176
|
+
const promptRequiredApiKey = async (providerLabel) => {
|
|
177
|
+
const apiKey = await question(`${providerLabel} API key: `);
|
|
178
|
+
if (!apiKey) {
|
|
179
|
+
throw new Error(`${providerLabel} API key is required.`);
|
|
180
|
+
}
|
|
181
|
+
return apiKey;
|
|
182
|
+
};
|
|
176
183
|
const ensureConfigured = async () => {
|
|
177
184
|
let config = await loadConfig();
|
|
178
185
|
let changed = false;
|
|
@@ -183,10 +190,8 @@ const ensureConfigured = async () => {
|
|
|
183
190
|
if (!process.stdin.isTTY) {
|
|
184
191
|
throw new Error(`Missing ${providerLabel} API key. Run \`nvicode auth\` first.`);
|
|
185
192
|
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
throw new Error(`${providerLabel} API key is required.`);
|
|
189
|
-
}
|
|
193
|
+
console.error(`Missing ${providerLabel} API key. Enter it now to continue.`);
|
|
194
|
+
const apiKey = await promptRequiredApiKey(providerLabel);
|
|
190
195
|
config = {
|
|
191
196
|
...config,
|
|
192
197
|
...(config.provider === "openrouter"
|
|
@@ -194,6 +199,7 @@ const ensureConfigured = async () => {
|
|
|
194
199
|
: { nvidiaApiKey: apiKey }),
|
|
195
200
|
};
|
|
196
201
|
changed = true;
|
|
202
|
+
console.error(`Saved ${providerLabel} API key. Continuing launch.`);
|
|
197
203
|
}
|
|
198
204
|
if (!activeModel) {
|
|
199
205
|
const [first] = await getRecommendedModels(config.provider, getActiveApiKey(config));
|
|
@@ -214,16 +220,13 @@ const runAuth = async () => {
|
|
|
214
220
|
const config = await loadConfig();
|
|
215
221
|
const providerLabel = getProviderLabel(config.provider);
|
|
216
222
|
const currentApiKey = getActiveApiKey(config);
|
|
217
|
-
const apiKey =
|
|
218
|
-
? `${providerLabel} API key (leave blank to keep current): `
|
|
219
|
-
:
|
|
223
|
+
const apiKey = currentApiKey
|
|
224
|
+
? await question(`${providerLabel} API key (leave blank to keep current): `)
|
|
225
|
+
: await promptRequiredApiKey(providerLabel);
|
|
220
226
|
if (!apiKey && currentApiKey) {
|
|
221
227
|
console.log(`Kept existing ${providerLabel} API key.`);
|
|
222
228
|
return;
|
|
223
229
|
}
|
|
224
|
-
if (!apiKey) {
|
|
225
|
-
throw new Error(`${providerLabel} API key is required.`);
|
|
226
|
-
}
|
|
227
230
|
await saveConfig({
|
|
228
231
|
...config,
|
|
229
232
|
...(config.provider === "openrouter"
|