Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

misc: rename lighthouse-core to core #13303

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 3 additions & 3 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
**/third_party/**
**/source-maps/**

lighthouse-cli/test/fixtures/byte-efficiency/bundle.js
cli/test/fixtures/byte-efficiency/bundle.js

/dist/**

coverage/**

!.eslintrc.js

lighthouse-core/lib/cdt/generated/SourceMap.js
lighthouse-core/scripts/legacy-javascript/variants
core/lib/cdt/generated/SourceMap.js
core/scripts/legacy-javascript/variants

third-party/**

Expand Down
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ module.exports = {
},
overrides: [
{
files: ['lighthouse-cli/test/smokehouse/**/*expectations.js'],
files: ['cli/test/smokehouse/**/*expectations.js'],
rules: {
'max-len': 0,
},
Expand Down
2 changes: 1 addition & 1 deletion .github/scripts/bump-nightly-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ set -euxo pipefail

DATE=$(date --date=yesterday '+%Y%m%d')
PATCH=$(node -e "console.log(require('./package.json').version)")
node lighthouse-core/scripts/release/bump-versions.js "$PATCH-dev.$DATE"
node core/scripts/release/bump-versions.js "$PATCH-dev.$DATE"
2 changes: 1 addition & 1 deletion .github/scripts/generate-devtools-hash.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ md5 \
build/build-dt-report-resources.js \
clients/devtools-entry.js \
clients/devtools-report-assets.js \
lighthouse-core/test/chromium-web-tests/* \
core/test/chromium-web-tests/* \
third-party/chromium-webtests/webtests/http/tests/devtools/lighthouse/*.js
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
uses: actions/checkout@v2
with:
fetch-depth: 100
- run: bash lighthouse-core/scripts/github-actions-commit-range.sh
- run: bash core/scripts/github-actions-commit-range.sh
env:
GITHUB_CONTEXT_PR_BASE_SHA: ${{ github.event.pull_request.base.sha }}
GITHUB_CONTEXT_BASE_SHA: ${{ github.event.before }}
Expand Down Expand Up @@ -49,7 +49,7 @@ jobs:
- run: yarn test-legacy-javascript
- run: yarn i18n:checks
- run: yarn dogfood-lhci
- run: bash lighthouse-core/scripts/copy-util-commonjs.sh
- run: bash core/scripts/copy-util-commonjs.sh

# Fail if any changes were written to any source files or generated untracked files (ex, from: build/build-cdt-lib.js).
- run: git add -A && git diff --cached --exit-code
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/devtools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,19 @@ jobs:
working-directory: ${{ github.workspace }}/lighthouse

- name: Download depot tools
run: bash $GITHUB_WORKSPACE/lighthouse/lighthouse-core/test/chromium-web-tests/download-depot-tools.sh
run: bash $GITHUB_WORKSPACE/lighthouse/core/test/chromium-web-tests/download-depot-tools.sh
- name: Download DevTools Frontend
run: bash $GITHUB_WORKSPACE/lighthouse/lighthouse-core/test/chromium-web-tests/download-devtools.sh
run: bash $GITHUB_WORKSPACE/lighthouse/core/test/chromium-web-tests/download-devtools.sh
- name: Download Blink Tools
run: bash $GITHUB_WORKSPACE/lighthouse/lighthouse-core/test/chromium-web-tests/download-blink-tools.sh
run: bash $GITHUB_WORKSPACE/lighthouse/core/test/chromium-web-tests/download-blink-tools.sh
- name: Download Content Shell
run: bash $GITHUB_WORKSPACE/lighthouse/lighthouse-core/test/chromium-web-tests/download-content-shell.sh
run: bash $GITHUB_WORKSPACE/lighthouse/core/test/chromium-web-tests/download-content-shell.sh

- name: Install python deps
run: pip install six requests

- name: Run Web Tests
run: bash $GITHUB_WORKSPACE/lighthouse/lighthouse-core/test/chromium-web-tests/run-web-tests.sh
run: bash $GITHUB_WORKSPACE/lighthouse/core/test/chromium-web-tests/run-web-tests.sh

- name: Print diff
if: failure()
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/package-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- run: yarn build-report
- run: sudo apt-get install xvfb

- run: xvfb-run --auto-servernum bash $GITHUB_WORKSPACE/lighthouse-core/scripts/release/package-test.sh
- run: xvfb-run --auto-servernum bash $GITHUB_WORKSPACE/core/scripts/release/package-test.sh

# Fail if any changes were written to source files.
- run: git diff --exit-code
2 changes: 1 addition & 1 deletion .github/workflows/smoke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
- name: Install Chrome ToT
if: matrix.chrome-channel == 'ToT'
working-directory: /home/runner
run: bash $GITHUB_WORKSPACE/lighthouse-core/scripts/download-chrome.sh && mv chrome-linux chrome-linux-tot
run: bash $GITHUB_WORKSPACE/core/scripts/download-chrome.sh && mv chrome-linux chrome-linux-tot

- run: yarn install --frozen-lockfile --network-timeout 1000000
- run: yarn build-report
Expand Down
20 changes: 10 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ lcov.info
.nyc_output
*.lcov

lighthouse-cli/results
cli/results
results.html
last-run-results.html

Expand All @@ -27,16 +27,16 @@ last-run-results.html
*.artifacts.log
*.ctc.json

!lighthouse-core/test/results/artifacts/*.trace.json
!lighthouse-core/test/results/artifacts/*.devtoolslog.json
!lighthouse-core/test/fixtures/artifacts/**/*.trace.json
!lighthouse-core/test/fixtures/artifacts/**/*.devtoolslog.json
!lighthouse-core/test/fixtures/traces/**/*.trace.json
!lighthouse-core/test/fixtures/traces/**/*.devtoolslog.json
!lighthouse-core/test/fixtures/config/**/node_modules
!core/test/results/artifacts/*.trace.json
!core/test/results/artifacts/*.devtoolslog.json
!core/test/fixtures/artifacts/**/*.trace.json
!core/test/fixtures/artifacts/**/*.devtoolslog.json
!core/test/fixtures/traces/**/*.trace.json
!core/test/fixtures/traces/**/*.devtoolslog.json
!core/test/fixtures/config/**/node_modules

lighthouse-core/scripts/legacy-javascript/variants
lighthouse-core/scripts/gcp-collection/gcp-data
core/scripts/legacy-javascript/variants
core/scripts/gcp-collection/gcp-data

latest-run
lantern-data
Expand Down
20 changes: 10 additions & 10 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,25 @@ coverage/
proto/
docs/

lighthouse-core/lib/sd-validation/
lighthouse-core/scripts/*
lighthouse-core/test/
lighthouse-core/third_party/src/
core/lib/sd-validation/
core/scripts/*
core/test/
core/third_party/src/
viewer/
treemap/
clients/
lighthouse-cli/results/
cli/results/
lighthouse-logger/

# keep a few scripts useful for CI
!lighthouse-core/scripts/manual-chrome-launcher.js
!lighthouse-core/scripts/download-chrome.sh
!core/scripts/manual-chrome-launcher.js
!core/scripts/download-chrome.sh

# Exclude the CLI smoketests but keep the smoketest runner that is used
# by downstream projects (e.g. publisher ads).
lighthouse-cli/test/*
!lighthouse-cli/test/smokehouse/
lighthouse-cli/test/smokehouse/test-definitions/
cli/test/*
!cli/test/smokehouse/
cli/test/smokehouse/test-definitions/

results/
lantern-data/
Expand Down
22 changes: 11 additions & 11 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ If proposing a new audit for Lighthouse, see the [new audit proposal guide](./do

A PR for a new audit or changing an existing audit almost always needs the following:

1. If new, add the audit to the [default config file](lighthouse-core/config/default-config.js) (or, rarely, one of the other config files) so Lighthouse will run it.
1. If new, add the audit to the [default config file](core/config/default-config.js) (or, rarely, one of the other config files) so Lighthouse will run it.

1. **Unit tests**: in the matching test file (e.g. tests for `lighthouse-core/audits/my-swell-audit.js` go in `lighthouse-core/test/audits/my-swell-audit-test.js`).
1. **Unit tests**: in the matching test file (e.g. tests for `core/audits/my-swell-audit.js` go in `core/test/audits/my-swell-audit-test.js`).

1. **Smoke (end-to-end) tests**: search through the [existing test expectations](lighthouse-cli/test/smokehouse/test-definitions/) to see if there's a logical place to add a check for your change, or (as a last resort) add a new smoke test.
1. **Smoke (end-to-end) tests**: search through the [existing test expectations](cli/test/smokehouse/test-definitions/) to see if there's a logical place to add a check for your change, or (as a last resort) add a new smoke test.

1. Run `yarn update:sample-json` to update the [sample Lighthouse result JSON](lighthouse-core/test/results/sample_v2.json) kept in the repo for testing. This will also pull any strings needed for localization into the correct files.
1. Run `yarn update:sample-json` to update the [sample Lighthouse result JSON](core/test/results/sample_v2.json) kept in the repo for testing. This will also pull any strings needed for localization into the correct files.

### Audit `description` Guidelines

Expand Down Expand Up @@ -68,13 +68,13 @@ It can be tempting to serialize the entire state of the world into the artifact

A PR adding or changing a gatherer almost always needs to include the following:

1. If new, add the gatherer to the [default config file](lighthouse-core/config/default-config.js) (or, rarely, one of the other config files) so Lighthouse will run it.
1. If new, add the gatherer to the [default config file](core/config/default-config.js) (or, rarely, one of the other config files) so Lighthouse will run it.

1. **Unit tests**: gatherer execution often takes place mostly on the browser side, either through protocol functionality or executing javascript in the test page. This makes gatherers difficult to unit test without extensive mocking, ending up mostly exercising the mocks instead of the actual gatherer.

As a result, we mostly rely on smoke testing for gatherers. However, if there are parts of a gatherer that naturally lend themselves to unit testing, the new tests would go in the matching test file (e.g. tests for `lighthouse-core/gather/gatherers/reap.js` go in `lighthouse-core/test/gather/gatherers/reap-test.js`).
As a result, we mostly rely on smoke testing for gatherers. However, if there are parts of a gatherer that naturally lend themselves to unit testing, the new tests would go in the matching test file (e.g. tests for `core/gather/gatherers/reap.js` go in `core/test/gather/gatherers/reap-test.js`).

1. **Smoke (end-to-end) tests**: search through the [existing test expectations](lighthouse-cli/test/smokehouse/test-definitions/) to see if there's a logical place to add a check for your change, or (as a last resort) add a new smoke test if one is required.
1. **Smoke (end-to-end) tests**: search through the [existing test expectations](cli/test/smokehouse/test-definitions/) to see if there's a logical place to add a check for your change, or (as a last resort) add a new smoke test if one is required.

It's most important to get true end-to-end coverage, so be sure that audits that consume the new gatherer output are in the expectations. Artifacts can also have expectations for those intermediate results.

Expand All @@ -87,7 +87,7 @@ A PR adding or changing a gatherer almost always needs to include the following:

This command works for updating `yarn update:sample-artifacts devtoolsLogs` or `traces` as well, but the resulting `sample_v2.json` churn may be extensive and you might be better off editing manually.

1. Run `yarn update:sample-json` to update the [sample Lighthouse result JSON](lighthouse-core/test/results/sample_v2.json) kept in the repo for testing. This will also pull any strings needed for localization into the correct files.
1. Run `yarn update:sample-json` to update the [sample Lighthouse result JSON](core/test/results/sample_v2.json) kept in the repo for testing. This will also pull any strings needed for localization into the correct files.

## Protobuf errors

Expand Down Expand Up @@ -128,13 +128,13 @@ accept your pull requests.

## Tracking Errors

We track our errors in the wild with Sentry. In general, do not worry about wrapping your audits or gatherers in try/catch blocks and reporting every error that could possibly occur; `lighthouse-core/runner.js` and `lighthouse-core/gather/gather-runner.js` already catch and report any errors that occur while running a gatherer or audit, including errors fatal to the entire run. However, there are some situations when you might want to explicitly handle an error and report it to Sentry or wrap it to avoid reporting. Generally, you can interact with Sentry simply by requiring the `lighthouse-core/lib/sentry.js` file and call its methods. The module exports a delegate that will correctly handle the error reporting based on the user's opt-in preference and will simply no-op if they haven't so you don't need to check.
We track our errors in the wild with Sentry. In general, do not worry about wrapping your audits or gatherers in try/catch blocks and reporting every error that could possibly occur; `core/runner.js` and `core/gather/gather-runner.js` already catch and report any errors that occur while running a gatherer or audit, including errors fatal to the entire run. However, there are some situations when you might want to explicitly handle an error and report it to Sentry or wrap it to avoid reporting. Generally, you can interact with Sentry simply by requiring the `core/lib/sentry.js` file and call its methods. The module exports a delegate that will correctly handle the error reporting based on the user's opt-in preference and will simply no-op if they haven't so you don't need to check.


#### If you have an expected error that is recoverable but want to track how frequently it happens, *use Sentry.captureException*.

```js
const Sentry = require('./lighthouse-core/lib/sentry');
const Sentry = require('./core/lib/sentry');

try {
doRiskyThing();
Expand All @@ -152,7 +152,7 @@ try {
NOTE: If the message you're capturing is dynamic/based on user data or you need a stack trace, then create a fake error instead and use `Sentry.captureException` so that the instances will be grouped together in Sentry.

```js
const Sentry = require('./lighthouse-core/lib/sentry');
const Sentry = require('./core/lib/sentry');

if (networkRecords.length === 1) {
Sentry.captureMessage('Site only had 1 network request', {level: 'info'});
Expand Down
8 changes: 4 additions & 4 deletions build/build-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const fs = require('fs');
const path = require('path');
const rollup = require('rollup');
const rollupPlugins = require('./rollup-plugins.js');
const Runner = require('../lighthouse-core/runner.js');
const Runner = require('../core/runner.js');
const {LH_ROOT} = require('../root.js');

const COMMIT_HASH = require('child_process')
Expand Down Expand Up @@ -97,7 +97,7 @@ async function build(entryPath, distPath, opts = {minify: true}) {
'raven',
'source-map',
'ws',
require.resolve('../lighthouse-core/gather/connections/cri.js'),
require.resolve('../core/gather/connections/cri.js'),
];

// Don't include the stringified report in DevTools - see devtools-report-assets.js
Expand Down Expand Up @@ -142,14 +142,14 @@ async function build(entryPath, distPath, opts = {minify: true}) {
entries: {
'debug': require.resolve('debug/src/browser.js'),
'lighthouse-logger': require.resolve('../lighthouse-logger/index.js'),
'url': require.resolve('../lighthouse-core/lib/url-shim.js'),
'url': require.resolve('../core/lib/url-shim.js'),
},
}),
rollupPlugins.shim({
...shimsObj,
// Allows for plugins to import lighthouse.
'lighthouse': `
import Audit from '${require.resolve('../lighthouse-core/audits/audit.js')}';
import Audit from '${require.resolve('../core/audits/audit.js')}';
export {Audit};
`,
}),
Expand Down
2 changes: 1 addition & 1 deletion build/build-cdt-lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const fs = require('fs');
const ts = require('typescript');
const {LH_ROOT} = require('../root.js');

const outDir = `${LH_ROOT}/lighthouse-core/lib/cdt/generated`;
const outDir = `${LH_ROOT}/core/lib/cdt/generated`;
const files = {
'node_modules/chrome-devtools-frontend/front_end/core/sdk/SourceMap.ts': 'SourceMap.js',
};
Expand Down
2 changes: 1 addition & 1 deletion build/build-lightrider-bundles.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function buildReportGenerator() {

async function buildStaticServerBundle() {
const bundle = await rollup.rollup({
input: 'lighthouse-cli/test/fixtures/static-server.js',
input: 'cli/test/fixtures/static-server.js',
plugins: [
rollupPlugins.shim({
'es-main': 'export default function() { return false; }',
Expand Down
8 changes: 4 additions & 4 deletions build/build-sample-reports.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ const path = require('path');
const swapLocale = require('../shared/localization/swap-locale.js');
const swapFlowLocale = require('../shared/localization/swap-flow-locale.js');
const ReportGenerator = require('../report/generator/report-generator.js');
const {defaultSettings} = require('../lighthouse-core/config/constants.js');
const lighthouse = require('../lighthouse-core/index.js');
const lhr = /** @type {LH.Result} */ (require('../lighthouse-core/test/results/sample_v2.json'));
const {defaultSettings} = require('../core/config/constants.js');
const lighthouse = require('../core/index.js');
const lhr = /** @type {LH.Result} */ (require('../core/test/results/sample_v2.json'));
const {LH_ROOT, readJson} = require('../root.js');

/** @type {LH.FlowResult} */
const flowResult = readJson(
`${LH_ROOT}/lighthouse-core/test/fixtures/fraggle-rock/reports/sample-flow-result.json`
`${LH_ROOT}/core/test/fixtures/fraggle-rock/reports/sample-flow-result.json`
);

const DIST = path.join(LH_ROOT, 'dist');
Expand Down
4 changes: 2 additions & 2 deletions build/build-smokehouse-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ const {LH_ROOT} = require('../root.js');

const distDir = `${LH_ROOT}/dist`;
const bundleOutFile = `${distDir}/smokehouse-bundle.js`;
const smokehouseLibFilename = './lighthouse-cli/test/smokehouse/frontends/lib.js';
const smokehouseCliFilename = `${LH_ROOT}/lighthouse-cli/test/smokehouse/lighthouse-runners/cli.js`;
const smokehouseLibFilename = './cli/test/smokehouse/frontends/lib.js';
const smokehouseCliFilename = `${LH_ROOT}/cli/test/smokehouse/lighthouse-runners/cli.js`;

async function build() {
const bundle = await rollup.rollup({
Expand Down
2 changes: 1 addition & 1 deletion build/test/plugins/inline-fs-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const path = require('path');
const {inlineFs} = require('../../plugins/inline-fs.js');

const {LH_ROOT} = require('../../../root.js');
const filepath = `${LH_ROOT}/lighthouse-core/index.js`;
const filepath = `${LH_ROOT}/core/index.js`;

describe('inline-fs', () => {
const tmpPath = `${LH_ROOT}/.tmp/inline-fs/test.txt`;
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions lighthouse-cli/bin.js → cli/bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* index.js : only calls bin.js's begin()
* cli-flags.js : leverages yargs to read argv, outputs LH.CliFlags
* bin.js : CLI args processing. cwd, list/print commands
* run.js : chrome-launcher bits, calling lighthouse-core, output to Printer
* run.js : chrome-launcher bits, calling core, output to Printer
*
* index ----> bin ----> run ----> printer
* ⭏ ⭎ ⭏ ⭎
Expand All @@ -30,15 +30,15 @@ import * as commands from './commands/commands.js';
import * as Printer from './printer.js';
import {getFlags} from './cli-flags.js';
import {runLighthouse} from './run.js';
import lighthouse from '../lighthouse-core/index.js';
import lighthouse from '../core/index.js';
import {askPermission} from './sentry-prompt.js';
import {LH_ROOT} from '../root.js';

const pkg = JSON.parse(fs.readFileSync(LH_ROOT + '/package.json', 'utf-8'));

// TODO(esmodules): use regular import when this file is esm.
const require = module.createRequire(import.meta.url);
const Sentry = require('../lighthouse-core/lib/sentry.js');
const Sentry = require('../core/lib/sentry.js');

/**
* @return {boolean}
Expand Down Expand Up @@ -86,7 +86,7 @@ async function begin() {
configJson = (await import(configModuleUrl)).default;
}
} else if (cliFlags.preset) {
configJson = (await import(`../lighthouse-core/config/${cliFlags.preset}-config.js`)).default;
configJson = (await import(`../core/config/${cliFlags.preset}-config.js`)).default;
}

if (cliFlags.budgetPath) {
Expand Down
2 changes: 1 addition & 1 deletion lighthouse-cli/cli-flags.js → cli/cli-flags.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ function getFlags(manualArgv, options = {}) {
'config-path': {
type: 'string',
describe: `The path to the config JSON.
An example config file: lighthouse-core/config/lr-desktop-config.js`,
An example config file: core/config/lr-desktop-config.js`,
},
'preset': {
type: 'string',
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
'use strict';

import lighthouse from '../../lighthouse-core/index.js';
import lighthouse from '../../core/index.js';

function listAudits() {
const audits = lighthouse.getAuditList().map((i) => i.replace(/\.js$/, ''));
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
'use strict';

import lighthouse from '../../lighthouse-core/index.js';
import lighthouse from '../../core/index.js';

function listTraceCategories() {
const traceCategories = lighthouse.traceCategories;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading