spine-rigc 2.19.1 → 2.20.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.
@@ -0,0 +1,48 @@
1
+ /**
2
+ * The package's own metadata — its installed version and repository — read
3
+ * once from the `package.json` beside the code.
4
+ *
5
+ * Moved here unchanged from `src/cli/shared.ts` (issue #1230), which imports
6
+ * these back and re-exports every name it exported before, so no caller
7
+ * changed an import. They moved because the motion comparison
8
+ * (`src/meshcompare.ts`) records the version of the poser that ran
9
+ * (`MeshQualityReport.poser`, P2 of docs/MESH_REDUCTION.md), and a library
10
+ * module that read it through `src/cli/shared.ts` would load the whole CLI —
11
+ * the compiler, `check` and every command body — to read one string. One
12
+ * reader, in the one place both can reach.
13
+ *
14
+ * Imports nothing but `node:fs` and `node:path`: no clock, no runtime.
15
+ */
16
+ import { readFileSync } from 'node:fs';
17
+ import { join } from 'node:path';
18
+
19
+ interface PackageMeta {
20
+ version?: string;
21
+ repository?: string | { url?: string };
22
+ }
23
+
24
+ let packageMeta: PackageMeta | null | undefined;
25
+
26
+ /**
27
+ * The directory `cli.ts` sits in: `package.json`, `skills/` and, in a
28
+ * checkout, `examples/` and `scripts/` are beside it, in the repository and
29
+ * once installed. One level above this file (`src/`) — the same directory
30
+ * `src/cli/shared.ts` reached two levels above itself before the reader moved.
31
+ */
32
+ export const PACKAGE_ROOT = join(import.meta.dir, '..');
33
+
34
+ /** `package.json` sits next to `cli.ts` both in the repo and once installed (`PACKAGE_ROOT`). */
35
+ export function readPackageMeta(): PackageMeta | null {
36
+ if (packageMeta === undefined) {
37
+ try {
38
+ packageMeta = JSON.parse(readFileSync(join(PACKAGE_ROOT, 'package.json'), 'utf8')) as PackageMeta;
39
+ } catch {
40
+ packageMeta = null;
41
+ }
42
+ }
43
+ return packageMeta;
44
+ }
45
+
46
+ export function readVersion(): string {
47
+ return readPackageMeta()?.version ?? 'unknown';
48
+ }