import fs from 'fs'; import { resolve } from 'path'; import assert from 'assert'; import { unified } from 'unified'; import remarkParse from 'remark-parse'; const source = resolve(process.argv[2]); const skipDeprecationComment = /^$/; const generateDeprecationCode = (codeAsNumber) => `DEP${codeAsNumber.toString().padStart(4, '0')}`; const addMarkdownPathToErrorStack = (error, node) => { const { line, column } = node.position.start; const [header, ...lines] = error.stack.split('\n'); error.stack = header + `\n at (${source}:${line}:${column})\n` + lines.join('\n'); return error; }; const testHeading = (headingNode, expectedDeprecationCode) => { try { assert.strictEqual( headingNode?.children[0]?.value.substring(0, 9), `${expectedDeprecationCode}: `, 'Ill-formed or out-of-order deprecation code.', ); } catch (e) { throw addMarkdownPathToErrorStack(e, headingNode); } }; const testYAMLComment = (commentNode) => { try { assert.match( commentNode?.value?.substring(0, 21), /^