redhataccess / pantheon-cmd

Pantheon CMD is an open source and freely distributed program for validating and building local previews of modular documentation.
GNU General Public License v3.0
2 stars 5 forks source link

Add a way to programmatically retrieve repo root and content directory paths #22

Open inoxx03 opened 3 years ago

inoxx03 commented 3 years ago

We should consider implementing a way for pcmd to retrieve the patsh to content directories form the shell. Having this feature would allow users to run pcmd from anywhere anywhere without having to run it from the root of the repository.

It could also improve the pantheon2.yml file generation feature, allowing the generation script to locate the content directory and add its path relative to the repository root under the modules and assemblies section of the YAML template.

We can use built in shell commands and git tools to avoid introducing too many package dependencies.

For example, we can retrieve the absolute path to the repository root using:

REPOSITORY_ROOT=$(git rev-parse --show-toplevel)

we can then get the root directory name using basename and use it to build relative paths to other content directories (If we only need the name of the root directory, we can do this in one step.)

ROOT_DIR=$(basename ${REPOSITORY_ROOT})

Alternatively, we can have the script locate the content directories automatically. This should be fairly easy to do, because we have standardized the content directory names to assemblies and modules across all repos so we can search for them by name We could use something like:

ASSEMBLIES_DIR=$(find ${REPOSITORY_ROOT} -type d -name "modules")

Please not that these are just initial suggestions, we can tweak and changes them based on usability and tooling considerations.