@sdeverywhere/plugin-check 0.1.5 → 0.2.1
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/bin/sde-check.js +60 -0
- package/dist/index.cjs +80 -37
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +76 -39
- package/dist/index.js.map +1 -1
- package/package.json +13 -6
- package/template-bundle/src/bundle.ts +1 -9
- package/template-bundle/src/empty-model-spec.ts +2 -0
- package/template-report/index.html +10 -0
- package/template-report/package.json +1 -1
- package/template-report/src/env.d.ts +1 -0
- package/template-report/src/index.ts +144 -13
- package/template-report/tsconfig.json +2 -2
- package/template-tests/src/index.ts +2 -5
- package/template-tests/tsconfig.json +3 -2
|
@@ -14,17 +14,73 @@ import { createBundle as createBaselineBundle } from '@_baseline_bundle_'
|
|
|
14
14
|
import { createBundle as createCurrentBundle } from '@_current_bundle_'
|
|
15
15
|
import { getConfigOptions } from '@_test_config_'
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
17
|
+
function loadBundleName(key: string): string | undefined {
|
|
18
|
+
if (import.meta.hot) {
|
|
19
|
+
return localStorage.getItem(`sde-check-selected-bundle-${key}`)
|
|
20
|
+
} else {
|
|
21
|
+
return undefined
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function saveBundleName(key: string, value: string): void {
|
|
26
|
+
if (import.meta.hot) {
|
|
27
|
+
localStorage.setItem(`sde-check-selected-bundle-${key}`, value)
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// For local development mode, load the list of available baseline bundles
|
|
32
|
+
type BundleModule = {
|
|
33
|
+
createBundle(): Bundle
|
|
25
34
|
}
|
|
35
|
+
type LoadBundle = () => Promise<Bundle>
|
|
36
|
+
const availableBundles: { [key: string]: LoadBundle } = {}
|
|
37
|
+
let bundleNames: string[]
|
|
38
|
+
let selectedBaselineBundleName: string
|
|
39
|
+
let selectedCurrentBundleName: string
|
|
40
|
+
const baselinesPath = __BASELINE_BUNDLES_PATH__
|
|
41
|
+
if (import.meta.hot && baselinesPath) {
|
|
42
|
+
// Restore the previously selected bundles (from before the page was reloaded)
|
|
43
|
+
selectedBaselineBundleName = loadBundleName('baseline')
|
|
44
|
+
selectedCurrentBundleName = loadBundleName('current')
|
|
45
|
+
|
|
46
|
+
// Get the available baseline bundles
|
|
47
|
+
const bundlesGlob = import.meta.glob(__BASELINE_BUNDLES_PATH__, {
|
|
48
|
+
eager: false
|
|
49
|
+
})
|
|
50
|
+
const baselineBundleNames: string[] = []
|
|
51
|
+
for (const bundleKey of Object.keys(bundlesGlob)) {
|
|
52
|
+
const loadBundle = bundlesGlob[bundleKey]
|
|
53
|
+
const bundlePathParts = bundleKey.split('/')
|
|
54
|
+
const bundleFileName = bundlePathParts[bundlePathParts.length - 1]
|
|
55
|
+
const bundleName = bundleFileName.replace('.js', '')
|
|
56
|
+
baselineBundleNames.push(bundleName)
|
|
57
|
+
availableBundles[bundleName] = async () => {
|
|
58
|
+
const module = (await loadBundle()) as BundleModule
|
|
59
|
+
return module.createBundle() as Bundle
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Alphabetize (reversed, so that newer dates are at the top of the list)
|
|
64
|
+
baselineBundleNames.sort((a, b) => {
|
|
65
|
+
return b.toLowerCase().localeCompare(a.toLowerCase())
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
// Always include the "current" bundle as the first option, followed by
|
|
69
|
+
// the alphabetized bundle names
|
|
70
|
+
bundleNames = ['current', ...baselineBundleNames]
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
async function initForProduction(): Promise<void> {
|
|
74
|
+
// For "production" builds, load the summary from a JSON file that
|
|
75
|
+
// was generated as part of the build process. This makes the
|
|
76
|
+
// report load almost immediately instead of running all the checks
|
|
77
|
+
// in the user's browser.
|
|
78
|
+
const suiteSummaryJson = __SUITE_SUMMARY_JSON__
|
|
79
|
+
let suiteSummary: SuiteSummary
|
|
80
|
+
if (suiteSummaryJson) {
|
|
81
|
+
suiteSummary = JSON.parse(suiteSummaryJson) as SuiteSummary
|
|
82
|
+
}
|
|
26
83
|
|
|
27
|
-
async function init() {
|
|
28
84
|
// Load the bundles used by the model check/compare configuration. We
|
|
29
85
|
// always initialize the "current" bundle.
|
|
30
86
|
const bundleR: Bundle = createCurrentBundle()
|
|
@@ -47,10 +103,85 @@ async function init() {
|
|
|
47
103
|
})
|
|
48
104
|
|
|
49
105
|
// Initialize the root Svelte component
|
|
50
|
-
initAppShell(checkOptions,
|
|
106
|
+
initAppShell(checkOptions, {
|
|
107
|
+
suiteSummary
|
|
108
|
+
})
|
|
109
|
+
}
|
|
51
110
|
|
|
52
|
-
|
|
53
|
-
|
|
111
|
+
async function initForLocal(): Promise<void> {
|
|
112
|
+
async function createBundle(requestedName: string | undefined): Promise<[Bundle, string]> {
|
|
113
|
+
if (requestedName === undefined) {
|
|
114
|
+
requestedName = 'current'
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// See if there is a bundle available for the requested name
|
|
118
|
+
let bundle: Bundle
|
|
119
|
+
let bundleName: string
|
|
120
|
+
if (requestedName in availableBundles) {
|
|
121
|
+
// Load the bundle for the requested name
|
|
122
|
+
const loadBundle = availableBundles[requestedName]
|
|
123
|
+
bundle = await loadBundle()
|
|
124
|
+
bundleName = requestedName
|
|
125
|
+
} else {
|
|
126
|
+
// Load the "current" bundle
|
|
127
|
+
bundle = createCurrentBundle()
|
|
128
|
+
bundleName = 'current'
|
|
129
|
+
}
|
|
130
|
+
return [bundle, bundleName]
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const [bundleL, nameL] = await createBundle(selectedBaselineBundleName)
|
|
134
|
+
const [bundleR, nameR] = await createBundle(selectedCurrentBundleName)
|
|
135
|
+
|
|
136
|
+
// Prepare the model check/compare configuration
|
|
137
|
+
const checkOptions = await getConfigOptions(bundleL, bundleR, {
|
|
138
|
+
nameL,
|
|
139
|
+
nameR
|
|
140
|
+
})
|
|
141
|
+
|
|
142
|
+
// Initialize the root Svelte component
|
|
143
|
+
initAppShell(checkOptions, {
|
|
144
|
+
bundleNames
|
|
145
|
+
})
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
async function initBundlesAndUI() {
|
|
149
|
+
// Prepare options differently if in local development mode
|
|
150
|
+
if (import.meta.hot) {
|
|
151
|
+
await initForLocal()
|
|
152
|
+
} else {
|
|
153
|
+
await initForProduction()
|
|
154
|
+
}
|
|
54
155
|
}
|
|
55
156
|
|
|
56
|
-
|
|
157
|
+
// Initialize the overlay element used to show builder messages/errors
|
|
158
|
+
initOverlay()
|
|
159
|
+
|
|
160
|
+
// Initialize the bundles and user interface
|
|
161
|
+
initBundlesAndUI()
|
|
162
|
+
|
|
163
|
+
if (import.meta.hot) {
|
|
164
|
+
// Reload everything when the user chooses a new baseline or current bundle
|
|
165
|
+
document.addEventListener('sde-check-bundle', e => {
|
|
166
|
+
// Change the selected bundle
|
|
167
|
+
const info = (e as CustomEvent).detail
|
|
168
|
+
if (info.kind === 'left') {
|
|
169
|
+
saveBundleName('baseline', info.name)
|
|
170
|
+
selectedBaselineBundleName = info.name
|
|
171
|
+
} else {
|
|
172
|
+
saveBundleName('current', info.name)
|
|
173
|
+
selectedCurrentBundleName = info.name
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// Before switching bundles, clear out the app-shell-container element
|
|
177
|
+
const container = document.getElementById('app-shell-container')
|
|
178
|
+
while (container.firstChild) {
|
|
179
|
+
container.removeChild(container.firstChild)
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// TODO: Release resources associated with active bundles
|
|
183
|
+
|
|
184
|
+
// Reinitialize using the chosen bundles
|
|
185
|
+
initBundlesAndUI()
|
|
186
|
+
})
|
|
187
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
-
"
|
|
3
|
+
// Use "esnext" for import.meta
|
|
4
|
+
"target": "esnext",
|
|
4
5
|
// Use "es2020" for dynamic import
|
|
5
6
|
"module": "es2020",
|
|
6
7
|
// Emit additional JS to ease support for importing CommonJS modules
|
|
@@ -14,7 +15,6 @@
|
|
|
14
15
|
"noImplicitAny": true,
|
|
15
16
|
"noUnusedLocals": true,
|
|
16
17
|
"noUnusedParameters": true,
|
|
17
|
-
// "types": ["vite/client", "vite-plugin-glob/client"],
|
|
18
18
|
"types": ["vite/client"],
|
|
19
19
|
"skipLibCheck": true,
|
|
20
20
|
// Use placeholders for path aliases that are configured in the Vite
|
|
@@ -4,11 +4,8 @@ import type { Bundle, CompareOptions, ConfigOptions, DatasetKey } from '@sdevery
|
|
|
4
4
|
|
|
5
5
|
import { DatasetManager, ScenarioManager } from '@sdeverywhere/check-core'
|
|
6
6
|
|
|
7
|
-
// Load the yaml test files
|
|
8
|
-
|
|
9
|
-
// does a better job of handling HMR when the yaml files are outside of
|
|
10
|
-
// the `template-report` app root directory.
|
|
11
|
-
const yamlGlob = import.meta.importGlob(__YAML_PATH__, {
|
|
7
|
+
// Load the yaml test files
|
|
8
|
+
const yamlGlob = import.meta.glob(__YAML_PATH__, {
|
|
12
9
|
eager: true,
|
|
13
10
|
as: 'raw'
|
|
14
11
|
})
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
-
"
|
|
3
|
+
// Use "esnext" for import.meta
|
|
4
|
+
"target": "esnext",
|
|
4
5
|
// Use "es2020" for dynamic import
|
|
5
6
|
"module": "es2020",
|
|
6
7
|
// Emit additional JS to ease support for importing CommonJS modules
|
|
@@ -14,6 +15,6 @@
|
|
|
14
15
|
"noImplicitAny": true,
|
|
15
16
|
"noUnusedLocals": true,
|
|
16
17
|
"noUnusedParameters": true,
|
|
17
|
-
"types": ["vite
|
|
18
|
+
"types": ["vite/client"]
|
|
18
19
|
}
|
|
19
20
|
}
|