From ff481081e720dedb3854599d8851163371a9a392 Mon Sep 17 00:00:00 2001 From: Roshni Naveena S Date: Thu, 11 Jul 2024 12:52:30 +0530 Subject: [PATCH 1/9] Create lint.yml --- .github/workflows/lint.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .github/workflows/lint.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..3960f77 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,20 @@ +name: Lint + +on: + push: + branches: [main] + pull_request: + types: [opened, synchronize, reopened, auto_merge_enabled] + +concurrency: + group: lint-${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/setup-node@v4 + - uses: actions/checkout@v4 + - run: npm i + - run: npm run lint \ No newline at end of file From bcd66ae2cea731d2c27600177c532d24348be93d Mon Sep 17 00:00:00 2001 From: Roshni Naveena S Date: Thu, 11 Jul 2024 13:09:56 +0530 Subject: [PATCH 2/9] Create .eslintrc.json --- .eslintrc.json | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 .eslintrc.json diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..84c3958 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,16 @@ +{ + "env": { + "jest": true, + "commonjs": true, + "node": true, + "es2021": true + }, + "extends": "eslint:recommended", + "parserOptions": { + "ecmaVersion": "latest" + }, + "rules": { + "no-unused-vars": ["warn", { "argsIgnorePattern": "lazy" }], + "no-extra-semi": 1 + } +} \ No newline at end of file From 4ec86f1a154b38922e26190a75446cb928cb9dff Mon Sep 17 00:00:00 2001 From: Roshni Naveena S Date: Fri, 12 Jul 2024 12:46:46 +0530 Subject: [PATCH 3/9] Update package.json --- package.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/package.json b/package.json index e16ba03..3b4a788 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,9 @@ "scripts": { "lint": "npx eslint ." }, + "devDependencies": { + "eslint": "^8" + }, "peerDependencies": { "@sap/cds": ">=7.6", "@cap-js/asyncapi": "^1.0.0", From 5ad4c51eec6f5c91c92a1b6b43934d5b017b5070 Mon Sep 17 00:00:00 2001 From: Roshni Naveena S Date: Fri, 12 Jul 2024 12:57:48 +0530 Subject: [PATCH 4/9] adding cds as a require package --- lib/ord.js | 1 + lib/plugin.js | 1 + lib/templates.js | 1 + 3 files changed, 3 insertions(+) diff --git a/lib/ord.js b/lib/ord.js index de5f9fe..ad0a6ed 100644 --- a/lib/ord.js +++ b/lib/ord.js @@ -1,4 +1,5 @@ const path = require("path"); +const cds = require("@sap/cds"); const { exists } = cds.utils; const defaults = require("./defaults"); const { diff --git a/lib/plugin.js b/lib/plugin.js index 648bc54..4dd6fcf 100644 --- a/lib/plugin.js +++ b/lib/plugin.js @@ -1,4 +1,5 @@ const { ord, getMetadata, defaults } = require("./"); +const cds = require("@sap/cds"); cds.on("bootstrap", (app) => { app.use("/.well-known/open-resource-discovery", async (req, res) => { diff --git a/lib/templates.js b/lib/templates.js index e921d76..2c97082 100644 --- a/lib/templates.js +++ b/lib/templates.js @@ -1,4 +1,5 @@ const defaults = require("./defaults"); +const cds = require("@sap/cds"); const fReplaceSpecialCharacters = (namespace) => { return namespace.replace(/customer\.(.+)/, (match, group1) => 'customer.' + group1.replace(/[^a-zA-Z0-9]/g, '')) } From 102801ad3f05b75f5315f34edccff84cf75d3786 Mon Sep 17 00:00:00 2001 From: Roshni Naveena S Date: Fri, 12 Jul 2024 13:13:48 +0530 Subject: [PATCH 5/9] Update ord.js --- lib/ord.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ord.js b/lib/ord.js index ad0a6ed..9266235 100644 --- a/lib/ord.js +++ b/lib/ord.js @@ -24,7 +24,7 @@ const fInitializeGlobal = (csn) => { throw new Error(`package.json not found in the project root directory`); } - const appName = packageJson.name.replace(/\s/g, "-"); + const appName = packageJson.name.replace(/ /g, "-"); const aModelKeys = Object.keys(csn.definitions); const aEvents = []; From 40b97bb55326d4904692e0ddd5f01374604d31f8 Mon Sep 17 00:00:00 2001 From: Roshni Naveena S Date: Fri, 12 Jul 2024 13:16:00 +0530 Subject: [PATCH 6/9] Update ord.js --- lib/ord.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ord.js b/lib/ord.js index 9266235..922b8bd 100644 --- a/lib/ord.js +++ b/lib/ord.js @@ -168,7 +168,7 @@ module.exports = (csn) => { const linkedCsn = cds.linked(csn); global = fInitializeGlobal(linkedCsn); const data = global.namespace; - const validateSystemNamespace = new RegExp("^" + global.applicationNamespace + "\.[^.]+\..+$"); + const validateSystemNamespace = new RegExp(`^${global.applicationNamespace}\\.[^.]+\\..+$`); if (data === undefined && !validateSystemNamespace.test(data)) { let error = new Error(`Namespace is not defined in cdsrc.json or it is not in the format of ${global.applicationNamespace}..`); console.error('Namespace error:', error.message); From cdaffa53ad87b57bf5cced72bce91eb0553dfb96 Mon Sep 17 00:00:00 2001 From: Roshni Naveena S Date: Fri, 12 Jul 2024 13:18:33 +0530 Subject: [PATCH 7/9] Update ord.js --- lib/ord.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ord.js b/lib/ord.js index 6a1fbfa..e5e7286 100644 --- a/lib/ord.js +++ b/lib/ord.js @@ -23,7 +23,7 @@ const fInitializeGlobal = (csn) => { } else { throw new Error(`package.json not found in the project root directory`); } - const appName = packageJson.name.replace(/^[@]/, "").replace(/[@\/]/g, "-"); + const appName = packageJson.name.replace(/^[@]/, "").replace(/[@/]/g, "-"); const aModelKeys = Object.keys(csn.definitions); const aEvents = []; const aServices = []; From 28025c4ce17482a7374c63d391683ac8d437d64a Mon Sep 17 00:00:00 2001 From: Roshni Naveena S Date: Fri, 12 Jul 2024 13:20:51 +0530 Subject: [PATCH 8/9] Update ord.js --- lib/ord.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/ord.js b/lib/ord.js index e5e7286..b834b58 100644 --- a/lib/ord.js +++ b/lib/ord.js @@ -166,9 +166,8 @@ const fGetEventResources = (csn, global,packageIds) => global.aEvents.map((srv) module.exports = (csn) => { const linkedCsn = cds.linked(csn); global = fInitializeGlobal(linkedCsn); - const data = global.namespace; const validateSystemNamespace = new RegExp(`^${global.applicationNamespace}\\.[^.]+\\..+$`); - if (data === undefined && !validateSystemNamespace.test(data)) { + if (global.namespace === undefined && !validateSystemNamespace.test(global.namespace)) { let error = new Error(`Namespace is not defined in cdsrc.json or it is not in the format of ${global.applicationNamespace}..`); console.error('Namespace error:', error.message); throw error; From 925cbf890c685396b55e0ac11568d2beb5ef0f4f Mon Sep 17 00:00:00 2001 From: Roshni Naveena S Date: Fri, 12 Jul 2024 13:23:06 +0530 Subject: [PATCH 9/9] Update ord.js --- lib/ord.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ord.js b/lib/ord.js index b834b58..c68e2a7 100644 --- a/lib/ord.js +++ b/lib/ord.js @@ -165,7 +165,7 @@ const fGetEventResources = (csn, global,packageIds) => global.aEvents.map((srv) module.exports = (csn) => { const linkedCsn = cds.linked(csn); - global = fInitializeGlobal(linkedCsn); + Object.assign(global, fInitializeGlobal(linkedCsn)); const validateSystemNamespace = new RegExp(`^${global.applicationNamespace}\\.[^.]+\\..+$`); if (global.namespace === undefined && !validateSystemNamespace.test(global.namespace)) { let error = new Error(`Namespace is not defined in cdsrc.json or it is not in the format of ${global.applicationNamespace}..`);