[landingwidget] Add Makefile.

Bug: 1319718
Change-Id: I5431a443fdc5b075adfeec508ce5f97aed7f1bfa
diff --git a/README.md b/README.md
index 99e48a1..46b8e57 100644
--- a/README.md
+++ b/README.md
@@ -10,21 +10,22 @@
 
 ## Web Plugin Development
 
+Run the commands below in web/.
+
 For running unit tests execute:
 
-    bazel test --test_output=all //plugins/landingwidget/web:karma_test
+    make test
 
 For checking or fixing eslint formatter problems run:
 
-    bazel test //plugins/landingwidget/web:lint_test
-    bazel run //plugins/landingwidget/web:lint_bin -- --fix "$(pwd)/plugins/landingwidget/web"
+    make lint_test
+    make lint_fix
 
 For testing the plugin with
 [Gerrit FE Dev Helper](https://gerrit.googlesource.com/gerrit-fe-dev-helper/)
-build the JavaScript bundle and copy it to the `plugins/landingwidget` folder:
+the command below builds build the JavaScript bundle and copies it to the `plugins/landingwidget` folder:
 
-    bazel build //plugins/landingwidget/web:landingwidget
-    cp -f bazel-bin/plugins/landingwidget/web/landingwidget.js plugins/landingwidget
+    make build
 
 and let the Dev Helper redirect from `.+/plugins/landingwidget/static/landingwidget.js` to
 `http://localhost:8081/plugins_/plugins/landingwidget.js`.
diff --git a/web/Makefile b/web/Makefile
new file mode 100644
index 0000000..1d0c59f
--- /dev/null
+++ b/web/Makefile
@@ -0,0 +1,18 @@
+# Copyright 2022 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+.PHONY: test
+
+test:
+	bazel test --test_output=all //plugins/landingwidget/web:karma_test
+
+lint_test:
+	bazel test //plugins/landingwidget/web:lint_test
+
+lint_fix:
+	bazel run //plugins/landingwidget/web:lint_bin -- --fix "./"
+
+build:
+	bazel build //plugins/landingwidget/web:landingwidget && \
+	cp -f ../../../bazel-bin/plugins/landingwidget/web/landingwidget.js ../
diff --git a/web/landingwidget.ts b/web/landingwidget.ts
index c4ff707..9fc46b2 100644
--- a/web/landingwidget.ts
+++ b/web/landingwidget.ts
@@ -95,12 +95,16 @@
     if (!this.hasVersionInfo) {
       return;
     }
-    const items = this.versions.map((v: LandingWidgetVersion) =>
-        html`<li><a href="${v.link}" target="_blank">${v.text}</a></li>`);
+    const items = this.versions.map(
+      (v: LandingWidgetVersion) =>
+        html`<li><a href="${v.link}" target="_blank">${v.text}</a></li>`
+    );
     return html`
       <section>
         <span class="title">Landed in</span>
-        <ul class="value">${items}</ul>
+        <ul class="value">
+          ${items}
+        </ul>
       </section>
     `;
   }
@@ -129,13 +133,12 @@
     const changeNum = this.change._number;
     // We need to use fetch instead of restApi because we need to include
     // credentials.
-    const response = await this.fetchJSON(
+    const response = (await this.fetchJSON(
       `${config.serviceUrl}/lookupFirstBuild` +
         `?instance=${config.instanceName}&cl=${changeNum}`,
       {credentials: 'include'}
-    ) as LandingWidgetResponse;
-    const versionsLink =
-        `${config.serviceUrl}/cl?q=${config.instanceName}:${changeNum}`;
+    )) as LandingWidgetResponse;
+    const versionsLink = `${config.serviceUrl}/cl?q=${config.instanceName}:${changeNum}`;
 
     if (response?.versions) {
       this.versions = response.versions.map((v: string) => {
@@ -151,10 +154,11 @@
    * Get the LandingWidget configuration for the given project.
    */
   async getProjectConfig(project: string): Promise<LandingWidgetConfig | null> {
-    const landingWidgetUrl =
-        `/projects/${encodeURIComponent(project)}/landingwidget~config`;
+    const landingWidgetUrl = `/projects/${encodeURIComponent(
+      project
+    )}/landingwidget~config`;
     const config: LandingWidgetConfig =
-        await this.plugin.restApi().get(landingWidgetUrl) || null;
+      (await this.plugin.restApi().get(landingWidgetUrl)) || null;
     if (!config) {
       console.info('LandingWidget is not configured');
       return null;
@@ -162,7 +166,8 @@
     // Legacy config from GerritSiteFooter.html
     if (config.projectPatterns) {
       const configMatchesProject = config.projectPatterns.some(pattern =>
-          project.match(pattern));
+        project.match(pattern)
+      );
       if (!configMatchesProject) {
         return null;
       }
diff --git a/web/plugin.ts b/web/plugin.ts
index 569d6a6..ccc0070 100644
--- a/web/plugin.ts
+++ b/web/plugin.ts
@@ -7,5 +7,7 @@
 
 window.Gerrit.install(plugin => {
   plugin.registerCustomComponent(
-      'change-metadata-item', 'chromium-landing-widget');
+    'change-metadata-item',
+    'chromium-landing-widget'
+  );
 });