feat: update default presets
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
[presets.config.tasks.setup.config]
|
||||
priority = 1
|
||||
conditions = ["{{ ('.env-base' | file) and ('.env' | file | not ) }}"]
|
||||
commands = ["cp .env-base .env"]
|
||||
@@ -34,3 +34,13 @@ commands = [
|
||||
"mkdir -p {{ docker_output }}",
|
||||
"docker save --output {{ docker_output }}/{{ docker_name }}-{{ docker_version }}.tar {{ docker_image }}",
|
||||
]
|
||||
|
||||
# run
|
||||
[presets.docker.tasks.run.compose]
|
||||
conditions = ["{{ 'docker-compose.yaml' | file }}"]
|
||||
commands = ["docker compose -f docker-compose.yaml up"]
|
||||
|
||||
# develop
|
||||
[presets.docker.tasks.develop.compose]
|
||||
conditions = ["{{ 'docker-compose-develop.yaml' | file }}"]
|
||||
commands = ["docker compose -f docker-compose-develop.yaml up --build --watch"]
|
||||
|
||||
@@ -1,30 +1,32 @@
|
||||
[presets.nodejs]
|
||||
conditions = ["{{ 'package.json' | file }}"]
|
||||
variables.use_nvm = "{{ (((('home' | env) + '/.nvm/nvm.sh') | file) and ('.nvmrc' | file)) | bool }}"
|
||||
variables.nvm = "{{ '. ~/.nvm/nvm.sh && nvm use && ' if use_nvm | bool else '' }}"
|
||||
|
||||
# install
|
||||
[presets.nodejs.tasks.setup.npm]
|
||||
conditions = ["{{ 'package-lock.json' | file }}"]
|
||||
commands = ["npm install-clean"]
|
||||
commands = ["{{ nvm }}npm install-clean"]
|
||||
|
||||
# install legacy
|
||||
[presets.nodejs.tasks.setup.npm-legacy]
|
||||
conditions = ["{{ not ('package-lock.json' | file) }}"]
|
||||
commands = ["npm install"]
|
||||
commands = ["{{ nvm }}npm install"]
|
||||
|
||||
# test
|
||||
[presets.nodejs.tasks.test.jest]
|
||||
conditions = ["{{ 'node_modules/jest' | file }}"]
|
||||
commands = ["npx jest"]
|
||||
commands = ["{{ nvm }}npx jest"]
|
||||
|
||||
# build
|
||||
[presets.nodejs.tasks.build.npm]
|
||||
conditions = ["{{ 'package.json' | read | get('scripts.build') }}"]
|
||||
commands = ["npm run build"]
|
||||
commands = ["{{ nvm }}npm run build"]
|
||||
|
||||
# publish
|
||||
[presets.nodejs.tasks.publish.npm]
|
||||
conditions = ["{{ 'package.json' | read | get('scripts.publish') }}"]
|
||||
commands = ["npm run publish"]
|
||||
commands = ["{{ nvm }}npm run publish"]
|
||||
|
||||
# clean
|
||||
[presets.nodejs.tasks.clean.node_modules]
|
||||
@@ -34,4 +36,4 @@ commands = ["rm -rf node_modules"]
|
||||
# version
|
||||
[presets.nodejs.tasks.version.npm]
|
||||
conditions = ["{{ version }}"]
|
||||
commands = ["npm version {{ version }} --allow-same-version"]
|
||||
commands = ["{{ nvm }}npm version {{ version }} --allow-same-version"]
|
||||
|
||||
@@ -8,6 +8,11 @@ conditions = ["{{ python_poetry }}"]
|
||||
variables.python_version = "{{ 'pyproject.toml' | read | get('project.requires-python') | search('(\\d+.\\d+)') }}"
|
||||
commands = ["poetry env use {{ python_version }}", "poetry install"]
|
||||
|
||||
# playwright
|
||||
[presets.python.tasks.setup.playwright]
|
||||
conditions = ["{{ '.venv/bin/playwright' | file }}"]
|
||||
commands = [".venv/bin/playwright install chromium --with-deps --only-shell"]
|
||||
|
||||
# build
|
||||
[presets.python.tasks.build.poetry]
|
||||
conditions = ["{{ python_poetry }}"]
|
||||
|
||||
@@ -14,9 +14,14 @@ class PresetEntryDetector(EntryDetector):
|
||||
def __init__(self, preset_loader_config: PresetLoaderConfig | None = None):
|
||||
self._preset_loader_config = preset_loader_config
|
||||
|
||||
# pylint:disable=too-many-locals
|
||||
def detect_entry(self, basepath: Path, rootpath: Path) -> Entry:
|
||||
template = PathTemplate(basepath)
|
||||
preset = PresetLoader(basepath, self._preset_loader_config).load()
|
||||
if preset.modules:
|
||||
modules = [Path(item).resolve() for item in preset.modules]
|
||||
if basepath not in modules:
|
||||
return ENTRY_SKIP
|
||||
if preset.skip:
|
||||
return ENTRY_SKIP
|
||||
tasks = []
|
||||
@@ -25,7 +30,10 @@ class PresetEntryDetector(EntryDetector):
|
||||
preset.presets.items(), key=lambda item: item[1].priority, reverse=True
|
||||
)
|
||||
for tag, preset in presets:
|
||||
preset_variables: Variables = {**global_variables, "entry_path": basepath}
|
||||
preset_variables: Variables = {
|
||||
**global_variables,
|
||||
"entry_path": str(basepath),
|
||||
}
|
||||
if preset.variables:
|
||||
if tag == "*":
|
||||
template.update_variables(preset.variables, global_variables)
|
||||
|
||||
@@ -20,4 +20,5 @@ class EntryPreset(BaseModel):
|
||||
|
||||
class Preset(BaseModel):
|
||||
skip: bool | None = None
|
||||
modules: list[str] | None = None
|
||||
presets: dict[str, EntryPreset]
|
||||
|
||||
Reference in New Issue
Block a user