Upgrade to eslint/unicorn 54 (#4213)
This commit is contained in:
parent
d9989b90c6
commit
3741366d45
|
|
@ -5,7 +5,7 @@
|
|||
import { writeFileSync } from 'node:fs';
|
||||
import { execSync } from 'node:child_process';
|
||||
import { platform } from 'node:os';
|
||||
import { resolve, basename } from 'node:path';
|
||||
import path from 'node:path';
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { EventEmitter } from 'node:events';
|
||||
|
||||
|
|
@ -38,10 +38,10 @@ async function api(options) {
|
|||
// Add support for running multi tests
|
||||
if (options.multi) {
|
||||
const scripting = await readFileSync(
|
||||
new URL(resolve(process.cwd(), options._[0]), import.meta.url)
|
||||
new URL(path.resolve(process.cwd(), options._[0]), import.meta.url)
|
||||
);
|
||||
apiOptions.api.scripting = scripting.toString();
|
||||
apiOptions.api.scriptingName = basename(options._[0]);
|
||||
apiOptions.api.scriptingName = path.basename(options._[0]);
|
||||
}
|
||||
|
||||
if (apiOptions.mobile) {
|
||||
|
|
@ -57,7 +57,7 @@ async function api(options) {
|
|||
if (options.config) {
|
||||
const config = JSON.parse(
|
||||
await readFileSync(
|
||||
new URL(resolve(process.cwd(), options.config), import.meta.url)
|
||||
new URL(path.resolve(process.cwd(), options.config), import.meta.url)
|
||||
)
|
||||
);
|
||||
apiOptions = merge(options.explicitOptions, config);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { resolve } from 'node:path';
|
||||
import path from 'node:path';
|
||||
import { platform } from 'node:os';
|
||||
import { createRequire } from 'node:module';
|
||||
import { readFileSync, statSync } from 'node:fs';
|
||||
|
|
@ -189,7 +189,7 @@ function validateInput(argv) {
|
|||
|
||||
if (argv.html && argv.html.summaryBoxesThresholds) {
|
||||
try {
|
||||
const box = readFileSync(resolve(argv.html.summaryBoxesThresholds), {
|
||||
const box = readFileSync(path.resolve(argv.html.summaryBoxesThresholds), {
|
||||
encoding: 'utf8'
|
||||
});
|
||||
argv.html.summaryBoxesThresholds = JSON.parse(box);
|
||||
|
|
@ -1131,13 +1131,11 @@ export async function parseCommandLine() {
|
|||
group: 'Crawler'
|
||||
})
|
||||
.option('crawler.exclude', {
|
||||
describe:
|
||||
'Exclude URLs matching the provided regular expression (ex: "/some/path/", "://some\\.domain/"). Can be provided multiple times.',
|
||||
describe: String.raw`Exclude URLs matching the provided regular expression (ex: "/some/path/", "://some\.domain/"). Can be provided multiple times.`,
|
||||
group: 'Crawler'
|
||||
})
|
||||
.option('crawler.include', {
|
||||
describe:
|
||||
'Discard URLs not matching the provided regular expression (ex: "/some/path/", "://some\\.domain/"). Can be provided multiple times.',
|
||||
describe: String.raw`Discard URLs not matching the provided regular expression (ex: "/some/path/", "://some\.domain/"). Can be provided multiple times.`,
|
||||
group: 'Crawler'
|
||||
})
|
||||
.option('crawler.ignoreRobotsTxt', {
|
||||
|
|
@ -2160,7 +2158,7 @@ export async function parseCommandLine() {
|
|||
|
||||
if (argv.config) {
|
||||
const config = JSON.parse(
|
||||
await readFileSync(resolve(process.cwd(), argv.config))
|
||||
await readFileSync(path.resolve(process.cwd(), argv.config))
|
||||
);
|
||||
explicitOptions = merge(explicitOptions, config);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*eslint no-console: 0*/
|
||||
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { resolve } from 'node:path';
|
||||
import path from 'node:path';
|
||||
import { format } from 'node:util';
|
||||
|
||||
import { toArray } from '../support/util.js';
|
||||
|
|
@ -36,7 +36,7 @@ export function getURLs(urls) {
|
|||
if (url.startsWith('http')) {
|
||||
allUrls.push(url);
|
||||
} else {
|
||||
const filePath = resolve(url);
|
||||
const filePath = path.resolve(url);
|
||||
try {
|
||||
const lines = readFileSync(filePath).toString().split('\n');
|
||||
for (let line of lines) {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import { join, basename, resolve, dirname } from 'node:path';
|
||||
import path from 'node:path';
|
||||
import { readdir as _readdir } from 'node:fs';
|
||||
import { promisify } from 'node:util';
|
||||
|
||||
import { importGlobalSilent } from 'import-global';
|
||||
const readdir = promisify(_readdir);
|
||||
const __dirname = dirname(import.meta.url);
|
||||
const __dirname = path.dirname(import.meta.url);
|
||||
|
||||
const defaultPlugins = new Set([
|
||||
'browsertime',
|
||||
|
|
@ -23,7 +23,7 @@ const defaultPlugins = new Set([
|
|||
'remove'
|
||||
]);
|
||||
|
||||
const pluginsDir = join(__dirname, '..', 'plugins');
|
||||
const pluginsDir = path.join(__dirname, '..', 'plugins');
|
||||
|
||||
export async function parsePluginNames(options) {
|
||||
// There's a problem with Safari on iOS runninhg a big blob
|
||||
|
|
@ -51,7 +51,7 @@ export async function parsePluginNames(options) {
|
|||
|
||||
const files = await readdir(new URL(pluginsDir));
|
||||
|
||||
const builtins = files.map(name => basename(name, '.js'));
|
||||
const builtins = files.map(name => path.basename(name, '.js'));
|
||||
// eslint-disable-next-line unicorn/no-array-callback-reference
|
||||
const plugins = builtins.filter(isDefaultOrConfigured);
|
||||
return addMessageLoggerIfDebug(plugins);
|
||||
|
|
@ -61,13 +61,15 @@ export async function loadPlugins(pluginNames, options, context, queue) {
|
|||
for (let name of pluginNames) {
|
||||
try {
|
||||
let { default: plugin } = await import(
|
||||
join(pluginsDir, name, 'index.js')
|
||||
path.join(pluginsDir, name, 'index.js')
|
||||
);
|
||||
let p = new plugin(options, context, queue);
|
||||
plugins.push(p);
|
||||
} catch (error_) {
|
||||
try {
|
||||
let { default: plugin } = await import(resolve(process.cwd(), name));
|
||||
let { default: plugin } = await import(
|
||||
path.resolve(process.cwd(), name)
|
||||
);
|
||||
let p = new plugin(options, context, queue);
|
||||
plugins.push(p);
|
||||
} catch {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { parse, format } from 'node:url';
|
||||
import { basename, resolve, join } from 'node:path';
|
||||
import path from 'node:path';
|
||||
|
||||
import { resultUrls } from './resultUrls.js';
|
||||
import { storageManager } from './storageManager.js';
|
||||
|
|
@ -8,7 +8,7 @@ function getDomainOrFileName(input) {
|
|||
let domainOrFile = input;
|
||||
domainOrFile = domainOrFile.startsWith('http')
|
||||
? parse(domainOrFile).hostname
|
||||
: basename(domainOrFile).replaceAll('.', '_');
|
||||
: path.basename(domainOrFile).replaceAll('.', '_');
|
||||
return domainOrFile;
|
||||
}
|
||||
|
||||
|
|
@ -21,17 +21,17 @@ export function resultsStorage(input, timestamp, options) {
|
|||
let resultUrl;
|
||||
|
||||
if (outputFolder) {
|
||||
resultsSubFolders.push(basename(outputFolder));
|
||||
storageBasePath = resolve(outputFolder);
|
||||
resultsSubFolders.push(path.basename(outputFolder));
|
||||
storageBasePath = path.resolve(outputFolder);
|
||||
} else {
|
||||
resultsSubFolders.push(
|
||||
options.slug || getDomainOrFileName(input),
|
||||
timestamp.format('YYYY-MM-DD-HH-mm-ss')
|
||||
);
|
||||
storageBasePath = resolve('sitespeed-result', ...resultsSubFolders);
|
||||
storageBasePath = path.resolve('sitespeed-result', ...resultsSubFolders);
|
||||
}
|
||||
|
||||
storagePathPrefix = join(...resultsSubFolders);
|
||||
storagePathPrefix = path.join(...resultsSubFolders);
|
||||
|
||||
if (resultBaseURL) {
|
||||
const url = parse(resultBaseURL);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { join } from 'node:path';
|
||||
import path from 'node:path';
|
||||
import { promisify } from 'node:util';
|
||||
import {
|
||||
rmdir as _rmdir,
|
||||
|
|
@ -23,7 +23,7 @@ const rmdir = promisify(_rmdir);
|
|||
const writeFile = promisify(_writeFile);
|
||||
|
||||
function write(dirPath, filename, data) {
|
||||
return writeFile(join(dirPath, filename), data);
|
||||
return writeFile(path.join(dirPath, filename), data);
|
||||
}
|
||||
|
||||
function isValidDirectoryName(name) {
|
||||
|
|
@ -45,7 +45,7 @@ export function storageManager(baseDir, storagePathPrefix, options) {
|
|||
isValidDirectoryName(element)
|
||||
);
|
||||
|
||||
const dirPath = join.apply(undefined, pathSegments);
|
||||
const dirPath = path.join.apply(undefined, pathSegments);
|
||||
return mkdir(dirPath, { recursive: true }).then(() => dirPath);
|
||||
},
|
||||
writeData(data, filename) {
|
||||
|
|
@ -63,7 +63,7 @@ export function storageManager(baseDir, storagePathPrefix, options) {
|
|||
return baseDir;
|
||||
},
|
||||
getFullPathToURLDir(url, alias) {
|
||||
return join(baseDir, pathToFolder(url, options, alias));
|
||||
return path.join(baseDir, pathToFolder(url, options, alias));
|
||||
},
|
||||
getStoragePrefix() {
|
||||
return storagePathPrefix;
|
||||
|
|
@ -76,14 +76,14 @@ export function storageManager(baseDir, storagePathPrefix, options) {
|
|||
},
|
||||
// TODO is missing alias
|
||||
removeDataForUrl(url) {
|
||||
const dirName = join(baseDir, pathToFolder(url, options));
|
||||
const dirName = path.join(baseDir, pathToFolder(url, options));
|
||||
const removeDir = async dir => {
|
||||
try {
|
||||
const files = await readdir(dir);
|
||||
await Promise.all(
|
||||
files.map(async file => {
|
||||
try {
|
||||
const p = join(dir, file);
|
||||
const p = path.join(dir, file);
|
||||
const stat = await lstat(p);
|
||||
await (stat.isDirectory() ? removeDir(p) : unlink(p));
|
||||
} catch (error) {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ const axe = require('axe-core').source;
|
|||
const clone = require('lodash.clonedeep');
|
||||
const log = require('intel').getLogger('sitespeedio.plugin.axe');
|
||||
|
||||
module.exports = async function (context) {
|
||||
module.exports = async function runAxe(context) {
|
||||
// Insert the axe source
|
||||
await context.selenium.driver.executeScript(axe);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { resolve } from 'node:path';
|
||||
import path from 'node:path';
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import intel from 'intel';
|
||||
|
|
@ -16,7 +16,10 @@ export default class AxePlugin extends SitespeedioPlugin {
|
|||
open(context, options) {
|
||||
this.options = options;
|
||||
this.make = context.messageMaker('axe').make;
|
||||
this.pug = readFileSync(resolve(__dirname, 'pug', 'index.pug'), 'utf8');
|
||||
this.pug = readFileSync(
|
||||
path.resolve(__dirname, 'pug', 'index.pug'),
|
||||
'utf8'
|
||||
);
|
||||
log.info(`Axe version %s plugin activated`, axeVersion);
|
||||
}
|
||||
|
||||
|
|
@ -26,7 +29,7 @@ export default class AxePlugin extends SitespeedioPlugin {
|
|||
case 'browsertime.setup': {
|
||||
queue.postMessage(
|
||||
make('browsertime.config', {
|
||||
postURLScript: resolve(__dirname, 'axePostScript.cjs')
|
||||
postURLScript: path.resolve(__dirname, 'axePostScript.cjs')
|
||||
})
|
||||
);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { resolve } from 'node:path';
|
||||
import path from 'node:path';
|
||||
import merge from 'lodash.merge';
|
||||
import forEach from 'lodash.foreach';
|
||||
import set from 'lodash.set';
|
||||
|
|
@ -105,7 +105,7 @@ async function parseUserScripts(scripts) {
|
|||
const allUserScripts = {};
|
||||
for (let script of scripts) {
|
||||
let myScript = await browserScripts.findAndParseScripts(
|
||||
resolve(script),
|
||||
path.resolve(script),
|
||||
'custom'
|
||||
);
|
||||
if (!myScript['custom']) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { readdir as _readdir } from 'node:fs';
|
||||
import { promisify } from 'node:util';
|
||||
import { join } from 'node:path';
|
||||
import path from 'node:path';
|
||||
const readdir = promisify(_readdir);
|
||||
import intel from 'intel';
|
||||
const log = intel.getLogger('sitespeedio.plugin.browsertime');
|
||||
|
|
@ -191,7 +191,7 @@ export async function getFilmstrip(
|
|||
if (browsertimeData) {
|
||||
metrics = getMetricsFromBrowsertime(browsertimeData);
|
||||
}
|
||||
const files = await readdir(join(dir, 'data', 'filmstrip', run + ''));
|
||||
const files = await readdir(path.join(dir, 'data', 'filmstrip', run + ''));
|
||||
const timings = [];
|
||||
for (let file of files) {
|
||||
timings.push({ time: file.replaceAll(/\D/g, ''), file });
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { createReadStream } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
import path from 'node:path';
|
||||
import { gunzip as _gunzip } from 'node:zlib';
|
||||
import { promisify } from 'node:util';
|
||||
const gunzip = promisify(_gunzip);
|
||||
|
|
@ -14,7 +14,7 @@ async function streamToString(stream) {
|
|||
}
|
||||
|
||||
export async function getGzippedFileAsJson(dir, file) {
|
||||
const readStream = createReadStream(join(dir, file));
|
||||
const readStream = createReadStream(path.join(dir, file));
|
||||
const text = await streamToString(readStream);
|
||||
const unzipped = await gunzip(text);
|
||||
return JSON.parse(unzipped.toString());
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
import { writeFileSync } from 'node:fs';
|
||||
import { join, resolve } from 'node:path';
|
||||
import path from 'node:path';
|
||||
|
||||
import intel from 'intel';
|
||||
const log = intel.getLogger('sitespeedio.plugin.budget');
|
||||
|
||||
export function writeJson(results, dir) {
|
||||
const file = join(dir, 'budgetResult.json');
|
||||
log.info('Write budget to %s', resolve(file));
|
||||
const file = path.join(dir, 'budgetResult.json');
|
||||
log.info('Write budget to %s', path.resolve(file));
|
||||
writeFileSync(file, JSON.stringify(results, undefined, 2));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { join, resolve } from 'node:path';
|
||||
import path from 'node:path';
|
||||
import { parse } from 'node:url';
|
||||
|
||||
import jrp from 'junit-report-builder';
|
||||
|
|
@ -63,7 +63,7 @@ export function writeJunit(results, dir, options) {
|
|||
}
|
||||
}
|
||||
}
|
||||
const file = join(dir, 'junit.xml');
|
||||
log.info('Write junit budget to %s', resolve(file));
|
||||
const file = path.join(dir, 'junit.xml');
|
||||
log.info('Write junit budget to %s', path.resolve(file));
|
||||
jrp.writeTo(file);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
import fs from 'node:fs/promises';
|
||||
import { join, resolve } from 'node:path';
|
||||
import path from 'node:path';
|
||||
|
||||
export async function getBaseline(id, compareOptions) {
|
||||
try {
|
||||
return JSON.parse(
|
||||
await fs.readFile(
|
||||
resolve(
|
||||
join(compareOptions.baselinePath || process.cwd(), `${id}.json`)
|
||||
path.resolve(
|
||||
path.join(compareOptions.baselinePath || process.cwd(), `${id}.json`)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
|
@ -16,5 +16,5 @@ export async function getBaseline(id, compareOptions) {
|
|||
}
|
||||
|
||||
export async function saveBaseline(json, name) {
|
||||
return fs.writeFile(resolve(name), JSON.stringify(json));
|
||||
return fs.writeFile(path.resolve(name), JSON.stringify(json));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import { fileURLToPath } from 'node:url';
|
||||
import { join } from 'node:path';
|
||||
import path from 'node:path';
|
||||
|
||||
import { execa } from 'execa';
|
||||
|
|
@ -32,7 +31,7 @@ export async function runStatisticalTests(data) {
|
|||
try {
|
||||
const { stdout } = await execa(
|
||||
process.env.PYTHON || 'python',
|
||||
[join(__dirname, 'statistical.py')],
|
||||
[path.join(__dirname, 'statistical.py')],
|
||||
{
|
||||
input: JSON.stringify(data)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { fileURLToPath } from 'node:url';
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { resolve, join } from 'node:path';
|
||||
import path from 'node:path';
|
||||
|
||||
import { SitespeedioPlugin } from '@sitespeed.io/plugin';
|
||||
import intel from 'intel';
|
||||
|
|
@ -71,7 +71,10 @@ export default class ComparePlugin extends SitespeedioPlugin {
|
|||
this.make = context.messageMaker('compare').make;
|
||||
this.compareOptions = merge({}, defaultConfig, options.compare);
|
||||
this.options = options;
|
||||
this.pug = readFileSync(resolve(__dirname, 'pug', 'index.pug'), 'utf8');
|
||||
this.pug = readFileSync(
|
||||
path.resolve(__dirname, 'pug', 'index.pug'),
|
||||
'utf8'
|
||||
);
|
||||
log.info(
|
||||
'Starting the compare plugin.' +
|
||||
(this.compareOptions.saveBaseline
|
||||
|
|
@ -260,7 +263,7 @@ export default class ComparePlugin extends SitespeedioPlugin {
|
|||
browsertime: this.browsertimes[url].data,
|
||||
pagexray: this.pageXrays[url].data
|
||||
},
|
||||
join(
|
||||
path.join(
|
||||
this.compareOptions.baselinePath || process.cwd(),
|
||||
`${id}-${this.page}.json`
|
||||
)
|
||||
|
|
@ -283,7 +286,7 @@ export default class ComparePlugin extends SitespeedioPlugin {
|
|||
browsertime: this.browsertimes[url].data,
|
||||
pagexray: this.pageXrays[url].data
|
||||
},
|
||||
join(
|
||||
path.join(
|
||||
this.compareOptions.baselinePath || process.cwd(),
|
||||
`${id}-${this.page}.json`
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { extname } from 'node:path';
|
||||
import path from 'node:path';
|
||||
import merge from 'lodash.merge';
|
||||
import intel from 'intel';
|
||||
import { SitespeedioPlugin } from '@sitespeed.io/plugin';
|
||||
|
|
@ -70,7 +70,7 @@ export default class CrawlerPlugin extends SitespeedioPlugin {
|
|||
}
|
||||
|
||||
crawler.addFetchCondition(queueItem => {
|
||||
const extension = extname(queueItem.path);
|
||||
const extension = path.extname(queueItem.path);
|
||||
// Don't try to download these, based on file name.
|
||||
if (['png', 'jpg', 'gif', 'pdf'].includes(extension)) {
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { readFileSync } from 'node:fs';
|
||||
import { resolve } from 'node:path';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
import intel from 'intel';
|
||||
|
|
@ -52,7 +52,10 @@ export default class CruxPlugin extends SitespeedioPlugin {
|
|||
this.formFactors = Array.isArray(this.options.formFactor)
|
||||
? this.options.formFactor
|
||||
: [this.options.formFactor];
|
||||
this.pug = readFileSync(resolve(__dirname, 'pug', 'index.pug'), 'utf8');
|
||||
this.pug = readFileSync(
|
||||
path.resolve(__dirname, 'pug', 'index.pug'),
|
||||
'utf8'
|
||||
);
|
||||
|
||||
if (this.options.collect === 'ALL' || this.options.collect === 'URL') {
|
||||
context.filterRegistry.registerFilterForType(
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { relative, join, resolve, sep } from 'node:path';
|
||||
import path from 'node:path';
|
||||
import fs from 'node:fs';
|
||||
|
||||
import { SitespeedioPlugin } from '@sitespeed.io/plugin';
|
||||
|
|
@ -61,8 +61,8 @@ async function uploadFile(
|
|||
baseDir,
|
||||
noCacheTime
|
||||
) {
|
||||
const subPath = relative(baseDir, file);
|
||||
const fileName = join(gcsOptions.path || prefix, subPath);
|
||||
const subPath = path.relative(baseDir, file);
|
||||
const fileName = path.join(gcsOptions.path || prefix, subPath);
|
||||
|
||||
const parameters = {
|
||||
public: !!gcsOptions.public,
|
||||
|
|
@ -112,8 +112,8 @@ export default class GcsPlugin extends SitespeedioPlugin {
|
|||
this.storageManager.getStoragePrefix()
|
||||
);
|
||||
if (this.options.copyLatestFilesToBase) {
|
||||
const rootPath = resolve(baseDir, '..');
|
||||
const directoriesAsArray = rootPath.split(sep);
|
||||
const rootPath = path.resolve(baseDir, '..');
|
||||
const directoriesAsArray = rootPath.split(path.sep);
|
||||
const rootName = directoriesAsArray.at(-1);
|
||||
await uploadLatestFiles(rootPath, gcsOptions, rootName);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// eslint-disable-next-line unicorn/import-style
|
||||
import util, { format } from 'node:util';
|
||||
import reduce from 'lodash.reduce';
|
||||
import {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { readFile as _readFile } from 'node:fs';
|
|||
import { promisify } from 'node:util';
|
||||
const readFile = promisify(_readFile);
|
||||
|
||||
export default async options => {
|
||||
export default async function getScripts(options) {
|
||||
const scripts = [];
|
||||
for (let file of options._) {
|
||||
// We could promise all these in the future
|
||||
|
|
@ -16,4 +16,4 @@ export default async options => {
|
|||
}
|
||||
}
|
||||
return scripts;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { join } from 'node:path';
|
||||
import path from 'node:path';
|
||||
import osName from 'os-name';
|
||||
import { promisify } from 'node:util';
|
||||
import { platform, hostname } from 'node:os';
|
||||
|
|
@ -486,7 +486,7 @@ export class HTMLBuilder {
|
|||
let res;
|
||||
res = this.options.html.assetsBaseURL
|
||||
? Promise.resolve()
|
||||
: this.storageManager.copyToResultDir(join(__dirname, 'assets'));
|
||||
: this.storageManager.copyToResultDir(path.join(__dirname, 'assets'));
|
||||
|
||||
return res.then(() =>
|
||||
Promise.allSettled(summaryRenders)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { resolve } from 'node:path';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
import { compileFile, compile } from 'pug';
|
||||
|
|
@ -6,7 +6,7 @@ import intel from 'intel';
|
|||
|
||||
const log = intel.getLogger('sitespeedio.plugin.html');
|
||||
const __dirname = fileURLToPath(new URL('.', import.meta.url));
|
||||
const basePath = resolve(__dirname, 'templates');
|
||||
const basePath = path.resolve(__dirname, 'templates');
|
||||
|
||||
const templateCache = {};
|
||||
|
||||
|
|
@ -18,7 +18,7 @@ function getTemplate(templateName) {
|
|||
return template;
|
||||
}
|
||||
|
||||
const filename = resolve(basePath, templateName);
|
||||
const filename = path.resolve(basePath, templateName);
|
||||
const renderedTemplate = compileFile(filename);
|
||||
|
||||
templateCache[templateName] = renderedTemplate;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ function row(stat, name, metricName, formatter) {
|
|||
};
|
||||
}
|
||||
|
||||
export default function (data) {
|
||||
export default function getDetailed(data) {
|
||||
if (!data) {
|
||||
return [];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ function _box(stat, name, label, formatter, url) {
|
|||
};
|
||||
}
|
||||
|
||||
export default function (data, html) {
|
||||
export default function parse(data, html) {
|
||||
if (!data) {
|
||||
return [];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { resolve, join } from 'node:path';
|
||||
import path from 'node:path';
|
||||
import { platform } from 'node:os';
|
||||
import { promisify } from 'node:util';
|
||||
|
||||
|
|
@ -52,7 +52,7 @@ export default class LatestStorerPlugin extends SitespeedioPlugin {
|
|||
const browserData = this.browserData;
|
||||
const baseDir = this.storageManager.getBaseDir();
|
||||
// Hack to get out of the date dir
|
||||
const newPath = resolve(baseDir, '..');
|
||||
const newPath = path.resolve(baseDir, '..');
|
||||
|
||||
// This is a hack to get the same name as in Grafana, meaning we can
|
||||
// generate the path to the URL there
|
||||
|
|
@ -85,7 +85,7 @@ export default class LatestStorerPlugin extends SitespeedioPlugin {
|
|||
);
|
||||
|
||||
imagePath = screenshot;
|
||||
const imageFullPath = join(baseDir, imagePath);
|
||||
const imageFullPath = path.join(baseDir, imagePath);
|
||||
await this.storageManager.copyFileToDir(
|
||||
imageFullPath,
|
||||
newPath +
|
||||
|
|
@ -105,7 +105,7 @@ export default class LatestStorerPlugin extends SitespeedioPlugin {
|
|||
}
|
||||
}
|
||||
if (options.browsertime && options.browsertime.video) {
|
||||
const videoFullPath = join(baseDir, message.data.video);
|
||||
const videoFullPath = path.join(baseDir, message.data.video);
|
||||
|
||||
await this.storageManager.copyFileToDir(
|
||||
videoFullPath,
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ function send(
|
|||
});
|
||||
}
|
||||
|
||||
export default async (host, room, accessToken, message) => {
|
||||
export default async function sendMatrix(host, room, accessToken, message) {
|
||||
const data = {
|
||||
msgtype: 'm.notice',
|
||||
body: '',
|
||||
|
|
@ -69,4 +69,4 @@ export default async (host, room, accessToken, message) => {
|
|||
formatted_body: message
|
||||
};
|
||||
return send(host, data, message, room, accessToken);
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { relative, join, sep } from 'node:path';
|
||||
import path from 'node:path';
|
||||
import { promises as fsPromises } from 'node:fs';
|
||||
|
||||
import readdir from 'recursive-readdir';
|
||||
|
|
@ -19,10 +19,10 @@ function ignoreDirectories(file, stats) {
|
|||
async function uploadFile(file, s3Client, s3Options, prefix, baseDir) {
|
||||
const stream = await fsPromises.readFile(file);
|
||||
const contentType = getContentType(file);
|
||||
const subPath = relative(baseDir, file);
|
||||
const subPath = path.relative(baseDir, file);
|
||||
const parameters = {
|
||||
Bucket: s3Options.bucketname,
|
||||
Key: join(s3Options.path || prefix, subPath),
|
||||
Key: path.join(s3Options.path || prefix, subPath),
|
||||
Body: stream,
|
||||
ContentType: contentType,
|
||||
ACL: s3Options.acl,
|
||||
|
|
@ -105,8 +105,8 @@ export default class S3Plugin extends SitespeedioPlugin {
|
|||
await Promise.all(uploadPromises);
|
||||
|
||||
if (this.options.copyLatestFilesToBase) {
|
||||
const rootPath = join(baseDir, '..');
|
||||
const directoriesAsArray = rootPath.split(sep);
|
||||
const rootPath = path.join(baseDir, '..');
|
||||
const directoriesAsArray = rootPath.split(path.sep);
|
||||
const rootName = directoriesAsArray.at(-1);
|
||||
const latestFiles = await readdir(rootPath, [ignoreDirectories]);
|
||||
const latestUploadPromises = latestFiles.map(file =>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { join, basename, resolve } from 'node:path';
|
||||
import path from 'node:path';
|
||||
import fs from 'node:fs';
|
||||
|
||||
import { SitespeedioPlugin } from '@sitespeed.io/plugin';
|
||||
|
|
@ -38,13 +38,13 @@ async function upload(dir, scpOptions, prefix) {
|
|||
for (let dir of directories) {
|
||||
fullPath += dir + '/';
|
||||
const doThePathExist = await client.exists(
|
||||
join(scpOptions.destinationPath, fullPath)
|
||||
path.join(scpOptions.destinationPath, fullPath)
|
||||
);
|
||||
if (!doThePathExist) {
|
||||
await client.mkdir(join(scpOptions.destinationPath, fullPath));
|
||||
await client.mkdir(path.join(scpOptions.destinationPath, fullPath));
|
||||
}
|
||||
}
|
||||
await client.uploadDir(dir, join(scpOptions.destinationPath, prefix));
|
||||
await client.uploadDir(dir, path.join(scpOptions.destinationPath, prefix));
|
||||
} catch (error) {
|
||||
log.error(error);
|
||||
throw error;
|
||||
|
|
@ -62,7 +62,7 @@ async function uploadFiles(files, scpOptions, prefix) {
|
|||
for (let file of files) {
|
||||
await client.uploadFile(
|
||||
file,
|
||||
join(scpOptions.destinationPath, prefix, basename(file))
|
||||
path.join(scpOptions.destinationPath, prefix, path.basename(file))
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
|
|
@ -119,7 +119,7 @@ export default class ScpPlugin extends SitespeedioPlugin {
|
|||
this.storageManager.getStoragePrefix()
|
||||
);
|
||||
if (this.options.copyLatestFilesToBase) {
|
||||
const rootPath = resolve(baseDir, '..');
|
||||
const rootPath = path.resolve(baseDir, '..');
|
||||
const prefix = this.storageManager.getStoragePrefix();
|
||||
const firstPart = prefix.split('/')[0];
|
||||
await uploadLatestFiles(rootPath, this.scpOptions, firstPart);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { resolve, join } from 'node:path';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import fs from 'node:fs';
|
||||
import zlib from 'node:zlib';
|
||||
|
|
@ -20,7 +20,9 @@ const fsp = fs.promises;
|
|||
const __dirname = fileURLToPath(new URL('.', import.meta.url));
|
||||
|
||||
const packageJson = JSON.parse(
|
||||
await fsp.readFile(resolve(join(__dirname, '..', '..', '..', 'package.json')))
|
||||
await fsp.readFile(
|
||||
path.resolve(path.join(__dirname, '..', '..', '..', 'package.json'))
|
||||
)
|
||||
);
|
||||
const co2Version = packageJson.dependencies['@tgwf/co2'];
|
||||
|
||||
|
|
@ -68,7 +70,7 @@ export default class SustainablePlugin extends SitespeedioPlugin {
|
|||
this.sustainableOptions = options.sustainable || {};
|
||||
this.make = context.messageMaker('sustainable').make;
|
||||
this.pug = await fsp.readFile(
|
||||
resolve(__dirname, 'pug', 'index.pug'),
|
||||
path.resolve(__dirname, 'pug', 'index.pug'),
|
||||
'utf8'
|
||||
);
|
||||
this.aggregator = new Aggregator(options);
|
||||
|
|
@ -116,7 +118,7 @@ export default class SustainablePlugin extends SitespeedioPlugin {
|
|||
case 'pagexray.run': {
|
||||
// We got data for a URL, lets calculate co2, check green servers etc
|
||||
const listOfDomains = Object.keys(message.data.domains);
|
||||
const greenDomainJSONpath = join(
|
||||
const greenDomainJSONpath = path.join(
|
||||
__dirname,
|
||||
'data',
|
||||
'url2green.json.gz'
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { platform, release } from 'node:os';
|
||||
import { env, version } from 'node:process';
|
||||
import { join, resolve } from 'node:path';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import fs from 'node:fs/promises';
|
||||
|
||||
|
|
@ -23,7 +23,7 @@ import * as scriptSource from './core/script-source.js';
|
|||
|
||||
const __dirname = fileURLToPath(new URL('.', import.meta.url));
|
||||
const packageJson = JSON.parse(
|
||||
await fs.readFile(resolve(join(__dirname, '..', 'package.json')))
|
||||
await fs.readFile(path.resolve(path.join(__dirname, '..', 'package.json')))
|
||||
);
|
||||
|
||||
const log = intel.getLogger('sitespeedio');
|
||||
|
|
@ -69,7 +69,10 @@ export async function run(options) {
|
|||
options.browsertime.tcpdump &&
|
||||
!env.SSLKEYLOGFILE
|
||||
) {
|
||||
env.SSLKEYLOGFILE = join(storageManager.getBaseDir(), 'SSLKEYLOGFILE.txt');
|
||||
env.SSLKEYLOGFILE = path.join(
|
||||
storageManager.getBaseDir(),
|
||||
'SSLKEYLOGFILE.txt'
|
||||
);
|
||||
}
|
||||
configure(options, logDir);
|
||||
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@
|
|||
"eslint": "9.6.0",
|
||||
"eslint-config-prettier": "9.1.0",
|
||||
"eslint-plugin-prettier": "5.1.3",
|
||||
"eslint-plugin-unicorn": "51.0.1",
|
||||
"eslint-plugin-unicorn": "54.0.0",
|
||||
"feed": "4.2.2",
|
||||
"jsdoc": "4.0.3",
|
||||
"license-checker": "^25.0.0",
|
||||
|
|
@ -953,9 +953,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@babel/helper-validator-identifier": {
|
||||
"version": "7.22.20",
|
||||
"resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.20.tgz",
|
||||
"integrity": "sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==",
|
||||
"version": "7.24.7",
|
||||
"resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.24.7.tgz",
|
||||
"integrity": "sha512-rR+PBcQ1SMQDDyF6X0wxtG8QyLCgUB0eRAGguqRLfkCA87l7yAP7ehq8SNj96OOGTO8OBV70KhuFYcIkHXOg0w==",
|
||||
"engines": {
|
||||
"node": ">=6.9.0"
|
||||
}
|
||||
|
|
@ -1170,15 +1170,15 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@eslint/eslintrc": {
|
||||
"version": "2.1.4",
|
||||
"resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.4.tgz",
|
||||
"integrity": "sha512-269Z39MS6wVJtsoUl10L60WdkhJVdPG24Q4eZTH3nnF6lpvSShEK3wQjDX9JRWAUPvPh7COouPpU9IrqaZFvtQ==",
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-3.1.0.tgz",
|
||||
"integrity": "sha512-4Bfj15dVJdoy3RfZmmo86RK1Fwzn6SstsvK9JS+BaVKqC6QQQQyXekNaC+g+LKNgkQ+2VhGAzm6hO40AhMR3zQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"ajv": "^6.12.4",
|
||||
"debug": "^4.3.2",
|
||||
"espree": "^9.6.0",
|
||||
"globals": "^13.19.0",
|
||||
"espree": "^10.0.1",
|
||||
"globals": "^14.0.0",
|
||||
"ignore": "^5.2.0",
|
||||
"import-fresh": "^3.2.1",
|
||||
"js-yaml": "^4.1.0",
|
||||
|
|
@ -1186,7 +1186,7 @@
|
|||
"strip-json-comments": "^3.1.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/eslint"
|
||||
|
|
@ -5071,17 +5071,17 @@
|
|||
}
|
||||
},
|
||||
"node_modules/eslint-plugin-unicorn": {
|
||||
"version": "51.0.1",
|
||||
"resolved": "https://registry.npmjs.org/eslint-plugin-unicorn/-/eslint-plugin-unicorn-51.0.1.tgz",
|
||||
"integrity": "sha512-MuR/+9VuB0fydoI0nIn2RDA5WISRn4AsJyNSaNKLVwie9/ONvQhxOBbkfSICBPnzKrB77Fh6CZZXjgTt/4Latw==",
|
||||
"version": "54.0.0",
|
||||
"resolved": "https://registry.npmjs.org/eslint-plugin-unicorn/-/eslint-plugin-unicorn-54.0.0.tgz",
|
||||
"integrity": "sha512-XxYLRiYtAWiAjPv6z4JREby1TAE2byBC7wlh0V4vWDCpccOSU1KovWV//jqPXF6bq3WKxqX9rdjoRQ1EhdmNdQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@babel/helper-validator-identifier": "^7.22.20",
|
||||
"@babel/helper-validator-identifier": "^7.24.5",
|
||||
"@eslint-community/eslint-utils": "^4.4.0",
|
||||
"@eslint/eslintrc": "^2.1.4",
|
||||
"@eslint/eslintrc": "^3.0.2",
|
||||
"ci-info": "^4.0.0",
|
||||
"clean-regexp": "^1.0.0",
|
||||
"core-js-compat": "^3.34.0",
|
||||
"core-js-compat": "^3.37.0",
|
||||
"esquery": "^1.5.0",
|
||||
"indent-string": "^4.0.0",
|
||||
"is-builtin-module": "^3.2.1",
|
||||
|
|
@ -5090,11 +5090,11 @@
|
|||
"read-pkg-up": "^7.0.1",
|
||||
"regexp-tree": "^0.1.27",
|
||||
"regjsparser": "^0.10.0",
|
||||
"semver": "^7.5.4",
|
||||
"semver": "^7.6.1",
|
||||
"strip-indent": "^3.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16"
|
||||
"node": ">=18.18"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sindresorhus/eslint-plugin-unicorn?sponsor=1"
|
||||
|
|
@ -5113,13 +5113,10 @@
|
|||
}
|
||||
},
|
||||
"node_modules/eslint-plugin-unicorn/node_modules/semver": {
|
||||
"version": "7.6.0",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz",
|
||||
"integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==",
|
||||
"version": "7.6.2",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-7.6.2.tgz",
|
||||
"integrity": "sha512-FNAIBWCx9qcRhoHcgcJ0gvU7SN1lYU2ZXuSfl04bSC5OpvDHFyJCjdNHomPXxjQlCBU67YW64PzY7/VIEH7F2w==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"lru-cache": "^6.0.0"
|
||||
},
|
||||
"bin": {
|
||||
"semver": "bin/semver.js"
|
||||
},
|
||||
|
|
@ -5155,41 +5152,6 @@
|
|||
"url": "https://opencollective.com/eslint"
|
||||
}
|
||||
},
|
||||
"node_modules/eslint/node_modules/@eslint/eslintrc": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-3.1.0.tgz",
|
||||
"integrity": "sha512-4Bfj15dVJdoy3RfZmmo86RK1Fwzn6SstsvK9JS+BaVKqC6QQQQyXekNaC+g+LKNgkQ+2VhGAzm6hO40AhMR3zQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"ajv": "^6.12.4",
|
||||
"debug": "^4.3.2",
|
||||
"espree": "^10.0.1",
|
||||
"globals": "^14.0.0",
|
||||
"ignore": "^5.2.0",
|
||||
"import-fresh": "^3.2.1",
|
||||
"js-yaml": "^4.1.0",
|
||||
"minimatch": "^3.1.2",
|
||||
"strip-json-comments": "^3.1.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/eslint"
|
||||
}
|
||||
},
|
||||
"node_modules/eslint/node_modules/acorn": {
|
||||
"version": "8.12.1",
|
||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.12.1.tgz",
|
||||
"integrity": "sha512-tcpGyI9zbizT9JbV6oYE477V6mTlXvvi0T0G3SNIYE2apm/G5huBa1+K89VGeovbg+jycCrfhl3ADxErOuO6Jg==",
|
||||
"dev": true,
|
||||
"bin": {
|
||||
"acorn": "bin/acorn"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/eslint/node_modules/ansi-regex": {
|
||||
"version": "5.0.1",
|
||||
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz",
|
||||
|
|
@ -5254,23 +5216,6 @@
|
|||
"url": "https://opencollective.com/eslint"
|
||||
}
|
||||
},
|
||||
"node_modules/eslint/node_modules/espree": {
|
||||
"version": "10.1.0",
|
||||
"resolved": "https://registry.npmjs.org/espree/-/espree-10.1.0.tgz",
|
||||
"integrity": "sha512-M1M6CpiE6ffoigIOWYO9UDP8TMUw9kqb21tf+08IgDYjCsOvCuDt4jQcZmoYxx+w7zlKw9/N0KXfto+I8/FrXA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"acorn": "^8.12.0",
|
||||
"acorn-jsx": "^5.3.2",
|
||||
"eslint-visitor-keys": "^4.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/eslint"
|
||||
}
|
||||
},
|
||||
"node_modules/eslint/node_modules/find-up": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz",
|
||||
|
|
@ -5299,18 +5244,6 @@
|
|||
"node": ">=10.13.0"
|
||||
}
|
||||
},
|
||||
"node_modules/eslint/node_modules/globals": {
|
||||
"version": "14.0.0",
|
||||
"resolved": "https://registry.npmjs.org/globals/-/globals-14.0.0.tgz",
|
||||
"integrity": "sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/eslint/node_modules/locate-path": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz",
|
||||
|
|
@ -5377,18 +5310,6 @@
|
|||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/eslint/node_modules/strip-json-comments": {
|
||||
"version": "3.1.1",
|
||||
"resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz",
|
||||
"integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/eslint/node_modules/supports-color": {
|
||||
"version": "7.2.0",
|
||||
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
|
||||
|
|
@ -5421,26 +5342,26 @@
|
|||
"integrity": "sha512-dzlvlNlt6AXU7EBSfpAscydQ7gXB+pPGsPnfJnZpiNJBDj7IaJzQlBZYGdEi4R9HmPdBv2XmWJ6YUtoTa7lmCw=="
|
||||
},
|
||||
"node_modules/espree": {
|
||||
"version": "9.6.1",
|
||||
"resolved": "https://registry.npmjs.org/espree/-/espree-9.6.1.tgz",
|
||||
"integrity": "sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ==",
|
||||
"version": "10.1.0",
|
||||
"resolved": "https://registry.npmjs.org/espree/-/espree-10.1.0.tgz",
|
||||
"integrity": "sha512-M1M6CpiE6ffoigIOWYO9UDP8TMUw9kqb21tf+08IgDYjCsOvCuDt4jQcZmoYxx+w7zlKw9/N0KXfto+I8/FrXA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"acorn": "^8.9.0",
|
||||
"acorn": "^8.12.0",
|
||||
"acorn-jsx": "^5.3.2",
|
||||
"eslint-visitor-keys": "^3.4.1"
|
||||
"eslint-visitor-keys": "^4.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/eslint"
|
||||
}
|
||||
},
|
||||
"node_modules/espree/node_modules/acorn": {
|
||||
"version": "8.11.3",
|
||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz",
|
||||
"integrity": "sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==",
|
||||
"version": "8.12.1",
|
||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.12.1.tgz",
|
||||
"integrity": "sha512-tcpGyI9zbizT9JbV6oYE477V6mTlXvvi0T0G3SNIYE2apm/G5huBa1+K89VGeovbg+jycCrfhl3ADxErOuO6Jg==",
|
||||
"dev": true,
|
||||
"bin": {
|
||||
"acorn": "bin/acorn"
|
||||
|
|
@ -5449,6 +5370,18 @@
|
|||
"node": ">=0.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/espree/node_modules/eslint-visitor-keys": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.0.0.tgz",
|
||||
"integrity": "sha512-OtIRv/2GyiF6o/d8K7MYKKbXrOUBIK6SfkIRM4Z0dY3w+LiQ0vy3F57m0Z71bjbyeiWFiHJ8brqnmE6H6/jEuw==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/eslint"
|
||||
}
|
||||
},
|
||||
"node_modules/esprima": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz",
|
||||
|
|
@ -6284,15 +6217,12 @@
|
|||
}
|
||||
},
|
||||
"node_modules/globals": {
|
||||
"version": "13.24.0",
|
||||
"resolved": "https://registry.npmjs.org/globals/-/globals-13.24.0.tgz",
|
||||
"integrity": "sha512-AhO5QUcj8llrbG09iWhPU2B204J1xnPeL8kQmVorSsy+Sjj1sk8gIyh6cUocGmH4L0UuhAJy+hJMRA4mgA4mFQ==",
|
||||
"version": "14.0.0",
|
||||
"resolved": "https://registry.npmjs.org/globals/-/globals-14.0.0.tgz",
|
||||
"integrity": "sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"type-fest": "^0.20.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
"node": ">=18"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
|
|
@ -11090,18 +11020,6 @@
|
|||
"node": ">= 0.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/type-fest": {
|
||||
"version": "0.20.2",
|
||||
"resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz",
|
||||
"integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/typed-array-buffer": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/typed-array-buffer/-/typed-array-buffer-1.0.2.tgz",
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@
|
|||
"eslint": "9.6.0",
|
||||
"eslint-config-prettier": "9.1.0",
|
||||
"eslint-plugin-prettier": "5.1.3",
|
||||
"eslint-plugin-unicorn": "51.0.1",
|
||||
"eslint-plugin-unicorn": "54.0.0",
|
||||
"feed": "4.2.2",
|
||||
"jsdoc": "4.0.3",
|
||||
"license-checker": "^25.0.0",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { Feed } from 'feed';
|
||||
import { readdirSync, statSync, readFileSync, writeFileSync } from 'node:fs';
|
||||
import { parse, join } from 'node:path';
|
||||
import path from 'node:path';
|
||||
import parseChangelog from 'changelog-parser';
|
||||
import { marked } from 'marked';
|
||||
|
||||
|
|
@ -25,7 +25,7 @@ const getSortedFiles = dir => {
|
|||
return files
|
||||
.map(fileName => ({
|
||||
fileName: fileName,
|
||||
name: parse(fileName).name,
|
||||
name: path.parse(fileName).name,
|
||||
time: statSync(`${dir}/${fileName}`).mtime.getTime(),
|
||||
version: readFileSync(`${dir}/${fileName}`, 'utf8').trim()
|
||||
}))
|
||||
|
|
@ -165,9 +165,12 @@ async function generateFeed() {
|
|||
|
||||
const documentPath = './docs/';
|
||||
|
||||
writeFileSync(join(documentPath, 'feed', `${tool.name}.rss`), feed.rss2());
|
||||
writeFileSync(
|
||||
join(documentPath, 'feed', `${tool.name}.atom`),
|
||||
path.join(documentPath, 'feed', `${tool.name}.rss`),
|
||||
feed.rss2()
|
||||
);
|
||||
writeFileSync(
|
||||
path.join(documentPath, 'feed', `${tool.name}.atom`),
|
||||
feed.atom1()
|
||||
);
|
||||
}
|
||||
|
|
@ -183,8 +186,8 @@ async function generateFeed() {
|
|||
|
||||
const documentPath = './docs/';
|
||||
|
||||
writeFileSync(join(documentPath, 'feed', `rss.xml`), allFeed.rss2());
|
||||
writeFileSync(join(documentPath, 'feed', `atom.xml`), allFeed.atom1());
|
||||
writeFileSync(path.join(documentPath, 'feed', `rss.xml`), allFeed.rss2());
|
||||
writeFileSync(path.join(documentPath, 'feed', `atom.xml`), allFeed.atom1());
|
||||
}
|
||||
|
||||
await generateFeed();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import test from 'ava';
|
||||
import { join, resolve } from 'node:path';
|
||||
import path from 'node:path';
|
||||
import { promisify } from 'node:util';
|
||||
import { execFile as _execFile } from 'node:child_process';
|
||||
const execFile = promisify(_execFile);
|
||||
|
|
@ -9,7 +9,7 @@ import { fileURLToPath } from 'node:url';
|
|||
const __dirname = fileURLToPath(new URL('.', import.meta.url));
|
||||
|
||||
function runSitespeed(options = []) {
|
||||
const cli = join(resolve(__dirname), '../bin/sitespeed.js');
|
||||
const cli = path.join(path.resolve(__dirname), '../bin/sitespeed.js');
|
||||
return execFile('node', [cli].concat(options));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
import test from 'ava';
|
||||
import { CoachAggregator } from '../lib/plugins/coach/aggregator.js';
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { resolve } from 'node:path';
|
||||
import path from 'node:path';
|
||||
|
||||
import { fileURLToPath } from 'node:url';
|
||||
const __dirname = fileURLToPath(new URL('.', import.meta.url));
|
||||
|
||||
const coachRunPath = resolve(__dirname, 'fixtures', 'coach.run-0.json');
|
||||
const coachRunPath = path.resolve(__dirname, 'fixtures', 'coach.run-0.json');
|
||||
const coachRun = JSON.parse(readFileSync(coachRunPath, 'utf8'));
|
||||
|
||||
test(`Should summarize Coach data`, t => {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { readFileSync } from 'node:fs';
|
||||
import { resolve } from 'node:path';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
import test from 'ava';
|
||||
|
|
@ -9,7 +9,10 @@ import { DomainsAggregator } from '../lib/plugins/domains/aggregator.js';
|
|||
const __dirname = fileURLToPath(new URL('.', import.meta.url));
|
||||
|
||||
const har = JSON.parse(
|
||||
readFileSync(resolve(__dirname, 'fixtures', 'www-theverge-com.har'), 'utf8')
|
||||
readFileSync(
|
||||
path.resolve(__dirname, 'fixtures', 'www-theverge-com.har'),
|
||||
'utf8'
|
||||
)
|
||||
);
|
||||
|
||||
test(`Should summarize data per domain`, t => {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { resolve } from 'node:path';
|
||||
import path from 'node:path';
|
||||
import { readFileSync } from 'node:fs';
|
||||
|
||||
import test from 'ava';
|
||||
|
|
@ -13,7 +13,7 @@ import { getSummary } from '../lib/plugins/slack/summary.js';
|
|||
import { fileURLToPath } from 'node:url';
|
||||
const __dirname = fileURLToPath(new URL('.', import.meta.url));
|
||||
|
||||
const coachRunPath = resolve(__dirname, 'fixtures', 'coach.run-0.json');
|
||||
const coachRunPath = path.resolve(__dirname, 'fixtures', 'coach.run-0.json');
|
||||
const coachRun = JSON.parse(readFileSync(coachRunPath, 'utf8'));
|
||||
|
||||
import { DataCollector } from '../lib/plugins/slack/dataCollector.js';
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { resolve, join } from 'node:path';
|
||||
import path from 'node:path';
|
||||
|
||||
import dayjs from 'dayjs';
|
||||
import test from 'ava';
|
||||
|
|
@ -30,7 +30,7 @@ test(`Create base dir with default output folder`, t => {
|
|||
const storageManager = createManager('http://www.foo.bar');
|
||||
t.is(
|
||||
storageManager.getBaseDir(),
|
||||
resolve('sitespeed-result', 'www.foo.bar', timestampString)
|
||||
path.resolve('sitespeed-result', 'www.foo.bar', timestampString)
|
||||
);
|
||||
});
|
||||
|
||||
|
|
@ -44,7 +44,10 @@ test(`Create base dir with custom output folder`, t => {
|
|||
|
||||
test(`Create prefix with default output folder`, t => {
|
||||
const storageManager = createManager('http://www.foo.bar');
|
||||
t.is(storageManager.getStoragePrefix(), join('www.foo.bar', timestampString));
|
||||
t.is(
|
||||
storageManager.getStoragePrefix(),
|
||||
path.join('www.foo.bar', timestampString)
|
||||
);
|
||||
});
|
||||
|
||||
test(`Create prefix with custom output folder`, t => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue