@keywaysh/cli 0.0.4 → 0.0.6

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 +28 -8
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -66,7 +66,11 @@ var INTERNAL_POSTHOG_KEY = "phc_duG0qqI5z8LeHrS9pNxR5KaD4djgD0nmzUxuD3zP0ov";
66
66
  var INTERNAL_POSTHOG_HOST = "https://eu.i.posthog.com";
67
67
 
68
68
  // src/utils/api.ts
69
+ import { createRequire } from "module";
70
+ var require2 = createRequire(import.meta.url);
71
+ var pkg = require2("../../package.json");
69
72
  var API_BASE_URL = process.env.KEYWAY_API_URL || INTERNAL_API_URL;
73
+ var USER_AGENT = `keyway-cli/${pkg.version}`;
70
74
  var APIError = class extends Error {
71
75
  constructor(statusCode, error, message) {
72
76
  super(message);
@@ -102,7 +106,10 @@ async function handleResponse(response) {
102
106
  }
103
107
  async function initVault(repoFullName, accessToken) {
104
108
  const body = { repoFullName };
105
- const headers = { "Content-Type": "application/json" };
109
+ const headers = {
110
+ "Content-Type": "application/json",
111
+ "User-Agent": USER_AGENT
112
+ };
106
113
  if (accessToken) {
107
114
  headers.Authorization = `Bearer ${accessToken}`;
108
115
  }
@@ -134,7 +141,10 @@ function parseEnvContent(content) {
134
141
  async function pushSecrets(repoFullName, environment, content, accessToken) {
135
142
  const secrets = parseEnvContent(content);
136
143
  const body = { repoFullName, environment, secrets };
137
- const headers = { "Content-Type": "application/json" };
144
+ const headers = {
145
+ "Content-Type": "application/json",
146
+ "User-Agent": USER_AGENT
147
+ };
138
148
  if (accessToken) {
139
149
  headers.Authorization = `Bearer ${accessToken}`;
140
150
  }
@@ -147,7 +157,10 @@ async function pushSecrets(repoFullName, environment, content, accessToken) {
147
157
  return result.data;
148
158
  }
149
159
  async function pullSecrets(repoFullName, environment, accessToken) {
150
- const headers = { "Content-Type": "application/json" };
160
+ const headers = {
161
+ "Content-Type": "application/json",
162
+ "User-Agent": USER_AGENT
163
+ };
151
164
  if (accessToken) {
152
165
  headers.Authorization = `Bearer ${accessToken}`;
153
166
  }
@@ -165,7 +178,10 @@ async function pullSecrets(repoFullName, environment, accessToken) {
165
178
  async function startDeviceLogin(repository) {
166
179
  const response = await fetch(`${API_BASE_URL}/v1/auth/device/start`, {
167
180
  method: "POST",
168
- headers: { "Content-Type": "application/json" },
181
+ headers: {
182
+ "Content-Type": "application/json",
183
+ "User-Agent": USER_AGENT
184
+ },
169
185
  body: JSON.stringify(repository ? { repository } : {})
170
186
  });
171
187
  return handleResponse(response);
@@ -173,7 +189,10 @@ async function startDeviceLogin(repository) {
173
189
  async function pollDeviceLogin(deviceCode) {
174
190
  const response = await fetch(`${API_BASE_URL}/v1/auth/device/poll`, {
175
191
  method: "POST",
176
- headers: { "Content-Type": "application/json" },
192
+ headers: {
193
+ "Content-Type": "application/json",
194
+ "User-Agent": USER_AGENT
195
+ },
177
196
  body: JSON.stringify({ deviceCode })
178
197
  });
179
198
  return handleResponse(response);
@@ -183,6 +202,7 @@ async function validateToken(token) {
183
202
  method: "POST",
184
203
  headers: {
185
204
  "Content-Type": "application/json",
205
+ "User-Agent": USER_AGENT,
186
206
  Authorization: `Bearer ${token}`
187
207
  },
188
208
  body: JSON.stringify({})
@@ -200,7 +220,7 @@ import fs from "fs";
200
220
  // package.json
201
221
  var package_default = {
202
222
  name: "@keywaysh/cli",
203
- version: "0.0.4",
223
+ version: "0.0.6",
204
224
  description: "One link to all your secrets",
205
225
  type: "module",
206
226
  bin: {
@@ -562,7 +582,7 @@ function insertBadgeIntoReadme(readmeContent, badge) {
562
582
  return readmeContent;
563
583
  }
564
584
  const lines = readmeContent.split(/\r?\n/);
565
- const titleIndex = lines.findIndex((line) => /^#\s+/.test(line.trim()));
585
+ const titleIndex = lines.findIndex((line) => /^#(?!#)\s+/.test(line.trim()));
566
586
  if (titleIndex !== -1) {
567
587
  const before = lines.slice(0, titleIndex + 1);
568
588
  const after = lines.slice(titleIndex + 1);
@@ -1267,7 +1287,7 @@ Summary: ${formatSummary(results)}`);
1267
1287
  // package.json with { type: 'json' }
1268
1288
  var package_default2 = {
1269
1289
  name: "@keywaysh/cli",
1270
- version: "0.0.4",
1290
+ version: "0.0.6",
1271
1291
  description: "One link to all your secrets",
1272
1292
  type: "module",
1273
1293
  bin: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keywaysh/cli",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "description": "One link to all your secrets",
5
5
  "type": "module",
6
6
  "bin": {