snapfail 0.0.8 → 0.0.10
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/index.js +24 -8
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5,8 +5,8 @@ var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
|
5
5
|
import { join, resolve, basename } from "path";
|
|
6
6
|
import { existsSync, readFileSync, writeFileSync } from "fs";
|
|
7
7
|
import { createServer } from "http";
|
|
8
|
-
import { spawn } from "child_process";
|
|
9
|
-
var VERSION = "0.0.
|
|
8
|
+
import { spawn, execSync } from "child_process";
|
|
9
|
+
var VERSION = "0.0.10";
|
|
10
10
|
var APP_URL = process.env["SNAPFAIL_APP_URL"] ?? "https://app.snapfail.com";
|
|
11
11
|
var AUTH_TIMEOUT_MS = 5 * 60 * 1000;
|
|
12
12
|
var c = {
|
|
@@ -154,7 +154,7 @@ function injectViteConfig(configPath, appName, enableReplay) {
|
|
|
154
154
|
function injectHtmlFile(htmlPath, apiKey, enableReplay) {
|
|
155
155
|
try {
|
|
156
156
|
let src = readFileSync(htmlPath, "utf8");
|
|
157
|
-
if (src.includes("__snapfailConfig") || src.includes("@snapfail/sdk") || src.includes("
|
|
157
|
+
if (src.includes("__snapfailConfig") || src.includes("@snapfail/sdk") || src.includes("sdk.js")) {
|
|
158
158
|
warn(`SnapFail is already present in ${basename(htmlPath)}.`);
|
|
159
159
|
return true;
|
|
160
160
|
}
|
|
@@ -164,7 +164,7 @@ function injectHtmlFile(htmlPath, apiKey, enableReplay) {
|
|
|
164
164
|
}
|
|
165
165
|
const snippet = ` <!-- SnapFail SDK -->
|
|
166
166
|
<script>window.__snapfailConfig=${JSON.stringify(config)};</script>
|
|
167
|
-
<script type="module" src="https://cdn.jsdelivr.net/npm/@snapfail/sdk/dist/
|
|
167
|
+
<script type="module" src="https://cdn.jsdelivr.net/npm/@snapfail/sdk/dist/sdk.js"></script>
|
|
168
168
|
`;
|
|
169
169
|
src = src.replace("</head>", `${snippet}</head>`);
|
|
170
170
|
writeFileSync(htmlPath, src, "utf8");
|
|
@@ -234,9 +234,9 @@ function printManualInstructions(kind, apiKey, appName, enableReplay) {
|
|
|
234
234
|
if (enableReplay) {
|
|
235
235
|
config.recordSession = true;
|
|
236
236
|
}
|
|
237
|
-
console.log(` ${dim("<!-- index.html <head> — CDN
|
|
237
|
+
console.log(` ${dim("<!-- index.html <head> — CDN sdk (no build tool) -->")}`);
|
|
238
238
|
console.log(` <script>window.__snapfailConfig=${JSON.stringify(config)};</script>`);
|
|
239
|
-
console.log(` <script type="module" src="https://cdn.jsdelivr.net/npm/@snapfail/sdk/dist/
|
|
239
|
+
console.log(` <script type="module" src="https://cdn.jsdelivr.net/npm/@snapfail/sdk/dist/sdk.js"></script>`);
|
|
240
240
|
}
|
|
241
241
|
console.log("");
|
|
242
242
|
}
|
|
@@ -391,8 +391,24 @@ async function cmdInit(cwd) {
|
|
|
391
391
|
success("SnapFail is now integrated into your project!");
|
|
392
392
|
console.log("");
|
|
393
393
|
if (project.kind !== "html") {
|
|
394
|
-
|
|
395
|
-
|
|
394
|
+
const installCmd = getInstallCommand(cwd);
|
|
395
|
+
const installNow = await askYesNo("Would you like to automatically install @snapfail/sdk dependency now?", true);
|
|
396
|
+
console.log("");
|
|
397
|
+
if (installNow) {
|
|
398
|
+
log(`Running: ${bold(installCmd)}…`);
|
|
399
|
+
try {
|
|
400
|
+
execSync(installCmd, { stdio: "inherit", cwd });
|
|
401
|
+
console.log("");
|
|
402
|
+
success("SDK package installed successfully!");
|
|
403
|
+
} catch (err) {
|
|
404
|
+
console.log("");
|
|
405
|
+
warn(`Could not run install command: ${err.message}`);
|
|
406
|
+
warn(`Please run manually: ${installCmd}`);
|
|
407
|
+
}
|
|
408
|
+
} else {
|
|
409
|
+
console.log(` ${dim("Make sure the SDK package is installed:")}`);
|
|
410
|
+
console.log(` ${bold(" " + installCmd)}`);
|
|
411
|
+
}
|
|
396
412
|
console.log("");
|
|
397
413
|
console.log(` ${dim("Add .env to .gitignore to keep your API key private:")}`);
|
|
398
414
|
console.log(` ${bold(' echo ".env" >> .gitignore')}`);
|