Skip to content

Commit

Permalink
Merge branch 'main' into colors
Browse files Browse the repository at this point in the history
  • Loading branch information
swaldmann authored Oct 2, 2024
2 parents 897ef90 + e1d461f commit 12a80ab
Show file tree
Hide file tree
Showing 36 changed files with 965 additions and 556 deletions.
3 changes: 2 additions & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# This files defines code ownership.

# General content
* @smahati
* @renejeglinsky
node.js/ @smahati
java/ @smahati

# Infra
.github/ @chgeo @swaldmann
Expand Down
52 changes: 52 additions & 0 deletions .github/cli/grab-cli-texts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env node

// CLI Help Extractor
// ============================
// runs "npm exec --package=<tool> -c <cmd>" to extract the command output and version
// of the latest tool version and writes it to stdout

import * as proc from 'node:child_process'
import * as util from 'node:util'

const exec = util.promisify(proc.exec)
const pkg = process.argv[2]
if (!pkg) throw new Error('Missing package')
const cmd = process.argv[3] || pkg.split('/').pop()
const cwd = process.argv[4] || process.cwd()

const toOutput = (str) => [
'<!-- this file is automatically generated and updated by a github action -->',
`<pre class="log">`,
`> ${cmd}`,
'',
str
.replace(/\n.*home.*[|:].*/g, '') // remove absolute cds home path as it's system-specific
.replace(/\<(.*?)\>/g, '&lt;$1&gt;') // <foo> -> &lt;foo&gt;
.replace(/^\x1b\[1m(.*?)\x1b\[(:?0|39|49)m\n/gm, '<strong>$1</strong>') // bold at beginning of line -> strong
.replace(/(\s*)\x1b\[4m(.*?)\x1b\[(:?0|39|49)m/g, '$1<i>$2</i>') // underline -> i
.replace(/(\s*)\x1b\[\d+m(.*?)\x1b\[(:?0|39|49)m/g, '$1<em>$2</em>') // other colors -> em
,
`</pre>`
].join('\n')

try {
const version = (await exec(`npm view ${pkg} version`)).stdout.trim()
if (!/\d+\.\d+\.\d+/.test(version)) {
throw new Error(`unexpected version: ${version}`)
}

const cmdString = `npm exec --package=${pkg}@${version} -c "${cmd}"`
// const cmdString = `${cmd}` // for local testing
console.error(`> ${cmdString}`) // use stderr for debugging output
const { stdout: cmdOut } = await exec(cmdString, {cwd, env: { FORCE_COLOR: 'true', ...process.env }})

// some very basic plausibility checks to make sure we don't
// end up with garbage or npx errors in the markdown
if (!cmdOut || !cmdOut.includes('\n')) {
throw new Error(`no or invalid output from: ${cmdString}`)
}
// result is on stdout
console.log(toOutput(cmdOut.trim(), version.trim()))
} catch (e) {
console.error(`could not generate synopsis: ${e.message}`, e)
}
20 changes: 20 additions & 0 deletions .github/cli/grab-cli-texts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash

dir=`dirname -- "$0"`

# create a temp project to run the commands in
proj=/tmp/your-project
rm -rf ${proj}
mkdir -p `dirname ${proj}`
pushd `dirname ${proj}` && cds init `basename ${proj}` && pushd `basename ${proj}` && npm i && popd && popd

echo
echo "Grabbing CLI texts..."
${dir}/grab-cli-texts.js @cap-js/cds-typer "cds-typer --help" ${proj} > ${dir}/../../tools/assets/help/cds-typer.out.md
${dir}/grab-cli-texts.js @sap/cds-dk "cds --help" ${proj} > ${dir}/../../tools/assets/help/cds-help.out.md
${dir}/grab-cli-texts.js @sap/cds-dk "cds watch --help" ${proj} > ${dir}/../../tools/assets/help/cds-watch.out.md
${dir}/grab-cli-texts.js @sap/cds-dk "cds version" ${proj} > ${dir}/../../tools/assets/help/cds-version.out.md
${dir}/grab-cli-texts.js @sap/cds-dk "cds version --markdown" ${proj} > ${dir}/../../tools/assets/help/cds-version-md.out.md
${dir}/grab-cli-texts.js @sap/cds-dk "cds env requires.db" ${proj} > ${dir}/../../tools/assets/help/cds-env-requires-db.out.md
${dir}/grab-cli-texts.js @sap/cds-dk "cds env ls requires.db" ${proj} > ${dir}/../../tools/assets/help/cds-env-ls-requires-db.out.md
${dir}/grab-cli-texts.js @sap/cds-dk "cds -e .env.requires.db" ${proj} > ${dir}/../../tools/assets/help/cds-eval-env-requires-db.out.md
60 changes: 0 additions & 60 deletions .github/renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,65 +54,5 @@
"depNameTemplate": "com.sap.cds:cds4j-api",
"datasourceTemplate": "maven",
"versioningTemplate": "maven"
},
{
"customType": "regex",
"fileMatch": ["\\.md$"],
"matchStrings": [
"<em>\\s*@sap/cds:\\s*</em>\\s*(?<currentValue>\\d+\\.\\d+\\.\\d+)",
"\\|\\s*@sap/cds\\s*\\|\\s*(?<currentValue>\\d+\\.\\d+\\.\\d+)\\s*\\|"
],
"depNameTemplate": "@sap/cds",
"datasourceTemplate": "npm"
},
{
"customType": "regex",
"fileMatch": ["\\.md$"],
"matchStrings": [
"<em>\\s*@sap/cds-compiler:\\s*</em>\\s*(?<currentValue>\\d+\\.\\d+\\.\\d+)",
"\\|\\s*@sap/cds-compiler\\s*\\|\\s*(?<currentValue>\\d+\\.\\d+\\.\\d+)\\s*\\|"
],
"depNameTemplate": "@sap/cds-compiler",
"datasourceTemplate": "npm"
},
{
"customType": "regex",
"fileMatch": ["\\.md$"],
"matchStrings": [
"<em>\\s*@sap/cds-dk:\\s*</em>\\s*(?<currentValue>\\d+\\.\\d+\\.\\d+)",
"\\|\\s*@sap/cds-dk\\s*\\|\\s*(?<currentValue>\\d+\\.\\d+\\.\\d+)\\s*\\|"
],
"depNameTemplate": "@sap/cds-dk",
"datasourceTemplate": "npm"
},
{
"customType": "regex",
"fileMatch": ["\\.md$"],
"matchStrings": [
"<em>\\s*@sap/cds-mtxs:\\s*</em>\\s*(?<currentValue>\\d+\\.\\d+\\.\\d+)",
"\\|\\s*@sap/cds-mtxs\\s*\\|\\s*(?<currentValue>\\d+\\.\\d+\\.\\d+)\\s*\\|"
],
"depNameTemplate": "@sap/cds-mtxs",
"datasourceTemplate": "npm"
},
{
"customType": "regex",
"fileMatch": ["\\.md$"],
"matchStrings": [
"<em>\\s*@sap/eslint-plugin-cds:\\s*</em>\\s*(?<currentValue>\\d+\\.\\d+\\.\\d+)",
"\\|\\s*@sap/eslint-plugin-cds\\s*\\|\\s*(?<currentValue>\\d+\\.\\d+\\.\\d+)\\s*\\|"
],
"depNameTemplate": "@sap/eslint-plugin-cds",
"datasourceTemplate": "npm"
},
{
"customType": "regex",
"fileMatch": ["\\.md$"],
"matchStrings": [
"<em>\\s*Node.js:\\s*</em>\\s*(?<currentValue>v\\d+\\.\\d+\\.\\d+)",
"\\|\\s*Node.js\\s*\\|\\s*(?<currentValue>v\\d+\\.\\d+\\.\\d+)\\s*\\|"
],
"depNameTemplate": "nodejs",
"datasourceTemplate": "node"
}
]}
46 changes: 46 additions & 0 deletions .github/typer/grab-typer-synopsis.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env node

// cds-typer Synopsis Extractor
// ============================
// runs "npx @cap-js/cds-typer --help" to extract the synopsis and version
// of the latest cds-typer version and writes it to a markdown file
// that is included in the cds-typer documentation page.

import * as fs from 'node:fs'
import * as path from 'node:path'
import * as proc from 'node:child_process'
import * as util from 'node:util'

const exec = util.promisify(proc.exec)
const tool = '@cap-js/cds-typer'
const includingFile = path.join('tools', 'cds-typer.md')
const synopsisFile = path.join('tools', 'cds-typer_help-output.md')

const toMarkdown = (version, synopsis) => [
'<!-- this file is automatically generated and updated by a github action -->',
'```log',
`> ${tool}@${version} --help`,
'',
synopsis,
'```'
].join('\n')

try {
const { stdout: version } = await exec(`npx ${tool} --version`)
const { stdout: synopsis } = await exec(`npx ${tool} --help`)

// some very basic plausibility checks to make sure we don't
// end up with garbage or npx errors in the markdown
if (!/\d+\.\d+\.\d+/.test(version)) {
throw new Error(`unexpected version: ${version}`)
}
if (!synopsis || !/SYNOPSIS/.test(synopsis)) {
throw new Error(`unexpected synopsis: ${synopsis}`)
}
if (!fs.existsSync(includingFile)) {
throw new Error(`could not find file '${includingFile}', where to include the synopsis. Has the documentation for cds-typer moved?`)
}
fs.writeFileSync(synopsisFile, toMarkdown(version.trim(), synopsis))
} catch (e) {
console.error(`could not run cds-typer to generate synopsis: ${e.message}`)
}
47 changes: 47 additions & 0 deletions .github/workflows/extract-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Update CLI Texts

on:
workflow_dispatch:
schedule:
# Runs every Wednesday at 02:45 AM (UTC)
- cron: '45 2 * * 3'

permissions:
contents: write
pull-requests: write

jobs:
run:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Extract CLI texts
run: |
npm i -g @sap/cds-dk
.github/cli/grab-cli-texts.sh
- name: Check for changes
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
if git diff --exit-code; then
echo "No changes detected. Exiting."
exit 0
fi
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: "update-cds-cli-texts"
commit-message: "Update CLI texts"
title: "chore: Update CLI texts"
body: "Updates the output of cds CLI texts to the latest version."
4 changes: 2 additions & 2 deletions .vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const redirectLinks: Record<string, string> = {}

const latestVersions = {
java_services: '3.2.0',
java_cds4j: '3.2.0'
java_cds4j: '3.3.0'
}

const localSearchOptions = {
Expand Down Expand Up @@ -105,7 +105,7 @@ const config:UserConfig<CapireThemeConfig> = {
] as DefaultTheme.NavItem[],
search: localSearchOptions,
footer: {
message: '<a href="https://www.sap.com/about/legal/impressum.html" target="_blank">Legal Disclosure</a> | <a href="https://www.sap.com/corporate/en/legal/terms-of-use.html" target="_blank">Terms of Use</a> | <a href="https://www.sap.com/about/legal/privacy.html" target="_blank">Privacy</a>',
message: `<a href="https://www.sap.com/about/legal/impressum.html" target="_blank">Legal Disclosure</a> | <a href="https://www.sap.com/corporate/en/legal/terms-of-use.html" target="_blank">Terms of Use</a> | <a href="${base}/resources/privacy" target="_blank">Privacy</a> | <a href="${base}/resources/cookies">Cookies</a>`,
copyright: `Copyright © 2019-${new Date().getFullYear()} SAP SE`
},
editLink: {
Expand Down
25 changes: 12 additions & 13 deletions .vitepress/theme/components/ShortcutsList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
</template>

<script setup>
import { computed, reactive, ref, onMounted, onUnmounted, watch } from 'vue'
import { computed, ref, onMounted, onUnmounted, watch } from 'vue'
import { useData } from 'vitepress'
const { site, theme, page } = useData()
Expand All @@ -46,7 +46,7 @@ const dialog = ref(null) // must match to ref="dialog" from template
const querySelectorSearchInput = 'input[class=search-input]'
const showHiddenCommands = ref(false)
const commands = reactive([
const commands = computed(() => [
DOMCommand('Search', 'local-search', keyStrokesSearch, false, ()=>{}), // VP search has the actual logic
DOMCommand('Toggle dark/light mode', 'VPSwitchAppearance', ['.']),
DOMCommand('Toggle Node.js or Java', 'SwitchImplVariant', ['v']),
Expand All @@ -59,16 +59,15 @@ const commands = reactive([
{ name:'Close dialog', keys:[ref('Escape')], hidden:true, run: () => visible.value = false },
])
const activeCommands = computed(() => {
return commands
.filter(cmd => (showHiddenCommands.value || !cmd.hidden) && ('enabled' in cmd ? cmd.enabled() : true))
.map(cmd => {
cmd.keyStrings = cmd.keys.map(stroke => stroke.length
? `${formattedStrokes[stroke[0].value]||stroke[0].value} ${formattedStrokes[stroke[1].value]||stroke[1].value}`
: formattedStrokes[stroke.value]||stroke.value)
return cmd
})
})
const activeCommands = computed(() => commands.value
.filter(cmd => (showHiddenCommands.value || !cmd.hidden) && ('enabled' in cmd ? cmd.enabled() : true))
.map(cmd => {
cmd.keyStrings = cmd.keys.map(stroke => stroke.length
? `${formattedStrokes[stroke[0].value]||stroke[0].value} ${formattedStrokes[stroke[1].value]||stroke[1].value}`
: formattedStrokes[stroke.value]||stroke.value)
return cmd
})
)
// Close when the user clicks anywhere outside of the dialog.
// This is not a true 'modal' behavior, but still more convenient than not.
Expand All @@ -91,7 +90,7 @@ function onKeyDown(event) {
showHiddenCommands.value = !showHiddenCommands.value
return
}
const cmd = commands.find(cmd => !!cmd.keys.find(k => k.value === event.key))
const cmd = commands.value.find(cmd => !!cmd.keys.find(k => k.value === event.key))
const enabled = cmd && cmd.run && ('enabled' in cmd ? cmd.enabled() : true)
if (enabled) {
event.preventDefault()
Expand Down
4 changes: 1 addition & 3 deletions about/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,11 @@ Following is an index of the features currently covered by CAP, with status and
| [Declared Events in CDS](../cds/cdl#events) | <X/> | <X/> | <X/> |
| Mock Broker (to speed up local dev) [[Node.js](../node.js/messaging#file-based)\|[Java](../java/messaging#local-testing)] | <Na/> | <X/> | <X/> |
| SAP Event Mesh (For single-tenant apps) [[Node.js](../node.js/messaging#event-mesh-shared)\|[Java](../java/messaging#configuring-sap-event-mesh-support)] | <Na/> | <X/> | <X/> |
| SAP Event Broker (For single-tenant apps) [[Node.js](../node.js/messaging#event-broker)] | <Na/> | <X/><br>beta<sup>1</sup> | <D/> |
| SAP Event Broker (For single-tenant apps) [[Node.js](../node.js/messaging#event-broker)] | <Na/> | <X/><br>beta | <D/> |
| Composite Messaging (routing by configuration) [[Node.js](../node.js/messaging#composite-messaging)\|[Java](../java/messaging#composite-messaging-service)] | <Na/> | <X/> | <X/> |
| Import AsyncAPI | <O/> | | |
| Export AsyncAPI | <X/> | | |

> <sup>1</sup> May be outsourced into a plugin, hence the status _beta_. <br>
<span id="events-messaging-more" />

### Database Support
Expand Down
3 changes: 2 additions & 1 deletion about/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,8 @@ Following is an excerpt of generic features provided:
- [Open Telementry → SAP Cloud Logging, Dynatrace, ...](../plugins/#telemetry)
- [Attachments → SAP Object Store](../plugins/#attachments)
- [Attachments → SAP Document Management Service](../plugins/#@cap-js/sdm)
- [Messaging → SAP Event Broker](../plugins/#event-broker)
- [Messaging → SAP Event Broker](../plugins/#event-broker-plugin)
- [Messaging → SAP Event Broker (Multitenancy)](../plugins/#event-broker-multitenancy)
- [Messaging → Kafka](../plugins/#apache-kafka)
- [Change Tracking](../plugins/#change-tracking)
- [Notifications](../plugins/#notifications)
Expand Down
2 changes: 2 additions & 0 deletions advanced/odata.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,11 @@ OData is an OASIS standard, which essentially enhances plain REST with standardi
| `$apply` | For [data aggregation](#data-aggregation) | <X/> | <X/> |
| `$expand` | Deep-read associated entities | <X/> | <X/> |
| [Lambda Operators](https://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part2-url-conventions.html#_Toc31361024) | Boolean expressions on a collection | <X/> | <X/> <sup>(2)</sup> |
| [Parameters Aliases](https://docs.oasis-open.org/odata/odata/v4.01/os/part1-protocol/odata-v4.01-os-part1-protocol.html#sec_ParameterAliases) | Replace literal value in URL with parameter alias | <X/> | <X/> <sup>(3)</sup> |

- <sup>(1)</sup> The elements to be searched are specified with the [`@cds.search` annotation](../guides/providing-services#searching-data).
- <sup>(2)</sup> The navigation path identifying the collection can only contain one segment.
- <sup>(3)</sup> Supported for key values and for parameters of functions only.

System query options can also be applied to an [expanded navigation property](https://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part2-url-conventions.html#_Toc31361039) (nested within `$expand`):

Expand Down
1 change: 1 addition & 0 deletions cds/cdl.md
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,7 @@ entity Employees {

This example is equivalent to the [unmanaged example above](#unmanaged-associations), with the foreign
key element `address_ID` being added automatically upon activation to a SQL database.
The names of the automatically added foreign key elements cannot be changed.

> Note: For adding foreign key constraints on database level, see [Database Constraints.](../guides/databases#db-constraints).
Expand Down
8 changes: 7 additions & 1 deletion guides/messaging/event-broker.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
---
# # layout: cookbook
shorty: SAP Event Broker
status: released
---

<script setup>
import { h } from 'vue'
const X = () => h('span', { class: 'ga', title: 'Available' }, [''] )
Expand Down Expand Up @@ -71,7 +77,7 @@ Configure your application to use the `event-broker` messaging service.
[Learn more about `cds.env` profiles](../../node.js/cds-env#profiles){.learn-more}

::: tip Local Testing
Since SAP Event Broker sends events via HTTP, local
Since SAP Event Broker sends events via HTTP, you won't be able to receive events on your local machine unless you use a tunneling service. Therefore we recommend to use a messaging service of kind [`local-messaging`](../../node.js/messaging#local-messaging) for local testing.
:::


Expand Down
2 changes: 1 addition & 1 deletion guides/messaging/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ The message payload is in the `data` property of the inbound `msg` object.


::: tip
To have more control over imported service definitions, you can set the `model` configuration of your external service to a cds file where you define the external service and only use the imported definitions your app needs. This way, plugins like [Open Resource Discovery (ORD)](/plugins/#ord-open-resource-discovery) know which parts of the external service you actually use in your application.
To have more control over imported service definitions, you can set the `model` configuration of your external service to a cds file where you define the external service and only use the imported definitions your app needs. This way, plugins like [Open Resource Discovery (ORD)](../../plugins/#ord-open-resource-discovery) know which parts of the external service you actually use in your application.
:::


Expand Down
Loading

0 comments on commit 12a80ab

Please sign in to comment.