Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Old FPL Code #35

Merged
merged 1 commit into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
185 changes: 85 additions & 100 deletions README.md

Large diffs are not rendered by default.

509 changes: 0 additions & 509 deletions src/FHIRDefinitions.ts

This file was deleted.

39 changes: 0 additions & 39 deletions src/api.ts

This file was deleted.

37 changes: 26 additions & 11 deletions src/app.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
#!/usr/bin/env node

import { program, OptionValues } from 'commander';
import path from 'path';
import fs from 'fs-extra';
import { loadDependencies } from './load';
import os from 'os';
import initSqlJs from 'sql.js';
import { logger } from './utils';
import { program, OptionValues } from 'commander';
import { BasePackageLoader } from './loader';
import { SQLJSPackageDB } from './db';
import { DiskBasedPackageCache } from './cache';
import { DefaultRegistryClient } from './registry';
import { BuildDotFhirDotOrgClient } from './current';

function getVersion(): string {
const packageJSONPath = path.join(__dirname, '..', 'package.json');
Expand All @@ -18,21 +24,30 @@ function getVersion(): string {
function getHelpText(): string {
return `
Examples:
fpl install hl7.fhir.us.core@current
fpl install hl7.fhir.us.core@4.0.0 hl7.fhir.us.mcode@2.0.0 --cachePath ./myProject`;
fpl install hl7.fhir.us.core#current
fpl install hl7.fhir.us.core#4.0.0 hl7.fhir.us.mcode#2.0.0 --cachePath ./myProject`;
}

async function install(fhirPackages: string[], options: OptionValues) {
if (options.debug) logger.level = 'debug';

const packages = fhirPackages.map(dep => dep.replace('@', '#'));
const cachePath = options.cachePath;

const logMessage = (level: string, message: string) => {
const log = (level: string, message: string) => {
logger.log(level, message);
};

await loadDependencies(packages, cachePath, logMessage);
const SQL = await initSqlJs();
const packageDB = new SQLJSPackageDB(new SQL.Database());
const fhirCache = options.cachePath ?? path.join(os.homedir(), '.fhir', 'packages');
const packageCache = new DiskBasedPackageCache(fhirCache, [], { log });
const registryClient = new DefaultRegistryClient({ log });
const buildClient = new BuildDotFhirDotOrgClient({ log });
const loader = new BasePackageLoader(packageDB, packageCache, registryClient, buildClient, {
log
});

for (const pkg of fhirPackages) {
const [name, version] = pkg.split(/[#@]/, 2);
await loader.loadPackage(name, version);
}
}

async function app() {
Expand All @@ -48,7 +63,7 @@ async function app() {
.usage('<fhirPackages...> [options]')
.argument(
'<fhirPackages...>',
'list of FHIR packages to load using the format packageId@packageVersion...'
'list of FHIR packages to load using the format packageId#packageVersion or packageId@packageVersion'
)
.option(
'-c, --cachePath <dir>',
Expand Down
3 changes: 2 additions & 1 deletion src/current/BuildDotFhirDotOrgClient.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Readable } from 'stream';
import { LogFunction, axiosGet } from '../utils';
import { CurrentPackageLoadError } from '../errors';
import { CurrentBuildClient, CurrentBuildClientOptions } from './CurrentBuildClient';

export class BuildDotFhirDotOrgClient implements CurrentBuildClient {
Expand All @@ -12,7 +13,7 @@ export class BuildDotFhirDotOrgClient implements CurrentBuildClient {
const version = branch ? `current$${branch}` : 'current';
const baseURL = await this.getCurrentBuildBaseURL(name, branch);
if (!baseURL) {
throw new Error(`Failed to download ${name}#${version}`);
throw new CurrentPackageLoadError(`${name}#${version}`);
}
const url = `${baseURL}/package.tgz`;
this.log('info', `Attempting to download ${name}#${version} from ${url}`);
Expand Down
8 changes: 0 additions & 8 deletions src/errors/InvalidPackageError.ts

This file was deleted.

13 changes: 0 additions & 13 deletions src/errors/PackageLoadError.ts

This file was deleted.

2 changes: 0 additions & 2 deletions src/errors/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
export * from './CurrentPackageLoadError';
export * from './IncorrectWildcardVersionFormatError';
export * from './InvalidPackageError';
export * from './InvalidResourceError';
export * from './LatestVersionUnavailableError';
export * from './PackageLoadError';
3 changes: 0 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
export * from './api';
export * from './errors';
export * from './FHIRDefinitions';
export * from './load';
export * from './utils';
export * from './cache';
export * from './current';
Expand Down
Loading