UNPKG

@storm-software/pulumi-tools

Version:

Tools for managing Pulumi infrastructure within a Nx workspace.

43 lines (36 loc) 2.09 kB
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); 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; } var _chunkMVIY32YGjs = require('./chunk-MVIY32YG.js'); // src/base/base-executor.ts var _path = require('path'); var _shelljs = require('shelljs'); var withPulumiExecutor = (command, argsMapper, executorOptions = {}) => async (_options, context) => { return _chunkMVIY32YGjs.withRunExecutor.call(void 0, `Pulumi \`${command}\` Command Executor`, async (options, context2, config) => { if (!_shelljs.which.call(void 0, "pulumi")) { throw new Error( "Pulumi is not installed. Please install it before running this executor." ); } if (!_optionalChain([context2, 'access', _ => _.projectsConfigurations, 'optionalAccess', _2 => _2.projects]) || !context2.projectName || !context2.projectsConfigurations.projects[context2.projectName]) { throw new Error( "The Build process failed because the context is not valid. Please run this command from a workspace." ); } const { sourceRoot } = context2.projectsConfigurations.projects[context2.projectName]; _chunkMVIY32YGjs.run.call(void 0, config, ["pulumi", command, ...argsMapper(options)].filter(Boolean).join(" "), _path.join.call(void 0, config.workspaceRoot, options.root || sourceRoot), "inherit", { ...process.env, PULUMI_EXPERIMENTAL: "true" } ); return null; }, executorOptions )(_options, context); }; exports.withPulumiExecutor = withPulumiExecutor;