@keywaysh/cli 0.1.3 → 0.1.4
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 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -102,7 +102,7 @@ var INTERNAL_POSTHOG_HOST = "https://eu.i.posthog.com";
|
|
|
102
102
|
// package.json
|
|
103
103
|
var package_default = {
|
|
104
104
|
name: "@keywaysh/cli",
|
|
105
|
-
version: "0.1.
|
|
105
|
+
version: "0.1.4",
|
|
106
106
|
description: "One link to all your secrets",
|
|
107
107
|
type: "module",
|
|
108
108
|
bin: {
|
|
@@ -491,6 +491,24 @@ async function executeSync(accessToken, repoFullName, options) {
|
|
|
491
491
|
const wrapped = await handleResponse(response);
|
|
492
492
|
return wrapped.data;
|
|
493
493
|
}
|
|
494
|
+
async function checkVaultExists(accessToken, repoFullName) {
|
|
495
|
+
const [owner, repo] = repoFullName.split("/");
|
|
496
|
+
try {
|
|
497
|
+
const response = await fetchWithTimeout(
|
|
498
|
+
`${API_BASE_URL}/v1/vaults/${owner}/${repo}`,
|
|
499
|
+
{
|
|
500
|
+
method: "GET",
|
|
501
|
+
headers: {
|
|
502
|
+
"User-Agent": USER_AGENT,
|
|
503
|
+
Authorization: `Bearer ${accessToken}`
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
);
|
|
507
|
+
return response.ok;
|
|
508
|
+
} catch {
|
|
509
|
+
return false;
|
|
510
|
+
}
|
|
511
|
+
}
|
|
494
512
|
async function getVaultEnvironments(accessToken, repoFullName) {
|
|
495
513
|
const [owner, repo] = repoFullName.split("/");
|
|
496
514
|
try {
|
|
@@ -1315,6 +1333,15 @@ async function initCommand(options = {}) {
|
|
|
1315
1333
|
allowPrompt: options.loginPrompt !== false
|
|
1316
1334
|
});
|
|
1317
1335
|
trackEvent(AnalyticsEvents.CLI_INIT, { repoFullName, githubAppInstalled: true });
|
|
1336
|
+
const vaultExists = await checkVaultExists(accessToken, repoFullName);
|
|
1337
|
+
if (vaultExists) {
|
|
1338
|
+
console.log(pc5.green("\n\u2713 Already initialized!\n"));
|
|
1339
|
+
console.log(` ${pc5.yellow("\u2192")} Run ${pc5.cyan("keyway push")} to sync your secrets`);
|
|
1340
|
+
console.log(` ${pc5.blue("\u2394")} Dashboard: ${pc5.underline(dashboardLink)}`);
|
|
1341
|
+
console.log("");
|
|
1342
|
+
await shutdownAnalytics();
|
|
1343
|
+
return;
|
|
1344
|
+
}
|
|
1318
1345
|
await initVault(repoFullName, accessToken);
|
|
1319
1346
|
console.log(pc5.green("\u2713 Vault created!"));
|
|
1320
1347
|
try {
|