Update the NodeJS version compat checks. (#3083)
- Unify the 1.x.y series and the 0.17.z series - Fix the check s.t. post-1.0, only the major versions are required to match
This commit is contained in:
parent
2afe5b88b8
commit
fdfef5f334
|
@ -1,6 +1,11 @@
|
|||
CHANGELOG
|
||||
=========
|
||||
|
||||
## 1.0.0-beta.2 (2019-08-13)
|
||||
|
||||
- Fix the package version compatibility checks in the NodeJS language host.
|
||||
[#3083](https://github.com/pulumi/pulumi/pull/3083)
|
||||
|
||||
## 1.0.0-beta.1 (2019-08-13)
|
||||
|
||||
- Do not propagate input properties to missing output properties during preview. The old behavior can cause issues that
|
||||
|
|
|
@ -160,6 +160,31 @@ func newLanguageHost(nodePath, runPath, engineAddress,
|
|||
}
|
||||
}
|
||||
|
||||
func compatibleVersions(a, b semver.Version) (bool, string) {
|
||||
switch {
|
||||
case a.Major == 0 && b.Major == 0:
|
||||
// If both major versions are pre-1.0, we require that the major and minor versions match.
|
||||
if a.Minor != b.Minor {
|
||||
return false, "Differing major or minor versions are not supported."
|
||||
}
|
||||
|
||||
case a.Major >= 1 && b.Major >= 1:
|
||||
// If both major versions are post-1.0, we require that the major versions match.
|
||||
if a.Major != b.Major {
|
||||
return false, "Differing major versions are not supported."
|
||||
}
|
||||
|
||||
case a.Major == 1 && b.Major == 0 && b.Minor == 17 || b.Major == 1 && a.Major == 0 && a.Minor == 17:
|
||||
// If one version is pre-1.0 and the other is post-1.0, we unify 1.x.y and 0.17.z. This combination is legal.
|
||||
|
||||
default:
|
||||
// All other combinations of versions are illegal.
|
||||
return false, "Differing major or minor versions are not supported."
|
||||
}
|
||||
|
||||
return true, ""
|
||||
}
|
||||
|
||||
// GetRequiredPlugins computes the complete set of anticipated plugins required by a program.
|
||||
func (host *nodeLanguageHost) GetRequiredPlugins(ctx context.Context,
|
||||
req *pulumirpc.GetRequiredPluginsRequest) (*pulumirpc.GetRequiredPluginsResponse, error) {
|
||||
|
@ -186,12 +211,12 @@ func (host *nodeLanguageHost) GetRequiredPlugins(ctx context.Context,
|
|||
continue
|
||||
}
|
||||
|
||||
if version.Major != firstVersion.Major || version.Minor != firstVersion.Minor {
|
||||
if ok, message := compatibleVersions(version, firstVersion); !ok {
|
||||
fmt.Fprintf(os.Stderr,
|
||||
`Found incompatible versions of @pulumi/pulumi. Differing major or minor versions are not supported.
|
||||
`Found incompatible versions of @pulumi/pulumi. %s
|
||||
Version %s referenced at %s
|
||||
Version %s referenced at %s
|
||||
`, firstVersion, firstPath, version, path)
|
||||
`, message, firstVersion, firstPath, version, path)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue