Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Lint

on:
push:
branches: [main]
pull_request:

permissions:
contents: read

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: pnpm/setup@v2
- run: pnpm install --frozen-lockfile
- run: pnpm run lint
- run: pnpm test
117 changes: 59 additions & 58 deletions benchmarkFixture.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
'use strict'
import path from 'path'
import pathKey from 'path-key'
import spawn from "cross-spawn"
import { promises as fs, cpSync } from 'fs'
import { cpSync, promises as fs } from 'node:fs'
import path from 'node:path'
import { fileURLToPath } from 'node:url'

import spawn from 'cross-spawn'
import getFolderSize from 'get-folder-size'
import pathKey from 'path-key'
import rimraf from 'rimraf'
import { fileURLToPath } from 'url'
import tempy from 'tempy'

const DIRNAME = path.dirname(fileURLToPath(import.meta.url))
Expand All @@ -17,7 +18,7 @@ const lockfileNameByPM = {
npm: 'package-lock.json',
pnpm: 'pnpm-lock.yaml',
yarn: 'yarn.lock',
bun: 'bun.lock'
bun: 'bun.lock',
}

export function createEnv (managersDir) {
Expand Down Expand Up @@ -45,7 +46,7 @@ export function createEnv (managersDir) {
// Where tools installed as packages keep theirs — pnpr today.
path.join(managersDir, 'node_modules/.bin'),
path.dirname(process.execPath),
process.env[pathEnv]
process.env[pathEnv],
].join(path.delimiter)
return env
}
Expand Down Expand Up @@ -76,7 +77,7 @@ function cleanLockfile (pm, cwd, env) {
rimraf.sync(path.join(cwd, lockfileName))
if (pm.name === 'yarn') {
// This ensures yarn berry to install under a nested folder
spawnSyncOrThrow({ name: 'nodetouch', args: [lockfileName] }, { env, cwd, stdio: "inherit" })
spawnSyncOrThrow({ name: 'nodetouch', args: [lockfileName] }, { env, cwd, stdio: 'inherit' })
}
}

Expand All @@ -88,49 +89,49 @@ function cleanLockfile (pm, cwd, env) {
* pull it from npmjs inside a measured run.
*/
export const UPDATED_DEPENDENCIES = {
"babel-core": "^6.4.0",
"babel-eslint": "^6.1.2",
"babel-loader": "^6.2.1",
"babel-plugin-lodash": "^3.2.11",
"babel-plugin-module-resolver": "^2.2.0",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-plugin-transform-runtime": "^6.4.3",
"babel-polyfill": "^6.23.0",
"babel-preset-es2015": "^6.3.13",
"babel-preset-react": "^6.3.13",
"babel-preset-react-hmre": "^1.0.1",
"babel-preset-stage-1": "^6.3.13",
"babel-runtime": "^6.3.19",
"clean-webpack-plugin": "^0.1.16",
"core-decorators": "^0.12.3",
"css-loader": "^0.23.1",
"css-mqpacker": "^4.0.0",
"react": "^15.4.1",
"react-addons-css-transition-group": "^15.3.0",
"react-addons-shallow-compare": "^15.3.0",
"react-dnd": "^2.1.4",
"react-dnd-html5-backend": "^2.1.2",
"react-dom": "^15.4.1",
"react-draft-wysiwyg": "^1.6.5",
"react-dropzone": "^3.5.3",
"react-grid-layout": "^0.12.6",
"react-highcharts": "^11.5.0",
"react-hot-loader": "v3.0.0-beta.6",
"react-input-calendar": "^0.3.14",
"react-lazyload": "^2.2.5",
"react-measure": "^1.4.6",
"react-mixin": "^3.0.3",
"react-responsive": "^1.2.5",
"react-responsive-tabs": "^0.5.3",
"react-router": "^4.0.0",
"react-router-dom": "^4.0.0",
"react-select-plus": "^1.0.0-rc",
"react-skylight": "^0.3.0",
"react-sortablejs": "^1.2.1",
"react-tappable": "^0.8.4",
"react-tooltip": "3.11.2",
"react-virtualized": "^7.19.4",
"react-waypoint": "^5.2.0",
'babel-core': '^6.4.0',
'babel-eslint': '^6.1.2',
'babel-loader': '^6.2.1',
'babel-plugin-lodash': '^3.2.11',
'babel-plugin-module-resolver': '^2.2.0',
'babel-plugin-transform-decorators-legacy': '^1.3.4',
'babel-plugin-transform-runtime': '^6.4.3',
'babel-polyfill': '^6.23.0',
'babel-preset-es2015': '^6.3.13',
'babel-preset-react': '^6.3.13',
'babel-preset-react-hmre': '^1.0.1',
'babel-preset-stage-1': '^6.3.13',
'babel-runtime': '^6.3.19',
'clean-webpack-plugin': '^0.1.16',
'core-decorators': '^0.12.3',
'css-loader': '^0.23.1',
'css-mqpacker': '^4.0.0',
'react': '^15.4.1',
'react-addons-css-transition-group': '^15.3.0',
'react-addons-shallow-compare': '^15.3.0',
'react-dnd': '^2.1.4',
'react-dnd-html5-backend': '^2.1.2',
'react-dom': '^15.4.1',
'react-draft-wysiwyg': '^1.6.5',
'react-dropzone': '^3.5.3',
'react-grid-layout': '^0.12.6',
'react-highcharts': '^11.5.0',
'react-hot-loader': 'v3.0.0-beta.6',
'react-input-calendar': '^0.3.14',
'react-lazyload': '^2.2.5',
'react-measure': '^1.4.6',
'react-mixin': '^3.0.3',
'react-responsive': '^1.2.5',
'react-responsive-tabs': '^0.5.3',
'react-router': '^4.0.0',
'react-router-dom': '^4.0.0',
'react-select-plus': '^1.0.0-rc',
'react-skylight': '^0.3.0',
'react-sortablejs': '^1.2.1',
'react-tappable': '^0.8.4',
'react-tooltip': '3.11.2',
'react-virtualized': '^7.19.4',
'react-waypoint': '^5.2.0',
}

async function updateDependenciesInPackageJson (cwd) {
Expand Down Expand Up @@ -262,7 +263,7 @@ function removeInstallOutput (cwd, modules) {
}
}

export default async function benchmark (pm, fixture, opts) {
export async function benchmark (pm, fixture, opts) {
const cwd = path.join(TMP, pm.scenario, fixture)
const env = createEnv(opts.managersDir)
if (pm.rustEngine) {
Expand Down Expand Up @@ -348,13 +349,13 @@ export default async function benchmark (pm, fixture, opts) {
rimraf.sync(path.join(cwd, 'cache'))
cleanLockfile(pm, cwd, env)

console.log(`# first install`)
console.log('# first install')

const firstInstall = measureInstall(pm, cwd, env)

let repeatInstall
if (modules) {
console.log(`# repeat install`)
console.log('# repeat install')

repeatInstall = measureInstall(pm, cwd, env)

Expand All @@ -363,7 +364,7 @@ export default async function benchmark (pm, fixture, opts) {
repeatInstall = 0
}

console.log(`# with warm cache and lockfile`)
console.log('# with warm cache and lockfile')

const withWarmCacheAndLockfile = measureInstall(pm, cwd, env)

Expand Down Expand Up @@ -414,7 +415,7 @@ export default async function benchmark (pm, fixture, opts) {
} else {
withWarmCacheAndModules =
withWarmModulesAndLockfile =
withWarmModules = 0
withWarmModules = 0
size = await getFolderSize.loose(path.join(cwd, 'cache'))
}

Expand Down Expand Up @@ -490,7 +491,7 @@ export default async function benchmark (pm, fixture, opts) {
withWarmModulesAndLockfile,
withWarmModules,
updatedDependencies,
size
size,
}
}

Expand All @@ -511,7 +512,7 @@ function measureInstall (cmd, cwd, env) {
const startTime = Date.now()

console.log(`> ${cmd.name} ${cmd.args.join(' ')}`)
spawnSyncOrThrow(cmd, { env, cwd, stdio: "inherit" });
spawnSyncOrThrow(cmd, { env, cwd, stdio: 'inherit' });

const endTime = Date.now()

Expand Down
14 changes: 8 additions & 6 deletions benchmarkNodeVersions.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
'use strict'
import fs from 'fs'
import path from 'path'
import rimraf from 'rimraf'
import pathKey from 'path-key'
import fs from 'node:fs'
import path from 'node:path'

import spawn from 'cross-spawn'
import pathKey from 'path-key'
import rimraf from 'rimraf'
import tempy from 'tempy'

import { createEnv } from './benchmarkFixture.js'

const TMP = tempy.directory()
Expand Down Expand Up @@ -190,7 +192,7 @@ export function readManagerVersion (pm, opts) {
return captureShell(runner, 'nvm --version', opts.managersDir, env).trim()
}

export default async function benchmarkNodeVersions (pm, opts) {
export async function benchmarkNodeVersions (pm, opts) {
const dir = path.join(TMP, pm.scenario)
rimraf.sync(dir)
fs.mkdirSync(dir, { recursive: true })
Expand Down Expand Up @@ -332,5 +334,5 @@ function nvmSourceDir (managersDir) {
}

function quote (value) {
return `'${value.replace(/'/g, `'\\''`)}'`
return `'${value.replace(/'/g, "'\\''")}'`
}
20 changes: 11 additions & 9 deletions benchmarkRegistry.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
'use strict'
import fs from 'fs'
import path from 'path'
import { fileURLToPath } from 'url'
import cmdsMap from './commandsMap.js'
import { startLatencyProxy, mbpsToBytesPerSec } from './latencyProxy.js'
import fs from 'node:fs'
import path from 'node:path'
import { fileURLToPath } from 'node:url'

import { cmdsMap } from './commandsMap.js'
import { mbpsToBytesPerSec, startLatencyProxy } from './latencyProxy.js'
import {
installPnpr,
pnprVersion,
startPnpr,
mintToken,
npmRegistryUrl,
pnprVersion,
populateCache,
verifyResolverIsUsed,
reservePort,
npmRegistryUrl,
startPnpr,
tarRegistryUrl,
verifyResolverIsUsed,
} from './pnprServer.js'

const DIRNAME = path.dirname(fileURLToPath(import.meta.url))
Expand Down Expand Up @@ -152,6 +153,7 @@ export async function startBenchmarkRegistry ({ managersDirs, fixtureNames }) {
console.log(`# pnpr storage seeded from ${seededStorage} (cache warm-up skipped)`)
} else {
for (const fixtureName of fixtureNames) {
// eslint-disable-next-line no-await-in-loop -- the fixtures warm one shared registry one after another
await populateCache({
pm: withRegistry(cmdsMap.pnpm12, url),
managersDir: managersDirs.pnpm12,
Expand Down
18 changes: 9 additions & 9 deletions commandsMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Nor does anything here say which of them a reader is shown. Every manager
// listed is measured and reported in `benchmarks.json`; pnpm.io draws npm and
// the pnpm columns from it, and the rest are measured for our own comparisons.
export default {
export const cmdsMap = {
npm: {
scenario: 'npm',
name: 'npm',
Expand All @@ -20,7 +20,7 @@ export default {
'--legacy-peer-deps',
// npm CLI fails on the benchmarks with this option. So, commenting out for now.
// '--install-strategy=linked',
]
],
},
pnpm11: {
scenario: 'pnpm11',
Expand All @@ -34,7 +34,7 @@ export default {
'--no-strict-peer-dependencies',
'--config.auto-install-peers=false',
'--config.resolution-mode=highest',
]
],
},
pnpm12: {
scenario: 'pnpm12',
Expand All @@ -46,7 +46,7 @@ export default {
args: [
'install',
'--ignore-scripts',
]
],
},
// The two scenarios below are the same pnpm 12 as the row above, measured
// under a different linking strategy. Neither changes the command: the
Expand Down Expand Up @@ -95,14 +95,14 @@ export default {
args: [
'install',
'--ignore-scripts',
]
],
},
yarn: {
scenario: 'yarn',
name: 'yarn',
args: [
'install'
]
'install',
],
},
bun: {
scenario: 'bun',
Expand All @@ -116,6 +116,6 @@ export default {
// scenario that starts without a lockfile. Yarn is opted out of the same
// behaviour through `enableImmutableInstalls: false`.
'--no-frozen-lockfile',
]
}
],
},
}
Loading
Loading