@astl/devkit 0.0.0 → 0.1.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/CHANGELOG.md ADDED
@@ -0,0 +1,40 @@
1
+ # @astl/devkit
2
+
3
+ ## 0.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 2f8247b: Shorter npm description for @astl/astrolabe and keywords for all packages.
8
+ - Updated dependencies [2f8247b]
9
+ - @astl/components@0.1.1
10
+ - @astl/core@0.1.1
11
+ - @astl/engine@0.1.1
12
+ - @astl/tokens@0.1.1
13
+
14
+ ## 0.1.0
15
+
16
+ ### Minor Changes
17
+
18
+ - 6a4f220: The first release on npm, under the scope `@astl`: `@astl/astrolabe` with everything on by default, and the single packages it is built from, all at one version.
19
+
20
+ ### Patch Changes
21
+
22
+ - Updated dependencies [402924c]
23
+ - Updated dependencies [97e412c]
24
+ - Updated dependencies [47b19e2]
25
+ - Updated dependencies [bac3ecb]
26
+ - Updated dependencies [ec2a249]
27
+ - Updated dependencies [cfa6485]
28
+ - Updated dependencies [4611aeb]
29
+ - Updated dependencies [6a4f220]
30
+ - Updated dependencies [ae90305]
31
+ - Updated dependencies [c500ae1]
32
+ - Updated dependencies [871b57a]
33
+ - Updated dependencies [3a4945c]
34
+ - Updated dependencies [1609051]
35
+ - Updated dependencies [64af38f]
36
+ - Updated dependencies [36059aa]
37
+ - @astl/core@0.1.0
38
+ - @astl/engine@0.1.0
39
+ - @astl/components@0.1.0
40
+ - @astl/tokens@0.1.0
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,42 @@
1
+ # @astl/devkit
2
+
3
+ `astl` CLI: validate, compile and run conformance fixtures.
4
+
5
+ ## Install
6
+
7
+ ```sh
8
+ npm install --save-dev @astl/devkit
9
+ ```
10
+
11
+ ## Use
12
+
13
+ ```txt
14
+ astl validate <files...> [--json] [--locale <tag>]
15
+ astl compile <file> --out <dir> --key-out <file> --salt <salt> [--secret-env <NAME>]
16
+ astl conformance [dir] [--update]
17
+ ```
18
+
19
+ For example, in npm scripts:
20
+
21
+ ```json
22
+ {
23
+ "scripts": {
24
+ "check:exercises": "astl validate exercises/*.html --locale en",
25
+ "build:lesson": "astl compile lesson.html --out public/lesson --key-out private/lesson.key.json --salt lesson-42"
26
+ }
27
+ }
28
+ ```
29
+
30
+ `compile` writes the public view to `--out` and the private answer key to `--key-out`, never inside `--out`. It
31
+ reads the secret, at least 16 bytes, from the environment variable `--secret-env` names (`ASTL_SECRET` by default).
32
+
33
+ ## This package or @astl/astrolabe
34
+
35
+ `@astl/astrolabe` does not include the CLI. Pick `@astl/devkit` to check exercises in CI, compile them at build time,
36
+ or run the conformance fixtures of components of your own.
37
+
38
+ Documentation: <https://astrolabe.starship.education/reference/cli/>
39
+
40
+ ## License
41
+
42
+ Apache-2.0, see [LICENSE](https://github.com/starship1337/astrolabe/blob/main/LICENSE).
package/dist/cli.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
package/dist/cli.js ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ import { main } from './main.js';
3
+ process.exitCode = await main(process.argv.slice(2));
4
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,CAAC,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC"}
@@ -0,0 +1,50 @@
1
+ import { type Engine, type GroupVerdict } from '@astl/core';
2
+ export declare const CONFORMANCE_SECRET = "astrolabe-conformance-secret";
3
+ export declare const CONFORMANCE_SALT = "fixture";
4
+ /** Files a fixture may hold. */
5
+ export declare const FIXTURE_FILES: readonly string[];
6
+ /** One grading case (`grading.json`): refs such as `g1`, `q1/a`, `page:p1`; a value `@q1/b` is the id of `q1/b`. */
7
+ export interface GradingCase {
8
+ readonly name: string;
9
+ readonly page?: string;
10
+ /** Element ref (`q1`) for a check of one interaction. */
11
+ readonly element?: string;
12
+ /** Hints used by element or page ref (`q1`, `page:p1`): their costs come off. */
13
+ readonly hintsUsed?: Readonly<Record<string, number>>;
14
+ readonly answers: Readonly<Record<string, unknown>>;
15
+ readonly expect: {
16
+ readonly score: number;
17
+ readonly max: number;
18
+ readonly correct: boolean;
19
+ readonly verdicts?: Readonly<Record<string, GroupVerdict>>;
20
+ };
21
+ }
22
+ export interface FixtureCheck {
23
+ /** Why the fixture does not conform; empty when it does. */
24
+ readonly failures: readonly string[];
25
+ /** Goldens to write (file name to content): missing ones, and with `update` the ones that differ. */
26
+ readonly goldens: Readonly<Record<string, string>>;
27
+ }
28
+ /**
29
+ * Checks one fixture against `engine` (which must be created with CONFORMANCE_SECRET). `name` is the folder name;
30
+ * `files` maps file names to contents.
31
+ */
32
+ export declare function checkFixture(name: string, files: ReadonlyMap<string, string>, engine: Engine, options?: {
33
+ readonly update?: boolean;
34
+ }): Promise<FixtureCheck>;
35
+ export interface FixtureOutcome extends FixtureCheck {
36
+ /** Folder path relative to the run's root, with `/` separators. */
37
+ readonly id: string;
38
+ /** Golden files written by this run. */
39
+ readonly written: readonly string[];
40
+ }
41
+ /**
42
+ * Folders under `root` that contain a `source.html`, sorted. Folders named node_modules or dist inside `root` are
43
+ * skipped; `root` itself may sit in node_modules, as the built-in fixtures do when the components come from npm.
44
+ */
45
+ export declare function findFixtures(root: string): Promise<string[]>;
46
+ /** Checks every fixture under `root` and writes the goldens it should (missing ones; with `update`, changed ones). */
47
+ export declare function runConformance(root: string, engine: Engine, options?: {
48
+ readonly update?: boolean;
49
+ }): Promise<FixtureOutcome[]>;
50
+ //# sourceMappingURL=conformance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conformance.d.ts","sourceRoot":"","sources":["../src/conformance.ts"],"names":[],"mappings":"AAWA,OAAO,EAGL,KAAK,MAAM,EAGX,KAAK,YAAY,EAGlB,MAAM,YAAY,CAAC;AAGpB,eAAO,MAAM,kBAAkB,iCAAiC,CAAC;AACjE,eAAO,MAAM,gBAAgB,YAAY,CAAC;AAE1C,gCAAgC;AAChC,eAAO,MAAM,aAAa,EAAE,SAAS,MAAM,EAO1C,CAAC;AAEF,oHAAoH;AACpH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,yDAAyD;IACzD,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,iFAAiF;IACjF,QAAQ,CAAC,SAAS,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAEtD,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACpD,QAAQ,CAAC,MAAM,EAAE;QACf,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;QACrB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;QAC1B,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC;KAC5D,CAAC;CACH;AAED,MAAM,WAAW,YAAY;IAC3B,4DAA4D;IAC5D,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,qGAAqG;IACrG,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACpD;AA0CD;;;GAGG;AACH,wBAAsB,YAAY,CAChC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,EAClC,MAAM,EAAE,MAAM,EACd,OAAO,GAAE;IAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAA;CAAO,GAC1C,OAAO,CAAC,YAAY,CAAC,CAsGvB;AAED,MAAM,WAAW,cAAe,SAAQ,YAAY;IAClD,mEAAmE;IACnE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,wCAAwC;IACxC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;CACrC;AAED;;;GAGG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAUlE;AAED,sHAAsH;AACtH,wBAAsB,cAAc,CAClC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,OAAO,GAAE;IAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAA;CAAO,GAC1C,OAAO,CAAC,cAAc,EAAE,CAAC,CA6B3B"}
@@ -0,0 +1,219 @@
1
+ /**
2
+ * Conformance fixtures on disk: the checks of the components conformance test (goldens, determinism, the engine's
3
+ * leak probe, grading cases and their coverage), for any folder of fixtures and any engine or port under test.
4
+ *
5
+ * A fixture folder holds `source.html` and `issues.json`; valid fixtures (names without `-invalid-`) also hold the
6
+ * goldens `view.html`, `key.json`, `meta.json` and the hand-written `grading.json`. Goldens are compiled with
7
+ * CONFORMANCE_SECRET and CONFORMANCE_SALT. `checkFixture` is pure; `runConformance` adds the file system.
8
+ */
9
+ import { readdir, readFile, writeFile } from 'node:fs/promises';
10
+ import { basename, dirname, join, relative, sep } from 'node:path';
11
+ import { isDeepStrictEqual } from 'node:util';
12
+ import { fitsAnswer, isOpaqueId, } from '@astl/core';
13
+ import { leakProbe, parseHtml, refResolver } from '@astl/engine';
14
+ export const CONFORMANCE_SECRET = 'astrolabe-conformance-secret';
15
+ export const CONFORMANCE_SALT = 'fixture';
16
+ /** Files a fixture may hold. */
17
+ export const FIXTURE_FILES = [
18
+ 'source.html',
19
+ 'issues.json',
20
+ 'view.html',
21
+ 'key.json',
22
+ 'meta.json',
23
+ 'grading.json',
24
+ ];
25
+ const json = (value) => `${JSON.stringify(value, null, 2)}\n`;
26
+ function sameJson(expected, actual) {
27
+ try {
28
+ return isDeepStrictEqual(JSON.parse(expected), JSON.parse(actual));
29
+ }
30
+ catch {
31
+ return false;
32
+ }
33
+ }
34
+ function opaqueIdsOnly(nodes) {
35
+ return nodes.every((n) => n.type === 'text' ||
36
+ ((n.attrs.id === undefined || isOpaqueId(n.attrs.id)) && opaqueIdsOnly(n.children)));
37
+ }
38
+ async function resolveAnswers(c, resolve, key) {
39
+ const answers = {};
40
+ let wellFormed = true;
41
+ for (const [ref, value] of Object.entries(c.answers)) {
42
+ const id = await resolve(ref);
43
+ // Open slots take longer answers than the other kinds (fitsAnswer).
44
+ const kind = Object.hasOwn(key.slots, id) ? key.slots[id]?.kind : undefined;
45
+ if (typeof value !== 'string' || !fitsAnswer(value, kind))
46
+ wellFormed = false;
47
+ answers[id] = typeof value === 'string' && value.startsWith('@') ? await resolve(value.slice(1)) : value;
48
+ }
49
+ const options = {};
50
+ if (c.page !== undefined)
51
+ options.page = await resolve(c.page);
52
+ if (c.element !== undefined)
53
+ options.element = await resolve(c.element);
54
+ if (c.hintsUsed !== undefined) {
55
+ const used = {};
56
+ for (const [ref, n] of Object.entries(c.hintsUsed))
57
+ used[await resolve(ref)] = n;
58
+ options.hintsUsed = used;
59
+ }
60
+ // Malformed answers are passed on as they are: the engine must count them as unanswered.
61
+ return { answers: answers, options, wellFormed };
62
+ }
63
+ /**
64
+ * Checks one fixture against `engine` (which must be created with CONFORMANCE_SECRET). `name` is the folder name;
65
+ * `files` maps file names to contents.
66
+ */
67
+ export async function checkFixture(name, files, engine, options = {}) {
68
+ const failures = [];
69
+ const goldens = {};
70
+ const golden = (file, actual, same) => {
71
+ const expected = files.get(file);
72
+ if (expected !== undefined && same(expected, actual))
73
+ return;
74
+ if (expected === undefined || options.update)
75
+ goldens[file] = actual;
76
+ else
77
+ failures.push(`${file} differs from the compiled output`);
78
+ };
79
+ const source = files.get('source.html');
80
+ if (source === undefined)
81
+ return { failures: ['source.html is missing'], goldens };
82
+ const valid = !name.includes('-invalid-');
83
+ const result = await engine.compile(source, { salt: CONFORMANCE_SALT });
84
+ const issues = result.issues.map((i) => ({ code: i.code, severity: i.severity, path: i.at.path }));
85
+ golden('issues.json', json(issues), sameJson);
86
+ if (result.ok !== valid) {
87
+ const codes = issues.filter((i) => i.severity === 'error').map((i) => i.code);
88
+ failures.push(valid ? `does not compile (${codes.join(', ')})` : 'compiles, but an -invalid- fixture must not');
89
+ }
90
+ if (!valid || !result.ok)
91
+ return { failures, goldens };
92
+ golden('view.html', result.view, (a, b) => a === b);
93
+ golden('key.json', json(result.key), sameJson);
94
+ golden('meta.json', json(result.metadata), sameJson);
95
+ const again = await engine.compile(source, { salt: CONFORMANCE_SALT });
96
+ if (!again.ok ||
97
+ again.view !== result.view ||
98
+ JSON.stringify(again.key) !== JSON.stringify(result.key) ||
99
+ JSON.stringify(again.metadata) !== JSON.stringify(result.metadata)) {
100
+ failures.push('compiling twice gives different output');
101
+ }
102
+ for (const leak of leakProbe(source, result.view, engine.manifests)) {
103
+ failures.push(`leak: <${leak.tag}${leak.element ? `#${leak.element}` : ''}> ${leak.kind} ${leak.detail}`);
104
+ }
105
+ if (!opaqueIdsOnly(parseHtml(result.view)))
106
+ failures.push('the view contains ids that are not opaque');
107
+ // Only components of `graded: false` types without open slots: no answers, so grading cases are optional. Open slots
108
+ // (stored for the teacher, never graded) are answers to enter all the same: they need cases, without point rules.
109
+ const scored = result.key.groups.length > 0;
110
+ const open = result.metadata.open;
111
+ const text = files.get('grading.json');
112
+ if (text === undefined) {
113
+ if (scored) {
114
+ failures.push('grading.json is missing: add cases for empty, all correct, all wrong and malformed answers');
115
+ }
116
+ else if (open.length > 0) {
117
+ failures.push('grading.json is missing: add an empty case and one that answers every open slot');
118
+ }
119
+ return { failures, goldens };
120
+ }
121
+ let cases;
122
+ try {
123
+ cases = JSON.parse(text);
124
+ }
125
+ catch {
126
+ failures.push('grading.json is not valid JSON');
127
+ return { failures, goldens };
128
+ }
129
+ const resolve = refResolver(CONFORMANCE_SECRET, CONFORMANCE_SALT);
130
+ const seen = [];
131
+ for (const c of cases) {
132
+ const { answers, options: gradeOptions, wellFormed } = await resolveAnswers(c, resolve, result.key);
133
+ const graded = engine.grade(result.key, answers, gradeOptions);
134
+ const { score, max, correct } = c.expect;
135
+ if (graded.score !== score || graded.max !== max || graded.correct !== correct) {
136
+ failures.push(`case "${c.name}": ${graded.score} of ${graded.max} (correct: ${graded.correct}), expected ${score} of ${max} (correct: ${correct})`);
137
+ }
138
+ for (const [ref, verdict] of Object.entries(c.expect.verdicts ?? {})) {
139
+ const id = await resolve(ref);
140
+ const actual = graded.groups.find((g) => g.id === id)?.verdict ?? 'missing';
141
+ if (actual !== verdict)
142
+ failures.push(`case "${c.name}": ${ref} is ${actual}, expected ${verdict}`);
143
+ }
144
+ const written = (id) => typeof answers[id] === 'string' && answers[id] !== '';
145
+ seen.push({
146
+ result: graded,
147
+ wellFormed,
148
+ answered: Object.keys(c.answers).length > 0,
149
+ open: open.length > 0 && open.every(written),
150
+ });
151
+ }
152
+ if (open.length > 0) {
153
+ if (!seen.some((s) => !s.answered))
154
+ failures.push('grading.json needs an empty case');
155
+ if (!seen.some((s) => s.open))
156
+ failures.push('grading.json needs a case that answers every open slot');
157
+ }
158
+ if (!scored)
159
+ return { failures, goldens };
160
+ const every = (r, verdict) => r.counts.total > 0 && r.counts[verdict] === r.counts.total;
161
+ const coverage = [
162
+ ['an empty case', seen.some((s) => !s.answered && every(s.result, 'empty'))],
163
+ ['an all-correct case', seen.some((s) => s.result.correct)],
164
+ ['an all-wrong case', seen.some((s) => every(s.result, 'incorrect'))],
165
+ ['a malformed case', seen.some((s) => !s.wellFormed)],
166
+ ];
167
+ for (const [what, covered] of coverage)
168
+ if (!covered)
169
+ failures.push(`grading.json needs ${what}`);
170
+ return { failures, goldens };
171
+ }
172
+ /**
173
+ * Folders under `root` that contain a `source.html`, sorted. Folders named node_modules or dist inside `root` are
174
+ * skipped; `root` itself may sit in node_modules, as the built-in fixtures do when the components come from npm.
175
+ */
176
+ export async function findFixtures(root) {
177
+ const entries = await readdir(root, { recursive: true, withFileTypes: true });
178
+ return entries
179
+ .filter((e) => e.isFile() && e.name === 'source.html')
180
+ .map((e) => e.parentPath)
181
+ .filter((dir) => {
182
+ const parts = relative(root, dir).split(sep);
183
+ return !parts.includes('node_modules') && !parts.includes('dist');
184
+ })
185
+ .sort();
186
+ }
187
+ /** Checks every fixture under `root` and writes the goldens it should (missing ones; with `update`, changed ones). */
188
+ export async function runConformance(root, engine, options = {}) {
189
+ const outcomes = [];
190
+ for (const dir of await findFixtures(root)) {
191
+ const files = new Map();
192
+ for (const file of FIXTURE_FILES) {
193
+ const content = await readFile(join(dir, file), 'utf8').catch(() => undefined);
194
+ if (content !== undefined)
195
+ files.set(file, content);
196
+ }
197
+ const name = basename(dir);
198
+ const check = await checkFixture(name, files, engine, options);
199
+ const failures = [...check.failures];
200
+ // `<type>/fixtures/<type>-<case>`, as in the built-in components.
201
+ const parent = dirname(dir);
202
+ if (basename(parent) === 'fixtures' && !name.startsWith(`${basename(dirname(parent))}-`)) {
203
+ failures.unshift(`the folder name must start with "${basename(dirname(parent))}-"`);
204
+ }
205
+ const written = [];
206
+ for (const [file, content] of Object.entries(check.goldens)) {
207
+ await writeFile(join(dir, file), content);
208
+ written.push(file);
209
+ }
210
+ outcomes.push({
211
+ id: relative(root, dir).split(sep).join('/'),
212
+ failures,
213
+ goldens: check.goldens,
214
+ written,
215
+ });
216
+ }
217
+ return outcomes;
218
+ }
219
+ //# sourceMappingURL=conformance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conformance.js","sourceRoot":"","sources":["../src/conformance.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAIL,UAAU,EAGV,UAAU,GAEX,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,SAAS,EAAE,SAAS,EAAoB,WAAW,EAAE,MAAM,cAAc,CAAC;AAEnF,MAAM,CAAC,MAAM,kBAAkB,GAAG,8BAA8B,CAAC;AACjE,MAAM,CAAC,MAAM,gBAAgB,GAAG,SAAS,CAAC;AAE1C,gCAAgC;AAChC,MAAM,CAAC,MAAM,aAAa,GAAsB;IAC9C,aAAa;IACb,aAAa;IACb,WAAW;IACX,UAAU;IACV,WAAW;IACX,cAAc;CACf,CAAC;AA2BF,MAAM,IAAI,GAAG,CAAC,KAAc,EAAU,EAAE,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC;AAE/E,SAAS,QAAQ,CAAC,QAAgB,EAAE,MAAc;IAChD,IAAI,CAAC;QACH,OAAO,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;IACrE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,SAAS,aAAa,CAAC,KAAsB;IAC3C,OAAO,KAAK,CAAC,KAAK,CAChB,CAAC,CAAC,EAAE,EAAE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AQ;YACR,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,OAAO;SACR,CAAC,CAAC;IACL,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -0,0 +1,6 @@
1
+ export type { FixtureCheck, FixtureOutcome, GradingCase } from './conformance.js';
2
+ export { CONFORMANCE_SALT, CONFORMANCE_SECRET, checkFixture, FIXTURE_FILES, findFixtures, runConformance, } from './conformance.js';
3
+ export type { Io } from './main.js';
4
+ export { builtInEngine, main, USAGE } from './main.js';
5
+ export { documentsIn } from './sources.js';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAClF,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,cAAc,GACf,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ export { CONFORMANCE_SALT, CONFORMANCE_SECRET, checkFixture, FIXTURE_FILES, findFixtures, runConformance, } from './conformance.js';
2
+ export { builtInEngine, main, USAGE } from './main.js';
3
+ export { documentsIn } from './sources.js';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,cAAc,GACf,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC"}
package/dist/main.d.ts ADDED
@@ -0,0 +1,16 @@
1
+ /**
2
+ * The `astl` commands. Issue messages come from the catalogs (`engine.describe` in the chosen UI locale); the rest of
3
+ * the output is for developers and stays English, like the problem titles of the grading protocol.
4
+ */
5
+ import type { Engine } from '@astl/core';
6
+ export interface Io {
7
+ readonly stdout: (text: string) => void;
8
+ readonly stderr: (text: string) => void;
9
+ readonly env: Readonly<Record<string, string | undefined>>;
10
+ }
11
+ export declare const USAGE = "Usage:\n astl validate <files...> [--json] [--locale <tag>]\n astl compile <file> --out <dir> --key-out <file> --salt <salt> [--secret-env <NAME>]\n astl conformance [dir] [--update]\n\nCommands:\n validate Check exercise sources, or HTML pages with <astl-doc> inside, and print their issues in the\n --locale UI language (default: from LC_ALL / LANG). Exits 1 when a document has errors.\n compile Compile one source. Public: <dir>/view.html and meta.json. Private: the answer key at --key-out,\n written with mode 0600 and refused inside <dir>. --salt (required, not empty, e.g. the exercise\n id) keeps ids unique per exercise. The secret comes from the environment variable named by\n --secret-env (default ASTL_SECRET), at least 16 bytes.\n conformance Check the fixture folders under [dir] (default: the built-in components' fixtures): goldens,\n determinism, the leak probe and grading cases. Missing goldens are written; --update rewrites\n the ones that differ.\n";
12
+ /** The built-in components and style templates, as the CLI registers them. */
13
+ export declare function builtInEngine(secret: string): Engine;
14
+ /** Runs one command; resolves to the exit code (0 ok, 1 problems found, 2 usage or configuration error). */
15
+ export declare function main(argv: readonly string[], io?: Io): Promise<number>;
16
+ //# sourceMappingURL=main.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,KAAK,EAAE,MAAM,EAAS,MAAM,YAAY,CAAC;AAMhD,MAAM,WAAW,EAAE;IACjB,QAAQ,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,QAAQ,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;CAC5D;AAQD,eAAO,MAAM,KAAK,qjCAejB,CAAC;AAEF,8EAA8E;AAC9E,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEpD;AAsKD,4GAA4G;AAC5G,wBAAsB,IAAI,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,EAAE,GAAE,EAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CA8CvF"}