UNPKG

@storm-software/build-tools

Version:

A comprehensive set of tools for building and managing projects within a Storm workspace. Includes builders such as rollup, rolldown, tsup, and unbuild, along with various utilities.

70 lines (64 loc) 2.92 kB
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/utilities/get-project-deps.ts function getExtraDependencies(projectName, graph) { const deps = /* @__PURE__ */ new Map(); recur(projectName); function recur(currProjectName) { const allDeps = graph.dependencies[currProjectName]; const externalDeps = _nullishCoalesce(_optionalChain([allDeps, 'optionalAccess', _ => _.reduce, 'call', _2 => _2( (acc, node) => { const found = _optionalChain([graph, 'access', _3 => _3.externalNodes, 'optionalAccess', _4 => _4[node.target]]); if (found) { acc.push(found); } return acc; }, [] )]), () => ( [])); const internalDeps = _nullishCoalesce(_optionalChain([allDeps, 'optionalAccess', _5 => _5.reduce, 'call', _6 => _6( (acc, node) => { const found = graph.nodes[node.target]; if (found) acc.push(found); return acc; }, [] )]), () => ( [])); for (const externalDep of externalDeps) { deps.set(externalDep.name, { name: externalDep.name, outputs: [], node: externalDep }); } for (const internalDep of internalDeps) { recur(internalDep.name); } } return Array.from(deps.values()); } function getInternalDependencies(projectName, graph) { const allDeps = _nullishCoalesce(graph.dependencies[projectName], () => ( [])); return Array.from( allDeps.reduce( (acc, node) => { const found = graph.nodes[node.target]; if (found) acc.push(found); return acc; }, [] ) ); } function getExternalDependencies(projectName, graph) { const allDeps = graph.dependencies[projectName]; return _nullishCoalesce(Array.from( _nullishCoalesce(_optionalChain([allDeps, 'optionalAccess', _7 => _7.reduce, 'call', _8 => _8( (acc, node) => { const found = _optionalChain([graph, 'access', _9 => _9.externalNodes, 'optionalAccess', _10 => _10[node.target]]); if (found) acc.push(found); return acc; }, [] )]), () => ( [])) ), () => ( [])); } exports.getExtraDependencies = getExtraDependencies; exports.getInternalDependencies = getInternalDependencies; exports.getExternalDependencies = getExternalDependencies;