Files
spark/tools/py/gen_tsconfig.py
T
John Colvin e97335189a refactor: Rename Spark.Admin.Console -> WebApp
This is a more appropriate name (it is a web app after all), especially
now that we've renamed sparkcmd -> Spark.Console (a literal console
app). The old name implies a parallel between the two apps that doesn't
exist.
2023-03-20 13:26:44 -04:00

61 lines
1.5 KiB
Python

import json
import os
from pathlib import Path
from core.logging import exec_and_log_error
from core.file_utils import SparkPaths
import argparse
def _get_arg_parser():
parser = argparse.ArgumentParser(description='Generate a tsconfig (that extends a base tsconfig) for web build')
parser.add_argument(
'--config-base',
metavar='path',
help='The base tsconfig file to use',
required=True)
parser.add_argument(
'--config-out',
metavar='path',
help='The tsconfig file to create',
required=True)
parser.add_argument(
'--protos',
nargs='+',
help='The protocol buffers to transpile')
parser.add_argument(
'--build-out',
help='The build output directory',
required=True)
parser.set_defaults(mode='development')
return parser
def _main():
parser = _get_arg_parser()
args = parser.parse_args()
src_path = SparkPaths.root().joinpath('src', 'Spark.Admin.WebApp')
os.chdir(src_path)
cfg_base = Path(args.config_base).absolute()
cfg_out = Path(args.config_out).absolute()
build_out = Path(args.build_out).absolute()
cfg = {
'extends': str(cfg_base),
'compilerOptions': {
'outDir': str(build_out),
'paths': {
'proto': [str(build_out.joinpath('proto'))]
}
}
}
with open(str(cfg_out), 'w') as f_out:
json.dump(cfg, f_out, indent=2)
if __name__ == '__main__':
exec_and_log_error(_main, name=__file__)