@atomic-ehr/fhir-canonical-manager 0.0.13 → 0.0.14

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 (160) hide show
  1. package/dist/cache.d.ts +16 -0
  2. package/dist/cache.d.ts.map +1 -0
  3. package/dist/cache.js +49 -0
  4. package/dist/cache.js.map +1 -0
  5. package/dist/cli/index.d.ts.map +1 -1
  6. package/dist/cli/index.js +15 -15
  7. package/dist/cli/index.js.map +1 -1
  8. package/dist/cli/init.d.ts.map +1 -1
  9. package/dist/cli/init.js +7 -10
  10. package/dist/cli/init.js.map +1 -1
  11. package/dist/cli/list.d.ts.map +1 -1
  12. package/dist/cli/list.js +14 -10
  13. package/dist/cli/list.js.map +1 -1
  14. package/dist/cli/resolve.js +7 -7
  15. package/dist/cli/resolve.js.map +1 -1
  16. package/dist/cli/search.js +9 -9
  17. package/dist/cli/search.js.map +1 -1
  18. package/dist/cli/searchparam.d.ts.map +1 -1
  19. package/dist/cli/searchparam.js +27 -24
  20. package/dist/cli/searchparam.js.map +1 -1
  21. package/dist/fs/index.d.ts +1 -1
  22. package/dist/fs/index.d.ts.map +1 -1
  23. package/dist/fs/index.js +1 -1
  24. package/dist/fs/index.js.map +1 -1
  25. package/dist/fs/utils.js +2 -2
  26. package/dist/fs/utils.js.map +1 -1
  27. package/dist/index.d.ts +6 -6
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/index.js +4 -4
  30. package/dist/index.js.map +1 -1
  31. package/dist/manager/canonical.d.ts +1 -1
  32. package/dist/manager/canonical.d.ts.map +1 -1
  33. package/dist/manager/canonical.js +46 -42
  34. package/dist/manager/canonical.js.map +1 -1
  35. package/dist/manager/index.d.ts +1 -2
  36. package/dist/manager/index.d.ts.map +1 -1
  37. package/dist/manager/index.js +1 -2
  38. package/dist/manager/index.js.map +1 -1
  39. package/dist/package.d.ts +4 -0
  40. package/dist/package.d.ts.map +1 -0
  41. package/dist/package.js +69 -0
  42. package/dist/package.js.map +1 -0
  43. package/dist/reference/index.d.ts +3 -4
  44. package/dist/reference/index.d.ts.map +1 -1
  45. package/dist/reference/index.js +2 -3
  46. package/dist/reference/index.js.map +1 -1
  47. package/dist/reference/manager.d.ts +2 -2
  48. package/dist/reference/manager.d.ts.map +1 -1
  49. package/dist/reference/manager.js +7 -3
  50. package/dist/reference/manager.js.map +1 -1
  51. package/dist/reference/store.d.ts.map +1 -1
  52. package/dist/reference/store.js +1 -1
  53. package/dist/reference/store.js.map +1 -1
  54. package/dist/resolver/context.d.ts +3 -3
  55. package/dist/resolver/context.d.ts.map +1 -1
  56. package/dist/resolver/context.js +1 -1
  57. package/dist/resolver/context.js.map +1 -1
  58. package/dist/resolver/index.d.ts +1 -1
  59. package/dist/resolver/index.js +1 -1
  60. package/dist/scanner/directory.d.ts +2 -2
  61. package/dist/scanner/directory.d.ts.map +1 -1
  62. package/dist/scanner/directory.js +24 -27
  63. package/dist/scanner/directory.js.map +1 -1
  64. package/dist/scanner/index.d.ts +4 -4
  65. package/dist/scanner/index.d.ts.map +1 -1
  66. package/dist/scanner/index.js +4 -4
  67. package/dist/scanner/index.js.map +1 -1
  68. package/dist/scanner/package.d.ts +1 -1
  69. package/dist/scanner/package.d.ts.map +1 -1
  70. package/dist/scanner/package.js +4 -4
  71. package/dist/scanner/package.js.map +1 -1
  72. package/dist/scanner/parser.d.ts +2 -2
  73. package/dist/scanner/parser.d.ts.map +1 -1
  74. package/dist/scanner/parser.js +1 -1
  75. package/dist/scanner/parser.js.map +1 -1
  76. package/dist/scanner/processor.d.ts +2 -2
  77. package/dist/scanner/processor.d.ts.map +1 -1
  78. package/dist/scanner/processor.js +3 -3
  79. package/dist/scanner/processor.js.map +1 -1
  80. package/dist/search/index.d.ts +2 -2
  81. package/dist/search/index.d.ts.map +1 -1
  82. package/dist/search/index.js +2 -2
  83. package/dist/search/index.js.map +1 -1
  84. package/dist/search/smart.d.ts +1 -1
  85. package/dist/search/smart.d.ts.map +1 -1
  86. package/dist/search/smart.js +3 -7
  87. package/dist/search/smart.js.map +1 -1
  88. package/dist/search/terms.js.map +1 -1
  89. package/dist/types/core.d.ts +3 -2
  90. package/dist/types/core.d.ts.map +1 -1
  91. package/dist/types/index.d.ts +2 -2
  92. package/dist/types/index.js +2 -2
  93. package/dist/types/internal.d.ts +7 -4
  94. package/dist/types/internal.d.ts.map +1 -1
  95. package/package.json +12 -2
  96. package/src/cache.ts +58 -0
  97. package/src/cli/index.ts +112 -114
  98. package/src/cli/init.ts +104 -108
  99. package/src/cli/list.ts +84 -77
  100. package/src/cli/resolve.ts +57 -57
  101. package/src/cli/search.ts +72 -72
  102. package/src/cli/searchparam.ts +118 -117
  103. package/src/constants.ts +1 -1
  104. package/src/fs/index.ts +1 -1
  105. package/src/fs/utils.ts +16 -16
  106. package/src/index.ts +9 -12
  107. package/src/manager/canonical.ts +317 -360
  108. package/src/manager/index.ts +1 -3
  109. package/src/package.ts +79 -0
  110. package/src/reference/index.ts +3 -5
  111. package/src/reference/manager.ts +43 -39
  112. package/src/reference/store.ts +7 -8
  113. package/src/resolver/context.ts +17 -17
  114. package/src/resolver/index.ts +1 -1
  115. package/src/scanner/directory.ts +25 -31
  116. package/src/scanner/index.ts +4 -4
  117. package/src/scanner/package.ts +26 -29
  118. package/src/scanner/parser.ts +25 -27
  119. package/src/scanner/processor.ts +51 -55
  120. package/src/search/index.ts +2 -2
  121. package/src/search/smart.ts +41 -48
  122. package/src/search/terms.ts +17 -17
  123. package/src/types/core.ts +102 -89
  124. package/src/types/index.ts +2 -2
  125. package/src/types/internal.ts +36 -34
  126. package/dist/cache/core.d.ts +0 -7
  127. package/dist/cache/core.d.ts.map +0 -1
  128. package/dist/cache/core.js +0 -11
  129. package/dist/cache/core.js.map +0 -1
  130. package/dist/cache/index.d.ts +0 -4
  131. package/dist/cache/index.d.ts.map +0 -1
  132. package/dist/cache/index.js +0 -4
  133. package/dist/cache/index.js.map +0 -1
  134. package/dist/cache/persistence.d.ts +0 -5
  135. package/dist/cache/persistence.d.ts.map +0 -1
  136. package/dist/cache/persistence.js +0 -25
  137. package/dist/cache/persistence.js.map +0 -1
  138. package/dist/cache/validation.d.ts +0 -2
  139. package/dist/cache/validation.d.ts.map +0 -1
  140. package/dist/cache/validation.js +0 -21
  141. package/dist/cache/validation.js.map +0 -1
  142. package/dist/package/detector.d.ts +0 -2
  143. package/dist/package/detector.d.ts.map +0 -1
  144. package/dist/package/detector.js +0 -19
  145. package/dist/package/detector.js.map +0 -1
  146. package/dist/package/index.d.ts +0 -3
  147. package/dist/package/index.d.ts.map +0 -1
  148. package/dist/package/index.js +0 -3
  149. package/dist/package/index.js.map +0 -1
  150. package/dist/package/installer.d.ts +0 -2
  151. package/dist/package/installer.d.ts.map +0 -1
  152. package/dist/package/installer.js +0 -55
  153. package/dist/package/installer.js.map +0 -1
  154. package/src/cache/core.ts +0 -20
  155. package/src/cache/index.ts +0 -7
  156. package/src/cache/persistence.ts +0 -39
  157. package/src/cache/validation.ts +0 -27
  158. package/src/package/detector.ts +0 -24
  159. package/src/package/index.ts +0 -6
  160. package/src/package/installer.ts +0 -77
package/src/cli/index.ts CHANGED
@@ -1,16 +1,15 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import * as fs from "fs";
4
- import * as path from "path";
5
- import { fileURLToPath } from "url";
6
- import { CanonicalManager } from "../index.js";
7
- import type { Config, IndexEntry, PackageInfo } from "../index.js";
3
+ import * as fs from "node:fs";
4
+ import * as path from "node:path";
5
+ import { fileURLToPath } from "node:url";
6
+ import type { Config } from "../index.js";
8
7
 
9
8
  // Command handlers
10
9
  import { initCommand } from "./init.js";
11
10
  import { listCommand } from "./list.js";
12
- import { searchCommand } from "./search.js";
13
11
  import { resolveCommand } from "./resolve.js";
12
+ import { searchCommand } from "./search.js";
14
13
  import { searchParamCommand } from "./searchparam.js";
15
14
 
16
15
  // Get version from package.json
@@ -20,15 +19,15 @@ const packageJsonPath = path.join(__dirname, "..", "..", "package.json");
20
19
 
21
20
  let VERSION = "unknown";
22
21
  try {
23
- const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
24
- VERSION = packageJson.version;
25
- } catch (error) {
26
- // Fallback version if package.json can't be read
27
- VERSION = "0.0.3";
22
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
23
+ VERSION = packageJson.version;
24
+ } catch (_error) {
25
+ // Fallback version if package.json can't be read
26
+ VERSION = "0.0.3";
28
27
  }
29
28
 
30
29
  function showHelp() {
31
- console.log(`
30
+ console.log(`
32
31
  fcm - FHIR Canonical Manager CLI
33
32
 
34
33
  Usage: fcm <command> [options]
@@ -54,130 +53,129 @@ Examples:
54
53
  }
55
54
 
56
55
  async function main() {
57
- const args = process.argv.slice(2);
58
- const command = args[0];
59
-
60
- if (!command || command === "--help" || command === "-h") {
61
- showHelp();
62
- if (process.env.NODE_ENV === 'test') {
63
- return;
56
+ const args = process.argv.slice(2);
57
+ const command = args[0];
58
+
59
+ if (!command || command === "--help" || command === "-h") {
60
+ showHelp();
61
+ if (process.env.NODE_ENV === "test") {
62
+ return;
63
+ }
64
+ process.exit(0);
64
65
  }
65
- process.exit(0);
66
- }
67
66
 
68
- if (command === "--version" || command === "-v") {
69
- console.log(VERSION);
70
- if (process.env.NODE_ENV === 'test') {
71
- return;
67
+ if (command === "--version" || command === "-v") {
68
+ console.log(VERSION);
69
+ if (process.env.NODE_ENV === "test") {
70
+ return;
71
+ }
72
+ process.exit(0);
72
73
  }
73
- process.exit(0);
74
- }
75
-
76
- const commands: Record<string, (args: string[]) => Promise<void>> = {
77
- init: initCommand,
78
- list: listCommand,
79
- search: searchCommand,
80
- resolve: resolveCommand,
81
- searchparam: searchParamCommand,
82
- };
83
-
84
- if (!commands[command]) {
85
- console.error(`Error: Unknown command '${command}'`);
86
- console.error(`Run 'fcm --help' for usage information`);
87
- if (process.env.NODE_ENV === 'test') {
88
- throw new Error(`Unknown command '${command}'`);
74
+
75
+ const commands: Record<string, (args: string[]) => Promise<void>> = {
76
+ init: initCommand,
77
+ list: listCommand,
78
+ search: searchCommand,
79
+ resolve: resolveCommand,
80
+ searchparam: searchParamCommand,
81
+ };
82
+
83
+ if (!commands[command]) {
84
+ console.error(`Error: Unknown command '${command}'`);
85
+ console.error(`Run 'fcm --help' for usage information`);
86
+ if (process.env.NODE_ENV === "test") {
87
+ throw new Error(`Unknown command '${command}'`);
88
+ }
89
+ process.exit(1);
89
90
  }
90
- process.exit(1);
91
- }
92
-
93
- try {
94
- await commands[command](args.slice(1));
95
- } catch (error) {
96
- console.error(
97
- `Error: ${error instanceof Error ? error.message : String(error)}`,
98
- );
99
- if (process.env.NODE_ENV === 'test') {
100
- throw error;
91
+
92
+ try {
93
+ await commands[command](args.slice(1));
94
+ } catch (error) {
95
+ console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);
96
+ if (process.env.NODE_ENV === "test") {
97
+ throw error;
98
+ }
99
+ process.exit(1);
101
100
  }
102
- process.exit(1);
103
- }
104
101
  }
105
102
 
106
103
  // Export utility functions for commands
107
104
  export function parseArgs(args: string[]): {
108
- positional: string[];
109
- options: Record<string, string | boolean>;
105
+ positional: string[];
106
+ options: Record<string, string | boolean>;
110
107
  } {
111
- const positional: string[] = [];
112
- const options: Record<string, string | boolean> = {};
113
-
114
- for (let i = 0; i < args.length; i++) {
115
- const arg = args[i];
116
- if (arg && arg.startsWith("--")) {
117
- const key = arg.slice(2);
118
- const nextArg = args[i + 1];
119
- if (nextArg && !nextArg.startsWith("--")) {
120
- options[key] = nextArg;
121
- i++;
122
- } else {
123
- options[key] = true;
124
- }
125
- } else if (arg && arg.startsWith("-")) {
126
- // Handle short aliases
127
- switch (arg) {
128
- case "-sd":
129
- options.resourceType = "StructureDefinition";
130
- break;
131
- case "-cs":
132
- options.resourceType = "CodeSystem";
133
- break;
134
- case "-vs":
135
- options.resourceType = "ValueSet";
136
- break;
137
- default:
138
- // Handle other single-letter flags
139
- const key = arg.slice(1);
140
- const nextArg = args[i + 1];
141
- if (nextArg && !nextArg.startsWith("-")) {
142
- options[key] = nextArg;
143
- i++;
144
- } else {
145
- options[key] = true;
146
- }
147
- }
148
- } else if (arg) {
149
- positional.push(arg);
108
+ const positional: string[] = [];
109
+ const options: Record<string, string | boolean> = {};
110
+
111
+ for (let i = 0; i < args.length; i++) {
112
+ const arg = args[i];
113
+ if (arg?.startsWith("--")) {
114
+ const key = arg.slice(2);
115
+ const nextArg = args[i + 1];
116
+ if (nextArg && !nextArg.startsWith("--")) {
117
+ options[key] = nextArg;
118
+ i++;
119
+ } else {
120
+ options[key] = true;
121
+ }
122
+ } else if (arg?.startsWith("-")) {
123
+ // Handle short aliases
124
+ switch (arg) {
125
+ case "-sd":
126
+ options.resourceType = "StructureDefinition";
127
+ break;
128
+ case "-cs":
129
+ options.resourceType = "CodeSystem";
130
+ break;
131
+ case "-vs":
132
+ options.resourceType = "ValueSet";
133
+ break;
134
+ default: {
135
+ // Handle other single-letter flags
136
+ const key = arg.slice(1);
137
+ const nextArg = args[i + 1];
138
+ if (nextArg && !nextArg.startsWith("-")) {
139
+ options[key] = nextArg;
140
+ i++;
141
+ } else {
142
+ options[key] = true;
143
+ }
144
+ }
145
+ }
146
+ } else if (arg) {
147
+ positional.push(arg);
148
+ }
150
149
  }
151
- }
152
150
 
153
- return { positional, options };
151
+ return { positional, options };
154
152
  }
155
153
 
156
154
  export async function loadPackageJson(): Promise<any> {
157
- const packagePath = path.join(process.cwd(), "package.json");
158
- try {
159
- if (fs.existsSync(packagePath)) {
160
- const content = fs.readFileSync(packagePath, "utf-8");
161
- return JSON.parse(content);
155
+ const packagePath = path.join(process.cwd(), "package.json");
156
+ try {
157
+ if (fs.existsSync(packagePath)) {
158
+ const content = fs.readFileSync(packagePath, "utf-8");
159
+ return JSON.parse(content);
160
+ }
161
+ } catch (_error) {
162
+ // Ignore parse errors
162
163
  }
163
- } catch (error) {
164
- // Ignore parse errors
165
- }
166
- return null;
164
+ return null;
167
165
  }
168
166
 
169
167
  export async function savePackageJson(data: any): Promise<void> {
170
- const packagePath = path.join(process.cwd(), "package.json");
171
- fs.writeFileSync(packagePath, JSON.stringify(data, null, 2) + "\n");
168
+ const packagePath = path.join(process.cwd(), "package.json");
169
+ fs.writeFileSync(packagePath, `${JSON.stringify(data, null, 2)}\n`);
172
170
  }
173
171
 
174
172
  export function getConfigFromPackageJson(packageJson: any): Partial<Config> {
175
- const fcm = packageJson?.fcm || {};
176
- return {
177
- packages: fcm.packages || [],
178
- registry: fcm.registry,
179
- workingDir: process.cwd(),
180
- };
173
+ const fcm = packageJson?.fcm || {};
174
+ return {
175
+ packages: fcm.packages || [],
176
+ registry: fcm.registry,
177
+ workingDir: process.cwd(),
178
+ };
181
179
  }
182
180
 
183
181
  main();
package/src/cli/init.ts CHANGED
@@ -1,116 +1,112 @@
1
- import * as fs from "fs";
2
- import * as path from "path";
3
- import { exec } from "child_process";
4
- import { promisify } from "util";
5
- import { parseArgs, loadPackageJson, savePackageJson } from "./index.js";
1
+ import { exec } from "node:child_process";
2
+ import * as path from "node:path";
3
+ import { promisify } from "node:util";
6
4
  import { CanonicalManager } from "../index.js";
5
+ import { loadPackageJson, parseArgs, savePackageJson } from "./index.js";
7
6
 
8
7
  const execAsync = promisify(exec);
9
8
 
10
9
  export async function initCommand(args: string[]): Promise<void> {
11
- const { positional, options } = parseArgs(args);
12
- const packages = positional;
13
- const registry = options.registry as string | undefined;
14
-
15
- // Load or create package.json
16
- let packageJson = await loadPackageJson();
17
- const isNewPackageJson = !packageJson;
18
-
19
- if (!packageJson) {
20
- // Create minimal package.json
21
- packageJson = {
22
- name: path.basename(process.cwd()),
23
- version: "1.0.0",
24
- type: "module",
25
- };
26
- }
27
-
28
- // Initialize fcm config
29
- if (!packageJson.fcm) {
30
- packageJson.fcm = {
31
- packages: [],
32
- registry: registry
33
- ? (registry.endsWith('/') ? registry : `${registry}/`)
34
- : "https://fs.get-ig.org/pkgs/",
35
- };
36
- }
37
-
38
- // If no packages specified, use packages from config
39
- const packagesToInstall =
40
- packages.length > 0 ? packages : packageJson.fcm.packages;
41
-
42
- if (packagesToInstall.length === 0) {
43
- console.error("Error: No packages specified");
44
- console.error("Usage: fcm init [packages...]");
45
- console.error("Example: fcm init hl7.fhir.r4.core hl7.fhir.us.core@5.0.1");
46
- if (process.env.NODE_ENV === 'test') {
47
- throw new Error("No packages specified");
10
+ const { positional, options } = parseArgs(args);
11
+ const packages = positional;
12
+ const registry = options.registry as string | undefined;
13
+
14
+ // Load or create package.json
15
+ let packageJson = await loadPackageJson();
16
+ const isNewPackageJson = !packageJson;
17
+
18
+ if (!packageJson) {
19
+ // Create minimal package.json
20
+ packageJson = {
21
+ name: path.basename(process.cwd()),
22
+ version: "1.0.0",
23
+ type: "module",
24
+ };
48
25
  }
49
- process.exit(1);
50
- }
51
-
52
- // Update fcm packages list (merge with existing)
53
- const existingPackages = new Set(packageJson.fcm.packages);
54
- packagesToInstall.forEach((pkg: string) => {
55
- existingPackages.add(pkg);
56
- });
57
- packageJson.fcm.packages = Array.from(existingPackages);
58
-
59
- // Update registry if provided, ensuring it ends with /
60
- if (registry) {
61
- packageJson.fcm.registry = registry.endsWith('/') ? registry : `${registry}/`;
62
- }
63
-
64
- // Initialize dependencies if not present
65
- if (!packageJson.dependencies) {
66
- packageJson.dependencies = {};
67
- }
68
-
69
- // Save package.json
70
- await savePackageJson(packageJson);
71
-
72
- if (isNewPackageJson) {
73
- console.log("Created package.json");
74
- }
75
-
76
- // Install packages using npm
77
- console.log("Installing FHIR packages...");
78
-
79
- for (const pkg of packagesToInstall) {
80
- console.log(`Installing ${pkg}...`);
81
- try {
82
- const command = packageJson.fcm.registry
83
- ? `npm install ${pkg} --registry ${packageJson.fcm.registry}`
84
- : `npm install ${pkg}`;
85
-
86
- await execAsync(command, {
87
- cwd: process.cwd(),
88
- maxBuffer: 10 * 1024 * 1024, // 10MB buffer
89
- });
90
- } catch (error) {
91
- console.error(`Failed to install ${pkg}`);
92
- throw error;
26
+
27
+ // Initialize fcm config
28
+ if (!packageJson.fcm) {
29
+ packageJson.fcm = {
30
+ packages: [],
31
+ registry: registry ? (registry.endsWith("/") ? registry : `${registry}/`) : "https://fs.get-ig.org/pkgs/",
32
+ };
33
+ }
34
+
35
+ // If no packages specified, use packages from config
36
+ const packagesToInstall = packages.length > 0 ? packages : packageJson.fcm.packages;
37
+
38
+ if (packagesToInstall.length === 0) {
39
+ console.error("Error: No packages specified");
40
+ console.error("Usage: fcm init [packages...]");
41
+ console.error("Example: fcm init hl7.fhir.r4.core hl7.fhir.us.core@5.0.1");
42
+ if (process.env.NODE_ENV === "test") {
43
+ throw new Error("No packages specified");
44
+ }
45
+ process.exit(1);
46
+ }
47
+
48
+ // Update fcm packages list (merge with existing)
49
+ const existingPackages = new Set(packageJson.fcm.packages);
50
+ packagesToInstall.forEach((pkg: string) => {
51
+ existingPackages.add(pkg);
52
+ });
53
+ packageJson.fcm.packages = Array.from(existingPackages);
54
+
55
+ // Update registry if provided, ensuring it ends with /
56
+ if (registry) {
57
+ packageJson.fcm.registry = registry.endsWith("/") ? registry : `${registry}/`;
58
+ }
59
+
60
+ // Initialize dependencies if not present
61
+ if (!packageJson.dependencies) {
62
+ packageJson.dependencies = {};
63
+ }
64
+
65
+ // Save package.json
66
+ await savePackageJson(packageJson);
67
+
68
+ if (isNewPackageJson) {
69
+ console.log("Created package.json");
93
70
  }
94
- }
95
-
96
- // Initialize CanonicalManager to build cache
97
- console.log("Building package index...");
98
- console.log("Registry", packageJson?.fcm?.registry);
99
- const manager = CanonicalManager({
100
- packages: packageJson.fcm.packages,
101
- workingDir: process.cwd(),
102
- registry: packageJson.fcm.registry,
103
- });
104
-
105
- await manager.init();
106
-
107
- // Show summary
108
- const installedPackages = await manager.packages();
109
- console.log("\nInstalled packages:");
110
- installedPackages.forEach((pkg) => {
111
- console.log(` ${pkg.name}@${pkg.version}`);
112
- });
113
-
114
- await manager.destroy();
115
- console.log("\nInitialization complete!");
71
+
72
+ // Install packages using npm
73
+ console.log("Installing FHIR packages...");
74
+
75
+ for (const pkg of packagesToInstall) {
76
+ console.log(`Installing ${pkg}...`);
77
+ try {
78
+ const command = packageJson.fcm.registry
79
+ ? `npm install ${pkg} --registry ${packageJson.fcm.registry}`
80
+ : `npm install ${pkg}`;
81
+
82
+ await execAsync(command, {
83
+ cwd: process.cwd(),
84
+ maxBuffer: 10 * 1024 * 1024, // 10MB buffer
85
+ });
86
+ } catch (error) {
87
+ console.error(`Failed to install ${pkg}`);
88
+ throw error;
89
+ }
90
+ }
91
+
92
+ // Initialize CanonicalManager to build cache
93
+ console.log("Building package index...");
94
+ console.log("Registry", packageJson?.fcm?.registry);
95
+ const manager = CanonicalManager({
96
+ packages: packageJson.fcm.packages,
97
+ workingDir: process.cwd(),
98
+ registry: packageJson.fcm.registry,
99
+ });
100
+
101
+ await manager.init();
102
+
103
+ // Show summary
104
+ const installedPackages = await manager.packages();
105
+ console.log("\nInstalled packages:");
106
+ installedPackages.forEach((pkg) => {
107
+ console.log(` ${pkg.name}@${pkg.version}`);
108
+ });
109
+
110
+ await manager.destroy();
111
+ console.log("\nInitialization complete!");
116
112
  }