New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

tsarch

Package Overview
Dependencies
Maintainers
0
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tsarch - npm Package Compare versions

Comparing version 5.4.0 to 5.4.1

11

dist/src/common/extraction/extractNxGraph.js

@@ -40,3 +40,9 @@ "use strict";

var workspaceRoot = rootFolder !== null && rootFolder !== void 0 ? rootFolder : guessNxWorkspaceRoot();
var projectGraphCacheDirectory = absolutePath(workspaceRoot, (_a = process.env["NX_PROJECT_GRAPH_CACHE_DIRECTORY"]) !== null && _a !== void 0 ? _a : defaultCacheDirectory(workspaceRoot));
// The location of the project graph was moved from .nx/cache to .nx/workspace-data in Nx v19.2.0
// If using Nx 19.2.0+ us the new location
var projectGraphCacheDirectory = absolutePath(workspaceRoot, (_a = process.env["NX_PROJECT_GRAPH_CACHE_DIRECTORY"]) !== null && _a !== void 0 ? _a : defaultWorkspaceDataDirectory(workspaceRoot));
// If using Nx <19.2.0 use the old location
if (!fs.existsSync(path.join(projectGraphCacheDirectory, "project-graph.json"))) {
projectGraphCacheDirectory = absolutePath(workspaceRoot, defaultCacheDirectory(workspaceRoot));
}
var depGraph = fs.readFileSync(path.join(projectGraphCacheDirectory, "project-graph.json"));

@@ -73,2 +79,5 @@ var deps = JSON.parse(depGraph.toString("utf-8")).dependencies;

}
function defaultWorkspaceDataDirectory(root) {
return path.join(root, ".nx", "workspace-data");
}
function guessNxWorkspaceRoot() {

@@ -75,0 +84,0 @@ var nxConfigFileName = guessLocationOfNxConfigRecursively(".");

@@ -42,11 +42,16 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var fs_1 = __importDefault(require("fs"));
var path_1 = __importDefault(require("path"));
var plantuml_parser_1 = require("plantuml-parser");
var slices_1 = require("../../../src/slices/fluentapi/slices");
var exportDiagram_1 = require("../../../src/slices/uml/exportDiagram");
var path_1 = __importDefault(require("path"));
var extractGraph_1 = require("../../../src/common/extraction/extractGraph");
var slicingProjections_1 = require("../../../src/slices/projection/slicingProjections");
var extractNxGraph_1 = require("../../../src/common/extraction/extractNxGraph");
var projectEdges_1 = require("../../../src/common/projection/projectEdges");
var admissibleEdges_1 = require("../../../src/slices/assertion/admissibleEdges");
var slices_1 = require("../../../src/slices/fluentapi/slices");
var slicingProjections_1 = require("../../../src/slices/projection/slicingProjections");
var exportDiagram_1 = require("../../../src/slices/uml/exportDiagram");
describe("Integration test", function () {
afterEach(function () {
jest.restoreAllMocks();
});
it("finds simple violations", function () { return __awaiter(void 0, void 0, void 0, function () {

@@ -219,2 +224,3 @@ var violations;

case 0:
jest.spyOn(fs_1.default, "readFileSync").mockReturnValue(getExampleNxProjectGraphJsonFileContent());
diagram = "\n@startuml\n component [is-even]\n component [is-odd]\n@enduml\n ";

@@ -251,2 +257,3 @@ return [4 /*yield*/, slices_1.slicesOfNxProject(__dirname)

case 0:
jest.spyOn(fs_1.default, "readFileSync").mockReturnValue(getExampleNxProjectGraphJsonFileContent());
diagram = "\n@startuml\n component [is-even]\n@enduml\n ";

@@ -266,3 +273,72 @@ return [4 /*yield*/, slices_1.slicesOfNxProject(__dirname)

}); });
it("when project graph cache is located in .nx/workspace-data directory then extracts nx graph", function () {
var projectGraphFilePath = path_1.default.join(__dirname, ".nx", "workspace-data", "project-graph.json");
jest.spyOn(fs_1.default, "existsSync").mockImplementation(function (filePath) { return filePath === projectGraphFilePath; });
jest.spyOn(fs_1.default, "readFileSync").mockImplementation(function (filePath) {
if (filePath === projectGraphFilePath) {
return getExampleNxProjectGraphJsonFileContent();
}
throw new Error("Project graph not located in " + projectGraphFilePath);
});
expect(extractNxGraph_1.extractNxGraph(__dirname)).toEqual(getExampleProjectGraph());
});
it("when project graph cache is located in .nx/cache directory then extracts nx graph", function () {
var projectGraphFilePath = path_1.default.join(__dirname, ".nx", "cache", "project-graph.json");
jest.spyOn(fs_1.default, "existsSync").mockImplementation(function (filePath) { return filePath === projectGraphFilePath; });
jest.spyOn(fs_1.default, "readFileSync").mockImplementation(function (filePath) {
if (filePath === projectGraphFilePath) {
return getExampleNxProjectGraphJsonFileContent();
}
throw new Error("Project graph not located in " + projectGraphFilePath);
});
expect(extractNxGraph_1.extractNxGraph(__dirname)).toEqual(getExampleProjectGraph());
});
it("when project graph cache is located in neither .nx/workspace-data nor .nx/cache directory then throw file not found error", function () {
jest.spyOn(fs_1.default, "readFileSync").mockImplementation(function () {
throw new Error("Project graph not found");
});
expect(function () { return extractNxGraph_1.extractNxGraph(__dirname); }).toThrow();
});
});
var getExampleNxProjectGraphJsonFileContent = function () {
var exampleProjectGraph = JSON.stringify({
nodes: {},
externalNodes: {},
dependencies: {
"is-super-odd": [
{
source: "is-super-odd",
target: "npm:tslib",
type: "static"
}
],
"is-even": [
{
source: "is-even",
target: "npm:tslib",
type: "static"
},
{
source: "is-even",
target: "is-odd",
type: "static"
}
],
"is-odd": [
{
source: "is-odd",
target: "npm:tslib",
type: "static"
}
]
}
});
return Buffer.from(exampleProjectGraph);
};
var getExampleProjectGraph = function () { return [
{ source: "is-super-odd", target: "npm:tslib", external: true },
{ source: "is-even", target: "npm:tslib", external: true },
{ source: "is-even", target: "is-odd", external: false },
{ source: "is-odd", target: "npm:tslib", external: true }
]; };
//# sourceMappingURL=integration.spec.js.map

2

package.json
{
"name": "tsarch",
"version": "5.4.0",
"version": "5.4.1",
"description": "",

@@ -5,0 +5,0 @@ "keywords": [],

Sorry, the diff of this file is not supported yet

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