buildinspace / peru

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

Named rules in sub-scoped peru files cause "Invalid name" errors at sync #242

Open KevinVdKAverna opened 1 year ago

KevinVdKAverna commented 1 year ago

The top-level peru.yaml file contains a module that possesses its own peru file. The peru file of the referenced module contains one or more named rules. These named rules generate "Invalid name" errors when running "peru sync" on the top-level file.

A likely reason for this error is that the name of modules and rules is validated prior to creating the Module and Rule objects. The name of a rule in the sub-level peru file receives a prefix from the parser to indicate its sub-level scope. The dot "." separator in the added prefix causes the validation to fail since rule and module names should not contain dots. For modules this works correctly since the validation of the name is performed prior to adding the prefix, but for named rules this is not the case.

Example:

This example would generate the error: "Invalid name: sub-level.builds".

# Top-level peru file
imports:
  sub-level: import_folder

git module sub-level:
  url: ...
# Sub-level peru file
imports:
  sub-level2|builds: import_folder2

git module sub-level2:
  url: ...

rule builds:
  export: builds