@tywalk/pcf-helper
Version:
Command line helper for building and publishing PCF controls to Dataverse.
67 lines (66 loc) • 3.95 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
Object.defineProperty(exports, "__esModule", { value: true });
const task = __importStar(require("../tasks/init-pcf"));
const package_json_1 = require("../package.json");
const color_logger_1 = __importDefault(require("@tywalk/color-logger"));
const commander_1 = require("commander");
const argumentUtil_1 = require("../util/argumentUtil");
const program = new commander_1.Command();
program
.name('pcf-helper-init')
.description('Initialize a new PCF project')
.version(package_json_1.version, '-v, --version')
.option('-V, --verbose', 'enable verbose logging')
.requiredOption('-n, --name <name>', 'name of the PCF control')
.option('--publisher-name <publisherName>', 'publisher name')
.option('--publisher-prefix <publisherPrefix>', 'publisher prefix')
.option('-p, --path <path>', 'path to create the PCF project')
.option('-t, --template <template>', 'template for the component (field|dataset)')
.option('-f, --framework <framework>', 'rendering framework for control (none|react)')
.option('--run-npm-install', 'run npm install after initialization', true);
(0, argumentUtil_1.addProfileOption)(program).parse();
const options = program.opts();
if (options.verbose) {
color_logger_1.default.setDebug(true);
}
color_logger_1.default.log('PCF Helper version', package_json_1.version);
const { profile } = (0, argumentUtil_1.resolveProfileOnly)(options.profile);
task.runInit((_b = (_a = options.path) !== null && _a !== void 0 ? _a : profile === null || profile === void 0 ? void 0 : profile.path) !== null && _b !== void 0 ? _b : '', options.name, (_d = (_c = options.publisherName) !== null && _c !== void 0 ? _c : profile === null || profile === void 0 ? void 0 : profile.publisherName) !== null && _d !== void 0 ? _d : '', (_f = (_e = options.publisherPrefix) !== null && _e !== void 0 ? _e : profile === null || profile === void 0 ? void 0 : profile.publisherPrefix) !== null && _f !== void 0 ? _f : '', (_h = (_g = options.template) !== null && _g !== void 0 ? _g : profile === null || profile === void 0 ? void 0 : profile.template) !== null && _h !== void 0 ? _h : 'field', (_k = (_j = options.framework) !== null && _j !== void 0 ? _j : profile === null || profile === void 0 ? void 0 : profile.framework) !== null && _k !== void 0 ? _k : 'react', options.runNpmInstall !== false, options.verbose || false);