snapfail 0.0.15 → 0.0.16
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 +2320 -397
- package/package.json +17 -13
- package/src/index.ts +95 -0
- package/README.md +0 -78
- package/bin/snapfail.js +0 -5
- package/dist/index.d.ts +0 -15
package/package.json
CHANGED
|
@@ -1,22 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "snapfail",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "CLI to initialise SnapFail error-tracking in Vite & Astro projects",
|
|
3
|
+
"version": "0.0.16",
|
|
5
4
|
"type": "module",
|
|
6
|
-
"
|
|
7
|
-
"
|
|
5
|
+
"description": "CLI for snapfail — project setup, incident inspection and AI diagnostics",
|
|
6
|
+
"license": "MIT",
|
|
8
7
|
"bin": {
|
|
9
|
-
"snapfail": "
|
|
8
|
+
"snapfail": "./src/index.ts"
|
|
10
9
|
},
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
"bin"
|
|
14
|
-
|
|
10
|
+
"main": "./src/index.ts",
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"bin": {
|
|
13
|
+
"snapfail": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"main": "./dist/index.js"
|
|
16
|
+
},
|
|
17
|
+
"files": ["dist"],
|
|
15
18
|
"scripts": {
|
|
16
|
-
"build": "bun build
|
|
17
|
-
"
|
|
19
|
+
"build": "bun build src/index.ts --outdir dist --target bun --format esm --sourcemap=none",
|
|
20
|
+
"prepublishOnly": "bun run build"
|
|
18
21
|
},
|
|
19
|
-
"
|
|
20
|
-
"
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@clack/prompts": "^1.5.1",
|
|
24
|
+
"@snapfail/protocol": "^0.0.1"
|
|
21
25
|
}
|
|
22
26
|
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
import { runIncidents } from "./commands/incidents.ts";
|
|
3
|
+
import { runIncident } from "./commands/incident.ts";
|
|
4
|
+
import { runInit } from "./commands/init.ts";
|
|
5
|
+
import { runExplain } from "./commands/explain.ts";
|
|
6
|
+
|
|
7
|
+
function parseArgs(argv: string[]): {
|
|
8
|
+
command: string;
|
|
9
|
+
args: string[];
|
|
10
|
+
flags: Record<string, string | boolean>;
|
|
11
|
+
} {
|
|
12
|
+
const [, , rawCommand = "incidents", ...rest] = argv;
|
|
13
|
+
const command = rawCommand;
|
|
14
|
+
const args: string[] = [];
|
|
15
|
+
const flags: Record<string, string | boolean> = {};
|
|
16
|
+
|
|
17
|
+
for (const token of rest) {
|
|
18
|
+
if (token.startsWith("--")) {
|
|
19
|
+
const eq = token.indexOf("=");
|
|
20
|
+
if (eq !== -1) {
|
|
21
|
+
flags[token.slice(2, eq)] = token.slice(eq + 1);
|
|
22
|
+
} else {
|
|
23
|
+
flags[token.slice(2)] = true;
|
|
24
|
+
}
|
|
25
|
+
} else {
|
|
26
|
+
args.push(token);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return { command, args, flags };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const VERSION = "0.0.16";
|
|
34
|
+
|
|
35
|
+
async function main(): Promise<void> {
|
|
36
|
+
const { command, args, flags } = parseArgs(process.argv);
|
|
37
|
+
const json = flags["json"] === true;
|
|
38
|
+
|
|
39
|
+
if (command === "--version" || command === "-v" || flags["version"] === true) {
|
|
40
|
+
console.log(VERSION);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
try {
|
|
45
|
+
if (command === "init") {
|
|
46
|
+
await runInit();
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (command === "incidents") {
|
|
51
|
+
await runIncidents({
|
|
52
|
+
json,
|
|
53
|
+
status: typeof flags["status"] === "string" ? flags["status"] : undefined,
|
|
54
|
+
limit: typeof flags["limit"] === "string" ? parseInt(flags["limit"]) : undefined,
|
|
55
|
+
offset: typeof flags["offset"] === "string" ? parseInt(flags["offset"]) : undefined,
|
|
56
|
+
});
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (command === "incident") {
|
|
61
|
+
const id = args[0];
|
|
62
|
+
if (!id) {
|
|
63
|
+
console.error("Usage: snapfail incident <id> [--sample <n>] [--json]");
|
|
64
|
+
process.exit(1);
|
|
65
|
+
}
|
|
66
|
+
const sampleFlag = flags["sample"];
|
|
67
|
+
const sample =
|
|
68
|
+
typeof sampleFlag === "string" ? parseInt(sampleFlag) : undefined;
|
|
69
|
+
await runIncident({ id, sample, json });
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (command === "explain") {
|
|
74
|
+
const id = args[0];
|
|
75
|
+
if (!id) {
|
|
76
|
+
console.error("Usage: snapfail explain <id> [--force] [--json]");
|
|
77
|
+
process.exit(1);
|
|
78
|
+
}
|
|
79
|
+
await runExplain({ id, force: flags["force"] === true, json });
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
console.error(`Unknown command: ${command}`);
|
|
84
|
+
console.error(`snapfail v${VERSION} — Usage: snapfail [incidents|incident|init|explain] [--version]`);
|
|
85
|
+
process.exit(1);
|
|
86
|
+
} catch (err) {
|
|
87
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
88
|
+
console.error(`Error: ${message}`);
|
|
89
|
+
process.exit(1);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (import.meta.main) {
|
|
94
|
+
main();
|
|
95
|
+
}
|
package/README.md
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
# snapfail
|
|
2
|
-
|
|
3
|
-
> **The official Command Line Interface (CLI) to automatically initialize and configure SnapFail error-tracking.**
|
|
4
|
-
|
|
5
|
-
[](https://www.npmjs.com/package/snapfail)
|
|
6
|
-
[](https://opensource.org/licenses/MIT)
|
|
7
|
-
|
|
8
|
-
**SnapFail CLI** is a terminal-based onboarding utility that automatically configures and integrates SnapFail error tracking and session replays inside your Vite and Astro codebases in seconds.
|
|
9
|
-
|
|
10
|
-
Visit the live telemetry dashboard at [app.snapfail.com](https://app.snapfail.com).
|
|
11
|
-
|
|
12
|
-
---
|
|
13
|
-
|
|
14
|
-
## Getting Started
|
|
15
|
-
|
|
16
|
-
You do not need to install the CLI permanently. You can run it on-demand using standard Node `npx`:
|
|
17
|
-
|
|
18
|
-
```bash
|
|
19
|
-
npx snapfail init
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
Or, if you prefer, install it globally on your system:
|
|
23
|
-
|
|
24
|
-
```bash
|
|
25
|
-
# npm
|
|
26
|
-
npm install -g snapfail
|
|
27
|
-
|
|
28
|
-
# pnpm
|
|
29
|
-
pnpm add -g snapfail
|
|
30
|
-
|
|
31
|
-
# Bun
|
|
32
|
-
bun add -g snapfail
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
Once installed globally, you can invoke the CLI with:
|
|
36
|
-
```bash
|
|
37
|
-
snapfail init
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
---
|
|
41
|
-
|
|
42
|
-
## Interactive Onboarding Flow
|
|
43
|
-
|
|
44
|
-
Running `snapfail init` initiates a guided terminal onboarding experience:
|
|
45
|
-
|
|
46
|
-
1. **Dashboard Authentication:** Automatically opens your default web browser to [app.snapfail.com/cli-auth](https://app.snapfail.com/cli-auth), securely performing a local CORS-approved handshake to authorize your CLI session.
|
|
47
|
-
2. **Project Selection:** Fetches your existing projects from the SnapFail dashboard, allowing you to select one or instantly create a new one right from the terminal.
|
|
48
|
-
3. **Session Replay Setup:** Prompts whether you want to enable **rrweb Session Replays** (enables full 60-second DOM playback video captures of browser crashes).
|
|
49
|
-
4. **Codebase Inspection:** Detects your project's build tool configuration:
|
|
50
|
-
* **Astro Project:** Locates `astro.config.mjs` / `astro.config.ts`, automatically installs `@snapfail/sdk` using your project's active package manager (`npm`, `pnpm`, `yarn`, or `bun`), and safely injects the `snapfail` integration.
|
|
51
|
-
* **Vite Project:** Locates `vite.config.js` / `vite.config.ts`, automatically installs `@snapfail/sdk`, and injects the `snapfail` Vite plugin.
|
|
52
|
-
* **Vanilla HTML:** Provides a ready-to-copy custom CDN `<script>` tag snippet pre-configured with your project's API Key and the new `sdk.js` loader.
|
|
53
|
-
|
|
54
|
-
---
|
|
55
|
-
|
|
56
|
-
## CLI Options
|
|
57
|
-
|
|
58
|
-
```bash
|
|
59
|
-
# Show help and commands list
|
|
60
|
-
npx snapfail --help
|
|
61
|
-
|
|
62
|
-
# Initialize integration in the current directory
|
|
63
|
-
npx snapfail init
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
---
|
|
67
|
-
|
|
68
|
-
## Advanced Detection Features
|
|
69
|
-
|
|
70
|
-
* 📦 **Dynamic Package Manager Detection:** The CLI automatically inspects lockfiles (`package-lock.json`, `pnpm-lock.yaml`, `bun.lock`, `yarn.lock`) to run the correct installation command natively in your project.
|
|
71
|
-
* 🔐 **Secure Handshake:** The CLI launches a temporary local secure server on port `4321` or random fallback, using full cross-origin headers to safely receive authorization tokens back from the dashboard browser.
|
|
72
|
-
* ⚡ **Node.js Native:** Executable binary runs natively in standard Node.js without requiring third-party runtime dependencies (like Bun or ts-node).
|
|
73
|
-
|
|
74
|
-
---
|
|
75
|
-
|
|
76
|
-
## License
|
|
77
|
-
|
|
78
|
-
MIT © [SnapFail Protocol](https://app.snapfail.com)
|
package/bin/snapfail.js
DELETED
package/dist/index.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* SnapFail CLI
|
|
3
|
-
*
|
|
4
|
-
* Authenticates against the SnapFail dashboard via a browser-based OAuth-style
|
|
5
|
-
* flow, obtains an API key for a project, writes it to the project's .env file,
|
|
6
|
-
* and injects the SDK plugin/integration into the project's Vite or Astro config
|
|
7
|
-
* automatically.
|
|
8
|
-
*
|
|
9
|
-
* Usage:
|
|
10
|
-
* snapfail init # initialise SnapFail in the current project
|
|
11
|
-
* snapfail init ./path # use a different project root
|
|
12
|
-
* snapfail --version
|
|
13
|
-
* snapfail --help
|
|
14
|
-
*/
|
|
15
|
-
export {};
|