diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index 155a10fd5..000000000 --- a/.eslintrc +++ /dev/null @@ -1,22 +0,0 @@ -{ - "ignorePatterns": ["**/webapp/**", "assets/**"], - "extends": ["eslint:recommended", "plugin:vue/vue3-recommended"], - "parser": "@typescript-eslint/parser", - "env": { - "es2022": true, - "node": true, - "jest": true, - "mocha": true - }, - "globals": { - "SELECT": true, - "INSERT": true, - "UPDATE": true, - "DELETE": true, - "CREATE": true, - "DROP": true, - "CDL": true, - "CQL": true, - "CXL": true - } -} diff --git a/.github/workflows/PR-SAP.yml b/.github/workflows/PR-SAP.yml index 461d83af5..f6d1a8db8 100644 --- a/.github/workflows/PR-SAP.yml +++ b/.github/workflows/PR-SAP.yml @@ -37,6 +37,8 @@ jobs: working-directory: docs - run: npm test working-directory: docs + - run: npm run lint + working-directory: docs - run: npm run docs:build working-directory: docs env: diff --git a/.github/workflows/PR.yml b/.github/workflows/PR.yml index fcbfc7d15..ebee41b82 100644 --- a/.github/workflows/PR.yml +++ b/.github/workflows/PR.yml @@ -31,3 +31,4 @@ jobs: - run: npm ci - run: npm test - run: npm run docs:build + - run: npm run lint diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6a64d9681..744120097 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -35,6 +35,7 @@ jobs: cache: 'npm' - run: npm ci - run: npm test + - run: npm run lint - run: npm run docs:build env: GH_BASE: / diff --git a/.vitepress/lib/md-typed-models.ts b/.vitepress/lib/md-typed-models.ts index 5c9a372ae..5df9fcbbe 100644 --- a/.vitepress/lib/md-typed-models.ts +++ b/.vitepress/lib/md-typed-models.ts @@ -3,7 +3,7 @@ import { execSync } from 'node:child_process' import { dirname, join, relative, resolve } from 'node:path' import { existsSync } from 'node:fs' -type mdItEnv = { frontmatter: Record, path: string, realPath: string } +type mdItEnv = { frontmatter: Record, path: string, realPath?: string } const modelOut = '@cds-models' /** @@ -30,8 +30,9 @@ export function install(md: MarkdownRenderer) { runTyper(srcDir, modelOut) - const resolvedPath = resolve(mdDir, modelPath, modelOut, '*') - tokens[idx].content = tokens[idx].content.replaceAll(`%typedModels:${modelKey}:resolved%`, resolvedPath) + const resPath = resolvedImportPath(srcDir, modelOut) + // console.log(`📚 ${modelPath} -> ${resPath}`) + tokens[idx].content = tokens[idx].content.replaceAll(`%typedModels:${modelKey}:resolved%`, resPath) } } @@ -39,6 +40,14 @@ export function install(md: MarkdownRenderer) { } } +function resolvedImportPath(srcDir: string, modelOut: string) { + // make resolved path relative - tsc seems to have problems with absolute Windows paths (C:\...) + let resolvedPath = relative(process.cwd(), srcDir) + // also make it a local import path, starting with ./ and replacing Windows \ + resolvedPath = join(resolvedPath, modelOut, '*').replace(/\\/g, '/') + return resolvedPath.startsWith('.') ? resolvedPath : './'+resolvedPath +} + function runTyper(srcDir:string, out:string) { const outPath = resolve(srcDir, out) // If target dir exists, stop here. Delta compilation is done through cds-typer ion VS Code. @@ -46,6 +55,6 @@ function runTyper(srcDir:string, out:string) { const label = '✓ running cds-typer in ' + relative(process.cwd(), srcDir) console.time(label) - execSync(`npm exec --prefix ${srcDir} -- cds-typer '*' --outputDirectory ${out}`, {cwd: srcDir}) + execSync(`npm exec --prefix ${srcDir} -- cds-typer * --outputDirectory ${out}`, {cwd: srcDir}) console.timeEnd(label) } diff --git a/.vitepress/menu.js b/.vitepress/menu.js index 60d273fb1..88f730d5d 100644 --- a/.vitepress/menu.js +++ b/.vitepress/menu.js @@ -1,4 +1,3 @@ -import path from 'node:path' import fs from 'node:fs' import rulesSidebar from '../tools/cds-lint/sidebar.js' @@ -13,7 +12,7 @@ const dynamicItems = (item) => { /** * Construct sidebar from markdown */ -export function sidebar (file = 'menu.md', filter=(_)=>true) { +export function sidebar (file = 'menu.md', filter=()=>true) { const source = file const markdown = fs.readFileSync(source,'utf8') const sidebar = [] @@ -26,13 +25,13 @@ export function sidebar (file = 'menu.md', filter=(_)=>true) { let [, text, link ] = /^-\s*\[(.*)\]\((.*)\)/.exec(line) || /^-\s*(.*)/.exec(line) || [] if (text && filter(link)) section.items.push (item = _item({ link, text })) else { - let [, text, link ] = /^ -\s*\[(.*)\]\((.*)\)/.exec(line) || /^ -\s*(.*)/.exec(line) || [] + let [, text, link ] = /^ {2}-\s*\[(.*)\]\((.*)\)/.exec(line) || /^ {2}-\s*(.*)/.exec(line) || [] if (text && filter(link)) { (item.items ??= []).push (subitem = _item({ link, text })) item.collapsed = true } else { - let [, text, link ] = /^ -\s*\[(.*)\]\((.*)\)/.exec(line) || /^ -\s*(.*)/.exec(line) || [] + let [, text, link ] = /^ {4}-\s*\[(.*)\]\((.*)\)/.exec(line) || /^ {4}-\s*(.*)/.exec(line) || [] if (text && filter(link)) { (subitem.items ??= []).push (_item({ link, text })) subitem.collapsed = true @@ -63,5 +62,6 @@ export function nav4(sidebar) { if (process.argv[1] === import.meta.url.slice(7)) { let {inspect} = await import ('node:util') + // eslint-disable-next-line no-console console.log(inspect(sidebar('menu.md'),{depth:11,colors:true})) } diff --git a/.vitepress/theme/components/NotFound.vue b/.vitepress/theme/components/NotFound.vue index 52498b6f2..6decf4a51 100644 --- a/.vitepress/theme/components/NotFound.vue +++ b/.vitepress/theme/components/NotFound.vue @@ -23,7 +23,7 @@ import { useRoute, useData, withBase } from 'vitepress' import { onMounted, ref } from 'vue' -const { frontmatter, site } = useData() +const { site } = useData() const route = useRoute() const base = site.value.base diff --git a/.vitepress/theme/components/NotebookHint.vue b/.vitepress/theme/components/NotebookHint.vue index de88fb669..c0e4a0686 100644 --- a/.vitepress/theme/components/NotebookHint.vue +++ b/.vitepress/theme/components/NotebookHint.vue @@ -17,21 +17,19 @@