buildinspace / peru

a generic package manager, for including other people's code in your projects
MIT License
1.12k stars 69 forks source link

feature_request(enhancement): rename downloaded folders #205

Closed Kristinita closed 4 years ago

Kristinita commented 5 years ago

1. Summary

It would be nice, if peru can rename downloaded folders without using third-party tools.

2. Examples in other implementations

2.1. git

Change name of folder when cloning from GitHub:

git clone https://github.com/kira/pelican-kiragoddess.git kiragoddess

Repository clone to kiragoddess, not pelican-kiragoddess folder.

2.2. Python

Aliasing modules:

import pelican_kiragoddess as kiragoddess

3. Argumentation

I use plugins for Pelican — static sites generator. Names of some plugins begin to pelican- or pelican_:

pelican- plugins

That use some plugins, user needs to remove pelican- or pelican_ from plugin folder name. For example, if folder name is open_graph, Pelican will works; else pelican-open_graph — no.

4. Example of expected behavior

For peru.yaml:

imports:
  pelican-plugins: plugins/

git module pelican-plugins:
  url: https://github.com/getpelican/pelican-plugins
  pick:
  - pelican-open_graph
  - sitemap

New peru.yaml:

imports:
  pelican-plugins: plugins/

git module pelican-plugins:
  url: https://github.com/getpelican/pelican-plugins
  pick:
  - pelican-open_graph
  - sitemap

renames:
  pelican-open_graph: open_graph

Folder pelican-open_graph will rename to open_graph.

Thanks.

oconnor663 commented 5 years ago

Again apologies for leaving you hanging for so long. You put a lot of effort into these issues, and I feel bad for not responding promptly.

I think what you're trying to do works today with the move field. Try this:

imports:
  pelican-plugins: plugins/

git module pelican-plugins:
  url: https://github.com/getpelican/pelican-plugins
  move:
    pelican-open_graph: open_graph
  pick:
    - open_graph
    - sitemap
Kristinita commented 4 years ago

Status: CONFIRMED :heavy_check_mark:

I tested move, but I didn’t understand that the value for pick should be moved name, not original. This is a little confusing intuitively.

Thanks.

oconnor663 commented 4 years ago

Yes, rules fields are always applied in the order they're given in the docs, with copy/move first and export last. It's done that way because we get parsed YAML as a dictionary, which doesn't tell us the order in which keys were written. But that's definitely unexpected, and I should make the docs more explicit about it.

oconnor663 commented 4 years ago

9258b573100c8efc208668741151be621567707b