Skip to content

Commit b0e12cc

Browse files
Set init --base flag by defaault (#1240)
1 parent 6a03300 commit b0e12cc

File tree

13 files changed

+52
-16
lines changed

13 files changed

+52
-16
lines changed

CHANGELOG.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,19 @@ Releases prior to 7.0 has been removed from this file to declutter search result
88

99
## [Unreleased]
1010

11-
### Fidex
11+
### Added
12+
13+
- cli: Added `init --no-base` option to skip creating the base template.
14+
- env: Added `DIPDUP_NO_BASE` environment variable to skip creating the base template.
15+
16+
### Fixed
1217

1318
- cli: Fixed `new` command using incorrect template.
1419

20+
### Changed
21+
22+
- cli: `init --base` option is now enabled by default.
23+
1524
## [8.3.1] - 2025-04-08
1625

1726
### Added

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ demos: ## Recreate demo projects from templates
8787
DIPDUP_NO_SYMLINK=1 python scripts/demos.py init ${DEMO}
8888

8989
demos_refresh:
90-
for demo in `ls src | grep demo | grep -v etherlink`; do cd src/$$demo && DIPDUP_NO_SYMLINK=1 dipdup init -b -f && cd ../..; done
90+
for demo in `ls src | grep demo | grep -v etherlink`; do cd src/$$demo && DIPDUP_NO_SYMLINK=1 dipdup init --force && cd ../..; done
9191

9292
before_release: ## Prepare for a new release after updating version in pyproject.toml
9393
make format lint update demos test docs

docs/1.getting-started/1.installation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ make install
3636
source .venv/bin/activate
3737
```
3838

39-
If you prefer to use other package manager, edit `configs/replay.yaml` file and run `dipdup init -b -f`.
39+
If you prefer to use other package manager, edit `configs/replay.yaml` file and run `dipdup init --force`.
4040

4141
## Docker
4242

docs/1.getting-started/4.package.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ When upgrading to a newer version of DipDup, particularly major releases, you ma
3939
To refresh your project package, run:
4040

4141
```shell [Terminal]
42-
dipdup init -b -f
42+
dipdup init --force
4343
make install
4444
```
4545

docs/12.faq.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ For historical reasons, Python package management is a mess. There are multiple
178178

179179
Using PDM/Poetry is not required to run DipDup, but strongly recommended. Choosing one over the other is a matter of personal preference. _As of writing_, Poetry is [faster](https://lincolnloop.github.io/python-package-manager-shootout/), more popular, and has a nicer CLI, while PDM is more PEP-compatible and allows dependency overrides.
180180

181-
You can choose the preferred tool (or none) when initializing a project with `dipdup new` command. If you change your mind later, modify the `replay.yaml` file and run `dipdup init --base --force`.
181+
You can choose the preferred tool (or none) when initializing a project with `dipdup new` command. If you change your mind later, modify the `replay.yaml` file and run `dipdup init --force`.
182182

183183
## Miscellaneous
184184

docs/5.advanced/2.environment-variables.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ DipDup uses multiple environment variables internally. They read once on process
1919
| `DIPDUP_MIGRATIONS` | Enable migrations with `aerich` |
2020
| `DIPDUP_NEXT` | Enable experimental features from the next major release that require schema changes |
2121
| `DIPDUP_NO_SYMLINK` | Don't create magic symlink in the package root even when used as cwd |
22+
| `DIPDUP_NO_LINTER` | Don't format and lint generated files with ruff |
23+
| `DIPDUP_NO_BASE` | Don't generate project template base |
2224
| `DIPDUP_NO_VERSION_CHECK` | Disable warning about running unstable or out-of-date DipDup version |
2325
| `DIPDUP_PACKAGE_PATH` | Disable package discovery and use the specified path |
2426
| `DIPDUP_REPLAY_PATH` | Path to datasource replay files; used in tests (dev only) |

docs/7.references/1.cli.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,13 @@ Discord: <a class="reference external" href="https://discord.gg/aG
190190
<dl class="std option">
191191
<dt class="sig sig-object std" id="cmdoption-dipdup-init-b">
192192
<span id="cmdoption-dipdup-init-base"></span><span class="sig-name descname"><span class="pre">-b</span></span><span class="sig-prename descclassname"></span><span class="sig-prename descclassname"><span class="pre">,</span> </span><span class="sig-name descname"><span class="pre">--base</span></span><span class="sig-prename descclassname"></span></dt>
193-
<dd><p>Include template base: pyproject.toml, Dockerfile, etc.</p>
193+
<dd><p>Include template base (default)</p>
194+
</dd></dl>
195+
196+
<dl class="std option">
197+
<dt class="sig sig-object std" id="cmdoption-dipdup-init-0">
198+
<span id="cmdoption-dipdup-init-no-base"></span><span class="sig-name descname"><span class="pre">-b</span></span><span class="sig-prename descclassname"></span><span class="sig-prename descclassname"><span class="pre">,</span> </span><span class="sig-name descname"><span class="pre">--no-base</span></span><span class="sig-prename descclassname"></span></dt>
199+
<dd><p>Skip template base</p>
194200
</dd></dl>
195201

196202
<dl class="std option">

docs/9.release-notes/1.v8.3.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ In this release, we've enhanced the integration:
3232
- Default project templates are configured to use `uv` by default
3333
- Better handling of dependencies and virtual environments
3434

35-
To switch to uv in existing projects, update your `configs/replay.yaml` and run `dipdup init -b -f`.
35+
To switch to uv in existing projects, update your `configs/replay.yaml` and run `dipdup init --force`.
3636

3737
::banner{type="warning"}
3838
Note that `uv` build backend (see [#3957](https://github.com/astral-sh/uv/issues/3957), available separately as `uv_build` package) doesn't support non-standard layout of DipDup packages. Hatchling build backend handles both editable and non-editable builds correctly.
@@ -56,7 +56,7 @@ Existing projects will continue to work with 8.3 without any modifications.
5656
If you want to use recent improvements like the MCP server, uv package manager, and Ruff formatter, refresh your project template:
5757

5858
```shell [Terminal]
59-
dipdup init -b -f
59+
dipdup init --force
6060
make install
6161
```
6262

docs/9.release-notes/_8.0_changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@
66
- cli: Added `--pre` flag to `self` group commands to install pre-release versions.
77
- cli: Added `--raw` option to `config export` command to dump config preserving the original structure.
88
- cli: Added `-C` option, a shorthand for `-c . -c configs/dipdup.<name>.yaml`.
9+
- cli: Added `init --no-base` option to skip creating the base template.
910
- cli: Added `package verify` command to check the package consistency.
1011
- cli: Added full project migration support for 3.0 spec.
1112
- cli: Added spec_version 3.0 support to `migrate` command.
1213
- config: Publish JSON schemas for config validation and autocompletion.
1314
- database: Added `dipdup_status` view to the schema.
1415
- env: Added `DIPDUP_JSON_LOG` environment variable to enable JSON logging.
1516
- env: Added `DIPDUP_LOW_MEMORY` variable to reduce the size of caches and buffers.
17+
- env: Added `DIPDUP_NO_BASE` environment variable to skip creating the base template.
1618
- env: Added `DIPDUP_PACKAGE_PATH` environment variable to override discovered package path.
1719
- package: Added built-in `batch` handler to modify higher-level indexing logic.
1820
- starknet.events: Added `starknet.events` index kind to process Starknet events.
@@ -25,6 +27,7 @@
2527
- cli: Don't save reports for successful test runs.
2628
- cli: Don't update existing installation in `self install` command unless asked to.
2729
- cli: Fixed `--pre` installer flag.
30+
- cli: Fixed `new` command using incorrect template.
2831
- cli: Fixed env files not being loaded in some commands.
2932
- cli: Fixed errors raised when the project package is invalid.
3033
- cli: Fixed progress estimation when there are indexes with `last_level` option set.
@@ -54,6 +57,7 @@
5457
### Changed
5558

5659
- api: `/performance` endpoint response format has been changed.
60+
- cli: `init --base` option is now enabled by default.
5761
- config: Index configs accept `datasources` list instead of `datasource` field.
5862
- config: Index kinds have been renamed and grouped by the network.
5963
- config: Index template values now can be any JSON-serializable object.

src/dipdup/cli.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,9 @@ def wrapper(ctx: click.Context, *args: Any, **kwargs: Any) -> None:
180180
except (KeyboardInterrupt, asyncio.CancelledError):
181181
pass
182182
except Exception as e:
183+
if isinstance(e, click.UsageError):
184+
raise
185+
183186
from dipdup.report import save_report
184187

185188
package = ctx.obj.config.package if ctx.obj else 'unknown'
@@ -347,7 +350,8 @@ async def run(ctx: click.Context) -> None:
347350

348351
@cli.command()
349352
@click.option('--force', '-f', is_flag=True, help='Overwrite existing types and ABIs.')
350-
@click.option('--base', '-b', is_flag=True, help='Include template base: pyproject.toml, Dockerfile, etc.')
353+
@click.option('--base', '-b', is_flag=True, help='Include template base (default)')
354+
@click.option('--no-base', '-b', is_flag=True, help='Skip template base')
351355
@click.option('--no-linter', is_flag=True, help='Skip linter and formatter.')
352356
@click.argument(
353357
'include',
@@ -361,6 +365,7 @@ async def init(
361365
ctx: click.Context,
362366
force: bool,
363367
base: bool,
368+
no_base: bool,
364369
no_linter: bool,
365370
include: list[str],
366371
) -> None:
@@ -370,12 +375,17 @@ async def init(
370375
"""
371376
from dipdup.dipdup import DipDup
372377

378+
if base:
379+
if no_base:
380+
raise click.BadParameter('You cannot use both `--base` and `--no-base` options at the same time')
381+
_logger.warning('`--base` option became default; use `--no-base` to disable it')
382+
373383
config: DipDupConfig = ctx.obj.config
374384
dipdup = DipDup(config)
375385

376386
await dipdup.init(
377387
force=force,
378-
base=base or bool(include),
388+
no_base=no_base or bool(include),
379389
no_linter=no_linter,
380390
include=set(include),
381391
)
@@ -416,9 +426,10 @@ async def migrate(ctx: click.Context, dry_run: bool) -> None:
416426
)
417427
await _cli_unwrapper(init)(
418428
ctx=ctx,
419-
base=True,
429+
base=False,
420430
force=True,
421431
no_linter=True,
432+
no_base=False,
422433
include=[],
423434
)
424435

@@ -993,6 +1004,7 @@ async def new(
9931004
base=False,
9941005
force=force,
9951006
no_linter=False,
1007+
no_base=False,
9961008
include=[],
9971009
)
9981010

0 commit comments

Comments
 (0)