@keywaysh/cli 0.0.9 → 0.0.10

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/dist/cli.js +80 -53
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -5,7 +5,8 @@ import { Command } from "commander";
5
5
  import chalk7 from "chalk";
6
6
 
7
7
  // src/cmds/init.ts
8
- import chalk3 from "chalk";
8
+ import chalk4 from "chalk";
9
+ import prompts4 from "prompts";
9
10
 
10
11
  // src/utils/git.ts
11
12
  import { execSync } from "child_process";
@@ -68,7 +69,7 @@ var INTERNAL_POSTHOG_HOST = "https://eu.i.posthog.com";
68
69
  // package.json with { type: 'json' }
69
70
  var package_default = {
70
71
  name: "@keywaysh/cli",
71
- version: "0.0.9",
72
+ version: "0.0.10",
72
73
  description: "One link to all your secrets",
73
74
  type: "module",
74
75
  bin: {
@@ -280,7 +281,7 @@ import fs from "fs";
280
281
  // package.json
281
282
  var package_default2 = {
282
283
  name: "@keywaysh/cli",
283
- version: "0.0.9",
284
+ version: "0.0.10",
284
285
  description: "One link to all your secrets",
285
286
  type: "module",
286
287
  bin: {
@@ -715,43 +716,8 @@ async function addBadgeToReadme() {
715
716
  console.log(chalk2.green(`\u2713 Keyway badge added to ${path2.basename(readmePath)}`));
716
717
  }
717
718
 
718
- // src/cmds/init.ts
719
- async function initCommand(options = {}) {
720
- try {
721
- console.log(chalk3.blue("\u{1F510} Initializing Keyway vault...\n"));
722
- const repoFullName = getCurrentRepoFullName();
723
- console.log(`Repository: ${chalk3.cyan(repoFullName)}`);
724
- const accessToken = await ensureLogin({ allowPrompt: options.loginPrompt !== false });
725
- trackEvent(AnalyticsEvents.CLI_INIT, { repoFullName });
726
- console.log("\nInitializing vault...");
727
- const response = await initVault(repoFullName, accessToken);
728
- console.log(chalk3.green("\n\u2713 " + response.message));
729
- console.log(`
730
- Vault ID: ${chalk3.gray(response.vaultId)}`);
731
- console.log("\nNext steps:");
732
- console.log(` 1. Create a ${chalk3.cyan(".env")} file with your secrets`);
733
- console.log(` 2. Run ${chalk3.cyan("keyway push")} to upload your secrets`);
734
- try {
735
- await addBadgeToReadme();
736
- } catch (badgeError) {
737
- console.log(chalk3.yellow("Badge insertion skipped:"), badgeError instanceof Error ? badgeError.message : String(badgeError));
738
- }
739
- await shutdownAnalytics();
740
- } catch (error) {
741
- const message = error instanceof APIError ? `API ${error.statusCode}: ${error.message}` : error instanceof Error ? error.message.slice(0, 200) : "Unknown error";
742
- trackEvent(AnalyticsEvents.CLI_ERROR, {
743
- command: "init",
744
- error: message
745
- });
746
- await shutdownAnalytics();
747
- console.error(chalk3.red(`
748
- \u2717 Error: ${message}`));
749
- process.exit(1);
750
- }
751
- }
752
-
753
719
  // src/cmds/push.ts
754
- import chalk4 from "chalk";
720
+ import chalk3 from "chalk";
755
721
  import fs3 from "fs";
756
722
  import path3 from "path";
757
723
  import prompts3 from "prompts";
@@ -768,7 +734,7 @@ function discoverEnvCandidates(cwd) {
768
734
  const entries = fs3.readdirSync(cwd);
769
735
  const hasEnvLocal = entries.includes(".env.local");
770
736
  if (hasEnvLocal) {
771
- console.log(chalk4.gray("\u2139\uFE0F Detected .env.local \u2014 not synced by design (machine-specific secrets)"));
737
+ console.log(chalk3.gray("\u2139\uFE0F Detected .env.local \u2014 not synced by design (machine-specific secrets)"));
772
738
  }
773
739
  const candidates = entries.filter((name) => name.startsWith(".env") && name !== ".env.local").map((name) => {
774
740
  const fullPath = path3.join(cwd, name);
@@ -794,7 +760,7 @@ function discoverEnvCandidates(cwd) {
794
760
  }
795
761
  async function pushCommand(options) {
796
762
  try {
797
- console.log(chalk4.blue("\u{1F510} Pushing secrets to Keyway...\n"));
763
+ console.log(chalk3.blue("\u{1F510} Pushing secrets to Keyway...\n"));
798
764
  const isInteractive2 = process.stdin.isTTY && process.stdout.isTTY;
799
765
  let environment = options.env;
800
766
  let envFile = options.file;
@@ -894,11 +860,11 @@ async function pushCommand(options) {
894
860
  const trimmed = line.trim();
895
861
  return trimmed.length > 0 && !trimmed.startsWith("#");
896
862
  });
897
- console.log(`File: ${chalk4.cyan(envFile)}`);
898
- console.log(`Environment: ${chalk4.cyan(environment)}`);
899
- console.log(`Variables: ${chalk4.cyan(lines.length.toString())}`);
863
+ console.log(`File: ${chalk3.cyan(envFile)}`);
864
+ console.log(`Environment: ${chalk3.cyan(environment)}`);
865
+ console.log(`Variables: ${chalk3.cyan(lines.length.toString())}`);
900
866
  const repoFullName = getCurrentRepoFullName();
901
- console.log(`Repository: ${chalk4.cyan(repoFullName)}`);
867
+ console.log(`Repository: ${chalk3.cyan(repoFullName)}`);
902
868
  if (!options.yes) {
903
869
  const isInteractive3 = process.stdin.isTTY && process.stdout.isTTY;
904
870
  if (!isInteractive3) {
@@ -918,7 +884,7 @@ async function pushCommand(options) {
918
884
  }
919
885
  );
920
886
  if (!confirm) {
921
- console.log(chalk4.yellow("Push aborted."));
887
+ console.log(chalk3.yellow("Push aborted."));
922
888
  return;
923
889
  }
924
890
  }
@@ -930,20 +896,20 @@ async function pushCommand(options) {
930
896
  });
931
897
  console.log("\nUploading secrets...");
932
898
  const response = await pushSecrets(repoFullName, environment, content, accessToken);
933
- console.log(chalk4.green("\n\u2713 " + response.message));
899
+ console.log(chalk3.green("\n\u2713 " + response.message));
934
900
  if (response.stats) {
935
901
  const { created, updated, deleted } = response.stats;
936
902
  const parts = [];
937
- if (created > 0) parts.push(chalk4.green(`+${created} created`));
938
- if (updated > 0) parts.push(chalk4.yellow(`~${updated} updated`));
939
- if (deleted > 0) parts.push(chalk4.red(`-${deleted} deleted`));
903
+ if (created > 0) parts.push(chalk3.green(`+${created} created`));
904
+ if (updated > 0) parts.push(chalk3.yellow(`~${updated} updated`));
905
+ if (deleted > 0) parts.push(chalk3.red(`-${deleted} deleted`));
940
906
  if (parts.length > 0) {
941
907
  console.log(`Stats: ${parts.join(", ")}`);
942
908
  }
943
909
  }
944
910
  console.log(`
945
911
  Your secrets are now encrypted and stored securely.`);
946
- console.log(`To retrieve them, run: ${chalk4.cyan(`keyway pull --env ${environment}`)}`);
912
+ console.log(`To retrieve them, run: ${chalk3.cyan(`keyway pull --env ${environment}`)}`);
947
913
  await shutdownAnalytics();
948
914
  } catch (error) {
949
915
  const message = error instanceof APIError ? `API ${error.statusCode}: ${error.message}` : error instanceof Error ? error.message.slice(0, 200) : "Unknown error";
@@ -952,6 +918,67 @@ Your secrets are now encrypted and stored securely.`);
952
918
  error: message
953
919
  });
954
920
  await shutdownAnalytics();
921
+ console.error(chalk3.red(`
922
+ \u2717 Error: ${message}`));
923
+ process.exit(1);
924
+ }
925
+ }
926
+
927
+ // src/cmds/init.ts
928
+ var DASHBOARD_URL = "https://www.keyway.sh/dashboard/vaults";
929
+ async function initCommand(options = {}) {
930
+ try {
931
+ const repoFullName = getCurrentRepoFullName();
932
+ const dashboardLink = `${DASHBOARD_URL}/${repoFullName}`;
933
+ console.log(chalk4.blue("\u{1F510} Initializing Keyway vault...\n"));
934
+ console.log(` ${chalk4.gray("Repository:")} ${chalk4.white(repoFullName)}`);
935
+ const accessToken = await ensureLogin({ allowPrompt: options.loginPrompt !== false });
936
+ trackEvent(AnalyticsEvents.CLI_INIT, { repoFullName });
937
+ const response = await initVault(repoFullName, accessToken);
938
+ console.log(chalk4.green("\u2713 Vault created!"));
939
+ try {
940
+ await addBadgeToReadme();
941
+ console.log(chalk4.green("\u2713 Badge added to README.md"));
942
+ } catch {
943
+ }
944
+ console.log("");
945
+ const envCandidates = discoverEnvCandidates(process.cwd());
946
+ const isInteractive2 = process.stdin.isTTY && process.stdout.isTTY;
947
+ if (envCandidates.length > 0 && isInteractive2) {
948
+ console.log(chalk4.gray(` Found ${envCandidates.length} env file(s): ${envCandidates.map((c) => c.file).join(", ")}
949
+ `));
950
+ const { shouldPush } = await prompts4({
951
+ type: "confirm",
952
+ name: "shouldPush",
953
+ message: "Push secrets now?",
954
+ initial: true
955
+ });
956
+ if (shouldPush) {
957
+ console.log("");
958
+ await pushCommand({ loginPrompt: false, yes: false });
959
+ return;
960
+ }
961
+ }
962
+ console.log(chalk4.dim("\u2500".repeat(50)));
963
+ console.log("");
964
+ if (envCandidates.length === 0) {
965
+ console.log(` ${chalk4.yellow("\u2192")} Create a ${chalk4.cyan(".env")} file with your secrets`);
966
+ console.log(` ${chalk4.yellow("\u2192")} Run ${chalk4.cyan("keyway push")} to sync them
967
+ `);
968
+ } else {
969
+ console.log(` ${chalk4.yellow("\u2192")} Run ${chalk4.cyan("keyway push")} to sync your secrets
970
+ `);
971
+ }
972
+ console.log(` ${chalk4.blue("\u2394")} Dashboard: ${chalk4.underline(dashboardLink)}`);
973
+ console.log("");
974
+ await shutdownAnalytics();
975
+ } catch (error) {
976
+ const message = error instanceof APIError ? `API ${error.statusCode}: ${error.message}` : error instanceof Error ? error.message.slice(0, 200) : "Unknown error";
977
+ trackEvent(AnalyticsEvents.CLI_ERROR, {
978
+ command: "init",
979
+ error: message
980
+ });
981
+ await shutdownAnalytics();
955
982
  console.error(chalk4.red(`
956
983
  \u2717 Error: ${message}`));
957
984
  process.exit(1);
@@ -962,7 +989,7 @@ Your secrets are now encrypted and stored securely.`);
962
989
  import chalk5 from "chalk";
963
990
  import fs4 from "fs";
964
991
  import path4 from "path";
965
- import prompts4 from "prompts";
992
+ import prompts5 from "prompts";
966
993
  async function pullCommand(options) {
967
994
  try {
968
995
  const environment = options.env || "development";
@@ -987,7 +1014,7 @@ async function pullCommand(options) {
987
1014
  } else if (!isInteractive2) {
988
1015
  throw new Error(`File ${envFile} exists. Re-run with --yes to overwrite or choose a different --file.`);
989
1016
  } else {
990
- const { confirm } = await prompts4(
1017
+ const { confirm } = await prompts5(
991
1018
  {
992
1019
  type: "confirm",
993
1020
  name: "confirm",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keywaysh/cli",
3
- "version": "0.0.9",
3
+ "version": "0.0.10",
4
4
  "description": "One link to all your secrets",
5
5
  "type": "module",
6
6
  "bin": {