Skip to content

Commit

Permalink
Merge branch 'main' into doc/typescript-build-and-facet
Browse files Browse the repository at this point in the history
  • Loading branch information
renejeglinsky committed Sep 16, 2024
2 parents c1abd25 + 49af3a3 commit aac7910
Show file tree
Hide file tree
Showing 21 changed files with 573 additions and 635 deletions.
22 changes: 0 additions & 22 deletions .eslintrc

This file was deleted.

2 changes: 2 additions & 0 deletions .github/workflows/PR-SAP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/PR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ jobs:
- run: npm ci
- run: npm test
- run: npm run docs:build
- run: npm run lint
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: /
Expand Down
17 changes: 13 additions & 4 deletions .vitepress/lib/md-typed-models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, any>, path: string, realPath: string }
type mdItEnv = { frontmatter: Record<string, any>, path: string, realPath?: string }
const modelOut = '@cds-models'

/**
Expand All @@ -30,22 +30,31 @@ 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)
}
}

return fence!(tokens, idx, options, env, ...args)
}
}

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.
if (existsSync(outPath)) return

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)
}
8 changes: 4 additions & 4 deletions .vitepress/menu.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import path from 'node:path'
import fs from 'node:fs'

import rulesSidebar from '../tools/cds-lint/sidebar.js'
Expand All @@ -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 = []
Expand All @@ -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
Expand Down Expand Up @@ -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}))
}
2 changes: 1 addition & 1 deletion .vitepress/theme/components/NotFound.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 4 additions & 6 deletions .vitepress/theme/components/NotebookHint.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,19 @@

<script setup>
import { onMounted, computed, ref } from 'vue'
import { useData, useRoute } from 'vitepress'
import { computed } from 'vue'
import { useData } from 'vitepress'
const { frontmatter, base, page, site } = useData()
const { path } = useRoute()
const { frontmatter, site } = useData()
const supportsNotebook = computed(() => !!frontmatter.value['notebook'])
const isExternal = import.meta.env.VITE_CAPIRE_ENV === 'external'
function linkNotebook($event) {
return typeof localStorage !== 'undefined' ? useNotebook($event) : () => {}
}
function useNotebook(event) {
function getNotebook(event) {
function getNotebook() {
const baseUrl = new URL(window.location);
const urlParams = new URLSearchParams(window.location.search)
const implVariant = urlParams.get('impl-variant')
Expand Down
6 changes: 3 additions & 3 deletions .vitepress/theme/components/implvariants/ImplVariants.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ function scrollTo(id) {
function currentCheckState() {
const url = new URL(window.location)
let variant = url.searchParams.get('impl-variant')
if (url.searchParams.has('impl-variant'))
return url.searchParams.get('impl-variant') === 'java'
return localStorage.getItem('impl-variant') === 'java'
Expand Down Expand Up @@ -87,7 +86,8 @@ transition: none !important;
cb()
// @ts-expect-error keep unused declaration, used to force the browser to redraw
// keep unused declaration, used to force the browser to redraw
// eslint-disable-next-line no-unused-vars
const _ = window.getComputedStyle(css).opacity
document.head.removeChild(css)
}
Expand All @@ -100,7 +100,7 @@ watchEffect(() => {
}, 20)
})
function toggleContent(variant, initial) {
function toggleContent(variant) {
const htmlClassList = document.documentElement.classList
knownImplVariants.forEach(v => htmlClassList.remove(v))
htmlClassList.add(variant)
Expand Down
63 changes: 0 additions & 63 deletions assets/concepts/_snippets/cds.cds

This file was deleted.

13 changes: 0 additions & 13 deletions assets/concepts/_snippets/http.groovy

This file was deleted.

37 changes: 0 additions & 37 deletions assets/concepts/_snippets/javascript.js

This file was deleted.

26 changes: 26 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import cds from '@sap/cds/eslint.config.mjs'
import vue from 'eslint-plugin-vue'

export default [
{
ignores: [
'**/.vitepress/dist/**',
'**/.vitepress/cache/**',
'**/.github/**'
],
},
...cds.recommended,
...vue.configs['flat/essential'],
{
files: ['*.vue', '**/*.vue'],
languageOptions: {
parserOptions: {
parser: '@typescript-eslint/parser'
},
},
rules: {
'vue/multi-word-component-names': 0,
'vue/no-v-text-v-html-on-component': 0
}
}
]
23 changes: 0 additions & 23 deletions guides/assets/actions-functions/requests.http

This file was deleted.

12 changes: 0 additions & 12 deletions guides/assets/actions-functions/services.cds

This file was deleted.

Loading

0 comments on commit aac7910

Please sign in to comment.