UNPKG

@arthurgubaidullin/nx-embed-dependencies

Version:

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

27 lines 1.92 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.pipeline = void 0; const tslib_1 = require("tslib"); const dist_copying_1 = require("@embed-dependencies/dist-copying"); const package_json_program_1 = require("@embed-dependencies/package-json-program"); const project_1 = require("@embed-dependencies/project"); const Either_1 = require("fp-ts/Either"); const function_1 = require("fp-ts/function"); const T = require("fp-ts/Task"); const TE = require("fp-ts/TaskEither"); const node_child_process_1 = require("node:child_process"); const node_path_1 = require("node:path"); const time_1 = require("./time"); function pipeline(options) { return (P) => { const sourcePath = (0, node_path_1.join)(P.context.cwd, P.context.workspace.projects[P.context.projectName].targets['build'] .options['outputPath']); const targetPath = (0, node_path_1.join)(P.context.cwd, options.outputPath); return (0, function_1.pipe)((0, dist_copying_1.copyDist)(sourcePath, targetPath), (0, time_1.time)('copyDist', P.context), T.chain(() => (0, function_1.pipe)(P.injectDependencies(targetPath, (0, project_1.getProjectDependencies)(P.context)), (0, time_1.time)('injectDependencies', P.context))), T.chain(() => (0, function_1.pipe)(targetPath, package_json_program_1.fixPackageJson, T.fromIO, (0, time_1.time)('fixPackageJson', P.context))), TE.chain(() => (0, function_1.pipe)(() => tslib_1.__awaiter(this, void 0, void 0, function* () { process.chdir(targetPath); (0, node_child_process_1.execSync)('npm install'); }), (0, time_1.time)('npm install', P.context), (f) => TE.tryCatch(f, Either_1.toError))), TE.map(() => ({ success: true })), TE.orElseFirstIOK((e) => () => console.error(e)), TE.mapLeft(() => ({ success: false })), TE.getOrElse(T.of)); }; } exports.pipeline = pipeline; //# sourceMappingURL=pipeline.js.map