toolsplus / nx-forge

Atlassian Forge plugin for Nx
https://toolsplus.github.io/nx-forge/
MIT License
17 stars 4 forks source link

Bug: Loading manifest does not account for sub-directories #38

Closed jackgraves closed 1 year ago

jackgraves commented 1 year ago

If you use sub-directories with nx, to have a nested structure, the load-manifest-yml.js file does not account for this and fails, nx uses some logic to convert '/' to '-' to produce package names, however it is able to account for this - but the load manifest file does not.

I'm not sure if there is an nx command which will perform this conversion automatically.

e.g. The forge app manifest location: apps/test/subdirectory/app/manifest.yml Where the script looks: apps/test-subdirectory-app/manifest.yml

Error: Failed to parse manifest.yml (/.../test-subdirectory-app/manifest.yml): To run this command, make sure you're in the top-level directory of your app, and the manifest.yml file is in the same directory.
    at /.../node_modules/.pnpm/@toolsplus+nx-forge@1.5.0/node_modules/@toolsplus/nx-forge/src/utils/forge/load-manifest-yml.js:11:19
    at Generator.next (<anonymous>)
    at fulfilled (/.../node_modules/.pnpm/tslib@2.5.0/node_modules/tslib/tslib.js:164:62)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
tbinna commented 1 year ago

Hey @jackgraves, I just had a peek at the code. I guess there are two places here and here where the construction of the manifest path is not correct, i.e., it assumes the manifest always lives under <context.root>/apps/<context.projectName>/manifest.yml. According to this logic, I would assume that test-subdirectory-app is your project name, right? The project should be defined as name in the project.json file under apps/test/subdirectory/app.

I think the solution would be along the lines of using readProjectConfiguration(tree, context.projectName). The resulting ProjectConfiguration object contains the root property which I believe is what should be used to build the manifest path.

Once this is fixed, more issues may pop up with the sub-directory structure, but I expect the fixes to be along the same lines.

github-actions[bot] commented 1 year ago

:tada: This issue has been resolved in version 2.0.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket: