@tywalk/pcf-helper
Version:
Command line helper for building and publishing PCF controls to Dataverse.
42 lines (41 loc) • 2.35 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.runUpgrade = runUpgrade;
const child_process_1 = require("child_process");
const performanceUtil_1 = require("../util/performanceUtil");
const commandUtil_1 = require("../util/commandUtil");
const color_logger_1 = __importDefault(require("@tywalk/color-logger"));
/**
* Upgrades the Power Apps component framework project.
*
* @param {string} path The path to the project folder containing the pcfproj.json file.
* @param {boolean} verbose - If true, additional debug information is logged.
*
* @returns {number} The exit code of the spawned process.
*/
function runUpgrade(path, verbose) {
color_logger_1.default.log('[PCF Helper] ' + (0, performanceUtil_1.formatTime)(new Date()) + ' Starting upgrade...\n');
const tick = performance.now();
const spawnOpts = {
cwd: process.cwd(),
stdio: 'inherit',
killSignal: 'SIGKILL',
timeout: 1000 * 60, // 1 min
};
const solutionVersionCommand = (0, commandUtil_1.resolveSpawnCommand)('pac', ['solution', 'version', '-s', 'Solution', '-sp', path]);
const solutionVersionTask = (0, child_process_1.spawnSync)(solutionVersionCommand.command, solutionVersionCommand.args, spawnOpts);
if (solutionVersionTask.status !== 0) {
return (0, performanceUtil_1.handleTaskCompletion)(solutionVersionTask, 'upgrade', performance.now() - tick, verbose);
}
const pcfVersionCommand = (0, commandUtil_1.resolveSpawnCommand)('pac', ['pcf', 'version', '-s', 'Manifest']);
const pcfVersionTask = (0, child_process_1.spawnSync)(pcfVersionCommand.command, pcfVersionCommand.args, spawnOpts);
if (pcfVersionTask.status !== 0) {
return (0, performanceUtil_1.handleTaskCompletion)(pcfVersionTask, 'upgrade', performance.now() - tick, verbose);
}
const npmVersionCommand = (0, commandUtil_1.resolveSpawnCommand)('npm', ['version', 'patch', '--no-git-tag-version']);
const npmVersionTask = (0, child_process_1.spawnSync)(npmVersionCommand.command, npmVersionCommand.args, spawnOpts);
return (0, performanceUtil_1.handleTaskCompletion)(npmVersionTask, 'upgrade', performance.now() - tick, verbose);
}