babelfhir-ts 1.0.14 → 1.0.15

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/out/main.js +22 -10
  2. package/package.json +1 -1
package/out/main.js CHANGED
@@ -12,7 +12,7 @@ function printUsage() {
12
12
  console.log("");
13
13
  console.log("Usage:");
14
14
  console.log(" babelfhir-ts [options] [<input> [output]]");
15
- console.log(" babelfhir-ts install [--package] <pkg@version> [--registry <url>] [options]");
15
+ console.log(" babelfhir-ts install [--package] <pkg@version|path> [--registry <url>] [options]");
16
16
  console.log("");
17
17
  console.log("Arguments:");
18
18
  console.log(" input Input can be:");
@@ -35,12 +35,13 @@ function printUsage() {
35
35
  console.log(" --registry <url> FHIR package registry URL (default: https://packages.simplifier.net)");
36
36
  console.log("");
37
37
  console.log("Examples:");
38
- console.log(" babelfhir-ts # Process ./input to ./output");
39
- console.log(" babelfhir-ts package.tgz # Process package to ./output");
38
+ console.log(" babelfhir-ts # Process ./input to ./output");
39
+ console.log(" babelfhir-ts package.tgz # Process package to current directory");
40
40
  console.log(" babelfhir-ts package.tgz modified-package.tgz # Embed interfaces in package");
41
41
  console.log(" babelfhir-ts profiles/ generated/ # Process directory to directory");
42
42
  console.log(" babelfhir-ts --package hl7.fhir.us.core@8.0.0 # Download and process from default registry");
43
43
  console.log(" babelfhir-ts install de.gematik.isik-basismodul@3.1.0 # Download, process, and npm install");
44
+ console.log(" babelfhir-ts install ./package.tgz # Install from local package file");
44
45
  console.log(" babelfhir-ts install hl7.fhir.us.core@8.0.0 --registry <url> # Install from custom registry");
45
46
  console.log(" babelfhir-ts install --package hl7.fhir.us.core@8.0.0 --registry <url> # Alternative syntax");
46
47
  }
@@ -203,22 +204,33 @@ async function run() {
203
204
  // Package can come from --package flag OR as positional argument after 'install'
204
205
  const packageToInstall = packageSpec || positionals[1];
205
206
  if (!packageToInstall) {
206
- console.error('Error: install command requires a package name');
207
+ console.error('Error: install command requires a package name or local .tgz/.zip file');
207
208
  console.error('Example: babelfhir-ts install de.gematik.isik-basismodul@3.1.0');
208
209
  console.error(' or: babelfhir-ts install --package hl7.fhir.us.core@8.0.0');
210
+ console.error(' or: babelfhir-ts install ./package.tgz');
209
211
  process.exit(1);
210
212
  }
211
213
  try {
212
- // Download and process package
213
- const downloadedPath = await downloadPackage(packageToInstall, registry);
214
+ let downloadedPath;
215
+ // Check if packageToInstall is a local file path
216
+ if (fs.existsSync(packageToInstall) && (packageToInstall.endsWith('.tgz') || packageToInstall.endsWith('.zip'))) {
217
+ console.log(`Using local package: ${packageToInstall}`);
218
+ downloadedPath = path.resolve(packageToInstall);
219
+ }
220
+ else {
221
+ // Download from registry
222
+ downloadedPath = await downloadPackage(packageToInstall, registry);
223
+ }
214
224
  console.log(`Processing package...`);
215
225
  const baseName = path.basename(downloadedPath, path.extname(downloadedPath));
216
226
  const outputArchive = path.join(process.cwd(), `${baseName}.with-generated.tgz`);
217
227
  await generateIntoPackage(downloadedPath, outputArchive, flags);
218
- // Clean up temp directory
219
- const tempDir = path.join(process.cwd(), '.temp-download');
220
- if (fs.existsSync(tempDir)) {
221
- fs.rmSync(tempDir, { recursive: true, force: true });
228
+ // Clean up temp directory only if we downloaded from registry (not for local files)
229
+ if (!fs.existsSync(packageToInstall) || !(packageToInstall.endsWith('.tgz') || packageToInstall.endsWith('.zip'))) {
230
+ const tempDir = path.join(process.cwd(), '.temp-download');
231
+ if (fs.existsSync(tempDir)) {
232
+ fs.rmSync(tempDir, { recursive: true, force: true });
233
+ }
222
234
  }
223
235
  console.log(`✓ Package processed successfully: ${path.basename(outputArchive)}`);
224
236
  // Extract the archive to access generated folder
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "babelfhir-ts",
3
- "version": "1.0.14",
3
+ "version": "1.0.15",
4
4
  "description": "BabelFHIR-TS: generate TypeScript interfaces, validators, and helper classes from FHIR R4 StructureDefinitions (profiles) directly inside package archives.",
5
5
  "type": "module",
6
6
  "main": "out/main.js",