git diff > patch.diff
patch -p1 < patch.diff
/** | |
* Graph respects explicit dependencies | |
* and implicit by resources (via positions) | |
*/ | |
export const makeGraphFromTasks = (tasks: Array<Task>): Graph => { | |
// task and blockedBy | |
const graph: Graph = new Map(); | |
const resourcesTasks = new Map<ID, Array<Task>>(); | |
// Create graphs |
export type Task = { | |
id: ID; | |
title: string; | |
start: Date; | |
end: Date; | |
duration: number; | |
/** | |
* Approximation of priority | |
*/ |
export const makeReverseGraph = (graph: Graph): Graph => { | |
const reverseGraph: Graph = new Map(); | |
for (const [id, parentId] of dfs(graph, { withParentId: true })) { | |
const prerequesitions = reverseGraph.get(id) ?? new Set(); | |
if (parentId) { | |
prerequesitions.add(parentId); | |
} | |
reverseGraph.set(id, prerequesitions); | |
} |
export const scheduleTasks = ( | |
inputTasks: Array<Task>, | |
today: Date = getNowDate() | |
): Array<Task> => { | |
const dayBeforeToday = subtractDays(today, 1); | |
const tasks: Array<Task> = inputTasks.map((t) => ({ ...t })); | |
const tasksById: TasksById = Object.fromEntries(tasks.map((t) => [t.id, t])); | |
const graph = makeGraphFromTasks(tasks); | |
let cyclesToFullyUpdateDates = 1; |
const result = (function () { | |
switch (step) { | |
case Step.One: | |
return {one: 1}; | |
case Step.Two: | |
return {two: 2}; | |
case Step.Three: | |
return {three: 4}; | |
} | |
})(); |
/** | |
* Main source of cyclic dependencies is previous step where graph is created | |
* Often top-level task has same owner as children tasks | |
* Since we create edge in graph also by same owner that's why there is cyclic deps | |
* | |
* IDEA: mitigate the issue by starting DFS walk from top-level (source) tasks! | |
*/ | |
export const removeCyclicDependencies = ( | |
graph: Graph, | |
tasks: Array<Task> |
import type { ServerBuild } from "@remix-run/node"; | |
import { createRequestHandler } from "@remix-run/server-runtime"; | |
import { serve } from "bun"; | |
import { resolve } from "node:path"; | |
process.env.REMIX_DEV_ORIGIN = "https://localhost"; | |
// @see https://remix.run/docs/en/main/future/vite#migrating-a-custom-server | |
const viteDevServer = | |
process.env.NODE_ENV === "production" |