diff --git a/CHANGELOG.md b/CHANGELOG.md index 081639f..4f5d4bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 0.4.0 + +- fix exec function +- replace diff with structural diff +- add package '@types/jsonpath' + ## 0.3.9 - remove global variables diff --git a/package.json b/package.json index 9e8cb85..be5abd0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@azure/rest-api-specs-scripts", - "version": "0.3.9", + "version": "0.4.0", "description": "Scripts for the Azure RestAPI specification repository 'azure-rest-api-specs'.", "types": "dist/index.d.ts", "main": "dist/index.js", @@ -27,6 +27,7 @@ "@types/fs-extra": "^5.0.5", "@types/glob": "^7.1.1", "@types/js-yaml": "^3.12.1", + "@types/jsonpath": "^0.2.0", "@types/node": "^11.13.6", "@types/request": "^2.48.1", "typescript": "^3.4.4" diff --git a/src/modelValidation.ts b/src/modelValidation.ts index 3addda0..831c7ba 100644 --- a/src/modelValidation.ts +++ b/src/modelValidation.ts @@ -20,14 +20,14 @@ const exec = (cmd: string, options?: cp.SpawnSyncOptions) => { export async function main() { const pr = await devOps.createPullRequestProperties(cli.defaultConfig()) const swaggersToProcess = await utils.getFilesChangedInPR(pr); - let result = 0 + let result: number = 0 for (const swagger of swaggersToProcess) { try { // await oav.validateExamples(swagger, null, {consoleLogLevel: 'error', pretty: true}); // run OAV as a separate process to avoid memory issues. const r = exec(`node node_modules/oav/dist/cli.js validate-example ${swagger} --pretty`) if (result === 0) { - result = r + result = r === null ? 1 : r } } catch (e) { console.error("error: ") diff --git a/src/utils.ts b/src/utils.ts index ef7bccf..3a60da2 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -236,7 +236,7 @@ export const getConfigFilesChangedInPR = async (pr: devOps.PullRequestProperties console.log(filesChanged); // traverse up to readme.md files - const configFiles = new Set(); + const configFiles = new Set(); for (let fileChanged of filesChanged) { while (fileChanged.startsWith("specification")) { if (fileChanged.toLowerCase().endsWith("readme.md") && fs.existsSync(fileChanged)) { @@ -273,7 +273,7 @@ export const getFilesChangedInPR = async (pr: devOps.PullRequestProperties | und let result = getSwaggers(); if (pr !== undefined) { try { - let filesChanged = (await pr.diff()).map(file => file.path) + let filesChanged = (await pr.structuralDiff().toArray()) console.log('>>>>> Files changed in this PR are as follows:') console.log(filesChanged); let swaggerFilesInPR = filesChanged.filter(function (item: string) {