@guanlin4924/devflow-pi 0.1.4 → 0.1.5

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/cli.ts +10 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guanlin4924/devflow-pi",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "type": "module",
5
5
  "description": "Devflow 专项研发 Pi,基于固定版本 OMP Runtime 组装研发状态机、代码智能、设计、实现与质量门禁。",
6
6
  "license": "UNLICENSED",
package/src/cli.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env bun
2
2
 
3
3
  import path from "node:path";
4
+ import { readFileSync } from "node:fs";
4
5
 
5
6
  import { formatDoctor, runHostDoctor } from "./doctor.ts";
6
7
  import { initializeProject, loadProjectContext, resolveProjectRoot } from "./project-context.ts";
@@ -17,6 +18,11 @@ function usage(): string {
17
18
  ].join("\n");
18
19
  }
19
20
 
21
+ function packageVersion(): string {
22
+ const packageJson = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")) as { version?: unknown };
23
+ return typeof packageJson.version === "string" ? packageJson.version : "unknown";
24
+ }
25
+
20
26
  function option(args: string[], name: string): string | undefined {
21
27
  const index = args.indexOf(name);
22
28
  return index >= 0 ? args[index + 1] : undefined;
@@ -32,6 +38,10 @@ function optionalOption(args: string[], name: string): boolean | string | undefi
32
38
  async function main(): Promise<void> {
33
39
  const args = process.argv.slice(2);
34
40
  const command = args[0];
41
+ if (command === "--version" || command === "-v" || command === "version") {
42
+ console.log(packageVersion());
43
+ return;
44
+ }
35
45
  if (command === "--help" || command === "-h" || command === "help") {
36
46
  console.log(usage());
37
47
  return;