inveniosoftware / invenio-cli

CLI module for Invenio
https://invenio-cli.readthedocs.io
MIT License
10 stars 43 forks source link

init/install: "project_dir" shouldn't be an absolute path, but auto-detected #121

Closed slint closed 4 years ago

slint commented 4 years ago

The fact that project_dir is filled-in during init as an absolute path, makes it not possible to re-use the generated project files in a different directory/machine. Example:

# In my machine (e.g. with "HOME=/home/slint")
$ invenio-cli init
...generate "zenodo-rdm" instance...
$ cd zenodo-rdm
$ cat zenodo-rdm/.invenio

[cli]
flavour = RDM
project_dir = /home/slint/src/zenodo-rdm
instance_path = /home/slint/Envs/zenodo-rdm-5ubStj9L/var/instance
logfile = /home/slint/src/zenodo-rdm/logs/invenio-cli.log
...
$ git init && git add . && git commit -m "initial commit" && git push ...

# in another machine (e.g. with "HOME=/home/glignos")
$ git clone https://gtihub.com/zenodo/zenodo-rdm.git && cd zenodo-rdm
$ invenio-cli install
$ invenio-cli install
Installing python dependencies...
...pipenv creates virutalenv correctly at /home/glignos/Envs/...
Symlinking invenio.cfg...
Symlinking templates/...
Collecting statics and assets...
...
Collect static from blueprints.
Created webpack project.
Installing js dependencies...
...
Installed webpack project.
Copying project statics and assets...
...fails with:

    distutils.errors.DistutilsFileError: cannot copy tree '/home/slint/src/zenodo-rdm/static': not a directory

A possible solution is to follow the behaviour of pipenv regarding the Pipfile location in order to auto-detect the project_dir value. Basically if you run invenio-cli in a directory that has a .invenio file, it should use this directory as the absolute path, instead of baking it in .invenio.

This probably also requires some design/refactoring on how the CLI determines its context...

ppanero commented 4 years ago

Thanks for reporting! It makes sense (Added it to the board)

P.S. Happy to see zenodo-rdm ;)

fenekku commented 4 years ago

@slint Oh my... thank you for that! Making sure the cli configuration/file is re-usable on different developer machine was a total blindspot on my part. Pablo and I have fixed a number of problems that was going to cause in https://github.com/inveniosoftware/invenio-cli/pull/125 .