Skip to content

Commit

Permalink
Merge branch 'main' into launchpad-plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
DanSchlachter authored Jul 11, 2024
2 parents 626d456 + 72745d1 commit d0dfff5
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 9 deletions.
81 changes: 81 additions & 0 deletions .github/workflows/checkout
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#!/usr/bin/env node
/* eslint-disable no-console */

const [,,$1] = process.argv
const { exec } = require('child_process')
const path = require('path')
const { readFile, writeFile } = require("fs").promises;
const { join } = require("path");

async function remoteService () {
const TARGET_DIR = "xmpls/remote-service"
const levelUP = "../../"
const INCLUDES = ["srv", "test"]
const paths = INCLUDES.map(pattern => join(__dirname, levelUP, TARGET_DIR, pattern))
const cmd = `cp -r ${paths.join(' ')} ${join(__dirname, levelUP)}`
await run(cmd);

const packageJson = JSON.parse(await readFile(join(__dirname, levelUP ,"package.json"), "utf-8"));
const delta = JSON.parse(await readFile(join(__dirname, levelUP, TARGET_DIR, "package.json"), "utf-8"));
packageJson.cds.requires["API_BUSINESS_PARTNER"] = delta.cds.requires["API_BUSINESS_PARTNER"]
await writeFile(join(__dirname, levelUP, "package.json"), JSON.stringify(packageJson, null, 2), "utf-8");

// dependencies
const deps = [
"@sap-cloud-sdk/connectivity",
"@sap-cloud-sdk/http-client",
"@sap-cloud-sdk/resilience",
"@sap-cloud-sdk/util"
]
return await run(`npm add ${deps.join(" ")}`)
}

async function messaging () {
const TARGET_DIR = "xmpls/messaging"
const levelUP = "../../"
const INCLUDES = ["app", "srv", "test"]
const paths = INCLUDES.map(pattern => join(__dirname, levelUP, TARGET_DIR, pattern))
const cmd = `cp -r ${paths.join(' ')} ${join(__dirname, levelUP)}`
await run(cmd);

const packageJson = JSON.parse(await readFile(join(__dirname, levelUP, "package.json"), "utf-8"));
const delta = JSON.parse(await readFile(join(__dirname, levelUP, TARGET_DIR, "package.json"), "utf-8"));
packageJson.cds.requires["API_BUSINESS_PARTNER"] = delta.cds.requires["API_BUSINESS_PARTNER"]
packageJson.cds.requires["messaging"] = delta.cds.requires["messaging"]
await writeFile(join(__dirname, levelUP, "package.json"), JSON.stringify(packageJson, null, 2), "utf-8");

// dependencies
const deps = [
"@sap-cloud-sdk/connectivity",
"@sap-cloud-sdk/http-client",
"@sap-cloud-sdk/resilience",
"@sap-cloud-sdk/util",
"@sap/xb-msg-amqp-v100"
]
return await run(`npm add ${deps.join(" ")}`)
}

function run (cmd, silent) {
if (cmd.raw) return run (String.raw(...arguments))
if (cmd.endsWith('--silent')) silent = cmd = cmd.slice(0,-9)
if (typeof cmd === 'string') cmd = new Promise ((done,failed) => {
const cp = exec (cmd, (e,stdout) => e ? failed(e) : done(stdout))
if (!silent) {
cp.stdout.on ('data', d => process.stdout.write(d))
cp.stderr.on ('data', d => process.stderr.write(d))
}
})
return cmd
}

switch ($1) {

case 'remote-service':
remoteService();
break;
case 'messaging':
messaging();
break;
default:
console.log('Usage: ./checkout <command>');
}
4 changes: 2 additions & 2 deletions app/incidents/webapp/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</style>
<script
id="sap-ui-bootstrap"
src="https://ui5.sap.com/1.121.0/resources/sap-ui-core.js"
src="https://ui5.sap.com/1.125.1/resources/sap-ui-core.js"
data-sap-ui-theme="sap_horizon"
data-sap-ui-resourceroots='{
"ns.incidents": "./"
Expand All @@ -32,4 +32,4 @@
data-handle-validation="true"
></div>
</body>
</html>
</html>
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
"add-attachments": "npm add @cap-js/attachments && cp -r xmpls/attachments.cds ./db",
"add-notifications": "npm add @cap-js/notifications && cp xmpls/alert-notifications.js ./srv && cp xmpls/notification-types.json ./srv",
"add-audit-log": "npm add @cap-js/audit-logging && cp xmpls/data-privacy.cds ./srv && cp xmpls/audit-log.test.js ./test",
"add-remote-service": "cp -r xmpls/remote-service/* .",
"add-messaging": "cp -r xmpls/messaging/* .",
"add-remote-service": "./.github/workflows/checkout remote-service",
"add-messaging": "./.github/workflows/checkout messaging",
"add-all-xmpls": "npm run add-remote-service && npm run add-messaging && npm run add-change-tracking && npm run add-audit-log",
"reset": "read -p 'This will irreversibly reset your working directory including ALL files in this git repo. Continue?' -n 1 -r && echo && if [[ $REPLY =~ ^[Yy]$ ]]; then git clean -fd && git reset --hard && npm i; fi"
},
Expand Down
4 changes: 2 additions & 2 deletions test/audit-logging.http
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ Authorization: Basic alice:wonderland
Content-Type: application/json

{
"ID": "{{$guid}}",
"ID": "{{$randomInt 9000000 9999999}}",
"firstName": "Bob",
"lastName": "Builder",
"email": "[email protected]"
}

### Updating a customer with personal data details
@customer = {{create_customer.response.body.ID}}
PATCH {{host}}/odata/v4/admin/Customers({{customer}})
PATCH {{host}}/odata/v4/admin/Customers('{{customer}}')
Authorization: Basic alice:wonderland
Content-Type: application/json

Expand Down
1 change: 1 addition & 0 deletions xmpls/messaging/app/fields.cds
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
using from './incidents/field';
3 changes: 0 additions & 3 deletions xmpls/messaging/app/services.cds

This file was deleted.

0 comments on commit d0dfff5

Please sign in to comment.