New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@lage-run/target-graph

Package Overview
Dependencies
Maintainers
0
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lage-run/target-graph - npm Package Compare versions

Comparing version 0.11.0 to 0.11.1

17

CHANGELOG.json

@@ -5,3 +5,18 @@ {

{
"date": "Mon, 02 Dec 2024 17:22:51 GMT",
"date": "Wed, 15 Jan 2025 16:55:51 GMT",
"version": "0.11.1",
"tag": "@lage-run/target-graph_v0.11.1",
"comments": {
"patch": [
{
"author": "1581488+christiango@users.noreply.github.com",
"package": "@lage-run/target-graph",
"commit": "f4551ca0219cf233f7497a27dea7df57229eb02c",
"comment": "Fix bug where priorities were not being correctly set on tasks"
}
]
}
},
{
"date": "Mon, 02 Dec 2024 17:23:22 GMT",
"version": "0.11.0",

@@ -8,0 +23,0 @@ "tag": "@lage-run/target-graph_v0.11.0",

# Change Log - @lage-run/target-graph
<!-- This log was last generated on Mon, 02 Dec 2024 17:22:51 GMT and should not be manually modified. -->
<!-- This log was last generated on Wed, 15 Jan 2025 16:55:51 GMT and should not be manually modified. -->
<!-- Start content -->
## 0.11.1
Wed, 15 Jan 2025 16:55:51 GMT
### Patches
- Fix bug where priorities were not being correctly set on tasks (1581488+christiango@users.noreply.github.com)
## 0.11.0
Mon, 02 Dec 2024 17:22:51 GMT
Mon, 02 Dec 2024 17:23:22 GMT

@@ -11,0 +19,0 @@ ### Minor changes

2

lib/prioritize.d.ts
import type { Target } from "./types/Target.js";
/**
* Priorities for a target is actually the MAX of all the priorities of the targets that depend on it.
* Priorities for a target is actually the MAX of all the priorities of the targets that depend on it plus the current priority.
*/
export declare function prioritize(targets: Map<string, Target>): void;

@@ -29,5 +29,5 @@ "use strict";

/**
* Topologically sort the nodes in a graph - starting with nodes with no dependencies
* @returns a list of ids in order
*/ function topologicalSort(targets, nodesWithNoDependencies) {
* Topologically sort the nodes in a graph in reverse order. Leaf nodes are at the beginning of the list and nodes with no dependencies are at the end of the list
* @returns a list of ids in reverse topological order
*/ function reverseTopoSort(targets, nodesWithNoDependencies) {
const sortedList = [];

@@ -40,3 +40,3 @@ const dependsOnMap = getNewDependsOnMap(targets);

const currentId = nodesWithNoDependenciesClone.pop();
sortedList.push(currentId);
sortedList.unshift(currentId);
const node = targets.get(currentId);

@@ -58,13 +58,15 @@ // Update the depends on maps of all outgoing edges

const nodesWithNoDependencies = getNodesWithNoDependencies(targets);
const topoSortedNodeIds = topologicalSort(targets, nodesWithNoDependencies);
const reverseTopoSortedNodeIds = reverseTopoSort(targets, nodesWithNoDependencies);
/**
* What is this loop doing?
*
* Now that we have topologically sorted the nodes, we examine the each node
* and update the cumulative priority of all the nodes that depend on it.
*/ for (const currentNodeId of topoSortedNodeIds){
* We want to make sure that all nodes with high priority are scheduled earlier. This means we need to make sure everything a node with high priority needs to ensure that all nodes it depends on has at least as high a priority set on them.
* We go through all the nodes in reverse topological sort order, meaning we will visit a node before we visit any nodes it depends on. For each node, we will look at all the nodes that depend on the current task. All dependents will have
* already been visited by the reverse topological sort so their priority is final. We will then take the maximum priority of all dependents and set the current nodes priority equal to the maximum priority plus the current node priority.
*/ for (const currentNodeId of reverseTopoSortedNodeIds){
const node = targets.get(currentNodeId);
// The default priority for a node is zero
const currentNodePriority = node.priority || 0;
const childrenPriorities = node.dependencies.map((childId)=>{
// Let's find the dependent with the highest priority and make sure the current node has a priority at least as high as that
const childrenPriorities = node.dependents.map((childId)=>{
const childCumulativePriority = nodeCumulativePriorities.get(childId);

@@ -71,0 +73,0 @@ if (childCumulativePriority === undefined) {

@@ -57,7 +57,11 @@ import type { PackageInfos } from "workspace-tools";

* @param scope
* @returns
* @param priorities the set of global priorities for the workspace.
*/
build(tasks: string[], scope?: string[]): Promise<{
build(tasks: string[], scope?: string[], priorities?: {
package?: string;
task: string;
priority: number;
}[]): Promise<{
targets: Map<string, Target>;
}>;
}

@@ -117,4 +117,4 @@ "use strict";

* @param scope
* @returns
*/ async build(tasks, scope) {
* @param priorities the set of global priorities for the workspace.
*/ async build(tasks, scope, priorities) {
// Expands the dependency specs from the target definitions

@@ -149,2 +149,15 @@ const fullDependencies = (0, _expandDepSpecs.expandDepSpecs)(this.graphBuilder.targets, this.dependencyMap);

}
// Add all the global priorities for individual targets
if (priorities) {
for (const priorityConfig of priorities){
// Right now we are only handling global priorities where the package name is set
if (priorityConfig.package) {
const targetId = (0, _targetId.getTargetId)(priorityConfig.package, priorityConfig.task);
const target = this.graphBuilder.targets.get(targetId);
if (target) {
target.priority = target.priority ? Math.max(target.priority, priorityConfig.priority) : priorityConfig.priority;
}
}
}
}
const subGraph = this.graphBuilder.subgraph(subGraphEntries);

@@ -151,0 +164,0 @@ const limit = (0, _plimit.default)(8);

{
"name": "@lage-run/target-graph",
"version": "0.11.0",
"version": "0.11.1",
"description": "Target for Lage",

@@ -5,0 +5,0 @@ "repository": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc