tessera-learn 0.2.2 → 0.2.3

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.
@@ -1,5 +1,5 @@
1
1
  import { spawn, type SpawnOptions } from 'node:child_process';
2
- import { existsSync, readFileSync, writeFileSync } from 'node:fs';
2
+ import { readFileSync, writeFileSync } from 'node:fs';
3
3
  import { createRequire } from 'node:module';
4
4
  import { dirname, resolve } from 'node:path';
5
5
  import { generateManifest, readCourseConfig } from '../manifest.js';
@@ -8,8 +8,6 @@ import { normalizeA11y, type A11ySettings } from '../validation.js';
8
8
  export interface AuditOptions {
9
9
  /** Minimum violation impact that fails the run (CI gate). Default 'serious'. */
10
10
  threshold?: ImpactLevel;
11
- /** Force a fresh `vite build` even if dist/ exists. */
12
- rebuild?: boolean;
13
11
  }
14
12
 
15
13
  export type ImpactLevel = 'minor' | 'moderate' | 'serious' | 'critical';
@@ -378,7 +376,6 @@ export async function runAudit(
378
376
 
379
377
  // A throwaway web build, kept out of dist/ so a real LMS export is untouched.
380
378
  const auditDist = resolve(projectRoot, 'node_modules', '.tessera-a11y');
381
- const distHtml = resolve(auditDist, 'index.html');
382
379
 
383
380
  const prevEnv = process.env[AUDIT_ENV_FLAG];
384
381
  process.env[AUDIT_ENV_FLAG] = '1';
@@ -386,15 +383,13 @@ export async function runAudit(
386
383
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
387
384
  let server: any;
388
385
  try {
389
- if (options.rebuild || !existsSync(distHtml)) {
390
- console.log('[tessera a11y] Building course…');
391
- await vite.build(
392
- vite.mergeConfig(auditBaseConfig, {
393
- build: { outDir: auditDist, emptyOutDir: true },
394
- logLevel: 'warn',
395
- }),
396
- );
397
- }
386
+ console.log('[tessera a11y] Building course…');
387
+ await vite.build(
388
+ vite.mergeConfig(auditBaseConfig, {
389
+ build: { outDir: auditDist, emptyOutDir: true },
390
+ logLevel: 'warn',
391
+ }),
392
+ );
398
393
 
399
394
  server = await vite.preview({
400
395
  root: projectRoot,
@@ -13,7 +13,6 @@ export type ParsedA11yArgs =
13
13
 
14
14
  export function parseA11yArgs(argv: string[]): ParsedA11yArgs {
15
15
  let threshold: ImpactLevel | undefined;
16
- let rebuild = false;
17
16
 
18
17
  for (let i = 0; i < argv.length; i++) {
19
18
  const arg = argv[i];
@@ -26,14 +25,12 @@ export function parseA11yArgs(argv: string[]): ParsedA11yArgs {
26
25
  };
27
26
  }
28
27
  threshold = value;
29
- } else if (arg === '--build') {
30
- rebuild = true;
31
28
  } else {
32
29
  return { ok: false, error: `Unknown argument: ${arg}` };
33
30
  }
34
31
  }
35
32
 
36
- const args: AuditOptions = { rebuild };
33
+ const args: AuditOptions = {};
37
34
  if (threshold !== undefined) args.threshold = threshold;
38
35
  return { ok: true, args };
39
36
  }
package/src/plugin/cli.ts CHANGED
@@ -19,8 +19,7 @@ Commands:
19
19
  Run a command from inside a course folder, or name the course explicitly.
20
20
 
21
21
  a11y/check options:
22
- --threshold <minor|moderate|serious|critical> Failing impact (default: serious)
23
- --build Force a fresh build first`;
22
+ --threshold <minor|moderate|serious|critical> Failing impact (default: serious)`;
24
23
 
25
24
  // The course is a leading positional: `tessera <cmd> [course] [flags]`. Only the
26
25
  // first token can be the course, and only when it isn't a flag — otherwise a flag
@@ -74,7 +73,7 @@ export async function main(
74
73
  case 'validate':
75
74
  return runValidate(courseRoot);
76
75
  case 'check': {
77
- const validateCode = runValidate(courseRoot);
76
+ const validateCode = runValidate(courseRoot, { showA11yTip: false });
78
77
  if (validateCode !== 0) return validateCode;
79
78
  return runA11y(courseRoot, workspaceRoot, flags);
80
79
  }
@@ -1,6 +1,10 @@
1
+ import { basename } from 'node:path';
1
2
  import { validateProject, reportValidationIssues } from './validation.js';
2
3
 
3
- export function runValidate(projectRoot: string): number {
4
+ export function runValidate(
5
+ projectRoot: string,
6
+ { showA11yTip = true }: { showA11yTip?: boolean } = {},
7
+ ): number {
4
8
  const { errors, warnings } = validateProject(projectRoot);
5
9
 
6
10
  reportValidationIssues({ errors, warnings });
@@ -23,8 +27,10 @@ export function runValidate(projectRoot: string): number {
23
27
  '\x1b[32m[tessera]\x1b[0m Validation passed — no issues found.',
24
28
  );
25
29
  }
26
- console.log(
27
- '\x1b[2m[tessera] Static checks only. For a full runtime accessibility audit, run: pnpm exec tessera a11y\x1b[0m',
28
- );
30
+ if (showA11yTip) {
31
+ console.log(
32
+ `\x1b[2m[tessera] Static checks only. For a full runtime accessibility audit, run: pnpm a11y ${basename(projectRoot)}\x1b[0m`,
33
+ );
34
+ }
29
35
  return 0;
30
36
  }