openmrs 5.7.3-pre.2139 → 5.7.3-pre.2142
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.
- package/dist/cli.js +15 -7
- package/dist/commands/assemble.js +17 -3
- package/package.json +3 -3
- package/src/cli.ts +16 -7
- package/src/commands/assemble.ts +25 -4
package/dist/cli.js
CHANGED
|
@@ -164,6 +164,7 @@ yargs_1.default.command('build', 'Builds a new app shell.', (argv) => argv
|
|
|
164
164
|
default: [],
|
|
165
165
|
describe: 'The path to a frontend configuration file. Can be used multiple times. The file is copied directly into the build directory.',
|
|
166
166
|
type: 'array',
|
|
167
|
+
coerce: (arg) => arg.map((p) => (0, path_1.resolve)(process.cwd(), p)),
|
|
167
168
|
})
|
|
168
169
|
.option('importmap', {
|
|
169
170
|
default: undefined,
|
|
@@ -180,9 +181,9 @@ yargs_1.default.command('build', 'Builds a new app shell.', (argv) => argv
|
|
|
180
181
|
describe: "The locale to use as a default for this build of the app shell. Should be a value that's valid to use in an HTML lang attribute, e.g., en or en_GB.",
|
|
181
182
|
type: 'string',
|
|
182
183
|
}), async (args) => runCommand('runBuild', {
|
|
183
|
-
configUrls: args['config-url'],
|
|
184
|
-
configPaths: args['config-path'].map((p) => (0, path_1.resolve)(process.cwd(), p)),
|
|
185
184
|
...args,
|
|
185
|
+
configUrls: args['config-url'],
|
|
186
|
+
configPaths: args['config-path'],
|
|
186
187
|
}));
|
|
187
188
|
yargs_1.default.command('assemble', 'Assembles an import map incl. all required resources.', (argv) => argv
|
|
188
189
|
.option('target', {
|
|
@@ -200,13 +201,20 @@ yargs_1.default.command('assemble', 'Assembles an import map incl. all required
|
|
|
200
201
|
})
|
|
201
202
|
.option('config', {
|
|
202
203
|
default: ['spa-build-config.json'],
|
|
203
|
-
description: 'Path to a SPA
|
|
204
|
+
description: 'Path to a SPA assemble config JSON.',
|
|
205
|
+
type: 'array',
|
|
206
|
+
coerce: (arg) => arg.map((p) => (0, path_1.resolve)(process.cwd(), p)),
|
|
207
|
+
})
|
|
208
|
+
.option('config-file', {
|
|
209
|
+
default: [],
|
|
210
|
+
describe: 'Reference to a frontend configuration file. Can be used multiple times. Configurations are merged in the order specified into openmrs-config.json.',
|
|
204
211
|
type: 'array',
|
|
205
212
|
coerce: (arg) => arg.map((p) => (0, path_1.resolve)(process.cwd(), p)),
|
|
206
213
|
})
|
|
207
|
-
.option('hash-
|
|
214
|
+
.option('hash-files', {
|
|
208
215
|
default: false,
|
|
209
|
-
|
|
216
|
+
alias: ['hasn', 'hash-importmap'],
|
|
217
|
+
description: 'Determines whether to include a content-specific hash for the generated JSON files. This is useful if you want to be able to cache those files.',
|
|
210
218
|
type: 'boolean',
|
|
211
219
|
})
|
|
212
220
|
.option('fresh', {
|
|
@@ -229,7 +237,7 @@ yargs_1.default.command('assemble', 'Assembles an import map incl. all required
|
|
|
229
237
|
default: 'survey',
|
|
230
238
|
description: 'The source of the frontend modules to assemble. `config` uses a configuration file specified via `--config`. `survey` starts an interactive command-line survey.',
|
|
231
239
|
type: 'string',
|
|
232
|
-
}), (args) => runCommand('runAssemble', args));
|
|
240
|
+
}), (args) => runCommand('runAssemble', { ...args, configFiles: args['config-file'] }));
|
|
233
241
|
yargs_1.default.command(['start', '$0'], 'Starts the app shell using the provided configuration. This uses express for serving static files with some proxy middleware.', (argv) => argv
|
|
234
242
|
.number('port')
|
|
235
243
|
.default('port', 8080)
|
|
@@ -249,7 +257,7 @@ yargs_1.default.command(['start', '$0'], 'Starts the app shell using the provide
|
|
|
249
257
|
...args,
|
|
250
258
|
}));
|
|
251
259
|
yargs_1.default
|
|
252
|
-
.epilog('The SPA
|
|
260
|
+
.epilog('The SPA assemble config JSON is a JSON file, typically `frontend.json`, which defines parameters for the `build` and `assemble` ' +
|
|
253
261
|
'commands. The keys used by `build` are:\n' +
|
|
254
262
|
' `apiUrl`, `spaPath`, `configPaths`, `configUrls`, `importmap`, `pageTitle`, and `supportOffline`;\n' +
|
|
255
263
|
'each of which is equivalent to the corresponding command line argument (see `openmrs build --help`). ' +
|
|
@@ -14,6 +14,7 @@ const axios_1 = __importDefault(require("axios"));
|
|
|
14
14
|
const npm_registry_fetch_1 = __importDefault(require("npm-registry-fetch"));
|
|
15
15
|
const pacote_1 = __importDefault(require("pacote"));
|
|
16
16
|
const semver_1 = __importDefault(require("semver"));
|
|
17
|
+
const lodash_es_1 = require("lodash-es");
|
|
17
18
|
const utils_1 = require("../utils");
|
|
18
19
|
const npmConfig_1 = require("../utils/npmConfig");
|
|
19
20
|
async function readConfig(mode, configs, fetchOptions) {
|
|
@@ -185,7 +186,7 @@ async function runAssemble(args) {
|
|
|
185
186
|
const appRoutes = (0, path_1.resolve)(args.target, dirName, 'routes.json');
|
|
186
187
|
if ((0, fs_1.existsSync)(appRoutes)) {
|
|
187
188
|
try {
|
|
188
|
-
routes[esmName] = JSON.parse(
|
|
189
|
+
routes[esmName] = JSON.parse(await (0, promises_1.readFile)(appRoutes, 'utf8'));
|
|
189
190
|
routes[esmName]['version'] = version;
|
|
190
191
|
}
|
|
191
192
|
catch (e) {
|
|
@@ -201,9 +202,22 @@ async function runAssemble(args) {
|
|
|
201
202
|
importmap.imports[esmName] = `${publicUrl}/${dirName}/${fileName}`;
|
|
202
203
|
versionManifest.frontendModules[esmName] = version;
|
|
203
204
|
}));
|
|
204
|
-
await (0, promises_1.writeFile)((0, path_1.resolve)(args.target, `importmap${args.
|
|
205
|
+
await (0, promises_1.writeFile)((0, path_1.resolve)(args.target, `importmap${args.hashFiles ? '.' + (0, utils_1.contentHash)(importmap) : ''}.json`), JSON.stringify(importmap), 'utf8');
|
|
205
206
|
if (args.buildRoutes) {
|
|
206
|
-
await (0, promises_1.writeFile)((0, path_1.resolve)(args.target, `routes.registry${args.
|
|
207
|
+
await (0, promises_1.writeFile)((0, path_1.resolve)(args.target, `routes.registry${args.hashFiles ? '.' + (0, utils_1.contentHash)(routes) : ''}.json`), JSON.stringify(routes), 'utf-8');
|
|
208
|
+
}
|
|
209
|
+
if (args.configFiles && args.configFiles.length > 0) {
|
|
210
|
+
const assembledConfig = args.configFiles.reduce(async (merged, file) => {
|
|
211
|
+
try {
|
|
212
|
+
const config = JSON.parse((await (0, promises_1.readFile)(file), 'utf8'));
|
|
213
|
+
return (0, lodash_es_1.merge)(merged, config);
|
|
214
|
+
}
|
|
215
|
+
catch (e) {
|
|
216
|
+
(0, utils_1.logWarn)(`Error while processing config file ${file}: ${e}`);
|
|
217
|
+
}
|
|
218
|
+
return merged;
|
|
219
|
+
}, {});
|
|
220
|
+
await (0, promises_1.writeFile)((0, path_1.resolve)(args.target, `openmrs-config${args.hashFiles ? '.' + (0, utils_1.contentHash)(assembledConfig) : ''}.json`), JSON.stringify(assembledConfig), 'utf8');
|
|
207
221
|
}
|
|
208
222
|
if (args.manifest) {
|
|
209
223
|
await (0, promises_1.writeFile)((0, path_1.resolve)(args.target, 'spa-assemble-config.json'), JSON.stringify(versionManifest), 'utf8');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openmrs",
|
|
3
|
-
"version": "5.7.3-pre.
|
|
3
|
+
"version": "5.7.3-pre.2142",
|
|
4
4
|
"license": "MPL-2.0",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": "./dist/cli.js",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
],
|
|
30
30
|
"homepage": "https://github.com/openmrs/openmrs-esm-core#readme",
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@openmrs/esm-app-shell": "5.7.3-pre.
|
|
33
|
-
"@openmrs/webpack-config": "5.7.3-pre.
|
|
32
|
+
"@openmrs/esm-app-shell": "5.7.3-pre.2142",
|
|
33
|
+
"@openmrs/webpack-config": "5.7.3-pre.2142",
|
|
34
34
|
"@pnpm/npm-conf": "^2.1.0",
|
|
35
35
|
"@swc/core": "^1.3.58",
|
|
36
36
|
"autoprefixer": "^10.4.2",
|
package/src/cli.ts
CHANGED
|
@@ -216,6 +216,7 @@ yargs.command(
|
|
|
216
216
|
describe:
|
|
217
217
|
'The path to a frontend configuration file. Can be used multiple times. The file is copied directly into the build directory.',
|
|
218
218
|
type: 'array',
|
|
219
|
+
coerce: (arg: Array<string>) => arg.map((p) => resolve(process.cwd(), p)),
|
|
219
220
|
})
|
|
220
221
|
.option('importmap', {
|
|
221
222
|
default: undefined,
|
|
@@ -237,9 +238,9 @@ yargs.command(
|
|
|
237
238
|
}),
|
|
238
239
|
async (args) =>
|
|
239
240
|
runCommand('runBuild', {
|
|
240
|
-
configUrls: args['config-url'],
|
|
241
|
-
configPaths: args['config-path'].map((p) => resolve(process.cwd(), p)),
|
|
242
241
|
...args,
|
|
242
|
+
configUrls: args['config-url'],
|
|
243
|
+
configPaths: args['config-path'],
|
|
243
244
|
}),
|
|
244
245
|
);
|
|
245
246
|
|
|
@@ -263,14 +264,22 @@ yargs.command(
|
|
|
263
264
|
})
|
|
264
265
|
.option('config', {
|
|
265
266
|
default: ['spa-build-config.json'],
|
|
266
|
-
description: 'Path to a SPA
|
|
267
|
+
description: 'Path to a SPA assemble config JSON.',
|
|
268
|
+
type: 'array',
|
|
269
|
+
coerce: (arg: Array<string>) => arg.map((p) => resolve(process.cwd(), p)),
|
|
270
|
+
})
|
|
271
|
+
.option('config-file', {
|
|
272
|
+
default: [],
|
|
273
|
+
describe:
|
|
274
|
+
'Reference to a frontend configuration file. Can be used multiple times. Configurations are merged in the order specified into openmrs-config.json.',
|
|
267
275
|
type: 'array',
|
|
268
276
|
coerce: (arg: Array<string>) => arg.map((p) => resolve(process.cwd(), p)),
|
|
269
277
|
})
|
|
270
|
-
.option('hash-
|
|
278
|
+
.option('hash-files', {
|
|
271
279
|
default: false,
|
|
280
|
+
alias: ['hasn', 'hash-importmap'],
|
|
272
281
|
description:
|
|
273
|
-
'Determines whether to include a content-specific hash for the generated
|
|
282
|
+
'Determines whether to include a content-specific hash for the generated JSON files. This is useful if you want to be able to cache those files.',
|
|
274
283
|
type: 'boolean',
|
|
275
284
|
})
|
|
276
285
|
.option('fresh', {
|
|
@@ -295,7 +304,7 @@ yargs.command(
|
|
|
295
304
|
'The source of the frontend modules to assemble. `config` uses a configuration file specified via `--config`. `survey` starts an interactive command-line survey.',
|
|
296
305
|
type: 'string',
|
|
297
306
|
}),
|
|
298
|
-
(args) => runCommand('runAssemble', args),
|
|
307
|
+
(args) => runCommand('runAssemble', { ...args, configFiles: args['config-file'] }),
|
|
299
308
|
);
|
|
300
309
|
|
|
301
310
|
yargs.command(
|
|
@@ -326,7 +335,7 @@ yargs.command(
|
|
|
326
335
|
|
|
327
336
|
yargs
|
|
328
337
|
.epilog(
|
|
329
|
-
'The SPA
|
|
338
|
+
'The SPA assemble config JSON is a JSON file, typically `frontend.json`, which defines parameters for the `build` and `assemble` ' +
|
|
330
339
|
'commands. The keys used by `build` are:\n' +
|
|
331
340
|
' `apiUrl`, `spaPath`, `configPaths`, `configUrls`, `importmap`, `pageTitle`, and `supportOffline`;\n' +
|
|
332
341
|
'each of which is equivalent to the corresponding command line argument (see `openmrs build --help`). ' +
|
package/src/commands/assemble.ts
CHANGED
|
@@ -8,6 +8,7 @@ import axios from 'axios';
|
|
|
8
8
|
import npmRegistryFetch from 'npm-registry-fetch';
|
|
9
9
|
import pacote from 'pacote';
|
|
10
10
|
import semver from 'semver';
|
|
11
|
+
import { merge } from 'lodash-es';
|
|
11
12
|
import { contentHash, logInfo, logWarn, untar } from '../utils';
|
|
12
13
|
import { getNpmRegistryConfiguration } from '../utils/npmConfig';
|
|
13
14
|
|
|
@@ -18,7 +19,8 @@ export interface AssembleArgs {
|
|
|
18
19
|
mode: string;
|
|
19
20
|
config: Array<string>;
|
|
20
21
|
registry?: string;
|
|
21
|
-
|
|
22
|
+
configFiles: Array<string>;
|
|
23
|
+
hashFiles: boolean;
|
|
22
24
|
fresh: boolean;
|
|
23
25
|
buildRoutes: boolean;
|
|
24
26
|
manifest: boolean;
|
|
@@ -265,7 +267,7 @@ export async function runAssemble(args: AssembleArgs) {
|
|
|
265
267
|
const appRoutes = resolve(args.target, dirName, 'routes.json');
|
|
266
268
|
if (existsSync(appRoutes)) {
|
|
267
269
|
try {
|
|
268
|
-
routes[esmName] = JSON.parse(
|
|
270
|
+
routes[esmName] = JSON.parse(await readFile(appRoutes, 'utf8'));
|
|
269
271
|
routes[esmName]['version'] = version;
|
|
270
272
|
} catch (e) {
|
|
271
273
|
logWarn(`Error while processing routes for ${esmName} using ${appRoutes}: ${e}`);
|
|
@@ -286,19 +288,38 @@ export async function runAssemble(args: AssembleArgs) {
|
|
|
286
288
|
);
|
|
287
289
|
|
|
288
290
|
await writeFile(
|
|
289
|
-
resolve(args.target, `importmap${args.
|
|
291
|
+
resolve(args.target, `importmap${args.hashFiles ? '.' + contentHash(importmap) : ''}.json`),
|
|
290
292
|
JSON.stringify(importmap),
|
|
291
293
|
'utf8',
|
|
292
294
|
);
|
|
293
295
|
|
|
294
296
|
if (args.buildRoutes) {
|
|
295
297
|
await writeFile(
|
|
296
|
-
resolve(args.target, `routes.registry${args.
|
|
298
|
+
resolve(args.target, `routes.registry${args.hashFiles ? '.' + contentHash(routes) : ''}.json`),
|
|
297
299
|
JSON.stringify(routes),
|
|
298
300
|
'utf-8',
|
|
299
301
|
);
|
|
300
302
|
}
|
|
301
303
|
|
|
304
|
+
if (args.configFiles && args.configFiles.length > 0) {
|
|
305
|
+
const assembledConfig = args.configFiles.reduce(async (merged, file) => {
|
|
306
|
+
try {
|
|
307
|
+
const config = JSON.parse((await readFile(file), 'utf8'));
|
|
308
|
+
return merge(merged, config);
|
|
309
|
+
} catch (e) {
|
|
310
|
+
logWarn(`Error while processing config file ${file}: ${e}`);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
return merged;
|
|
314
|
+
}, {});
|
|
315
|
+
|
|
316
|
+
await writeFile(
|
|
317
|
+
resolve(args.target, `openmrs-config${args.hashFiles ? '.' + contentHash(assembledConfig) : ''}.json`),
|
|
318
|
+
JSON.stringify(assembledConfig),
|
|
319
|
+
'utf8',
|
|
320
|
+
);
|
|
321
|
+
}
|
|
322
|
+
|
|
302
323
|
if (args.manifest) {
|
|
303
324
|
await writeFile(resolve(args.target, 'spa-assemble-config.json'), JSON.stringify(versionManifest), 'utf8');
|
|
304
325
|
}
|