Add project hash information to `nx print-affected` output
See original GitHub issueDescription
I’d like to see a set of fields added to the print affected json output, something like
{
"projects": [...],
"projectGraph": {...},
"hashes": {
"my-app": {
"current": "4b669d95627bf6724502d7b4ff6f41d3654c50ba9e3b1cf31e72c138370423f8",
"previous": "0bdb20fbd1788957302f4cf356ff0449ee3c2d10960814f6c34fd399fa64f5d3"
}
}
}
This hash key should include all projects, not just the affected ones.
Motivation
I use nx print-affected in order to dynamically generate a CI pipeline which works amazingly well, however I have a need to determine the current hash of an unchanged project so that I can fetch the docker container
Suggested Implementaion
I assume that the affected projects is determined by some hashing already, so it must be feasible to add this into the affected output
Alternate Implementations
This could be a completely different command line tool if needed.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:19
- Comments:20 (2 by maintainers)
Top Results From Across the Web
Getting Started with Monorepo with Nx Nrwl - Rupesh Tiwari
Let's create a loggingService inside our logger project. Use Nx Console to create angular service. This is dry run result of angular service ......
Read more >Module: index - Nx
The Nx Devkit is used to customize Nx for different technologies and use cases. ... Hash. • Hash: Object ... Adds project configuration...
Read more >How to Deploy Nx monorepos to Netlify
Next-level monorepos with Nx. Let's add a new app to our repo, a bike-store-api : api project added next to the...
Read more >10x Faster CI with Nx and Github Actions - Medium
Depending on the target and the Github reference, the print-affected command provided by Nx CLI returns the list of projects affected by the ......
Read more >Nrwl/Community #support #npm-packages #random
I've added root and feature state using nrwl ngrx schematics and it inserted ... Does anyone know of a way to run nx...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
If there isn’t any plans to support exposing the hash again, which would be super sad, then maybe it is enough to use the Hasher in a custom script by importing it from
import { Hasher } from '@nrwl/workspace/src/core/hasher/hasher';
.ng print-affected --target=build --all
could provide theProjectGraph
and the tasks needed to get the hashes from the Hasher using thehashTaskWithDepsAndContext
function.e.g. something like
I spent some time during a hackday to see if I could get something in our case to get back the hash on a per app/per lib case.
I did dug into the diff mentioned by @zakhenry, I also looked into “NX plugins and devkit”, “NX plugins”, “Creating Custom Executors”, the
affected
function and therunAllTasks
function (which uses theHasher
). Unfortunately, I don’t think there’s any way to export those directly without updating the code on NX side.Plugins and custom executors won’t be able to add something like/modify the
affected
command.I also tried a dummy approach of using NX through a node script like this:
but unless I copy the whole
affected
file to modify it, I don’t think there’s any argument I can pass to tweak the output 🤔. And for obvious reason I don’t want to do that (that’d be like maintaining a small fork of NX…).I’m also confused by the commit that @zakhenry mentioned. This commit is called “feat(core): add support for custom hashers” so I’d expect the ability to customize the hashing strategy from a consumer point of view but maybe that’s not it.
Anyway from here I’ve got 2 things to highlight:
nx my-custom-command
). But this may go against nx philosophy, unsureThanks for any help on this 🙏 We’re now stuck to nx 12.2.0 till we solve it as our CI pipeline relies on the hashes 🙏