MCPcopy Create free account
hub / github.com/parse-community/parse-dashboard / check

Function check

ci/nodeEngineCheck.mjs:154–209  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

152}
153
154async function check() {
155 try {
156 // Define paths
157 const nodeModulesPath = path.join(__dirname, '../node_modules');
158 const packageJsonPath = path.join(__dirname, '../package.json');
159
160 // Create check
161 const check = new NodeEngineCheck({
162 nodeModulesPath,
163 packageJsonPath,
164 });
165
166 // Get package node version of parent package
167 const parentVersion = await check.getParentVersion();
168
169 // Determine parent min version
170 const parentMinVersion = semver.minVersion(parentVersion.nodeVersion);
171
172 // Get package.json files
173 const files = await check.getPackageFiles();
174 core.info(`Checking the minimum node version requirement of ${files.length} dependencies`);
175
176 // List of package.json paths that should be skipped
177 const ignoredFilePaths = [
178 // Malformed package.json for testing purpose in eslint-plugin-react
179 /eslint-plugin-react\/.*malformed.*/,
180 ];
181
182 // Get node versions
183 const versions = await check.getNodeVersion({ files, ignoredFilePaths, clean: true });
184
185 // Get are dependencies that require a higher node version than the parent package
186 const higherVersions = check.getHigherVersions({ versions, baseVersion: parentMinVersion });
187
188 // Get highest version
189 const highestVersion = higherVersions.map(v => v.nodeMinVersion).pop();
190
191 // If there are higher versions
192 if (higherVersions.length > 0) {
193 console.log(`\nThere are ${higherVersions.length} dependencies that require a higher node engine version than the parent package (${parentVersion.nodeVersion}):`);
194
195 // For each dependency
196 for (const higherVersion of higherVersions) {
197
198 // Get package name
199 const _package = higherVersion.file.split('node_modules/').pop().replace('/package.json', '');
200 console.log(`- ${_package} requires at least node ${higherVersion.nodeMinVersion} (${higherVersion.nodeVersion})`);
201 }
202 throw `\n❌ Upgrade the node engine version in package.json to at least '${highestVersion}' to satisfy the dependencies.\n`;
203 }
204
205 console.log(`\n✅ All dependencies satisfy the node version requirement of the parent package (${parentVersion.nodeVersion}).\n`);
206 } catch (err) {
207 core.setFailed(err);
208 }
209}
210
211check();

Callers 1

Calls 4

getParentVersionMethod · 0.95
getPackageFilesMethod · 0.95
getNodeVersionMethod · 0.95
getHigherVersionsMethod · 0.95

Tested by

no test coverage detected