UNPKG

pcf-scripts

Version:

This package contains a module for building PowerApps Component Framework (PCF) controls. See project homepage how to install.

40 lines (38 loc) 1.84 kB
"use strict"; // Copyright (C) Microsoft Corporation. All rights reserved. Object.defineProperty(exports, "__esModule", { value: true }); exports.GenerateManifestTypesTask = void 0; const fs = require("fs-extra"); const path = require("node:path"); const constants = require("../constants"); const diagnosticMessages_generated_1 = require("../diagnosticMessages.generated"); const locale_1 = require("../generated/locale"); const manifestTypesGenerator_1 = require("../manifestTypesGenerator"); class GenerateManifestTypesTask { constructor() { this._manifestTypesGenerator = new manifestTypesGenerator_1.ManifestTypesGenerator(); this._options = {}; } getDescription() { return (0, locale_1.translate)(diagnosticMessages_generated_1.strings.task_generate_manifest_types.key); } setOptions(options) { this._options = { ...this._options, ...options }; } run(context) { return context.mapControls((control) => { return Promise.resolve(this.generateManifestTypes(control)); }); } // Generates ManifestTypes.d.ts file from control manifest generateManifestTypes(context) { const comment = `/*\n*This is auto generated from the ControlManifest.Input.xml file\n*/\n\n` + `// Define IInputs and IOutputs Type. They should match with ControlManifest.\n`; const code = comment + this._manifestTypesGenerator.generateManifestTypes(context.getControlManifest().getManifestData()); const generatedDir = path.join(context.getControlPath(), constants.TYPING_FOLDER_NAME); fs.ensureDirSync(generatedDir); fs.writeFileSync(path.join(generatedDir, constants.MANIFEST_TYPE_FILE_NAME), code); } } exports.GenerateManifestTypesTask = GenerateManifestTypesTask; //# sourceMappingURL=manifestTypesTask.js.map