wads.profiles¶
Declarative generation profiles and overlays built on the engine.
A profile is a named declarative description of a project setup expressed as a
list of wads.templating.Artifact. The default profile (python-lib)
is produced by wads.populate.
This module hosts two opt-in overlays added on top of an existing project:
The frontend profile registry (issue #39): a small registry of language/toolchain profiles –
js(the original #32 overlay, the back-compat anchor),ts(single-package TypeScript), andts-monorepo(pnpm workspaces + turbo). A project may declare several frontend components (e.g.jsandts); each lives in its own subdir with its own path-filtered workflow, so they never collide. Selected viapopulate --frontend <profile>[,<profile>](--with-npmstays as an alias for--frontend js). Profiles are extensible throughregister_frontend_profile().The tests-folder overlay (issue #4): scaffolds a
tests/package.
Nothing here runs by default; the Python populate path and the
name/name/ root layout are untouched.
Module Attributes
The frontend profile registry. |
Functions
|
Apply one frontend profile component to an existing project directory. |
|
Deprecated alias for |
|
Scaffold a |
|
Build the render context shared by all frontend-profile templates. |
|
Look up a registered profile, with an informative error if unknown. |
|
Artifacts that scaffold a |
|
Deprecated: the |
|
Deprecated: render context for the |
|
Register (or override) a frontend profile by name. |
Classes
|
A declarative frontend language/toolchain profile. |
- wads.profiles.FRONTEND_PROFILES: dict = {'js': FrontendProfile(name='js', default_subdir='js', default_package_manager='npm', artifacts=<function _js_artifacts>, description='JavaScript single package (the original #32 overlay).'), 'ts': FrontendProfile(name='ts', default_subdir='ts', default_package_manager='npm', artifacts=<function _ts_artifacts>, description='TypeScript single package (tsconfig + tsup build + vitest).'), 'ts-monorepo': FrontendProfile(name='ts-monorepo', default_subdir='ts', default_package_manager='pnpm', artifacts=<function _ts_monorepo_artifacts>, description='TypeScript monorepo (pnpm workspaces + turbo).')}¶
The frontend profile registry. Extend it via
register_frontend_profile().
- class wads.profiles.FrontendProfile(name, default_subdir, default_package_manager, artifacts, description='')[source]¶
Bases:
objectA declarative frontend language/toolchain profile.
- Parameters:
name (
str) – registry key (e.g."js","ts","ts-monorepo").default_subdir (
str) – subdir the component lives in when unspecified.default_package_manager (
str) –"npm"or"pnpm".artifacts (
Callable[[Mapping],list]) –context -> list[Artifact]builder for this profile.description (
str) – one-line human summary.
- wads.profiles.apply_frontend(pkg_dir, *, profile='js', project_name, description='', license=None, subdir=None, package_name=None, version='0.0.1', package_manager=None, workspace_glob='packages/*', example_package_name=None, overwrite=(), on_add=None, on_skip=None)[source]¶
Apply one frontend profile component to an existing project directory.
subdirandpackage_managerdefault to the selected profile’s defaults. Returns thewads.templating.GenerationResult.- Return type:
>>> import tempfile >>> d = tempfile.mkdtemp() >>> res = apply_frontend(d, profile="ts", project_name="widget") >>> sorted(res.added) ['.github/workflows/npm-ci-ts.yml', 'ts/package.json', 'ts/src/index.test.ts', 'ts/src/index.ts', 'ts/tsconfig.json']
- wads.profiles.apply_npm_overlay(pkg_dir, *, project_name, description='', license=None, npm_subdir='js', npm_package_name=None, npm_version='0.0.1', npm_package_manager='npm', overwrite=(), on_add=None, on_skip=None)[source]¶
Deprecated alias for
apply_frontend(profile="js", ...)(issue #32 surface).Kept so existing callers and tests keep working; new code should call
apply_frontend().
- wads.profiles.apply_tests_overlay(pkg_dir, *, project_name, with_data_util=True, overwrite=(), on_add=None, on_skip=None)[source]¶
Scaffold a
tests/folder in an existing project (issue #4).
- wads.profiles.frontend_context(*, profile_name, project_name, description='', license=None, subdir, package_name=None, version='0.0.1', package_manager='npm', workspace_glob='packages/*', example_package_name=None)[source]¶
Build the render context shared by all frontend-profile templates.
The returned mapping is a superset: it carries the keys every profile’s templates may reference (single-package and monorepo). Unused keys are harmless under Jinja
StrictUndefinedbecause that only errors on keys a template references yet are missing.- Return type:
- wads.profiles.get_frontend_profile(name)[source]¶
Look up a registered profile, with an informative error if unknown.
- Return type:
- wads.profiles.make_tests_overlay_artifacts(project_name, *, with_data_util=True)[source]¶
Artifacts that scaffold a
tests/folder for a project.Writes
tests/__init__.py,tests/test_<project_name>.py(a smoke test), and optionallytests/util.py(atests/dataaccessor, per #4). The smoke-test filename embeds the package name, so it is built here where the name is known.- Return type:
- wads.profiles.npm_overlay_artifacts(npm_subdir='js')[source]¶
Deprecated: the
jsoverlay artifacts. Use thejsfrontend profile.- Return type:
- wads.profiles.npm_overlay_context(*, project_name, description='', license=None, npm_subdir='js', npm_package_name=None, npm_version='0.0.1', npm_package_manager='npm')[source]¶
Deprecated: render context for the
jsoverlay. Useapply_frontend().- Return type: