MCPcopy Index your code
hub / github.com/parse-community/parse-server / check

Function check

ci/nodeEngineCheck.js:139–196  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

137}
138
139async function check() {
140 core = await import('@actions/core');
141 // Define paths
142 const nodeModulesPath = path.join(__dirname, '../node_modules');
143 const packageJsonPath = path.join(__dirname, '../package.json');
144
145 // Create check
146 const check = new NodeEngineCheck({
147 nodeModulesPath,
148 packageJsonPath,
149 });
150
151 // Get package node version of parent package
152 const parentVersion = await check.getParentVersion();
153
154 // If parent node version could not be determined
155 if (parentVersion === undefined) {
156 core.setFailed(`Failed to determine node engine version of parent package at ${this.packageJsonPath}`);
157 return;
158 }
159
160 // Determine parent min version
161 const parentMinVersion = semver.minVersion(parentVersion.nodeVersion);
162
163 // Get package.json files
164 const files = await check.getPackageFiles();
165 core.info(`Checking the minimum node version requirement of ${files.length} dependencies`);
166
167 // Get node versions
168 const versions = await check.getNodeVersion({ files, clean: true });
169
170 // Get are dependencies that require a higher node version than the parent package
171 const higherVersions = check.getHigherVersions({ versions, baseVersion: parentMinVersion });
172
173 // Get highest version
174 const highestVersion = higherVersions.map(v => v.nodeMinVersion).pop();
175
176 /* eslint-disable no-console */
177 // If there are higher versions
178 if (higherVersions.length > 0) {
179 console.log(`\nThere are ${higherVersions.length} dependencies that require a higher node engine version than the parent package (${parentVersion.nodeVersion}):`);
180
181 // For each dependency
182 for (const higherVersion of higherVersions) {
183
184 // Get package name
185 const _package = higherVersion.file.split('node_modules/').pop().replace('/package.json', '');
186 console.log(`- ${_package} requires at least node ${higherVersion.nodeMinVersion} (${higherVersion.nodeVersion})`);
187 }
188 console.log('');
189 core.setFailed(`❌ Upgrade the node engine version in package.json to at least '${highestVersion}' to satisfy the dependencies.`);
190 console.log('');
191 return;
192 }
193
194 console.log(`✅ All dependencies satisfy the node version requirement of the parent package (${parentVersion.nodeVersion}).`);
195 /* eslint-enable no-console */
196}

Callers 1

nodeEngineCheck.jsFile · 0.70

Calls 6

getParentVersionMethod · 0.95
getPackageFilesMethod · 0.95
getNodeVersionMethod · 0.95
getHigherVersionsMethod · 0.95
infoMethod · 0.80
logMethod · 0.45

Tested by

no test coverage detected