dotnet-deps-parser
Advanced tools
Comparing version 5.4.0 to 5.5.0
@@ -7,6 +7,6 @@ "use strict"; | ||
const path = require("path"); | ||
const error_catalog_nodejs_public_1 = require("@snyk/error-catalog-nodejs-public"); | ||
const parsers_1 = require("./parsers"); | ||
Object.defineProperty(exports, "DepType", { enumerable: true, get: function () { return parsers_1.DepType; } }); | ||
const project_assets_json_parser_1 = require("./parsers/project-assets-json-parser"); | ||
const errors_1 = require("./errors"); | ||
const PROJ_FILE_EXTENSIONS = ['.csproj', '.vbproj', '.fsproj']; | ||
@@ -22,3 +22,3 @@ function buildDepTreeFromProjectJson(manifestFileContents, includeDev = false) { | ||
if (!targetFramework) { | ||
throw new Error('Missing targetFramework for project.assets.json'); | ||
throw new error_catalog_nodejs_public_1.OpenSourceEcosystems.MissingPayloadError('Missing targetFramework for project.assets.json'); | ||
} | ||
@@ -42,8 +42,9 @@ // trimming required to address files with UTF-8 with BOM encoding | ||
if (!root || !manifestFilePath) { | ||
throw new Error('Missing required parameters for buildDepTreeFromFiles()'); | ||
throw new error_catalog_nodejs_public_1.OpenSourceEcosystems.MissingPayloadError('Missing required parameters for building dependency tree from files'); | ||
} | ||
const manifestFileFullPath = path.resolve(root, manifestFilePath); | ||
if (!fs.existsSync(manifestFileFullPath)) { | ||
throw new Error('No packages.config, project.json or project file found at ' + | ||
`location: ${manifestFileFullPath}`); | ||
throw new error_catalog_nodejs_public_1.OpenSourceEcosystems.CannotGetFileFromSourceError('No packages.config, project.json or project file found', { | ||
location: manifestFileFullPath, | ||
}); | ||
} | ||
@@ -65,4 +66,6 @@ const manifestFileContents = fs.readFileSync(manifestFileFullPath, 'utf-8'); | ||
else { | ||
throw new Error(`Unsupported file ${manifestFilePath}, Please provide ` + | ||
'either packages.config or project file.'); | ||
throw new error_catalog_nodejs_public_1.OpenSourceEcosystems.UnsupportedManifestFileError('Unsupported file, please provide ' + | ||
'either packages.config or project file.', { | ||
location: manifestFilePath, | ||
}); | ||
} | ||
@@ -73,7 +76,9 @@ } | ||
if (!root || !manifestFilePath) { | ||
throw new Error('Missing required parameters for extractTargetFrameworksFromFiles()'); | ||
throw new error_catalog_nodejs_public_1.OpenSourceEcosystems.MissingPayloadError('Missing required parameters for extractTargetFrameworksFromFiles()'); | ||
} | ||
const manifestFileFullPath = path.resolve(root, manifestFilePath); | ||
if (!fs.existsSync(manifestFileFullPath)) { | ||
throw new Error('No project file found at ' + `location: ${manifestFileFullPath}`); | ||
throw new error_catalog_nodejs_public_1.OpenSourceEcosystems.CannotGetFileFromSourceError('No project file found', { | ||
location: manifestFileFullPath, | ||
}); | ||
} | ||
@@ -95,4 +100,6 @@ const manifestFileContents = fs.readFileSync(manifestFileFullPath, 'utf-8'); | ||
else { | ||
throw new Error(`Unsupported file ${manifestFilePath}, Please provide ` + | ||
'a project *.csproj, *.vbproj, *.fsproj or packages.config file.'); | ||
throw new error_catalog_nodejs_public_1.OpenSourceEcosystems.UnsupportedManifestFileError('Unsupported file, please provide ' + | ||
'a project *.csproj, *.vbproj, *.fsproj or packages.config file.', { | ||
location: manifestFilePath, | ||
}); | ||
} | ||
@@ -102,19 +109,9 @@ } | ||
async function extractTargetFrameworksFromProjectFile(manifestFileContents) { | ||
try { | ||
const manifestFile = await (0, parsers_1.parseXmlFile)(manifestFileContents); | ||
return (0, parsers_1.getTargetFrameworksFromProjectFile)(manifestFile); | ||
} | ||
catch (err) { | ||
throw new Error(`Extracting target framework failed with error ${err.message}`); | ||
} | ||
const manifestFile = await (0, parsers_1.parseXmlFile)(manifestFileContents); | ||
return (0, parsers_1.getTargetFrameworksFromProjectFile)(manifestFile); | ||
} | ||
exports.extractTargetFrameworksFromProjectFile = extractTargetFrameworksFromProjectFile; | ||
async function extractTargetFrameworksFromProjectConfig(manifestFileContents) { | ||
try { | ||
const manifestFile = await (0, parsers_1.parseXmlFile)(manifestFileContents); | ||
return (0, parsers_1.getTargetFrameworksFromProjectConfig)(manifestFile); | ||
} | ||
catch (err) { | ||
throw new Error(`Extracting target framework failed with error ${err.message}`); | ||
} | ||
const manifestFile = await (0, parsers_1.parseXmlFile)(manifestFileContents); | ||
return (0, parsers_1.getTargetFrameworksFromProjectConfig)(manifestFile); | ||
} | ||
@@ -131,21 +128,23 @@ exports.extractTargetFrameworksFromProjectConfig = extractTargetFrameworksFromProjectConfig; | ||
async function extractTargetFrameworksFromProjectJson(manifestFileContents) { | ||
let manifestFile; | ||
try { | ||
// trimming required to address files with UTF-8 with BOM encoding | ||
const manifestFile = JSON.parse(manifestFileContents.trim()); | ||
return (0, parsers_1.getTargetFrameworksFromProjectJson)(manifestFile); | ||
manifestFile = JSON.parse(manifestFileContents.trim()); | ||
} | ||
catch (err) { | ||
throw new Error(`Extracting target framework failed with error ${err.message}`); | ||
throw new error_catalog_nodejs_public_1.OpenSourceEcosystems.UnparseableManifestError('Failed to parse manifest file'); | ||
} | ||
return (0, parsers_1.getTargetFrameworksFromProjectJson)(manifestFile); | ||
} | ||
exports.extractTargetFrameworksFromProjectJson = extractTargetFrameworksFromProjectJson; | ||
async function extractTargetFrameworksFromProjectAssetsJson(manifestFileContents) { | ||
let manifestFile; | ||
try { | ||
// trimming required to address files with UTF-8 with BOM encoding | ||
const manifestFile = JSON.parse(manifestFileContents.trim()); | ||
return (0, parsers_1.getTargetFrameworksFromProjectAssetsJson)(manifestFile); | ||
manifestFile = JSON.parse(manifestFileContents.trim()); | ||
} | ||
catch (err) { | ||
throw new Error(`Extracting target framework failed with error ${err.message}`); | ||
throw new error_catalog_nodejs_public_1.OpenSourceEcosystems.UnparseableManifestError('Failed to parse manifest file'); | ||
} | ||
return (0, parsers_1.getTargetFrameworksFromProjectAssetsJson)(manifestFile); | ||
} | ||
@@ -168,17 +167,9 @@ exports.extractTargetFrameworksFromProjectAssetsJson = extractTargetFrameworksFromProjectAssetsJson; | ||
async function extractProps(propsFileContents) { | ||
try { | ||
const propsFile = await (0, parsers_1.parseXmlFile)(propsFileContents); | ||
if (!propsFile) { | ||
throw new errors_1.InvalidUserInputError('xml file parsing failed'); | ||
} | ||
return (0, parsers_1.getPropertiesMap)(propsFile); | ||
const propsFile = await (0, parsers_1.parseXmlFile)(propsFileContents); | ||
if (!propsFile) { | ||
throw new error_catalog_nodejs_public_1.OpenSourceEcosystems.MissingPayloadError('Empty xml file'); | ||
} | ||
catch (err) { | ||
if (err.name === 'InvalidUserInputError') { | ||
throw err; | ||
} | ||
throw new Error(`Extracting props failed with error ${err.message}`); | ||
} | ||
return (0, parsers_1.getPropertiesMap)(propsFile); | ||
} | ||
exports.extractProps = extractProps; | ||
//# sourceMappingURL=index.js.map |
@@ -6,3 +6,3 @@ "use strict"; | ||
const lodash_1 = require("lodash"); | ||
const errors_1 = require("../errors"); | ||
const error_catalog_nodejs_public_1 = require("@snyk/error-catalog-nodejs-public"); | ||
var DepType; | ||
@@ -203,3 +203,3 @@ (function (DepType) { | ||
if (err) { | ||
const e = new errors_1.InvalidUserInputError('xml file parsing failed'); | ||
const e = new error_catalog_nodejs_public_1.OpenSourceEcosystems.UnparseableManifestError('Manifest xml file parsing failed'); | ||
return reject(e); | ||
@@ -206,0 +206,0 @@ } |
@@ -31,2 +31,3 @@ { | ||
"dependencies": { | ||
"@snyk/error-catalog-nodejs-public": "^3.18.6", | ||
"lodash": "^4.17.21", | ||
@@ -47,3 +48,3 @@ "source-map-support": "^0.5.21", | ||
}, | ||
"version": "5.4.0" | ||
"version": "5.5.0" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
50466
4
12
625
+ Added@snyk/error-catalog-nodejs-public@3.18.6(transitive)
+ Addedtslib@2.7.0(transitive)
+ Addeduuid@9.0.1(transitive)