mirror of
https://github.com/NoRedInk/noredink-ui.git
synced 2024-12-17 10:41:35 +03:00
e2907d9ba2
* Use elm-css 16.0.0 * 💀 Ui.Checkbox V1 and V2 * s/Css.Foreign/Css.Global/g * 💀 Nri.Ui.Styles.V1 * 💀 BannerAlert.V1 * 💀 Modal.V1 * 💀 Dropdown.V1 * 💀 Select.V1 and V2 * 💀 Alert.V1 * 💀 Button.V1 and V2 * 💀 Divider.V1 * 💀 Icon.V1 and V2 * 💀 Outline.V1 * 💀 SegmentedControl.V1-V5 * 💀 TextArea.V1 and V2 * 💀 TextInput.V1 * delete the rest of the modules * actually more deletions * InputStyles v1 is unused * move to src-0.18 * do the 0.19 upgrade * select options are addressable by index * elm-css 16 * update scripts * elm-format * Update V2.elm * put the nbsp back * elm-format validation for both versions
71 lines
2.1 KiB
Python
Executable File
71 lines
2.1 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
#
|
|
# Checks that `elm-package.json` contains an `exposed-modules` entry for every
|
|
# module in `src/Nri` (recursively) named `Vn.elm`, where `n` is a decimal
|
|
# number.
|
|
#
|
|
# On success, this emits nothing and exits 0.
|
|
#
|
|
# On failure, this emits a list of those modules not exposed, and exits 2.
|
|
#
|
|
|
|
import json
|
|
import os
|
|
import re
|
|
import sys
|
|
|
|
|
|
re_v_file = re.compile(r"^V[0-9]+[.]elm$")
|
|
re_module = re.compile(
|
|
r"""
|
|
# Zero or more blank lines or single-line comments.
|
|
(?:^$\n|^--.*$\n)*
|
|
# Optional port or effect modifier.
|
|
^(?:(?:port|effect)\s+)?
|
|
# The module declaration itself begins.
|
|
module
|
|
# Optional newline, comment, newline.
|
|
(?:\n\s+--.+\n)?
|
|
# After some whitespace, capture the module name.
|
|
\s+(?P<module>[^ ]+)\b
|
|
""",
|
|
flags=re.MULTILINE | re.VERBOSE)
|
|
|
|
|
|
def p_v_file(filename):
|
|
"""Is `filename` a versioned widget file?"""
|
|
return re_v_file.match(filename) is not None
|
|
|
|
|
|
def read_module(filename):
|
|
"""Read the module name from the Elm source."""
|
|
with open(filename, "r", encoding="utf-8") as elm:
|
|
return re_module.search(elm.read()).group("module")
|
|
|
|
|
|
def find_v_modules(root):
|
|
for dirname, dirnames, filenames in os.walk(root + "/Nri"):
|
|
filenames = filter(p_v_file, filenames)
|
|
filepaths = (os.path.join(dirname, filename) for filename in filenames)
|
|
yield from map(read_module, filepaths)
|
|
|
|
|
|
def read_exposed_modules(path):
|
|
with open(path, "r", encoding="utf-8") as pkg:
|
|
yield from json.load(pkg).get("exposed-modules")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
available_18 = set(find_v_modules("src-0.18"))
|
|
available_19 = set(find_v_modules("src"))
|
|
exposed_18 = set(read_exposed_modules("elm-package.json"))
|
|
exposed_19 = set(read_exposed_modules("elm.json"))
|
|
# XXX: Do we need to check that parent modules are exposed too?
|
|
missing_18 = available_18 - exposed_18
|
|
missing_19 = available_19 - exposed_19
|
|
missing = missing_18.union(missing_19)
|
|
for module in sorted(missing):
|
|
print("Not exposed:", module, file=sys.stderr)
|
|
raise SystemExit(
|
|
0 if len(missing) == 0 else 2)
|