Skip to content

Commit

Permalink
chore: review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Nayden Naydenov committed Jan 17, 2024
1 parent 8025662 commit 07b4e4b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 17 deletions.
2 changes: 1 addition & 1 deletion packages/fiori/package-scripts.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const filterOut = [
const options = {
port: 8081,
portStep: 2,
ui5package: true,
dev: true,
fioriPackage: true,
typescript: true,
noWatchTS: true,
Expand Down
2 changes: 1 addition & 1 deletion packages/main/package-scripts.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const options = {
portStep: 2,
typescript: true,
noWatchTS: true,
ui5package: true,
dev: true,
};

const scripts = getScripts(options);
Expand Down
4 changes: 2 additions & 2 deletions packages/tools/components-package/nps.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ const getScripts = (options) => {
},
generateAPI: {
default: `nps ${ tsOption ? "generateAPI.generateCEM generateAPI.validateCEM" : "generateAPI.prepare generateAPI.preprocess generateAPI.jsdoc generateAPI.cleanup generateAPI.prepareManifest"}`,
generateCEM: `cem analyze --config "${LIB}/cem/custom-elements-manifest.config.mjs" ${ options.ui5package ? "--ui5package" : "" }`,
validateCEM: `node "${LIB}/cem/validate.js" ${ options.ui5package ? "--ui5package" : "" }`,
generateCEM: `cem analyze --config "${LIB}/cem/custom-elements-manifest.config.mjs" ${ options.dev ? "--ui5package" : "" }`,
validateCEM: `node "${LIB}/cem/validate.js" ${ options.dev ? "--ui5package" : "" }`,
prepare: `node "${LIB}/copy-and-watch/index.js" --silent "dist/**/*.js" jsdoc-dist/`,
prepareManifest: `node "${LIB}/generate-custom-elements-manifest/index.js" dist dist`,
preprocess: `node "${preprocessJSDocScript}" jsdoc-dist/ src`,
Expand Down
20 changes: 7 additions & 13 deletions packages/tools/lib/cem/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,34 +40,28 @@ const clearProps = (data) => {
return data;
}

const inputDataExternal = clearProps(JSON.parse(JSON.stringify(inputDataInternal)));

const ajv = new Ajv({ allowUnionTypes: true, allError: true })

let validate = ajv.compile(internalSchema)

// Validate the JSON data against the schema
if (validate(inputDataInternal)) {
console.log('Validation internal custom-elements successful');
} else {
if (argv.ui5package) {
throw new Error(`Validation of internal custom-elements failed: ${validate.errors}`);
if (argv.ui5package) {
if (validate(inputDataInternal)) {
console.log('Internal custom element manifest is validated successfully');
} else {
console.error('Validation of internal custom-elements failed')
throw new Error(`Validation of internal custom elements manifest failed: ${validate.errors}`);
}
}

const inputDataExternal = clearProps(JSON.parse(JSON.stringify(inputDataInternal)));
validate = ajv.compile(extenalSchema)

// Validate the JSON data against the schema
if (validate(inputDataExternal)) {
console.log('Validation external custom-elements successful');
console.log('Custom element manifest is validated successfully');
fs.writeFileSync(inputFilePath, JSON.stringify(inputDataExternal, null, 2), 'utf8');
fs.writeFileSync(inputFilePath.replace("custom-elements", "custom-elements-internal"), JSON.stringify(inputDataInternal, null, 2), 'utf8');
} else {
if (argv.ui5package) {
throw new Error(`Validation of external custom-elements failed: ${validate.errors}`);
} else {
console.error('Validation of external custom-elements failed')
throw new Error(`Validation of public custom elements manifest failed: ${validate.errors}`);
}
}

0 comments on commit 07b4e4b

Please sign in to comment.