openmrs 3.1.13-pre.667 → 3.1.14
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 +151 -210
- package/dist/commands/assemble.js +125 -222
- package/dist/commands/build.js +87 -165
- package/dist/commands/debug.js +15 -25
- package/dist/commands/develop.js +41 -33
- package/dist/commands/index.js +1 -1
- package/dist/commands/start.js +22 -22
- package/dist/index.js +2 -2
- package/dist/runner.js +15 -56
- package/dist/utils/config.js +5 -6
- package/dist/utils/debugger.js +14 -28
- package/dist/utils/dependencies.js +12 -23
- package/dist/utils/helpers.js +2 -2
- package/dist/utils/importmap.js +144 -226
- package/dist/utils/index.js +1 -1
- package/dist/utils/logger.js +4 -4
- package/dist/utils/untar.js +12 -12
- package/dist/utils/variables.js +2 -2
- package/dist/utils/webpack.js +7 -8
- package/package.json +6 -3
- package/tsconfig.json +1 -0
package/dist/cli.js
CHANGED
|
@@ -1,16 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
|
-
var __assign = (this && this.__assign) || function () {
|
|
4
|
-
__assign = Object.assign || function(t) {
|
|
5
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
6
|
-
s = arguments[i];
|
|
7
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
8
|
-
t[p] = s[p];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
|
-
return __assign.apply(this, arguments);
|
|
13
|
-
};
|
|
14
3
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
15
4
|
if (k2 === undefined) k2 = k;
|
|
16
5
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
@@ -39,209 +28,161 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
39
28
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
40
29
|
});
|
|
41
30
|
};
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
50
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
51
|
-
switch (op[0]) {
|
|
52
|
-
case 0: case 1: t = op; break;
|
|
53
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
54
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
55
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
56
|
-
default:
|
|
57
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
58
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
59
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
60
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
61
|
-
if (t[2]) _.ops.pop();
|
|
62
|
-
_.trys.pop(); continue;
|
|
63
|
-
}
|
|
64
|
-
op = body.call(thisArg, _);
|
|
65
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
66
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
exports.__esModule = true;
|
|
70
|
-
var yargs = __importStar(require("yargs"));
|
|
71
|
-
var child_process_1 = require("child_process");
|
|
72
|
-
var path_1 = require("path");
|
|
73
|
-
var utils_1 = require("./utils");
|
|
74
|
-
var runner = (0, path_1.resolve)(__dirname, "runner.js");
|
|
75
|
-
var root = (0, path_1.resolve)(__dirname, "..");
|
|
31
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
+
const yargs = __importStar(require("yargs"));
|
|
33
|
+
const child_process_1 = require("child_process");
|
|
34
|
+
const path_1 = require("path");
|
|
35
|
+
const utils_1 = require("./utils");
|
|
36
|
+
const runner = (0, path_1.resolve)(__dirname, `runner.js`);
|
|
37
|
+
const root = (0, path_1.resolve)(__dirname, "..");
|
|
76
38
|
function runCommand(type, args) {
|
|
77
|
-
|
|
39
|
+
const ps = (0, child_process_1.fork)(runner, [], { cwd: root });
|
|
78
40
|
ps.send({
|
|
79
|
-
type
|
|
80
|
-
args
|
|
41
|
+
type,
|
|
42
|
+
args,
|
|
81
43
|
});
|
|
82
|
-
ps.on("exit",
|
|
44
|
+
ps.on("exit", (code) => process.exit(code || 0));
|
|
83
45
|
}
|
|
84
|
-
yargs.command("debug", "Starts a new debugging session of the OpenMRS app shell. This uses Webpack as a debug server with proxy middleware.",
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
.describe("registry", "The NPM registry used for getting the packages.")
|
|
225
|
-
.string("config")["default"]("config", "spa-build-config.json")
|
|
226
|
-
.describe("config", "Path to a SPA build config JSON.")
|
|
227
|
-
.boolean("fresh")
|
|
228
|
-
.describe("fresh", "Determines if the output directory should be cleaned before the run.")["default"]("fresh", false)
|
|
229
|
-
.choices("mode", ["config", "survey"])["default"]("mode", "survey")
|
|
230
|
-
.describe("mode", "The source of the frontend modules to assemble. `config` uses a configuration file specified via `--config`. `survey` starts an interactive command-line survey.");
|
|
231
|
-
}, function (args) {
|
|
232
|
-
return runCommand("runAssemble", __assign(__assign({}, args), { registry: (0, utils_1.trimEnd)(args.registry, "/"), config: (0, path_1.resolve)(process.cwd(), args.config), target: (0, path_1.resolve)(process.cwd(), args.target) }));
|
|
233
|
-
});
|
|
234
|
-
yargs.command(["start", "$0"], "Starts the app shell using the provided configuration. This uses express for serving static files with some proxy middleware.", function (argv) {
|
|
235
|
-
return argv
|
|
236
|
-
.number("port")["default"]("port", 8080)
|
|
237
|
-
.describe("port", "The port where the dev server should run.")
|
|
238
|
-
.number("host")["default"]("host", "localhost")
|
|
239
|
-
.describe("host", "The host name or IP for the server to use.")
|
|
240
|
-
.string("backend")["default"]("backend", "https://openmrs-spa.org/")
|
|
241
|
-
.describe("backend", "The backend to proxy API requests to.")
|
|
242
|
-
.boolean("open")["default"]("open", false)
|
|
243
|
-
.describe("open", "Immediately opens the SPA page URL in the browser.");
|
|
244
|
-
}, function (args) { return runCommand("runStart", __assign({}, args)); });
|
|
46
|
+
yargs.command("debug", "Starts a new debugging session of the OpenMRS app shell. This uses Webpack as a debug server with proxy middleware.", (argv) => argv
|
|
47
|
+
.number("port")
|
|
48
|
+
.default("port", 8080)
|
|
49
|
+
.describe("port", "The port where the dev server should run.")
|
|
50
|
+
.number("host")
|
|
51
|
+
.default("host", "localhost")
|
|
52
|
+
.describe("host", "The host name or IP for the server to use.")
|
|
53
|
+
.string("backend")
|
|
54
|
+
.default("backend", "https://openmrs-spa.org/")
|
|
55
|
+
.describe("backend", "The backend to proxy API requests to.")
|
|
56
|
+
.boolean("support-offline")
|
|
57
|
+
.describe("support-offline", "Determines if a service worker should be installed for offline support.")
|
|
58
|
+
.default("support-offline", true)
|
|
59
|
+
.string("spa-path")
|
|
60
|
+
.default("spa-path", "/openmrs/spa/")
|
|
61
|
+
.describe("spa-path", "The path of the application on the target server.")
|
|
62
|
+
.string("api-url")
|
|
63
|
+
.default("api-url", "/openmrs/")
|
|
64
|
+
.describe("api-url", "The URL of the API. Can be a path if the API is on the same target server.")
|
|
65
|
+
.string("page-title")
|
|
66
|
+
.default("page-title", "OpenMRS")
|
|
67
|
+
.describe("page-title", "The title of the web app usually displayed in the browser tab.")
|
|
68
|
+
.array("config-url")
|
|
69
|
+
.default("config-url", [])
|
|
70
|
+
.describe("config-url", "The URL to a valid frontend configuration. Can be used multiple times.")
|
|
71
|
+
.boolean("run-project")
|
|
72
|
+
.default("run-project", false)
|
|
73
|
+
.describe("run-project", "Runs the project in the current directory fusing it with the specified import map.")
|
|
74
|
+
.array("sources")
|
|
75
|
+
.default("sources", ["."])
|
|
76
|
+
.describe("sources", "Runs the projects from the provided source directories. Can be used multiple times.")
|
|
77
|
+
.array("shared-dependencies")
|
|
78
|
+
.default("shared-dependencies", [])
|
|
79
|
+
.describe("shared-dependencies", "The additional shared dependencies besides the ones from the app shell.")
|
|
80
|
+
.string("importmap")
|
|
81
|
+
.default("importmap", "importmap.json")
|
|
82
|
+
.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* () {
|
|
83
|
+
return runCommand("runDebug", Object.assign(Object.assign({ apiUrl: args["api-url"], spaPath: args["spa-path"], configUrls: args["config-url"], pageTitle: args["page-title"], supportOffline: args["support-offline"] }, args), { importmap: (0, utils_1.proxyImportmap)(yield (0, utils_1.mergeImportmap)(yield (0, utils_1.getImportmap)(args.importmap, args.port), (args["run-project"] || args.runProject) &&
|
|
84
|
+
(yield (0, utils_1.runProject)(args.port, args["shared-dependencies"], args.sources))), args.backend, args.host, args.port) }));
|
|
85
|
+
}));
|
|
86
|
+
yargs.command("develop", "Starts a new frontend module development session with the OpenMRS app shell.", (argv) => argv
|
|
87
|
+
.number("port")
|
|
88
|
+
.default("port", 8080)
|
|
89
|
+
.describe("port", "The port where the dev server should run.")
|
|
90
|
+
.number("host")
|
|
91
|
+
.default("host", "localhost")
|
|
92
|
+
.describe("host", "The host name or IP for the server to use.")
|
|
93
|
+
.string("backend")
|
|
94
|
+
.default("backend", "https://openmrs-spa.org/")
|
|
95
|
+
.describe("backend", "The backend to proxy API requests to.")
|
|
96
|
+
.string("spa-path")
|
|
97
|
+
.default("spa-path", "/openmrs/spa/")
|
|
98
|
+
.describe("spa-path", "The path of the application on the target server.")
|
|
99
|
+
.string("api-url")
|
|
100
|
+
.default("api-url", "/openmrs/")
|
|
101
|
+
.describe("api-url", "The URL of the API. Can be a path if the API is on the same target server.")
|
|
102
|
+
.boolean("open")
|
|
103
|
+
.default("open", true)
|
|
104
|
+
.describe("open", "Immediately opens the SPA page URL in the browser.")
|
|
105
|
+
.array("config-url")
|
|
106
|
+
.default("config-url", [])
|
|
107
|
+
.describe("config-url", "The URL to a valid frontend configuration. Can be used multiple times.")
|
|
108
|
+
.array("sources")
|
|
109
|
+
.default("sources", ["."])
|
|
110
|
+
.describe("sources", "Runs the projects from the provided source directories. Can be used multiple times.")
|
|
111
|
+
.array("shared-dependencies")
|
|
112
|
+
.default("shared-dependencies", [])
|
|
113
|
+
.describe("shared-dependencies", "The additional shared dependencies besides the ones from the app shell.")
|
|
114
|
+
.string("importmap")
|
|
115
|
+
.default("importmap", "importmap.json")
|
|
116
|
+
.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* () {
|
|
117
|
+
return runCommand("runDevelop", Object.assign(Object.assign({ apiUrl: args["api-url"], spaPath: args["spa-path"], 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 &&
|
|
118
|
+
(yield (0, utils_1.runProject)(args.port, args["shared-dependencies"], args.sources))), args.backend, args.host, args.port) }));
|
|
119
|
+
}));
|
|
120
|
+
yargs.command("build", "Builds a new app shell.", (argv) => argv
|
|
121
|
+
.string("target")
|
|
122
|
+
.default("target", "dist")
|
|
123
|
+
.describe("target", "The target directory where the build artifacts will be stored.")
|
|
124
|
+
.string("registry")
|
|
125
|
+
.default("registry", "https://registry.npmjs.org/")
|
|
126
|
+
.describe("registry", "The NPM registry used for getting the packages.")
|
|
127
|
+
.boolean("fresh")
|
|
128
|
+
.describe("fresh", "Determines if the output directory should be cleaned before the run.")
|
|
129
|
+
.boolean("support-offline")
|
|
130
|
+
.describe("support-offline", "Determines if a service worker should be installed for offline support.")
|
|
131
|
+
.default("support-offline", true)
|
|
132
|
+
.string("build-config")
|
|
133
|
+
.describe("build-config", "Path to a SPA build config JSON")
|
|
134
|
+
.string("spa-path")
|
|
135
|
+
.default("spa-path", "/openmrs/spa/")
|
|
136
|
+
.describe("spa-path", "The path of the application on the target server.")
|
|
137
|
+
.string("page-title")
|
|
138
|
+
.default("page-title", "OpenMRS")
|
|
139
|
+
.describe("page-title", "The title of the web app usually displayed in the browser tab.")
|
|
140
|
+
.string("api-url")
|
|
141
|
+
.default("api-url", "/openmrs/")
|
|
142
|
+
.describe("api-url", "The URL of the API. Can be a path if the API is on the same target server.")
|
|
143
|
+
.array("config-url")
|
|
144
|
+
.default("config-url", [])
|
|
145
|
+
.describe("config-url", "The URL to a frontend configuration. Can be used multiple times. Resolved by the client during initialization.")
|
|
146
|
+
.array("config-path")
|
|
147
|
+
.default("config-path", [])
|
|
148
|
+
.describe("config-path", "The path to a frontend configuration file. Can be used multiple times. The file is copied directly into the build directory.")
|
|
149
|
+
.string("importmap")
|
|
150
|
+
.default("importmap", "importmap.json")
|
|
151
|
+
.describe("importmap", "The import map to use. Can be a path to an import map to be taken literally, an URL, or a fixed JSON object.")
|
|
152
|
+
.boolean("download-coreapps")
|
|
153
|
+
.default("download-coreapps", false)
|
|
154
|
+
.describe("download-coreapps", "Downloads and bundles the core apps. For cases where the core apps are not in the import map."), (args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
155
|
+
return runCommand("runBuild", Object.assign(Object.assign({ apiUrl: args["api-url"], spaPath: args["spa-path"], configUrls: args["config-url"], configPaths: args["config-path"].map((p) => (0, path_1.resolve)(process.cwd(), p)), pageTitle: args["page-title"], supportOffline: args["support-offline"], downloadCoreapps: args["download-coreapps"] }, args), { importmap: args.importmap, buildConfig: args["build-config"] && (0, path_1.resolve)(process.cwd(), args["build-config"]), target: (0, path_1.resolve)(process.cwd(), args.target) }));
|
|
156
|
+
}));
|
|
157
|
+
yargs.command("assemble", "Assembles an import map incl. all required resources.", (argv) => argv
|
|
158
|
+
.string("target")
|
|
159
|
+
.default("target", "dist")
|
|
160
|
+
.describe("target", "The target directory where the gathered artifacts will be stored.")
|
|
161
|
+
.string("registry")
|
|
162
|
+
.default("registry", "https://registry.npmjs.org/")
|
|
163
|
+
.describe("registry", "The NPM registry used for getting the packages.")
|
|
164
|
+
.string("config")
|
|
165
|
+
.default("config", "spa-build-config.json")
|
|
166
|
+
.describe("config", "Path to a SPA build config JSON.")
|
|
167
|
+
.boolean("fresh")
|
|
168
|
+
.describe("fresh", "Determines if the output directory should be cleaned before the run.")
|
|
169
|
+
.default("fresh", false)
|
|
170
|
+
.choices("mode", ["config", "survey"])
|
|
171
|
+
.default("mode", "survey")
|
|
172
|
+
.describe("mode", "The source of the frontend modules to assemble. `config` uses a configuration file specified via `--config`. `survey` starts an interactive command-line survey."), (args) => runCommand("runAssemble", Object.assign(Object.assign({}, args), { registry: (0, utils_1.trimEnd)(args.registry, "/"), config: (0, path_1.resolve)(process.cwd(), args.config), target: (0, path_1.resolve)(process.cwd(), args.target) })));
|
|
173
|
+
yargs.command(["start", "$0"], "Starts the app shell using the provided configuration. This uses express for serving static files with some proxy middleware.", (argv) => argv
|
|
174
|
+
.number("port")
|
|
175
|
+
.default("port", 8080)
|
|
176
|
+
.describe("port", "The port where the dev server should run.")
|
|
177
|
+
.number("host")
|
|
178
|
+
.default("host", "localhost")
|
|
179
|
+
.describe("host", "The host name or IP for the server to use.")
|
|
180
|
+
.string("backend")
|
|
181
|
+
.default("backend", "https://openmrs-spa.org/")
|
|
182
|
+
.describe("backend", "The backend to proxy API requests to.")
|
|
183
|
+
.boolean("open")
|
|
184
|
+
.default("open", false)
|
|
185
|
+
.describe("open", "Immediately opens the SPA page URL in the browser."), (args) => runCommand("runStart", Object.assign({}, args)));
|
|
245
186
|
yargs
|
|
246
187
|
.epilog("The SPA build config JSON is a JSON file, typically `frontend.json`, which defines parameters for the `build` and `assemble` " +
|
|
247
188
|
"commands. The keys used by `build` are:\n" +
|