webcompy-cli 0.0.14__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. webcompy_cli/__init__.py +20 -0
  2. webcompy_cli/_argparser.py +232 -0
  3. webcompy_cli/_browser_probes.py +648 -0
  4. webcompy_cli/_browser_test_harness.py +554 -0
  5. webcompy_cli/_build.py +425 -0
  6. webcompy_cli/_console_types.py +15 -0
  7. webcompy_cli/_dependency_resolver.py +301 -0
  8. webcompy_cli/_dualrun_pytest_plugin.py +130 -0
  9. webcompy_cli/_exception.py +9 -0
  10. webcompy_cli/_generate.py +224 -0
  11. webcompy_cli/_init_project.py +54 -0
  12. webcompy_cli/_inspect.py +741 -0
  13. webcompy_cli/_inspect_pyexec.py +244 -0
  14. webcompy_cli/_lock.py +82 -0
  15. webcompy_cli/_lockfile.py +396 -0
  16. webcompy_cli/_lockfile_sync.py +343 -0
  17. webcompy_cli/_output.py +150 -0
  18. webcompy_cli/_prebuild.py +661 -0
  19. webcompy_cli/_pwa.py +474 -0
  20. webcompy_cli/_pyodide_downloader.py +113 -0
  21. webcompy_cli/_pyodide_lock.py +74 -0
  22. webcompy_cli/_runtime_downloader.py +222 -0
  23. webcompy_cli/_server.py +568 -0
  24. webcompy_cli/_static_files.py +27 -0
  25. webcompy_cli/_utils.py +72 -0
  26. webcompy_cli/_version_sweep.py +213 -0
  27. webcompy_cli/_wheel_builder.py +509 -0
  28. webcompy_cli/config/__init__.py +23 -0
  29. webcompy_cli/config/_build_config.py +168 -0
  30. webcompy_cli/config/_pwa_config.py +203 -0
  31. webcompy_cli/config/_server_config.py +53 -0
  32. webcompy_cli/py.typed +0 -0
  33. webcompy_cli/template_data/app/__init__.py +0 -0
  34. webcompy_cli/template_data/app/app.py +22 -0
  35. webcompy_cli/template_data/app/components/__init__.py +0 -0
  36. webcompy_cli/template_data/app/components/fizzbuzz.py +117 -0
  37. webcompy_cli/template_data/app/components/home.py +15 -0
  38. webcompy_cli/template_data/app/components/input.py +34 -0
  39. webcompy_cli/template_data/app/components/navigation.py +36 -0
  40. webcompy_cli/template_data/app/components/not_found.py +22 -0
  41. webcompy_cli/template_data/app/components/root.py +16 -0
  42. webcompy_cli/template_data/app/router.py +17 -0
  43. webcompy_cli/template_data/webcompy_config.py +12 -0
  44. webcompy_cli-0.0.14.dist-info/METADATA +53 -0
  45. webcompy_cli-0.0.14.dist-info/RECORD +47 -0
  46. webcompy_cli-0.0.14.dist-info/WHEEL +4 -0
  47. webcompy_cli-0.0.14.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,54 @@
1
+ """Project scaffolding from the bundled template."""
2
+
3
+ import os
4
+ import pathlib
5
+ import shutil
6
+ import sys
7
+
8
+
9
+ def _get_files(path: pathlib.Path, suffix: str) -> list[str]:
10
+ ret: list[str] = []
11
+ if path.is_dir():
12
+ for p in path.iterdir():
13
+ ret.extend(_get_files(p, suffix))
14
+ elif path.suffix == suffix:
15
+ ret.append(str(path))
16
+ return ret
17
+
18
+
19
+ def init_project():
20
+ import webcompy_cli
21
+
22
+ template_data_dir = pathlib.Path(webcompy_cli.__file__).parent / "template_data"
23
+ cwd = pathlib.Path().cwd().absolute()
24
+ filepath_pairs = [
25
+ (
26
+ filepath,
27
+ cwd / str(filepath).replace(str(template_data_dir), "").lstrip(os.sep),
28
+ )
29
+ for filepath in map(pathlib.Path, _get_files(template_data_dir, ".py"))
30
+ ]
31
+
32
+ files_exist = [p for _, p in filepath_pairs if p.exists()]
33
+ if files_exist:
34
+ for p in files_exist:
35
+ print(p)
36
+ while True:
37
+ ans = input("Some files already exist. Will you overwrite them? (y/N): ")
38
+ if len(ans) == 0 or (ans.isalpha() and ans.lower() in {"y", "n"}):
39
+ if len(ans) == 0 or ans.lower() == "n":
40
+ sys.exit()
41
+ else:
42
+ break
43
+ else:
44
+ continue
45
+ for template_filepath, project_filepath in filepath_pairs:
46
+ if not project_filepath.parent.exists():
47
+ os.makedirs(project_filepath.parent)
48
+ if project_filepath.exists():
49
+ os.remove(project_filepath)
50
+ shutil.copy(template_filepath, project_filepath)
51
+ print(project_filepath)
52
+ if not (staic_files_dir := (cwd / "static")).exists():
53
+ os.makedirs(staic_files_dir)
54
+ (cwd / "__init__.py").touch()