@sdeverywhere/plugin-check 0.1.0
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/LICENSE +21 -0
- package/README.md +12 -0
- package/dist/index.cjs +519 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.js +496 -0
- package/dist/index.js.map +1 -0
- package/package.json +62 -0
- package/template-bundle/package.json +8 -0
- package/template-bundle/src/bundle.ts +172 -0
- package/template-bundle/src/empty-model-spec.ts +15 -0
- package/template-bundle/src/index.ts +3 -0
- package/template-bundle/src/inputs.ts +139 -0
- package/template-bundle/src/outputs.ts +36 -0
- package/template-bundle/src/worker.js +9 -0
- package/template-bundle/tsconfig.json +27 -0
- package/template-report/index.html +27 -0
- package/template-report/package.json +6 -0
- package/template-report/src/empty-bundle.ts +23 -0
- package/template-report/src/empty-test-config.ts +24 -0
- package/template-report/src/env.d.ts +7 -0
- package/template-report/src/global.css +22 -0
- package/template-report/src/index.ts +56 -0
- package/template-report/src/messages.html +6 -0
- package/template-report/src/overlay.ts +32 -0
- package/template-report/src/url-polyfill.ts +10 -0
- package/template-report/tsconfig.json +31 -0
- package/template-tests/package.json +5 -0
- package/template-tests/src/env.d.ts +5 -0
- package/template-tests/src/index.ts +82 -0
- package/template-tests/tsconfig.json +19 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Climate Interactive / New Venture Fund
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# @sdeverywhere/plugin-check
|
|
2
|
+
|
|
3
|
+
This package provides a plugin that runs model checks and comparison tests for a
|
|
4
|
+
given SDEverywhere-generated system dynamics model.
|
|
5
|
+
|
|
6
|
+
## Documentation
|
|
7
|
+
|
|
8
|
+
TODO
|
|
9
|
+
|
|
10
|
+
## License
|
|
11
|
+
|
|
12
|
+
SDEverywhere is distributed under the MIT license. See `LICENSE` for more details.
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,519 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
9
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
|
+
var __spreadValues = (a, b) => {
|
|
11
|
+
for (var prop in b || (b = {}))
|
|
12
|
+
if (__hasOwnProp.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
if (__getOwnPropSymbols)
|
|
15
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
16
|
+
if (__propIsEnum.call(b, prop))
|
|
17
|
+
__defNormalProp(a, prop, b[prop]);
|
|
18
|
+
}
|
|
19
|
+
return a;
|
|
20
|
+
};
|
|
21
|
+
var __export = (target, all) => {
|
|
22
|
+
for (var name in all)
|
|
23
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
24
|
+
};
|
|
25
|
+
var __copyProps = (to, from, except, desc) => {
|
|
26
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
27
|
+
for (let key of __getOwnPropNames(from))
|
|
28
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
29
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
30
|
+
}
|
|
31
|
+
return to;
|
|
32
|
+
};
|
|
33
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
34
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
35
|
+
|
|
36
|
+
// src/index.ts
|
|
37
|
+
var src_exports = {};
|
|
38
|
+
__export(src_exports, {
|
|
39
|
+
checkPlugin: () => checkPlugin
|
|
40
|
+
});
|
|
41
|
+
module.exports = __toCommonJS(src_exports);
|
|
42
|
+
|
|
43
|
+
// src/plugin.ts
|
|
44
|
+
var import_path4 = require("path");
|
|
45
|
+
var import_url4 = require("url");
|
|
46
|
+
var import_vite = require("vite");
|
|
47
|
+
var import_check_core2 = require("@sdeverywhere/check-core");
|
|
48
|
+
|
|
49
|
+
// src/run-suite.ts
|
|
50
|
+
var import_perf_hooks = require("perf_hooks");
|
|
51
|
+
var import_picocolors = __toESM(require("picocolors"), 1);
|
|
52
|
+
var import_check_core = require("@sdeverywhere/check-core");
|
|
53
|
+
async function runTestSuite(context, config, verbose) {
|
|
54
|
+
return new Promise((resolve, reject) => {
|
|
55
|
+
const t0 = import_perf_hooks.performance.now();
|
|
56
|
+
let lastPctByInc;
|
|
57
|
+
const callbacks = {
|
|
58
|
+
onProgress: (progress) => {
|
|
59
|
+
const pct = Math.round(progress * 100);
|
|
60
|
+
const pctByInc = Math.floor(pct / 5) * 5;
|
|
61
|
+
if (lastPctByInc === void 0 || pctByInc > lastPctByInc) {
|
|
62
|
+
lastPctByInc = pctByInc;
|
|
63
|
+
context.log("info", `${pctByInc}%`);
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
onComplete: (report) => {
|
|
67
|
+
try {
|
|
68
|
+
const t1 = import_perf_hooks.performance.now();
|
|
69
|
+
const elapsed = ((t1 - t0) / 1e3).toFixed(1);
|
|
70
|
+
context.log("info", `
|
|
71
|
+
Test suite completed in ${elapsed}s`);
|
|
72
|
+
const allChecksPassed = printCheckSummary(context, report.checkReport, verbose);
|
|
73
|
+
if (report.compareReport) {
|
|
74
|
+
printPerfStats(context, config.compare, report.compareReport);
|
|
75
|
+
}
|
|
76
|
+
const suiteSummary = (0, import_check_core.suiteSummaryFromReport)(report);
|
|
77
|
+
resolve({
|
|
78
|
+
allChecksPassed,
|
|
79
|
+
suiteSummary
|
|
80
|
+
});
|
|
81
|
+
} catch (e) {
|
|
82
|
+
reject(e);
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
onError: (error) => {
|
|
86
|
+
reject(error);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
(0, import_check_core.runSuite)(config, callbacks);
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
function printCheckSummary(context, checkReport, verbose) {
|
|
93
|
+
function printResult(indent, status, text) {
|
|
94
|
+
if (!verbose && status === "passed" && indent > 1) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
let statusChar;
|
|
98
|
+
switch (status) {
|
|
99
|
+
case "passed":
|
|
100
|
+
statusChar = "\u2713";
|
|
101
|
+
break;
|
|
102
|
+
case "failed":
|
|
103
|
+
statusChar = "\u2717";
|
|
104
|
+
break;
|
|
105
|
+
case "error":
|
|
106
|
+
statusChar = "\u203C";
|
|
107
|
+
break;
|
|
108
|
+
default:
|
|
109
|
+
statusChar = "";
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
const msg = `${" ".repeat(indent)}${statusChar} ${text}`;
|
|
113
|
+
context.log("info", status === "passed" ? import_picocolors.default.green(msg) : import_picocolors.default.red(msg));
|
|
114
|
+
}
|
|
115
|
+
function bold(s) {
|
|
116
|
+
return import_picocolors.default.bold(s);
|
|
117
|
+
}
|
|
118
|
+
function printTest(test) {
|
|
119
|
+
const msg = `${test.name}${verbose || test.status !== "passed" ? ":" : ""}`;
|
|
120
|
+
printResult(1, test.status, msg);
|
|
121
|
+
}
|
|
122
|
+
let allPassed = true;
|
|
123
|
+
context.log("info", "\nCheck results:");
|
|
124
|
+
for (const group of checkReport.groups) {
|
|
125
|
+
context.log("info", `
|
|
126
|
+
${group.name}`);
|
|
127
|
+
for (const test of group.tests) {
|
|
128
|
+
if (test.status !== "passed") {
|
|
129
|
+
allPassed = false;
|
|
130
|
+
}
|
|
131
|
+
printTest(test);
|
|
132
|
+
for (const scenario of test.scenarios) {
|
|
133
|
+
printResult(3, scenario.status, (0, import_check_core.scenarioMessage)(scenario, bold));
|
|
134
|
+
for (const dataset of scenario.datasets) {
|
|
135
|
+
printResult(5, dataset.status, (0, import_check_core.datasetMessage)(dataset, bold));
|
|
136
|
+
for (const predicate of dataset.predicates) {
|
|
137
|
+
printResult(7, predicate.result.status, (0, import_check_core.predicateMessage)(predicate, bold));
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
context.log("info", "");
|
|
144
|
+
return allPassed;
|
|
145
|
+
}
|
|
146
|
+
function stat(label, n) {
|
|
147
|
+
return `${label}=${n.toFixed(1)}ms`;
|
|
148
|
+
}
|
|
149
|
+
function printPerfReportLine(context, perfReport) {
|
|
150
|
+
const avg = stat("avg", perfReport.avgTime);
|
|
151
|
+
const min = stat("min", perfReport.minTime);
|
|
152
|
+
const max = stat("max", perfReport.maxTime);
|
|
153
|
+
context.log("info", ` ${avg} ${min} ${max}`);
|
|
154
|
+
}
|
|
155
|
+
function printPerfStats(context, compareConfig, report) {
|
|
156
|
+
context.log("info", "\nPerformance stats:");
|
|
157
|
+
context.log("info", ` ${compareConfig.bundleL.name}:`);
|
|
158
|
+
printPerfReportLine(context, report.perfReportL);
|
|
159
|
+
context.log("info", ` ${compareConfig.bundleR.name}:`);
|
|
160
|
+
printPerfReportLine(context, report.perfReportR);
|
|
161
|
+
context.log("info", "");
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// src/vite-config-for-bundle.ts
|
|
165
|
+
var import_path = require("path");
|
|
166
|
+
var import_url = require("url");
|
|
167
|
+
var import_plugin_node_resolve = require("@rollup/plugin-node-resolve");
|
|
168
|
+
|
|
169
|
+
// src/var-names.ts
|
|
170
|
+
function sdeNameForVensimName(name) {
|
|
171
|
+
return "_" + name.trim().replace(/"/g, "_").replace(/\s+!$/g, "!").replace(/\s/g, "_").replace(/,/g, "_").replace(/-/g, "_").replace(/\./g, "_").replace(/\$/g, "_").replace(/'/g, "_").replace(/&/g, "_").replace(/%/g, "_").replace(/\//g, "_").replace(/\|/g, "_").toLowerCase();
|
|
172
|
+
}
|
|
173
|
+
function sdeNameForVensimVarName(varName) {
|
|
174
|
+
const m = varName.match(/([^[]+)(?:\[([^\]]+)\])?/);
|
|
175
|
+
if (!m) {
|
|
176
|
+
throw new Error(`Invalid Vensim name: ${varName}`);
|
|
177
|
+
}
|
|
178
|
+
let id = sdeNameForVensimName(m[1]);
|
|
179
|
+
if (m[2]) {
|
|
180
|
+
const subscripts = m[2].split(",").map((x) => sdeNameForVensimName(x));
|
|
181
|
+
id += `[${subscripts.join("][")}]`;
|
|
182
|
+
}
|
|
183
|
+
return id;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// src/vite-config-for-bundle.ts
|
|
187
|
+
var import_meta = {};
|
|
188
|
+
var __filename = (0, import_url.fileURLToPath)(import_meta.url);
|
|
189
|
+
var __dirname = (0, import_path.dirname)(__filename);
|
|
190
|
+
function injectModelSpec(modelSpec) {
|
|
191
|
+
const inputSpecs = modelSpec.inputs.map((i) => {
|
|
192
|
+
return __spreadValues({
|
|
193
|
+
varId: sdeNameForVensimVarName(i.varName)
|
|
194
|
+
}, i);
|
|
195
|
+
});
|
|
196
|
+
const outputSpecs = modelSpec.outputs.map((o) => {
|
|
197
|
+
return __spreadValues({
|
|
198
|
+
varId: sdeNameForVensimVarName(o.varName)
|
|
199
|
+
}, o);
|
|
200
|
+
});
|
|
201
|
+
const moduleSrc = `
|
|
202
|
+
export const startTime = ${modelSpec.startTime};
|
|
203
|
+
export const endTime = ${modelSpec.endTime};
|
|
204
|
+
export const inputSpecs = ${JSON.stringify(inputSpecs)};
|
|
205
|
+
export const outputSpecs = ${JSON.stringify(outputSpecs)};
|
|
206
|
+
`;
|
|
207
|
+
const virtualModuleId = "virtual:model-spec";
|
|
208
|
+
const resolvedVirtualModuleId = "\0" + virtualModuleId;
|
|
209
|
+
return {
|
|
210
|
+
name: "vite-plugin-virtual-custom",
|
|
211
|
+
resolveId(id) {
|
|
212
|
+
if (id === virtualModuleId) {
|
|
213
|
+
return resolvedVirtualModuleId;
|
|
214
|
+
}
|
|
215
|
+
},
|
|
216
|
+
load(id) {
|
|
217
|
+
if (id === resolvedVirtualModuleId) {
|
|
218
|
+
return moduleSrc;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
async function createViteConfigForBundle(prepDir, modelSpec) {
|
|
224
|
+
const root = (0, import_path.resolve)(__dirname, "..", "template-bundle");
|
|
225
|
+
const outDir = (0, import_path.relative)(root, prepDir);
|
|
226
|
+
const modelWorkerPath = (0, import_path.join)(prepDir, "staged", "model", "worker.js?raw");
|
|
227
|
+
return {
|
|
228
|
+
configFile: false,
|
|
229
|
+
root,
|
|
230
|
+
clearScreen: false,
|
|
231
|
+
resolve: {
|
|
232
|
+
alias: [
|
|
233
|
+
{
|
|
234
|
+
find: "@_model_worker_",
|
|
235
|
+
replacement: modelWorkerPath
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
find: "threads",
|
|
239
|
+
replacement: "threads",
|
|
240
|
+
customResolver: async function(source, importer, options) {
|
|
241
|
+
const customResolver = (0, import_plugin_node_resolve.nodeResolve)({ browser: false });
|
|
242
|
+
const resolved = await customResolver.resolveId.call(this, source, importer, options);
|
|
243
|
+
if (source === "threads/worker") {
|
|
244
|
+
return resolved.id.replace("worker.mjs", "dist-esm/worker/index.js");
|
|
245
|
+
} else {
|
|
246
|
+
return resolved.id.replace("index.mjs", "dist-esm/index.js");
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
]
|
|
251
|
+
},
|
|
252
|
+
plugins: [
|
|
253
|
+
injectModelSpec(modelSpec)
|
|
254
|
+
],
|
|
255
|
+
build: {
|
|
256
|
+
outDir,
|
|
257
|
+
emptyOutDir: false,
|
|
258
|
+
lib: {
|
|
259
|
+
entry: "./src/index.ts",
|
|
260
|
+
formats: ["es"],
|
|
261
|
+
fileName: () => "check-bundle.js"
|
|
262
|
+
},
|
|
263
|
+
rollupOptions: {
|
|
264
|
+
external: ["events", "os", "path", "url"],
|
|
265
|
+
output: {
|
|
266
|
+
banner: `
|
|
267
|
+
import * as worker_threads from 'worker_threads'
|
|
268
|
+
let __non_webpack_require__ = () => {
|
|
269
|
+
return worker_threads;
|
|
270
|
+
};
|
|
271
|
+
`
|
|
272
|
+
},
|
|
273
|
+
onwarn: (warning, warn) => {
|
|
274
|
+
if (warning.code !== "EVAL") {
|
|
275
|
+
warn(warning);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
// src/vite-config-for-report.ts
|
|
284
|
+
var import_path2 = require("path");
|
|
285
|
+
var import_url2 = require("url");
|
|
286
|
+
var import_plugin_node_resolve2 = require("@rollup/plugin-node-resolve");
|
|
287
|
+
var import_meta2 = {};
|
|
288
|
+
var __filename2 = (0, import_url2.fileURLToPath)(import_meta2.url);
|
|
289
|
+
var __dirname2 = (0, import_path2.dirname)(__filename2);
|
|
290
|
+
function createViteConfigForReport(options, prepDir, currentBundleName, currentBundlePath, testConfigPath, suiteSummary) {
|
|
291
|
+
var _a;
|
|
292
|
+
const root = (0, import_path2.resolve)(__dirname2, "..", "template-report");
|
|
293
|
+
let reportPath;
|
|
294
|
+
if (options == null ? void 0 : options.reportPath) {
|
|
295
|
+
reportPath = options.reportPath;
|
|
296
|
+
} else {
|
|
297
|
+
reportPath = (0, import_path2.join)(prepDir, "check-report");
|
|
298
|
+
}
|
|
299
|
+
const outDir = (0, import_path2.relative)(root, reportPath);
|
|
300
|
+
const suiteSummaryJson = suiteSummary ? JSON.stringify(suiteSummary) : "";
|
|
301
|
+
const alias = (find, replacement) => {
|
|
302
|
+
return {
|
|
303
|
+
find,
|
|
304
|
+
replacement
|
|
305
|
+
};
|
|
306
|
+
};
|
|
307
|
+
const polyfillAlias = (find) => {
|
|
308
|
+
return {
|
|
309
|
+
find,
|
|
310
|
+
replacement: find,
|
|
311
|
+
customResolver: async function(_source, _importer, options2) {
|
|
312
|
+
const customResolver = (0, import_plugin_node_resolve2.nodeResolve)();
|
|
313
|
+
const customSource = `rollup-plugin-node-polyfills/polyfills/${find}`;
|
|
314
|
+
const customImporter = __filename2;
|
|
315
|
+
const resolved = await customResolver.resolveId.call(this, customSource, customImporter, options2);
|
|
316
|
+
return resolved.id;
|
|
317
|
+
}
|
|
318
|
+
};
|
|
319
|
+
};
|
|
320
|
+
return {
|
|
321
|
+
configFile: false,
|
|
322
|
+
root,
|
|
323
|
+
base: "",
|
|
324
|
+
clearScreen: false,
|
|
325
|
+
optimizeDeps: {
|
|
326
|
+
entries: ["index.html"],
|
|
327
|
+
exclude: ["tiny-worker"]
|
|
328
|
+
},
|
|
329
|
+
resolve: {
|
|
330
|
+
alias: [
|
|
331
|
+
alias("@_baseline_bundle_", (options == null ? void 0 : options.baseline) ? options.baseline.path : "/src/empty-bundle.ts"),
|
|
332
|
+
alias("@_current_bundle_", currentBundlePath),
|
|
333
|
+
alias("@_test_config_", testConfigPath),
|
|
334
|
+
alias("@_prep_", prepDir),
|
|
335
|
+
polyfillAlias("events"),
|
|
336
|
+
polyfillAlias("os"),
|
|
337
|
+
polyfillAlias("path"),
|
|
338
|
+
alias("url", "/src/url-polyfill.ts")
|
|
339
|
+
]
|
|
340
|
+
},
|
|
341
|
+
define: {
|
|
342
|
+
__SUITE_SUMMARY_JSON__: JSON.stringify(suiteSummaryJson),
|
|
343
|
+
__BASELINE_NAME__: JSON.stringify(((_a = options == null ? void 0 : options.baseline) == null ? void 0 : _a.name) || ""),
|
|
344
|
+
__CURRENT_NAME__: JSON.stringify(currentBundleName)
|
|
345
|
+
},
|
|
346
|
+
plugins: [],
|
|
347
|
+
build: {
|
|
348
|
+
outDir,
|
|
349
|
+
assetsDir: "",
|
|
350
|
+
rollupOptions: {
|
|
351
|
+
output: {
|
|
352
|
+
manualChunks: void 0
|
|
353
|
+
},
|
|
354
|
+
onwarn: (warning, warn) => {
|
|
355
|
+
if (warning.code !== "EVAL") {
|
|
356
|
+
warn(warning);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
},
|
|
361
|
+
server: {
|
|
362
|
+
port: (options == null ? void 0 : options.serverPort) || 8081,
|
|
363
|
+
open: "/index.html",
|
|
364
|
+
watch: {
|
|
365
|
+
awaitWriteFinish: {
|
|
366
|
+
stabilityThreshold: 100
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
// src/vite-config-for-tests.ts
|
|
374
|
+
var import_path3 = require("path");
|
|
375
|
+
var import_url3 = require("url");
|
|
376
|
+
var import_vite_plugin_glob = __toESM(require("vite-plugin-glob"), 1);
|
|
377
|
+
var import_plugin_replace = __toESM(require("@rollup/plugin-replace"), 1);
|
|
378
|
+
var import_meta3 = {};
|
|
379
|
+
var __filename3 = (0, import_url3.fileURLToPath)(import_meta3.url);
|
|
380
|
+
var __dirname3 = (0, import_path3.dirname)(__filename3);
|
|
381
|
+
function createViteConfigForTests(projDir, prepDir, mode) {
|
|
382
|
+
const root = (0, import_path3.resolve)(__dirname3, "..", "template-tests");
|
|
383
|
+
const templateSrcDir = (0, import_path3.resolve)(root, "src");
|
|
384
|
+
const relProjDir = (0, import_path3.relative)(templateSrcDir, projDir);
|
|
385
|
+
const yamlPath = `${relProjDir}/**/*.check.yaml`;
|
|
386
|
+
const outDir = (0, import_path3.relative)(root, prepDir);
|
|
387
|
+
return {
|
|
388
|
+
configFile: false,
|
|
389
|
+
root,
|
|
390
|
+
clearScreen: false,
|
|
391
|
+
plugins: [
|
|
392
|
+
(0, import_plugin_replace.default)({
|
|
393
|
+
preventAssignment: true,
|
|
394
|
+
values: {
|
|
395
|
+
__YAML_PATH__: JSON.stringify(yamlPath)
|
|
396
|
+
}
|
|
397
|
+
}),
|
|
398
|
+
(0, import_vite_plugin_glob.default)()
|
|
399
|
+
],
|
|
400
|
+
build: {
|
|
401
|
+
outDir,
|
|
402
|
+
emptyOutDir: false,
|
|
403
|
+
lib: {
|
|
404
|
+
entry: "./src/index.ts",
|
|
405
|
+
formats: ["es"],
|
|
406
|
+
fileName: () => "check-tests.js"
|
|
407
|
+
},
|
|
408
|
+
watch: mode === "watch" && {},
|
|
409
|
+
rollupOptions: {}
|
|
410
|
+
}
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
// src/plugin.ts
|
|
415
|
+
function checkPlugin(options) {
|
|
416
|
+
return new CheckPlugin(options);
|
|
417
|
+
}
|
|
418
|
+
var CheckPlugin = class {
|
|
419
|
+
constructor(options) {
|
|
420
|
+
this.options = options;
|
|
421
|
+
}
|
|
422
|
+
async watch(config) {
|
|
423
|
+
var _a;
|
|
424
|
+
if (((_a = this.options) == null ? void 0 : _a.testConfigPath) === void 0) {
|
|
425
|
+
await this.genTestConfig(config, "watch");
|
|
426
|
+
}
|
|
427
|
+
const testOptions = this.resolveTestOptions(config);
|
|
428
|
+
const viteConfig = this.createViteConfigForReport(config, testOptions, void 0);
|
|
429
|
+
const server = await (0, import_vite.createServer)(viteConfig);
|
|
430
|
+
await server.listen();
|
|
431
|
+
}
|
|
432
|
+
async postBuild(context, modelSpec) {
|
|
433
|
+
var _a, _b;
|
|
434
|
+
if (((_a = this.options) == null ? void 0 : _a.current) === void 0) {
|
|
435
|
+
context.log("info", "Generating model check bundle...");
|
|
436
|
+
await this.genCurrentBundle(context.config, modelSpec);
|
|
437
|
+
}
|
|
438
|
+
if (context.config.mode === "production") {
|
|
439
|
+
if (((_b = this.options) == null ? void 0 : _b.testConfigPath) === void 0) {
|
|
440
|
+
context.log("info", "Generating model check test configuration...");
|
|
441
|
+
await this.genTestConfig(context.config, "build");
|
|
442
|
+
}
|
|
443
|
+
const testOptions = this.resolveTestOptions(context.config);
|
|
444
|
+
return this.runChecks(context, testOptions);
|
|
445
|
+
} else {
|
|
446
|
+
return true;
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
async genCurrentBundle(config, modelSpec) {
|
|
450
|
+
const prepDir = config.prepDir;
|
|
451
|
+
const viteConfig = await createViteConfigForBundle(prepDir, modelSpec);
|
|
452
|
+
await (0, import_vite.build)(viteConfig);
|
|
453
|
+
}
|
|
454
|
+
async genTestConfig(config, mode) {
|
|
455
|
+
const rootDir = config.rootDir;
|
|
456
|
+
const prepDir = config.prepDir;
|
|
457
|
+
const viteConfig = createViteConfigForTests(rootDir, prepDir, mode);
|
|
458
|
+
await (0, import_vite.build)(viteConfig);
|
|
459
|
+
}
|
|
460
|
+
async runChecks(context, testOptions) {
|
|
461
|
+
var _a;
|
|
462
|
+
context.log("info", "Running model checks...");
|
|
463
|
+
const moduleR = await import((0, import_url4.pathToFileURL)(testOptions.currentBundlePath).toString());
|
|
464
|
+
const bundleR = moduleR.createBundle();
|
|
465
|
+
const nameR = testOptions.currentBundleName;
|
|
466
|
+
let bundleL;
|
|
467
|
+
let nameL;
|
|
468
|
+
if ((_a = this.options) == null ? void 0 : _a.baseline) {
|
|
469
|
+
const moduleL = await import((0, import_url4.pathToFileURL)(this.options.baseline.path).toString());
|
|
470
|
+
const rawBundleL = moduleL.createBundle();
|
|
471
|
+
if (rawBundleL.version === bundleR.version) {
|
|
472
|
+
bundleL = rawBundleL;
|
|
473
|
+
nameL = this.options.baseline.name;
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
const testConfigModule = await import((0, import_url4.pathToFileURL)(testOptions.testConfigPath).toString());
|
|
477
|
+
const checkOptions = await testConfigModule.getConfigOptions(bundleL, bundleR, {
|
|
478
|
+
nameL,
|
|
479
|
+
nameR
|
|
480
|
+
});
|
|
481
|
+
const checkConfig = await (0, import_check_core2.createConfig)(checkOptions);
|
|
482
|
+
const result = await runTestSuite(context, checkConfig, false);
|
|
483
|
+
context.log("info", "Building model check report");
|
|
484
|
+
const viteConfig = this.createViteConfigForReport(context.config, testOptions, result.suiteSummary);
|
|
485
|
+
await (0, import_vite.build)(viteConfig);
|
|
486
|
+
return result.allChecksPassed;
|
|
487
|
+
}
|
|
488
|
+
resolveTestOptions(config) {
|
|
489
|
+
var _a, _b;
|
|
490
|
+
let currentBundleName;
|
|
491
|
+
let currentBundlePath;
|
|
492
|
+
if (((_a = this.options) == null ? void 0 : _a.current) === void 0) {
|
|
493
|
+
currentBundleName = "current";
|
|
494
|
+
currentBundlePath = (0, import_path4.join)(config.prepDir, "check-bundle.js");
|
|
495
|
+
} else {
|
|
496
|
+
currentBundleName = this.options.current.name;
|
|
497
|
+
currentBundlePath = this.options.current.path;
|
|
498
|
+
}
|
|
499
|
+
let testConfigPath;
|
|
500
|
+
if (((_b = this.options) == null ? void 0 : _b.testConfigPath) === void 0) {
|
|
501
|
+
testConfigPath = (0, import_path4.join)(config.prepDir, "check-tests.js");
|
|
502
|
+
} else {
|
|
503
|
+
testConfigPath = this.options.testConfigPath;
|
|
504
|
+
}
|
|
505
|
+
return {
|
|
506
|
+
currentBundleName,
|
|
507
|
+
currentBundlePath,
|
|
508
|
+
testConfigPath
|
|
509
|
+
};
|
|
510
|
+
}
|
|
511
|
+
createViteConfigForReport(config, testOptions, suiteSummary) {
|
|
512
|
+
return createViteConfigForReport(this.options, config.prepDir, testOptions.currentBundleName, testOptions.currentBundlePath, testOptions.testConfigPath, suiteSummary);
|
|
513
|
+
}
|
|
514
|
+
};
|
|
515
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
516
|
+
0 && (module.exports = {
|
|
517
|
+
checkPlugin
|
|
518
|
+
});
|
|
519
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/plugin.ts","../src/run-suite.ts","../src/vite-config-for-bundle.ts","../src/var-names.ts","../src/vite-config-for-report.ts","../src/vite-config-for-tests.ts"],"sourcesContent":["// Copyright (c) 2022 Climate Interactive / New Venture Fund\n\nexport type { CheckBundle, CheckPluginOptions } from './options'\nexport { checkPlugin } from './plugin'\n","// Copyright (c) 2022 Climate Interactive / New Venture Fund\n\nimport { join as joinPath } from 'path'\nimport { pathToFileURL } from 'url'\n\nimport type { InlineConfig, ViteDevServer } from 'vite'\nimport { build, createServer } from 'vite'\n\nimport type { BuildContext, ModelSpec, Plugin, ResolvedConfig } from '@sdeverywhere/build'\n\nimport type { Bundle, SuiteSummary } from '@sdeverywhere/check-core'\nimport { createConfig } from '@sdeverywhere/check-core'\n\nimport type { CheckPluginOptions } from './options'\nimport { runTestSuite } from './run-suite'\nimport { createViteConfigForBundle } from './vite-config-for-bundle'\nimport { createViteConfigForReport } from './vite-config-for-report'\nimport { createViteConfigForTests } from './vite-config-for-tests'\n\nexport function checkPlugin(options?: CheckPluginOptions): Plugin {\n return new CheckPlugin(options)\n}\n\ninterface TestOptions {\n currentBundleName: string\n currentBundlePath: string\n testConfigPath: string\n}\n\nclass CheckPlugin implements Plugin {\n constructor(private readonly options?: CheckPluginOptions) {}\n\n async watch(config: ResolvedConfig): Promise<void> {\n if (this.options?.testConfigPath === undefined) {\n // Test config was not provided, so generate a default config in watch mode.\n // The test template uses import.meta.importGlob so that checks are re-run\n // automatically when the *.check.yaml files are changed.\n await this.genTestConfig(config, 'watch')\n }\n\n // For development mode, run Vite in dev mode so that it serves the\n // model-check report locally (with live reload enabled). When a model\n // test file is changed, the tests will be re-run in the browser.\n const testOptions = this.resolveTestOptions(config)\n const viteConfig = this.createViteConfigForReport(config, testOptions, undefined)\n const server: ViteDevServer = await createServer(viteConfig)\n await server.listen()\n }\n\n // TODO: Note that this plugin runs as a `postBuild` step because it currently\n // needs to run after other plugins, and those plugins need to run after the\n // staged files are copied to their final destination(s). We should probably\n // make it configurable so that it can either be run as a `postGenerate` or a\n // `postBuild` step.\n async postBuild(context: BuildContext, modelSpec: ModelSpec): Promise<boolean> {\n // For both production builds and local development, generate default bundle\n // in this post-build step each time a source file is changed\n // TODO: We could potentially use watch mode for the bundle similar to\n // what we do for the test config, but the bundle depends on the ModelSpec,\n // which currently isn't made available to the `watch` function\n if (this.options?.current === undefined) {\n // Path to current bundle was not provided, so generate a default bundle\n context.log('info', 'Generating model check bundle...')\n await this.genCurrentBundle(context.config, modelSpec)\n }\n\n if (context.config.mode === 'production') {\n if (this.options?.testConfigPath === undefined) {\n // Test config was not provided, so generate a default config\n context.log('info', 'Generating model check test configuration...')\n await this.genTestConfig(context.config, 'build')\n }\n\n // For production builds, run the model checks/comparisons, and then\n // inject the results into the generated report\n const testOptions = this.resolveTestOptions(context.config)\n return this.runChecks(context, testOptions)\n } else {\n // Nothing to do here in dev mode; the dev server will refresh and\n // re-run the tests in the browser when changes are detected\n return true\n }\n }\n\n private async genCurrentBundle(config: ResolvedConfig, modelSpec: ModelSpec): Promise<void> {\n const prepDir = config.prepDir\n const viteConfig = await createViteConfigForBundle(prepDir, modelSpec)\n await build(viteConfig)\n }\n\n private async genTestConfig(config: ResolvedConfig, mode: 'build' | 'watch'): Promise<void> {\n const rootDir = config.rootDir\n const prepDir = config.prepDir\n const viteConfig = createViteConfigForTests(rootDir, prepDir, mode)\n await build(viteConfig)\n }\n\n private async runChecks(context: BuildContext, testOptions: TestOptions): Promise<boolean> {\n context.log('info', 'Running model checks...')\n\n // Load the bundles used by the model check/compare configuration. We\n // always initialize the \"current\" bundle. Note that on Windows the\n // dynamic import path must be a `file://` URL, so we have to convert.\n const moduleR = await import(pathToFileURL(testOptions.currentBundlePath).toString())\n const bundleR = moduleR.createBundle() as Bundle\n const nameR = testOptions.currentBundleName\n\n // Only initialize the \"baseline\" bundle if it is defined and the version\n // is the same as the \"current\" one. If the baseline bundle has a different\n // version, we will skip the comparison tests and only run the checks on the\n // current bundle.\n let bundleL: Bundle\n let nameL: string\n if (this.options?.baseline) {\n const moduleL = await import(pathToFileURL(this.options.baseline.path).toString())\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const rawBundleL: any = moduleL.createBundle() as any\n if (rawBundleL.version === bundleR.version) {\n bundleL = rawBundleL as Bundle\n nameL = this.options.baseline.name\n }\n }\n\n // Get the model check/compare configuration\n const testConfigModule = await import(pathToFileURL(testOptions.testConfigPath).toString())\n const checkOptions = await testConfigModule.getConfigOptions(bundleL, bundleR, {\n nameL,\n nameR\n })\n\n // Run the suite of checks and comparisons\n const checkConfig = await createConfig(checkOptions)\n const result = await runTestSuite(context, checkConfig, /*verbose=*/ false)\n\n // Build the report (using Vite)\n context.log('info', 'Building model check report')\n const viteConfig = this.createViteConfigForReport(context.config, testOptions, result.suiteSummary)\n await build(viteConfig)\n\n // context.log('info', 'Done!')\n\n return result.allChecksPassed\n }\n\n private resolveTestOptions(config: ResolvedConfig): TestOptions {\n let currentBundleName: string\n let currentBundlePath: string\n if (this.options?.current === undefined) {\n // Path to current bundle was not provided, so use a generated bundle\n currentBundleName = 'current'\n currentBundlePath = joinPath(config.prepDir, 'check-bundle.js')\n } else {\n // Use the provided bundle\n currentBundleName = this.options.current.name\n currentBundlePath = this.options.current.path\n }\n\n let testConfigPath: string\n if (this.options?.testConfigPath === undefined) {\n // Test config was not provided, so use a generated config\n testConfigPath = joinPath(config.prepDir, 'check-tests.js')\n } else {\n // Use the provided test config\n testConfigPath = this.options.testConfigPath\n }\n\n return {\n currentBundleName,\n currentBundlePath,\n testConfigPath\n }\n }\n\n private createViteConfigForReport(\n config: ResolvedConfig,\n testOptions: TestOptions,\n suiteSummary: SuiteSummary | undefined\n ): InlineConfig {\n return createViteConfigForReport(\n this.options,\n config.prepDir,\n testOptions.currentBundleName,\n testOptions.currentBundlePath,\n testOptions.testConfigPath,\n suiteSummary\n )\n }\n}\n","// Copyright (c) 2021-2022 Climate Interactive / New Venture Fund\n\nimport { performance } from 'perf_hooks'\n\nimport pico from 'picocolors'\n\nimport type { BuildContext } from '@sdeverywhere/build'\n\nimport type {\n Config,\n CompareReport,\n PerfReport,\n RunSuiteCallbacks,\n CheckReport,\n CheckStatus,\n CompareConfig,\n CheckTestReport,\n SuiteSummary\n} from '@sdeverywhere/check-core'\nimport {\n datasetMessage,\n predicateMessage,\n runSuite,\n scenarioMessage,\n suiteSummaryFromReport\n} from '@sdeverywhere/check-core'\n\nexport interface RunTestSuiteResult {\n allChecksPassed: boolean\n suiteSummary: SuiteSummary\n}\n\n/**\n * Runs the test suite.\n */\nexport async function runTestSuite(\n context: BuildContext,\n config: Config,\n verbose: boolean\n): Promise<RunTestSuiteResult> {\n return new Promise((resolve, reject) => {\n const t0 = performance.now()\n let lastPctByInc: number\n const callbacks: RunSuiteCallbacks = {\n onProgress: progress => {\n const pct = Math.round(progress * 100)\n const pctByInc = Math.floor(pct / 5) * 5\n if (lastPctByInc === undefined || pctByInc > lastPctByInc) {\n lastPctByInc = pctByInc\n context.log('info', `${pctByInc}%`)\n }\n },\n onComplete: report => {\n try {\n const t1 = performance.now()\n const elapsed = ((t1 - t0) / 1000).toFixed(1)\n context.log('info', `\\nTest suite completed in ${elapsed}s`)\n\n // Print check summary to the console\n const allChecksPassed = printCheckSummary(context, report.checkReport, verbose)\n\n if (report.compareReport) {\n // Print the perf stats to the console\n printPerfStats(context, config.compare, report.compareReport)\n }\n\n // Convert check and compare reports to terse form that only includes\n // failed/errored checks or comparisons with differences\n // TODO: The terse form was originally used when we had to write the\n // results to a JSON file and then read them back in when building\n // the report, but we no longer use that intermediate file, so there's\n // less reason to use the terse form (since it requires the web app\n // code to reconstruct the results). But for now, we will continue\n // to use the terse form, and later we can update the app code.\n const suiteSummary = suiteSummaryFromReport(report)\n\n resolve({\n allChecksPassed,\n suiteSummary\n })\n } catch (e) {\n reject(e)\n }\n },\n onError: error => {\n reject(error)\n }\n }\n runSuite(config, callbacks)\n })\n}\n\nfunction printCheckSummary(context: BuildContext, checkReport: CheckReport, verbose: boolean): boolean {\n function printResult(indent: number, status: CheckStatus, text: string): void {\n if (!verbose && status === 'passed' && indent > 1) {\n return\n }\n let statusChar: string\n switch (status) {\n case 'passed':\n statusChar = '✓'\n break\n case 'failed':\n statusChar = '✗'\n break\n case 'error':\n statusChar = '‼'\n break\n default:\n statusChar = ''\n break\n }\n const msg = `${' '.repeat(indent)}${statusChar} ${text}`\n context.log('info', status === 'passed' ? pico.green(msg) : pico.red(msg))\n }\n\n function bold(s: string): string {\n return pico.bold(s)\n }\n\n function printTest(test: CheckTestReport): void {\n const msg = `${test.name}${verbose || test.status !== 'passed' ? ':' : ''}`\n printResult(1, test.status, msg)\n }\n\n let allPassed = true\n context.log('info', '\\nCheck results:')\n for (const group of checkReport.groups) {\n context.log('info', `\\n${group.name}`)\n\n for (const test of group.tests) {\n if (test.status !== 'passed') {\n allPassed = false\n }\n printTest(test)\n\n for (const scenario of test.scenarios) {\n printResult(3, scenario.status, scenarioMessage(scenario, bold))\n\n for (const dataset of scenario.datasets) {\n printResult(5, dataset.status, datasetMessage(dataset, bold))\n\n for (const predicate of dataset.predicates) {\n printResult(7, predicate.result.status, predicateMessage(predicate, bold))\n }\n }\n }\n }\n }\n context.log('info', '')\n\n return allPassed\n}\n\nfunction stat(label: string, n: number): string {\n return `${label}=${n.toFixed(1)}ms`\n}\n\nfunction printPerfReportLine(context: BuildContext, perfReport: PerfReport): void {\n const avg = stat('avg', perfReport.avgTime)\n const min = stat('min', perfReport.minTime)\n const max = stat('max', perfReport.maxTime)\n context.log('info', ` ${avg} ${min} ${max}`)\n}\n\nfunction printPerfStats(context: BuildContext, compareConfig: CompareConfig, report: CompareReport): void {\n context.log('info', '\\nPerformance stats:')\n context.log('info', ` ${compareConfig.bundleL.name}:`)\n printPerfReportLine(context, report.perfReportL)\n context.log('info', ` ${compareConfig.bundleR.name}:`)\n printPerfReportLine(context, report.perfReportR)\n context.log('info', '')\n}\n","// Copyright (c) 2022 Climate Interactive / New Venture Fund\n\nimport type { ModelSpec } from '@sdeverywhere/build'\nimport { dirname, join as joinPath, relative, resolve as resolvePath } from 'path'\nimport { fileURLToPath } from 'url'\n\nimport type { InlineConfig, Plugin as VitePlugin } from 'vite'\nimport { nodeResolve } from '@rollup/plugin-node-resolve'\n\nimport { sdeNameForVensimVarName } from './var-names'\n\nconst __filename = fileURLToPath(import.meta.url)\nconst __dirname = dirname(__filename)\n\n/**\n * This is a virtual module plugin used to inject model-specific configuration\n * values into the generated worker bundle.\n *\n * This follows the \"Virtual Modules Convention\" described here:\n * https://vitejs.dev/guide/api-plugin.html#virtual-modules-convention\n *\n * TODO: This could be simplified by using `vite-plugin-virtual` but that\n * doesn't seem to be working correctly in an ESM setting\n */\nfunction injectModelSpec(modelSpec: ModelSpec): VitePlugin {\n // Include the SDE variable ID with each spec\n const inputSpecs = modelSpec.inputs.map(i => {\n return {\n varId: sdeNameForVensimVarName(i.varName),\n ...i\n }\n })\n const outputSpecs = modelSpec.outputs.map(o => {\n return {\n varId: sdeNameForVensimVarName(o.varName),\n ...o\n }\n })\n\n const moduleSrc = `\nexport const startTime = ${modelSpec.startTime};\nexport const endTime = ${modelSpec.endTime};\nexport const inputSpecs = ${JSON.stringify(inputSpecs)};\nexport const outputSpecs = ${JSON.stringify(outputSpecs)};\n`\n\n const virtualModuleId = 'virtual:model-spec'\n const resolvedVirtualModuleId = '\\0' + virtualModuleId\n\n return {\n name: 'vite-plugin-virtual-custom',\n resolveId(id: string) {\n if (id === virtualModuleId) {\n return resolvedVirtualModuleId\n }\n },\n load(id: string) {\n if (id === resolvedVirtualModuleId) {\n return moduleSrc\n }\n }\n }\n}\n\nexport async function createViteConfigForBundle(prepDir: string, modelSpec: ModelSpec): Promise<InlineConfig> {\n // Use `template-bundle` as the root directory for the bundle project\n const root = resolvePath(__dirname, '..', 'template-bundle')\n\n // Calculate output directory relative to the template root\n // TODO: For now we write it to `prepDir`; make this configurable?\n const outDir = relative(root, prepDir)\n\n // Use the model worker from the staged directory\n // TODO: Make this configurable?\n const modelWorkerPath = joinPath(prepDir, 'staged', 'model', 'worker.js?raw')\n\n return {\n // Don't use an external config file\n configFile: false,\n\n // Use the root directory configured above\n root,\n\n // Don't clear the screen in dev mode so that we can see builder output\n clearScreen: false,\n\n // TODO: Disable vite output by default?\n // logLevel: 'silent',\n\n // Configure path aliases\n resolve: {\n alias: [\n // Inject the configured model worker\n {\n find: '@_model_worker_',\n replacement: modelWorkerPath\n },\n\n // XXX: Prevent Vite from using the `browser` section of `threads/package.json`\n // since we want to force the use of the general module (under dist-esm) that chooses\n // the correct implementation (Web Worker vs worker_threads) at runtime. Currently\n // Vite's library mode is browser focused, so using a `customResolver` seems to be\n // the easiest way to prevent Vite from picking up the `browser` exports.\n {\n find: 'threads',\n replacement: 'threads',\n customResolver: async function (source, importer, options) {\n // Note that we need to use `resolveId.call` here in order to provide the\n // right `this` context, which provides Rollup plugin functionality\n const customResolver = nodeResolve({ browser: false })\n const resolved = await customResolver.resolveId.call(this, source, importer, options)\n // Force the use of the `dist-esm` variant of the threads.js package\n if (source === 'threads/worker') {\n return resolved.id.replace('worker.mjs', 'dist-esm/worker/index.js')\n } else {\n return resolved.id.replace('index.mjs', 'dist-esm/index.js')\n }\n }\n }\n ]\n },\n\n plugins: [\n // Use a virtual module plugin to inject the model spec values\n injectModelSpec(modelSpec)\n ],\n\n build: {\n // Write output files to the configured directory (instead of the default `dist`);\n // note that this must be relative to the project `root`\n outDir,\n emptyOutDir: false,\n\n lib: {\n entry: './src/index.ts',\n formats: ['es'],\n fileName: () => 'check-bundle.js'\n },\n\n rollupOptions: {\n // Don't transform Node imports used by threads.js\n external: ['events', 'os', 'path', 'url'],\n\n // XXX: Insert custom code at the top of the generated bundle that defines\n // the special `__non_webpack_require__` function that is used by threads.js\n // in its Node implementation. This import ensures that threads.js uses\n // the native `worker_threads` implementation when using the bundle in a\n // Node environment. When importing the bundle for use in the browser,\n // Vite will transform this import into an empty module (it does not seem\n // to be necessary to define a polyfill).\n output: {\n banner: `\nimport * as worker_threads from 'worker_threads'\nlet __non_webpack_require__ = () => {\n return worker_threads;\n};\n`\n },\n\n onwarn: (warning, warn) => {\n // XXX: Suppress \"Use of eval is strongly discouraged\" warnings that are\n // triggered by use of the following pattern in threads.js:\n // eval(\"require\")(\"worker_threads\")\n // It would be nice to avoid use of `eval` there, but it's not critical for\n // our use case so we will suppress the warnings for now\n if (warning.code !== 'EVAL') {\n warn(warning)\n }\n }\n }\n }\n }\n}\n","// Copyright (c) 2022 Climate Interactive / New Venture Fund\n\n/**\n * Helper function that converts a Vensim variable or subscript name\n * into a valid C identifier as used by SDE.\n * TODO: Import helper function from `compile` package instead\n */\nfunction sdeNameForVensimName(name: string): string {\n return (\n '_' +\n name\n .trim()\n .replace(/\"/g, '_')\n .replace(/\\s+!$/g, '!')\n .replace(/\\s/g, '_')\n .replace(/,/g, '_')\n .replace(/-/g, '_')\n .replace(/\\./g, '_')\n .replace(/\\$/g, '_')\n .replace(/'/g, '_')\n .replace(/&/g, '_')\n .replace(/%/g, '_')\n .replace(/\\//g, '_')\n .replace(/\\|/g, '_')\n .toLowerCase()\n )\n}\n\n/**\n * Helper function that converts a Vensim variable name (possibly containing\n * subscripts) into a valid C identifier as used by SDE.\n * TODO: Import helper function from `compile` package instead\n */\nexport function sdeNameForVensimVarName(varName: string): string {\n const m = varName.match(/([^[]+)(?:\\[([^\\]]+)\\])?/)\n if (!m) {\n throw new Error(`Invalid Vensim name: ${varName}`)\n }\n let id = sdeNameForVensimName(m[1])\n if (m[2]) {\n const subscripts = m[2].split(',').map(x => sdeNameForVensimName(x))\n id += `[${subscripts.join('][')}]`\n }\n\n return id\n}\n","// Copyright (c) 2022 Climate Interactive / New Venture Fund\n\nimport { dirname, relative, join as joinPath, resolve as resolvePath } from 'path'\nimport { fileURLToPath } from 'url'\n\nimport type { Alias, InlineConfig } from 'vite'\n// import globPlugin from 'vite-plugin-glob'\nimport { nodeResolve } from '@rollup/plugin-node-resolve'\n\nimport type { SuiteSummary } from '@sdeverywhere/check-core'\n\nimport type { CheckPluginOptions } from './options'\n\nconst __filename = fileURLToPath(import.meta.url)\nconst __dirname = dirname(__filename)\n\nexport function createViteConfigForReport(\n options: CheckPluginOptions | undefined,\n prepDir: string,\n currentBundleName: string,\n currentBundlePath: string,\n testConfigPath: string,\n suiteSummary: SuiteSummary | undefined\n): InlineConfig {\n // Use `template-report` as the root directory for the report project\n const root = resolvePath(__dirname, '..', 'template-report')\n\n // Calculate output directory relative to the template root\n let reportPath: string\n if (options?.reportPath) {\n reportPath = options.reportPath\n } else {\n reportPath = joinPath(prepDir, 'check-report')\n }\n const outDir = relative(root, reportPath)\n\n // Convert the suite summary to JSON, which is what the app currently expects\n const suiteSummaryJson = suiteSummary ? JSON.stringify(suiteSummary) : ''\n\n const alias = (find: string, replacement: string) => {\n return {\n find,\n replacement\n } as Alias\n }\n\n // XXX: This provides custom handling for Node built-ins such as 'events' that are\n // referenced by the check bundle (specifically in the Node implementation of\n // threads.js). These are not actually used in the browser, so we just need\n // to provide no-op polyfills for these.\n const polyfillAlias = (find: string) => {\n return {\n find,\n replacement: find,\n customResolver: async function (_source, _importer, options) {\n const customResolver = nodeResolve()\n // Replace uses of Node built-ins (e.g. 'events') with the appropriate polyfill\n const customSource = `rollup-plugin-node-polyfills/polyfills/${find}`\n // Use this file as the \"importer\" so that we resolve `rollup-plugin-node-polyfills`\n // relative to `plugin-check/node_modules`. Without this workaround, the consuming\n // project would need `rollup-plugin-node-polyfills` as an explicit dependency, and\n // we want to avoid that since it's more of an implementation detail.\n const customImporter = __filename\n // Note that we need to use `resolveId.call` here in order to provide the\n // right `this` context, which provides Rollup plugin functionality\n const resolved = await customResolver.resolveId.call(this, customSource, customImporter, options)\n return resolved.id\n }\n } as Alias\n }\n\n return {\n // Don't use an external config file\n configFile: false,\n\n // Use the root directory configured above\n root,\n\n // Use `.` as the base directory (instead of the default `/`); this controls\n // how the path to the js/css files are generated in `index.html`\n base: '',\n\n // Load static files from `static` (instead of the default `public`)\n // publicDir: 'static',\n\n // Don't clear the screen in dev mode so that we can see builder output\n clearScreen: false,\n\n // TODO\n // logLevel: 'silent',\n\n optimizeDeps: {\n // Prevent Vite from examining other html files when scanning entrypoints\n // for dependency optimization\n entries: ['index.html'],\n\n // XXX: The threads.js implementation references `tiny-worker` as an optional\n // dependency, but it doesn't get used at runtime, so we can just exclude it\n // so that Vite doesn't complain in dev mode\n exclude: ['tiny-worker']\n },\n\n // Configure path aliases\n resolve: {\n alias: [\n // Use the configured \"baseline\" bundle if defined, otherwise use the \"empty\" bundle\n // (which will cause comparison tests to be skipped)\n alias('@_baseline_bundle_', options?.baseline ? options.baseline.path : '/src/empty-bundle.ts'),\n\n // Use the configured \"current\" bundle\n alias('@_current_bundle_', currentBundlePath),\n\n // Use the configured test config file\n alias('@_test_config_', testConfigPath),\n\n // Make the overlay use the `messages.html` file that is written to the prep directory\n alias('@_prep_', prepDir),\n\n // XXX: Include polyfills for these modules that are used in the Node-specific\n // implementation of threads.js; this allows us to use one bundle that works\n // in both Node and browser environments\n polyfillAlias('events'),\n polyfillAlias('os'),\n polyfillAlias('path'),\n // XXX: The following is only needed due to threads.js 1.7.0 importing `fileURLToPath`.\n // We use a no-op polyfill of our own for the time being.\n alias('url', '/src/url-polyfill.ts')\n ]\n },\n\n // Inject special values into the generated JS\n define: {\n // Inject the summary JSON into the build\n __SUITE_SUMMARY_JSON__: JSON.stringify(suiteSummaryJson),\n\n // Inject the baseline branch name\n __BASELINE_NAME__: JSON.stringify(options?.baseline?.name || ''),\n\n // Inject the current branch name\n __CURRENT_NAME__: JSON.stringify(currentBundleName)\n },\n\n plugins: [\n // Use `vite-plugin-glob` instead of Vite's built-in `import.meta.globEager`\n // because the plugin does a better job of handling HMR when the yaml files\n // are outside of the `template-report` app root directory.\n // globPlugin(),\n ],\n\n build: {\n // Write output files to the configured directory (instead of the default `dist`);\n // note that this must be relative to the project `root`\n outDir,\n\n // Write js/css files to `public` (instead of the default `<outDir>/assets`)\n assetsDir: '',\n\n rollupOptions: {\n output: {\n // XXX: Prevent vite from creating a separate `vendor.js` file\n manualChunks: undefined\n },\n\n onwarn: (warning, warn) => {\n // XXX: Suppress \"Use of eval is strongly discouraged\" warnings that are\n // triggered by use of the following pattern in threads.js:\n // eval(\"require\")(\"worker_threads\")\n // It would be nice to avoid use of `eval` there, but it's not critical for\n // our use case so we will suppress the warnings for now\n if (warning.code !== 'EVAL') {\n warn(warning)\n }\n }\n }\n },\n\n server: {\n // Run the dev server at `localhost:8081` by default\n port: options?.serverPort || 8081,\n\n // Open the app in the browser by default\n open: '/index.html',\n\n // XXX: Add a small delay, otherwise on macOS we sometimes get multiple\n // change events when a file is saved just once. That is a relatively\n // harmless issue except that it causes redundant messages in the console\n // and can cause extra churn when refreshing the app.\n watch: {\n awaitWriteFinish: {\n stabilityThreshold: 100\n }\n }\n }\n }\n}\n","// Copyright (c) 2022 Climate Interactive / New Venture Fund\n\nimport { dirname, relative, resolve as resolvePath } from 'path'\nimport { fileURLToPath } from 'url'\n\nimport type { InlineConfig } from 'vite'\nimport globPlugin from 'vite-plugin-glob'\nimport replace from '@rollup/plugin-replace'\n\nconst __filename = fileURLToPath(import.meta.url)\nconst __dirname = dirname(__filename)\n\nexport function createViteConfigForTests(projDir: string, prepDir: string, mode: 'build' | 'watch'): InlineConfig {\n // Use `template-tests` as the root directory for the tests project\n const root = resolvePath(__dirname, '..', 'template-tests')\n\n // Include `*.check.yaml` files under the configured project root directory. This\n // glob path apparently must be a relative path (relative to the `template-tests/src`\n // directory where the glob is used).\n const templateSrcDir = resolvePath(root, 'src')\n const relProjDir = relative(templateSrcDir, projDir)\n // TODO: Use yamlPath from options\n const yamlPath = `${relProjDir}/**/*.check.yaml`\n\n // // Read the `package.json` for the template project\n // const pkgPath = resolvePath(root, 'package.json')\n // const pkg = JSON.parse(readFileSync(pkgPath, 'utf8'))\n\n // Calculate output directory relative to the template root\n // TODO: For now we write it to `prepDir`; make this configurable?\n const outDir = relative(root, prepDir)\n\n return {\n // Don't use an external config file\n configFile: false,\n\n // Use the root directory configured above\n root,\n\n // Don't clear the screen in dev mode so that we can see builder output\n clearScreen: false,\n\n // TODO: Disable vite output by default?\n // logLevel: 'silent',\n\n plugins: [\n // Inject special values into the generated JS\n // TODO: We currently have to use `@rollup/plugin-replace` instead of Vite's\n // built-in `define` feature because the latter does not seem to run before\n // the glob plugin, and that requires the glob to be injected as a literal;\n // `plugin-replace` seems to work as long as we order it before `plugin-glob`.\n // Maybe we can switch back to `define` once we move to Vite 3.x.\n replace({\n preventAssignment: true,\n values: {\n // Inject the glob pattern for matching check yaml files\n __YAML_PATH__: JSON.stringify(yamlPath)\n }\n }),\n\n // Use `vite-plugin-glob` instead of Vite's built-in `import.meta.globEager`\n // because the plugin does a better job of handling HMR when the yaml files\n // are outside of the `template-report` app root directory.\n globPlugin()\n ],\n\n build: {\n // Write output files to the configured directory (instead of the default `dist`);\n // note that this must be relative to the project `root`\n outDir,\n emptyOutDir: false,\n\n lib: {\n entry: './src/index.ts',\n formats: ['es'],\n fileName: () => 'check-tests.js'\n },\n\n // Enable watch mode if requested\n watch: mode === 'watch' && {},\n\n rollupOptions: {\n // Prevent dependencies from being included in packaged library\n // TODO: For now we include check-core in the packaged library so that its\n // dependencies are correctly resolved at runtime. Ideally this would only\n // include a couple functions that are used for defining tests, but Vite 2.x\n // does not implement tree shaking for ES libraries, which means the generated\n // library is much larger than it needs to be. Once we upgrade to Vite 3.x,\n // the generated library should be smaller; see related fix:\n // https://github.com/vitejs/vite/pull/8737\n // external: Object.keys(pkg.dependencies)\n }\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEA,mBAAiC;AACjC,kBAA8B;AAG9B,kBAAoC;AAKpC,yBAA6B;;;ACT7B,wBAA4B;AAE5B,wBAAiB;AAejB,wBAMO;AAUP,4BACE,SACA,QACA,SAC6B;AAC7B,SAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACtC,UAAM,KAAK,8BAAY,IAAI;AAC3B,QAAI;AACJ,UAAM,YAA+B;AAAA,MACnC,YAAY,cAAY;AACtB,cAAM,MAAM,KAAK,MAAM,WAAW,GAAG;AACrC,cAAM,WAAW,KAAK,MAAM,MAAM,CAAC,IAAI;AACvC,YAAI,iBAAiB,UAAa,WAAW,cAAc;AACzD,yBAAe;AACf,kBAAQ,IAAI,QAAQ,GAAG,WAAW;AAAA,QACpC;AAAA,MACF;AAAA,MACA,YAAY,YAAU;AACpB,YAAI;AACF,gBAAM,KAAK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