diff --git a/oarepo_model_builder/invenio/__init__.py b/oarepo_model_builder/invenio/__init__.py index 608b8ee4..968e924b 100644 --- a/oarepo_model_builder/invenio/__init__.py +++ b/oarepo_model_builder/invenio/__init__.py @@ -18,8 +18,6 @@ # utils and included "imports": "templates/imports.py.jinja2", # scripts - "script-bootstrap": "templates/script_bootstrap.sh.jinja2", - "script-runserver": "templates/script_runserver.sh.jinja2", "script-import-sample-data": "templates/script_import_sample_data.py.jinja2", "script-import-sample-data-shell": "templates/script_import_sample_data.sh.jinja2", } diff --git a/oarepo_model_builder/invenio/invenio_script_bootstrap.py b/oarepo_model_builder/invenio/invenio_script_bootstrap.py deleted file mode 100644 index ef2df433..00000000 --- a/oarepo_model_builder/invenio/invenio_script_bootstrap.py +++ /dev/null @@ -1,22 +0,0 @@ -from jinja2 import Environment, FunctionLoader, pass_context - -from oarepo_model_builder.builders import OutputBuilder -from oarepo_model_builder.builders.utils import ensure_directory -from oarepo_model_builder.templates import templates - - -class InvenioScriptBootstrapBuilder(OutputBuilder): - TYPE = "invenio_script_bootstrap" - - def finish(self): - context = {"settings": self.schema.settings} - - env = Environment( - loader=FunctionLoader(lambda tn: templates.get_template(tn, context["settings"])), - autoescape=False, - ) - - ensure_directory(self.builder, "scripts") - output = self.builder.get_output("diff", "scripts/bootstrap.sh") - output.write(env.get_template("script-bootstrap").render(context)) - output.make_executable() diff --git a/oarepo_model_builder/invenio/invenio_script_runserver.py b/oarepo_model_builder/invenio/invenio_script_runserver.py deleted file mode 100644 index 24f9e6f1..00000000 --- a/oarepo_model_builder/invenio/invenio_script_runserver.py +++ /dev/null @@ -1,22 +0,0 @@ -from jinja2 import Environment, FunctionLoader, pass_context - -from oarepo_model_builder.builders import OutputBuilder -from oarepo_model_builder.builders.utils import ensure_directory -from oarepo_model_builder.templates import templates - - -class InvenioScriptRunServerBuilder(OutputBuilder): - TYPE = "invenio_script_runserver" - - def finish(self): - context = {"settings": self.schema.settings} - - env = Environment( - loader=FunctionLoader(lambda tn: templates.get_template(tn, context["settings"])), - autoescape=False, - ) - - ensure_directory(self.builder, "scripts") - output = self.builder.get_output("diff", "scripts/runserver.sh") - output.write(env.get_template("script-runserver").render(context)) - output.make_executable() diff --git a/oarepo_model_builder/invenio/invenio_script_sample_data.py b/oarepo_model_builder/invenio/invenio_script_sample_data.py index 1463ea8e..825a43e8 100644 --- a/oarepo_model_builder/invenio/invenio_script_sample_data.py +++ b/oarepo_model_builder/invenio/invenio_script_sample_data.py @@ -180,7 +180,7 @@ def faker_provider(faker, settings, stack, params): class InvenioScriptSampleDataShellBuilder(OutputBuilder): - TYPE = "invenio_script_runserver" + TYPE = "invenio_script_sample_data_loader" def finish(self): context = {"settings": self.schema.settings} diff --git a/oarepo_model_builder/invenio/templates/script_bootstrap.sh.jinja2 b/oarepo_model_builder/invenio/templates/script_bootstrap.sh.jinja2 deleted file mode 100644 index 623a1620..00000000 --- a/oarepo_model_builder/invenio/templates/script_bootstrap.sh.jinja2 +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash - -cd `dirname $0`/.. - -set -e - -python3.9 -m venv .venv -source .venv/bin/activate - -pip install invenio-cli - -cd {{ settings.package_base.replace('_', '-') }}-sample-site -invenio-cli check-requirements -d -invenio-cli install -invenio-cli services setup -N - -cd .. - -# install back current app -pipenv run pip install -e . - -# create the branch -pipenv run invenio alembic revision "Create {{ settings.package_base }} branch." -b {{ settings.package_base }} -p dbdbc1b19cf2 --empty - -# apply the branch -pipenv run invenio alembic upgrade heads - -# initial revision -pipenv run invenio alembic revision "Initial revision." -b {{ settings.package_base }} - -find {{ settings.package_base }}/alembic -name "*py" | while read FN; do - echo "Fixing sqlalchemy file $FN" - # import sqlalchemy_utils - # remove length=16 from UUIDType(length=16) - # replace Text() with sa.Text() - cat "$FN" | \ - sed 's/import sqlalchemy as sa/import sqlalchemy as sa\nimport sqlalchemy_utils/' | \ - sed 's/UUIDType(length=16/UUIDType(/' | \ - sed 's/astext_type=Text()/astext_type=sa.Text()/' >"$FN".replaced - mv "$FN".replaced "$FN" -done - -# create db tables -pipenv run invenio alembic upgrade heads - -pipenv run invenio index destroy --yes-i-know || true -pipenv run invenio index init --force diff --git a/oarepo_model_builder/invenio/templates/script_runserver.sh.jinja2 b/oarepo_model_builder/invenio/templates/script_runserver.sh.jinja2 deleted file mode 100644 index 70338f5d..00000000 --- a/oarepo_model_builder/invenio/templates/script_runserver.sh.jinja2 +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - - -cd `dirname $0`/.. - -set -e - -source .venv/bin/activate - -# export FLASK_DEBUG=1 -cd {{ settings.package_base.replace('_', '-') }}-sample-site - -invenio-cli run \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index 4695c6f2..cd602e23 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = oarepo-model-builder -version = 1.0.0.dev17 +version = 1.0.0.dev18 description = An utility library that generates OARepo required data model files from a JSON specification file authors = Miroslav Bauer , Miroslav Simek readme = README.md @@ -78,8 +78,6 @@ oarepo_model_builder.builders = 0930-invenio_resource_setup_cfg = oarepo_model_builder.invenio.invenio_record_resource_setup_cfg:InvenioRecordResourceSetupCfgBuilder 0940-invenio_record_search_setup_cfg = oarepo_model_builder.invenio.invenio_record_search_setup_cfg:InvenioRecordSearchSetupCfgBuilder 0950-invenio_record_jsonschemas_setup_cfg = oarepo_model_builder.invenio.invenio_record_jsonschemas_setup_cfg:InvenioRecordJSONSchemasSetupCfgBuilder - 1000-invenio_script_bootstrap = oarepo_model_builder.invenio.invenio_script_bootstrap:InvenioScriptBootstrapBuilder - 1010-invenio_script_runserver = oarepo_model_builder.invenio.invenio_script_runserver:InvenioScriptRunServerBuilder 1020-invenio_script_import_sample_data = oarepo_model_builder.invenio.invenio_script_import_sample_data:InvenioScriptImportSampleDataBuilder 1030-invenio_script_sample_data = oarepo_model_builder.invenio.invenio_script_sample_data:InvenioScriptSampleDataBuilder 1040-invenio_script_sample_data_shell = oarepo_model_builder.invenio.invenio_script_sample_data:InvenioScriptSampleDataShellBuilder