@stephenov/feedbackwidget 0.2.1 → 0.2.2

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 CHANGED
@@ -27,6 +27,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
27
  var import_http = __toESM(require("http"));
28
28
  var import_open = __toESM(require("open"));
29
29
  var import_crypto = require("crypto");
30
+ var import_child_process = require("child_process");
30
31
  var import_fs = __toESM(require("fs"));
31
32
  var import_path = __toESM(require("path"));
32
33
  var API_BASE = "https://feedbackwidget-api.vercel.app";
@@ -95,13 +96,24 @@ async function initProject() {
95
96
  }, 5 * 60 * 1e3);
96
97
  });
97
98
  saveApiKey(apiKey);
98
- console.log("\u2705 Authenticated successfully!\n");
99
- console.log(` API Key: ${apiKey.slice(0, 20)}...`);
100
- console.log(" Saved to .feedbackwidgetrc\n");
101
- console.log(" Add to your app:\n");
102
- console.log(' import { FeedbackWidget } from "@stephenov/feedbackwidget"');
103
- console.log(` <FeedbackWidget apiKey="${apiKey}" />
99
+ const snippet = `import { FeedbackWidget } from "@stephenov/feedbackwidget"
100
+
101
+ <FeedbackWidget apiKey="${apiKey}" />`;
102
+ try {
103
+ await copyToClipboard(snippet);
104
+ console.log("\u2705 Authenticated successfully!\n");
105
+ console.log(` API Key: ${apiKey.slice(0, 20)}...`);
106
+ console.log(" Saved to .feedbackwidgetrc\n");
107
+ console.log(" \u{1F4CB} Code snippet copied to clipboard! Just paste into your app.\n");
108
+ } catch {
109
+ console.log("\u2705 Authenticated successfully!\n");
110
+ console.log(` API Key: ${apiKey.slice(0, 20)}...`);
111
+ console.log(" Saved to .feedbackwidgetrc\n");
112
+ console.log(" Add to your app:\n");
113
+ console.log(' import { FeedbackWidget } from "@stephenov/feedbackwidget"');
114
+ console.log(` <FeedbackWidget apiKey="${apiKey}" />
104
115
  `);
116
+ }
105
117
  }
106
118
  async function whoami() {
107
119
  const apiKey = getStoredApiKey();
@@ -208,4 +220,30 @@ function errorPage(error) {
208
220
  </body>
209
221
  </html>`;
210
222
  }
223
+ async function copyToClipboard(text) {
224
+ return new Promise((resolve, reject) => {
225
+ const platform = process.platform;
226
+ let cmd;
227
+ let args = [];
228
+ if (platform === "darwin") {
229
+ cmd = "pbcopy";
230
+ } else if (platform === "linux") {
231
+ cmd = "xclip";
232
+ args = ["-selection", "clipboard"];
233
+ } else if (platform === "win32") {
234
+ cmd = "clip";
235
+ } else {
236
+ reject(new Error("Unsupported platform"));
237
+ return;
238
+ }
239
+ const proc = (0, import_child_process.spawn)(cmd, args);
240
+ proc.stdin.write(text);
241
+ proc.stdin.end();
242
+ proc.on("close", (code) => {
243
+ if (code === 0) resolve();
244
+ else reject(new Error(`Clipboard failed with code ${code}`));
245
+ });
246
+ proc.on("error", reject);
247
+ });
248
+ }
211
249
  main().catch(console.error);
package/dist/cli.mjs CHANGED
@@ -4,6 +4,7 @@
4
4
  import http from "http";
5
5
  import open from "open";
6
6
  import { randomBytes } from "crypto";
7
+ import { spawn } from "child_process";
7
8
  import fs from "fs";
8
9
  import path from "path";
9
10
  var API_BASE = "https://feedbackwidget-api.vercel.app";
@@ -72,13 +73,24 @@ async function initProject() {
72
73
  }, 5 * 60 * 1e3);
73
74
  });
74
75
  saveApiKey(apiKey);
75
- console.log("\u2705 Authenticated successfully!\n");
76
- console.log(` API Key: ${apiKey.slice(0, 20)}...`);
77
- console.log(" Saved to .feedbackwidgetrc\n");
78
- console.log(" Add to your app:\n");
79
- console.log(' import { FeedbackWidget } from "@stephenov/feedbackwidget"');
80
- console.log(` <FeedbackWidget apiKey="${apiKey}" />
76
+ const snippet = `import { FeedbackWidget } from "@stephenov/feedbackwidget"
77
+
78
+ <FeedbackWidget apiKey="${apiKey}" />`;
79
+ try {
80
+ await copyToClipboard(snippet);
81
+ console.log("\u2705 Authenticated successfully!\n");
82
+ console.log(` API Key: ${apiKey.slice(0, 20)}...`);
83
+ console.log(" Saved to .feedbackwidgetrc\n");
84
+ console.log(" \u{1F4CB} Code snippet copied to clipboard! Just paste into your app.\n");
85
+ } catch {
86
+ console.log("\u2705 Authenticated successfully!\n");
87
+ console.log(` API Key: ${apiKey.slice(0, 20)}...`);
88
+ console.log(" Saved to .feedbackwidgetrc\n");
89
+ console.log(" Add to your app:\n");
90
+ console.log(' import { FeedbackWidget } from "@stephenov/feedbackwidget"');
91
+ console.log(` <FeedbackWidget apiKey="${apiKey}" />
81
92
  `);
93
+ }
82
94
  }
83
95
  async function whoami() {
84
96
  const apiKey = getStoredApiKey();
@@ -185,4 +197,30 @@ function errorPage(error) {
185
197
  </body>
186
198
  </html>`;
187
199
  }
200
+ async function copyToClipboard(text) {
201
+ return new Promise((resolve, reject) => {
202
+ const platform = process.platform;
203
+ let cmd;
204
+ let args = [];
205
+ if (platform === "darwin") {
206
+ cmd = "pbcopy";
207
+ } else if (platform === "linux") {
208
+ cmd = "xclip";
209
+ args = ["-selection", "clipboard"];
210
+ } else if (platform === "win32") {
211
+ cmd = "clip";
212
+ } else {
213
+ reject(new Error("Unsupported platform"));
214
+ return;
215
+ }
216
+ const proc = spawn(cmd, args);
217
+ proc.stdin.write(text);
218
+ proc.stdin.end();
219
+ proc.on("close", (code) => {
220
+ if (code === 0) resolve();
221
+ else reject(new Error(`Clipboard failed with code ${code}`));
222
+ });
223
+ proc.on("error", reject);
224
+ });
225
+ }
188
226
  main().catch(console.error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stephenov/feedbackwidget",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Voice-first feedback widget with AI analysis, GitHub, and Slack integration",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",