[l10n] Add a presubmit that runs the bundling step for the i18n lib

Previously we had no check that this bundling step was run when
the i18n lib source file was changed. Now presubmit will run the
bundling if the relevant devtools files change.

We don't check for changes to rollup itself or any of the other
non-devtools deps of the i18n lib at this point even though they
would change the output.

Bug: 941561
Change-Id: I9436f62b45f5aa4a2f2fc339941113f11962b7d0
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2656237
Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
Commit-Queue: Peter Marshall <petermarshall@chromium.org>
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index aa349bf..7ed0200 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -471,6 +471,7 @@
     results.extend(_CheckFormat(input_api, output_api))
     results.extend(_CheckOptimizeSVGHashes(input_api, output_api))
     results.extend(_CheckChangesAreExclusiveToDirectory(input_api, output_api))
+    results.extend(_CheckI18nWasBundled(input_api, output_api))
     # Run the canned checks from `depot_tools` after the custom DevTools checks.
     # The canned checks for example check that lines have line endings. The
     # DevTools presubmit checks automatically fix these issues. If we would run
@@ -603,3 +604,23 @@
 
     should_bail_out = len(files_to_lint) is 0 and not run_full_check
     return should_bail_out, files_to_lint
+
+
+def _CheckI18nWasBundled(input_api, output_api):
+    affected_files = _getAffectedFiles(input_api, [
+        input_api.os_path.join(input_api.PresubmitLocalPath(), 'front_end',
+                               'third_party', 'i18n', 'lib')
+    ], [], ['.js'])
+
+    if len(affected_files) == 0:
+        return [
+            output_api.PresubmitNotifyResult(
+                'No affected files for i18n bundle check')
+        ]
+
+    results = [output_api.PresubmitNotifyResult('Running buildi18nBundle.js:')]
+    script_path = input_api.os_path.join(input_api.PresubmitLocalPath(),
+                                         'scripts', 'localizationV2',
+                                         'buildi18nBundle.js')
+    results.extend(_checkWithNodeScript(input_api, output_api, script_path))
+    return results