Skip to content

Commit 70773b0

Browse files
committed
Feb Update
1 parent ebba926 commit 70773b0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+953
-726
lines changed

CHANGELOG.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
11
[
2+
{
3+
"date": "2023-02-03",
4+
"version": "3.202302.1",
5+
"Changed": [
6+
"Lazy Load dependent modules to reduce initial command processor boot time - 10x performance improvement",
7+
"CAP Upgrade to Jan 2023 - 6.5.0 version",
8+
"Switch to @json2csv/node as json2csv is abandoned",
9+
"New 'sub' command to list all active BTP Subscriptions and their URLs",
10+
"New 'btpInfo' command to list detailed information about th btp CLI target",
11+
"New 'issue' command to create GitHub issue preloaded with technical details",
12+
"version command now returns information about @sap/cds-dk, the cf cli, and the btp cli"
13+
]
14+
},
215
{
316
"date": "2023-01-17",
417
"version": "3.202301.1",

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](http://keepachangelog.com/).
66

7+
## [3.202302.1] - 2023-02-03
8+
9+
**Changed**
10+
11+
- Lazy Load dependent modules to reduce initial command processor boot time - 10x performance improvement
12+
- CAP Upgrade to Jan 2023 - 6.5.0 version
13+
- Switch to @json2csv/node as json2csv is abandoned
14+
- New 'sub' command to list all active BTP Subscriptions and their URLs
15+
- New 'btpInfo' command to list detailed information about th btp CLI target
16+
- New 'issue' command to create GitHub issue preloaded with technical details
17+
- version command now returns information about @sap/cds-dk, the cf cli, and the btp cli
18+
719
## [3.202301.1] - 2023-01-17
820

921
**Changed**

README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,25 @@ Options:
273273
274274
![bas example](https://raw.githubusercontent.com/wiki/SAP-samples/hana-developer-cli-tool-example/images/btp.gif)
275275
276+
### btpInfo
277+
278+
```shell
279+
Detailed Information about btp CLI target
280+
281+
Troubleshooting:
282+
--disableVerbose, --quiet Disable Verbose output - removes all extra outp
283+
ut that is only helpful to human readable inter
284+
face. Useful for scripting commands.
285+
[boolean] [default: false]
286+
--debug, --Debug Debug hana-cli itself by adding output of LOTS
287+
of intermediate details
288+
[boolean] [default: false]
289+
290+
Options:
291+
-o, --output, --Output Output Format for inspection
292+
[string] [choices: "tbl", "json"] [default: "tbl"]
293+
```
294+
276295
### callProcedure
277296
278297
```shell
@@ -1478,6 +1497,20 @@ Options:
14781497
ifiers ier] [boolean] [default: false]
14791498
```
14801499
1500+
### issue
1501+
1502+
```shell
1503+
Report an Issue with the hana-cli
1504+
1505+
Troubleshooting:
1506+
--disableVerbose, --quiet Disable Verbose output - removes all extra output t
1507+
hat is only helpful to human readable interface. Us
1508+
eful for scripting commands.
1509+
[boolean] [default: false]
1510+
--debug, --Debug Debug hana-cli itself by adding output of LOTS of i
1511+
ntermediate details [boolean] [default: false]
1512+
```
1513+
14811514
### libraries
14821515
14831516
```shell
@@ -1960,6 +1993,7 @@ Options:
19601993
![roles example](https://raw.githubusercontent.com/wiki/SAP-samples/hana-developer-cli-tool-example/images/roles.gif)
19611994
19621995
### sbss
1996+
19631997
```shell
19641998
hana-cli sbss List all SAP HANA Cloud SBSS service
19651999
instances in your target Space
@@ -2005,6 +2039,7 @@ Options:
20052039
--all, --al, --allSchemas Show all schemas regardless of permissions
20062040
[boolean] [default: false]
20072041
```
2042+
20082043
![schemas example](https://raw.githubusercontent.com/wiki/SAP-samples/hana-developer-cli-tool-example/images/schemas.gif)
20092044
20102045
### schemasUI
@@ -2034,6 +2069,7 @@ Options:
20342069
--all, --al, --allSchemas Show all schemas regardless of permissions
20352070
[boolean] [default: false]
20362071
```
2072+
20372073
### schemaInstances
20382074
20392075
```shell
@@ -2160,6 +2196,20 @@ Options:
21602196
21612197
![status example](https://raw.githubusercontent.com/wiki/SAP-samples/hana-developer-cli-tool-example/images/status.gif)
21622198
2199+
### sub
2200+
2201+
```shell
2202+
BTP Active Subscriptions and their URL
2203+
2204+
Troubleshooting:
2205+
--disableVerbose, --quiet Disable Verbose output - removes all extra output t
2206+
hat is only helpful to human readable interface. Us
2207+
eful for scripting commands.
2208+
[boolean] [default: false]
2209+
--debug, --Debug Debug hana-cli itself by adding output of LOTS of i
2210+
ntermediate details [boolean] [default: false]
2211+
```
2212+
21632213
### synonyms
21642214
21652215
```shell

_i18n/messages.properties

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,9 @@ errorUndefinedAction=Error: Undefined Action
215215
btpCmd=Set the target for commands for the btp CLI to the global account, a directory, or a subaccount. Commands are executed in the specified target, unless you override it using a parameter. If the specified target is part of an account hierarchy, its parents are also targeted, so that if a command is only available on a higher level, it will be executed there.
216216
btpDir=The ID of the directory to be targeted
217217
btpSa=The ID of the subaccount to be targeted
218+
btpSub=BTP Active Subscriptions and their URL
218219
btpGlobal=Global Account
220+
btpInfo=Detailed Information about btp CLI target
219221
log=Processing Log
220222
gui.conn=Connection Parameters
221223
gui.refreshConn=Refresh Connection
@@ -280,4 +282,10 @@ err.BTPNoTarget=No BTP cli Target found - are you logged in?
280282
err.BTPNoGlobalAccount=No BTP cli Global Account Target Found
281283
err.BTPNoSubAccount=No BTP cli Subaccount Target Found
282284
hc.BTPCheck=Checking at the BTP Level
283-
hc.CFCheck=Checking at the CF Level
285+
hc.CFCheck=Checking at the CF Level
286+
btp.ServerURL=btp CLI server URL
287+
btp.globalaccount=🗺️Global Account
288+
btp.folder=📂Folder
289+
btp.subaccount=🧾Sub Account
290+
btp.version=btp CLI version
291+
issue=Report an Issue with the hana-cli

bin/btp.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@
22
import * as base from '../utils/base.js'
33
import * as btp from '../utils/btp.js'
44
const colors = base.colors
5-
import { createRequire } from 'module'
6-
const require = createRequire(import.meta.url)
7-
const inquirer = require('inquirer')
8-
const TreePrompt = require('inquirer-tree-prompt')
9-
105

116
export const command = 'btp [directory] [subaccount]'
127
export const aliases = ['btpTarget', 'btptarget', 'btp']
@@ -30,13 +25,20 @@ export async function handler(argv) {
3025
}
3126
}
3227

28+
base.debug(`build inquirer prompts`)
29+
const inquirer = base.require('inquirer')
30+
const TreePrompt = base.require('inquirer-tree-prompt')
3331

3432
try {
33+
base.debug(`GetBTPGlobalAccount`)
34+
base.startSpinnerInt()
3535
var account = await btp.getBTPGlobalAccount()
36+
base.debug(account)
3637
try {
37-
console.log(`${base.bundle.getText("btpGlobal")}: ${colors.green(account.DisplayName)}`)
3838
let hierarchy = await btp.getBTPHierarchy()
3939
base.debug(hierarchy)
40+
base.stopSpinnerInt()
41+
console.log(`${base.bundle.getText("btpGlobal")}: ${colors.green(account.DisplayName)}`)
4042
inquirer.registerPrompt('tree', TreePrompt)
4143

4244
let tree = []
@@ -96,10 +98,12 @@ export async function handler(argv) {
9698

9799
export async function callBTP(prompts) {
98100
base.debug('callBTP')
101+
base.startSpinnerInt()
99102
base.debug(prompts)
100103
try {
101104
base.setPrompts(prompts)
102105
let targetOutput = await btp.setBTPSubAccount(prompts.subaccount)
106+
base.stopSpinnerInt()
103107
console.log(targetOutput)
104108

105109
return base.end()

bin/btpInfo.js

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
// @ts-check
2+
import * as base from '../utils/base.js'
3+
import * as btp from '../utils/btp.js'
4+
const colors = base.colors
5+
6+
export const command = 'btpInfo'
7+
export const aliases = ['btpinfo']
8+
export const describe = base.bundle.getText("btpInfo")
9+
10+
export const builder = base.getBuilder({
11+
output: {
12+
alias: ['o', 'Output'],
13+
choices: ["tbl", "json"],
14+
default: "tbl",
15+
type: 'string',
16+
desc: base.bundle.getText("outputType")
17+
}
18+
}, false)
19+
20+
21+
export async function handler(argv) {
22+
base.promptHandler(argv, getBTPInfo, {
23+
output: {
24+
description: base.bundle.getText("outputType"),
25+
type: 'string',
26+
// validator: /t[bl]*|s[ql]*|c[ds]?/,
27+
required: true
28+
}
29+
})
30+
}
31+
32+
export async function getBTPInfo(prompts) {
33+
base.debug('getBTPInfo')
34+
base.startSpinnerInt()
35+
base.debug(prompts)
36+
try {
37+
base.setPrompts(prompts)
38+
39+
let data = await btp.getBTPConfig()
40+
base.stopSpinnerInt()
41+
if(prompts.output === 'json'){
42+
console.log(data)
43+
}else{
44+
console.log(`${base.bundle.getText("dbx.user")}: ${colors.green(data.UserName)}`)
45+
console.log(`${base.bundle.getText("btp.ServerURL")}: ${colors.blue(data.ServerURL)}`)
46+
console.log(`${base.bundle.getText("btp.version")}: ${colors.green(data.Version)}`)
47+
for (let item of data.TargetHierarchy) {
48+
let output = ''
49+
if(item.Type === 'globalaccount'){
50+
output = base.bundle.getText("btp.globalaccount")
51+
}else if(item.Type === 'directory'){
52+
output = base.bundle.getText("btp.folder")
53+
}else if(item.Type === 'subaccount'){
54+
output = base.bundle.getText("btp.subaccount")
55+
}
56+
console.log(`${output}: ${colors.green(item.DisplayName)} ${colors.red(item.ID)}`)
57+
}
58+
}
59+
return base.end()
60+
} catch (error) {
61+
base.error(error)
62+
}
63+
}

bin/btpSubs.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// @ts-check
2+
import * as base from '../utils/base.js'
3+
import * as btp from '../utils/btp.js'
4+
const colors = base.colors
5+
6+
export const command = 'sub'
7+
export const aliases = ['subs', 'Sub', 'Subs', 'btpsub', 'btpsubs', 'btpSub', 'btpSubs', 'btpsubscriptions', 'btpSubscriptions']
8+
export const describe = base.bundle.getText("btpSub")
9+
10+
export const builder = base.getBuilder({}, false)
11+
12+
13+
export async function handler(argv) {
14+
base.promptHandler(argv, getSubs, {})
15+
}
16+
17+
export async function getSubs(prompts) {
18+
base.debug('getSubs')
19+
base.startSpinnerInt()
20+
base.debug(prompts)
21+
try {
22+
base.setPrompts(prompts)
23+
24+
let subs = await btp.getBTPSubscriptions()
25+
base.stopSpinnerInt()
26+
const subscribed = 'SUBSCRIBED'
27+
for (let item of subs.applications) {
28+
if (item.state === subscribed) {
29+
console.log(item.displayName)
30+
if (item.subscriptionUrl) {
31+
console.log(colors.blue(item.subscriptionUrl))
32+
}
33+
}
34+
}
35+
36+
return base.end()
37+
} catch (error) {
38+
base.error(error)
39+
}
40+
}

bin/cds.js

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
11
// @ts-check
22
import * as base from '../utils/base.js'
33
import * as dbInspect from '../utils/dbInspect.js'
4-
import * as swaggerUi from 'swagger-ui-express'
5-
import open from 'open'
64
import * as conn from '../utils/connections.js'
7-
import * as Server from 'http'
8-
import express from 'express'
5+
96
// @ts-ignore
107
import cds from '@sap/cds'
118

12-
import { createRequire } from 'module'
13-
const require = createRequire(import.meta.url)
14-
159
global.__xRef = []
1610

1711
export const command = 'cds [schema] [table]'
@@ -56,7 +50,7 @@ export const builder = base.getBuilder({
5650
}
5751
})
5852

59-
export function handler(argv) {
53+
export async function handler(argv) {
6054
base.promptHandler(argv, cdsBuild, {
6155
table: {
6256
description: base.bundle.getText("table"),
@@ -201,13 +195,15 @@ export async function cdsBuild(prompts) {
201195
async function cdsServerSetup(prompts, cdsSource) {
202196

203197
base.debug('cdsServerSetup')
198+
const {default:Server} = await import('http')
204199
const port = process.env.PORT || prompts.port || 3010
205200

206201
if (!(/^[1-9]\d*$/.test(port) && 1 <= 1 * port && 1 * port <= 65535)) {
207202
return base.error(`${port} ${base.bundle.getText("errPort")}`)
208203
}
209204

210205
const server = Server.createServer()
206+
const express = base.require('express')
211207
var app = express()
212208

213209
//CDS OData Service
@@ -336,7 +332,7 @@ async function cdsServerSetup(prompts, cdsSource) {
336332

337333
//Swagger UI
338334

339-
Object.defineProperty(cds.compile.to, 'openapi', { configurable: true, get: () => require('@sap/cds-dk/lib/compile/openapi') })
335+
Object.defineProperty(cds.compile.to, 'openapi', { configurable: true, get: () => base.require('@sap/cds-dk/lib/compile/openapi') })
340336
try {
341337
// @ts-ignore
342338
let metadata = await cds.compile.to.openapi(cds.parse(cdsSource), {
@@ -349,6 +345,7 @@ async function cdsServerSetup(prompts, cdsSource) {
349345
let serveOptions = {
350346
explorer: true
351347
}
348+
const swaggerUi = await import('swagger-ui-express')
352349
app.use('/api/api-docs', swaggerUi.serve, swaggerUi.setup(metadata, serveOptions))
353350

354351
app.get('/', (_, res) => res.send(getIndex(odataURL, entity)))
@@ -370,18 +367,18 @@ async function cdsServerSetup(prompts, cdsSource) {
370367

371368
//Start the Server
372369
server.on("request", app)
373-
server.listen(port, function () {
370+
server.listen(port, async () => {
374371
// @ts-ignore
375372
let serverAddr = `http://localhost:${server.address().port}`
376373
console.info(`HTTP Server: ${serverAddr}`)
377374

378375
//GraphQL
379-
const GraphQLAdapter = require('@cap-js/graphql/lib') //require('@sap/cds-graphql/lib')
376+
const GraphQLAdapter = base.require('@cap-js/graphql/lib') //require('@sap/cds-graphql/lib')
380377
const adapter = new GraphQLAdapter (cds.services, { graphiql: true, path: '/graphql' })
381378
app.use('/graphql', adapter)
382379
// app.use(new GraphQLAdapter(cds.services, { graphiql: true }))
383380
console.log("serving GraphQL endpoint for all services { at: '/graphql' }")
384-
381+
const { default:open } = await import('open')
385382
open(serverAddr)
386383
})
387384
}

0 commit comments

Comments
 (0)