Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 12 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,33 +22,30 @@
},
"dependencies": {
"axios": "^1.13.4",
"commander": "^8.0.0",
"debug": "^4.3.2",
"commander": "^14.0.3",
"debug": "^4.4.3",
"fastmatter": "^2.1.1",
"fs-extra": "^10.0.1",
"globby": "^11.0.4",
"jsonld": "^8.1.1",
"make-dir": "^3.1.0",
"jsonld": "^9.0.0",
"markdown-table": "2.0.0",
"moment": "^2.29.4",
"moment": "^2.30.1",
"outdent": "^0.8.0",
"rehype-stringify": "8.0.0",
"remark-frontmatter": "^3.0.0",
"remark-parse": "^9.0.0",
"remark-rehype": "8.1.0",
"rimraf": "^3.0.2",
"ts-node": "^10.1.0",
"typescript": "^4.3.5",
"rimraf": "^6.1.2",
"ts-node": "^10.9.2",
"typescript": "^5.9.3",
"unified": "^9.2.1"
},
"devDependencies": {
"@types/debug": "^4.1.7",
"@types/fs-extra": "^9.0.13",
"@types/debug": "^4.1.12",
"@types/jest": "^29.5.1",
"@types/js-yaml": "^4.0.2",
"@types/jsonld": "^1.5.8",
"@types/jsonld": "^1.5.15",
"@types/markdown-table": "2.0.0",
"@types/node": "^16.3.1",
"@types/node": "^25.2.0",
"@types/unist": "^2.0.6",
"@typescript-eslint/eslint-plugin": "^4.28.3",
"@typescript-eslint/parser": "^4.28.3",
Expand All @@ -57,7 +54,7 @@
"jest": "^29.5.0",
"lint-staged": "^11.0.1",
"pre-commit": "^1.2.2",
"prettier": "^2.3.2",
"prettier": "^3.8.1",
"ts-jest": "^29.1.0"
},
"jest": {
Expand All @@ -75,8 +72,7 @@
"lint-staged": {
"src/**/*.{js,ts,json}": [
"eslint --fix",
"prettier --write",
"git add"
"prettier --write"
]
},
"packageManager": "yarn@4.12.0"
Expand Down
12 changes: 6 additions & 6 deletions src/build-examples.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as path from "path";
import * as fs from "node:fs";
import * as path from "node:path";
import { createFile } from "./utils/create-file";
import { getRulePages } from "./utils/get-page-data";
import { copySync } from "fs-extra";
import {
extractTestCases,
TestCaseData,
Expand Down Expand Up @@ -35,7 +35,7 @@ export async function buildExamples({
ruleData,
baseUrl,
pageUrl,
proposed
proposed,
);
testCaseData.push(...extractedCases);
}
Expand All @@ -48,8 +48,8 @@ export async function buildExamples({
console.log(
`created ${testCaseData.length} test cases in ${path.resolve(
outDir,
"content/testcases/"
)}`
"content/testcases/",
)}`,
);

// Write testcases.json
Expand All @@ -60,7 +60,7 @@ export async function buildExamples({
// Copy test assets
if (testAssetsDir) {
const targetDir = path.resolve(assetsPath, "test-assets");
copySync(testAssetsDir, targetDir);
fs.copyFileSync(testAssetsDir, targetDir);
console.log(`Copied test assets to ${targetDir}`);
}
}
2 changes: 1 addition & 1 deletion src/build-examples/__tests__/extract-test-cases.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import outdent from "outdent";
import * as path from "path";
import * as path from "node:path";
import { getRulePages } from "../../utils/get-page-data";
import { extractTestCases } from "../extract-test-cases";

Expand Down
4 changes: 2 additions & 2 deletions src/build-examples/__tests__/update-test-cases-json.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as path from "path";
import { readFileSync } from "fs";
import * as path from "node:path";
import { readFileSync } from "node:fs";
import { RulePage, TestCaseJson, TestCase } from "../../types";
import { getRulePages } from "../../utils/get-page-data";
import { createFile } from "../../utils/create-file";
Expand Down
2 changes: 1 addition & 1 deletion src/build-examples/update-test-case-json.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { readFileSync } from "fs";
import { readFileSync } from "node:fs";
import { createFile } from "../utils/create-file";
import { TestCaseJson } from "../types";
import { TestCaseData } from "./extract-test-cases";
Expand Down
4 changes: 2 additions & 2 deletions src/implementations-update.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as fs from "fs";
import * as path from "path";
import * as fs from "node:fs";
import * as path from "node:path";
import * as yaml from "js-yaml";
import { getActImplementationReport } from "./map-implementation/get-act-implementation-report";
import { loadJson } from "./utils/load-json";
Expand Down
9 changes: 3 additions & 6 deletions src/map-implementation.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import fs from "fs";
import path from "path";
import { promisify } from "util";
import fs from "node:fs";
import path from "node:path";
import { getActImplementationReport } from "./map-implementation/get-act-implementation-report";
import { loadJson } from "./utils/load-json";
import { ImplementationBase, TestCaseJson } from "./map-implementation/types";

const writeFile = promisify(fs.writeFile);

export type CliArgs = ImplementationBase & {
jsonReport: string;
testCaseJson: string;
Expand Down Expand Up @@ -41,5 +38,5 @@ export async function cliProgram({

// Save the report
console.log(`Saved report to ${outputPath}`);
await writeFile(outputPath, fileContent, "utf8");
fs.writeFileSync(outputPath, fileContent, "utf8");
}
2 changes: 1 addition & 1 deletion src/map-implementation/earl/props/get-procedure-name.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import path from "path";
import path from "node:path";
import { EarlTest } from "../types";

export function procedureNameFromTest(
Expand Down
12 changes: 6 additions & 6 deletions src/rule-transform.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as path from "path";
import { pathExistsSync, readFileSync } from "fs-extra";
import * as fs from "node:fs";
import * as path from "node:path";
import { getRulePages, getDefinitionPages } from "./utils/get-page-data";
import { createFile } from "./utils";
import { getRuleContent } from "./rule-transform/get-rule-content";
Expand Down Expand Up @@ -47,7 +47,7 @@ function buildTfRuleFile(
ruleData: RulePage,
glossary: DefinitionPage[],
options: Record<string, boolean | undefined>,
rulesData: RulePage[]
rulesData: RulePage[],
) {
return {
filepath: ruleData.filename,
Expand All @@ -57,11 +57,11 @@ function buildTfRuleFile(

async function saveRuleFileIfChanged(
absolutePath: string,
newContent: string
newContent: string,
): Promise<void> {
let contentChanged = true;
if (pathExistsSync(absolutePath)) {
const currentContent = readFileSync(absolutePath, "utf8");
if (fs.existsSync(absolutePath)) {
const currentContent = fs.readFileSync(absolutePath, "utf8");
contentChanged = !isEqualExcludingDates(currentContent, newContent);
}

Expand Down
12 changes: 5 additions & 7 deletions src/rule-transform/__tests__/create-wcag-mapping.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import * as fs from "fs";
import { promisify } from "util";
import * as fs from "node:fs";
import * as path from "node:path";
import outdent from "outdent";
import { parsePage } from "../../utils/parse-page";
import { RulePage } from "../../types";
import { createFile, indent } from "../../utils/index";
import { createWcagMapping } from "../create-wcag-mapping";

const mkdir = promisify(fs.mkdir);
const rm = promisify(fs.rm);
const tmpDir = "./.tmp";
const tmpDir = path.join(".", ".tmp");
const mappingBase = {
successCriteria: [],
wcagTechniques: [],
Expand Down Expand Up @@ -39,12 +37,12 @@ describe("rule-transform", () => {
describe("updateWcagMapping", () => {
beforeEach(async () => {
if (!fs.existsSync(tmpDir)) {
await mkdir(tmpDir);
fs.mkdirSync(tmpDir, { recursive: true });
}
});

afterEach(async () => {
await rm(tmpDir, { recursive: true, force: true });
fs.rmSync(tmpDir, { recursive: true, force: true });
});

it("returns a WCAG mapping", async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/rule-transform/create-wcag-mapping.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as fs from "fs";
import * as fs from "node:fs";
import { createFile } from "../utils/create-file";
import { RulePage, RuleFrontMatter } from "../types";
import { getWcagCriterion } from "../act/get-accessibility-requirement";
Expand Down
12 changes: 5 additions & 7 deletions src/utils/__tests__/create-file.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
import * as fs from "fs";
import { promisify } from "util";
import * as fs from "node:fs";
import * as path from "node:path";
import { createFile } from "../create-file";

const mkdir = promisify(fs.mkdir);
const rm = promisify(fs.rm);
const tmpDir = "./.tmp-create-file";
const tmpDir = path.join(".", ".tmp-create-file");

describe("utils", () => {
describe("createFile", () => {
beforeEach(async () => {
if (!fs.existsSync(tmpDir)) {
await mkdir(tmpDir);
fs.mkdirSync(tmpDir, { recursive: true });
}
});

afterEach(async () => {
await rm(tmpDir, { recursive: true, force: true });
fs.rmSync(tmpDir, { recursive: true, force: true });
});

it("creates a new file at the specified path", async () => {
Expand Down
12 changes: 5 additions & 7 deletions src/utils/__tests__/get-page-data.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import * as fs from "fs";
import * as fs from "node:fs";
import * as path from "node:path";
import { outdent } from "outdent";
import { promisify } from "util";
import {
getRulePages,
getDefinitionPages,
getTestAssets,
} from "../get-page-data";

const mkdir = promisify(fs.mkdir);
const rm = promisify(fs.rm);
const tmpDir = "./.tmp-get-page-data";
const tmpDir = path.join(".", ".tmp-get-page-data");

describe("utils", () => {
const ruleText = outdent`
Expand All @@ -34,15 +32,15 @@ describe("utils", () => {

beforeEach(async () => {
if (!fs.existsSync(tmpDir)) {
await mkdir(tmpDir);
fs.mkdirSync(tmpDir, { recursive: true });
}
fs.writeFileSync(`${tmpDir}/abc123.md`, ruleText);
fs.writeFileSync(`${tmpDir}/dfn.md`, definitionText);
fs.writeFileSync(`${tmpDir}/hello.js`, testAssetText);
});

afterEach(async () => {
await rm(tmpDir, { recursive: true, force: true });
fs.rmSync(tmpDir, { recursive: true, force: true });
});

describe("getRulePages", () => {
Expand Down
11 changes: 4 additions & 7 deletions src/utils/create-file.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import * as fs from "fs";
import { promisify } from "util";
import { dirname as getDirName } from "path";
import makeDir from "make-dir";
import * as fs from "node:fs";
import { dirname as getDirName } from "node:path";

// Some stuff to simplify testing:
let isMocked = false;
let mockCalls: { path: string; content: string | unknown }[] = [];
const writeFile = promisify(fs.writeFile);

/**
* Create file with given contents at specified location
Expand All @@ -24,8 +21,8 @@ export const createFile = async (
typeof content !== "string" ? JSON.stringify(content, null, 2) : content;

const dirname = getDirName(path);
await makeDir(dirname);
await writeFile(path, stringData);
fs.mkdirSync(dirname, { recursive: true });
fs.writeFileSync(path, stringData);
};

createFile.mock = () => {
Expand Down
4 changes: 2 additions & 2 deletions src/utils/get-page-data.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as fs from "fs";
import * as path from "path";
import * as fs from "node:fs";
import * as path from "node:path";
import assert from "assert";
import globby from "globby";
import { parsePage, isParent } from "./parse-page";
Expand Down
Loading