Skip to content

Instantly share code, notes, and snippets.

View AgentEnder's full-sized avatar
🛠️
Working on Nx

Craigory Coppola AgentEnder

🛠️
Working on Nx
View GitHub Profile
@AgentEnder
AgentEnder / RequireYarn.preinstall.js
Created July 30, 2021 14:57
A simple node preinstall hook to require yarn usage
const { basename } = require('path');
const runningPackager = basename(process.env.npm_execpath);
if (!runningPackager.startsWith('yarn')) {
console.warn('<------------------------------------>');
console.warn('<------ detected `npm install` ----->');
console.warn('<---- use `yarn` to install deps ---->');
console.warn('<------------------------------------>');
throw new Error('Use yarn to install packages.');
import fetch from "node-fetch";
import { JSDOM } from "jsdom";
export function downloadHTML(url: string): Promise<JSDOM> {
return fetch(url)
.then((x) => x.text())
.then((html) => {
return new JSDOM(html);
});
}
import { execSync } from 'child_process';
import { writeFileSync } from 'fs';
import { ensureDirSync } from 'fs-extra';
import yargs from 'yargs-parser';
const ITERATIONS = 25;
type Measure = Record<string, number>;
const daemon_measures: Measure[] = [];
import { execSync } from "child_process";
import { ESLint } from "eslint";
import { basename } from "path";
export async function lintChangedFiles(
base: string = "main",
filePaths: string[] = []
) {
console.log(
"BASE branch to compare to find changed files for Lint check is: " + base
@AgentEnder
AgentEnder / benchmark.ts
Last active July 11, 2024 14:26
A quick benchmark script for comparing Nx graph construction times with various env variables
import { ExecSyncOptions, execSync } from 'child_process';
import { existsSync, readFileSync, unlinkSync, writeFileSync } from 'fs';
import { join } from 'path';
const ITERATIONS = 5;
const variables = [
['NX_DAEMON', ['true', 'false']],
['NX_ISOLATE_PLUGINS', ['true', 'false']],
] as const;
@AgentEnder
AgentEnder / extract-timings.js
Last active January 10, 2025 17:36
Small script to extract perf timings from Nx graph construction
//@ts-check
/**
* @type {Array<[string, number]>}
*/
const timings = [];
const { dirname } = require('path');
const labelReplacers = [
(l) => l.replace(dirname(dirname(require.resolve('nx'))), 'nx'),
];
@AgentEnder
AgentEnder / graph_perf.bat
Created October 24, 2025 16:04
Nx Graph Construction Perf Extraction
@echo off
REM Reset Nx
nx reset
IF %ERRORLEVEL% NEQ 0 (
echo Nx reset failed.
exit /b %ERRORLEVEL%
)
REM Set environment variable
set DOTNET_ROLL_FORWARD_TO_PRERELEASE=1