powerplatform-review-tool
Version:
Evaluate Power Platform solution zip files based on best practice patterns
63 lines (62 loc) • 2.6 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const commander_1 = require("commander");
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
const powerplatform_review_tool_shared_1 = require("powerplatform-review-tool-shared");
const program = new commander_1.Command();
program
.name('pp-review')
.description('Power Platform solution review CLI')
.version('1.0.14');
// ✅ Command 1: Review
program
.command('review')
.description('Evaluate a solution zip file for best practices')
.requiredOption('-f, --file <path>', 'Path to solution zip')
.option('-o, --output <path>', 'Path to output JSON file')
.action(async ({ file, output }) => {
const zipPath = path_1.default.resolve(process.cwd(), file);
console.log(`📦 Reading file from: ${zipPath}`);
if (!fs_1.default.existsSync(zipPath)) {
console.error(`❌ File not found: ${zipPath}`);
process.exit(1);
}
const buffer = fs_1.default.readFileSync(zipPath);
const result = await (0, powerplatform_review_tool_shared_1.startReview)(buffer);
// DEBUG: Log the result
console.log('🔍 Review result preview:', result);
if (output) {
const outPath = path_1.default.resolve(process.cwd(), output);
fs_1.default.writeFileSync(outPath, JSON.stringify(result, null, 2));
console.log(`✅ Review result saved to: ${outPath}`);
}
});
// ✅ Command 2: Extract
program
.command('extract')
.description('Extract solution metadata (e.g., apps, flows, bots)')
.requiredOption('-f, --file <path>', 'Path to solution zip')
.option('-o, --output <path>', 'Path to output JSON file')
.action(async ({ file, output }) => {
const zipPath = path_1.default.resolve(process.cwd(), file);
if (!fs_1.default.existsSync(zipPath)) {
console.error(`❌ File not found: ${zipPath}`);
process.exit(1);
}
const buffer = fs_1.default.readFileSync(zipPath);
const result = await (0, powerplatform_review_tool_shared_1.extractSolutionDetail)(buffer);
if (output) {
const outPath = path_1.default.resolve(process.cwd(), output);
fs_1.default.writeFileSync(outPath, JSON.stringify(result, null, 2));
console.log(`✅ Metadata written to ${outPath}`);
}
else {
console.log(JSON.stringify(result, null, 2));
}
});
program.parse();