Skip to content

Instantly share code, notes, and snippets.

@JamieMason
Last active February 19, 2023 20:46
Show Gist options
  • Save JamieMason/a042cc26e5432df39cfe5f72877b059d to your computer and use it in GitHub Desktop.
Save JamieMason/a042cc26e5432df39cfe5f72877b059d to your computer and use it in GitHub Desktop.

EDIT: Some of these issues have since been fixed in https://github.com/JamieMason/syncpack/releases/tag/9.7.4

@fluidframework etc

		// GROUP 1
		// TODO: This group doesn't seem to work and it's not clear why
		// All dependencies on common Fluid packages outside the release group should match
		{
			dependencies: [
				"@fluidframework/build-common",
				"@fluidframework/eslint-config-fluid",
				"@fluidframework/build-tools",
				"@fluid-tools/build-cli",
			],
			packages: ["**"],
		},

This seems correct in 9.3.2, please confirm, here is the output of syncpack list:

= Version Group 1 ==============================================================
- @fluid-tools/build-cli ^0.9.0
- @fluidframework/build-common ^1.1.0
- @fluidframework/build-tools ^0.9.0
- @fluidframework/eslint-config-fluid ^2.0.0

Issue 1

Run syncpack list-mismatches and view the output.

Output will look like this:

= Version Group 2 ==============================================================
✘ npm has mismatched versions which syncpack cannot fix
  ^6 in engines.npm of package.json
  ^5 in engines.npm of packages/framework/fluid-framework/package.json
  ^5 in engines.npm of packages/framework/tinylicious-client/package.json
= Default Version Group ========================================================
✘ node >=14.13.0 is the highest valid semver version in use
  ^12.13.0 in engines.node of packages/framework/fluid-framework/package.json
  ^12.13.0 in engines.node of packages/framework/tinylicious-client/package.json

The mismatched node version is caught, but I expected the it to be group 3, but it's in the default group. The relevant section of the syncpack config looks like this:

customTypes: {
  enginesNpm: {
    path: "engines.npm",
    strategy: "version",
  },
  enginesNode: {
    path: "engines.node",
    strategy: "version",
  },
  packageManager: {
    path: "packageManager",
    strategy: "name@version",
  },
},

// ...

// GROUP 3
// engines.npm field should match
{
  dependencyTypes: ["enginesNpm"],
  dependencies: ["**"],
  packages: ["**"],
},

// GROUP 2
// packageManager field versions should match, though this field is only used in the release group root
// package.json today.
{
  dependencyTypes: ["packageManager"],
  dependencies: ["**"],
  packages: ["**"],
},

There is no version group for enginesNode, just the one for enginesNpm – by the way, if you want to check everything under engines you can use:

{
  "customTypes": {
    "engines": {
      "path": "engines",
      "strategy": "versionsByName"
    },
  }
}

as it is though they'll need their own group if you want to give it its own header - the way it's linted and fixed though will be identical whether it's in a group or not though, because it's set to apply to every dependency in every package via the pair of ** globs.

Issue 2

Run syncpack lint-semver-ranges from the root of the repo.

Output will look like this:

= Semver Group 1 ===============================================================
✘ node
  ^12.13.0 → >=12.13.0 in engines.node of packages/framework/fluid-framework/package.json
  ^12.13.0 → >=12.13.0 in engines.node of packages/framework/tinylicious-client/package.json

The mismatched node version is caught, but I expected the it to be group 8, but it's in group 1.

After our discussion on the order being confusing, I un-reversed them in 9.3.2.

Issue 3

The npm version mismatch is missed. I expected it to be caught in group 7. I suspect that node would have also been missed but not for group 1, which has the same range requirement as npm.

The output for this is:

✘ npm has mismatched versions which syncpack cannot fix
  ^6 in engines.npm of package.json
  >=5 in engines.npm of packages/framework/fluid-framework/package.json
  ^5 in engines.npm of packages/framework/tinylicious-client/package.json

As a workaround, if you add .0.0 to the end of those versions it will recognise it as semver and work. This is probably a bug.

Issue 4

Run syncpack set-semver-ranges or syncpack fix-mismatches from the root of the repo; they both seem to behave the same way.

Files are overwritten with spaces instead of tabs. The indent: "\t" setting in the syncpack config is ignored.

This a bug to how config from the CLI and/or rcFile is merged and defaulted, will fix.

Issue 5

Reset changes from issue 4 using git reset --hard, then run syncpack set-semver-ranges --indent $'\t' or syncpack fix-mismatches --indent $'\t' from the root of the repo. This works around issue 4; both commands seem to behave the same way.

Makes sense, same as Issue 4, I think I know what this is and will fix.

Ignore changes in the experimental folder. Look at the changes in the fluid-framework and tinylicious-client packages. The npm version is mismatched, but the node version is corrected. I expected the npm version to be updated as well.

This will be the same as Issue 3, add .0.0 to the ends of the versions to workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment