Skip to content

Ability to inject lines into existing code #9

@derks

Description

@derks

Having a larger project broken out into smaller pieces is a useful usecase for Boss. For example and existing Django project from template, and django-app template that pastes into the existing django app. Adding a line to the 'INSTALLED_APPS' list in a django settings.py would be nice. For example:

Existing project settings.py:

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.admin',
    # boss.mark:installed_apps
)

Template boss.json:

{
    "injections": [
        ["installed_apps", "'@module@.apps.@app_name@',"]
    ]
}

Using a '#boss.mark' allows us to drop a line of code after the marking point. Might be nice to make the changes, and then present a 'diff' to the user making them accept the change... but maybe that is overkill.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions