Remove python script for generating dark mode CSS
Now devtools_paths.js exists, we can use JS and remove the Python
version completely. This unblocks further work to enforce that
`.darkmode.css` files are up to date as part of a PRESUBMIT.
Bug: chromium:1164945
Change-Id: Ie9e8fa1cd5287d8e444085d7f036a4b17c99eda9
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2662976
Commit-Queue: Jack Franklin <jacktfranklin@chromium.org>
Auto-Submit: Jack Franklin <jacktfranklin@chromium.org>
Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
diff --git a/scripts/dark_mode/generate_dark_theme_sheet.js b/scripts/dark_mode/generate_dark_theme_sheet.js
index c8ac4f3..27c01cf 100644
--- a/scripts/dark_mode/generate_dark_theme_sheet.js
+++ b/scripts/dark_mode/generate_dark_theme_sheet.js
@@ -14,6 +14,7 @@
const path = require('path');
const puppeteer = require('puppeteer');
const {argv} = require('yargs');
+const devtoolsPaths = require('../devtools_paths.js');
/**
* @param {string} chromeBinary
@@ -26,7 +27,12 @@
const browser = await puppeteer.launch({executablePath: chromeBinary, args: ['--ignore-certificate-errors']});
const page = await browser.newPage();
- await page.goto('https://localhost:8090/');
+ try {
+ await page.goto('https://localhost:8090/');
+ } catch (e) {
+ console.log('Could not connect. Is the hosted server running on port 8090?');
+ process.exit(1);
+ }
const darkModeStyles = await page.evaluate(async contents => {
const ThemeSupport = await import('./front_end/theme_support/theme_support.js');
@@ -67,7 +73,7 @@
const outputFilePath = path.join(process.cwd(), path.dirname(sheetFilePath), outputFileName);
const output = `/* This file was automatically generated via:
-npm run generate-dark-mode-styles -- --file=${path.relative(process.cwd(), inputFile)}
+npm run generate-dark-mode-styles ${path.relative(process.cwd(), inputFile)}
*/
/* stylelint-disable */
${darkModeStyles}
@@ -81,17 +87,17 @@
await generateDarkModeStyleSheet(chromeBinaryPath, inputFile);
}
-const [chromeBinaryPath, inputFile] = argv._;
+const [inputFile] = argv._;
-if (!chromeBinaryPath || !inputFile) {
+if (!inputFile) {
console.log(`Usage:
- generate_dark_theme_sheet.js chromeBinaryPath inputFile
+ generate_dark_theme_sheet.js inputFile
example:
- generate_dark_theme_sheet.js ./third_party/chrome/chrome-linux/chrome front_end/text_editor/cmdevtools.css
+ generate_dark_theme_sheet.js front_end/text_editor/cmdevtools.css
`);
process.exit(1);
}
-run(chromeBinaryPath, inputFile);
+run(devtoolsPaths.downloadedChromeBinaryPath(), inputFile);
diff --git a/scripts/dark_mode/run_dark_theme_generator.py b/scripts/dark_mode/run_dark_theme_generator.py
deleted file mode 100755
index cb384ab..0000000
--- a/scripts/dark_mode/run_dark_theme_generator.py
+++ /dev/null
@@ -1,46 +0,0 @@
-#!/usr/bin/env vpython
-#
-# Copyright 2019 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.
-"""
-Run the dark theme stylesheet generator.
-"""
-
-import os
-import sys
-import argparse
-import subprocess
-
-scripts_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
-sys.path.append(scripts_path)
-import devtools_paths
-
-
-def run_dark_mode_generator(file_path):
- chrome_binary = devtools_paths.downloaded_chrome_binary_path()
-
- exec_command = [
- devtools_paths.node_path(),
- 'scripts/dark_mode/generate_dark_theme_sheet.js', chrome_binary,
- file_path
- ]
- process = subprocess.Popen(exec_command)
- process.communicate()
-
-
-def main():
- parser = argparse.ArgumentParser(
- description='Run the dark theme stylesheet generator')
- parser.add_argument(
- '--file',
- '-f',
- dest='file',
- help='The CSS file to generate a dark mode variant from.')
- args = parser.parse_args(sys.argv[1:])
-
- run_dark_mode_generator(args.file)
-
-
-if __name__ == '__main__':
- main()
diff --git a/scripts/devtools_paths.js b/scripts/devtools_paths.js
index 116b8b1..9c77695 100644
--- a/scripts/devtools_paths.js
+++ b/scripts/devtools_paths.js
@@ -145,10 +145,20 @@
return path.join(nodeModulesPath(), 'stylelint', 'bin', 'stylelint.js');
}
+function downloadedChromeBinaryPath() {
+ const paths = {
+ 'linux': path.join('chrome-linux', 'chrome'),
+ 'darwin': path.join('chrome', 'chrome-mac', 'Chromium.app', 'Contents', 'MacOS', 'Chromium'),
+ 'win32': path.join('chrome-win', 'chrome.exe'),
+ };
+ return path.join(thirdPartyPath(), 'chrome', paths[os.platform()]);
+}
+
module.exports = {
thirdPartyPath,
nodePath,
devtoolsRootPath,
nodeModulesPath,
- stylelintExecutablePath
+ stylelintExecutablePath,
+ downloadedChromeBinaryPath
};