@sybelblue/prairielearn-navigator 1.1.2 → 1.2.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/README.md +12 -0
- package/dist/cli.js +8 -0
- package/dist/index.js +1 -1
- package/dist/shared.js +1 -0
- package/package.json +6 -3
- package/dist/cli.cjs +0 -8
- package/dist/core/config.d.ts +0 -80
- package/dist/core/course.d.ts +0 -7
- package/dist/core/courseFiles.d.ts +0 -14
- package/dist/core/diagnostic.d.ts +0 -36
- package/dist/core/html.d.ts +0 -20
- package/dist/core/json.d.ts +0 -32
- package/dist/core/plVersion.d.ts +0 -23
- package/dist/core/questionDirs.d.ts +0 -13
- package/dist/core/questionPaths.d.ts +0 -10
- package/dist/core/referenceIndex.d.ts +0 -71
- package/dist/core/references/bases.d.ts +0 -13
- package/dist/core/references/extract.d.ts +0 -34
- package/dist/core/references/specs.d.ts +0 -272
- package/dist/core/rules/impls.d.ts +0 -18
- package/dist/core/rules/registry.d.ts +0 -32
- package/dist/core/rules/run.d.ts +0 -25
- package/dist/core/rules/types.d.ts +0 -35
- package/dist/core/schemas.d.ts +0 -51
- package/dist/library.d.ts +0 -1
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { RefRuleId } from "../references/specs";
|
|
2
|
-
import { RuleEntry } from "./types";
|
|
3
|
-
/**
|
|
4
|
-
* Rules that are not about file references, by id. Each entry is
|
|
5
|
-
* `[plVersionRange, courseRelativeGlob, impl]`, and for a given file the
|
|
6
|
-
* first entry whose range and glob both match is the one that runs.
|
|
7
|
-
*
|
|
8
|
-
* To change a rule for newer PL versions, add an entry with a narrower
|
|
9
|
-
* range above the existing one, e.g.
|
|
10
|
-
* [">=2026-01-01", courseFiles.question, newImpl],
|
|
11
|
-
* ["*", courseFiles.question, oldImpl],
|
|
12
|
-
*/
|
|
13
|
-
declare const otherRules: {
|
|
14
|
-
readonly "json-syntax": (readonly ["*", "infoCourse.json" | "courseInstances/**/infoCourseInstance.json" | "courseInstances/**/assessments/**/infoAssessment.json" | "questions/**/info.json" | "elements/*/info.json" | "elementExtensions/*/*/info.json", import("./types").RuleImpl])[];
|
|
15
|
-
readonly schema: readonly [readonly ["*", "infoCourse.json", import("./types").RuleImpl], readonly ["*", "courseInstances/**/infoCourseInstance.json", import("./types").RuleImpl], readonly ["*", "courseInstances/**/assessments/**/infoAssessment.json", import("./types").RuleImpl], readonly ["*", "questions/**/info.json", import("./types").RuleImpl], readonly ["*", "elements/*/info.json", import("./types").RuleImpl], readonly ["*", "elementExtensions/*/*/info.json", import("./types").RuleImpl]];
|
|
16
|
-
readonly "duplicate-question-id": readonly [readonly ["*", "courseInstances/**/assessments/**/infoAssessment.json", import("./types").RuleImpl]];
|
|
17
|
-
readonly "unused-question": readonly [readonly ["*", "questions/**/info.json", import("./types").RuleImpl]];
|
|
18
|
-
readonly "unused-tag": readonly [readonly ["*", "infoCourse.json", import("./types").RuleImpl]];
|
|
19
|
-
readonly "unused-assessment-set": readonly [readonly ["*", "infoCourse.json", import("./types").RuleImpl]];
|
|
20
|
-
readonly "question-info-missing": readonly [];
|
|
21
|
-
};
|
|
22
|
-
/**
|
|
23
|
-
* Every validation rule, by id. Ids appear in diagnostic codes as
|
|
24
|
-
* `prairielearn-navigator/<id>` and are the keys of the `rules` setting.
|
|
25
|
-
*/
|
|
26
|
-
export declare const rules: Record<RuleId, readonly RuleEntry[]>;
|
|
27
|
-
export type RuleId = keyof typeof otherRules | RefRuleId;
|
|
28
|
-
/** Rules that read the reference index; without one they report nothing. */
|
|
29
|
-
export declare const indexedRules: readonly RuleId[];
|
|
30
|
-
export declare function isRuleId(id: string): id is RuleId;
|
|
31
|
-
export declare function ruleDiagnosticCode(id: RuleId): string;
|
|
32
|
-
export {};
|
package/dist/core/rules/run.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { NavigatorConfig } from "../config";
|
|
2
|
-
import { Diagnostic } from "../diagnostic";
|
|
3
|
-
import { IsoDate } from "../plVersion";
|
|
4
|
-
import { ReferenceIndex } from "../referenceIndex";
|
|
5
|
-
import { SchemaStore } from "../schemas";
|
|
6
|
-
import { RuleId } from "./registry";
|
|
7
|
-
import { RuleImpl, RuleTable } from "./types";
|
|
8
|
-
/** The implementation of each rule that applies to `relPath` at `plDate`. */
|
|
9
|
-
export declare function selectRules<Id extends string = RuleId>(relPath: string, plDate: IsoDate, table?: RuleTable): [Id, RuleImpl][];
|
|
10
|
-
/** Globs, relative to a course root, of every file some rule applies to. */
|
|
11
|
-
export declare function checkableGlobs(): string[];
|
|
12
|
-
/** Whether any rule applies to this course-relative path, at any version. */
|
|
13
|
-
export declare function isCheckable(relPath: string): boolean;
|
|
14
|
-
/** Runs every applicable, enabled rule on one file of a course. */
|
|
15
|
-
export declare function runRules(filePath: string, text: string, options: {
|
|
16
|
-
courseRoot: string;
|
|
17
|
-
config: NavigatorConfig;
|
|
18
|
-
schemas: SchemaStore;
|
|
19
|
-
references?: ReferenceIndex;
|
|
20
|
-
}): Promise<Diagnostic[]>;
|
|
21
|
-
/**
|
|
22
|
-
* Runs the rules that look at a course as a whole rather than one file.
|
|
23
|
-
* Returns diagnostics by the absolute path of the file each is shown on.
|
|
24
|
-
*/
|
|
25
|
-
export declare function runCourseRules(courseRoot: string, config: NavigatorConfig): Map<string, Diagnostic[]>;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { Diagnostic } from "../diagnostic";
|
|
2
|
-
import { JsonDoc } from "../json";
|
|
3
|
-
import { IsoDate, PlVersion, VersionRange } from "../plVersion";
|
|
4
|
-
import { ReferenceIndex } from "../referenceIndex";
|
|
5
|
-
import { SchemaStore } from "../schemas";
|
|
6
|
-
/** Everything a rule may inspect about the file being checked. */
|
|
7
|
-
export interface RuleContext {
|
|
8
|
-
courseRoot: string;
|
|
9
|
-
filePath: string;
|
|
10
|
-
/** Posix path relative to the course root, as matched by rule globs. */
|
|
11
|
-
relPath: string;
|
|
12
|
-
text: string;
|
|
13
|
-
doc: JsonDoc;
|
|
14
|
-
plVersion: PlVersion;
|
|
15
|
-
/** The date `plVersion` stands for, used to select version-ranged rules. */
|
|
16
|
-
plDate: IsoDate;
|
|
17
|
-
schemas: SchemaStore;
|
|
18
|
-
/**
|
|
19
|
-
* The course's reference index, when the caller has built one; cross-file
|
|
20
|
-
* rules report nothing without it.
|
|
21
|
-
*/
|
|
22
|
-
references?: ReferenceIndex;
|
|
23
|
-
}
|
|
24
|
-
export type RuleImpl = (ctx: RuleContext) => Diagnostic[] | Promise<Diagnostic[]>;
|
|
25
|
-
/**
|
|
26
|
-
* One implementation of a rule for PL versions in `range` and files matching
|
|
27
|
-
* `files` (a glob relative to the course root).
|
|
28
|
-
*/
|
|
29
|
-
export type RuleEntry = readonly [range: VersionRange, files: string, impl: RuleImpl];
|
|
30
|
-
/**
|
|
31
|
-
* Rule id -> ordered entries. For each rule, the first entry whose range and
|
|
32
|
-
* glob both match the file is the one that runs; put newer-version entries
|
|
33
|
-
* above older ones.
|
|
34
|
-
*/
|
|
35
|
-
export type RuleTable = Record<string, readonly RuleEntry[]>;
|
package/dist/core/schemas.d.ts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { ValidateFunction } from "ajv";
|
|
2
|
-
import { PlVersion } from "./plVersion";
|
|
3
|
-
export type SchemaName = "infoCourse" | "infoCourseInstance" | "infoAssessment" | "infoQuestion" | "infoElementCourse" | "infoElementExtension";
|
|
4
|
-
export interface LoadedSchema {
|
|
5
|
-
validate: ValidateFunction;
|
|
6
|
-
label: string;
|
|
7
|
-
}
|
|
8
|
-
type Fetch = (url: string, init?: {
|
|
9
|
-
headers?: Record<string, string>;
|
|
10
|
-
}) => Promise<{
|
|
11
|
-
ok: boolean;
|
|
12
|
-
status: number;
|
|
13
|
-
text(): Promise<string>;
|
|
14
|
-
json(): Promise<unknown>;
|
|
15
|
-
}>;
|
|
16
|
-
export interface SchemaStoreOptions {
|
|
17
|
-
cacheDir: string;
|
|
18
|
-
/** Injected for tests; defaults to the global fetch. */
|
|
19
|
-
fetch?: Fetch;
|
|
20
|
-
/** Raises the GitHub API rate limit for date versions. */
|
|
21
|
-
githubToken?: string;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Fetches PrairieLearn's JSON schemas for a given PL version and caches them
|
|
25
|
-
* on disk as `<cacheDir>/<sha | master-YYYY-MM-DD>/<name>.json`.
|
|
26
|
-
*
|
|
27
|
-
* Failures never throw: `get` resolves to undefined and the reason is
|
|
28
|
-
* recorded once in `problems`, so callers can report it a single time.
|
|
29
|
-
*/
|
|
30
|
-
export declare class SchemaStore {
|
|
31
|
-
private readonly options;
|
|
32
|
-
readonly problems: Set<string>;
|
|
33
|
-
private readonly fetch;
|
|
34
|
-
private readonly loading;
|
|
35
|
-
private readonly resolving;
|
|
36
|
-
constructor(options: SchemaStoreOptions);
|
|
37
|
-
get cacheDir(): string;
|
|
38
|
-
get(name: SchemaName, version: PlVersion): Promise<LoadedSchema | undefined>;
|
|
39
|
-
private load;
|
|
40
|
-
private resolve;
|
|
41
|
-
private resolveUncached;
|
|
42
|
-
/** Last commit on master at or before the end of `date` (UTC). */
|
|
43
|
-
private lookupSha;
|
|
44
|
-
private schemaText;
|
|
45
|
-
private writeCache;
|
|
46
|
-
private pruneStaleLatest;
|
|
47
|
-
private get refsFile();
|
|
48
|
-
private readRefs;
|
|
49
|
-
private writeRefs;
|
|
50
|
-
}
|
|
51
|
-
export {};
|
package/dist/library.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { createQuestionFileResolver, type QuestionFileDescriptor, type QuestionFileProvenance, type QuestionFileResolution, type QuestionFileResolutionUpdate, type QuestionFileResolver, type QuestionFileResolverOptions, type ResolvedQuestionFile, } from "./core/questionFileResolver";
|