microsoft / rushstack

Monorepo for tools developed by the Rush Stack community
https://rushstack.io/
Other
5.93k stars 597 forks source link

[rush] Rush bulk commands not running postRushBuild #1794

Open clarktozer opened 4 years ago

clarktozer commented 4 years ago

Is this a feature or a bug?

I have different types of build commands which run with different variables. For example "rush build" and "rush build:dev". The standard "rush build" will run my postRushBuild script but the others such as "rush build:dev" which are defined in the command-line.json file do not.

Is it possible to run postRushBuild scripts on custom commands or will it only work on "rush build"?

iclanton commented 4 years ago

postRushBuild currently only runs after the built-in build command. We originally designed this to allow repo maintainers to collect telemetry for their builds.

For your scenario, can you run rush build for dev and rush build with a flag (like --production or something) for non-dev? That's what we do.

We can certainly expand the postRushBuild feature, but it'd be a nontrivial change and would require some design work.

clarktozer commented 4 years ago

Thanks! I've tried changing mine around to add the flags/choices from custom parameters.

I'm building a bunch of SPFx projects where the build command needs to run 3 gulp tasks (clean, bundle, package-solution). Then the post build is run which moves the SPFx packages. Both the bundle and package-solution gulp tasks need the flags to be passed to them from the rush custom parameters. That's why I separated them. Would it be better to create a custom gulp task which then starts the full build of SPFx to ensure the flags are passed through to both?

I can separate them out into 3 different rush commands.

rush build => gulp clean && gulp bundle rush package => gulp package-solution rush post-build => node common/scripts/post-build.js

With this there is no more call to the postRushBuild though. Ideally it would just have:

rush build => gulp clean && gulp bundle && gulp package-solution postRushBuild: ["node common/scripts/post-build.js"]