@definitelytyped/definitions-parser
Advanced tools
Comparing version 0.1.5 to 0.1.6
@@ -19,2 +19,3 @@ @apollo/client | ||
@emotion/styled | ||
@floating-ui/react | ||
@glimmer/component | ||
@@ -21,0 +22,0 @@ @glimmer/manager |
# @definitelytyped/definitions-parser | ||
## 0.1.6 | ||
### Patch Changes | ||
- 9da3fc7: Detect package names added/removed from attw.json as changed | ||
- Updated dependencies [31de5d3] | ||
- Updated dependencies [9da3fc7] | ||
- @definitelytyped/utils@0.1.2 | ||
- @definitelytyped/header-parser@0.2.3 | ||
## 0.1.5 | ||
@@ -4,0 +14,0 @@ |
@@ -5,2 +5,3 @@ import { AllPackages, PackageId } from "./packages"; | ||
readonly dependents: Set<string>; | ||
readonly attwChanges: Set<string>; | ||
} | ||
@@ -11,4 +12,5 @@ /** Gets all packages that have changed on this branch, plus all packages affected by the change. */ | ||
additions: PackageId[]; | ||
attwChanges: PackageId[]; | ||
}, definitelyTypedPath: string, diffBase: string): Promise<PreparePackagesResult>; | ||
/** This function is exported for testing, since it's determined entirely by its inputs. */ | ||
export declare function getAffectedPackagesWorker(allPackages: AllPackages, changedOutput: string, additions: string[], dependentOutputs: string[], definitelyTypedPath: string): Promise<PreparePackagesResult>; | ||
export declare function getAffectedPackagesWorker(allPackages: AllPackages, changedOutput: string, additions: string[], attwChangedPackages: PackageId[], dependentOutputs: string[], definitelyTypedPath: string): Promise<PreparePackagesResult>; |
@@ -43,7 +43,7 @@ "use strict"; | ||
} | ||
return getAffectedPackagesWorker(allPackages, changedPackageDirectories, addedPackageDirectories, allDependentDirectories, definitelyTypedPath); | ||
return getAffectedPackagesWorker(allPackages, changedPackageDirectories, addedPackageDirectories, git.attwChanges, allDependentDirectories, definitelyTypedPath); | ||
} | ||
exports.getAffectedPackages = getAffectedPackages; | ||
/** This function is exported for testing, since it's determined entirely by its inputs. */ | ||
async function getAffectedPackagesWorker(allPackages, changedOutput, additions, dependentOutputs, definitelyTypedPath) { | ||
async function getAffectedPackagesWorker(allPackages, changedOutput, additions, attwChangedPackages, dependentOutputs, definitelyTypedPath) { | ||
const dt = (0, path_1.resolve)(definitelyTypedPath); | ||
@@ -57,3 +57,8 @@ const changedDirs = (0, utils_1.mapDefined)(changedOutput.split("\n"), getDirectoryName(dt)); | ||
const dependents = new Set((await Promise.all(dependentDirs.map(tryGetTypingsData))).filter((d) => !!d && !packageNames.has(d))); | ||
return { packageNames, dependents }; | ||
const attwChanges = new Set((await Promise.all(attwChangedPackages.map(async (id) => (await allPackages.tryGetTypingsData(id))?.subDirectoryPath))).filter((d) => !!d && !packageNames.has(d) && !dependents.has(d))); | ||
return { | ||
packageNames, | ||
dependents, | ||
attwChanges, | ||
}; | ||
async function tryGetTypingsData(d) { | ||
@@ -60,0 +65,0 @@ const dep = (0, packages_1.getDependencyFromFile)((0, utils_1.normalizeSlashes)(d + "/index.d.ts")); |
@@ -1,4 +0,4 @@ | ||
import { PackageId, AllPackages, NotNeededPackage } from "./packages"; | ||
import { Logger } from "@definitelytyped/utils"; | ||
import { PreparePackagesResult } from "./get-affected-packages"; | ||
import { AllPackages, NotNeededPackage, PackageId } from "./packages"; | ||
export type GitDiff = { | ||
@@ -17,3 +17,10 @@ status: "A" | "D" | "M"; | ||
*/ | ||
export declare function gitChanges(diffs: GitDiff[]): { | ||
export declare function gitChanges(diffs: GitDiff[], getAttwJson: () => Promise<{ | ||
base: { | ||
failingPackages: string[]; | ||
}; | ||
head: { | ||
failingPackages: string[]; | ||
}; | ||
}>): Promise<{ | ||
errors: string[]; | ||
@@ -23,3 +30,4 @@ } | { | ||
additions: PackageId[]; | ||
}; | ||
attwChanges: PackageId[]; | ||
}>; | ||
export declare function getAffectedPackagesFromDiff(allPackages: AllPackages, definitelyTypedPath: string, diffBase: string): Promise<string[] | PreparePackagesResult>; | ||
@@ -26,0 +34,0 @@ /** |
@@ -27,3 +27,2 @@ "use strict"; | ||
exports.getNotNeededPackages = exports.checkNotNeededPackage = exports.getAffectedPackagesFromDiff = exports.gitChanges = exports.gitDiff = void 0; | ||
const packages_1 = require("./packages"); | ||
const utils_1 = require("@definitelytyped/utils"); | ||
@@ -34,2 +33,5 @@ const pacote = __importStar(require("pacote")); | ||
const get_affected_packages_1 = require("./get-affected-packages"); | ||
const definition_parser_1 = require("./lib/definition-parser"); | ||
const packages_1 = require("./packages"); | ||
const promises_1 = require("fs/promises"); | ||
/* | ||
@@ -68,2 +70,8 @@ We have to be careful about how we get the diff because Actions uses a shallow clone. | ||
exports.gitDiff = gitDiff; | ||
async function getAttwJson(definitelyTypedPath, diffBase) { | ||
return { | ||
base: JSON.parse(await (0, utils_1.execAndThrowErrors)("git", ["show", `${diffBase}:attw.json`], definitelyTypedPath)), | ||
head: JSON.parse(await (0, promises_1.readFile)((0, utils_1.joinPaths)(definitelyTypedPath, "attw.json"), "utf8")), | ||
}; | ||
} | ||
/** | ||
@@ -73,7 +81,22 @@ * @returns packages with added or removed files, but not packages with only changed files; | ||
*/ | ||
function gitChanges(diffs) { | ||
async function gitChanges(diffs, getAttwJson) { | ||
const deletions = new Map(); | ||
const additions = new Map(); | ||
let attwChanges = []; | ||
const errors = []; | ||
for (const diff of diffs) { | ||
if (diff.file === "attw.json") { | ||
try { | ||
const { base, head } = await getAttwJson(); | ||
attwChanges = Array.from((0, utils_1.symmetricDifference)(new Set(base.failingPackages), new Set(head.failingPackages))).map((p) => { | ||
const [typesDirectoryName, versionDirectory] = p.split("/", 2); | ||
const version = (0, definition_parser_1.parseVersionFromDirectoryName)(versionDirectory) ?? "*"; | ||
return { typesDirectoryName, version }; | ||
}); | ||
} | ||
catch { | ||
errors.push(`Error reading attw.json`); | ||
} | ||
continue; | ||
} | ||
if (!/types[\\/]/.test(diff.file)) | ||
@@ -107,3 +130,3 @@ continue; | ||
return { errors }; | ||
return { deletions: Array.from(deletions.values()), additions: Array.from(additions.values()) }; | ||
return { deletions: Array.from(deletions.values()), additions: Array.from(additions.values()), attwChanges }; | ||
} | ||
@@ -114,3 +137,3 @@ exports.gitChanges = gitChanges; | ||
const diffs = await gitDiff(utils_1.consoleLogger.info, definitelyTypedPath, diffBase); | ||
const git = gitChanges(diffs); | ||
const git = await gitChanges(diffs, () => getAttwJson(definitelyTypedPath, diffBase)); | ||
if ("errors" in git) { | ||
@@ -137,2 +160,3 @@ return git.errors; | ||
console.log(`Testing ${affected.dependents.size} dependent packages: ${(0, util_1.inspect)(affected.dependents)}`); | ||
console.log(`Testing ${affected.attwChanges.size} packages from attw.json changes: ${(0, util_1.inspect)(affected.attwChanges)}`); | ||
return affected; | ||
@@ -139,0 +163,0 @@ } |
{ | ||
"name": "@definitelytyped/definitions-parser", | ||
"version": "0.1.5", | ||
"version": "0.1.6", | ||
"description": "Reads the DefinitelyTyped repository and provides an API for querying its metadata", | ||
@@ -22,5 +22,5 @@ "homepage": "https://github.com/microsoft/DefinitelyTyped-tools/tree/main/packages/definitions-parser#readme", | ||
"semver": "^7.5.4", | ||
"@definitelytyped/header-parser": "0.2.2", | ||
"@definitelytyped/typescript-versions": "0.1.0", | ||
"@definitelytyped/utils": "0.1.1" | ||
"@definitelytyped/header-parser": "0.2.3", | ||
"@definitelytyped/utils": "0.1.2" | ||
}, | ||
@@ -27,0 +27,0 @@ "devDependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
155885
1757
6
+ Added@definitelytyped/header-parser@0.2.3(transitive)
+ Added@definitelytyped/utils@0.1.2(transitive)
- Removed@definitelytyped/header-parser@0.2.2(transitive)
- Removed@definitelytyped/utils@0.1.1(transitive)
Updated@definitelytyped/utils@0.1.2