@platformatic/utils
Advanced tools
Comparing version 1.1.1 to 1.2.0
@@ -22,3 +22,3 @@ 'use strict' | ||
module.exports.checkForDependencies = packages.checkForDependencies | ||
module.exports.getLatestNpmVersion = packages.getLatestNpmVersion | ||
module.exports.errors = errors |
@@ -6,2 +6,3 @@ 'use strict' | ||
const isFileAccessible = require('./is-file-accessible') | ||
const { request } = require('undici') | ||
@@ -42,3 +43,12 @@ async function getDependencyVersion (require, dependencyName) { | ||
for (const m of modules) { | ||
requiredDependencies[m] = await getPlatformaticVersion() | ||
if (m.startsWith('@platformatic')) { | ||
requiredDependencies[m] = await getPlatformaticVersion() | ||
} else { | ||
const externalModuleVersion = await getLatestNpmVersion(m) | ||
if (externalModuleVersion === null) { | ||
logger.error(`Cannot find latest version on npm for package ${m}`) | ||
} else { | ||
requiredDependencies[m] = externalModuleVersion | ||
} | ||
} | ||
} | ||
@@ -60,4 +70,3 @@ | ||
} | ||
if (allRequiredDependenciesInstalled) return | ||
if (allRequiredDependenciesInstalled) return /* c8 ignore next */ | ||
} | ||
@@ -77,5 +86,17 @@ | ||
module.exports.getDependencyVersion = getDependencyVersion | ||
module.exports.getPlatformaticVersion = getPlatformaticVersion | ||
module.exports.hasDependency = hasDependency | ||
module.exports.checkForDependencies = checkForDependencies | ||
async function getLatestNpmVersion (pkg) { | ||
const res = await request(`https://registry.npmjs.org/${pkg}`) | ||
if (res.statusCode === 200) { | ||
const json = await res.body.json() | ||
return json['dist-tags'].latest | ||
} | ||
return null | ||
} | ||
module.exports = { | ||
getDependencyVersion, | ||
getPlatformaticVersion, | ||
hasDependency, | ||
checkForDependencies, | ||
getLatestNpmVersion | ||
} |
{ | ||
"name": "@platformatic/utils", | ||
"version": "1.1.1", | ||
"version": "1.2.0", | ||
"description": "Platformatic DB Utils", | ||
@@ -27,3 +27,4 @@ "main": "index.js", | ||
"leven": "~3.1.0", | ||
"minimatch": "^8.0.4" | ||
"minimatch": "^8.0.4", | ||
"undici": "^5.25.4" | ||
}, | ||
@@ -30,0 +31,0 @@ "scripts": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21355
253
5
+ Addedundici@^5.25.4
+ Added@fastify/busboy@2.1.1(transitive)
+ Addedundici@5.28.4(transitive)