@forwardimpact/map 0.15.0 → 0.15.2

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/bin/fit-map.js +19 -31
  2. package/package.json +5 -4
package/bin/fit-map.js CHANGED
@@ -12,9 +12,12 @@
12
12
  * --help Show help
13
13
  */
14
14
 
15
- import { stat } from "fs/promises";
15
+ import fs from "fs/promises";
16
16
  import { join, resolve, dirname } from "path";
17
17
  import { fileURLToPath } from "url";
18
+ import { homedir } from "os";
19
+ import { Finder } from "@forwardimpact/libutil";
20
+ import { createLogger } from "@forwardimpact/libtelemetry";
18
21
 
19
22
  const __filename = fileURLToPath(import.meta.url);
20
23
  const __dirname = dirname(__filename);
@@ -48,46 +51,31 @@ function parseArgs(args) {
48
51
  return { command, subcommand, options, positional: rest };
49
52
  }
50
53
 
51
- /**
52
- * Check if a directory exists
53
- */
54
- async function dirExists(path) {
55
- try {
56
- const stats = await stat(path);
57
- return stats.isDirectory();
58
- } catch {
59
- return false;
60
- }
61
- }
62
-
63
54
  /**
64
55
  * Find the data directory
56
+ * @param {string|undefined} providedPath - Explicit path from --data flag
57
+ * @returns {Promise<string>} Resolved data directory path
65
58
  */
66
59
  async function findDataDir(providedPath) {
67
60
  if (providedPath) {
68
61
  const resolved = resolve(providedPath);
69
- if (await dirExists(resolved)) {
70
- return resolved;
62
+ try {
63
+ await fs.access(resolved);
64
+ } catch {
65
+ throw new Error(`Data directory not found: ${providedPath}`);
71
66
  }
72
- throw new Error(`Data directory not found: ${providedPath}`);
67
+ return resolved;
73
68
  }
74
69
 
75
- const candidates = [
76
- join(process.cwd(), "data/pathway"),
77
- join(process.cwd(), "examples/pathway"),
78
- join(process.cwd(), "data"),
79
- join(process.cwd(), "examples"),
80
- ];
81
-
82
- for (const candidate of candidates) {
83
- if (await dirExists(candidate)) {
84
- return candidate;
85
- }
70
+ const logger = createLogger("map");
71
+ const finder = new Finder(fs, logger, process);
72
+ try {
73
+ return join(finder.findData("data", homedir()), "pathway");
74
+ } catch {
75
+ throw new Error(
76
+ "No data directory found. Use --data=<path> to specify location.",
77
+ );
86
78
  }
87
-
88
- throw new Error(
89
- "No data directory found. Use --data=PATH to specify location.",
90
- );
91
79
  }
92
80
 
93
81
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forwardimpact/map",
3
- "version": "0.15.0",
3
+ "version": "0.15.2",
4
4
  "description": "Public data model for career frameworks, consumed by AI agents and engineers",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -46,12 +46,13 @@
46
46
  "./activity/transform": "./activity/transform/index.js"
47
47
  },
48
48
  "dependencies": {
49
- "ajv": "^8.17.1",
49
+ "@forwardimpact/libutil": "^0.1.64",
50
+ "ajv": "^8.18.0",
50
51
  "ajv-formats": "^3.0.1",
51
- "yaml": "^2.3.4"
52
+ "yaml": "^2.8.3"
52
53
  },
53
54
  "devDependencies": {
54
- "n3": "^2.0.1"
55
+ "n3": "^2.0.3"
55
56
  },
56
57
  "engines": {
57
58
  "node": ">=18.0.0"