Skip to content

Commit

Permalink
Merge pull request #1718 from Accenture/bug/1717-skipvalidation-does-…
Browse files Browse the repository at this point in the history
…not-work-for-retrieve

Bug/1717 --skipValidation does not work for retrieve
  • Loading branch information
JoernBerkefeld authored Sep 17, 2024
2 parents 152a939 + bd863a3 commit 5406566
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 5 deletions.
2 changes: 2 additions & 0 deletions @types/lib/util/validations.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion @types/lib/util/validations.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions @types/types/mcdev.d.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion @types/types/mcdev.d.d.ts.map

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ yargs(hideBin(process.argv))
group: 'Options for retrieve:',
describe:
'filter metadata components (can include % as wildcard or _ for a single character)',
})
.option('skipValidation', {
alias: 'sv',
group: 'Options for retrieve:',
describe:
'allows reducing validation rules from error to warn to handle edge cases',
}),
(argv) => {
Mcdev.setOptions(argv);
Expand Down Expand Up @@ -594,7 +600,7 @@ yargs(hideBin(process.argv))
})
.option('skipValidation', {
alias: 'sv',
group: 'Options for deploy:',
group: 'Options for buildDefinitionBulk:',
describe:
'allows reducing validation rules from error to warn to handle edge cases',
}),
Expand Down
11 changes: 9 additions & 2 deletions lib/util/validations.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
import path from 'node:path';
import { Util } from './util.js';

/**
* @typedef {import('../../types/mcdev.d.js').validationRuleList} validationRuleList
* @typedef {import('../../types/mcdev.d.js').validationRuleTest} validationRuleTest
*/

/** @type {validationRuleList} */
let customRules = {};
let customRuleImport;
try {
Expand All @@ -28,11 +34,12 @@ export default async function validation(definition, item, targetDir) {
'Could not load custom validation rules from .mcdev-validations.js: ' + ex.message
);
}
/** @type {validationRuleList} */
const defaultRules = {
noGuidKeys: {
failedMsg: 'Please update the key to a readable value. Currently still in GUID format.',
/**
* @returns {boolean} true=test passed
* @type {validationRuleTest}
*/
passed: function () {
const key = item[definition.keyField];
Expand All @@ -48,7 +55,7 @@ export default async function validation(definition, item, targetDir) {
noRootFolder: {
failedMsg: 'Root folder not allowed. Current folder: ' + item.r__folder_Path,
/**
* @returns {boolean} true=test passed
* @type {validationRuleTest}
*/
passed: function () {
/** @type {string} */
Expand Down
13 changes: 13 additions & 0 deletions types/mcdev.d.js
Original file line number Diff line number Diff line change
Expand Up @@ -625,5 +625,18 @@ complex
* @property {number} scale ?
* @property {string} text seems to be equal to name-attribute?; "Email"
*/
/**
*
* @callback validationRuleTest
* @returns {boolean} true = test passed; false = test failed
*/
/**
* @typedef {object} validationRule
* @property {string} failedMsg error message to display in case of a failed test
* @property {validationRuleTest} passed test to run
*/
/**
* @typedef {Object.<string, validationRule>} validationRuleList key=rule name
*/

export default {};

0 comments on commit 5406566

Please sign in to comment.