@stephenov/feedbackwidget 0.5.0 → 0.5.1

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.d.mts ADDED
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node
package/dist/cli.d.ts ADDED
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node
package/dist/cli.js CHANGED
@@ -217,19 +217,31 @@ function injectWidget(apiKey) {
217
217
  if (content.includes("FeedbackWidget")) {
218
218
  return null;
219
219
  }
220
- const importMatch = content.match(/^(import .+\n)+/m);
221
- if (importMatch) {
222
- const lastImportEnd = importMatch.index + importMatch[0].length;
223
- content = content.slice(0, lastImportEnd) + importLine + "\n" + content.slice(lastImportEnd);
220
+ const lines = content.split("\n");
221
+ let lastImportIndex = -1;
222
+ for (let i = 0; i < lines.length; i++) {
223
+ if (lines[i].startsWith("import ")) {
224
+ lastImportIndex = i;
225
+ }
226
+ }
227
+ if (lastImportIndex >= 0) {
228
+ lines.splice(lastImportIndex + 1, 0, importLine);
224
229
  } else {
225
- content = importLine + "\n" + content;
230
+ lines.unshift(importLine);
226
231
  }
227
- const bodyMatch = content.match(/(<body[^>]*>)(\s*)/);
228
- if (bodyMatch) {
232
+ content = lines.join("\n");
233
+ const bodyRegex = /(<body[^>]*>)/;
234
+ const bodyMatch = content.match(bodyRegex);
235
+ if (bodyMatch && bodyMatch.index !== void 0) {
229
236
  const insertPos = bodyMatch.index + bodyMatch[0].length;
230
237
  content = content.slice(0, insertPos) + "\n " + component + content.slice(insertPos);
231
238
  }
232
- import_fs.default.writeFileSync(layoutPath, content);
239
+ import_fs.default.writeFileSync(layoutPath, content, { encoding: "utf-8", flag: "w" });
240
+ const verify = import_fs.default.readFileSync(layoutPath, "utf-8");
241
+ if (!verify.includes("FeedbackWidget")) {
242
+ console.error(" Warning: File write may not have persisted. Check " + layoutPath);
243
+ return null;
244
+ }
233
245
  return { file: layoutPath.replace(cwd + "/", "") };
234
246
  }
235
247
  }
package/dist/cli.mjs CHANGED
@@ -194,19 +194,31 @@ function injectWidget(apiKey) {
194
194
  if (content.includes("FeedbackWidget")) {
195
195
  return null;
196
196
  }
197
- const importMatch = content.match(/^(import .+\n)+/m);
198
- if (importMatch) {
199
- const lastImportEnd = importMatch.index + importMatch[0].length;
200
- content = content.slice(0, lastImportEnd) + importLine + "\n" + content.slice(lastImportEnd);
197
+ const lines = content.split("\n");
198
+ let lastImportIndex = -1;
199
+ for (let i = 0; i < lines.length; i++) {
200
+ if (lines[i].startsWith("import ")) {
201
+ lastImportIndex = i;
202
+ }
203
+ }
204
+ if (lastImportIndex >= 0) {
205
+ lines.splice(lastImportIndex + 1, 0, importLine);
201
206
  } else {
202
- content = importLine + "\n" + content;
207
+ lines.unshift(importLine);
203
208
  }
204
- const bodyMatch = content.match(/(<body[^>]*>)(\s*)/);
205
- if (bodyMatch) {
209
+ content = lines.join("\n");
210
+ const bodyRegex = /(<body[^>]*>)/;
211
+ const bodyMatch = content.match(bodyRegex);
212
+ if (bodyMatch && bodyMatch.index !== void 0) {
206
213
  const insertPos = bodyMatch.index + bodyMatch[0].length;
207
214
  content = content.slice(0, insertPos) + "\n " + component + content.slice(insertPos);
208
215
  }
209
- fs.writeFileSync(layoutPath, content);
216
+ fs.writeFileSync(layoutPath, content, { encoding: "utf-8", flag: "w" });
217
+ const verify = fs.readFileSync(layoutPath, "utf-8");
218
+ if (!verify.includes("FeedbackWidget")) {
219
+ console.error(" Warning: File write may not have persisted. Check " + layoutPath);
220
+ return null;
221
+ }
210
222
  return { file: layoutPath.replace(cwd + "/", "") };
211
223
  }
212
224
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stephenov/feedbackwidget",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
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",