openmrs 4.0.2-pre.336 → 4.0.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.
@@ -1 +1 @@
1
- openmrs:build: cache hit, replaying output 1d7a55aae66b0844
1
+ openmrs:build: cache hit, replaying output 58c23897be9965e7
package/dist/cli.js CHANGED
@@ -121,7 +121,7 @@ yargs.command("develop", "Starts a new frontend module development session with
121
121
  .default("importmap", "importmap.json")
122
122
  .describe("importmap", "The import map to use. Can be a path to a valid import map to be taken literally, an URL, or a fixed JSON object."), (args) => __awaiter(void 0, void 0, void 0, function* () {
123
123
  return runCommand("runDevelop", Object.assign(Object.assign({ configUrls: args["config-url"] }, args), { importmap: (0, utils_1.proxyImportmap)(yield (0, utils_1.mergeImportmap)(yield (0, utils_1.getImportmap)(args.importmap, args.port), args.sources[0] !== false &&
124
- (yield (0, utils_1.runProject)(args.port, args["shared-dependencies"], args.sources))), args.backend, args.host, args.port) }));
124
+ (yield (0, utils_1.runProject)(args.port, args["shared-dependencies"], args.sources)), args.backend, args.spaPath), args.backend, args.host, args.port) }));
125
125
  }));
126
126
  yargs.command("build", "Builds a new app shell.", (argv) => argv
127
127
  .string("target")
@@ -22,33 +22,43 @@ const webpack_1 = require("./webpack");
22
22
  const dependencies_1 = require("./dependencies");
23
23
  const axios_1 = __importDefault(require("axios"));
24
24
  const glob = require("glob");
25
- function readImportmap(path) {
25
+ function readImportmap(path, backend, spaPath) {
26
26
  return __awaiter(this, void 0, void 0, function* () {
27
27
  if (path.startsWith("http://") || path.startsWith("https://")) {
28
- return yield axios_1.default
29
- .get(path)
30
- .then((res) => res.data)
31
- .then((m) => (typeof m === "string" ? JSON.parse(m) : m))
32
- .then((m) => {
33
- if (typeof m === "object" && "imports" in m) {
34
- Object.keys(m.imports).forEach((key) => {
35
- const url = m.imports[key];
36
- if (typeof url === "string") {
37
- m.imports[key] = new url_1.URL(url, path).href;
38
- }
39
- });
40
- }
41
- return m;
42
- })
43
- .then((m) => JSON.stringify(m));
28
+ return fetchRemoteImportmap(path);
44
29
  }
45
30
  else if (path === "importmap.json") {
46
- const path = require.resolve("@openmrs/esm-app-shell/src/assets/importmap.json");
47
- return (0, fs_1.readFileSync)(path, "utf8");
31
+ if (backend && spaPath) {
32
+ try {
33
+ return yield fetchRemoteImportmap(`${backend}/${spaPath}/importmap.json`);
34
+ }
35
+ catch (_a) { }
36
+ }
37
+ return fetchRemoteImportmap("https://dev3.openmrs.org/openmrs/spa/importmap.json");
48
38
  }
49
39
  return '{"imports":{}}';
50
40
  });
51
41
  }
42
+ function fetchRemoteImportmap(fetchUrl) {
43
+ return __awaiter(this, void 0, void 0, function* () {
44
+ return yield axios_1.default
45
+ .get(fetchUrl)
46
+ .then((res) => res.data)
47
+ .then((m) => (typeof m === "string" ? JSON.parse(m) : m))
48
+ .then((m) => {
49
+ if (typeof m === "object" && "imports" in m) {
50
+ Object.keys(m.imports).forEach((key) => {
51
+ const url = m.imports[key];
52
+ if (typeof url === "string") {
53
+ m.imports[key] = new url_1.URL(url, fetchUrl).href;
54
+ }
55
+ });
56
+ }
57
+ return m;
58
+ })
59
+ .then((m) => JSON.stringify(m));
60
+ });
61
+ }
52
62
  function checkImportmapJson(value) {
53
63
  try {
54
64
  const content = JSON.parse(value);
@@ -137,12 +147,12 @@ exports.runProject = runProject;
137
147
  * there are new imports to add, and if the original import map declaration
138
148
  * had type "url", it is downloaded and resolved to one of type "inline".
139
149
  */
140
- function mergeImportmap(decl, additionalImports) {
150
+ function mergeImportmap(decl, additionalImports, backend, spaPath) {
141
151
  return __awaiter(this, void 0, void 0, function* () {
142
152
  if (additionalImports && Object.keys(additionalImports).length > 0) {
143
153
  if (decl.type === "url") {
144
154
  decl.type = "inline";
145
- decl.value = yield readImportmap(decl.value);
155
+ decl.value = yield readImportmap(decl.value, backend, spaPath);
146
156
  }
147
157
  const map = JSON.parse(decl.value);
148
158
  decl.value = JSON.stringify({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openmrs",
3
- "version": "4.0.2-pre.336",
3
+ "version": "4.0.2",
4
4
  "license": "MPL-2.0",
5
5
  "main": "dist/index.js",
6
6
  "bin": "./dist/cli.js",
@@ -30,8 +30,8 @@
30
30
  ],
31
31
  "homepage": "https://github.com/openmrs/openmrs-esm-core#readme",
32
32
  "dependencies": {
33
- "@openmrs/esm-app-shell": "4.0.2-pre.336",
34
- "@openmrs/webpack-config": "4.0.2-pre.336",
33
+ "@openmrs/esm-app-shell": "4.0.2",
34
+ "@openmrs/webpack-config": "4.0.2",
35
35
  "autoprefixer": "^10.4.2",
36
36
  "axios": "^0.21.1",
37
37
  "browserslist-config-openmrs": "^1.0.1",
@@ -65,5 +65,5 @@
65
65
  "@types/systemjs": "^6.1.0",
66
66
  "@types/tar": "^4.0.3"
67
67
  },
68
- "gitHead": "214eea9966cddd5723d48c80b6aaac0a26c6d7c3"
68
+ "gitHead": "cfd4f3a1a3746bff9ef8bc369033b77a0587be5c"
69
69
  }
package/src/cli.ts CHANGED
@@ -187,7 +187,9 @@ yargs.command(
187
187
  args.port,
188
188
  args["shared-dependencies"],
189
189
  args.sources
190
- ))
190
+ )),
191
+ args.backend,
192
+ args.spaPath
191
193
  ),
192
194
  args.backend,
193
195
  args.host,
@@ -9,35 +9,46 @@ import axios from "axios";
9
9
 
10
10
  import glob = require("glob");
11
11
 
12
- async function readImportmap(path: string) {
12
+ async function readImportmap(path: string, backend?: string, spaPath?: string) {
13
13
  if (path.startsWith("http://") || path.startsWith("https://")) {
14
- return await axios
15
- .get(path)
16
- .then((res) => res.data)
17
- .then((m) => (typeof m === "string" ? JSON.parse(m) : m))
18
- .then((m) => {
19
- if (typeof m === "object" && "imports" in m) {
20
- Object.keys(m.imports).forEach((key) => {
21
- const url = m.imports[key];
22
-
23
- if (typeof url === "string") {
24
- m.imports[key] = new URL(url, path).href;
25
- }
26
- });
27
- }
28
- return m;
29
- })
30
- .then((m) => JSON.stringify(m));
14
+ return fetchRemoteImportmap(path);
31
15
  } else if (path === "importmap.json") {
32
- const path = require.resolve(
33
- "@openmrs/esm-app-shell/src/assets/importmap.json"
16
+ if (backend && spaPath) {
17
+ try {
18
+ return await fetchRemoteImportmap(
19
+ `${backend}/${spaPath}/importmap.json`
20
+ );
21
+ } catch {}
22
+ }
23
+
24
+ return fetchRemoteImportmap(
25
+ "https://dev3.openmrs.org/openmrs/spa/importmap.json"
34
26
  );
35
- return readFileSync(path, "utf8");
36
27
  }
37
28
 
38
29
  return '{"imports":{}}';
39
30
  }
40
31
 
32
+ async function fetchRemoteImportmap(fetchUrl: string) {
33
+ return await axios
34
+ .get(fetchUrl)
35
+ .then((res) => res.data)
36
+ .then((m) => (typeof m === "string" ? JSON.parse(m) : m))
37
+ .then((m) => {
38
+ if (typeof m === "object" && "imports" in m) {
39
+ Object.keys(m.imports).forEach((key) => {
40
+ const url = m.imports[key];
41
+
42
+ if (typeof url === "string") {
43
+ m.imports[key] = new URL(url, fetchUrl).href;
44
+ }
45
+ });
46
+ }
47
+ return m;
48
+ })
49
+ .then((m) => JSON.stringify(m));
50
+ }
51
+
41
52
  export interface ImportmapDeclaration {
42
53
  type: "inline" | "url";
43
54
  value: string;
@@ -173,12 +184,14 @@ export async function runProject(
173
184
  */
174
185
  export async function mergeImportmap(
175
186
  decl: ImportmapDeclaration,
176
- additionalImports: Record<string, string> | false
187
+ additionalImports: Record<string, string> | false,
188
+ backend?: string,
189
+ spaPath?: string
177
190
  ) {
178
191
  if (additionalImports && Object.keys(additionalImports).length > 0) {
179
192
  if (decl.type === "url") {
180
193
  decl.type = "inline";
181
- decl.value = await readImportmap(decl.value);
194
+ decl.value = await readImportmap(decl.value, backend, spaPath);
182
195
  }
183
196
 
184
197
  const map = JSON.parse(decl.value);