UNPKG

sfdx-hardis

Version:

Swiss-army-knife Toolbox for Salesforce. Allows you to define a complete CD/CD Pipeline. Orchestrate base commands and assist users with interactive wizards

109 lines (98 loc) 4.66 kB
/* jscpd:ignore-start */ import { SfCommand, Flags, requiredOrgFlagWithDeprecations } from '@salesforce/sf-plugins-core'; import { Messages } from '@salesforce/core'; import { uxLog } from '../../../../common/utils/index.js'; import { restoreListViewMine } from '../../../../common/utils/orgConfigUtils.js'; import { getConfig } from '../../../../config/index.js'; import c from 'chalk'; Messages.importMessagesDirectoryFromMetaUrl(import.meta.url); const messages = Messages.loadMessages('sfdx-hardis', 'org'); export default class FixListViewMine extends SfCommand { static title = 'Fix listviews with '; static description = `Fix listviews whose scope Mine has been replaced by Everything [![Invalid scope:Mine, not allowed ? Deploy your ListViews anyway !](https://github.com/hardisgroupcom/sfdx-hardis/raw/main/docs/assets/images/article-invalid-scope-mine.jpg)](https://nicolas.vuillamy.fr/invalid-scope-mine-not-allowed-deploy-your-listviews-anyway-443aceca8ac7) List of ListViews can be: - read from .sfdx-hardis.yml file in property **listViewsToSetToMine** - sent in argument listviews Note: property **listViewsToSetToMine** can be auto-generated by command hardis:work:save if .sfdx-hardis.yml contains the following configuration \`\`\`yaml autoCleanTypes: - listViewsMine \`\`\` - Example of sfdx-hardis.yml property \`listViewsToSetToMine\`: \`\`\`yaml listViewsToSetToMine: - "force-app/main/default/objects/Operation__c/listViews/MyCurrentOperations.listView-meta.xml" - "force-app/main/default/objects/Operation__c/listViews/MyFinalizedOperations.listView-meta.xml" - "force-app/main/default/objects/Opportunity/listViews/Default_Opportunity_Pipeline.listView-meta.xml" - "force-app/main/default/objects/Opportunity/listViews/MyCurrentSubscriptions.listView-meta.xml" - "force-app/main/default/objects/Opportunity/listViews/MySubscriptions.listView-meta.xml" - "force-app/main/default/objects/Account/listViews/MyActivePartners.listView-meta.xml" \`\`\` - If manually written, this could also be: \`\`\`yaml listViewsToSetToMine: - "Operation__c:MyCurrentOperations" - "Operation__c:MyFinalizedOperations" - "Opportunity:Default_Opportunity_Pipeline" - "Opportunity:MyCurrentSubscriptions" - "Opportunity:MySubscriptions" - "Account:MyActivePartners" \`\`\` Troubleshooting: if you need to run this command from an alpine-linux based docker image, use this workaround in your dockerfile: \`\`\`dockerfile # Do not use puppeteer embedded chromium RUN apk add --update --no-cache chromium ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD="true" ENV CHROMIUM_PATH="/usr/bin/chromium-browser" ENV PUPPETEER_EXECUTABLE_PATH="$\\{CHROMIUM_PATH}" // remove \\ before { \`\`\` `; static examples = [ '$ sf hardis:org:fix:listviewmine', '$ sf hardis:org:fix:listviewmine --listviews Opportunity:MySubscriptions,Account:MyActivePartners', ]; // public static args = [{name: 'file'}]; static flags = { listviews: Flags.string({ char: 'l', description: `Comma-separated list of listviews following format Object:ListViewName\nExample: Contact:MyContacts,Contact:MyActiveContacts,Opportunity:MYClosedOpportunities`, }), debug: Flags.boolean({ char: 'd', default: false, description: messages.getMessage('debugMode'), }), websocket: Flags.string({ description: messages.getMessage('websocket'), }), skipauth: Flags.boolean({ description: 'Skip authentication check when a default username is required', }), 'target-org': requiredOrgFlagWithDeprecations, }; static requiresProject = true; debugMode = false; listViewsStrings = []; /* jscpd:ignore-end */ async run() { const { flags } = await this.parse(FixListViewMine); this.debugMode = flags.debug || false; uxLog("action", this, c.cyan('Setting back listviews to Mine instead of Everything...')); // Identify listviews to process if (flags.listviews) { // Use input flag this.listViewsStrings = flags.listviews.split(','); } else { // Use property listViewsToSetToMine from .sfdx-hardis.yml config file const config = await getConfig('project'); this.listViewsStrings = config.listViewsToSetToMine || []; } const result = await restoreListViewMine(this.listViewsStrings, flags['target-org'].getConnection(), { debug: this.debugMode, }); return result; } } //# sourceMappingURL=listviewmine.js.map