@stephenov/feedbackwidget 0.2.1 → 0.3.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/auto.d.mts +5 -0
- package/dist/auto.d.ts +5 -0
- package/dist/auto.js +1529 -0
- package/dist/auto.mjs +46 -0
- package/dist/chunk-QQLLK6MC.mjs +1457 -0
- package/dist/cli.js +46 -15
- package/dist/cli.mjs +46 -15
- package/dist/index.mjs +21 -1459
- package/package.json +8 -3
package/dist/cli.js
CHANGED
|
@@ -94,11 +94,23 @@ async function initProject() {
|
|
|
94
94
|
reject(new Error("Authentication timed out"));
|
|
95
95
|
}, 5 * 60 * 1e3);
|
|
96
96
|
});
|
|
97
|
-
|
|
97
|
+
const saved = saveApiKeyToEnv(apiKey);
|
|
98
98
|
console.log("\u2705 Authenticated successfully!\n");
|
|
99
|
-
console.log(` API Key: ${apiKey
|
|
100
|
-
|
|
101
|
-
|
|
99
|
+
console.log(` API Key: ${apiKey}
|
|
100
|
+
`);
|
|
101
|
+
if (saved) {
|
|
102
|
+
console.log(` \u2713 Saved to ${saved}
|
|
103
|
+
`);
|
|
104
|
+
console.log(" Add ONE line to your app's root layout:\n");
|
|
105
|
+
console.log(' import "@stephenov/feedbackwidget/auto"\n');
|
|
106
|
+
} else {
|
|
107
|
+
console.log(" Add to your .env.local (or .env):\n");
|
|
108
|
+
console.log(` NEXT_PUBLIC_FEEDBACKWIDGET_API_KEY=${apiKey}
|
|
109
|
+
`);
|
|
110
|
+
console.log(" Then add to your app's root layout:\n");
|
|
111
|
+
console.log(' import "@stephenov/feedbackwidget/auto"\n');
|
|
112
|
+
}
|
|
113
|
+
console.log(" Or use directly:\n");
|
|
102
114
|
console.log(' import { FeedbackWidget } from "@stephenov/feedbackwidget"');
|
|
103
115
|
console.log(` <FeedbackWidget apiKey="${apiKey}" />
|
|
104
116
|
`);
|
|
@@ -140,26 +152,45 @@ Usage:
|
|
|
140
152
|
`);
|
|
141
153
|
}
|
|
142
154
|
function getStoredApiKey() {
|
|
143
|
-
const
|
|
155
|
+
const envPath = import_path.default.join(process.cwd(), ".env.local");
|
|
144
156
|
try {
|
|
145
|
-
const content = import_fs.default.readFileSync(
|
|
146
|
-
const match = content.match(/
|
|
157
|
+
const content = import_fs.default.readFileSync(envPath, "utf-8");
|
|
158
|
+
const match = content.match(/NEXT_PUBLIC_FEEDBACKWIDGET_API_KEY=(.+)/);
|
|
147
159
|
return match ? match[1].trim() : null;
|
|
148
160
|
} catch {
|
|
149
161
|
return null;
|
|
150
162
|
}
|
|
151
163
|
}
|
|
152
|
-
function
|
|
153
|
-
const
|
|
154
|
-
|
|
164
|
+
function saveApiKeyToEnv(apiKey) {
|
|
165
|
+
const envVar = `NEXT_PUBLIC_FEEDBACKWIDGET_API_KEY=${apiKey}`;
|
|
166
|
+
const envFiles = [".env.local", ".env"];
|
|
167
|
+
for (const envFile of envFiles) {
|
|
168
|
+
const envPath = import_path.default.join(process.cwd(), envFile);
|
|
169
|
+
try {
|
|
170
|
+
const content = import_fs.default.readFileSync(envPath, "utf-8");
|
|
171
|
+
if (content.includes("NEXT_PUBLIC_FEEDBACKWIDGET_API_KEY=")) {
|
|
172
|
+
const updated = content.replace(
|
|
173
|
+
/NEXT_PUBLIC_FEEDBACKWIDGET_API_KEY=.*/,
|
|
174
|
+
envVar
|
|
175
|
+
);
|
|
176
|
+
import_fs.default.writeFileSync(envPath, updated);
|
|
177
|
+
} else {
|
|
178
|
+
import_fs.default.appendFileSync(envPath, `
|
|
179
|
+
${envVar}
|
|
155
180
|
`);
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
import_fs.default.appendFileSync(gitignorePath, "\n.feedbackwidgetrc\n");
|
|
181
|
+
}
|
|
182
|
+
return envFile;
|
|
183
|
+
} catch {
|
|
184
|
+
continue;
|
|
161
185
|
}
|
|
186
|
+
}
|
|
187
|
+
try {
|
|
188
|
+
const envPath = import_path.default.join(process.cwd(), ".env.local");
|
|
189
|
+
import_fs.default.writeFileSync(envPath, `${envVar}
|
|
190
|
+
`);
|
|
191
|
+
return ".env.local";
|
|
162
192
|
} catch {
|
|
193
|
+
return null;
|
|
163
194
|
}
|
|
164
195
|
}
|
|
165
196
|
function successPage() {
|
package/dist/cli.mjs
CHANGED
|
@@ -71,11 +71,23 @@ async function initProject() {
|
|
|
71
71
|
reject(new Error("Authentication timed out"));
|
|
72
72
|
}, 5 * 60 * 1e3);
|
|
73
73
|
});
|
|
74
|
-
|
|
74
|
+
const saved = saveApiKeyToEnv(apiKey);
|
|
75
75
|
console.log("\u2705 Authenticated successfully!\n");
|
|
76
|
-
console.log(` API Key: ${apiKey
|
|
77
|
-
|
|
78
|
-
|
|
76
|
+
console.log(` API Key: ${apiKey}
|
|
77
|
+
`);
|
|
78
|
+
if (saved) {
|
|
79
|
+
console.log(` \u2713 Saved to ${saved}
|
|
80
|
+
`);
|
|
81
|
+
console.log(" Add ONE line to your app's root layout:\n");
|
|
82
|
+
console.log(' import "@stephenov/feedbackwidget/auto"\n');
|
|
83
|
+
} else {
|
|
84
|
+
console.log(" Add to your .env.local (or .env):\n");
|
|
85
|
+
console.log(` NEXT_PUBLIC_FEEDBACKWIDGET_API_KEY=${apiKey}
|
|
86
|
+
`);
|
|
87
|
+
console.log(" Then add to your app's root layout:\n");
|
|
88
|
+
console.log(' import "@stephenov/feedbackwidget/auto"\n');
|
|
89
|
+
}
|
|
90
|
+
console.log(" Or use directly:\n");
|
|
79
91
|
console.log(' import { FeedbackWidget } from "@stephenov/feedbackwidget"');
|
|
80
92
|
console.log(` <FeedbackWidget apiKey="${apiKey}" />
|
|
81
93
|
`);
|
|
@@ -117,26 +129,45 @@ Usage:
|
|
|
117
129
|
`);
|
|
118
130
|
}
|
|
119
131
|
function getStoredApiKey() {
|
|
120
|
-
const
|
|
132
|
+
const envPath = path.join(process.cwd(), ".env.local");
|
|
121
133
|
try {
|
|
122
|
-
const content = fs.readFileSync(
|
|
123
|
-
const match = content.match(/
|
|
134
|
+
const content = fs.readFileSync(envPath, "utf-8");
|
|
135
|
+
const match = content.match(/NEXT_PUBLIC_FEEDBACKWIDGET_API_KEY=(.+)/);
|
|
124
136
|
return match ? match[1].trim() : null;
|
|
125
137
|
} catch {
|
|
126
138
|
return null;
|
|
127
139
|
}
|
|
128
140
|
}
|
|
129
|
-
function
|
|
130
|
-
const
|
|
131
|
-
|
|
141
|
+
function saveApiKeyToEnv(apiKey) {
|
|
142
|
+
const envVar = `NEXT_PUBLIC_FEEDBACKWIDGET_API_KEY=${apiKey}`;
|
|
143
|
+
const envFiles = [".env.local", ".env"];
|
|
144
|
+
for (const envFile of envFiles) {
|
|
145
|
+
const envPath = path.join(process.cwd(), envFile);
|
|
146
|
+
try {
|
|
147
|
+
const content = fs.readFileSync(envPath, "utf-8");
|
|
148
|
+
if (content.includes("NEXT_PUBLIC_FEEDBACKWIDGET_API_KEY=")) {
|
|
149
|
+
const updated = content.replace(
|
|
150
|
+
/NEXT_PUBLIC_FEEDBACKWIDGET_API_KEY=.*/,
|
|
151
|
+
envVar
|
|
152
|
+
);
|
|
153
|
+
fs.writeFileSync(envPath, updated);
|
|
154
|
+
} else {
|
|
155
|
+
fs.appendFileSync(envPath, `
|
|
156
|
+
${envVar}
|
|
132
157
|
`);
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
fs.appendFileSync(gitignorePath, "\n.feedbackwidgetrc\n");
|
|
158
|
+
}
|
|
159
|
+
return envFile;
|
|
160
|
+
} catch {
|
|
161
|
+
continue;
|
|
138
162
|
}
|
|
163
|
+
}
|
|
164
|
+
try {
|
|
165
|
+
const envPath = path.join(process.cwd(), ".env.local");
|
|
166
|
+
fs.writeFileSync(envPath, `${envVar}
|
|
167
|
+
`);
|
|
168
|
+
return ".env.local";
|
|
139
169
|
} catch {
|
|
170
|
+
return null;
|
|
140
171
|
}
|
|
141
172
|
}
|
|
142
173
|
function successPage() {
|