@antelopejs/tooling-configs 0.5.0 → 0.5.2
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 +68 -31
- package/dist/bin/api-diff.mjs +3 -3
- package/dist/bin/body-check.mjs +2 -2
- package/dist/bin/checks.mjs +157 -7
- package/dist/bin/comment-proof.mjs +2 -2
- package/dist/bin/garden.mjs +7 -2
- package/dist/bin/lease.mjs +48 -11
- package/dist/bin/ratchet.mjs +2 -2
- package/dist/bin/suppressions.mjs +1 -1
- package/dist/bin/sync.mjs +200 -484
- package/dist/bin/verify.mjs +211 -54
- package/dist/oxc/anti-slop/index.mjs +106 -366
- package/dist/oxc/guardrails/index.d.mts +1 -1
- package/dist/oxc/guardrails/index.mjs +279 -10
- package/dist/oxc/lint.d.mts +6 -0
- package/dist/oxc/lint.mjs +4 -2
- package/dist/{oxlint-DIV-lLSS.mjs → oxlint-BbpTFFmf.mjs} +7 -2
- package/dist/{package-Dn7VTFUW.mjs → package-DxxcxOzp.mjs} +28 -2
- package/dist/{proof-stamp-DLWpPwQE.mjs → proof-stamp-D9yo2dxU.mjs} +1 -1
- package/dist/{ratchet-BTiPMqam.mjs → ratchet--WWa_w2O.mjs} +3 -2
- package/dist/script-steps-CgH2DSsp.mjs +594 -0
- package/dist/{templates-lJBZFskp.mjs → templates-BiXgdsRN.mjs} +1 -1
- package/dist/{typescript-BBbry7uU.mjs → typescript-D7SaSmsl.mjs} +1 -1
- package/dist/{ci-workflow-COJUT12b.mjs → workflow-B0FmthGv.mjs} +107 -107
- package/package.json +3 -2
package/dist/bin/verify.mjs
CHANGED
|
@@ -233,8 +233,8 @@ function parseScript(path, source) {
|
|
|
233
233
|
file: ts.createSourceFile("emit.js", outputText, ts.ScriptTarget.ES2022, true, ts.ScriptKind.JS)
|
|
234
234
|
};
|
|
235
235
|
}
|
|
236
|
-
function declaredNames(name) {
|
|
237
|
-
return ts.isIdentifier(name) ? [name.text] : name.elements.flatMap((element) => ts.isOmittedExpression(element) ? [] : declaredNames(element.name));
|
|
236
|
+
function declaredNames$1(name) {
|
|
237
|
+
return ts.isIdentifier(name) ? [name.text] : name.elements.flatMap((element) => ts.isOmittedExpression(element) ? [] : declaredNames$1(element.name));
|
|
238
238
|
}
|
|
239
239
|
function isFunctionDeclaration(statement) {
|
|
240
240
|
return ts.isFunctionDeclaration(statement) && Boolean(statement.body) && statement.name !== void 0;
|
|
@@ -243,7 +243,7 @@ function isFunctionDeclaration(statement) {
|
|
|
243
243
|
function localsOf(script, covered) {
|
|
244
244
|
const file = script.path.replace(MODULE_EXTENSION, "");
|
|
245
245
|
const names = script.file.statements.flatMap((statement) => {
|
|
246
|
-
if (ts.isVariableStatement(statement)) return statement.declarationList.declarations.flatMap((declaration) => declaredNames(declaration.name));
|
|
246
|
+
if (ts.isVariableStatement(statement)) return statement.declarationList.declarations.flatMap((declaration) => declaredNames$1(declaration.name));
|
|
247
247
|
return (ts.isClassDeclaration(statement) || ts.isEnumDeclaration(statement)) && statement.name ? [statement.name.text] : [];
|
|
248
248
|
});
|
|
249
249
|
const clashing = [...covered.functions.get(file) ?? []].filter((name) => covered.duplicated.has(name));
|
|
@@ -1754,6 +1754,8 @@ function ajsEntry(root) {
|
|
|
1754
1754
|
//#endregion
|
|
1755
1755
|
//#region src/verify/surface-types.ts
|
|
1756
1756
|
const NAMED = ts.SymbolFlags.Interface | ts.SymbolFlags.Class | ts.SymbolFlags.Enum | ts.SymbolFlags.TypeAlias;
|
|
1757
|
+
const MODULE = ts.SymbolFlags.ValueModule | ts.SymbolFlags.NamespaceModule;
|
|
1758
|
+
const INHERITING = ts.SymbolFlags.Class | ts.SymbolFlags.Interface;
|
|
1757
1759
|
function isObjectType$1(type) {
|
|
1758
1760
|
return (type.flags & ts.TypeFlags.Object) !== 0;
|
|
1759
1761
|
}
|
|
@@ -1769,72 +1771,212 @@ function publicPart(declaration) {
|
|
|
1769
1771
|
if (!ts.isClassDeclaration(declaration)) return declaration;
|
|
1770
1772
|
return ts.factory.updateClassDeclaration(declaration, declaration.modifiers, declaration.name, declaration.typeParameters, declaration.heritageClauses, declaration.members.filter(isPublicMember));
|
|
1771
1773
|
}
|
|
1772
|
-
/**
|
|
1774
|
+
/** Whether a heritage expression is a name such as `Base` or `ns.Base`, rather than a call. */
|
|
1775
|
+
function isEntityName(expression) {
|
|
1776
|
+
return ts.isIdentifier(expression) || ts.isPropertyAccessExpression(expression) && isEntityName(expression.expression);
|
|
1777
|
+
}
|
|
1778
|
+
/** The name a written type reference resolves through, when the node is one. */
|
|
1779
|
+
function referencedName(node) {
|
|
1780
|
+
if (ts.isTypeReferenceNode(node)) return node.typeName;
|
|
1781
|
+
if (ts.isExpressionWithTypeArguments(node) && isEntityName(node.expression)) return node.expression;
|
|
1782
|
+
if (ts.isTypeQueryNode(node)) return node.exprName;
|
|
1783
|
+
if (!ts.isImportTypeNode(node)) return void 0;
|
|
1784
|
+
if (node.qualifier) return node.qualifier;
|
|
1785
|
+
return ts.isLiteralTypeNode(node.argument) ? node.argument.literal : void 0;
|
|
1786
|
+
}
|
|
1787
|
+
/** Whether reading the declaration would read a whole module rather than one declaration. */
|
|
1788
|
+
function isModuleBody(declaration) {
|
|
1789
|
+
return ts.isSourceFile(declaration) || ts.isModuleDeclaration(declaration);
|
|
1790
|
+
}
|
|
1791
|
+
/**
|
|
1792
|
+
* Collects the package's declarations a function reaches. The written text of
|
|
1793
|
+
* every declaration it meets is read once, and each type reference in it is
|
|
1794
|
+
* resolved to its symbol without evaluating a type, so the walk is finite. The
|
|
1795
|
+
* root signatures' own types are walked once for what their text does not
|
|
1796
|
+
* write: a class instance a constructor answers and the type arguments they
|
|
1797
|
+
* were instantiated with.
|
|
1798
|
+
*/
|
|
1773
1799
|
var DeclarationWalk = class {
|
|
1774
1800
|
declarations = /* @__PURE__ */ new Map();
|
|
1801
|
+
reached = /* @__PURE__ */ new Set();
|
|
1802
|
+
read = /* @__PURE__ */ new Set();
|
|
1803
|
+
inherited = /* @__PURE__ */ new Set();
|
|
1775
1804
|
seen = /* @__PURE__ */ new Set();
|
|
1805
|
+
unread = [];
|
|
1806
|
+
types = [];
|
|
1776
1807
|
printer = ts.createPrinter({ removeComments: true });
|
|
1777
1808
|
checker;
|
|
1778
|
-
|
|
1779
|
-
constructor(checker,
|
|
1809
|
+
isLocalFile;
|
|
1810
|
+
constructor(checker, isLocalFile) {
|
|
1780
1811
|
this.checker = checker;
|
|
1781
|
-
this.
|
|
1812
|
+
this.isLocalFile = isLocalFile;
|
|
1782
1813
|
}
|
|
1783
1814
|
get found() {
|
|
1784
|
-
|
|
1815
|
+
for (;;) {
|
|
1816
|
+
const type = this.types.pop();
|
|
1817
|
+
if (type) {
|
|
1818
|
+
this.type(type);
|
|
1819
|
+
continue;
|
|
1820
|
+
}
|
|
1821
|
+
const symbol = this.unread.pop();
|
|
1822
|
+
if (!symbol) return [...this.declarations.values()];
|
|
1823
|
+
for (const declaration of this.local(symbol)) if (!isModuleBody(declaration)) this.references(declaration);
|
|
1824
|
+
}
|
|
1785
1825
|
}
|
|
1786
1826
|
signature(signature) {
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1827
|
+
this.types.push(...signature.getTypeParameters() ?? [], ...signature.getParameters().map((parameter) => this.checker.getTypeOfSymbol(parameter)), signature.getReturnType());
|
|
1828
|
+
}
|
|
1829
|
+
/** Reads what a symbol on the path to the signatures writes of their types: a class's or interface's heritage type arguments, any other symbol's declarations. */
|
|
1830
|
+
owner(symbol) {
|
|
1831
|
+
if (symbol.flags & INHERITING) this.inherit(symbol);
|
|
1832
|
+
else this.open(symbol);
|
|
1833
|
+
}
|
|
1834
|
+
/** The symbol's declarations in the package, leaving out what lib or a dependency declares of a symbol the package augments. */
|
|
1835
|
+
local(symbol) {
|
|
1836
|
+
return (symbol.declarations ?? []).filter((declaration) => this.isLocalFile(declaration.getSourceFile()));
|
|
1837
|
+
}
|
|
1838
|
+
isLocal(symbol) {
|
|
1839
|
+
return this.local(symbol).length > 0;
|
|
1840
|
+
}
|
|
1841
|
+
resolve(symbol) {
|
|
1842
|
+
return symbol.flags & ts.SymbolFlags.Alias ? this.checker.getAliasedSymbol(symbol) : symbol;
|
|
1790
1843
|
}
|
|
1791
1844
|
record(symbol) {
|
|
1792
|
-
if (
|
|
1793
|
-
const texts = (symbol
|
|
1845
|
+
if ((symbol.flags & NAMED) === 0) return;
|
|
1846
|
+
const texts = this.local(symbol).map((declaration) => this.printer.printNode(ts.EmitHint.Unspecified, publicPart(declaration), declaration.getSourceFile()).replace(/\s+/g, " ").replace(/^(?:export )?(?:declare )?/, ""));
|
|
1794
1847
|
this.declarations.set(symbol, texts.join(" "));
|
|
1795
|
-
for (const declaration of symbol.declarations ?? []) this.generics(declaration);
|
|
1796
1848
|
}
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
if (
|
|
1849
|
+
open(found) {
|
|
1850
|
+
const symbol = this.resolve(found);
|
|
1851
|
+
if (this.read.has(symbol) || !this.isLocal(symbol)) return;
|
|
1852
|
+
this.read.add(symbol);
|
|
1853
|
+
this.unread.push(symbol);
|
|
1854
|
+
}
|
|
1855
|
+
inherit(found) {
|
|
1856
|
+
const symbol = this.resolve(found);
|
|
1857
|
+
if (this.inherited.has(symbol) || !this.isLocal(symbol)) return;
|
|
1858
|
+
this.inherited.add(symbol);
|
|
1859
|
+
for (const declaration of this.local(symbol)) {
|
|
1860
|
+
if (!ts.isClassLike(declaration) && !ts.isInterfaceDeclaration(declaration)) continue;
|
|
1861
|
+
for (const clause of declaration.heritageClauses ?? []) for (const base of clause.types) {
|
|
1862
|
+
this.typeArguments(base);
|
|
1863
|
+
for (const owner of this.bases(base.expression)) this.owner(owner);
|
|
1864
|
+
}
|
|
1865
|
+
}
|
|
1866
|
+
}
|
|
1867
|
+
/** Reads the type arguments a heritage expression writes, including those inside a call such as `mix<A>(Base<B>)`. */
|
|
1868
|
+
typeArguments(node) {
|
|
1869
|
+
if (ts.isExpressionWithTypeArguments(node)) {
|
|
1870
|
+
for (const argument of node.typeArguments ?? []) this.references(argument);
|
|
1871
|
+
this.typeArguments(node.expression);
|
|
1872
|
+
} else if (ts.isTypeNode(node)) this.references(node);
|
|
1873
|
+
else ts.forEachChild(node, (child) => this.typeArguments(child));
|
|
1874
|
+
}
|
|
1875
|
+
/** Records the symbol when it names an interface, class, enum or alias of the package, and queues its declarations to be read, once. */
|
|
1876
|
+
reach(found) {
|
|
1877
|
+
const symbol = this.resolve(found);
|
|
1878
|
+
if (this.reached.has(symbol) || !this.isLocal(symbol)) return;
|
|
1879
|
+
this.reached.add(symbol);
|
|
1880
|
+
for (const declaration of symbol.declarations ?? []) {
|
|
1881
|
+
const owner = ts.isEnumMember(declaration) ? this.checker.getSymbolAtLocation(declaration.parent.name) : void 0;
|
|
1882
|
+
if (owner) this.reach(owner);
|
|
1883
|
+
}
|
|
1884
|
+
const assigned = symbol.exports?.get(ts.InternalSymbolName.ExportEquals);
|
|
1885
|
+
if (assigned) this.reach(assigned);
|
|
1886
|
+
if (symbol.flags & MODULE) for (const member of this.checker.getExportsOfModule(symbol)) {
|
|
1887
|
+
const value = this.resolve(member);
|
|
1888
|
+
if (value.flags & ts.SymbolFlags.Value) this.reach(value);
|
|
1889
|
+
}
|
|
1890
|
+
this.record(symbol);
|
|
1891
|
+
this.open(symbol);
|
|
1892
|
+
}
|
|
1893
|
+
/** The symbols a heritage expression names: the entity it is, or each name in a call such as `Mixin(Base)`. */
|
|
1894
|
+
bases(expression) {
|
|
1895
|
+
const symbol = ts.isIdentifier(expression) || ts.isPropertyAccessExpression(expression) ? this.checker.getSymbolAtLocation(expression) : void 0;
|
|
1896
|
+
if (symbol) return [symbol];
|
|
1897
|
+
const found = [];
|
|
1898
|
+
ts.forEachChild(expression, (child) => {
|
|
1899
|
+
if (!ts.isTypeNode(child)) found.push(...this.bases(child));
|
|
1900
|
+
});
|
|
1901
|
+
return found;
|
|
1800
1902
|
}
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1903
|
+
references(node) {
|
|
1904
|
+
const name = referencedName(node);
|
|
1905
|
+
const symbol = name && this.checker.getSymbolAtLocation(name);
|
|
1906
|
+
if (symbol) this.reach(symbol);
|
|
1907
|
+
if (ts.isExpressionWithTypeArguments(node) && !isEntityName(node.expression)) for (const base of this.bases(node.expression)) this.reach(base);
|
|
1908
|
+
ts.forEachChild(node, (child) => this.references(child));
|
|
1804
1909
|
}
|
|
1805
1910
|
type(type) {
|
|
1806
1911
|
if (this.seen.has(type)) return;
|
|
1807
1912
|
this.seen.add(type);
|
|
1913
|
+
if (type.aliasSymbol) {
|
|
1914
|
+
this.reach(type.aliasSymbol);
|
|
1915
|
+
this.types.push(...type.aliasTypeArguments ?? []);
|
|
1916
|
+
return;
|
|
1917
|
+
}
|
|
1808
1918
|
if (type.isUnionOrIntersection()) {
|
|
1809
|
-
|
|
1919
|
+
this.types.push(...type.types);
|
|
1810
1920
|
return;
|
|
1811
1921
|
}
|
|
1812
1922
|
if (type.flags & ts.TypeFlags.TypeParameter) {
|
|
1813
|
-
this.
|
|
1814
|
-
this.type(type.getDefault() ?? type);
|
|
1923
|
+
this.types.push(type.getConstraint() ?? type, type.getDefault() ?? type);
|
|
1815
1924
|
return;
|
|
1816
1925
|
}
|
|
1817
|
-
if (type
|
|
1818
|
-
for (const argument of type.aliasTypeArguments ?? []) this.type(argument);
|
|
1819
|
-
if (isObjectType$1(type) && isReference(type)) for (const argument of this.checker.getTypeArguments(type)) this.type(argument);
|
|
1926
|
+
if (isObjectType$1(type) && isReference(type)) this.types.push(...this.checker.getTypeArguments(type));
|
|
1820
1927
|
const symbol = type.getSymbol();
|
|
1821
|
-
if (symbol
|
|
1822
|
-
for (const declaration of symbol.declarations ?? []) {
|
|
1823
|
-
const owner = ts.isEnumMember(declaration) ? this.checker.getSymbolAtLocation(declaration.parent.name) : void 0;
|
|
1824
|
-
if (owner) this.record(owner);
|
|
1825
|
-
}
|
|
1826
|
-
this.record(symbol);
|
|
1827
|
-
this.members(type);
|
|
1928
|
+
if (symbol) this.reach(symbol);
|
|
1828
1929
|
}
|
|
1829
1930
|
};
|
|
1931
|
+
function declaredNames(statement) {
|
|
1932
|
+
if (ts.isVariableStatement(statement)) return statement.declarationList.declarations.map((declaration) => declaration.name);
|
|
1933
|
+
if (ts.isInterfaceDeclaration(statement) || ts.isClassDeclaration(statement) || ts.isFunctionDeclaration(statement) || ts.isTypeAliasDeclaration(statement) || ts.isEnumDeclaration(statement) || ts.isModuleDeclaration(statement)) return statement.name ? [statement.name] : [];
|
|
1934
|
+
return [];
|
|
1935
|
+
}
|
|
1936
|
+
function moduleStatements(statement) {
|
|
1937
|
+
const body = ts.isModuleDeclaration(statement) ? statement.body : void 0;
|
|
1938
|
+
if (body && ts.isModuleBlock(body)) return body.statements;
|
|
1939
|
+
return body && ts.isModuleDeclaration(body) ? [body] : [];
|
|
1940
|
+
}
|
|
1941
|
+
/** Whether a module file's statement opens a scope outside text can see: `declare global`, or `declare module` of a module that is not a package file. */
|
|
1942
|
+
function opensOutside(checker, statement, isLocalFile) {
|
|
1943
|
+
if (!ts.isModuleDeclaration(statement)) return false;
|
|
1944
|
+
if (statement.flags & ts.NodeFlags.GlobalAugmentation) return true;
|
|
1945
|
+
if (!ts.isStringLiteral(statement.name)) return false;
|
|
1946
|
+
return !(checker.getSymbolAtLocation(statement.name)?.declarations ?? []).some((declaration) => ts.isSourceFile(declaration) && isLocalFile(declaration));
|
|
1947
|
+
}
|
|
1948
|
+
/**
|
|
1949
|
+
* The symbols the package declares where text outside the package can name
|
|
1950
|
+
* them: in a script file, in `declare global`, or in `declare module` of a
|
|
1951
|
+
* module that is not a package file. These include every augmentation of a
|
|
1952
|
+
* lib or dependency symbol. Text outside the package reaches a declaration
|
|
1953
|
+
* of the package only through one of them, so every walk reaches them all.
|
|
1954
|
+
*/
|
|
1955
|
+
function outsideVisible(checker, files, isLocalFile) {
|
|
1956
|
+
const visible = /* @__PURE__ */ new Set();
|
|
1957
|
+
const pending = files.flatMap((file) => ts.isExternalModule(file) ? file.statements.filter((statement) => opensOutside(checker, statement, isLocalFile)).flatMap(moduleStatements) : [...file.statements]);
|
|
1958
|
+
for (let statement = pending.pop(); statement; statement = pending.pop()) {
|
|
1959
|
+
pending.push(...moduleStatements(statement));
|
|
1960
|
+
for (const name of declaredNames(statement)) {
|
|
1961
|
+
const symbol = checker.getSymbolAtLocation(name);
|
|
1962
|
+
if (symbol) visible.add(symbol);
|
|
1963
|
+
}
|
|
1964
|
+
}
|
|
1965
|
+
return [...visible];
|
|
1966
|
+
}
|
|
1830
1967
|
/**
|
|
1831
1968
|
* The declarations of the package that the signatures reach through their
|
|
1832
1969
|
* parameter and answer types, transitively, each printed without comments.
|
|
1833
|
-
*
|
|
1834
|
-
*
|
|
1970
|
+
* `path` holds the symbols the surface entered to find the signatures, the
|
|
1971
|
+
* last one owning them; their declarations write the type arguments the
|
|
1972
|
+
* signatures were instantiated with. `visible` holds the
|
|
1973
|
+
* package's symbols outside text can name, from {@link outsideVisible}. A change inside a reached declaration,
|
|
1974
|
+
* such as a member's type, changes the functions that reach it.
|
|
1835
1975
|
*/
|
|
1836
|
-
function referencedDeclarations(checker,
|
|
1837
|
-
const walk = new DeclarationWalk(checker,
|
|
1976
|
+
function referencedDeclarations(checker, isLocalFile, signatures, path, visible) {
|
|
1977
|
+
const walk = new DeclarationWalk(checker, isLocalFile);
|
|
1978
|
+
for (const symbol of visible) walk.reach(symbol);
|
|
1979
|
+
for (const symbol of path) walk.owner(symbol);
|
|
1838
1980
|
for (const signature of signatures) walk.signature(signature);
|
|
1839
1981
|
return walk.found.sort((left, right) => left.localeCompare(right));
|
|
1840
1982
|
}
|
|
@@ -1880,13 +2022,13 @@ function resolveAlias(walk, symbol) {
|
|
|
1880
2022
|
function signatureTexts(walk, signatures, kind) {
|
|
1881
2023
|
return signatures.map((signature) => walk.checker.signatureToString(signature, void 0, SIGNATURE_FLAGS, kind).replace(/\s+/g, " "));
|
|
1882
2024
|
}
|
|
1883
|
-
function callableText(walk, type) {
|
|
2025
|
+
function callableText(walk, type, path) {
|
|
1884
2026
|
const callable = walk.checker.getNonNullableType(type);
|
|
1885
2027
|
const calls = callable.getCallSignatures();
|
|
1886
2028
|
const constructs = callable.getConstructSignatures();
|
|
1887
2029
|
const texts = [...signatureTexts(walk, calls, ts.SignatureKind.Call), ...signatureTexts(walk, constructs, ts.SignatureKind.Construct)];
|
|
1888
2030
|
if (texts.length === 0) return void 0;
|
|
1889
|
-
const reached = referencedDeclarations(walk.checker, (
|
|
2031
|
+
const reached = referencedDeclarations(walk.checker, (file) => inPackage(walk, file.fileName), [...calls, ...constructs], path, walk.visible);
|
|
1890
2032
|
return reached.length === 0 ? texts.join(" | ") : `${texts.join(" | ")} where ${reached.join(" ")}`;
|
|
1891
2033
|
}
|
|
1892
2034
|
function typeOf(walk, symbol) {
|
|
@@ -1896,17 +2038,17 @@ function isPublic(property) {
|
|
|
1896
2038
|
const hidden = ts.ModifierFlags.Private | ts.ModifierFlags.Protected;
|
|
1897
2039
|
return (property.declarations ?? []).every((declaration) => (ts.getCombinedModifierFlags(declaration) & hidden) === 0);
|
|
1898
2040
|
}
|
|
1899
|
-
function recordMembers(walk, type, prefix, skip) {
|
|
2041
|
+
function recordMembers(walk, type, prefix, skip, owners) {
|
|
1900
2042
|
for (const property of walk.checker.getPropertiesOfType(type)) {
|
|
1901
2043
|
if (property.name === skip || !isPublic(property)) continue;
|
|
1902
2044
|
if (!declaredHere(walk, property)) continue;
|
|
1903
|
-
const text = callableText(walk, typeOf(walk, property));
|
|
2045
|
+
const text = callableText(walk, typeOf(walk, property), [...owners, property]);
|
|
1904
2046
|
if (text !== void 0) walk.surface.set(`${prefix}${property.name}`, text);
|
|
1905
2047
|
}
|
|
1906
2048
|
}
|
|
1907
|
-
function recordClass(walk, symbol, path) {
|
|
1908
|
-
recordMembers(walk, typeOf(walk, symbol), `${path}.`, "prototype");
|
|
1909
|
-
recordMembers(walk, walk.checker.getDeclaredTypeOfSymbol(symbol), `${path}.prototype.`, "");
|
|
2049
|
+
function recordClass(walk, symbol, path, owners) {
|
|
2050
|
+
recordMembers(walk, typeOf(walk, symbol), `${path}.`, "prototype", owners);
|
|
2051
|
+
recordMembers(walk, walk.checker.getDeclaredTypeOfSymbol(symbol), `${path}.prototype.`, "", owners);
|
|
1910
2052
|
}
|
|
1911
2053
|
function isObjectType(type) {
|
|
1912
2054
|
return (type.flags & ts.TypeFlags.Object) !== 0;
|
|
@@ -1920,14 +2062,14 @@ function visit(walk, exported, path, trail) {
|
|
|
1920
2062
|
if (trail.includes(symbol)) return;
|
|
1921
2063
|
const depth = path.split(":")[1]?.split(".").length ?? MAX_DEPTH;
|
|
1922
2064
|
const type = symbol.flags & ts.SymbolFlags.Value ? typeOf(walk, symbol) : void 0;
|
|
1923
|
-
const
|
|
2065
|
+
const next = [...trail, symbol];
|
|
2066
|
+
const text = type && callableText(walk, type, next);
|
|
1924
2067
|
if (text !== void 0) walk.surface.set(path, text);
|
|
1925
2068
|
if (symbol.flags & ts.SymbolFlags.Class && declaredHere(walk, symbol)) {
|
|
1926
|
-
recordClass(walk, symbol, path);
|
|
2069
|
+
recordClass(walk, symbol, path, next);
|
|
1927
2070
|
return;
|
|
1928
2071
|
}
|
|
1929
2072
|
if (depth >= MAX_DEPTH || !declaredHere(walk, symbol)) return;
|
|
1930
|
-
const next = [...trail, symbol];
|
|
1931
2073
|
if (symbol.flags & ts.SymbolFlags.Module) for (const member of walk.checker.getExportsOfModule(symbol)) visit(walk, member, `${path}.${member.name}`, next);
|
|
1932
2074
|
else if (type && text === void 0 && isObjectLiteralType(walk, type)) for (const member of walk.checker.getPropertiesOfType(type)) visit(walk, member, `${path}.${member.name}`, next);
|
|
1933
2075
|
}
|
|
@@ -1983,10 +2125,13 @@ function declaredSurface(packageFolder) {
|
|
|
1983
2125
|
types: ["node"]
|
|
1984
2126
|
}
|
|
1985
2127
|
});
|
|
2128
|
+
const checker = program.getTypeChecker();
|
|
2129
|
+
const local = (file) => inPackage({ folder }, file.fileName);
|
|
1986
2130
|
const walk = {
|
|
1987
|
-
checker
|
|
2131
|
+
checker,
|
|
1988
2132
|
folder,
|
|
1989
|
-
surface: /* @__PURE__ */ new Map()
|
|
2133
|
+
surface: /* @__PURE__ */ new Map(),
|
|
2134
|
+
visible: outsideVisible(checker, program.getSourceFiles().filter(local), local)
|
|
1990
2135
|
};
|
|
1991
2136
|
const missing = unresolvedImports(walk, program);
|
|
1992
2137
|
if (missing.length > 0) throw new Error(`unresolved imports in declarations: ${missing.join(", ")}${nodeTypes === void 0 && missing.some((entry) => entry.includes("-> node:")) ? "; install @types/node so node: built-ins resolve" : ""}`);
|
|
@@ -4801,7 +4946,8 @@ const USAGE = `Usage: antelopejs-verify <command>
|
|
|
4801
4946
|
formal <run> [--all] run the formal checks that cover the diff and gate them on changed behaviour
|
|
4802
4947
|
doors [patch] [--base <ref>] print the One-way-door line for a patch, or for the diff
|
|
4803
4948
|
clean <run> stop what the run started, keep only the evidence
|
|
4804
|
-
verdict <run> --pr <n>
|
|
4949
|
+
verdict <run> --pr <n> [--judgement <file>]
|
|
4950
|
+
store the judgement as evidence/judgement.json, then write evidence/verdict.md from it and the results
|
|
4805
4951
|
`;
|
|
4806
4952
|
function print(text) {
|
|
4807
4953
|
process.stdout.write(text.endsWith("\n") ? text : `${text}\n`);
|
|
@@ -4955,10 +5101,20 @@ function printDoors(workspace, files) {
|
|
|
4955
5101
|
for (const door of doors) print(` ${door.kind}: ${door.files.join(", ")}`);
|
|
4956
5102
|
return 0;
|
|
4957
5103
|
}
|
|
4958
|
-
function judge(workspace, dir, pr) {
|
|
4959
|
-
if (!Number.isInteger(pr) || pr <= 0) throw new Error("verdict needs --pr <number>");
|
|
5104
|
+
function judge(workspace, dir, pr, source) {
|
|
4960
5105
|
const state = loadRun(dir);
|
|
4961
|
-
|
|
5106
|
+
for (const output of [
|
|
5107
|
+
"verdict.md",
|
|
5108
|
+
"verdict.json",
|
|
5109
|
+
"plan.json"
|
|
5110
|
+
]) rmSync(join(state.evidence, output), { force: true });
|
|
5111
|
+
if (!Number.isInteger(pr) || pr <= 0) throw new Error("verdict needs --pr <number>");
|
|
5112
|
+
const stored = join(state.evidence, "judgement.json");
|
|
5113
|
+
if (source !== void 0) {
|
|
5114
|
+
readJudgement(source);
|
|
5115
|
+
writeFileSync(stored, readFileSync(source));
|
|
5116
|
+
}
|
|
5117
|
+
const verdict = renderVerdict(workspace, state, pr, readJudgement(stored));
|
|
4962
5118
|
print(verdict.markdown);
|
|
4963
5119
|
return verdict.result === "PASS" || verdict.result === "PASS+NOTES" ? 0 : 1;
|
|
4964
5120
|
}
|
|
@@ -4976,6 +5132,7 @@ async function main(argv) {
|
|
|
4976
5132
|
default: ""
|
|
4977
5133
|
},
|
|
4978
5134
|
pr: { type: "string" },
|
|
5135
|
+
judgement: { type: "string" },
|
|
4979
5136
|
all: { type: "boolean" },
|
|
4980
5137
|
kind: { type: "string" },
|
|
4981
5138
|
plan: { type: "boolean" },
|
|
@@ -5023,7 +5180,7 @@ async function main(argv) {
|
|
|
5023
5180
|
} else if (command === "formal") return runFormal(workspace, rest[0], values.all === true);
|
|
5024
5181
|
else if (command === "doors") return printDoors(workspace, rest[0] ? patchFiles(rest[0]) : planFor(workspace, values.base).changed);
|
|
5025
5182
|
else if (command === "clean") for (const line of clean(ownRun(workspace, rest[0]))) print(line);
|
|
5026
|
-
else if (command === "verdict") return judge(workspace, rest[0], Number(values.pr));
|
|
5183
|
+
else if (command === "verdict") return judge(workspace, rest[0], Number(values.pr), values.judgement);
|
|
5027
5184
|
else {
|
|
5028
5185
|
print(USAGE);
|
|
5029
5186
|
return 2;
|