@keywaysh/cli 0.1.7 → 0.1.8
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 +46 -13
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -101,7 +101,7 @@ var INTERNAL_POSTHOG_HOST = "https://eu.i.posthog.com";
|
|
|
101
101
|
// package.json
|
|
102
102
|
var package_default = {
|
|
103
103
|
name: "@keywaysh/cli",
|
|
104
|
-
version: "0.1.
|
|
104
|
+
version: "0.1.8",
|
|
105
105
|
description: "One link to all your secrets",
|
|
106
106
|
type: "module",
|
|
107
107
|
bin: {
|
|
@@ -2175,6 +2175,9 @@ function displayDiffSummary(diff, providerName) {
|
|
|
2175
2175
|
}
|
|
2176
2176
|
console.log("");
|
|
2177
2177
|
}
|
|
2178
|
+
function getProjectDisplayName(project) {
|
|
2179
|
+
return project.serviceName || project.name;
|
|
2180
|
+
}
|
|
2178
2181
|
function findMatchingProject(projects, repoFullName) {
|
|
2179
2182
|
const repoFullNameLower = repoFullName.toLowerCase();
|
|
2180
2183
|
const repoName = repoFullName.split("/")[1]?.toLowerCase();
|
|
@@ -2211,17 +2214,18 @@ function projectMatchesRepo(project, repoFullName) {
|
|
|
2211
2214
|
async function promptProjectSelection(projects, repoFullName) {
|
|
2212
2215
|
const repoName = repoFullName.split("/")[1]?.toLowerCase() || "";
|
|
2213
2216
|
const choices = projects.map((p) => {
|
|
2214
|
-
|
|
2217
|
+
const displayName = getProjectDisplayName(p);
|
|
2218
|
+
let title = displayName;
|
|
2215
2219
|
const badges = [];
|
|
2216
2220
|
if (p.linkedRepo?.toLowerCase() === repoFullName.toLowerCase()) {
|
|
2217
2221
|
badges.push(pc10.green("\u2190 linked"));
|
|
2218
|
-
} else if (p.name.toLowerCase() === repoName) {
|
|
2222
|
+
} else if (p.name.toLowerCase() === repoName || p.serviceName?.toLowerCase() === repoName) {
|
|
2219
2223
|
badges.push(pc10.green("\u2190 same name"));
|
|
2220
2224
|
} else if (p.linkedRepo) {
|
|
2221
2225
|
badges.push(pc10.gray(`\u2192 ${p.linkedRepo}`));
|
|
2222
2226
|
}
|
|
2223
2227
|
if (badges.length > 0) {
|
|
2224
|
-
title = `${
|
|
2228
|
+
title = `${displayName} ${badges.join(" ")}`;
|
|
2225
2229
|
}
|
|
2226
2230
|
return { title, value: p.id };
|
|
2227
2231
|
});
|
|
@@ -2287,12 +2291,12 @@ Connection to ${providerDisplayName} failed.`));
|
|
|
2287
2291
|
let selectedProject;
|
|
2288
2292
|
if (options.project) {
|
|
2289
2293
|
const found = projects.find(
|
|
2290
|
-
(p) => p.id === options.project || p.name.toLowerCase() === options.project?.toLowerCase()
|
|
2294
|
+
(p) => p.id === options.project || p.name.toLowerCase() === options.project?.toLowerCase() || p.serviceName?.toLowerCase() === options.project?.toLowerCase()
|
|
2291
2295
|
);
|
|
2292
2296
|
if (!found) {
|
|
2293
2297
|
console.error(pc10.red(`Project not found: ${options.project}`));
|
|
2294
2298
|
console.log(pc10.gray("Available projects:"));
|
|
2295
|
-
projects.forEach((p) => console.log(pc10.gray(` - ${p
|
|
2299
|
+
projects.forEach((p) => console.log(pc10.gray(` - ${getProjectDisplayName(p)}`)));
|
|
2296
2300
|
process.exit(1);
|
|
2297
2301
|
}
|
|
2298
2302
|
selectedProject = found;
|
|
@@ -2302,7 +2306,7 @@ Connection to ${providerDisplayName} failed.`));
|
|
|
2302
2306
|
console.log(pc10.yellow("\u2502 \u26A0\uFE0F WARNING: Project does not match current repository \u2502"));
|
|
2303
2307
|
console.log(pc10.yellow("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518"));
|
|
2304
2308
|
console.log(pc10.yellow(` Current repo: ${repoFullName}`));
|
|
2305
|
-
console.log(pc10.yellow(` Selected project: ${selectedProject
|
|
2309
|
+
console.log(pc10.yellow(` Selected project: ${getProjectDisplayName(selectedProject)}`));
|
|
2306
2310
|
if (selectedProject.linkedRepo) {
|
|
2307
2311
|
console.log(pc10.yellow(` Project linked to: ${selectedProject.linkedRepo}`));
|
|
2308
2312
|
}
|
|
@@ -2313,13 +2317,14 @@ Connection to ${providerDisplayName} failed.`));
|
|
|
2313
2317
|
if (autoMatch && (autoMatch.matchType === "linked_repo" || autoMatch.matchType === "exact_name")) {
|
|
2314
2318
|
selectedProject = autoMatch.project;
|
|
2315
2319
|
const matchReason = autoMatch.matchType === "linked_repo" ? `linked to ${repoFullName}` : "exact name match";
|
|
2316
|
-
console.log(pc10.green(`\u2713 Auto-selected project: ${selectedProject
|
|
2320
|
+
console.log(pc10.green(`\u2713 Auto-selected project: ${getProjectDisplayName(selectedProject)} (${matchReason})`));
|
|
2317
2321
|
} else if (autoMatch && autoMatch.matchType === "partial_name") {
|
|
2318
|
-
|
|
2322
|
+
const partialDisplayName = getProjectDisplayName(autoMatch.project);
|
|
2323
|
+
console.log(pc10.yellow(`Detected project: ${partialDisplayName} (partial match)`));
|
|
2319
2324
|
const { useDetected } = await prompts7({
|
|
2320
2325
|
type: "confirm",
|
|
2321
2326
|
name: "useDetected",
|
|
2322
|
-
message: `Use ${
|
|
2327
|
+
message: `Use ${partialDisplayName}?`,
|
|
2323
2328
|
initial: true
|
|
2324
2329
|
});
|
|
2325
2330
|
if (useDetected) {
|
|
@@ -2335,7 +2340,7 @@ Connection to ${providerDisplayName} failed.`));
|
|
|
2335
2340
|
console.log(pc10.yellow("\u2502 \u26A0\uFE0F WARNING: Project does not match current repository \u2502"));
|
|
2336
2341
|
console.log(pc10.yellow("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518"));
|
|
2337
2342
|
console.log(pc10.yellow(` Current repo: ${repoFullName}`));
|
|
2338
|
-
console.log(pc10.yellow(` Only project: ${selectedProject
|
|
2343
|
+
console.log(pc10.yellow(` Only project: ${getProjectDisplayName(selectedProject)}`));
|
|
2339
2344
|
if (selectedProject.linkedRepo) {
|
|
2340
2345
|
console.log(pc10.yellow(` Project linked to: ${selectedProject.linkedRepo}`));
|
|
2341
2346
|
}
|
|
@@ -2366,7 +2371,7 @@ Connection to ${providerDisplayName} failed.`));
|
|
|
2366
2371
|
console.log(pc10.yellow("\u2502 \u26A0\uFE0F WARNING: You selected a different project \u2502"));
|
|
2367
2372
|
console.log(pc10.yellow("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518"));
|
|
2368
2373
|
console.log(pc10.yellow(` Current repo: ${repoFullName}`));
|
|
2369
|
-
console.log(pc10.yellow(` Selected project: ${selectedProject
|
|
2374
|
+
console.log(pc10.yellow(` Selected project: ${getProjectDisplayName(selectedProject)}`));
|
|
2370
2375
|
if (selectedProject.linkedRepo) {
|
|
2371
2376
|
console.log(pc10.yellow(` Project linked to: ${selectedProject.linkedRepo}`));
|
|
2372
2377
|
}
|
|
@@ -2405,7 +2410,35 @@ Connection to ${providerDisplayName} failed.`));
|
|
|
2405
2410
|
}
|
|
2406
2411
|
keywayEnv = selectedEnv;
|
|
2407
2412
|
if (!options.providerEnv) {
|
|
2408
|
-
|
|
2413
|
+
if (selectedProject.environments && selectedProject.environments.length > 0) {
|
|
2414
|
+
const mappedEnv = mapToProviderEnvironment(provider, keywayEnv);
|
|
2415
|
+
const envExists = selectedProject.environments.some(
|
|
2416
|
+
(e) => e.toLowerCase() === mappedEnv.toLowerCase()
|
|
2417
|
+
);
|
|
2418
|
+
if (envExists) {
|
|
2419
|
+
providerEnv = mappedEnv;
|
|
2420
|
+
} else if (selectedProject.environments.length === 1) {
|
|
2421
|
+
providerEnv = selectedProject.environments[0];
|
|
2422
|
+
console.log(pc10.gray(`Using ${providerName} environment: ${providerEnv}`));
|
|
2423
|
+
} else {
|
|
2424
|
+
const { selectedProviderEnv } = await prompts7({
|
|
2425
|
+
type: "select",
|
|
2426
|
+
name: "selectedProviderEnv",
|
|
2427
|
+
message: `${providerName} environment:`,
|
|
2428
|
+
choices: selectedProject.environments.map((e) => ({ title: e, value: e })),
|
|
2429
|
+
initial: Math.max(0, selectedProject.environments.findIndex(
|
|
2430
|
+
(e) => e.toLowerCase() === "production"
|
|
2431
|
+
))
|
|
2432
|
+
});
|
|
2433
|
+
if (!selectedProviderEnv) {
|
|
2434
|
+
console.log(pc10.gray("Cancelled."));
|
|
2435
|
+
process.exit(0);
|
|
2436
|
+
}
|
|
2437
|
+
providerEnv = selectedProviderEnv;
|
|
2438
|
+
}
|
|
2439
|
+
} else {
|
|
2440
|
+
providerEnv = mapToProviderEnvironment(provider, keywayEnv);
|
|
2441
|
+
}
|
|
2409
2442
|
}
|
|
2410
2443
|
}
|
|
2411
2444
|
if (needsDirectionPrompt) {
|