Skip to content

Commit

Permalink
Improved the CLI with the run-project option
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianRappl committed Oct 15, 2020
1 parent 6d9edc7 commit a730b0c
Show file tree
Hide file tree
Showing 3 changed files with 810 additions and 836 deletions.
2 changes: 1 addition & 1 deletion packages/openmrs/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ yargs.command(
.default("spa-path", "/openmrs/spa/")
.describe("spa-path", "The path of the application on the target server.")
.string("api-url")
.default("api-url", "/openmrs/spa/")
.default("api-url", "/openmrs/")
.describe(
"api-url",
"The URL of the API. Can be a path if the API is on the same target server."
Expand Down
21 changes: 17 additions & 4 deletions packages/openmrs/src/utils/importmap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,22 @@ import { startWebpack } from "./webpack";
import { getDependentModules, getMainBundle } from "./dependencies";
import axios from "axios";

async function readImportmap(path: string) {
if (path.startsWith("http://") || path.startsWith("https://")) {
return await axios
.get(path)
.then((res) => res.data)
.then((m) => (typeof m !== "string" ? JSON.stringify(m) : m));
} else if (path === "importmap.json") {
const path = require.resolve(
"@openmrs/esm-app-shell/src/assets/importmap.json"
);
return readFileSync(path, "utf8");
}

return '{"imports":{}}';
}

export interface ImportmapDeclaration {
type: "inline" | "url";
value: string;
Expand Down Expand Up @@ -61,10 +77,7 @@ export async function mergeImportmap(
if (imports && Object.keys(imports).length > 0) {
if (decl.type === "url") {
decl.type = "inline";
decl.value = await axios
.get(decl.value)
.then((res) => res.data)
.then((m) => (typeof m !== "string" ? JSON.stringify(m) : m));
decl.value = await readImportmap(decl.value);
}

const map = JSON.parse(decl.value);
Expand Down
Loading

0 comments on commit a730b0c

Please sign in to comment.