snapfail 0.0.15 → 0.0.17
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/README.md +15 -60
- package/dist/index.js +2320 -397
- package/package.json +17 -13
- package/src/index.ts +95 -0
- 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.17",
|
|
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.17";
|
|
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/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 {};
|