rushstack icon indicating copy to clipboard operation
rushstack copied to clipboard

[rush-lib] components package.json JSON format validation & version adherence to semver validation

Open 1000RR opened this issue 3 years ago • 6 comments

Summary

This PR seeks to solve 2 issues:

  • rush repo components' package.json version not in semver format fails when listed as a dependency with workspace:* in another project - https://github.com/microsoft/rushstack/issues/2678
  • when running rush update and there are parsing errors in a component's package.json, pnpm does not provide stderr/stdio feedback - only exit code 1, which is not descriptive to the user. The rush update error message is ERROR: Error: The command failed with exit code 1

Details

  • The component version is manually checked for being in semver format after package.json is loaded.
  • Package.json parsing of rush repos' subprojects' validates strict JSON format - no comments, syntactically correct.

How it was tested

  • building a project containing 2 components A and B, where A imports B's workspace:* version. 2 tests cases:

    • B's package.json version is set to 1.0 (new error message shown, graceful exit)
    • B's package.json version is set to 1.0.0(runs ok, graceful exit)
  • building a project where a component's package.json is malformed JSON - with comments or extra/missing commas.

  • [x] 👉 STEP 7: Don't forget to run "rush change": https://rushjs.io/pages/best_practices/change_logs/

1000RR avatar Jul 28 '22 21:07 1000RR

CLA assistant check
All CLA requirements met.

ghost avatar Jul 28 '22 21:07 ghost

  • when running rush update and there are parsing errors in a component's package.json, pnpm does not provide stderr/stdio feedback - only exit code 1, which is not descriptive to the user. The rush update error message is ERROR: Error: The command failed with exit code 1

🥳 yes, let's finally fix this! 🙏

octogonz avatar Jul 30 '22 18:07 octogonz

Your new API can also fix this issue: https://github.com/microsoft/rushstack/issues/996

octogonz avatar Jul 30 '22 19:07 octogonz

Legal sign-off is pending.

On Mon, Aug 1, 2022 at 16:46 Pete Gonzalez @.***> wrote:

@.**** commented on this pull request.

In libraries/rush-lib/src/api/RushConfigurationProject.ts https://github.com/microsoft/rushstack/pull/3560#discussion_r934998049:

@@ -106,7 +106,7 @@ export class RushConfigurationProject { const packageJsonFilename: string = path.join(this._projectFolder, FileConstants.PackageJson);

 try {
  •  this._packageJson = JsonFile.load(packageJsonFilename);
    
  •  this._packageJson = JsonFile.load(packageJsonFilename, true);
    

We need you to sign the CLA in order to get this PR merged.

— Reply to this email directly, view it on GitHub https://github.com/microsoft/rushstack/pull/3560#discussion_r934998049, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJ3OSFS45SQQU42MRWWY4ZTVXBOV7ANCNFSM546YMWDA . You are receiving this because you were mentioned.Message ID: @.***>

1000RR avatar Aug 02 '22 01:08 1000RR

@octogonz Legal has cleared the CLA - good to go.

1000RR avatar Aug 10 '22 21:08 1000RR

@1000RR if you're good with these changes, could you promote this to a non-draft PR?

octogonz avatar Aug 11 '22 01:08 octogonz

@octogonz Looks like it's ready to go.

1000RR avatar Aug 16 '22 21:08 1000RR

@octogonz may I ask for a final review and merge?

1000RR avatar Aug 23 '22 20:08 1000RR

@octogonz may I ask for a final review and merge?

Thanks for the reminder. And thanks for your patience -- things have been very busy lately. 😄

octogonz avatar Aug 24 '22 02:08 octogonz