Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug/1717 --skipValidation does not work for retrieve #1718

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 {};
Loading