prisma-guard-lite 0.1.0 → 0.1.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/README.md CHANGED
@@ -93,6 +93,8 @@ Git-aware modes require a Git worktree.
93
93
  | `--no-write` | Do not write `prisma-guard-report.md` |
94
94
  | `--fail-on high` | Exit with code 1 when high findings exist |
95
95
  | `--fail-on medium` | Exit with code 1 when high or medium findings exist |
96
+ | `--help`, `-h` | Print CLI usage and options |
97
+ | `--version`, `-v` | Print the installed package version |
96
98
 
97
99
  ## Example output
98
100
 
package/dist/index.js CHANGED
@@ -8,7 +8,33 @@ const node_fs_1 = require("node:fs");
8
8
  const node_path_1 = __importDefault(require("node:path"));
9
9
  const report_js_1 = require("./report.js");
10
10
  const scanner_js_1 = require("./scanner.js");
11
+ const helpText = `Prisma Guard Lite
12
+
13
+ Pre-deploy migration risk checker for Prisma projects.
14
+
15
+ Usage:
16
+ prisma-guard-lite [project-path] [options]
17
+
18
+ Examples:
19
+ npx prisma-guard-lite --latest
20
+ npx prisma-guard-lite --since main
21
+ npx prisma-guard-lite --staged --fail-on high
22
+ npx prisma-guard-lite /path/to/project --changed
23
+
24
+ Options:
25
+ --latest Scan only the latest migration
26
+ --since <git-ref> Scan migrations changed since a Git ref
27
+ --staged Scan staged migration files
28
+ --changed Scan changed and untracked migration files
29
+ --json Output JSON
30
+ --include-low Include low-severity best-practice checks
31
+ --no-write Do not write prisma-guard-report.md
32
+ --fail-on high|medium Exit 1 at the selected severity threshold
33
+ --help, -h Show help
34
+ --version, -v Show version
35
+ `;
11
36
  function parseArgs(args) {
37
+ let action;
12
38
  let projectPath;
13
39
  let json = false;
14
40
  let mode = "history";
@@ -26,7 +52,13 @@ function parseArgs(args) {
26
52
  };
27
53
  for (let index = 0; index < args.length; index += 1) {
28
54
  const arg = args[index];
29
- if (arg === "--json") {
55
+ if (arg === "--help" || arg === "-h") {
56
+ action = "help";
57
+ }
58
+ else if (arg === "--version" || arg === "-v") {
59
+ action = "version";
60
+ }
61
+ else if (arg === "--json") {
30
62
  json = true;
31
63
  }
32
64
  else if (arg === "--latest") {
@@ -71,6 +103,7 @@ function parseArgs(args) {
71
103
  }
72
104
  }
73
105
  return {
106
+ action,
74
107
  projectRoot: node_path_1.default.resolve(projectPath ?? process.cwd()),
75
108
  json,
76
109
  mode,
@@ -80,8 +113,24 @@ function parseArgs(args) {
80
113
  failOn,
81
114
  };
82
115
  }
116
+ async function packageVersion() {
117
+ const packagePath = node_path_1.default.join(__dirname, "..", "package.json");
118
+ const packageJson = JSON.parse(await node_fs_1.promises.readFile(packagePath, "utf8"));
119
+ if (typeof packageJson.version !== "string") {
120
+ throw new Error("Unable to read package version.");
121
+ }
122
+ return packageJson.version;
123
+ }
83
124
  async function main() {
84
125
  const options = parseArgs(process.argv.slice(2));
126
+ if (options.action === "help") {
127
+ process.stdout.write(helpText);
128
+ return;
129
+ }
130
+ if (options.action === "version") {
131
+ process.stdout.write(`${await packageVersion()}\n`);
132
+ return;
133
+ }
85
134
  const stat = await node_fs_1.promises.stat(options.projectRoot).catch(() => null);
86
135
  if (!stat?.isDirectory()) {
87
136
  throw new Error(`Project directory not found: ${options.projectRoot}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prisma-guard-lite",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Pre-deploy migration risk checker for Prisma projects",
5
5
  "keywords": [
6
6
  "prisma",