UNPKG

@arthurgubaidullin/nx-embed-dependencies

Version:

This plugin for [Nx](https://nx.dev) helps injecting local dependencies into a package.

28 lines 1.96 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getProjectDependencies = void 0; const function_1 = require("fp-ts/function"); const O = require("fp-ts/Option"); const RA = require("fp-ts/ReadonlyArray"); const RS = require("fp-ts/ReadonlySet"); const S = require("fp-ts/string"); const path = require("path"); const Eq_1 = require("fp-ts/Eq"); const Ord = require("fp-ts/Ord"); function getProjectDependencies(context) { const EqProjectGraphProjectNode = Eq_1.eqStrict; const OrdProjectGraphProjectNode = Ord.contramap((a) => a.name)(S.Ord); const iter = (projectGraph, projectName, projects) => (0, function_1.pipe)(projectGraph.dependencies[projectName], RA.map((a) => projectGraph.nodes[a.target]), RA.map(O.fromNullable), RA.compact, RS.fromReadonlyArray(EqProjectGraphProjectNode), RS.difference(EqProjectGraphProjectNode)(projects), RS.reduce(OrdProjectGraphProjectNode)(projects, (acc, v) => acc.has(v) ? acc : iter(projectGraph, v.name, RS.insert(EqProjectGraphProjectNode)(v)(acc)))); return (0, function_1.pipe)(O.Do, O.bind('projectName', () => O.fromNullable(context.projectName)), O.bind('projectGraph', () => O.fromNullable(context.projectGraph)), O.map(({ projectName, projectGraph }) => (0, function_1.pipe)(iter(projectGraph, projectName, new Set()), RS.toReadonlyArray(OrdProjectGraphProjectNode), RA.map((a) => { var _a, _b; const pathToBuild = (_b = (_a = context.projectsConfigurations) === null || _a === void 0 ? void 0 : _a.projects[a.name].targets) === null || _b === void 0 ? void 0 : _b['build'].options['outputPath']; if (!pathToBuild) { throw new Error(`Package \`${a.name}\` has no build output path.`); } return path.join(context.cwd, pathToBuild); }))), O.fold(() => [], function_1.identity)); } exports.getProjectDependencies = getProjectDependencies; //# sourceMappingURL=getProjectDependencies.js.map