Skip to content

Commit

Permalink
Merge branch 'main' into revert-952-rm-cds.middlewares.after
Browse files Browse the repository at this point in the history
  • Loading branch information
sjvans authored Jan 9, 2025
2 parents 706a78a + cdbf70b commit bf95bc4
Show file tree
Hide file tree
Showing 359 changed files with 33,893 additions and 8,852 deletions.
22 changes: 0 additions & 22 deletions .eslintrc

This file was deleted.

6 changes: 4 additions & 2 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# This files defines code ownership.

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

# Infra
.github/ @chgeo @swaldmann
.vitepress/ @chgeo @swaldmann

# allow dependencies updates through renovate w/o code owners
package.json
package-lock.json
package-lock.json
2 changes: 1 addition & 1 deletion .github/cds-snippet-checker/check-cds-snippets.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ function* extractSnippets(section) {
// Code snippets may have a configuration in form of an HTML comment.
// When a cds-mode comment exists, we ignore the language.
if (snippets[1]) {
const modeRegEx = /cds-mode: ([^,]+)$/;
const modeRegEx = /cds-mode: ([^,;]+)/;
const result = modeRegEx.exec(snippets[1]);
if (result && result[1])
mode = validateMode(result[1].trim());
Expand Down
2 changes: 1 addition & 1 deletion .github/cds-snippet-checker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
"check": "node check-cds-snippets.js"
},
"dependencies": {
"@sap/cds-compiler": "^4.4"
"@sap/cds-compiler": "latest"
}
}
53 changes: 53 additions & 0 deletions .github/cli/grab-cli-texts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/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 = process.env.CDS_GLOBAL
? `${cmd}` // for local testing
: `npm exec --package=${pkg}@${version} -c "${cmd}"`
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)
}
22 changes: 22 additions & 0 deletions .github/cli/grab-cli-texts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/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 @sap/cds-dk "cds add --help" ${proj} > ${dir}/../../tools/assets/help/cds-add.out.md
${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 repl --help" ${proj} > ${dir}/../../tools/assets/help/cds-repl.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
1 change: 1 addition & 0 deletions .github/java-snippet-checker/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock.json
Loading

0 comments on commit bf95bc4

Please sign in to comment.