Skip to content

Commit

Permalink
Upgrade dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
mbalabash committed Nov 21, 2023
1 parent d09b8ad commit b2ef0ea
Show file tree
Hide file tree
Showing 15 changed files with 1,113 additions and 676 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
node: [14, 16]
node: [18, 20]
os: [macos-latest, ubuntu-latest, windows-latest]
name: OS ${{ matrix.os }} Node.js ${{ matrix.node }}
steps:
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import estimo from './src/lib.js'

export { generatePrettyReport } from './src/reporter.js'
export { processor } from './src/processor.js'
export { generatePrettyReport } from './src/reporter.js'

export default estimo
30 changes: 16 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"types": "./index.d.ts",
"type": "module",
"engines": {
"node": ">=14"
"node": ">=18"
},
"license": "MIT",
"author": "mbalabash <maksim.balabash@gmail.com>",
Expand All @@ -20,24 +20,26 @@
},
"dependencies": {
"@sitespeed.io/tracium": "^0.3.3",
"commander": "^10.0.0",
"find-chrome-bin": "1.0.4",
"nanoid": "4.0.1",
"puppeteer-core": "19.8.0"
"commander": "^11.1.0",
"find-chrome-bin": "2.0.0",
"nanoid": "5.0.3",
"puppeteer-core": "21.5.2"
},
"devDependencies": {
"@logux/eslint-config": "^49.0.0",
"ava": "5.2.0",
"eslint": "^8.36.0",
"eslint-config-standard": "^17.0.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-n": "^15.6.1",
"@logux/eslint-config": "^52.0.2",
"ava": "5.3.1",
"eslint": "^8.54.0",
"eslint-config-standard": "^17.1.0",
"eslint-plugin-import": "^2.29.0",
"eslint-plugin-n": "^16.3.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-node-import": "^1.0.4",
"eslint-plugin-perfectionist": "^2.4.0",
"eslint-plugin-prefer-let": "^3.0.1",
"eslint-plugin-promise": "^6.1.1",
"prettier": "^2.8.7",
"rimraf": "^4.4.1",
"typescript": "^5.0.2"
"prettier": "^3.1.0",
"rimraf": "^5.0.5",
"typescript": "^5.3.2"
},
"eslintConfig": {
"extends": "@logux/eslint-config",
Expand Down
4 changes: 2 additions & 2 deletions scripts/clean-chrome-config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { join, dirname } from 'path'
import { fileURLToPath } from 'url'
import { dirname, join } from 'node:path'
import { fileURLToPath } from 'node:url'

import { writeFile } from '../src/utils.js'

Expand Down
8 changes: 4 additions & 4 deletions scripts/cli.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env node
import { resolve } from 'path'
import { Command } from 'commander'
import { resolve } from 'node:path'

import { isUrl } from '../src/utils.js'
import estimo from '../index.js'
import { isUrl } from '../src/utils.js'

const program = new Command()
program
Expand Down Expand Up @@ -31,11 +31,11 @@ program.parse(process.argv)

const options = program.opts()
const settings = {
cpuThrottlingRate: options.Cpu ? parseInt(options.Cpu, 10) : 1,
device: options.Device || false,
diff: options.Diff || false,
runs: options.Runs ? parseInt(options.Runs, 10) : 1,
cpuThrottlingRate: options.Cpu ? parseInt(options.Cpu, 10) : 1,
emulateNetworkConditions: options.Net,
runs: options.Runs ? parseInt(options.Runs, 10) : 1,
timeout: options.Timeout || 20000
}

Expand Down
8 changes: 4 additions & 4 deletions src/create-chrome-trace.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ async function createBrowserEntity(options) {
chromeLaunchArgs.push(`--window-size=${options.width},${options.height}`)
}
let browserConfig = {
headless: options.headless,
executablePath: options.executablePath,
args: chromeLaunchArgs,
executablePath: options.executablePath,
headless: options.headless,
ignoreDefaultArgs: ['--disable-extensions']
}
if (process.env.ESTIMO_DEBUG) {
Expand All @@ -53,8 +53,8 @@ async function createPageEntity(context, options) {
}
if (options.width && options.height) {
await page.setViewport({
width: options.width,
height: options.height
height: options.height,
width: options.width
})
}
if (options.device) {
Expand Down
8 changes: 4 additions & 4 deletions src/generate-html-file.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { nanoid } from 'nanoid'

import {
writeFile,
resolvePathToTempDir,
existsAsync,
getLibraryName,
getUrlToHtmlFile,
isUrl,
existsAsync
resolvePathToTempDir,
writeFile
} from './utils.js'

export function createHtmlContent(library) {
Expand Down Expand Up @@ -52,7 +52,7 @@ export async function prepareLibrariesForEstimation(libraries) {

let name = getLibraryName(lib)
let url = getUrlToHtmlFile(html)
resources.push({ name, url, htmlPath: html })
resources.push({ htmlPath: html, name, url })
}

return resources
Expand Down
8 changes: 4 additions & 4 deletions src/lib.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { processor } from './processor.js'
import {
splitResourcesForEstimo,
checkEstimoArgs,
findChromeBinary
findChromeBinary,
splitResourcesForEstimo
} from './utils.js'
import { processor } from './processor.js'

export async function estimo(resources = [], browserOptions = {}) {
if (process.env.ESTIMO_DISABLE) process.exit()
Expand All @@ -14,7 +14,7 @@ export async function estimo(resources = [], browserOptions = {}) {
let { executablePath } = await findChromeBinary()
browserOptions.executablePath = executablePath

let { pages, libraries } = splitResourcesForEstimo(resources)
let { libraries, pages } = splitResourcesForEstimo(resources)

if (libraries.length > 0) {
reports = reports.concat(
Expand Down
50 changes: 25 additions & 25 deletions src/processor.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { createChromeTrace } from './create-chrome-trace.js'
import { prepareLibrariesForEstimation } from './generate-html-file.js'
import { generatePrettyReport } from './reporter.js'
import {
median,
removeAllFiles,
createDiff,
estimoMedianExecutor,
createDiff
median,
removeAllFiles
} from './utils.js'
import { prepareLibrariesForEstimation } from './generate-html-file.js'
import { createChromeTrace } from './create-chrome-trace.js'
import { generatePrettyReport } from './reporter.js'

async function reportsProcessor(reports, browserOptions) {
let runs = browserOptions.runs || 1
Expand All @@ -28,39 +28,39 @@ async function reportsProcessor(reports, browserOptions) {
let baseline = result[0]
for (let i = 1; i < result.length; i += 1) {
result[i].diff = {
parseHTML: `${result[i].parseHTML} (${createDiff(
result[i].parseHTML,
baseline.parseHTML
garbageCollection: `${result[i].garbageCollection} (${createDiff(
result[i].garbageCollection,
baseline.garbageCollection
)})`,
styleLayout: `${result[i].styleLayout} (${createDiff(
result[i].styleLayout,
baseline.styleLayout
javaScript: `${result[i].javaScript} (${createDiff(
result[i].javaScript,
baseline.javaScript
)})`,
other: `${result[i].other} (${createDiff(
result[i].other,
baseline.other
)})`,
paintCompositeRender: `${
result[i].paintCompositeRender
} (${createDiff(
result[i].paintCompositeRender,
baseline.paintCompositeRender
)})`,
scriptParseCompile: `${result[i].scriptParseCompile} (${createDiff(
result[i].scriptParseCompile,
baseline.scriptParseCompile
parseHTML: `${result[i].parseHTML} (${createDiff(
result[i].parseHTML,
baseline.parseHTML
)})`,
scriptEvaluation: `${result[i].scriptEvaluation} (${createDiff(
result[i].scriptEvaluation,
baseline.scriptEvaluation
)})`,
javaScript: `${result[i].javaScript} (${createDiff(
result[i].javaScript,
baseline.javaScript
)})`,
garbageCollection: `${result[i].garbageCollection} (${createDiff(
result[i].garbageCollection,
baseline.garbageCollection
scriptParseCompile: `${result[i].scriptParseCompile} (${createDiff(
result[i].scriptParseCompile,
baseline.scriptParseCompile
)})`,
other: `${result[i].other} (${createDiff(
result[i].other,
baseline.other
styleLayout: `${result[i].styleLayout} (${createDiff(
result[i].styleLayout,
baseline.styleLayout
)})`,
total: `${result[i].total} (${createDiff(
result[i].total,
Expand Down
12 changes: 6 additions & 6 deletions src/reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ export async function generatePrettyReport(resources) {
)

reports.push({
garbageCollection: garbageTime,
javaScript: formatTime(compileTime + evaluationTime),
name: item.name,
parseHTML: htmlTime,
styleLayout: styleTime,
other: otherTime,
paintCompositeRender: renderTime,
scriptParseCompile: compileTime,
parseHTML: htmlTime,
scriptEvaluation: evaluationTime,
javaScript: formatTime(compileTime + evaluationTime),
garbageCollection: garbageTime,
other: otherTime,
scriptParseCompile: compileTime,
styleLayout: styleTime,
total: formatTime(
htmlTime +
styleTime +
Expand Down
34 changes: 17 additions & 17 deletions src/utils.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import fs from 'fs'
import path from 'path'
import { promisify } from 'util'
import { fileURLToPath } from 'url'
import puppeteer from 'puppeteer-core'
import { findChrome } from 'find-chrome-bin'
import fs from 'node:fs'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import { promisify } from 'node:util'
import puppeteer from 'puppeteer-core'
import { PUPPETEER_REVISIONS } from 'puppeteer-core/lib/cjs/puppeteer/revisions.js'

const __dirname = path.dirname(fileURLToPath(import.meta.url))
Expand Down Expand Up @@ -141,24 +141,24 @@ export function estimoMedianExecutor(reportA, reportB) {
let calc = (a, b) => +((a + b) / 2).toFixed(2)

return {
garbageCollection: calc(
reportA.garbageCollection,
reportB.garbageCollection
),
javaScript: calc(reportA.javaScript, reportB.javaScript),
name: reportA.name,
parseHTML: calc(reportA.parseHTML, reportB.parseHTML),
styleLayout: calc(reportA.styleLayout, reportB.styleLayout),
other: calc(reportA.other, reportB.other),
paintCompositeRender: calc(
reportA.paintCompositeRender,
reportB.paintCompositeRender
),
parseHTML: calc(reportA.parseHTML, reportB.parseHTML),
scriptEvaluation: calc(reportA.scriptEvaluation, reportB.scriptEvaluation),
scriptParseCompile: calc(
reportA.scriptParseCompile,
reportB.scriptParseCompile
),
scriptEvaluation: calc(reportA.scriptEvaluation, reportB.scriptEvaluation),
javaScript: calc(reportA.javaScript, reportB.javaScript),
garbageCollection: calc(
reportA.garbageCollection,
reportB.garbageCollection
),
other: calc(reportA.other, reportB.other),
styleLayout: calc(reportA.styleLayout, reportB.styleLayout),
total: calc(reportA.total, reportB.total)
}
}
Expand Down Expand Up @@ -223,9 +223,9 @@ export async function findChromeBinary() {

let chromeInfo = await findChrome({
download: {
path: chromeTempPath,
puppeteer,
revision: PUPPETEER_REVISIONS.chromium,
path: chromeTempPath
revision: PUPPETEER_REVISIONS.chrome
}
})
await writeFile(chromeConfigPath, JSON.stringify(chromeInfo))
Expand All @@ -235,6 +235,6 @@ export async function findChromeBinary() {
console.info()
console.error(error)
console.info()
return { executablePath: '', browser: '' }
return { browser: '', executablePath: '' }
}
}
12 changes: 6 additions & 6 deletions tests/estimo.test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import test from 'ava'
import path from 'path'
import { fileURLToPath } from 'url'
import path from 'node:path'
import { fileURLToPath } from 'node:url'

import estimo from '../src/lib.js'
import { getUrlToHtmlFile, findChromeBinary } from '../src/utils.js'
import { cleanChromeConfig } from '../scripts/clean-chrome-config.js'
import estimo from '../src/lib.js'
import { findChromeBinary, getUrlToHtmlFile } from '../src/utils.js'

const __dirname = path.dirname(fileURLToPath(import.meta.url))
const delay = ms => new Promise(resolve => setTimeout(resolve, ms))
Expand Down Expand Up @@ -192,9 +192,9 @@ test('estimo - should works properly in DIFF MODE', async t => {
let lib2 = path.join(__dirname, '__mock__', '7kb.js')

let reports = await estimo([lib1, lib2], {
diff: true,
executablePath: chromeInfo.executablePath,
runs: 2,
diff: true
runs: 2
})

t.is(reports.length, 2)
Expand Down
10 changes: 5 additions & 5 deletions tests/generate-html-file.test.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import fs from 'fs'
import test from 'ava'
import path from 'path'
import { fileURLToPath } from 'url'
import fs from 'node:fs'
import path from 'node:path'
import { fileURLToPath } from 'node:url'

import { resolvePathToTempDir, removeAllFiles } from '../src/utils.js'
import {
generateHtmlFile,
createHtmlContent,
generateHtmlFile,
prepareLibrariesForEstimation
} from '../src/generate-html-file.js'
import { removeAllFiles, resolvePathToTempDir } from '../src/utils.js'

const __dirname = path.dirname(fileURLToPath(import.meta.url))

Expand Down
Loading

0 comments on commit b2ef0ea

Please sign in to comment.