@@ -33,6 +33,7 @@ export const getExpectedVersion = async function ({
33
33
pinnedVersion,
34
34
featureFlags,
35
35
systemLog,
36
+ authoritative,
36
37
} : {
37
38
versions : PluginVersion [ ]
38
39
/** The package.json of the repository */
@@ -44,6 +45,11 @@ export const getExpectedVersion = async function ({
44
45
pinnedVersion ?: string
45
46
featureFlags ?: FeatureFlags
46
47
systemLog : SystemLogger
48
+ /* Defines whether the version returned from this method is the authoritative
49
+ version that will be used for the plugin; if not, the method may be called
50
+ just to get information about other compatible versions that will not be
51
+ selected */
52
+ authoritative ?: boolean
47
53
} ) {
48
54
const { version, conditions = [ ] } = await getCompatibleEntry ( {
49
55
versions,
@@ -54,7 +60,7 @@ export const getExpectedVersion = async function ({
54
60
buildDir,
55
61
pinnedVersion,
56
62
featureFlags,
57
- systemLog,
63
+ systemLog : authoritative ? systemLog : undefined ,
58
64
} )
59
65
60
66
// Retrieve warning message shown when using an older version with `compatibility`
@@ -87,7 +93,9 @@ const getCompatibleEntry = async function ({
87
93
buildDir,
88
94
pinnedVersion,
89
95
featureFlags,
90
- systemLog,
96
+ systemLog = ( ) => {
97
+ // no-op
98
+ } ,
91
99
} : {
92
100
versions : PluginVersion [ ]
93
101
packageJson : PackageJson
@@ -97,7 +105,7 @@ const getCompatibleEntry = async function ({
97
105
packagePath ?: string
98
106
pinnedVersion ?: string
99
107
featureFlags ?: FeatureFlags
100
- systemLog : SystemLogger
108
+ systemLog ? : SystemLogger
101
109
} ) : Promise < Pick < PluginVersion , 'conditions' | 'version' > > {
102
110
const compatibleEntry = await pLocate ( versions , async ( { version, overridePinnedVersion, conditions } ) => {
103
111
// When there's a `pinnedVersion`, we typically pick the first version that
@@ -126,10 +134,16 @@ const getCompatibleEntry = async function ({
126
134
} )
127
135
128
136
if ( compatibleEntry ) {
137
+ systemLog (
138
+ `Used compatible version '${ compatibleEntry . version } ' for plugin '${ packageName } ' (pinned version is ${ pinnedVersion } )` ,
139
+ )
140
+
129
141
return compatibleEntry
130
142
}
131
143
132
144
if ( pinnedVersion ) {
145
+ systemLog ( `Used pinned version '${ pinnedVersion } ' for plugin '${ packageName } '` )
146
+
133
147
return { version : pinnedVersion , conditions : [ ] }
134
148
}
135
149
0 commit comments