@keywaysh/cli 0.0.10 → 0.0.11
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 +28 -11
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -69,7 +69,7 @@ var INTERNAL_POSTHOG_HOST = "https://eu.i.posthog.com";
|
|
|
69
69
|
// package.json with { type: 'json' }
|
|
70
70
|
var package_default = {
|
|
71
71
|
name: "@keywaysh/cli",
|
|
72
|
-
version: "0.0.
|
|
72
|
+
version: "0.0.11",
|
|
73
73
|
description: "One link to all your secrets",
|
|
74
74
|
type: "module",
|
|
75
75
|
bin: {
|
|
@@ -281,7 +281,7 @@ import fs from "fs";
|
|
|
281
281
|
// package.json
|
|
282
282
|
var package_default2 = {
|
|
283
283
|
name: "@keywaysh/cli",
|
|
284
|
-
version: "0.0.
|
|
284
|
+
version: "0.0.11",
|
|
285
285
|
description: "One link to all your secrets",
|
|
286
286
|
type: "module",
|
|
287
287
|
bin: {
|
|
@@ -697,23 +697,28 @@ async function ensureReadme(repoName, cwd) {
|
|
|
697
697
|
fs2.writeFileSync(defaultPath, content, "utf-8");
|
|
698
698
|
return defaultPath;
|
|
699
699
|
}
|
|
700
|
-
async function addBadgeToReadme() {
|
|
700
|
+
async function addBadgeToReadme(silent = false) {
|
|
701
701
|
const repo = detectGitRepo();
|
|
702
702
|
if (!repo) {
|
|
703
703
|
throw new Error("This directory is not a Git repository.");
|
|
704
704
|
}
|
|
705
705
|
const cwd = process.cwd();
|
|
706
706
|
const readmePath = await ensureReadme(repo, cwd);
|
|
707
|
-
if (!readmePath) return;
|
|
707
|
+
if (!readmePath) return false;
|
|
708
708
|
const badge = generateBadge(repo);
|
|
709
709
|
const content = fs2.readFileSync(readmePath, "utf-8");
|
|
710
710
|
const updated = insertBadgeIntoReadme(content, badge);
|
|
711
711
|
if (updated === content) {
|
|
712
|
-
|
|
713
|
-
|
|
712
|
+
if (!silent) {
|
|
713
|
+
console.log(chalk2.gray("Keyway badge already present in README."));
|
|
714
|
+
}
|
|
715
|
+
return false;
|
|
714
716
|
}
|
|
715
717
|
fs2.writeFileSync(readmePath, updated, "utf-8");
|
|
716
|
-
|
|
718
|
+
if (!silent) {
|
|
719
|
+
console.log(chalk2.green(`\u2713 Keyway badge added to ${path2.basename(readmePath)}`));
|
|
720
|
+
}
|
|
721
|
+
return true;
|
|
717
722
|
}
|
|
718
723
|
|
|
719
724
|
// src/cmds/push.ts
|
|
@@ -937,8 +942,10 @@ async function initCommand(options = {}) {
|
|
|
937
942
|
const response = await initVault(repoFullName, accessToken);
|
|
938
943
|
console.log(chalk4.green("\u2713 Vault created!"));
|
|
939
944
|
try {
|
|
940
|
-
await addBadgeToReadme();
|
|
941
|
-
|
|
945
|
+
const badgeAdded = await addBadgeToReadme(true);
|
|
946
|
+
if (badgeAdded) {
|
|
947
|
+
console.log(chalk4.green("\u2713 Badge added to README.md"));
|
|
948
|
+
}
|
|
942
949
|
} catch {
|
|
943
950
|
}
|
|
944
951
|
console.log("");
|
|
@@ -973,14 +980,24 @@ async function initCommand(options = {}) {
|
|
|
973
980
|
console.log("");
|
|
974
981
|
await shutdownAnalytics();
|
|
975
982
|
} catch (error) {
|
|
976
|
-
|
|
983
|
+
if (error instanceof APIError) {
|
|
984
|
+
if (error.statusCode === 409) {
|
|
985
|
+
console.log(chalk4.yellow("\n\u26A0 Vault already exists for this repository.\n"));
|
|
986
|
+
console.log(` ${chalk4.yellow("\u2192")} Run ${chalk4.cyan("keyway push")} to sync your secrets`);
|
|
987
|
+
console.log(` ${chalk4.blue("\u2394")} Dashboard: ${chalk4.underline(`${DASHBOARD_URL}/${getCurrentRepoFullName()}`)}`);
|
|
988
|
+
console.log("");
|
|
989
|
+
await shutdownAnalytics();
|
|
990
|
+
return;
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
const message = error instanceof APIError ? error.message : error instanceof Error ? error.message.slice(0, 200) : "Unknown error";
|
|
977
994
|
trackEvent(AnalyticsEvents.CLI_ERROR, {
|
|
978
995
|
command: "init",
|
|
979
996
|
error: message
|
|
980
997
|
});
|
|
981
998
|
await shutdownAnalytics();
|
|
982
999
|
console.error(chalk4.red(`
|
|
983
|
-
\u2717
|
|
1000
|
+
\u2717 ${message}`));
|
|
984
1001
|
process.exit(1);
|
|
985
1002
|
}
|
|
986
1003
|
}
|