UNPKG

@pnp/cli-microsoft365

Version:

Manage Microsoft 365 and SharePoint Framework projects on any platform

58 lines 2.18 kB
import { JsonRule } from '../../JsonRule.js'; export class FN006006_CFG_PS_features extends JsonRule { get id() { return 'FN006006'; } get title() { return 'package-solution.json features'; } get description() { return `In package-solution.json add features for components`; } get resolution() { return ''; } get resolutionType() { return 'json'; } get severity() { return 'Required'; } get file() { return './config/package-solution.json'; } visit(project, findings) { if (!project.packageSolutionJson || !project.packageSolutionJson.solution || // if project already has features defined, we don't need to do anything (project.packageSolutionJson.solution.features && project.packageSolutionJson.solution.features.length > 0) || // if there are no components, we don't need to do anything !project.manifests || project.manifests.length < 1) { return; } const occurrences = []; project.manifests.forEach(manifest => { const resolution = { solution: { features: [ { title: `${project.packageJson?.name} ${manifest.alias} Feature`, description: `The feature that activates ${manifest.alias} from the ${project.packageJson?.name} solution.`, id: manifest.id, version: project.packageSolutionJson.solution.version, componentIds: [manifest.id] } ] } }; const node = this.getAstNodeFromFile(project.packageSolutionJson, 'solution'); occurrences.push({ file: this.file, resolution: JSON.stringify(resolution, null, 2), position: this.getPositionFromNode(node) }); }); this.addFindingWithOccurrences(occurrences, findings); } } //# sourceMappingURL=FN006006_CFG_PS_features.js.map