How to use the @lhci/utils/src/lodash.js.shortId function in @lhci/utils

To help you get started, we’ve selected a few @lhci/utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github GoogleChrome / lighthouse-ci / scripts / ci-dogfood-get-urls.js View on Github external
async function main() {
  const rootURL = process.env.LHCI_ROOT_URL;
  if (!rootURL) throw new Error(`Missing LHCI_ROOT_URL environment variable`);

  const client = new ApiClient({rootURL});

  const projects = await client.getProjects();
  const project = projects.find(project => project.name.includes('Viewer')) || projects[0];
  const builds = await client.getBuilds(project.id);
  const build = builds.find(build => build.branch.includes('test_1')) || builds[0];

  process.stdout.write(
    [
      new URL(`/app`, rootURL),
      new URL(`/app/projects/${project.slug}`, rootURL),
      new URL(`/app/projects/${project.slug}/compare/${_.shortId(build.id)}`, rootURL),
    ].join('\n')
  );

  process.exit(0);
}
github GoogleChrome / lighthouse-ci / packages / server / src / ui / routes / project-dashboard / project-dashboard.jsx View on Github external
onClick={() =>
                    route(`/app/projects/${project.slug}/compare/${_.shortId(build.id)}`)
                  }
github GoogleChrome / lighthouse-ci / packages / server / src / ui / routes / project-dashboard / project-graphs.jsx View on Github external
onClick={({points}) => {
                const currentUrl = new URL(window.location.href);
                const x = points[0].x;
                const to = `${currentUrl.pathname}/compare/${_.shortId(builds[x].id)}`;
                route(to);
              }}
              data={ys.map((yVals, i) => ({
github GoogleChrome / lighthouse-ci / packages / server / src / ui / routes / build-view / build-hash-selector.jsx View on Github external
onClick={() => {
        if (isCompareBranch && selector === 'compare') return;
        if (isBaseBranch && selector === 'base') return;

        const url = new URL(window.location.href);

        if (selector === 'base') {
          url.searchParams.set('baseBuild', build.id);
        } else {
          url.searchParams.delete('baseBuild');
          if (baseBuild) url.searchParams.set('baseBuild', baseBuild.id);
          url.pathname = url.pathname.replace(/compare\/\w+$/, `compare/${_.shortId(build.id)}`);
        }

        window.location.href = url.href;
      }}
    >