Socket
Socket
Sign inDemoInstall

snyk-paket-parser

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

snyk-paket-parser - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

dist/dependencies-parser.d.ts

67

dist/index.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const lock_parser_1 = require("./lock-parser");
const path = require("path");
const fs = require("fs");
var DepType;
(function (DepType) {
DepType["prod"] = "prod";
DepType["dev"] = "dev";
})(DepType || (DepType = {}));
function parse(manifestFileContents, lockFileContents, includeDev = false) {
// parse manifestFileContents here too when the time comes
const lockFile = lock_parser_1.parseLockFile(lockFileContents);
return buildDependencyTree(lockFile, includeDev);
}
function parseFromFile(root, manifestFilePath, lockFilePath, includeDev = false) {
if (!root || !manifestFilePath || !lockFilePath) {
throw new Error('Missing required parameters for parseFromFile()');
}
const manifestFileFullPath = path.resolve(root, manifestFilePath);
const lockFileeFullPath = path.resolve(root, lockFilePath);
if (!fs.existsSync(manifestFileFullPath)) {
throw new Error('No paket.dependencies file found at ' +
`location: ${manifestFileFullPath}`);
}
if (!fs.existsSync(lockFileeFullPath)) {
throw new Error('No paket.lock file found at ' +
`location: ${lockFileeFullPath}`);
}
const manifestFileContents = fs.readFileSync(manifestFileFullPath, 'utf-8');
const lockFileContents = fs.readFileSync(manifestFileFullPath, 'utf-8');
return parse(manifestFileContents, manifestFileContents, includeDev);
}
function buildDependencyTree(
/* manifestFile: PaketManifest, */ lockFile, includeDev = false) {
const depTree = {
dependencies: {},
name: '',
version: '',
};
for (const group of lockFile.groups) {
const isDev = group.name === 'build' || group.name === 'test' || group.name === 'tests';
if (isDev && !includeDev) {
continue;
}
for (const dep of group.dependencies) {
depTree.dependencies[dep.name] = {
depType: isDev ? DepType.dev : DepType.prod,
dependencies: buildSubTree(dep.dependencies),
name: dep.name,
version: dep.version,
};
}
}
return depTree;
}
exports.buildDependencyTree = buildDependencyTree;
function buildSubTree(dependency) {
const subTree = {};
for (const dep of dependency) {
subTree[dep.name] = {
dependencies: {},
name: dep.name,
version: dep.version,
};
}
return subTree;
}
//# sourceMappingURL=index.js.map

2

package.json

@@ -41,3 +41,3 @@ {

},
"version": "1.1.0"
"version": "1.2.0"
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc