main.py
Setup and commands for the ts-backend-check command line interface.
- ts_backend_check.cli.main.check_files_and_print_results(identifier: str, backend_model_file_path: Path, ts_interface_file_paths: list[Path], check_blank: bool = False, model_name_conversions: dict[str, list[str]] = {}, backend_models_to_ignore: list[str] = []) bool[source]
Check the provided files for the given model and print the results.
- Parameters:
- identifierstr
The model in the .ts-backend-check.yaml configuration file to check models and interfaces for.
- backend_model_file_pathPath
The path to the backend models as defined in the .ts-backend-check.yaml configuration file.
- ts_interface_file_pathslist[Path]
The paths to the TypeScript interfaces as defined in the .ts-backend-check.yaml configuration file.
- check_blankbool, default=False
Whether to also check that fields marked ‘blank=True’ within Django models are optional (?) in the TypeScript interfaces.
- model_name_conversionsdict[str, list[str]], default={}
A dictionary of backend model names to their corresponding TypeScript interfaces when snake to camel case isn’t valid.
- backend_models_to_ignorelist[str]
Backend model classes to ignore, obtained from the config file.
- Returns:
- bool
Whether the checks passed (True) or not (False).
- ts_backend_check.cli.main.main() None[source]
The main check function to compare a the methods within a backend model to a corresponding TypeScript file.
Notes
The available command line arguments are: - –help (-h): Show this help message and exit. - –version (-v): Show the version of the ts-backend-check CLI. - –upgrade (-u): Upgrade the ts-backend-check CLI to the latest version. - –generate-config-file (-gcf): Interactively generate a configuration file for ts-backend-check. - –generate-test-project (-gtp): Generate project to test ts-backend-check functionalities. - –identifier (-i): The model-interface identifier in the .ts-backend-check.yaml configuration file to check. - –all (-a): Run checks of all backend models against their corresponding TypeScript interfaces.
Examples
>>> ts-backend-check --generate-config-file # -gcf >>> ts-backend-check --identifier <model-interface-identifier-from-config-file> # -i >>> ts-backend-check --all # -a